1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-08 11:36:07 +01:00
nixvim/ci/nvim-lspconfig/default.nix
saygo-png c89994b0ac treewide: generate JSON instead of Nix
Signed-off-by: saygo-png <saygo.mail@proton.me>
2025-10-19 00:31:33 +00:00

54 lines
1.2 KiB
Nix

{
callPackage,
vimPlugins,
runCommand,
pandoc,
jq,
}:
runCommand "lspconfig-servers.json"
{
lspconfig = vimPlugins.nvim-lspconfig;
nativeBuildInputs = [
jq
pandoc
];
passthru.unsupported = callPackage ./unsupported.nix { };
}
''
for file in "$lspconfig"/lsp/*.lua
do
name=$(basename --suffix=.lua "$file")
# A lua @brief doc-comment has the description
# NOTE: this is only needed for `plugins.lsp`
description=$(
awk '
# Capture the @brief doc-comment
/^---@brief/ {
inbrief=1
next
}
# Print each line in the doc-comment
inbrief && /^--- / {
sub(/^--- /, "")
print
next
}
# Until the end of the comment
inbrief && !/^---/ {
inbrief=0
}
' "$file" \
| pandoc -t markdown --lua-filter ${./desc-filter.lua}
)
# Map each server config to {name: description}
jq --null-input \
--arg name "$name" \
--arg desc "$description" \
'{ ($name): $desc }'
done | jq --slurp add > "$out"
''