Add completion and basic lsp config to nixvim

This commit is contained in:
2025-07-07 00:39:19 +02:00
parent 407f943102
commit 88998315d3
4 changed files with 111 additions and 12 deletions
@@ -0,0 +1,66 @@
{
programs.nixvim = {
opts.completeopt = ["menu" "menuone" "noselect"];
plugins = {
luasnip.enable = true;
cmp-nvim-lsp.enable = true;
cmp-nvim-lsp-signature-help.enable = true;
lspkind = {
enable = true;
cmp = {
enable = true;
menu = {
nvim_lsp = "[LSP]";
nvim_lua = "[api]";
path = "[path]";
luasnip = "[snip]";
buffer = "[buffer]";
};
};
extraOptions = {
mode = "symbol";
};
};
cmp = {
enable = true;
autoEnableSources = true;
settings = {
snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end";
mapping = {
"<C-p>" = "cmp.mapping.select_prev_item()";
"<C-n>" = "cmp.mapping.select_next_item()";
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-e>" = "cmp.mapping.close()";
"<C-y>" = "cmp.mapping.confirm({ select = true })";
"<CR>" = "cmp.mapping.confirm({ select = true })";
"<C-Space>" = "cmp.mapping.complete()";
"<C-l>" = ''cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, {'i', 's'})'';
"<C-h>" = ''cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, {'i', 's'})'';
};
sources = [
{ name = "nvim_lsp"; }
{ name = "luasnip"; }
{ name = "path"; }
];
};
};
};
};
}
@@ -1,5 +1,7 @@
{ pkgs, ... }: {
imports = [
./cmp.nix
./lsp.nix
./treesitter.nix
./lualine.nix
./nvim-autopairs.nix
@@ -0,0 +1,31 @@
{
programs.nixvim = {
plugins = {
lsp = {
enable = true;
keymaps = {
silent = true;
lspBuf = {
"gd" = "definition";
"gD" = "declaration";
"gr" = "references";
"gI" = "implementation";
"<leader>ca" = "code_action";
"<leader>D" = "type_definition";
"<leader>rn" = "rename";
};
};
servers = {
lua_ls.enable = true;
nil_ls.enable = true;
pyright.enable = true;
};
};
lsp-format = {
enable = true;
};
};
};
}