2024-06-04 11:47:56 +01:00
|
|
|
{
|
|
|
|
programs.nixvim.plugins = {
|
|
|
|
cmp-emoji = { enable = true; };
|
|
|
|
cmp = {
|
|
|
|
enable = true;
|
2024-10-23 22:34:35 +01:00
|
|
|
cmdline = {};
|
2024-06-04 11:47:56 +01:00
|
|
|
settings = {
|
|
|
|
autoEnableSources = true;
|
|
|
|
experimental = { ghost_text = true; };
|
|
|
|
performance = {
|
|
|
|
debounce = 60;
|
|
|
|
fetchingTimeout = 200;
|
|
|
|
maxViewEntries = 30;
|
|
|
|
};
|
2024-10-23 22:34:35 +01:00
|
|
|
snippet = { expand = "function(args) require('luasnip').lsp_expand(args.body) end"; };
|
2024-06-04 11:47:56 +01:00
|
|
|
formatting = {
|
|
|
|
fields = [ "kind" "abbr" "menu" ];
|
2024-06-05 12:30:55 +01:00
|
|
|
format = ''
|
|
|
|
function(entry, vim_item)
|
|
|
|
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind)
|
|
|
|
vim_item.menu = ({
|
|
|
|
nvim_lsp = "[LSP]",
|
|
|
|
nvim_lua = "[Lua]",
|
|
|
|
luasnip = "[Snippet]",
|
|
|
|
buffer = "[Buffer]",
|
|
|
|
path = "[Path]",
|
|
|
|
["vim-dadbod-completion"] = "[SQL-dadbod]"
|
|
|
|
})[entry.source.name]
|
|
|
|
return vim_item
|
|
|
|
end,
|
|
|
|
'';
|
2024-06-04 11:47:56 +01:00
|
|
|
};
|
|
|
|
sources = [
|
|
|
|
{ name = "nvim_lsp"; }
|
|
|
|
{ name = "nvim_lua"; }
|
|
|
|
{ name = "luasnip"; }
|
|
|
|
{ name = "buffer"; }
|
|
|
|
{ name = "path"; }
|
|
|
|
{ name = "vim-dadbod-completion"; }
|
|
|
|
];
|
|
|
|
window = {
|
|
|
|
completion = { border = "solid"; };
|
|
|
|
documentation = { border = "solid"; };
|
|
|
|
};
|
|
|
|
mapping = {
|
|
|
|
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
|
2024-10-23 22:34:35 +01:00
|
|
|
"<S-Tab>" = "cmp.mapping.select_prev_item()";
|
2024-06-04 11:47:56 +01:00
|
|
|
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
|
|
|
|
"<C-f>" = "cmp.mapping.scroll_docs(4)";
|
|
|
|
"<CR>" = "cmp.mapping.confirm({ select = true })";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
cmp-nvim-lsp = { enable = true; }; # lsp
|
|
|
|
cmp-buffer = { enable = true; };
|
|
|
|
cmp-path = { enable = true; }; # file system paths
|
|
|
|
cmp_luasnip = { enable = true; }; # snippets
|
2024-10-23 22:34:35 +01:00
|
|
|
cmp-cmdline = { enable = true; }; # autocomplete for cmdline
|
2024-06-04 11:47:56 +01:00
|
|
|
};
|
|
|
|
programs.nixvim.extraConfigLua = ''
|
|
|
|
luasnip = require("luasnip")
|
|
|
|
kind_icons = {
|
|
|
|
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 = "",
|
|
|
|
}
|
|
|
|
|
|
|
|
local cmp = require'cmp'
|
|
|
|
|
|
|
|
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
|
|
|
cmp.setup.cmdline({'/', "?" }, {
|
2024-10-23 22:34:35 +01:00
|
|
|
mapping = cmp.mapping.preset.cmdline(),
|
2024-06-04 11:47:56 +01:00
|
|
|
sources = {
|
|
|
|
{ name = 'buffer' }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
|
|
|
cmp.setup.cmdline(':', {
|
2024-10-23 22:34:35 +01:00
|
|
|
mapping = cmp.mapping.preset.cmdline(),
|
2024-06-04 11:47:56 +01:00
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = 'path' }
|
|
|
|
}, {
|
|
|
|
{ name = 'cmdline' }
|
|
|
|
}),
|
|
|
|
}) '';
|
|
|
|
}
|