refactor: reorganize post-configuration functions into utils module
This commit is contained in:
+36
-4
@@ -57,6 +57,17 @@ return { -- cmp
|
||||
}
|
||||
luasnip.config.setup({})
|
||||
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
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 = {
|
||||
expand = function(args)
|
||||
@@ -78,14 +89,33 @@ return { -- cmp
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-y>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-Space>"] = cmp.mapping.complete({}),
|
||||
["<Tab>"] = cmp.mapping(function()
|
||||
if luasnip.expand_or_locally_jumpable() then
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
-- cmp.confirm({ select = true })
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif vim.snippet.active({ direction = 1 }) then
|
||||
vim.schedule(function()
|
||||
vim.snippet.jump(1)
|
||||
end)
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function()
|
||||
if luasnip.locally_jumpable(-1) then
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
elseif vim.snippet.active({ direction = -1 }) then
|
||||
vim.schedule(function()
|
||||
vim.snippet.jump(-1)
|
||||
end)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
@@ -98,8 +128,10 @@ return { -- cmp
|
||||
{ name = "dotenv" },
|
||||
{ name = "calc" },
|
||||
{ name = "conventionalcommits" },
|
||||
{ name = "nerd", priority = 9997 },
|
||||
{ name = "gitmoji", priority = 9998 },
|
||||
{ name = "emoji", priority = 9999 },
|
||||
{ name = "math", priority = 9999 },
|
||||
},
|
||||
formatting = {
|
||||
fields = { "abbr", "kind", "menu" },
|
||||
|
||||
Reference in New Issue
Block a user