this repo has no description
at main 5.6 kB view raw
1return { 2 { "b0o/schemastore.nvim" }, 3 { 4 "neovim/nvim-lspconfig", 5 dependencies = { 6 "mason-org/mason.nvim", 7 "klen/nvim-config-local", 8 }, 9 config = function() 10 local lspc = require("lspconfig") 11 local lspconfig_defaults = lspc.util.default_config 12 lspconfig_defaults.capabilities = 13 vim.tbl_deep_extend("force", lspconfig_defaults.capabilities, require("cmp_nvim_lsp").default_capabilities()) 14 end, 15 }, 16 { 17 "mason-org/mason-lspconfig.nvim", 18 dependencies = { 19 "neovim/nvim-lspconfig", 20 "mason-org/mason.nvim", 21 "klen/nvim-config-local", 22 }, 23 config = function() 24 local function not_deno(bufn, on_dir) 25 local util = require("lspconfig.util") 26 if util.root_pattern("deno.json", "deno.jsonc")(bufn) then 27 return nil 28 end 29 on_dir(util.root_pattern("package.json", "tsconfig.json", ".git")(bufn)) 30 end 31 32 require("mason").setup({}) 33 require("mason-lspconfig").setup({ 34 automatic_enable = false, 35 automatic_installation = true, 36 ensure_installed = { 37 "efm", -- general purpose language server 38 "lua_ls", 39 "jsonls", 40 "vtsls", 41 "eslint", 42 "bashls", 43 "rust_analyzer", 44 "pyright", 45 "yamlls", 46 "denols", 47 }, 48 }) 49 50 LangServers.lua_ls = { 51 settings = { 52 Lua = { diagnostics = { globals = { "LangServers" } } }, 53 }, 54 } 55 LangServers.vtsls = { 56 root_dir = not_deno, 57 single_file_support = false, 58 settings = { 59 -- Formatting handled by efm 60 javascript = { format = { enable = false } }, 61 typescript = { format = { enable = false } }, 62 } 63 } 64 LangServers.eslint = { 65 single_file_support = false, 66 } 67 LangServers.denols = { 68 root_dir = function(bufn, on_dir) 69 local util = require("lspconfig.util") 70 if util.root_pattern("deno.json", "deno.jsonc")(bufn) then 71 on_dir(util.root_pattern("deno.json", "deno.jsonc")(bufn)) 72 end 73 end 74 } 75 LangServers.yamlls = { 76 settings = { 77 yaml = { 78 -- Disable built in schema store stuff in favor of `schemastore` plugin 79 schemaStore = { enable = false, url = "" }, 80 schemas = require("schemastore").yaml.schemas(), 81 82 validate = true, 83 completion = true, 84 hover = true, 85 }, 86 }, 87 } 88 LangServers.jsonls = { 89 filetypes = { "json", "json5", "jsonc" }, 90 settings = { 91 json = { 92 schemas = require("schemastore").json.schemas(), 93 validate = { enable = true }, 94 format = { enable = false }, 95 }, 96 } 97 } 98 LangServers.bashls = { 99 filetypes = { "sh", "bash", "zsh" }, 100 } 101 LangServers.efm = { 102 filetypes = { "sh", "bash", "zsh", "javascript", "typescript", "javascriptreact", "typescriptreact", "json", "css", "scss", "html", "markdown" }, 103 init_options = { 104 documentFormatting = true, 105 documentRangeFormatting = true, 106 }, 107 settings = { 108 rootMarkers = { ".git/" }, 109 languages = (function() 110 local prettier_config = { formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true } 111 local shfmt_config = { formatCommand = "shfmt -ci", formatStdin = true } 112 113 return { 114 sh = { shfmt_config }, 115 bash = { shfmt_config }, 116 zsh = { shfmt_config }, 117 javascript = { prettier_config }, 118 typescript = { prettier_config }, 119 javascriptreact = { prettier_config }, 120 typescriptreact = { prettier_config }, 121 json = { prettier_config }, 122 css = { prettier_config }, 123 scss = { prettier_config }, 124 html = { prettier_config }, 125 markdown = { prettier_config }, 126 } 127 end)(), 128 }, 129 } 130 LangServers.gopls = { 131 cmd = { "gopls" }, 132 filetypes = { "go", "gomod", "gowork", "gotmpl" }, 133 } 134 LangServers.pyright = {} 135 136 function SetupLspHandlers() 137 for server_name, server_config in pairs(LangServers) do 138 if server_config == false then 139 return 140 end 141 vim.lsp.config(server_name, server_config or {}) 142 vim.lsp.enable(server_name) 143 end 144 end 145 146 -- Call this after loading local configs so the `LangServers` global 147 -- can be modified in those configs as needed first. 148 vim.api.nvim_create_autocmd("User", { 149 pattern = "ConfigLocalFinished", 150 callback = SetupLspHandlers, 151 }) 152 vim.api.nvim_create_autocmd("BufWritePre", { 153 callback = function() 154 if vim.bo.filetype ~= "markdown" then 155 vim.lsp.buf.format() 156 end 157 end, 158 }) 159 end, 160 }, 161 { 162 "folke/lazydev.nvim", 163 ft = "lua", -- only load on lua files 164 opts = {}, 165 }, 166 { 167 "folke/trouble.nvim", 168 opts = { 169 icons = {}, 170 modes = { 171 symbols = { 172 win = { 173 wo = { foldlevel = 0 }, 174 size = 50, 175 }, 176 format = "{kind_icon} {symbol.name} {pos}", 177 }, 178 }, 179 }, 180 cmd = "Trouble", 181 }, 182 { 183 "antosha417/nvim-lsp-file-operations", 184 dependencies = { 185 "nvim-lua/plenary.nvim", 186 "nvim-neo-tree/neo-tree.nvim", 187 }, 188 config = function() 189 require("lsp-file-operations").setup() 190 end, 191 }, 192}