asyncomplete-lsp.vim icon indicating copy to clipboard operation
asyncomplete-lsp.vim copied to clipboard

Duplicate functions are being returned in React

Open jsit opened this issue 3 years ago • 2 comments

Doesn't seem to happen when you first start typing something; only after going into insert mode, then back into normal mode, then back into insert mode again.

Minimal .vimrc:

set nocompatible
filetype indent on
filetype plugin on
syntax on
set runtimepath=~/.vim/bundle/asyncomplete.vim,~/.vim/bundle/asyncomplete-lsp.vim,~/.vim/bundle/vim-lsp,$VIMRUNTIME

set completeopt+=menuone

if exists("asyncomplete#enable_for_buffer()") 
  autocmd BufEnter * call asyncomplete#enable_for_buffer()
endif

if executable('typescript-language-server')
	au User lsp_setup call lsp#register_server({
				\ 'name': 'javascript support using typescript-language-server',
				\ 'cmd': { server_info->[&shell, &shellcmdflag, 'typescript-language-server --stdio']},
				\ 'root_uri': { server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_directory(lsp#utils#get_buffer_path(), '.git/..'))},
				\ 'allowlist': ['javascript', 'javascript.jsx', 'javascriptreact']
				\ })
endif
Screen Shot 2020-08-26 at 3 51 00 PM

Replaces prabirshrestha/vim-lsp#894

jsit avatar Aug 26 '20 20:08 jsit

The value of data being passed here seems to have duplicate values in some cases:

https://github.com/prabirshrestha/asyncomplete-lsp.vim/blob/684c34453db9dcbed5dbf4769aaa6521530a23e0/plugin/asyncomplete-lsp.vim#L82

jsit avatar Aug 26 '20 20:08 jsit

I don't have an answer and I'm still a noob at Vim, but I wanted to +1. I've been seeing the same thing and chalked it up to my configurations being hacked together with duct tape.

It wasn't until today when I realized there's something more fundamental going on after trying to use LspCodeAction and was getting duplicate results: image (This is happening almost across the board, I would say. For example, my diagnostics do the same thing)

This is my current configuration -- everything else I pretty much copied from vim-lsp.

if executable('rust-analyzer')
    au User lsp_setup call lsp#register_server({
                \   'name': 'Rust Analyzer',
                \   'cmd': {server_info->['rust-analyzer']},
                \   'whitelist': ['rust'],
                \   'initialization_options': {
                \       'checkOnSave': { 'command': 'clippy', 'enable': v:true },
                \   },
                \ })
endif

What I noticed is one of the results comes from the name setting, and the other from rust-analyzer. Maybe it's of no consequence :man_shrugging: Just pattern matching over here.

P.S. -- if I can help improve the tool with my limited experience, please let me know. Happy to try!

P.P.S. -- Changing the name key to match rust-analyzer fixed this problem for me! Holy cow! I enabled logging to catch the logs as they were happening. I now no longer see duplicates in practice as well. I guess it's noteworthy a lot of the non-rust examples I looked at gopls and pylsp used matching values! Configuration now looks like this

if executable('rust-analyzer')
    au User lsp_setup call lsp#register_server({
                \   'name': 'rust-analyzer',
                \   'cmd': {server_info->['rust-analyzer']},
                \   'whitelist': ['rust'],
                \   'initialization_options': {
                \       'checkOnSave': { 'command': 'clippy', 'enable': v:true },
                \   },
                \ })
endif

yusuphisms avatar Nov 21 '22 04:11 yusuphisms