1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-08 19:46:06 +01:00

ci/nvim-lspconfig: migrate to the new API

This is nearly a full rewrite of the lspconfig-servers update-script,
migrating it to the new `lsp/` directory system and simplifying where
possible.

- plugins/lsp: adapt to new file format
- flake/locate-lsp-packages: update for new lspconfig file format
- generated: Updated lspconfig-servers.json
This commit is contained in:
Matt Sturgeon 2025-10-02 20:44:07 +01:00
parent 308e5b3843
commit b9c5a75cc6
7 changed files with 456 additions and 1561 deletions

View file

@ -1,23 +0,0 @@
#!/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))

View file

@ -1,42 +1,54 @@
{
lib,
callPackage,
vimPlugins,
neovimUtils,
wrapNeovimUnstable,
neovim-unwrapped,
runCommand,
pandoc,
python3,
jq,
}:
let
nvimConfig = neovimUtils.makeNeovimConfig {
plugins = [
{
plugin = vimPlugins.nvim-lspconfig;
config = null;
optional = false;
}
];
};
nvim = (wrapNeovimUnstable neovim-unwrapped nvimConfig).overrideAttrs {
dontFixup = true;
};
in
runCommand "lspconfig-servers"
{
lspconfig = "${vimPlugins.nvim-lspconfig}";
lspconfig = vimPlugins.nvim-lspconfig;
nativeBuildInputs = [
jq
pandoc
python3
];
passthru.unsupported = callPackage ./unsupported.nix { };
}
''
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
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"
''

View file

@ -1,3 +1,5 @@
local pandoc = pandoc
function Header(elem)
return pandoc.Strong(elem.content)
end

View file

