Make tree-sitter kinda work

This commit is contained in:
Natsu Kagami 2024-10-07 21:11:48 +02:00
parent 53cafeb021
commit eb3d53b829
Signed by: nki
GPG key ID: 55A032EB38B49ADB
10 changed files with 187 additions and 27 deletions

View file

@ -129,25 +129,19 @@ let
include = "keyword_control_import";
};
configDir =
configFile =
let
toScm = name: lib.concatStringsSep "." (lib.splitString "_" name);
toml = formats.toml { };
file =
toml.generate "config.toml" {
highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases);
features = {
highlighting = true;
text_objects = true;
};
language = grammars;
};
in
runCommandLocal "kak-tree-sitter-config" { } ''
mkdir -p $out/kak-tree-sitter
ln -s ${file} $out/kak-tree-sitter/config.toml
'';
toml.generate "config.toml" {
highlight.groups = builtins.map toScm (builtins.attrNames highlighterGroups ++ builtins.attrNames aliases);
features = {
highlighting = true;
text_objects = true;
};
language = grammars;
};
extraFaces =
let
@ -162,10 +156,12 @@ in
{
rc = ''
# Enable kak-tree-sitter
eval %sh{env XDG_CONFIG_DIR=${configDir} ${lib.getExe' kak-tree-sitter "kak-tree-sitter"} --kakoune -d --server --init $kak_session}
eval %sh{kak-tree-sitter --kakoune -d --server --init $kak_session --user-config ${configFile}}
map global normal <c-t> ": enter-user-mode tree-sitter<ret>"
'';
extraPaths = "${kak-tree-sitter}/bin";
plugin = utils.mkFacesScript "kak-tree-sitter" extraFaces;
}

View file

@ -33,6 +33,7 @@ let
,
}: {
grammar.source.local.path = "${mkGrammarPackage args}";
grammar.link_args = grammarLinkArgs ++ [ "-o" "${name}.so" ];
queries.source.local.path = querySrc;
queries.path = queryPath;
};