Skip to content

bug: NES throws error "attempt to get length of a nil value" when editing a scratch/in-memory buffer #86

@pbnj-dragon

Description

@pbnj-dragon

Did you check docs and existing issues?

  • I have read all the sidekick.nvim docs
  • I have updated the plugin to the latest version before submitting this issue
  • I have searched the existing issues of sidekick.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.11.4

Operating system/version

macOS 26.0.1

Describe the bug

When editing a scratch/in-memory buffer, NES throws error:

Error executing vim.schedule lua callback: .../share/nvim/lazy/sidekick.nvim/lua/sidekick/nes/init.lua:200: attempt to get length of a nil value
stack traceback:
        .../share/nvim/lazy/sidekick.nvim/lua/sidekick/nes/init.lua:200: in function 'fix_pos'
        .../share/nvim/lazy/sidekick.nvim/lua/sidekick/nes/init.lua:187: in function 'handler'
        .../neovim/0.11.4/share/nvim/runtime/lua/vim/lsp/client.lua:682: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Steps To Reproduce

  1. Start neovim: nvim -u repro.lua
  2. Set the filetype: set ft=bash
  3. Insert for and accept the snippet
  4. In the first cursor position, type foo then hit TAB
  5. Error message appears

Expected Behavior

NES does not throw error in scratch/in-memory buffers

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
	spec = {
		{ "folke/sidekick.nvim", opts = {} },
		{
			"https://github.com/saghen/blink.cmp",
			dependencies = { "https://github.com/rafamadriz/friendly-snippets" },
			version = "1.*",
			---@module 'blink.cmp'
			---@type blink.cmp.Config
			opts = {
				keymap = {
					["<Tab>"] = {
						"snippet_forward",
						function() -- sidekick next edit suggestion
							return require("sidekick").nes_jump_or_apply()
						end,
						-- function() -- if you are using Neovim's native inline completions
						--   return vim.lsp.inline_completion.get()
						-- end,
						"fallback",
					},
				},
				appearance = { nerd_font_variant = "mono" },
				completion = {
					documentation = { auto_show = false },
					list = { selection = { preselect = false, auto_insert = true } },
				},
				sources = { default = { "lsp", "path", "snippets", "buffer" } },
				fuzzy = { implementation = "prefer_rust_with_warning" },
			},
			opts_extend = { "sources.default" },
		},
		{
			"https://github.com/neovim/nvim-lspconfig",
			event = "VeryLazy",
			dependencies = {
				{ "https://github.com/saghen/blink.cmp" },
			},
			config = function()
				vim.lsp.set_log_level("OFF")
				-- local capabilities = vim.tbl_deep_extend("force", {}, vim.lsp.protocol.make_client_capabilities())
				local servers = {
					-- misc
					bashls = {},
					copilot = {},
				}
				for server_name, server_config in pairs(servers) do
					server_config.capabilities = require("blink.cmp").get_lsp_capabilities(server_config.capabilities)
					vim.lsp.config(server_name, server_config)
					vim.lsp.enable(server_name)
				end
			end,
		},
	},
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions