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

An auto-import may trigger twice when using multiple LSP servers and multiple buffers #527

Open
moussetf opened this issue May 30, 2024 · 0 comments

Comments

@moussetf
Copy link

When using multiple LSP servers for the same file type, one of which provides completions/auto-imports, and when working with multiple buffers (using set hidden), an auto-import may trigger twice.

Setup. I am using the following vimrc with VIM 9.1.16, not using any packages besides lsp:

vim9script
set hidden
var lspServers = [
	{ name: 'python-pyright', filetype: ['python'], path: 'pyright-langserver', args: ['--stdio'],
		workspaceConfig: {
			python: { pythonPath: 'python', analysis: { autoImportCompletions: true }
			}
		}
	},
	{ name: 'efm-languageserver', filetype: ['python'], path: 'efm-langserver', args: [] }
]
autocmd User LspSetup call LspAddServer(lspServers)

As you can see, I am using pyright together with a second language server defined for the python file type, which does not really do anything in this case.

Steps to reproduce. Open a new python file using vim foo.py and type some text (e.g. get_cache_) and accept the auto-import suggestion. The function get_cache_token is imported once as expected. Now open a second buffer with :e bar.py and then do the same thing (type get_cache_ and accept the auto-import suggestion). Now the same function is imported twice.

Some notes:

  1. When the second language server is not present, the issue does not appear.
  2. Although the example above uses pyright/efm-langserver, I can reproduce the same issue with other combinations of LSP servers (I have also tested pyright/pylsp and typescript-language-server/efm-langserver for the typescript filetype). So this seems like it is not connected to a particular LSP server.

I believe this is a different issue than #522.

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

1 participant