Skip to content

Commit

Permalink
terminal/editors/neovim: disable some completions on large buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Jul 10, 2024
1 parent 1c07a72 commit e514fdf
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions modules/home/programs/terminal/editors/neovim/plugins/cmp.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
_: {
_:
let
get_bufnrs.__raw = # lua
''
function()
local buf_size_limit = 1024 * 1024 -- 1MB size limit
local bufs = vim.api.nvim_list_bufs()
local valid_bufs = {}
for _, buf in ipairs(bufs) do
if vim.api.nvim_buf_is_loaded(buf) and vim.api.nvim_buf_get_offset(buf, vim.api.nvim_buf_line_count(buf)) < buf_size_limit then
table.insert(valid_bufs, buf)
end
end
return valid_bufs
end
'';
in
{
programs.nixvim = {
opts.completeopt = [
"menu"
Expand Down Expand Up @@ -39,18 +56,30 @@ _: {
{
name = "nvim_lsp";
priority = 1000;
option = {
inherit get_bufnrs;
};
}
{
name = "nvim_lsp_signature_help";
priority = 1000;
option = {
inherit get_bufnrs;
};
}
{
name = "nvim_lsp_document_symbol";
priority = 1000;
option = {
inherit get_bufnrs;
};
}
{
name = "treesitter";
priority = 850;
option = {
inherit get_bufnrs;
};
}
{
name = "luasnip";
Expand All @@ -63,9 +92,9 @@ _: {
{
name = "buffer";
priority = 500;
# Words from other open buffers can also be suggested.
option.get_bufnrs.__raw = # lua
"vim.api.nvim_list_bufs";
option = {
inherit get_bufnrs;
};
}
{
name = "path";
Expand Down

0 comments on commit e514fdf

Please sign in to comment.