🪴 my neovim config:)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(lsp)!: move lsp config from `nvim-lspconfig` to native lsp

robin afb78a4b 62c84169

+162 -249
+162
config/lua/ivy/init.lua
··· 21 21 { 22 22 "ivy.config.keybinds", 23 23 }, 24 + { 25 + "ivy.config.lsp", 26 + opts = { 27 + common = function() 28 + require("lz.n").trigger_load({ 29 + "blink.cmp", 30 + "lsp-status.nvim", 31 + "schemastore.nvim", 32 + }) 33 + local capabilities = require("blink.cmp").get_lsp_capabilities({}, true) 34 + 35 + return { capabilities = capabilities } 36 + end, 37 + servers = function() 38 + return { 39 + astro = {}, 40 + bashls = {}, 41 + cssls = {}, 42 + dockerls = {}, 43 + emmet_language_server = { 44 + filetypes = { 45 + "astro", 46 + "css", 47 + "eruby", 48 + "html", 49 + "javascript", 50 + "javascriptreact", 51 + "less", 52 + "sass", 53 + "scss", 54 + "pug", 55 + "typescriptreact", 56 + }, 57 + }, 58 + helm_ls = {}, 59 + hls = {}, 60 + html = {}, 61 + intelephense = {}, 62 + jqls = {}, 63 + jsonls = { 64 + settings = { 65 + json = { 66 + schemas = require("schemastore").json.schemas(), 67 + validate = { enable = true }, 68 + }, 69 + }, 70 + }, 71 + marksman = {}, 72 + nushell = {}, 73 + serve_d = {}, 74 + sourcekit = {}, 75 + taplo = {}, 76 + teal_ls = {}, 77 + tailwindcss = { 78 + filetypes = { 79 + "astro", 80 + "javascriptreact", 81 + "typescriptreact", 82 + "html", 83 + "css", 84 + "tera", 85 + }, 86 + }, 87 + tinymist = { 88 + settings = { 89 + formatterMode = "typstyle", 90 + exportPdf = "onDocumentHasTitle", 91 + }, 92 + }, 93 + volar = { 94 + capabilities = { 95 + workspace = { 96 + didChangeWatchedFiles = { 97 + dynamicRegistration = true, 98 + }, 99 + }, 100 + }, 101 + root_markers = { "package.json" }, 102 + }, 103 + yamlls = { 104 + settings = { 105 + yaml = { 106 + completion = true, 107 + validate = true, 108 + suggest = { 109 + parentSkeletonSelectedFirst = true, 110 + }, 111 + schemas = vim.tbl_extend("keep", { 112 + ["https://json.schemastore.org/github-action"] = ".github/action.{yaml,yml}", 113 + ["https://json.schemastore.org/github-workflow"] = ".github/workflows/*", 114 + ["https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"] = "*lab-ci.{yaml,yml}", 115 + ["https://json.schemastore.org/helmfile"] = "helmfile.{yaml,yml}", 116 + ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "docker-compose.{yml,yaml}", 117 + ["https://goreleaser.com/static/schema.json"] = ".goreleaser.{yml,yaml}", 118 + }, require("schemastore").yaml.schemas()), 119 + }, 120 + redhat = { 121 + telemetry = { 122 + enabled = false, 123 + }, 124 + }, 125 + }, 126 + }, 127 + } 128 + end, 129 + on_attach = function(ev) 130 + local client = vim.lsp.get_client_by_id(ev.data.client_id) 131 + 132 + if client == nil then 133 + return 134 + end 135 + 136 + local navic_present, navic = pcall(require, "nvim-navic") 137 + 138 + if navic_present and client.server_capabilities.documentSymbolProvider then 139 + navic.attach(client, ev.buf) 140 + end 141 + 142 + if client.server_capabilities.inlayHintProvider then 143 + vim.lsp.inlay_hint.enable(true, { bufnr = ev.buf }) 144 + end 145 + 146 + if client.server_capabilities.documentHighlightProvider then 147 + local group = 148 + vim.api.nvim_create_augroup(string.format("lsp:document_highlight:%d", ev.buf), { clear = true }) 149 + vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { 150 + group = group, 151 + buffer = ev.buf, 152 + callback = function() 153 + vim.lsp.buf.clear_references() 154 + vim.lsp.buf.document_highlight() 155 + end, 156 + desc = "highlight lsp reference", 157 + }) 158 + vim.api.nvim_create_autocmd("CursorMoved", { 159 + group = group, 160 + buffer = ev.buf, 161 + callback = function() 162 + vim.lsp.buf.clear_references() 163 + end, 164 + desc = "clear lsp references", 165 + }) 166 + end 167 + 168 + local opts = { buffer = ev.buf } 169 + local function use_border(cb) 170 + return function() 171 + cb({ border = vim.g.bc.style }) 172 + end 173 + end 174 + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) 175 + vim.keymap.set("n", "K", use_border(vim.lsp.buf.hover), opts) 176 + vim.keymap.set("i", "<C-k>", use_border(vim.lsp.buf.signature_help), opts) 177 + vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts) 178 + vim.keymap.set({ "n", "v" }, "<space>ca", vim.lsp.buf.code_action, opts) 179 + vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) 180 + vim.keymap.set("n", "<localleader>f", function() 181 + vim.lsp.buf.format({ async = true }) 182 + end, opts) 183 + end, 184 + }, 185 + }, 24 186 }) 25 187 :setup() 26 188 end,
-249
config/lua/ivy/plugins/lsp.lua
··· 84 84 { "schemastore.nvim" }, 85 85 86 86 { 87 - "nvim-lspconfig", 88 - event = "DeferredUIEnter", 89 - after = function() 90 - require("lz.n").trigger_load({ 91 - "blink.cmp", 92 - "lsp-status.nvim", 93 - "schemastore.nvim", 94 - }) 95 - 96 - local lsp_present, lspconfig = pcall(require, "lspconfig") 97 - local navic_present, navic = pcall(require, "nvim-navic") 98 - 99 - if not lsp_present then 100 - vim.notify("lspnot present", vim.log.levels.ERROR) 101 - return 102 - end 103 - 104 - -- border style 105 - require("lspconfig.ui.windows").default_options.border = vim.g.bc.style 106 - 107 - vim.api.nvim_create_autocmd("LspAttach", { 108 - group = vim.api.nvim_create_augroup("UserLspConfig", { clear = true }), 109 - callback = function(ev) 110 - local client = vim.lsp.get_client_by_id(ev.data.client_id) 111 - 112 - if client == nil then 113 - return 114 - end 115 - 116 - if navic_present and client.server_capabilities.documentSymbolProvider then 117 - navic.attach(client, ev.buf) 118 - end 119 - 120 - if client.server_capabilities.inlayHintProvider then 121 - vim.lsp.inlay_hint.enable(true, { bufnr = ev.buf }) 122 - end 123 - 124 - if client.server_capabilities.documentHighlightProvider then 125 - local group = 126 - vim.api.nvim_create_augroup(string.format("lsp:document_highlight:%d", ev.buf), { clear = true }) 127 - vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { 128 - group = group, 129 - buffer = ev.buf, 130 - callback = function() 131 - vim.lsp.buf.clear_references() 132 - vim.lsp.buf.document_highlight() 133 - end, 134 - desc = "highlight lsp reference", 135 - }) 136 - vim.api.nvim_create_autocmd("CursorMoved", { 137 - group = group, 138 - buffer = ev.buf, 139 - callback = function() 140 - vim.lsp.buf.clear_references() 141 - end, 142 - desc = "clear lsp references", 143 - }) 144 - end 145 - 146 - local opts = { buffer = ev.buf } 147 - local function use_border(cb) 148 - return function() 149 - cb({ border = vim.g.bc.style }) 150 - end 151 - end 152 - vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) 153 - vim.keymap.set("n", "K", use_border(vim.lsp.buf.hover), opts) 154 - vim.keymap.set("i", "<C-k>", use_border(vim.lsp.buf.signature_help), opts) 155 - vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts) 156 - vim.keymap.set({ "n", "v" }, "<space>ca", vim.lsp.buf.code_action, opts) 157 - vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) 158 - vim.keymap.set("n", "<localleader>f", function() 159 - vim.lsp.buf.format({ async = true }) 160 - end, opts) 161 - end, 162 - }) 163 - 164 - local capabilities = require("blink.cmp").get_lsp_capabilities({}, true) 165 - 166 - local common = { capabilities = capabilities } 167 - 168 - local servers = { 169 - astro = {}, 170 - bashls = {}, 171 - cssls = {}, 172 - denols = { 173 - root_dir = lspconfig.util.root_pattern("deno.json", "deno.jsonc"), 174 - single_file_support = false, 175 - settings = { 176 - deno = { 177 - inlayHints = { 178 - parameterNames = { enabled = "all", suppressWhenArgumentMatchesName = true }, 179 - parameterTypes = { enabled = true }, 180 - variableTypes = { enabled = true, suppressWhenTypeMatchesName = true }, 181 - propertyDeclarationTypes = { enabled = true }, 182 - functionLikeReturnTypes = { enable = true }, 183 - enumMemberValues = { enabled = true }, 184 - }, 185 - }, 186 - }, 187 - }, 188 - dockerls = {}, 189 - emmet_language_server = { 190 - filetypes = { 191 - "astro", 192 - "css", 193 - "eruby", 194 - "html", 195 - "javascript", 196 - "javascriptreact", 197 - "less", 198 - "sass", 199 - "scss", 200 - "pug", 201 - "typescriptreact", 202 - }, 203 - }, 204 - gopls = { 205 - single_file_support = true, 206 - filetypes = { "go", "gomod", "gosum", "gotmpl", "gohtmltmpl", "gotexttmpl" }, 207 - cmd = { 208 - "gopls", -- share the gopls instance if there is one already 209 - "-remote.debug=:0", 210 - }, 211 - settings = { 212 - gopls = { 213 - hints = { 214 - assignVariableTypes = true, 215 - compositeLiteralFields = true, 216 - compositeLiteralTypes = true, 217 - constantValues = true, 218 - functionTypeParameters = true, 219 - parameterNames = true, 220 - rangeVariableTypes = true, 221 - }, 222 - usePlaceholders = true, 223 - completeUnimported = true, 224 - staticcheck = true, 225 - matcher = "Fuzzy", 226 - diagnosticsDelay = "500ms", 227 - symbolMatcher = "fuzzy", 228 - semanticTokens = true, 229 - gofumpt = true, 230 - }, 231 - }, 232 - }, 233 - helm_ls = {}, 234 - hls = {}, 235 - html = {}, 236 - intelephense = {}, 237 - jqls = {}, 238 - jsonls = { 239 - settings = { 240 - json = { 241 - schemas = require("schemastore").json.schemas(), 242 - validate = { enable = true }, 243 - }, 244 - }, 245 - }, 246 - lua_ls = { 247 - settings = { 248 - Lua = { 249 - diagnostics = { 250 - globals = { "vim", "package", "table" }, 251 - }, 252 - hint = { 253 - enable = true, 254 - arrayIndex = "Disable", 255 - }, 256 - }, 257 - }, 258 - }, 259 - marksman = {}, 260 - nil_ls = { 261 - autostart = true, 262 - cmd = { "nil" }, 263 - settings = { 264 - ["nil"] = { 265 - formatting = { 266 - command = { "nixfmt" }, 267 - }, 268 - nix = { maxMemoryMB = nil }, 269 - }, 270 - }, 271 - }, 272 - nushell = {}, 273 - serve_d = {}, 274 - sourcekit = {}, 275 - taplo = {}, 276 - teal_ls = {}, 277 - tailwindcss = { 278 - filetypes = { 279 - "astro", 280 - "javascriptreact", 281 - "typescriptreact", 282 - "html", 283 - "css", 284 - "tera", 285 - }, 286 - }, 287 - tinymist = { 288 - settings = { 289 - formatterMode = "typstyle", 290 - exportPdf = "onDocumentHasTitle", 291 - }, 292 - }, 293 - volar = { 294 - capabilities = { 295 - workspace = { 296 - didChangeWatchedFiles = { 297 - dynamicRegistration = true, 298 - }, 299 - }, 300 - }, 301 - root_dir = require("lspconfig.util").root_pattern("package.json"), 302 - }, 303 - yamlls = { 304 - settings = { 305 - yaml = { 306 - completion = true, 307 - validate = true, 308 - suggest = { 309 - parentSkeletonSelectedFirst = true, 310 - }, 311 - schemas = vim.tbl_extend("keep", { 312 - ["https://json.schemastore.org/github-action"] = ".github/action.{yaml,yml}", 313 - ["https://json.schemastore.org/github-workflow"] = ".github/workflows/*", 314 - ["https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"] = "*lab-ci.{yaml,yml}", 315 - ["https://json.schemastore.org/helmfile"] = "helmfile.{yaml,yml}", 316 - ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "docker-compose.{yml,yaml}", 317 - ["https://goreleaser.com/static/schema.json"] = ".goreleaser.{yml,yaml}", 318 - }, require("schemastore").yaml.schemas()), 319 - }, 320 - redhat = { 321 - telemetry = { 322 - enabled = false, 323 - }, 324 - }, 325 - }, 326 - }, 327 - } 328 - 329 - for server, config in pairs(servers) do 330 - lspconfig[server].setup(vim.tbl_extend("force", common, config)) 331 - end 332 - end, 333 - }, 334 - 335 - { 336 87 "crates.nvim", 337 88 after = function() 338 89 require("crates").setup({})