completion-nvim icon indicating copy to clipboard operation
completion-nvim copied to clipboard

Snippet expands with TM message

Open ChrisAmelia opened this issue 4 years ago • 4 comments

image

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

  1. 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;
	}

}
  1. Open the file with:
nvim -u init.vim Test.java
  1. Place the cursor below error this is not a valid code; and type if to display the snippet completion menu.

  2. Select one of the snippets proposed, there should be 4 snippets:

image

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.

ChrisAmelia avatar Oct 16 '20 14:10 ChrisAmelia

Will this still happen when using the newest commit?

haorenW1025 avatar Oct 22 '20 05:10 haorenW1025

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.

hrsh7th avatar Oct 22 '20 05:10 hrsh7th

Or vim-lamp just use completion_item.label as completed_item.word when the item is snippet kind.

hrsh7th avatar Oct 22 '20 05:10 hrsh7th

Will this still happen when using the newest commit?

Yes, it still happens.

ChrisAmelia avatar Oct 22 '20 08:10 ChrisAmelia