neovim-dotfiles/lua/plugins/nvim-cmp.lua
2025-10-08 21:24:37 +02:00

79 lines
1.8 KiB
Lua

return {
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-nvim-lua",
"neovim/nvim-lspconfig",
"mtoohey31/cmp-fish",
"petertriho/cmp-git",
},
config = function()
local cmp = require("cmp")
cmp.setup({
sources = {
{
name = "lazydev",
group_index = 0, -- set group index to 0 to skip loading LuaLS completions
},
{ name = "nvim_lua" },
{
name = "nvim_lsp",
entry_filter = function(entry, ctx)
local kind = require("cmp.types").lsp.CompletionItemKind[entry:get_kind()]
if kind == "Text" then
return false
end
return true
end,
},
{ name = "neorg" },
{ name = "fish" },
},
snippet = {
expand = function(args)
-- You need Neovim v0.10 to use vim.snippet
vim.snippet.expand(args.body)
end,
},
cmp.setup.filetype("gitcommit", {
sources = cmp.config.sources({
{ name = "git" },
}, {
{ name = "buffer" },
}),
}),
require("cmp_git").setup({}),
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
["<C-Space>"] = cmp.mapping.complete(),
["<S-NL>"] = cmp.mapping.scroll_docs(-4),
["<C-S-K>"] = cmp.mapping.scroll_docs(-4),
[" "] = cmp.mapping.confirm(),
}),
})
end,
},
{
"folke/lazydev.nvim",
ft = "lua", -- only load on lua files
config = function()
local lazydev = require("lazydev")
require("lazydev").setup()
vim.lsp.enable("lua_ls")
vim.lsp.config("lua_ls", {
root_dir = function(bufnr, on_dir)
on_dir(lazydev.find_workspace(bufnr))
end,
})
end,
},
}