🪴 my neovim config:)
1
fork

Configure Feed

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

lsp: refactor configs without massive table

robin be762f07 5f0c5946

+99 -130
+10
config/lsp/jsonls.lua
··· 1 + return { 2 + before_init = function(_, config) 3 + config.settings.json.schemas = require("schemastore").json.schemas() 4 + end, 5 + settings = { 6 + json = { 7 + validate = { enable = true }, 8 + }, 9 + }, 10 + }
+41
config/lsp/lua_ls.lua
··· 1 + return { 2 + on_init = function(client) 3 + if client.workspace_folders then 4 + local path = client.workspace_folders[1].name 5 + if 6 + path ~= vim.fn.stdpath("config") 7 + and (vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc")) 8 + then 9 + return 10 + end 11 + end 12 + client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { 13 + workspace = { 14 + checkThirdParty = false, 15 + library = { 16 + vim.env.VIMRUNTIME, 17 + -- Depending on the usage, you might want to add additional paths here. 18 + -- "${3rd}/luv/library" 19 + }, 20 + }, 21 + }) 22 + end, 23 + settings = { 24 + Lua = { 25 + runtime = { 26 + version = "LuaJIT", 27 + path = { 28 + "lua/?.lua", 29 + "lua/?/init.lua", 30 + }, 31 + }, 32 + diagnostics = { 33 + globals = { "vim", "package", "table" }, 34 + }, 35 + hint = { 36 + enable = true, 37 + arrayIndex = "Disable", 38 + }, 39 + }, 40 + }, 41 + }
+11
config/lsp/yamlls.lua
··· 1 + return { 2 + before_init = function(_, config) 3 + config.settings.yaml.schemas = vim.tbl_extend("keep", { 4 + ["https://json.schemastore.org/github-action"] = ".github/action.{yaml,yml}", 5 + ["https://json.schemastore.org/github-workflow"] = ".github/workflows/*", 6 + ["https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"] = "*lab-ci.{yaml,yml}", 7 + ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "docker-compose.{yml,yaml}", 8 + ["https://goreleaser.com/static/schema.json"] = ".goreleaser.{yml,yaml}", 9 + }, require("schemastore").yaml.schemas()) 10 + end, 11 + }
+36 -95
config/lua/ivy/config/lsp.lua
··· 1 - vim.g.lsp_config = { 2 - common = {}, 3 - servers = function() 4 - return { 5 - astro = {}, 6 - bashls = {}, 7 - clangd = {}, 8 - colorlsp = {}, 9 - cssls = {}, 10 - denols = {}, 11 - dockerls = {}, 12 - emmet_language_server = {}, 13 - gopls = {}, 14 - hls = {}, 15 - html = {}, 16 - jsonls = { 17 - settings = { 18 - json = { 19 - schemas = require("schemastore").json.schemas(), 20 - validate = { enable = true }, 21 - }, 22 - }, 23 - }, 24 - lua_ls = { 25 - on_init = function(client) 26 - if client.workspace_folders then 27 - local path = client.workspace_folders[1].name 28 - if 29 - path ~= vim.fn.stdpath("config") 30 - and (vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc")) 31 - then 32 - return 33 - end 34 - end 35 - client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { 36 - workspace = { 37 - checkThirdParty = false, 38 - library = { 39 - vim.env.VIMRUNTIME, 40 - -- Depending on the usage, you might want to add additional paths here. 41 - -- "${3rd}/luv/library" 42 - }, 43 - }, 44 - }) 45 - end, 46 - settings = { 47 - Lua = { 48 - runtime = { 49 - version = "LuaJIT", 50 - path = { 51 - "lua/?.lua", 52 - "lua/?/init.lua", 53 - }, 54 - }, 55 - diagnostics = { 56 - globals = { "vim", "package", "table" }, 57 - }, 58 - hint = { 59 - enable = true, 60 - arrayIndex = "Disable", 61 - }, 62 - }, 63 - }, 64 - }, 65 - marksman = {}, 66 - nil_ls = {}, 67 - nushell = {}, 68 - taplo = {}, 69 - teal_ls = {}, 70 - tinymist = {}, 71 - ts_ls = {}, 72 - tailwindcss = {}, 73 - vue_ls = {}, 74 - yamlls = { 75 - settings = { 76 - yaml = { 77 - schemas = vim.tbl_extend("keep", { 78 - ["https://json.schemastore.org/github-action"] = ".github/action.{yaml,yml}", 79 - ["https://json.schemastore.org/github-workflow"] = ".github/workflows/*", 80 - ["https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json"] = "*lab-ci.{yaml,yml}", 81 - ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "docker-compose.{yml,yaml}", 82 - ["https://goreleaser.com/static/schema.json"] = ".goreleaser.{yml,yaml}", 83 - }, require("schemastore").yaml.schemas()), 84 - }, 85 - }, 86 - }, 87 - zk = {}, 88 - zls = {}, 89 - } 90 - end, 91 - on_attach = function(_, buf) 92 - local opts = { buffer = buf } 93 - vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) 94 - end, 95 - } 1 + -- common ===================================================================== 2 + -- vim.lsp.config('*', {}) 3 + 4 + -- enable ===================================================================== 5 + vim.lsp.enable({ 6 + "astro", 7 + "bashls", 8 + "clangd", 9 + "colorlsp", 10 + "cssls", 11 + "denols", 12 + "dockerls", 13 + "emmet_language_server", 14 + "gopls", 15 + "hls", 16 + "html", 17 + "jsonls", 18 + "lua_ls", 19 + "marksman", 20 + "nil_ls", 21 + "nushell", 22 + "taplo", 23 + "teal_ls", 24 + "tinymist", 25 + "ts_ls", 26 + "tailwindcss", 27 + "vue_ls", 28 + "yamlls", 29 + "zk", 30 + "zls", 31 + }) 32 + 33 + vim.g.lsp_on_attach = function(_, buf) 34 + local opts = { buffer = buf } 35 + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) 36 + end
+1 -35
config/plugin/lsp.lua
··· 1 - local props = vim.g.lsp_config or {} 2 - 3 - vim.validate("vim.g.lsp_config.common", props.common, { "table", "function" }) 4 - vim.validate("vim.g.lsp_config.servers", props.servers, { "table", "function" }) 5 - vim.validate("vim.g.lsp_config.on_attach", props.on_attach, "function") 6 - 7 1 local components = { 8 2 { 9 3 name = "inlay_hint", ··· 50 44 end 51 45 end, 52 46 }, 53 - { name = "user", callback = props.on_attach }, 47 + { name = "user", callback = vim.g.lsp_on_attach }, 54 48 } 55 49 56 50 vim.iter(ipairs(components)):each(function(_, fn) ··· 69 63 end 70 64 end) 71 65 end) 72 - 73 - local common = props.common 74 - if type(common) == "function" then 75 - common = common() 76 - end 77 - 78 - vim.lsp.config("*", common) 79 - 80 - local function setup_ls(name, cfg) 81 - ---@diagnostic disable-next-line: param-type-mismatch 82 - local ok, result = pcall(vim.lsp.config, name, cfg) 83 - if not ok then 84 - vim.notify(("unable to configure lsp server %s:\n\t%s"):format(name, result)) 85 - return 86 - end 87 - vim.lsp.enable(name) 88 - end 89 - 90 - local servers = props.servers 91 - if type(servers) == "function" then 92 - ---@diagnostic disable-next-line: cast-local-type 93 - servers = servers() 94 - end 95 - 96 - vim.once(function() 97 - ---@diagnostic disable-next-line: param-type-mismatch 98 - vim.iter(pairs(servers)):each(setup_ls) 99 - end)