modify nixvim

- add config for nixd
- fix luasnip call func in cmp
- enable autocomplete in cmp- cmdline
- add cmp-cmdline mapping
This commit is contained in:
Sam 2024-10-23 22:34:35 +01:00
parent 71ac9901dd
commit bd3f24056e
2 changed files with 17 additions and 17 deletions

View File

@ -3,6 +3,7 @@
cmp-emoji = { enable = true; };
cmp = {
enable = true;
cmdline = {};
settings = {
autoEnableSources = true;
experimental = { ghost_text = true; };
@ -11,7 +12,7 @@
fetchingTimeout = 200;
maxViewEntries = 30;
};
snippet = { expand = "luasnip"; };
snippet = { expand = "function(args) require('luasnip').lsp_expand(args.body) end"; };
formatting = {
fields = [ "kind" "abbr" "menu" ];
format = ''
@ -43,14 +44,10 @@
};
mapping = {
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
"<C-j>" = "cmp.mapping.select_next_item()";
"<C-k>" = "cmp.mapping.select_prev_item()";
"<C-e>" = "cmp.mapping.abort()";
"<S-Tab>" = "cmp.mapping.select_prev_item()";
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-Space>" = "cmp.mapping.complete()";
"<CR>" = "cmp.mapping.confirm({ select = true })";
"<S-CR>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })";
};
};
};
@ -58,7 +55,7 @@
cmp-buffer = { enable = true; };
cmp-path = { enable = true; }; # file system paths
cmp_luasnip = { enable = true; }; # snippets
cmp-cmdline = { enable = false; }; # autocomplete for cmdline
cmp-cmdline = { enable = true; }; # autocomplete for cmdline
};
programs.nixvim.extraConfigLua = ''
luasnip = require("luasnip")
@ -94,22 +91,15 @@
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({'/', "?" }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ name = 'buffer' },
})
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {

View File

@ -4,7 +4,17 @@
enable = true;
servers = {
lua-ls = {enable = true;};
nixd = {enable = true;};
nixd = {
enable = true;
cmd = ["nixd"];
settings = {
nixpkgs.expr = "import <nixpkgs> { }";
options = {
nixos.expr = "(builtins.getFlake ('git+file://' + toString ./.)).nixosConfigurations.k-on.options";
home_manager.expr = "(builtins.getFlake ('git+file://' + toString ./.)).homeConfigurations.'ruixi@k-on'.options";
};
};
};
bashls = {enable = true;};
pyright = {enable = true;};
html = {enable = true;};