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;
autoEnableSources = true;
settings = {
sources = [
{name = "nvim_lsp";}
{name = "path";}
{name = "buffer";}
{name = "luasnip";}
mapping = {
"<C-Space>" = "cmp.mapping.complete()";
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-e>" = "cmp.mapping.close()";
"<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.softtabstop = 4
vim.opt.numbers = true;
# cmp
return {
{
"hrsh7th/nvim-cmp",
dependencies = {
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
'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
},
}
vim.cmd [[
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
]]
'';
};
}