nix-dotfiles/snippets/kakoune.nix
vorboyvo a5349ca647 Did A BUNCH of semantic refactoring.
Added i3blocks config; not active.
2024-12-04 12:53:29 -05:00

130 lines
3.4 KiB
Nix

{ pkgs, ... }:
{
programs.kakoune = {
enable = true;
defaultEditor = true;
plugins = with pkgs.kakounePlugins;
[ kak-fzf byline-kak kakboard auto-pairs-kak ];
config = {
colorScheme = "tomorrow-night";
numberLines = {
enable = true;
highlightCursor = true;
};
showMatching = true;
tabStop = 2;
indentWidth = 2;
hooks = [
{
name = "WinCreate";
commands = "kakboard-enable";
option = ".*";
}
{
name = "BufCreate";
commands = "set buffer filetype typst";
option = ".*\.typ";
}
{
# When the filetype=latex option is set in a buffer context (automatically), add a new hook to build the latex file on write
name = "BufSetOption";
option = "filetype=latex";
commands = "hook buffer BufWritePost .* %{ texlab-build }";
}
{
name = "BufSetOption";
option = "filetype=typst";
commands = "hook buffer BufWritePost .* %{ nop %sh{ typst compile $kak_buffile } }";
}
{
# When the filetype=markdown option is set (automatically), set word wrap on
name = "WinSetOption";
option = "filetype=markdown";
commands = "set-option window lintcmd \"proselint\"";
}
# {
# name = "BufSetOption";
# option = "filetype=markdown";
# commands = ''
# hook buffer BufWritePost .* %{ %sh{
#
# } };
# '';
# }
];
keyMappings = [
# Define select all
{
key = "a";
mode = "user";
effect = "*%s<ret>";
docstring = "Select all";
}
# Define usermode yank/copy and paste
{
key = "y";
mode = "user";
effect = "<a-|> wl-copy<ret>";
}
{
key = "p";
mode = "user";
effect = "<a-!> wl-paste -n<ret>";
}
{
key = "P";
mode = "user";
effect = "! wl-paste -n<ret>";
}
];
};
extraConfig = ''
# highlight trailing whitespace
add-highlighter global/trailing-whitespace regex '\h+$' 0:Error
# don't remove trailing indent
set global disabled_hooks .*-trim-indent
source ${pkgs.writeText "kakoune-divider.kak" (builtins.readFile ./kakoune/divider.kak)}
set-option global divider_face LineNumbers
divider-on 80
# byline enables extending selection with x
require-module byline
eval %sh{kak-lsp --kakoune -s $kak_session}
lsp-enable
'';
};
xdg.configFile."kak-lsp/kak-lsp.toml".source =
./kakoune/kak-lsp.toml;
xdg.desktopEntries.kakoune = {
name = "Kakoune";
genericName = "Text Editor";
comment = "Edit text files";
icon = "kak";
exec = "kak %F";
terminal = true;
mimeType = [
"text/english"
"text/plain"
"text/x-makefile"
"text/x-c++hdr"
"text/x-c++src"
"text/x-chdr"
"text/x-csrc"
"text/x-java"
"text/x-moc"
"text/x-pascal"
"text/x-tcl"
"text/x-tex"
"application/x-shellscript"
"text/x-c"
"text/x-c++"
"text/x-devicetree-source"
];
categories = [ "Utility" "TextEditor" ];
};
}