return { "neovim/nvim-lspconfig", lazy = false, dependencies = { "hrsh7th/cmp-nvim-lsp", }, config = function() local capabilities = require("cmp_nvim_lsp").default_capabilities() local lspconfig = require("lspconfig") lspconfig.pyright.setup { capabilities = capabilities } lspconfig.ruff_lsp.setup { capabilities = capabilities } lspconfig.nixd.setup { capabilities = capabilities } lspconfig.jsonls.setup { capabilities = capabilities } lspconfig.beancount.setup { capabilities = capabilities } lspconfig.ltex.setup { capabilities = capabilities } lspconfig.terraformls.setup { capabilities = capabilities } lspconfig.tflint.setup { capabilities = capabilities } lspconfig.docker_compose_language_service.setup { root_dir = lspconfig.util.root_pattern("docker-compose.yaml", "docker-compose.yml"), filetypes = { "yaml", "yaml.docker-compose" }, capabilities = capabilities, } lspconfig.dockerls.setup { capabilities = capabilities } -- lspconfig.sqlls.setup {capabilities = capabilities} lspconfig.lua_ls.setup { settings = { Lua = { runtime = { -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) version = "LuaJIT", }, diagnostics = { -- Get the language server to recognize the `vim` global globals = { "vim" }, }, workspace = { -- Make the server aware of Neovim runtime files library = vim.api.nvim_get_runtime_file("", true), }, -- Do not send telemetry data containing a randomized but unique identifier telemetry = { enable = false, }, }, }, capabilities = capabilities } lspconfig.efm.setup { init_options = { documentFormatting = true }, filetypes = { "python", "sh" }, settings = { rootMarkers = { ".git/", "pyproject.toml" }, languages = { python = { { formatCommand = "black -", formatStdin = true } }, sql = { { formatCommand = "sqlfluff fix --dialect bigquery -", formatStdin = true } }, sh = { { formatCommand = "shfmt -i 4 -bn -sr -p -ci", formatStdin = true, lintCommand = "shellcheck -f gcc -x", lintSource = "shellcheck", lintFormats = { "%f:%l:%c: %trror: %m", "%f:%l:%c: %tarning: %m", "%f:%l:%c: %tote: %m", } } }, }, }, capabilities = capabilities } vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("UserLspConfig", {}), callback = function(ev) -- Enable completion triggered by vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc" end }) end, keys = { { 'gD', vim.lsp.buf.declaration }, { 'gd', vim.lsp.buf.definition }, { 'K', vim.lsp.buf.hover }, { 'gi', vim.lsp.buf.implementation }, { '', vim.lsp.buf.signature_help }, { 'wa', vim.lsp.buf.add_workspace_folder }, { 'wr', vim.lsp.buf.remove_workspace_folder }, { 'D', vim.lsp.buf.type_definition }, { 'rn', vim.lsp.buf.rename }, { 'gr', vim.lsp.buf.references }, { 'ca', vim.lsp.buf.code_action, { 'n', 'v' } }, { 'wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end }, { 'f', function() vim.lsp.buf.format { async = true } end }, }, }