Skip to content

Commit ac820b4

Browse files
committed
feat: cmp
1 parent def3d45 commit ac820b4

File tree

5 files changed

+149
-15
lines changed

5 files changed

+149
-15
lines changed

config/cmp.nix

Lines changed: 118 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,121 @@
11
{
2-
plugins.cmp = {
3-
enable = true;
4-
autoEnableSources = true;
2+
plugins = {
3+
cmp-emoji = { enable = true; };
4+
cmp = {
5+
enable = true;
6+
settings = {
7+
autoEnableSources = true;
8+
experimental = { ghost_text = true; };
9+
performance = {
10+
debounce = 60;
11+
fetchingTimeout = 200;
12+
maxViewEntries = 30;
13+
};
14+
snippet = { expand = "luasnip"; };
15+
formatting = { fields = [ "kind" "abbr" "menu" ]; };
16+
sources = [
17+
{ name = "nvim_lsp"; }
18+
{ name = "emoji"; }
19+
{
20+
name = "buffer"; # text within current buffer
21+
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
22+
keywordLength = 3;
23+
}
24+
{ name = "copilot"; }
25+
{
26+
name = "path"; # file system paths
27+
keywordLength = 3;
28+
}
29+
{
30+
name = "luasnip"; # snippets
31+
keywordLength = 3;
32+
}
33+
];
34+
35+
window = {
36+
completion = { border = "solid"; };
37+
documentation = { border = "solid"; };
38+
};
39+
40+
mapping = {
41+
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
42+
"<C-j>" = "cmp.mapping.select_next_item()";
43+
"<C-k>" = "cmp.mapping.select_prev_item()";
44+
"<C-e>" = "cmp.mapping.abort()";
45+
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
46+
"<C-f>" = "cmp.mapping.scroll_docs(4)";
47+
"<C-Space>" = "cmp.mapping.complete()";
48+
"<CR>" = "cmp.mapping.confirm({ select = true })";
49+
"<S-CR>" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })";
50+
};
51+
};
52+
};
53+
cmp-nvim-lsp = { enable = true; }; # lsp
54+
cmp-buffer = { enable = true; };
55+
cmp-path = { enable = true; }; # file system paths
56+
cmp_luasnip = { enable = true; }; # snippets
57+
cmp-cmdline = { enable = false; }; # autocomplete for cmdline
558
};
6-
7-
plugins.cmp-buffer.enable = true;
59+
extraConfigLua = ''
60+
luasnip = require("luasnip")
61+
kind_icons = {
62+
Text = "󰊄",
63+
Method = "",
64+
Function = "󰡱",
65+
Constructor = "",
66+
Field = "",
67+
Variable = "󱀍",
68+
Class = "",
69+
Interface = "",
70+
Module = "󰕳",
71+
Property = "",
72+
Unit = "",
73+
Value = "",
74+
Enum = "",
75+
Keyword = "",
76+
Snippet = "",
77+
Color = "",
78+
File = "",
79+
Reference = "",
80+
Folder = "",
81+
EnumMember = "",
82+
Constant = "",
83+
Struct = "",
84+
Event = "",
85+
Operator = "",
86+
TypeParameter = "",
87+
}
88+
89+
local cmp = require'cmp'
90+
91+
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
92+
cmp.setup.cmdline({'/', "?" }, {
93+
sources = {
94+
{ name = 'buffer' }
95+
}
96+
})
97+
98+
-- Set configuration for specific filetype.
99+
cmp.setup.filetype('gitcommit', {
100+
sources = cmp.config.sources({
101+
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
102+
}, {
103+
{ name = 'buffer' },
104+
})
105+
})
106+
107+
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
108+
cmp.setup.cmdline(':', {
109+
sources = cmp.config.sources({
110+
{ name = 'path' }
111+
}, {
112+
{ name = 'cmdline' }
113+
}),
114+
-- formatting = {
115+
-- format = function(_, vim_item)
116+
-- vim_item.kind = cmdIcons[vim_item.kind] or "FOO"
117+
-- return vim_item
118+
-- end
119+
-- }
120+
}) '';
8121
}

config/copilot.nix

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
{
2-
plugins = {
3-
#copilot-lua.enable = true;
4-
#copilot-cmp.enable = true;
5-
copilot-vim = {
6-
enable = true;
7-
settings = {
8-
filetypes = { "*" = true; };
9-
};
10-
};
2+
plugins.copilot-cmp = {
3+
enable = true;
114
};
5+
plugins.copilot-lua = {
6+
enable = true;
7+
suggestion = { enabled = false; };
8+
panel = { enabled = false; };
9+
};
10+
11+
extraConfigLua = ''
12+
require("copilot").setup({
13+
suggestion = { enabled = false },
14+
panel = { enabled = false },
15+
})
16+
'';
1217
}

config/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
./keymaps.nix
1010
./lsp.nix
1111
./lualine.nix
12+
./luasnip.nix
1213
./markdown.nix
1314
./neo-tree.nix
1415
./telescope.nix

config/lsp.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
jsonls.enable = true;
1616
lua-ls.enable = true;
1717
# nixd.enable = true;
18-
nil_ls.enable = true;
18+
nil-ls.enable = true;
1919
ruff-lsp.enable = true;
2020
rust-analyzer = {
2121
enable = true;

config/luasnip.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{ pkgs, ... }: {
2+
plugins.luasnip = {
3+
enable = true;
4+
extraConfig = {
5+
enable_autosnippets = true;
6+
store_selection_keys = "<Tab>";
7+
};
8+
fromVscode = [
9+
{
10+
lazyLoad = true;
11+
paths = "${pkgs.vimPlugins.friendly-snippets}";
12+
}
13+
];
14+
};
15+
}

0 commit comments

Comments
 (0)