return { 'neovim/nvim-lspconfig', tag = 'v1.0.0', 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', { 'towolf/vim-helm', ft = 'helm' }, { 'folke/lazydev.nvim', ft = 'lua', -- only load on lua files opts = { library = { -- See the configuration section for more details -- Load luvit types when the `vim.uv` word is found { path = '${3rd}/luv/library', words = { 'vim%.uv' } }, }, }, }, }, 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 = { 'ts_ls', 'lua_ls', 'gopls', 'pylsp', 'gitlab_ci_ls', 'yamlls', 'ansiblels', 'terraformls', 'helm_ls', 'marksman', }, handlers = { function(server_name) local capabilities = require('cmp_nvim_lsp').default_capabilities() require('lspconfig')[server_name].setup({ capabilities = capabilities }) end, } }) cmp.setup({ sources = { { name = 'path' }, { name = 'nvim_lsp' }, { 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 = true }) 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 capabilities = require('cmp_nvim_lsp').default_capabilities() local pythonLineLength = 95 lspconfig.pylsp.setup { settings = { pylsp = { plugins = { pycodestyle = { ignore = { 'W391' }, maxLineLength = pythonLineLength } } } } } lspconfig.ansiblels.setup {} lspconfig.lua_ls.setup {} lspconfig.helm_ls.setup { settings = { ['helm-ls'] = { yamlls = { path = 'yaml-language-server', } } } } lspconfig.yamlls.setup { capabilities = capabilities, } lspconfig.terraformls.setup { filetypes = { 'terraform', 'terraform-vars', 'tf' } } end }