120 lines
3.3 KiB
Lua
120 lines
3.3 KiB
Lua
return {
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
event = "InsertEnter",
|
|
dependencies = {
|
|
{ "L3MON4D3/LuaSnip" },
|
|
},
|
|
config = function()
|
|
require("lsp-zero.cmp").extend()
|
|
local cmp = require("cmp")
|
|
local cmp_action = require("lsp-zero.cmp").action()
|
|
|
|
cmp.setup({
|
|
completion = {
|
|
completeopt = "menu,menuone",
|
|
},
|
|
mapping = {
|
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
|
["<C-c>"] = cmp.mapping.close(),
|
|
["<CR>"] = cmp.mapping.confirm {
|
|
behavior = cmp.ConfirmBehavior.Insert,
|
|
select = true,
|
|
},
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif require("luasnip").expand_or_jumpable() then
|
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
|
|
else
|
|
fallback()
|
|
end
|
|
end, {
|
|
"i",
|
|
"s",
|
|
}),
|
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
elseif require("luasnip").jumpable(-1) then
|
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
|
|
else
|
|
fallback()
|
|
end
|
|
end, {
|
|
"i",
|
|
"s",
|
|
}),
|
|
},
|
|
sources = {
|
|
{ name = "nvim_lsp" },
|
|
{ name = "luasnip" },
|
|
{ name = "buffer" },
|
|
{ name = "nvim_lua" },
|
|
{ name = "path" },
|
|
},
|
|
})
|
|
end,
|
|
},
|
|
-- LSP
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
cmd = "LspInfo",
|
|
event = { "BufReadPre", "BufNewFile" },
|
|
dependencies = {
|
|
{ "hrsh7th/cmp-nvim-lsp" },
|
|
{ "williamboman/mason-lspconfig.nvim" },
|
|
{ "williamboman/mason.nvim" },
|
|
{ "VonHeikemen/lsp-zero.nvim", }
|
|
},
|
|
config = function()
|
|
local lsp_zero = require('lsp-zero')
|
|
|
|
local lsp_attach = function(client, bufnr)
|
|
-- this is where you enable features that only work
|
|
-- if there is a language server active in the file
|
|
end
|
|
|
|
lsp_zero.extend_lspconfig({
|
|
sign_text = true,
|
|
lsp_attach = lsp_attach,
|
|
})
|
|
|
|
require('mason').setup({})
|
|
require('mason-lspconfig').setup({
|
|
-- Replace the language servers listed here
|
|
-- with the ones you want to install
|
|
ensure_installed = {
|
|
"lua_ls",
|
|
"gopls",
|
|
"pylsp",
|
|
"ruff_lsp",
|
|
"ts_ls",
|
|
},
|
|
handlers = {
|
|
function(server_name)
|
|
lsp_config = {}
|
|
|
|
if server_name == "pylsp" then
|
|
lsp_config = {
|
|
settings = {
|
|
pylsp = {
|
|
plugins = {
|
|
mypy = { enabled = true },
|
|
black = { enabled = true },
|
|
isort = { enabled = true, profile = "black" },
|
|
},
|
|
},
|
|
},
|
|
}
|
|
end
|
|
|
|
require('lspconfig')[server_name].setup(lsp_config)
|
|
end,
|
|
}
|
|
})
|
|
end
|
|
},
|
|
}
|