246 lines
7.8 KiB
Nix
246 lines
7.8 KiB
Nix
{
|
|
plugins = {
|
|
friendly-snippets = {
|
|
enable = true;
|
|
};
|
|
luasnip = {
|
|
enable = true;
|
|
extraConfig = {
|
|
enable_autosnippets = true;
|
|
store_selection_keys = "<Tab>";
|
|
};
|
|
fromLua = [
|
|
{ paths = ../../snippets; }
|
|
];
|
|
};
|
|
lspkind = {
|
|
enable = true;
|
|
symbolMap = {
|
|
Namespace = "";
|
|
Text = "";
|
|
Method = "";
|
|
Function = "";
|
|
Constructor = "";
|
|
Field = "";
|
|
Variable = "";
|
|
Class = "";
|
|
Interface = "";
|
|
Module = "";
|
|
Property = "";
|
|
Unit = "";
|
|
Value = "";
|
|
Enum = "";
|
|
Keyword = "";
|
|
Snippet = "";
|
|
Color = "";
|
|
File = "";
|
|
Reference = "";
|
|
Folder = "";
|
|
EnumMember = "";
|
|
Constant = "";
|
|
Struct = "";
|
|
Event = "";
|
|
Operator = "";
|
|
TypeParameter = "";
|
|
Table = "";
|
|
Object = "";
|
|
Tag = "";
|
|
Array = "[]";
|
|
Boolean = "";
|
|
Number = "";
|
|
Null = "";
|
|
String = "";
|
|
Calendar = "";
|
|
Watch = "";
|
|
Package = "";
|
|
Codeium = "";
|
|
Copilot = "";
|
|
TabNine = "";
|
|
};
|
|
};
|
|
cmp = {
|
|
enable = true;
|
|
autoEnableSources = true;
|
|
settings = {
|
|
snippet.expand = ''
|
|
function(args)
|
|
require('luasnip').lsp_expand(args.body)
|
|
end
|
|
'';
|
|
completion.completeopt = "menu,preview";
|
|
sources = [
|
|
{ name = "luasnip"; }
|
|
{ name = "nvim_lsp"; }
|
|
{ name = "nvim_lsp_signature_help"; }
|
|
{ name = "nvim_lsp_document_symbol"; }
|
|
{ name = "codeium"; }
|
|
{ name = "path"; }
|
|
{ name = "buffer"; }
|
|
{ name = "treesitter"; }
|
|
];
|
|
mapping = {
|
|
__raw = ''
|
|
cmp.mapping.preset.insert({
|
|
['<C-n>'] = cmp.mapping({
|
|
c = function()
|
|
if cmp.visible() then
|
|
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
|
else
|
|
vim.api.nvim_feedkeys(t('<Down>'), 'n', true)
|
|
end
|
|
end,
|
|
i = function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
|
else
|
|
fallback()
|
|
end
|
|
end
|
|
}),
|
|
['<C-p>'] = cmp.mapping({
|
|
c = function()
|
|
if cmp.visible() then
|
|
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
|
|
else
|
|
vim.api.nvim_feedkeys(t('<Up>'), 'n', true)
|
|
end
|
|
end,
|
|
i = function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
|
|
else
|
|
fallback()
|
|
end
|
|
end
|
|
}),
|
|
['<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'}),
|
|
['<C-e>'] = cmp.mapping({ i = cmp.mapping.close(), c = cmp.mapping.close() }),
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
['<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'}),
|
|
["<Tab>"] = cmp.mapping({
|
|
c = function()
|
|
if cmp.visible() then
|
|
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
|
|
else
|
|
cmp.complete()
|
|
end
|
|
end,
|
|
i = function(fallback)
|
|
local has_words_before = function()
|
|
local 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
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif require('luasnip').expand_or_jumpable() then
|
|
require('luasnip').expand_or_jump()
|
|
elseif has_words_before() then
|
|
cmp.complete()
|
|
else
|
|
fallback()
|
|
end
|
|
end,
|
|
s = function(fallback)
|
|
local has_words_before = function()
|
|
local 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
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif require('luasnip').expand_or_jumpable() then
|
|
require('luasnip').expand_or_jump()
|
|
elseif has_words_before() then
|
|
cmp.complete()
|
|
else
|
|
fallback()
|
|
end
|
|
end
|
|
}),
|
|
["<S-Tab>"] = cmp.mapping({
|
|
c = function()
|
|
if cmp.visible() then
|
|
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Insert })
|
|
else
|
|
cmp.complete()
|
|
end
|
|
end,
|
|
i = function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
elseif require('luasnip').jumpable(-1) then
|
|
require('luasnip').jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end,
|
|
s = function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
elseif require('luasnip').jumpable(-1) then
|
|
require('luasnip').jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end
|
|
}),
|
|
})
|
|
'';
|
|
};
|
|
};
|
|
cmdline = {
|
|
"/" = {
|
|
sources = [
|
|
{
|
|
name = "buffer";
|
|
}
|
|
];
|
|
};
|
|
":" = {
|
|
completion.completeopt = "menu,menuone,noselect";
|
|
mapping = {
|
|
__raw = ''
|
|
cmp.mapping.preset.cmdline({
|
|
["<CR>"] = cmp.mapping.confirm { select = true },
|
|
})
|
|
'';
|
|
};
|
|
sources = [
|
|
{
|
|
name = "path";
|
|
}
|
|
{
|
|
name = "cmdline";
|
|
}
|
|
];
|
|
};
|
|
"?" = {
|
|
mapping = {
|
|
completion.completeopt = "menu,menuone,noselect";
|
|
__raw = "cmp.mapping.preset.cmdline({
|
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
['<C-e>'] = cmp.mapping.abort(),
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
})";
|
|
};
|
|
sources = [
|
|
{
|
|
name = "cmdline";
|
|
ignoreCmds = [
|
|
"Man"
|
|
"!"
|
|
];
|
|
}
|
|
];
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|