mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-11-16 15:01:37 +01:00
update cmp config with jump to completion fields
This commit is contained in:
parent
aa647c8255
commit
d9a0c946cd
1 changed files with 17 additions and 1 deletions
|
@ -1,4 +1,10 @@
|
|||
local cmp = require "cmp"
|
||||
local luasnip = require "luasnip"
|
||||
|
||||
local function has_words_before()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match "%s" == nil
|
||||
end
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
|
@ -11,7 +17,17 @@ cmp.setup {
|
|||
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
|
||||
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
|
||||
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
|
||||
["<Tab>"] = cmp.mapping(cmp.mapping.select_next_item()),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(cmp.mapping.select_prev_item()),
|
||||
["<CR>"] = cmp.mapping.confirm { select = true },
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue