neovim: support choice nodes for luasnip

Also turn on short keys for moving between windows
This commit is contained in:
FollieHiyuki 2021-09-04 18:16:28 +07:00
parent af695b83db
commit ac38c5dcc9
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
2 changed files with 34 additions and 5 deletions

View File

@ -38,10 +38,10 @@ wk.register({
L = {'$', 'End of the line'},
-- Easier moving between windows
-- ['<C-h>'] = {'<C-w>h', 'Go to the left window'},
-- ['<C-l>'] = {'<C-w>l', 'Go to the right window'},
-- ['<C-j>'] = {'<C-w>j', 'Go to the down window'},
-- ['<C-k>'] = {'<C-w>k', 'Go to the up window'},
['<C-h>'] = {'<C-w>h', 'Go to the left window'},
['<C-l>'] = {'<C-w>l', 'Go to the right window'},
['<C-j>'] = {'<C-w>j', 'Go to the down window'},
['<C-k>'] = {'<C-w>k', 'Go to the up window'},
-- Copy the whole buffer
['<C-a>'] = {'<Cmd>%y+<CR>', 'Copy whole buffer'},

View File

@ -70,6 +70,21 @@ function M.cmp_conf()
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-e>'] = cmp.mapping.close(),
-- Change choice nodes for luasnip
['<C-h>'] = cmp.mapping(function(fallback)
if luasnip.choice_active() then
vim.fn.feedkeys(t('<Plug>luasnip-prev-choice'), '')
else
fallback()
end
end, {'i', 's'}),
['<C-l>'] = cmp.mapping(function(fallback)
if luasnip.choice_active() then
vim.fn.feedkeys(t('<Plug>luasnip-next-choice'), '')
else
fallback()
end
end, {'i', 's'}),
-- supertab-like mapping
['<Tab>'] = cmp.mapping(function(fallback)
if vim.fn.pumvisible() == 1 then
@ -123,9 +138,23 @@ function M.autopairs_conf()
end
function M.snippets_conf()
local types = require('luasnip.util.types')
require('luasnip').config.set_config({
updateevents = 'TextChanged, TextChangedI',
history = true
history = true,
ext_opts = {
[types.choiceNode] = {
active = {
virt_text = {{'', 'Number'}}
}
},
[types.insertNode] = {
active = {
virt_text = {{'', 'Keyword'}}
}
}
}
})
-- Loading vscode-like snippets from 'friendly-snippets'