diff options
author | Hirokazu Hata <h.hata.ai.t@gmail.com> | 2020-02-18 13:38:52 +0900 |
---|---|---|
committer | Hirokazu Hata <h.hata.ai.t@gmail.com> | 2020-02-19 07:27:29 +0900 |
commit | 4ac376740c85ee337fc10627a793452300801ce0 (patch) | |
tree | 9f1331f76a0708fbe697ae797398cfce20f96e40 /runtime/lua/vim/lsp/callbacks.lua | |
parent | e2ed8053bf722d4d111fac7dcdb07179fdea8752 (diff) | |
download | rneovim-4ac376740c85ee337fc10627a793452300801ce0.tar.gz rneovim-4ac376740c85ee337fc10627a793452300801ce0.tar.bz2 rneovim-4ac376740c85ee337fc10627a793452300801ce0.zip |
lsp: fix textDocument/completion handling
fix: #11826
Some lanuguage servers return complementary candidates whose prefixes do not match are also returned.
So we exclude completion candidates whose prefix does not match.
ex) Microsoft python-language-server, rust-analyzer
Diffstat (limited to 'runtime/lua/vim/lsp/callbacks.lua')
-rw-r--r-- | runtime/lua/vim/lsp/callbacks.lua | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/callbacks.lua b/runtime/lua/vim/lsp/callbacks.lua index 794140ee2e..e76e07ca96 100644 --- a/runtime/lua/vim/lsp/callbacks.lua +++ b/runtime/lua/vim/lsp/callbacks.lua @@ -63,8 +63,9 @@ M['textDocument/completion'] = function(_, _, result) local line = assert(api.nvim_buf_get_lines(0, row-1, row, false)[1]) local line_to_cursor = line:sub(col+1) local textMatch = vim.fn.match(line_to_cursor, '\\k*$') + local prefix = line_to_cursor:sub(textMatch+1) - local matches = util.text_document_completion_list_to_complete_items(result) + local matches = util.text_document_completion_list_to_complete_items(result, prefix) vim.fn.complete(textMatch+1, matches) end |