vim-vsnip icon indicating copy to clipboard operation
vim-vsnip copied to clipboard

Selection always miss the last character

Open AgentCosmic opened this issue 4 years ago • 6 comments

For example:

for (let index = 0; index < array.length; index++) {
	const element = array[index];
	
}

My first selection will be inde, but not index. Then I jump to next position arra, again missing the y. I'm using it with nvim-cmp. Neovim 5.1 Windows.

AgentCosmic avatar Oct 12 '21 06:10 AgentCosmic

Please minimal reproducible steps.

hrsh7th avatar Oct 12 '21 06:10 hrsh7th

This is my init.vim

" This is the folder where we'll store all the files
" set environment variable $env:XDG_CONFIG_HOME="D:/Applications/Neovim"
let $ROOT = expand('D:/Applications/Neovim/nvim')
set runtimepath+=$ROOT
" we reset $HOME directory here so plugins won't dirty our real home directory
let $HOME = $ROOT . '/home'

runtime mswin.vim

call plug#begin('$HOME/plugged')
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
Plug 'rafamadriz/friendly-snippets' " snippets
call plug#end()


" nvim-cmp
set completeopt=menu,menuone,noselect
lua << EOF
local cmp = require'cmp'
cmp.setup({
	mapping = {
		['<tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }),
		['<s-tab>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 's' }),
		['<c-space>'] = cmp.mapping.complete(),
		['<cr>'] = cmp.mapping.confirm({ select = true }),
		['<c-d>'] = cmp.mapping.scroll_docs(-4),
		['<c-f>'] = cmp.mapping.scroll_docs(4),
	},
	sources = {
		{ name = 'vsnip' },
	},
	snippet = {
		expand = function(args)
			vim.fn["vsnip#anonymous"](args.body)
		end,
	},
})
EOF

" vsnip
imap <expr> <c-s-n>   vsnip#available(1)  ? '<Plug>(vsnip-expand-or-jump)' : '<c-s-n>'
smap <expr> <c-s-n>   vsnip#available(1)  ? '<Plug>(vsnip-expand-or-jump)' : '<c-s-n>'

I open any javascript/typescript/python/css file. Then I type something like for and choose the snippet. But I noticed after working for a while, sometimes the selection works correctly.

AgentCosmic avatar Oct 13 '21 12:10 AgentCosmic

Hello, is there anything I can help you to debug this more easily?

AgentCosmic avatar Nov 01 '21 03:11 AgentCosmic

Same issuse happens to me. vim8.2 in Windows.

{
  "Class": {
    "prefix": ["let"],
    "body": [
      "let ${1:name} = $0"
    ]
  }
}

After triggered: 搜狗截图20211218230044

Expect: 搜狗截图20211218230222

JimmyHuang454 avatar Dec 18 '21 15:12 JimmyHuang454

@JimmyHuang454 I think the name will replace to a If you press a with After triggered: condition. If so It's expected behavior.

hrsh7th avatar Dec 18 '21 15:12 hrsh7th

I am new to vsnip, just starting in today. And I just want vsnip works as ultisnips: 动画

the first let in the gif is triggered by vsnip, the second one is triggered by ultisnips.

My vimrc:

Plug 'hrsh7th/vim-vsnip'

let g:vsnip_snippet_dir = 'D:/Vim/test_snip'

" Expand or jump
imap <expr> <C-l>   vsnip#available(1)  ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>'

JimmyHuang454 avatar Dec 18 '21 16:12 JimmyHuang454