1
0
Fork 0

module(neovim): update cmp and lsp

This commit is contained in:
Antoine Langlois 2024-03-31 13:25:29 +02:00
parent 7912b43b8a
commit ac08547f59
Signed by: DataHearth
GPG Key ID: 946E2D0C410C7B3D
4 changed files with 51 additions and 45 deletions

View File

@ -46,29 +46,35 @@ in
};
keymaps = import ./keymaps;
plugins = {
diffview.enable = true;
chadtree.enable = true;
leap.enable = true;
nix.enable = true;
cmp = import ./plugins/cmp.nix { lib = lib; };
cmp-buffer.enable = true;
cmp-cmdline.enable = true;
cmp-nvim-lsp.enable = true;
cmp-path.enable = true;
cmp_luasnip.enable = true;
comment.enable = true;
todo-comments.enable = true;
copilot-cmp.enable = true;
copilot-lua = import ./plugins/copilot-lua.nix;
crates-nvim.enable = true;
dashboard = import ./plugins/dashboard.nix;
diffview.enable = true;
gitsigns = import ./plugins/gitsigns.nix;
illuminate.enable = true;
indent-blankline = import ./plugins/indent-blankline.nix;
leap.enable = true;
lsp = import ./plugins/lsp.nix;
lspkind.enable = true;
lualine.enable = true;
luasnip.enable = true;
nix.enable = true;
nvim-autopairs.enable = true;
illuminate.enable = true;
copilot-cmp.enable = true;
cmp_luasnip.enable = true;
cmp-nvim-lsp.enable = true;
cmp-cmdline.enable = true;
cmp-path.enable = true;
cmp-buffer.enable = true;
crates-nvim.enable = true;
treesitter.enable = true;
telescope = import ./plugins/telescope.nix;
todo-comments.enable = true;
treesitter.enable = true;
trouble = import ./plugins/trouble.nix;
indent-blankline = import ./plugins/indent-blankline.nix;
dashboard = import ./plugins/dashboard.nix;
gitsigns = import ./plugins/gitsigns.nix;
# Custom
harpoon = {
enable = true;
package = pkgs.vimUtils.buildVimPlugin {
@ -81,15 +87,6 @@ in
};
};
};
# Completion
lsp = import ./plugins/lsp.nix;
## CMP
cmp = import ./plugins/cmp.nix;
### Thirdparties
copilot-lua = import ./plugins/copilot-lua.nix;
};
};
};

View File

@ -1,3 +1,4 @@
{ lib, ... }:
{
enable = true;
settings = {
@ -6,6 +7,7 @@
"<CR>" = "cmp.mapping.confirm({ select = false })";
"<S-Tab>" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})";
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
"<C-e>" = "cmp.mapping(cmp.mapping.abort(), {'i', 's'})";
};
sources = [
{ name = "nvim_lsp"; }
@ -24,5 +26,25 @@
require('luasnip').lsp_expand(args.body)
end
'';
formatting = {
fields = [ "kind" "abbr" "menu" ];
format = lib.mkForce ''
function(entry, vim_item)
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. (strings[1] or "") .. " "
kind.menu = " (" .. (strings[2] or "") .. ")"
return kind
end
'';
};
window = {
completion = {
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None";
col_offset = -3;
side_padding = 0;
};
};
};
}

View File

@ -1,20 +0,0 @@
{ vimUtils, fetchFromGithub }:
{
enable = true;
package = vimUtils.buildVimPlugins {
pname = "harpoon";
version = "26-01-2024";
src = fetchFromGithub {
owner = "ThePrimeagen";
repo = "harpoon";
rev = "a38be6e0dd4c6db66997deab71fc4453ace97f9c";
hash = "sha256-XXXXXXXXXXXXX";
};
};
enableTelescope = true;
keymaps = {
navNext = "<C-hn>";
navPrev = "<C-hp>";
toggleQuickMenu = "<C-e>";
};
}

View File

@ -21,4 +21,11 @@
tsserver.enable = true;
yamlls.enable = true;
};
keymaps = {
lspBuf = {
"<S-k>" = "hover";
"<leader>f" = "format";
"<leader>a" = "code_action";
};
};
}