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

plugins.lsp: automatically remove unsupported servers

A new update script will check which "old" files do not have an
equivalent "new" file, then the plugins.lsp module will create a
removal assertion for any servers that are listed in the generated
file.
This commit is contained in:
Matt Sturgeon 2025-10-01 22:53:06 +01:00
parent fc779c6e82
commit 5c4a10093d
6 changed files with 68 additions and 3 deletions

View file

@ -51,6 +51,7 @@ writeShellApplication {
generate_json "${conform-formatters}" "conform-formatters" generate_json "${conform-formatters}" "conform-formatters"
generate_json "${lspconfig-servers}" "lspconfig-servers" generate_json "${lspconfig-servers}" "lspconfig-servers"
generate_json "${lspconfig-servers.unsupported}" "unsupported-lspconfig-servers"
if [ -n "$commit" ]; then if [ -n "$commit" ]; then
cd "$generated_dir" cd "$generated_dir"

View file

@ -1,5 +1,6 @@
{ {
lib, lib,
callPackage,
vimPlugins, vimPlugins,
neovimUtils, neovimUtils,
wrapNeovimUnstable, wrapNeovimUnstable,
@ -31,6 +32,7 @@ runCommand "lspconfig-servers"
pandoc pandoc
python3 python3
]; ];
passthru.unsupported = callPackage ./unsupported.nix { };
} }
'' ''
export HOME=$(realpath .) export HOME=$(realpath .)

View file

@ -0,0 +1,24 @@
{
runCommand,
jq,
vimPlugins,
}:
/**
Produces a JSON array of all nvim-lspconfig server configs that don't yet
support the new system.
I.e., files in the old `lua/lspconfig/configs/` directory, that aren't
present in the new `lsp/` directory.
*/
runCommand "unsupported-lspconfig-servers"
{
nativeBuildInputs = [ jq ];
lspconfig = vimPlugins.nvim-lspconfig;
}
''
for file in "$lspconfig"/lua/lspconfig/configs/*.lua
do
name=$(basename --suffix=.lua "$file")
[ -f "$lspconfig"/lsp/"$name".lua ] || echo "$name"
done | jq --raw-input . | jq --slurp [.] > "$out"
''

View file

@ -0,0 +1,16 @@
[
"bitbake_ls",
"bqnlsp",
"cadence",
"clarity_lsp",
"codeqlls",
"delphi_ls",
"drools_lsp",
"haxe_language_server",
"openedge_ls",
"pkgbuild_language_server",
"relay_lsp",
"sourcery",
"vdmj",
"vuels"
]

View file

@ -212,7 +212,26 @@ in
imports = imports =
let let
mkLsp = import ./_mk-lsp.nix; mkLsp = import ./_mk-lsp.nix;
lspModules = map mkLsp generatedServers; 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;
baseLspPath = [ baseLspPath = [
"plugins" "plugins"
"lsp" "lsp"

View file

@ -1,11 +1,14 @@
{ {
lib,
nixvimConfiguration, nixvimConfiguration,
name ? "lsp-all-servers", name ? "lsp-all-servers",
}: }:
let let
_file = ./lsp-servers.nix; _file = ./lsp-servers.nix;
renamed = builtins.attrNames (import ../plugins/lsp/language-servers/_renamed.nix); unsupported =
builtins.attrNames (import ../plugins/lsp/language-servers/_renamed.nix)
++ lib.importJSON ../generated/unsupported-lspconfig-servers.json;
enable-lsp-module = { enable-lsp-module = {
inherit _file; inherit _file;
@ -63,7 +66,7 @@ let
package = null; package = null;
} }
)) ))
(lib.filterAttrs (server: _: !(lib.elem server renamed))) (lib.filterAttrs (server: _: !(lib.elem server unsupported)))
]; ];
# TODO 2025-10-01 # TODO 2025-10-01