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

Support for completionItem/resolve requests #13199

Open
mhartington opened this issue Oct 31, 2020 · 0 comments
Open

Support for completionItem/resolve requests #13199

mhartington opened this issue Oct 31, 2020 · 0 comments
Labels
completion Nvim built-in (omni)completion enhancement feature request lsp

Comments

@mhartington
Copy link
Contributor

  • nvim --version: NVIM v0.5.0-787-g98024853f
NVIM v0.5.0-787-g98024853f
Build type: Debug
LuaJIT 2.1.0-beta3
Compilation: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -g -Wal
l -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fs
tack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_
HAS_VAR_FROM -DMIN_LOG_LEVEL=1 -I/Users/mhartington/Github/neovim-org/neovim/build/config -I/Users/mhartington/Github/neovim-org/neovim/src -I/Users
/mhartington/Github/neovim-org/neovim/.deps/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX
10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/Users/mhartington/Github/neovim-org/neovim/build/src/nvim/auto -I/Users/mhartington/Github
/neovim-org/neovim/build/include
Compiled by mhartington@Michaels-MBP.fios-router.home

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/Users/mhartington/bin/nvim/share/nvim"

Run :checkhealth for more info
  • language server name/version: n/a
  • Operating system/version: macOS 10.15
nvim -c ":checkhealth nvim nvim_lsp"
health#nvim_lsp#check
========================================================================
## Checking language server protocol configuration
  - INFO: html: configuration checked.
  - INFO: tsserver: configuration checked.
  - INFO: cssls: configuration checked.
  - INFO: sumneko_lua: configuration checked.
  - INFO: pyls_ms: configuration checked.
  - INFO: vimls: configuration checked.
  - INFO: bashls: configuration checked.
  - INFO: vuels: configuration checked.
  - INFO: jsonls: configuration checked.


Not so much a bug, but a feature request for LSP. When completion is done, LSP can provide additional context about a completion item (either on selection change or completion "done") and provide things like docs or additional text edits.

Right now nothing is setup here to call completionItem/resolve in neovim itself. Other options are to have users provide their own customized callback function, which could be fine. Just wanted to raise the topic in case others were interested.

PR in LanguageClient: autozimu/LanguageClient-neovim#1043
Implementation in vim-lsp: https://github.com/prabirshrestha/vim-lsp/blob/master/autoload/lsp/ui/vim/completion.vim#L63

Spec for completion: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion

@mhartington mhartington added bug issues reporting wrong behavior lsp labels Oct 31, 2020
@bfredl bfredl added enhancement feature request and removed bug issues reporting wrong behavior labels Dec 2, 2020
@mjlbach mjlbach added this to Triage in LSP integration via automation Nov 1, 2021
@mjlbach mjlbach moved this from Triage to 0.8 to-dos in LSP integration Nov 1, 2021
jeremija added a commit to jeremija/dotfiles that referenced this issue May 16, 2023
And any server that suppors it like `typescript-language-server`.

The `rust-analyzer` supports auto imports, but it does not provide them
the `additionalTextEdits` with each completion entry. They state that
that's too costly, so the LSP client should call the
`completionItem/resolve` RPC call after completion is done for the
required edits to be calculated only once[1].

I found an old GitHub issue on Neovim that hasn't been completed yet
[2], and a relevant PR has not been merged yet [3].

Then I found a Reddit thread that provided an implementation that
_almost_ worked [4]. There were two issues with the sample
implementation in Neovim 0.9.0:

1. The `result` callback argument was third, but it actually needed to be
   second.

2. This version of Neovim requires a third parameter to
   `vim.lsp.util.apply_text_edits` (`offset_encoding`)

For LSPs like `gopls` which don't support it yet, the quickfix dialog
can still be used (or `goimports`) , but it ends up being a two-step
operation.

[1]: https://rust-analyzer.github.io/manual.html#auto-import
[2]: neovim/neovim#13199
[3]: neovim/neovim#13414
[4]: https://www.reddit.com/r/neovim/comments/mn8ipa/lsp_add_missing_imports_on_complete_using_the/
@justinmk justinmk added the completion Nvim built-in (omni)completion label Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completion Nvim built-in (omni)completion enhancement feature request lsp
Projects
LSP integration
0.8 to-dos (Completion, extensibility)
Development

No branches or pull requests

3 participants