Skip to content

Instantly share code, notes, and snippets.

@tobihans
Created October 3, 2025 19:01
Show Gist options
  • Select an option

  • Save tobihans/e1dfae02de0e678a1be3980d87d89832 to your computer and use it in GitHub Desktop.

Select an option

Save tobihans/e1dfae02de0e678a1be3980d87d89832 to your computer and use it in GitHub Desktop.
Dump neovim lsp configs in json
local servers = {
"elixirls",
"gopls",
"html",
"tinymist",
"vtsls",
"lua_ls",
"pyrefly",
"ruby_lsp",
}
local config = vim.iter(servers):fold({}, function(configs, lsp_name)
local conf = vim.lsp.config[lsp_name]
for key, value in pairs(conf) do
if type(value) == "function" then conf[key] = nil end
end
conf.init_options = nil
conf.capabilities = nil
configs[lsp_name] = conf
return configs
end)
local filename = "<path>/<to>/lsps.json"
local file = io.open(filename, "w")
if file then
file:write(vim.json.encode(config, { indent = " ", sort_keys = true }))
file:close()
print("Content written to " .. filename)
else
print("Error: Could not open file " .. filename .. " for writing.")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment