this repo has no description
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 = true,
35 automatic_installation = true,
36 ensure_installed = {
37 "efm", -- general purpose language server
38 "lua_ls",
39 "jsonls",
40 "vtsls",
41 "eslint",
42 "oxlint",
43 "bashls",
44 "gopls",
45 "goimports",
46 "rust_analyzer",
47 "pyright",
48 "yamlls",
49 "denols",
50 "marksman",
51 },
52 })
53
54 LangServers.lua_ls = {
55 settings = {
56 Lua = { diagnostics = { globals = { "LangServers" } } },
57 },
58 }
59 LangServers.vtsls = {
60 root_dir = not_deno,
61 single_file_support = false,
62 settings = {
63 -- Formatting handled by efm
64 javascript = { format = { enable = false } },
65 typescript = { format = { enable = false } },
66 },
67 }
68 LangServers.eslint = {
69 single_file_support = false,
70 }
71 LangServers.denols = {
72 root_dir = function(bufn, on_dir)
73 local util = require("lspconfig.util")
74 if util.root_pattern("deno.json", "deno.jsonc")(bufn) then
75 on_dir(util.root_pattern("deno.json", "deno.jsonc")(bufn))
76 end
77 end,
78 }
79 LangServers.yamlls = {
80 settings = {
81 yaml = {
82 -- Disable built in schema store stuff in favor of `schemastore` plugin
83 schemaStore = { enable = false, url = "" },
84 schemas = require("schemastore").yaml.schemas(),
85
86 validate = true,
87 completion = true,
88 hover = true,
89 },
90 },
91 }
92 LangServers.jsonls = {
93 filetypes = { "json", "json5", "jsonc" },
94 settings = {
95 json = {
96 schemas = require("schemastore").json.schemas(),
97 validate = { enable = true },
98 format = { enable = false },
99 },
100 },
101 }
102 LangServers.bashls = {
103 filetypes = { "sh", "bash", "zsh" },
104 }
105 LangServers.efm = {
106 filetypes = {
107 "sh",
108 "bash",
109 "zsh",
110 "javascript",
111 "typescript",
112 "javascriptreact",
113 "typescriptreact",
114 "json",
115 "css",
116 "scss",
117 "html",
118 "markdown",
119 },
120 init_options = {
121 documentFormatting = true,
122 documentRangeFormatting = true,
123 },
124 settings = {
125 rootMarkers = { ".git/" },
126 languages = (function()
127 local prettier_config = { formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true }
128 local shfmt_config = { formatCommand = "shfmt -ci", formatStdin = true }
129 -- Use a shell script to detect biome config and use appropriate formatter
130 local js_formatter = {
131 formatCommand = [[sh -c '
132 dir="$(dirname "${INPUT}")"
133 while [ "$dir" != "/" ]; do
134 if [ -f "$dir/biome.json" ] || [ -f "$dir/biome.jsonc" ]; then
135 biome format --stdin-file-path "${INPUT}"
136 exit 0
137 fi
138 dir="$(dirname "$dir")"
139 done
140 prettier --stdin-filepath "${INPUT}"
141 ']],
142 formatStdin = true,
143 }
144
145 return {
146 sh = { shfmt_config },
147 bash = { shfmt_config },
148 zsh = { shfmt_config },
149 javascript = { js_formatter },
150 typescript = { js_formatter },
151 javascriptreact = { js_formatter },
152 typescriptreact = { js_formatter },
153 json = { js_formatter },
154 css = { prettier_config },
155 scss = { prettier_config },
156 html = { prettier_config },
157 markdown = { prettier_config },
158 }
159 end)(),
160 },
161 }
162 LangServers.gopls = {
163 cmd = { "gopls" },
164 filetypes = { "go", "gomod", "gowork", "gotmpl" },
165 }
166 LangServers.pyright = {}
167
168 function SetupLspHandlers()
169 for server_name, server_config in pairs(LangServers) do
170 if server_config == false then
171 return
172 end
173 vim.lsp.config(server_name, server_config or {})
174 vim.lsp.enable(server_name)
175 end
176 end
177
178 -- Call this after loading local configs so the `LangServers` global
179 -- can be modified in those configs as needed first.
180 vim.api.nvim_create_autocmd("User", {
181 pattern = "ConfigLocalFinished",
182 callback = SetupLspHandlers,
183 })
184 vim.api.nvim_create_autocmd("BufWritePre", {
185 callback = function()
186 if vim.bo.filetype ~= "markdown" then
187 vim.lsp.buf.format()
188 end
189 end,
190 })
191 end,
192 },
193 {
194 "folke/lazydev.nvim",
195 ft = "lua", -- only load on lua files
196 opts = {},
197 },
198 {
199 "folke/trouble.nvim",
200 opts = {
201 icons = {},
202 modes = {
203 symbols_float = {
204 mode = "symbols",
205 focus = true,
206 win = {
207 type = "float",
208 wo = { foldlevel = 0 },
209 border = "single",
210 size = { width = 0.8, height = 0.8 },
211 },
212 format = "{kind_icon} {symbol.name} {pos}",
213 keys = {
214 ["<cr>"] = "jump_close",
215 ["q"] = "close",
216 },
217 },
218 symbols = {
219 focus = true,
220 win = {
221 wo = { foldlevel = 0 },
222 size = 50,
223 },
224 format = "{kind_icon} {symbol.name} {pos}",
225 },
226 },
227 },
228 cmd = "Trouble",
229 },
230 {
231 "antosha417/nvim-lsp-file-operations",
232 dependencies = {
233 "nvim-lua/plenary.nvim",
234 "nvim-neo-tree/neo-tree.nvim",
235 },
236 config = function()
237 require("lsp-file-operations").setup()
238 end,
239 },
240}