mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
update-scripts: Extract the list of all servers from nvim-lspconfig
This commit is contained in:
parent
cab6b0c9fe
commit
aa24b3f9d8
8 changed files with 1832 additions and 1 deletions
1705
generated/lspconfig-servers.json
Normal file
1705
generated/lspconfig-servers.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,6 @@
|
||||||
|
[files]
|
||||||
|
extend-exclude = ["**/lspconfig-servers.json"]
|
||||||
|
|
||||||
[default.extend-words]
|
[default.extend-words]
|
||||||
tabe = "tabe"
|
tabe = "tabe"
|
||||||
noice = "noice"
|
noice = "noice"
|
||||||
|
|
|
@ -26,4 +26,5 @@ lib.fix (self: {
|
||||||
efmls-configs-sources = pkgs.callPackage ./efmls-configs.nix { };
|
efmls-configs-sources = pkgs.callPackage ./efmls-configs.nix { };
|
||||||
none-ls-builtins = pkgs.callPackage ./none-ls.nix { };
|
none-ls-builtins = pkgs.callPackage ./none-ls.nix { };
|
||||||
rust-analyzer-options = pkgs.callPackage ./rust-analyzer { };
|
rust-analyzer-options = pkgs.callPackage ./rust-analyzer { };
|
||||||
|
lspconfig-servers = pkgs.callPackage ./nvim-lspconfig { };
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,12 +3,17 @@
|
||||||
rust-analyzer-options,
|
rust-analyzer-options,
|
||||||
efmls-configs-sources,
|
efmls-configs-sources,
|
||||||
none-ls-builtins,
|
none-ls-builtins,
|
||||||
|
lspconfig-servers,
|
||||||
nixfmt-rfc-style,
|
nixfmt-rfc-style,
|
||||||
|
nodePackages,
|
||||||
}:
|
}:
|
||||||
writeShellApplication {
|
writeShellApplication {
|
||||||
name = "generate";
|
name = "generate";
|
||||||
|
|
||||||
runtimeInputs = [ nixfmt-rfc-style ];
|
runtimeInputs = [
|
||||||
|
nixfmt-rfc-style
|
||||||
|
nodePackages.prettier
|
||||||
|
];
|
||||||
|
|
||||||
text = ''
|
text = ''
|
||||||
repo_root=$(git rev-parse --show-toplevel)
|
repo_root=$(git rev-parse --show-toplevel)
|
||||||
|
@ -37,6 +42,8 @@ writeShellApplication {
|
||||||
generate "${rust-analyzer-options}" "rust-analyzer"
|
generate "${rust-analyzer-options}" "rust-analyzer"
|
||||||
generate "${efmls-configs-sources}" "efmls-configs"
|
generate "${efmls-configs-sources}" "efmls-configs"
|
||||||
generate "${none-ls-builtins}" "none-ls"
|
generate "${none-ls-builtins}" "none-ls"
|
||||||
|
echo "lspconfig servers"
|
||||||
|
prettier --parser=json "${lspconfig-servers}" >"$generated_dir/lspconfig-servers.json"
|
||||||
|
|
||||||
if [ -n "$commit" ]; then
|
if [ -n "$commit" ]; then
|
||||||
cd "$generated_dir"
|
cd "$generated_dir"
|
||||||
|
|
23
update-scripts/nvim-lspconfig/clean-desc.py
Executable file
23
update-scripts/nvim-lspconfig/clean-desc.py
Executable file
|
@ -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))
|
37
update-scripts/nvim-lspconfig/default.nix
Normal file
37
update-scripts/nvim-lspconfig/default.nix
Normal file
|
@ -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
|
||||||
|
''
|
3
update-scripts/nvim-lspconfig/desc-filter.lua
Normal file
3
update-scripts/nvim-lspconfig/desc-filter.lua
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function Header(elem)
|
||||||
|
return pandoc.Strong(elem.content)
|
||||||
|
end
|
52
update-scripts/nvim-lspconfig/lspconfig-servers.lua
Normal file
52
update-scripts/nvim-lspconfig/lspconfig-servers.lua
Normal file
|
@ -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()
|
Loading…
Add table
Add a link
Reference in a new issue