Move kak-lsp config to new format
This commit is contained in:
parent
01521609d0
commit
b31be39a7a
5 changed files with 69 additions and 14 deletions
8
flake.lock
generated
8
flake.lock
generated
|
@ -639,16 +639,16 @@
|
||||||
"kak-lsp": {
|
"kak-lsp": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1737458684,
|
"lastModified": 1742457498,
|
||||||
"narHash": "sha256-wIKAChmD6gVfrRguywiAnpT3kbCbRk2k2u4ckd1CNOw=",
|
"narHash": "sha256-2jD0meehUNGvmywOY4D9CwP1qswD7QCPlctLBjngzvE=",
|
||||||
"owner": "kakoune-lsp",
|
"owner": "kakoune-lsp",
|
||||||
"repo": "kakoune-lsp",
|
"repo": "kakoune-lsp",
|
||||||
"rev": "d5db3de3b88a8a158e1bfa43f13d8766a6c6d522",
|
"rev": "30dfe2873dae089981d63d3405323a8e9def0468",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "kakoune-lsp",
|
"owner": "kakoune-lsp",
|
||||||
"ref": "v18.1.2",
|
"ref": "v18.1.3",
|
||||||
"repo": "kakoune-lsp",
|
"repo": "kakoune-lsp",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
# --- Sources
|
# --- Sources
|
||||||
kakoune.url = "github:mawww/kakoune";
|
kakoune.url = "github:mawww/kakoune";
|
||||||
kakoune.flake = false;
|
kakoune.flake = false;
|
||||||
kak-lsp.url = "github:kakoune-lsp/kakoune-lsp/v18.1.2";
|
kak-lsp.url = "github:kakoune-lsp/kakoune-lsp/v18.1.3";
|
||||||
kak-lsp.flake = false;
|
kak-lsp.flake = false;
|
||||||
nixos-m1.url = "github:tpwrules/nixos-apple-silicon";
|
nixos-m1.url = "github:tpwrules/nixos-apple-silicon";
|
||||||
nixos-m1.inputs.nixpkgs.follows = "nixpkgs";
|
nixos-m1.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
|
@ -59,6 +59,7 @@ in
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
cfg.autoloadFile;
|
cfg.autoloadFile;
|
||||||
|
xdg.dataFile."kak".source = "${cfg.package}/share/kak";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ let
|
||||||
kak-lsp = final.unstable.rustPlatform.buildRustPackage {
|
kak-lsp = final.unstable.rustPlatform.buildRustPackage {
|
||||||
name = "kak-lsp";
|
name = "kak-lsp";
|
||||||
src = inputs.kak-lsp;
|
src = inputs.kak-lsp;
|
||||||
cargoHash = "sha256-U9KxTHzIDtdJ3A62rcdvWlxJfnhbFnS6KDRaV0HJOHE=";
|
cargoHash = "sha256-8Y+haxC7ssN07ODZcKoDdTv0vEnKqxYseLPoQSNmWI4=";
|
||||||
buildInputs = [ final.libiconv ];
|
buildInputs = [ final.libiconv ];
|
||||||
|
|
||||||
meta.mainProgram = "kak-lsp";
|
meta.mainProgram = "kak-lsp";
|
||||||
|
|
|
@ -259,16 +259,64 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
kak-lsp-config =
|
per-lang-config = lang:
|
||||||
let
|
let
|
||||||
toml = formats.toml { };
|
toml = formats.toml { };
|
||||||
toLspConfig = builtins.mapAttrs (_: attrs: builtins.removeAttrs attrs [ "package" ]);
|
servers = lib.filterAttrs (_: server: builtins.elem lang server.filetypes) config.languageServers;
|
||||||
|
serverSettings = lib.mapAttrs
|
||||||
|
(name: server: builtins.removeAttrs
|
||||||
|
(server // {
|
||||||
|
root_globs = server.roots;
|
||||||
|
}) [ "package" "filetypes" "roots" ])
|
||||||
|
servers;
|
||||||
|
serversToml = toml.generate "kak-lsp-${lang}.toml" serverSettings;
|
||||||
|
lang-id =
|
||||||
|
if builtins.hasAttr lang config.languageIDs then ''
|
||||||
|
set-option buffer lsp_language_id ${config.languageIDs.${lang}}
|
||||||
|
'' else "# No lang-id remap needed";
|
||||||
in
|
in
|
||||||
toml.generate "kak-lsp.toml" ({
|
''
|
||||||
semantic_tokens.faces = config.faces;
|
# LSP Configuration for ${lang}
|
||||||
language_server = toLspConfig config.languageServers;
|
hook -group lsp-filetype-${lang} global BufSetOption filetype=(?:${lang}) %{
|
||||||
language_ids = config.languageIDs;
|
set-option buffer lsp_servers %{
|
||||||
} // config.raw);
|
${builtins.readFile serversToml}
|
||||||
|
}
|
||||||
|
${lang-id}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
|
lang-config =
|
||||||
|
let
|
||||||
|
langs = lib.unique (lib.flatten (lib.mapAttrsToList (_: server: server.filetypes) config.languageServers));
|
||||||
|
in
|
||||||
|
lib.concatMapStringsSep "\n" per-lang-config langs;
|
||||||
|
faces-config =
|
||||||
|
let
|
||||||
|
mapFace = face:
|
||||||
|
let
|
||||||
|
modifiers = if builtins.hasAttr "modifiers" face then ", modifiers=${builtins.toJSON face.modifiers}" else "";
|
||||||
|
in
|
||||||
|
"{face=${builtins.toJSON face.face}, token=${builtins.toJSON face.token}${modifiers}}";
|
||||||
|
faces = lib.concatMapStringsSep ",\n " mapFace config.faces;
|
||||||
|
in
|
||||||
|
''
|
||||||
|
set-option global lsp_semantic_tokens %{
|
||||||
|
[
|
||||||
|
${faces}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
|
# kak-lsp-config =
|
||||||
|
# let
|
||||||
|
# toml = formats.toml { };
|
||||||
|
# toLspConfig = builtins.mapAttrs (_: attrs: builtins.removeAttrs attrs [ "package" ]);
|
||||||
|
# in
|
||||||
|
# toml.generate "kak-lsp.toml" ({
|
||||||
|
# semantic_tokens.faces = config.faces;
|
||||||
|
# language_server = toLspConfig config.languageServers;
|
||||||
|
# language_ids = config.languageIDs;
|
||||||
|
# } // config.raw);
|
||||||
|
|
||||||
serverPackages =
|
serverPackages =
|
||||||
builtins.filter (v: v != null)
|
builtins.filter (v: v != null)
|
||||||
|
@ -279,7 +327,7 @@ in
|
||||||
plugin = writeTextDir "share/kak/autoload/kak-lsp.kak" ''
|
plugin = writeTextDir "share/kak/autoload/kak-lsp.kak" ''
|
||||||
hook global KakBegin .* %{
|
hook global KakBegin .* %{
|
||||||
try %{
|
try %{
|
||||||
eval %sh{kak-lsp --kakoune --config ${kak-lsp-config} -s $kak_session}
|
eval %sh{kak-lsp --kakoune -s $kak_session}
|
||||||
}
|
}
|
||||||
|
|
||||||
lsp-enable
|
lsp-enable
|
||||||
|
@ -327,6 +375,12 @@ in
|
||||||
define-command -params 0 -docstring "Import build" scala-build-import %{
|
define-command -params 0 -docstring "Import build" scala-build-import %{
|
||||||
lsp-execute-command 'build-import' '[]'
|
lsp-execute-command 'build-import' '[]'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## Language settings
|
||||||
|
${lang-config}
|
||||||
|
|
||||||
|
## Faces
|
||||||
|
${faces-config}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue