More efficient kakoune editing integration

This commit is contained in:
Natsu Kagami 2022-01-12 17:21:36 -05:00
parent d5989c525c
commit d625bb2c15
Signed by: nki
GPG key ID: 7306B3D3C3AD6E51
5 changed files with 111 additions and 3 deletions

View file

@ -19,10 +19,11 @@ let
};
in
{
imports = [ ../modules/programs/my-kakoune ];
imports = [ ../modules/programs/my-kakoune ./kaktex.nix ];
# Enable the kakoune package.
programs.my-kakoune.enable = true;
programs.my-kakoune.enable-fish-session = true;
programs.kak-lsp.enable = true;
programs.my-kakoune.package = kakounePkg;

28
home/kakoune/kaktex Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env fish
function usage
echo "Usage: "
echo " kaktex set [client] [session]"
echo " kaktex jump [file] [line]"
exit 1
end
if test (count $argv) -ne 3
usage
end
switch $argv[1]
case "set"
set -U _kaktex_client $argv[2]
set -U _kaktex_session $argv[3]
case "jump"
echo "
evaluate-commands -client $_kaktex_client %{
evaluate-commands -try-client $_kaktex_client %{
edit -- $argv[2] $argv[3]
}
}
" | kak -p $_kaktex_session
case '*'
usage
end

22
home/kakoune/kaktex.nix Normal file
View file

@ -0,0 +1,22 @@
{ config, pkgs, lib, ... }:
let
kaktexScript = ./kaktex;
in
{
# Create kak-tex executable
home.file.kaktex = {
source = kaktexScript;
executable = true;
target = ".bin/kaktex";
};
# Source kaktex whenever we have a tex file
programs.my-kakoune.rc = ''
hook global WinSetOption filetype=(tex|latex) %{
eval %sh{
${kaktexScript} set $kak_client $kak_session
}
}
'';
}