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, callPackage,
vimPlugins, vimPlugins,
neovimUtils,
wrapNeovimUnstable,
neovim-unwrapped,
runCommand, runCommand,
pandoc, 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" runCommand "lspconfig-servers"
{ {
lspconfig = "${vimPlugins.nvim-lspconfig}"; lspconfig = vimPlugins.nvim-lspconfig;
nativeBuildInputs = [ nativeBuildInputs = [
jq
pandoc pandoc
python3
]; ];
passthru.unsupported = callPackage ./unsupported.nix { }; passthru.unsupported = callPackage ./unsupported.nix { };
} }
'' ''
export HOME=$(realpath .) for file in "$lspconfig"/lsp/*.lua
# Generates `lsp.json` do
${lib.getExe nvim} -u NONE -E -R --headless +'luafile ${./lspconfig-servers.lua}' +q name=$(basename --suffix=.lua "$file")
LUA_FILTER=${./desc-filter.lua} python3 ${./clean-desc.py} "lsp.json" >$out
# 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) function Header(elem)
return pandoc.Strong(elem.content) return pandoc.Strong(elem.content)
end 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; with lib;
let let
renamedServers = import ./_renamed.nix; renamedServers = import ./_renamed.nix;
unsupportedServers = lib.importJSON ../../../generated/unsupported-lspconfig-servers.json;
lspExtraArgs = { lspExtraArgs = {
dartls = { dartls = {
@ -192,15 +193,10 @@ let
generatedServers = lib.pipe ../../../generated/lspconfig-servers.json [ generatedServers = lib.pipe ../../../generated/lspconfig-servers.json [
lib.importJSON lib.importJSON
(lib.map ( (lib.mapAttrsToList (
name: description:
{ {
name, inherit name description;
desc ? "${name} language server",
...
}:
{
inherit name;
description = desc;
} }
// lib.optionalAttrs (lspPackages.packages ? ${name}) { // lib.optionalAttrs (lspPackages.packages ? ${name}) {
package = lspPackages.packages.${name}; package = lspPackages.packages.${name};
@ -216,26 +212,7 @@ in
imports = imports =
let let
mkLsp = import ./_mk-lsp.nix; mkLsp = import ./_mk-lsp.nix;
mkUnsupportedLsp = lspModules = map mkLsp generatedServers;
{
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;
baseLspPath = [ baseLspPath = [
"plugins" "plugins"
"lsp" "lsp"
@ -244,9 +221,18 @@ in
renameModules = mapAttrsToList ( renameModules = mapAttrsToList (
old: new: lib.mkRenamedOptionModule (baseLspPath ++ [ old ]) (baseLspPath ++ [ new ]) old: new: lib.mkRenamedOptionModule (baseLspPath ++ [ old ]) (baseLspPath ++ [ new ])
) renamedServers; ) 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 in
lspModules lspModules
++ renameModules ++ renameModules
++ unsupportedModules
++ [ ++ [
./ccls.nix ./ccls.nix
./hls.nix ./hls.nix

View file

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