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 = { [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.close(), [""] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Insert, select = true, }, [""] = 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("luasnip-expand-or-jump", true, true, true), "") else fallback() end end, { "i", "s", }), [""] = 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("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, }) configs = { pylsp = { settings = { pylsp = { plugins = { mypy = { enabled = true }, black = { enabled = true }, isort = { enabled = true, profile = "black" }, }, }, }, }, ruff_lsp = { settings = { args = {}, format = { args = { "--line-length=120", "--config", "format.quote-style = 'single'" }, }, lint = { -- args = { "--config", "lint.select = ['F', 'E']", "--config", "lint.ignore = ['E501']" } } } }, pyright = { settings = { pyright = { disableOptimizeImports = true, }, python = { analysis = { typeCheckingMode = "basic", autoImportCompletions = false, } } } } } 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", "pyright", "ruff_lsp", "ts_ls", }, handlers = { function(server_name) require('lspconfig')[server_name].setup(configs[server_name] or {}) end, } }) end }, }