hrsh7th / vim-vsnip

Snippet plugin for vim/nvim that supports LSP/VSCode's snippet format.
MIT License
876 stars 37 forks source link

Snippets not loaded under macro #260

Closed bandithijo closed 1 year ago

bandithijo commented 1 year ago

Hi, First of all, thank you for your hard work on the plugin. I have been using it since migrating into init.lua since 10 months ago. This plugin, very makes my work a lot easier.

Today, I'm just realized that snippets not loaded under macro. This is the demo that I have recorded.

Without Macro macro_off

With Macro macro_on

I'm not sure, this problem rise because of my config or plugin.

This is the list of my plugin that relates to vim-vsnip.

-- snippet
use 'hrsh7th/cmp-vsnip'
use 'hrsh7th/vim-vsnip'
use 'hrsh7th/vim-vsnip-integ'

-- snippet exsample
use 'rafamadriz/friendly-snippets'

And this is the config that I used.

vim.cmd [[
" NOTE: You can use other key to expand snippet.

" Expand
imap <expr> <C-j>   vsnip#expandable()  ? '<Plug>(vsnip-expand)'         : '<C-j>'
smap <expr> <C-j>   vsnip#expandable()  ? '<Plug>(vsnip-expand)'         : '<C-j>'

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

" Jump forward or backward
imap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)'      : '<Tab>'
smap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)'      : '<Tab>'
imap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)'      : '<S-Tab>'
smap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)'      : '<S-Tab>'

" Select or cut text to use as $TM_SELECTED_TEXT in the next snippet.
" See https://github.com/hrsh7th/vim-vsnip/pull/50
nmap        s   <Plug>(vsnip-select-text)
xmap        s   <Plug>(vsnip-select-text)
nmap        S   <Plug>(vsnip-cut-text)
xmap        S   <Plug>(vsnip-cut-text)

" If you want to use snippet for multiple filetypes, you can `g:vsnip_filetypes` for it.
let g:vsnip_filetypes = {}
let g:vsnip_filetypes.javascriptreact = ['javascript']
let g:vsnip_filetypes.typescriptreact = ['typescript']
]]

Neovim version v0.8.1 vim-vsnip last commit hash e44026b5 cmp-vsnip last commit hash 989a8a73

Best Regards & Thank you.

hrsh7th commented 1 year ago

The nvim-cmp doesn't support macro. So the completion is disabled in macro by default.