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' }, }, 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', }, 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 pythonLineLength = 95 lspconfig.pylsp.setup { settings = { pylsp = { plugins = { pycodestyle = { ignore = { 'W391' }, maxLineLength = pythonLineLength } } } } } lspconfig.ansiblels.setup {} lspconfig.lua_ls.setup { on_init = function(client) local path = client.workspace_folders[1].name if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then return end client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { runtime = { -- Tell the language server which version of Lua you're using -- (most likely LuaJIT in the case of Neovim) version = 'LuaJIT' }, -- Make the server aware of Neovim runtime files workspace = { checkThirdParty = false, library = { vim.env.VIMRUNTIME -- Depending on the usage, you might want to add additional paths here. -- '${3rd}/luv/library' -- '${3rd}/busted/library', } -- or pull in all of 'runtimepath'. NOTE: this is a lot slower -- library = vim.api.nvim_get_runtime_file('', true) } }) end, settings = { Lua = {} } } lspconfig.helm_ls.setup { settings = { ['helm-ls'] = { yamlls = { path = 'yaml-language-server', } } } } lspconfig.terraformls.setup { filetypes = { 'terraform', 'terraform-vars', 'tf' } } end }