nixvim-for-share/config/plugins/cmp.nix
2025-07-26 12:43:01 +00:00

66 lines
1.5 KiB
Nix

{
config,
lib,
helpers,
...
}:
let
inherit (helpers) mkRaw;
in
{
# TJ
# https://www.youtube.com/watch?v=_DnmphIwnjo
plugins = {
cmp = {
enable = true;
autoEnableSources = true;
settings = {
sources =
lib.optionals config.plugins.lsp.enable [
{ name = "nvim_lsp"; }
]
++ lib.optionals config.plugins.luasnip.enable [
{
name = "luasnip";
option = {
show_autosnippets = true;
};
}
]
++ [
{ name = "path"; }
{ name = "spell"; }
{ name = "latex_symbols"; }
{
name = "buffer";
keyword_length = 5;
}
];
mapping = mkRaw ''
cmp.mapping.preset.insert({
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<C-y>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
})
'';
snippet.expand = ''
function(args)
require('luasnip').lsp_expand(args.body)
end
'';
experimental = {
# ghost_text = true;
};
view.entries = {
name = "custom";
# selection_order = "top_down";
};
};
};
};
}