forked from nix-community/nixvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update-scripts: Extract the list of all servers from nvim-lspconfig
- Loading branch information
Showing
8 changed files
with
1,832 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[files] | ||
extend-exclude = ["**/lspconfig-servers.json"] | ||
|
||
[default.extend-words] | ||
tabe = "tabe" | ||
noice = "noice" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
filter = os.environ.get("LUA_FILTER") | ||
if filter is None: | ||
filter = os.path.dirname(__file__) + "/desc-filter.lua" | ||
|
||
with open(sys.argv[1]) as f: | ||
data = json.load(f) | ||
for d in data: | ||
if "desc" in d: | ||
if "#" in d["desc"]: | ||
d["desc"] = subprocess.run( | ||
["pandoc", "-t", "markdown", f"--lua-filter={filter}"], | ||
input=d["desc"], | ||
capture_output=True, | ||
text=True, | ||
).stdout | ||
print(json.dumps(data, sort_keys=True)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
lib, | ||
vimPlugins, | ||
neovimUtils, | ||
wrapNeovimUnstable, | ||
neovim-unwrapped, | ||
runCommand, | ||
pandoc, | ||
python3, | ||
}: | ||
let | ||
nvimConfig = neovimUtils.makeNeovimConfig { | ||
plugins = [ | ||
{ | ||
plugin = vimPlugins.nvim-lspconfig; | ||
config = null; | ||
optional = false; | ||
} | ||
]; | ||
}; | ||
|
||
nvim = wrapNeovimUnstable neovim-unwrapped nvimConfig; | ||
in | ||
runCommand "lspconfig-servers" | ||
{ | ||
lspconfig = "${vimPlugins.nvim-lspconfig}"; | ||
nativeBuildInputs = [ | ||
pandoc | ||
python3 | ||
]; | ||
} | ||
'' | ||
export HOME=$(realpath .) | ||
# Generates `lsp.json` | ||
${lib.getExe nvim} -u NONE -E -R --headless +'luafile ${./lspconfig-servers.lua}' +q | ||
LUA_FILTER=${./desc-filter.lua} python3 ${./clean-desc.py} "lsp.json" >$out | ||
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function Header(elem) | ||
return pandoc.Strong(elem.content) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-- This script is heavily inspired by https://github.com/neovim/nvim-lspconfig/blob/master/scripts/docgen.lua | ||
require("lspconfig") | ||
local configs = require("lspconfig.configs") | ||
local util = require("lspconfig.util") | ||
|
||
local function require_all_configs() | ||
for _, v in ipairs(vim.fn.glob(vim.env.lspconfig .. "/lua/lspconfig/server_configurations/*.lua", 1, 1)) do | ||
local module_name = v:gsub(".*/", ""):gsub("%.lua$", "") | ||
configs[module_name] = require("lspconfig.server_configurations." .. module_name) | ||
end | ||
end | ||
|
||
local function map_list(t, func) | ||
local res = {} | ||
for i, v in ipairs(t) do | ||
local x = func(v, i) | ||
if x ~= nil then | ||
table.insert(res, x) | ||
end | ||
end | ||
return res | ||
end | ||
|
||
local function sorted_map_table(t, func) | ||
local keys = vim.tbl_keys(t) | ||
table.sort(keys) | ||
return map_list(keys, function(k) | ||
return func(k, t[k]) | ||
end) | ||
end | ||
|
||
require_all_configs() | ||
|
||
info = sorted_map_table(configs, function(server_name, server_info) | ||
local description = nil | ||
if server_info.document_config.docs ~= nil then | ||
description = server_info.document_config.docs.description | ||
end | ||
local cmd = server_info.document_config.default_config.cmd | ||
if type(cmd) == "function" then | ||
cmd = "see source file" | ||
end | ||
return { | ||
name = server_name, | ||
cmd = cmd, | ||
desc = description, | ||
} | ||
end) | ||
|
||
local writer = io.open("lsp.json", "w") | ||
writer:write(vim.json.encode(info)) | ||
writer:close() |