Make tree-sitter kinda work
This commit is contained in:
parent
53cafeb021
commit
eb3d53b829
10 changed files with 187 additions and 27 deletions
|
@ -11,6 +11,7 @@ in
|
|||
++ callPackage ./themes.nix { }
|
||||
++ [
|
||||
(callPackage ./kaktex { })
|
||||
(callPackage ./faces.nix { })
|
||||
rc
|
||||
tree-sitter.plugin
|
||||
lsp.plugin
|
||||
|
@ -23,6 +24,7 @@ in
|
|||
rm "$out/bin/kak"
|
||||
makeWrapper "${kakoune-unwrapped}/bin/kak" "$out/bin/kak" \
|
||||
--set KAKOUNE_RUNTIME "$out/share/kak" \
|
||||
--suffix PATH ":" "${lsp.extraPaths}"
|
||||
--suffix PATH ":" "${lsp.extraPaths}" \
|
||||
--suffix PATH ":" "${tree-sitter.extraPaths}"
|
||||
'';
|
||||
})
|
||||
|
|
31
packages/common/nki-kakoune/faces.nix
Normal file
31
packages/common/nki-kakoune/faces.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ callPackage, ... } :
|
||||
let
|
||||
utils = callPackage ./utils.nix { };
|
||||
faces = {
|
||||
Default = "%opt{text},%opt{base}";
|
||||
BufferPadding = "%opt{base},%opt{base}";
|
||||
MenuForeground = "%opt{blue},white+bF";
|
||||
MenuBackground = "%opt{sky},white+F";
|
||||
Information = "%opt{sky},white";
|
||||
# Markdown help color scheme
|
||||
InfoDefault = "Information";
|
||||
InfoBlock = "@block";
|
||||
InfoBlockQuote = "+i@block";
|
||||
InfoBullet = "@bullet";
|
||||
InfoHeader = "@header";
|
||||
InfoLink = "@link";
|
||||
InfoLinkMono = "+b@mono";
|
||||
InfoMono = "@mono";
|
||||
InfoRule = "+b@Information";
|
||||
InfoDiagnosticError = "@DiagnosticError";
|
||||
InfoDiagnosticHint = "@DiagnosticHint";
|
||||
InfoDiagnosticInformation = "@Information";
|
||||
InfoDiagnosticWarning = "@DiagnosticWarning";
|
||||
# Extra faces
|
||||
macro = "+u@function";
|
||||
method = "@function";
|
||||
format_specifier = "+i@string";
|
||||
mutable_variable = "+i@variable";
|
||||
class = "+b@variable";
|
||||
};
|
||||
in utils.mkFacesScript "default-faces" faces
|
|
@ -248,7 +248,7 @@ let
|
|||
kak-lsp-config =
|
||||
let
|
||||
toml = formats.toml { };
|
||||
toLspConfig = attrs: builtins.removeAttrs attrs [ "package" ];
|
||||
toLspConfig = builtins.mapAttrs (_: attrs: builtins.removeAttrs attrs [ "package" ]);
|
||||
in
|
||||
toml.generate "kak-lsp.toml" ({
|
||||
semantic_tokens.faces = config.faces;
|
||||
|
@ -265,16 +265,16 @@ in
|
|||
plugin = writeTextDir "share/kak/autoload/kak-lsp.kak" ''
|
||||
hook global KakBegin .* %{
|
||||
try %{
|
||||
eval %sh{${lib.getExe kak-lsp} --config ${kak-lsp-config} -s $kak_session}
|
||||
eval %sh{${lib.getExe kak-lsp} --kakoune --config ${kak-lsp-config} -s $kak_session}
|
||||
}
|
||||
|
||||
lsp-enable
|
||||
map window lsp N -docstring "Display the next message request" ": lsp-show-message-request-next<ret>"
|
||||
map window normal <c-l> ": enter-user-mode lsp<ret>"
|
||||
map window normal <c-h> ": lsp-hover<ret>"
|
||||
map window normal <c-s-h> ": lsp-hover-buffer<ret>"
|
||||
map global lsp N -docstring "Display the next message request" ": lsp-show-message-request-next<ret>"
|
||||
map global normal <c-l> ": enter-user-mode lsp<ret>"
|
||||
map global normal <c-h> ": lsp-hover<ret>"
|
||||
map global normal <c-s-h> ": lsp-hover-buffer<ret>"
|
||||
# lsp-auto-hover-insert-mode-enable
|
||||
set window lsp_hover_anchor true
|
||||
set global lsp_hover_anchor true
|
||||
map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
|
||||
map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
|
||||
map global object <a-a> '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ lib, writeTextDir, ... }: {
|
||||
mkFacesScript = name: faces: writeTextDir "share/kak/autoload/${name}/faces.kak" ''
|
||||
hook global KakBegin .* {
|
||||
hook global KakBegin .* %{
|
||||
${lib.concatStringsSep "\n" (builtins.attrValues (builtins.mapAttrs (name: face: " face global ${name} \"${face}\"") faces))}
|
||||
}
|
||||
'';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue