This commit is contained in:
meml0rz
2024-11-12 23:06:28 +01:00
parent 7f18d2d772
commit ea13297b18
2 changed files with 34 additions and 102 deletions

View File

@ -8,13 +8,28 @@
enable = true; enable = true;
autoEnableSources = true; autoEnableSources = true;
settings = { settings = {
sources = [ mapping = {
{name = "nvim_lsp";} "<C-Space>" = "cmp.mapping.complete()";
{name = "path";} "<C-d>" = "cmp.mapping.scroll_docs(-4)";
{name = "buffer";} "<C-e>" = "cmp.mapping.close()";
{name = "luasnip";} "<C-f>" = "cmp.mapping.scroll_docs(4)";
"<CR>" = "cmp.mapping.confirm({ select = true })";
"<S-Tab>" = {
action = "cmp.mapping.select_prev_item()";
modes = [
"i"
"s"
];
};
"<Tab>" = {
action = "cmp.mapping.select_next_item()";
modes = [
"i"
"s"
]; ];
}; };
}; };
}; };
};
};
} }

View File

@ -20,101 +20,18 @@
vim.opt.smartindent = true vim.opt.smartindent = true
vim.opt.softtabstop = 4 vim.opt.softtabstop = 4
vim.opt.numbers = true; vim.opt.numbers = true;
vim.cmd [[
cnoreabbrev W! w!
# cmp cnoreabbrev Q! q!
return { cnoreabbrev Qall! qall!
{ cnoreabbrev Wq wq
"hrsh7th/nvim-cmp", cnoreabbrev Wa wa
dependencies = { cnoreabbrev wQ wq
'hrsh7th/cmp-nvim-lsp', cnoreabbrev WQ wq
'hrsh7th/cmp-buffer', cnoreabbrev W w
'hrsh7th/cmp-path', cnoreabbrev Q q
'hrsh7th/cmp-cmdline', cnoreabbrev Qall qall
'hrsh7th/cmp-nvim-lua', ]]
'hrsh7th/cmp-calc',
'f3fora/cmp-spell',
'hrsh7th/cmp-emoji',
'saadparwaiz1/cmp_luasnip',
'L3MON4D3/LuaSnip',
{
'windwp/nvim-autopairs',
event = "InsertEnter",
config = true
},
},
config = function()
local cmp = require("cmp")
vim.opt.completeopt = { "menu", "menuone", "noinsert", "noselect" }
cmp.setup({
sorting = {
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.recently_used,
require("clangd_extensions.cmp_scores"),
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
window = {
completion = {
autocomplete = true,
col_offset = -3,
side_padding = 0,
},
},
mapping = cmp.mapping.preset.insert({
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "s" }),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<C-Left>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = false }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'nvim_lua' },
{ name = 'calc' },
{ name = 'spell' },
{ name = 'emoji' },
{ name = 'crates' },
}),
highlight = {
default = "Subtle"
};
})
end
},
}
''; '';
}; };
} }