mirror of
https://github.com/traxys/Nixfiles.git
synced 2026-05-01 00:31:42 +02:00
68 lines
2.1 KiB
Nix
68 lines
2.1 KiB
Nix
{
|
|
extraConfigLuaPre = ''
|
|
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
|
|
local luasnip = require("luasnip")
|
|
'';
|
|
|
|
plugins.cmp = {
|
|
enable = true;
|
|
|
|
settings = {
|
|
snippet.expand = ''
|
|
function(args)
|
|
require('luasnip').lsp_expand(args.body)
|
|
end
|
|
'';
|
|
mapping = {
|
|
"<CR>" = "cmp.mapping.confirm({select = true })";
|
|
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
|
|
"<C-f>" = "cmp.mapping.scroll_docs(4)";
|
|
"<C-Space>" = "cmp.mapping.complete()";
|
|
"<Tab>" = # lua
|
|
''
|
|
cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
|
-- they way you will only jump inside the snippet region
|
|
elseif luasnip.expand_or_locally_jumpable() then
|
|
luasnip.expand_or_jump()
|
|
elseif has_words_before() then
|
|
cmp.complete()
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" })
|
|
'';
|
|
"<S-Tab>" = # lua
|
|
''
|
|
cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
elseif luasnip.jumpable(-1) then
|
|
luasnip.jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" })
|
|
'';
|
|
"<Down>" = "cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), {'i'})";
|
|
"<Up>" = "cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), {'i'})";
|
|
};
|
|
|
|
sources = [
|
|
{ name = "luasnip"; }
|
|
{ name = "nvim_lsp"; }
|
|
{ name = "path"; }
|
|
{ name = "buffer"; }
|
|
{ name = "calc"; }
|
|
{ name = "git"; }
|
|
{ name = "omni"; }
|
|
];
|
|
};
|
|
};
|
|
}
|