completion-nvim
completion-nvim copied to clipboard
Snippet expands with TM message
My testing minimal init.vim
set runtimepath^=~/.local/share/nvim/plugged/nvim-lspconfig
set runtimepath^=~/.local/share/nvim/plugged/completion-nvim
set runtimepath^=~/.local/share/nvim/plugged/vim-vsnip
set runtimepath^=~/.local/share/nvim/plugged/vim-vsnip-integ
let g:completion_enable_snippet = 'vim-vsnip'
lua << EOF
local nvim_lsp = require 'nvim_lsp'
local root_pattern = nvim_lsp.util.root_pattern
local on_attach_vim = function(client)
require'completion'.on_attach(client)
end
require'nvim_lsp'.jdtls.setup{
root_dir = root_pattern(".git", "pom.xml"),
on_attach = on_attach_vim,
}
EOF
How to reproduce
- Create a file
Test.java
with:
public class Test {
public static void main(String[] args) {
// the beneath line might not be necessary,
// I've managed to reproduce the error without it
error this is not a valid code;
}
}
- Open the file with:
nvim -u init.vim Test.java
-
Place the cursor below
error this is not a valid code;
and typeif
to display the snippet completion menu. -
Select one of the snippets proposed, there should be 4 snippets:
The above error doesn't always to appear, it seems to be quite erratic but testing the 4 options should make it happen.
Expected behavior TM message doesn't appear.
Will this still happen when using the newest commit?
I think it's neovim or completion-nvim's problem.
The completion-nvim will extract completed_item.word that cleaned by vim.lsp.util.parse_snippet
.
But vim.lsp.util.parse_snippet
is
- It does not treat
$TM_SELECTED_TEXT
, etc. - It does not treat
\n
In coc.nvim, the extracting completed_item.word by getValidWord
utility (https://github.com/neoclide/coc.nvim/blob/9f9d8a32c4669ba6895e801812c60153b94e22dd/src/util/complete.ts#L77)
When the completion_item.insertText
is method($1, $2)$0
, the getValidWord
will extract method
.
Or vim-lamp just use completion_item.label
as completed_item.word
when the item is snippet kind.
Will this still happen when using the newest commit?
Yes, it still happens.