@ -1,47 +0,0 @@
-- 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/configs/*.lua", 1, 1)) do
local module_name = v:gsub(".*/", ""):gsub("%.lua$", "")
configs[module_name] = require("lspconfig.configs." .. 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
return {
name = server_name,
desc = description,
}
end)
local writer = io.open("lsp.json", "w")
writer:write(vim.json.encode(info))
writer:close()

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,7 @@
with lib;
let
renamedServers = import ./_renamed.nix;
unsupportedServers = lib.importJSON ../../../generated/unsupported-lspconfig-servers.json;
lspExtraArgs = {
dartls = {
@ -192,15 +193,10 @@ let
generatedServers = lib.pipe ../../../generated/lspconfig-servers.json [
lib.importJSON
(lib.map (
(lib.mapAttrsToList (
name: description:
{
name,
desc ? "${name} language server",
...
}:
{
inherit name;
description = desc;
inherit name description;
}
// lib.optionalAttrs (lspPackages.packages ? ${name}) {
package = lspPackages.packages.${name};
@ -216,26 +212,7 @@ in
imports =
let
mkLsp = import ./_mk-lsp.nix;
mkUnsupportedLsp =
{
name,
serverName ? name,
...
}:
lib.mkRemovedOptionModule [ "plugins" "lsp" "servers" name ] ''
nvim-lspconfig has switched from its own LSP configuration API to neovim's built-in LSP API.
'${serverName}' has not been updated to support neovim's built-in LSP API.
See https://github.com/neovim/nvim-lspconfig/issues/3705
'';
unsupported = lib.importJSON ../../../generated/unsupported-lspconfig-servers.json;
lspModules = map (
{
name,
serverName ? name,
...
}@lsp:
(if lib.elem serverName unsupported then mkUnsupportedLsp else mkLsp) lsp
) generatedServers;
lspModules = map mkLsp generatedServers;
baseLspPath = [
"plugins"
"lsp"
@ -244,9 +221,18 @@ in
renameModules = mapAttrsToList (
old: new: lib.mkRenamedOptionModule (baseLspPath ++ [ old ]) (baseLspPath ++ [ new ])
) renamedServers;
unsupportedModules = map (
name:
lib.mkRemovedOptionModule [ "plugins" "lsp" "servers" name ] ''
nvim-lspconfig has switched from its own LSP configuration API to neovim's built-in LSP API.
'${name}' has not been updated to support neovim's built-in LSP API.
See https://github.com/neovim/nvim-lspconfig/issues/3705
''
) unsupportedServers;
in
lspModules
++ renameModules
++ unsupportedModules
++ [
./ccls.nix
./hls.nix

View file

@ -7,6 +7,7 @@
"antlersls"
"ansiblels"
"apex_ls"
"atopile"
"autohotkey_lsp"
"awk_ls"
"azure_pipelines_ls"
@ -14,26 +15,26 @@
"basics_ls"
"bazelrc_lsp"
"bicep" # Bicep.Cli is packaged, but not Bicep.LangServer
"bitbake_ls"
"bqls"
"bqnlsp"
"bright_script"
"bsl_ls"
"buddy_ls"
"bufls"
"bzl"
"c3_lsp"
"cadence"
"cairo_ls"
"cds_lsp"
"cir_lsp_server"
"circom-lsp"
"clarity_lsp"
"clarinet"
"cobol_ls"
"codeqlls"
"codebook"
"coffeesense"
"contextive"
"copilot"
# coqPackages.coq-lsp is unavailable since the bump to coq 9.0: https://github.com/NixOS/nixpkgs/pull/389454
"coq_lsp"
"cspell_ls"
"css_variables"
"cssmodules_ls"
"cucumber_language_server"
@ -42,14 +43,15 @@
"daedalus_ls"
"dcmls"
"debputy"
"delphi_ls"
"djlsp"
"drools_lsp"
"docker_language_server"
"ds_pinyin_lsp"
"dts_lsp"
"ecsact"
"ember"
"emmylua_ls"
"esbonio"
"expert"
"facility_language_server"
"fennel_language_server"
"flux_lsp"
@ -62,13 +64,14 @@
"ginko_ls"
"glasgow"
"glint"
"gnls"
"gradle_ls"
"grammarly"
"graphql" # nodePackages.graphql-language-service-cli was removed in https://github.com/NixOS/nixpkgs/pull/382557
"groovyls"
"guile_ls"
"haxe_language_server"
"hdl_checker"
"herb_ls"
"hhvm"
"hie"
"hlasm"
@ -79,6 +82,7 @@
"jinja_lsp"
"julials"
"kcl"
"kotlin_lsp"
"kulala_ls"
"laravel_ls"
"lean3ls"
@ -102,15 +106,15 @@
"nxls"
"ocamlls"
"opencl_ls"
"openedge_ls"
"openscad_ls"
"pact_ls"
"pasls"
"pbls"
"perlls"
"phptools"
"pico8_ls"
"pkgbuild_language_server"
"please"
"pli"
"poryscript_pls"
"powershell_es"
"prismals"
@ -120,17 +124,18 @@
"puppet"
"purescriptls"
"pyre"
"pyrefly"
"r_language_server"
"racket_langserver"
"raku_navigator"
"reason_ls"
"relay_lsp"
"remark_ls"
"rnix"
"robotcode"
"robotframework_ls"
"roc_ls"
"rome"
"roslyn_ls"
"rpmspec"
"ruff_lsp" # deprecated and removed from nixpkgs
"salt_ls"
@ -148,19 +153,25 @@
"solidity_ls_nomicfoundation"
"somesass_ls"
"sorbet"
"sourcery"
"spyglassmc_language_server"
"sqlls"
"sqruff"
"steep"
"stimulus_ls"
"stylua"
"stylua3p_ls"
"svlangserver"
"tabby_ml"
"termux_language_server"
"textlsp"
"theme_check"
"tofu_ls"
"tombi"
"tsgo"
"tsp_server"
"turbo_ls"
"turtle_ls"
"ty"
# typst-lsp has been removed from nixpkgs as the project is archived
"typst_lsp"
"tvm_ffi_navigator"
@ -170,17 +181,18 @@
"unocss"
"uvls"
"v_analyzer"
"vdmj"
"veridian"
"vespa_ls"
"visualforce_ls"
# coqPackages.vscoq-language-server is unavailable since the bump to coq 9.0: https://github.com/NixOS/nixpkgs/pull/389454
"vscoqtop"
"vuels"
"vue_ls"
"wasm_language_tools"
"yang_lsp"
"yls"
"ziggy"
"ziggy_schema"
"zuban"
];
packages = {