Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E565: Not allowed to change text or change window when triggering omnicompletion with a language server that doesn't support completion #205

Open
heygarrett opened this issue Jun 22, 2023 · 1 comment

Comments

@heygarrett
Copy link

When triggering omnicompletion with a language server that doesn't support completion a helpful message is displayed:

method textDocument/completion is not supported by any of the servers registered for the current buffer

But when nvim-notify is installed it causes an error instead:

E5108: Error executing lua ....repro/plugins/nvim-notify/lua/notify/render/default.lua:18: E565: Not allowed to change text or change window
stack traceback:
        [C]: in function 'nvim_buf_set_lines'
        ....repro/plugins/nvim-notify/lua/notify/render/default.lua:18: in function 'render'
        ...o/plugins/nvim-notify/lua/notify/service/buffer/init.lua:107: in function 'render'
        ...g/.repro/plugins/nvim-notify/lua/notify/service/init.lua:53: in function 'push'
        ...onfig/.repro/plugins/nvim-notify/lua/notify/instance.lua:77: in function 'notify'
        ...w/Cellar/neovim/0.9.1/share/nvim/runtime/lua/vim/lsp.lua:1963: in function 'buf_request'
        ...w/Cellar/neovim/0.9.1/share/nvim/runtime/lua/vim/lsp.lua:2140: in function <...w/Cellar/neovim/0.9.1/share/nvim/runtime/lua/vim/lsp.lua:2113>

Minimal repro.lua config:

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({
		"git",
		"clone",
		"--filter=blob:none",
		"https://github.com/folke/lazy.nvim.git",
		lazypath,
	})
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
	"folke/tokyonight.nvim",
	-- add any other plugins here
	"https://github.com/nvim-lua/plenary.nvim",
	{
		"https://github.com/jose-elias-alvarez/null-ls.nvim",
		config = function()
			local null_ls = require("null-ls")
			null_ls.setup({
				sources = {
					null_ls.builtins.diagnostics.fish,
				},
			})
		end,
	},
	{
		"https://github.com/rcarriga/nvim-notify",
		config = function() vim.notify = require("notify") end,
	},
}
require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
vim.o.number = true

Steps to reproduce:

  1. The config needs a language server that doesn't support completion. I chose null-ls with the fish diagnostics source.
  2. nvim -u repro.lua config.fish (I'm using a fish file)
  3. Enter insert mode, type some text and then <c-x><c-o>

Expected behavior:

The helpful LSP message would be displayed

Actual behavior:

Error

Additional info:

NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3

system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.1/share/nvim"

Run :checkhealth for more info

@heygarrett heygarrett changed the title E565: Not allow to change text or change window when triggering omnicompletion with a language server that doesn't support completion E565: Not allowed to change text or change window when triggering omnicompletion with a language server that doesn't support completion Jun 23, 2023
@wookayin
Copy link

wookayin commented Oct 10, 2023

I think nvim-notify's default implementation should be improved in a way that if vim is in the fast event, it should defer the execution.

A workaround would be:

-vim.notify = require("notify")
+vim.notify = vim.schedule_wrap(require("notify"))

BTW it may have some unwanted consequence, e.g., the ordering of async events can be slightly different than the invocation was made, due to vim.schedule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants