return { { "b0o/schemastore.nvim" }, { "neovim/nvim-lspconfig", dependencies = { "mason-org/mason.nvim", "klen/nvim-config-local", }, config = function() local lspc = require("lspconfig") local lspconfig_defaults = lspc.util.default_config lspconfig_defaults.capabilities = vim.tbl_deep_extend("force", lspconfig_defaults.capabilities, require("cmp_nvim_lsp").default_capabilities()) end, }, { "mason-org/mason-lspconfig.nvim", dependencies = { "neovim/nvim-lspconfig", "mason-org/mason.nvim", "klen/nvim-config-local", }, config = function() local function not_deno(bufn, on_dir) local util = require("lspconfig.util") if util.root_pattern("deno.json", "deno.jsonc")(bufn) then return nil end on_dir(util.root_pattern("package.json", "tsconfig.json", ".git")(bufn)) end require("mason").setup({}) require("mason-lspconfig").setup({ automatic_enable = false, automatic_installation = true, ensure_installed = { "efm", -- general purpose language server "lua_ls", "jsonls", "vtsls", "eslint", "bashls", "rust_analyzer", "pyright", "yamlls", "denols", }, }) LangServers.lua_ls = { settings = { Lua = { diagnostics = { globals = { "LangServers" } } }, }, } LangServers.vtsls = { root_dir = not_deno, single_file_support = false, settings = { -- Formatting handled by efm javascript = { format = { enable = false } }, typescript = { format = { enable = false } }, } } LangServers.eslint = { single_file_support = false, } LangServers.denols = { root_dir = function(bufn, on_dir) local util = require("lspconfig.util") if util.root_pattern("deno.json", "deno.jsonc")(bufn) then on_dir(util.root_pattern("deno.json", "deno.jsonc")(bufn)) end end } LangServers.yamlls = { settings = { yaml = { -- Disable built in schema store stuff in favor of `schemastore` plugin schemaStore = { enable = false, url = "" }, schemas = require("schemastore").yaml.schemas(), validate = true, completion = true, hover = true, }, }, } LangServers.jsonls = { filetypes = { "json", "json5", "jsonc" }, settings = { json = { schemas = require("schemastore").json.schemas(), validate = { enable = true }, format = { enable = false }, }, } } LangServers.bashls = { filetypes = { "sh", "bash", "zsh" }, } LangServers.efm = { filetypes = { "sh", "bash", "zsh", "javascript", "typescript", "javascriptreact", "typescriptreact", "json", "css", "scss", "html", "markdown" }, init_options = { documentFormatting = true, documentRangeFormatting = true, }, settings = { rootMarkers = { ".git/" }, languages = (function() local prettier_config = { formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true } local shfmt_config = { formatCommand = "shfmt -ci", formatStdin = true } return { sh = { shfmt_config }, bash = { shfmt_config }, zsh = { shfmt_config }, javascript = { prettier_config }, typescript = { prettier_config }, javascriptreact = { prettier_config }, typescriptreact = { prettier_config }, json = { prettier_config }, css = { prettier_config }, scss = { prettier_config }, html = { prettier_config }, markdown = { prettier_config }, } end)(), }, } LangServers.gopls = { cmd = { "gopls" }, filetypes = { "go", "gomod", "gowork", "gotmpl" }, } LangServers.pyright = {} function SetupLspHandlers() for server_name, server_config in pairs(LangServers) do if server_config == false then return end vim.lsp.config(server_name, server_config or {}) vim.lsp.enable(server_name) end end -- Call this after loading local configs so the `LangServers` global -- can be modified in those configs as needed first. vim.api.nvim_create_autocmd("User", { pattern = "ConfigLocalFinished", callback = SetupLspHandlers, }) vim.api.nvim_create_autocmd("BufWritePre", { callback = function() if vim.bo.filetype ~= "markdown" then vim.lsp.buf.format() end end, }) end, }, { "folke/lazydev.nvim", ft = "lua", -- only load on lua files opts = {}, }, { "folke/trouble.nvim", opts = { icons = {}, modes = { symbols = { win = { wo = { foldlevel = 0 }, size = 50, }, format = "{kind_icon} {symbol.name} {pos}", }, }, }, cmd = "Trouble", }, { "antosha417/nvim-lsp-file-operations", dependencies = { "nvim-lua/plenary.nvim", "nvim-neo-tree/neo-tree.nvim", }, config = function() require("lsp-file-operations").setup() end, }, }