return { "neovim/nvim-lspconfig", dependencies = { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", "hrsh7th/nvim-cmp", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", "SergioRibera/cmp-dotenv", "hrsh7th/cmp-cmdline", "saadparwaiz1/cmp_luasnip", "L3MON4D3/LuaSnip", "j-hui/fidget.nvim", "rafamadriz/friendly-snippets", }, config = function() local lspconfig = require('lspconfig') local cmp = require('cmp') local luasnip = require('luasnip') -- load snippets from friendly-snippets require('luasnip.loaders.from_vscode').lazy_load() require('fidget').setup({}) require('mason').setup({}) require('mason-lspconfig').setup({ -- Replace the language servers listed here -- with the ones you want to install ensure_installed = { 'tsserver', 'lua_ls', 'gopls', 'pylsp', 'gitlab_ci_ls', 'yamlls', 'ansiblels', 'terraformls' }, handlers = { function(server_name) require('lspconfig')[server_name].setup({}) end, } }) cmp.setup({ sources = { { name = 'path' }, { name = 'nvim_lsp' }, { name = 'dotenv' }, { name = 'luasnip', keyword_length = 2 }, { name = 'buffer', keyword_length = 3 }, }, mapping = cmp.mapping.preset.insert({ -- `Enter` key to confirm completion [""] = cmp.mapping({ i = function(fallback) if cmp.visible() and cmp.get_active_entry() then cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) else fallback() end end, s = cmp.mapping.confirm({ select = true }), c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.locally_jumpable(1) then luasnip.jump(1) else fallback() end end, { "i", "s" }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.locally_jumpable(-1) then luasnip.jump(-1) else fallback() end end, { "i", "s" }), -- Ctrl+Space to trigger completion menu [''] = cmp.mapping.complete(), -- Scroll up and down in the completion documentation [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), }), snippet = { expand = function(args) require('luasnip').lsp_expand(args.body) end, }, }) local pythonLineLength = 95 lspconfig.pylsp.setup { settings = { pylsp = { plugins = { pycodestyle = { maxLineLength = pythonLineLength } } } } } lspconfig.ansiblels.setup {} end }