dotfiles.nix/home/kakoune.nix

227 lines
5.7 KiB
Nix

{ pkgs, ... }:
let
colorsToKakoune = colors: with colors; {
attribute = magenta;
builtin = cyan;
comment = comment;
documentation = comment;
enum = red;
function = blue;
keyword = magenta;
meta = foreground;
module = blue;
operator = magenta;
parameter = yellow;
string = green;
type = magenta;
value = orange;
variable = white;
block = blue;
bullet = comment;
header = blue;
link = cyan;
list = foreground;
mono = foreground;
title = white;
BufferPadding = [ background background ];
Default = [ foreground background ];
PrimarySelection = [ "default" "!${magenta}40" ];
SecondarySelection = [ "default" "!${green}40" ];
PrimaryCursor = [ "default" "!${blue}80" ];
SecondaryCursor = [ "default" "!${green}80" ];
PrimaryCursorEol = [ "default" "!${red}80" ];
SecondaryCursorEol = [ "default" "!${orange}80" ];
LineNumbers = comment;
LineNumberCursor = orange;
LineNumbersWrapped = [ background background ];
MenuForeground = [ active_tab_foreground active_tab_background ];
MenuBackground = [ inactive_tab_foreground inactive_tab_background ];
MenuInfo = green;
Information = [ inactive_tab_foreground inactive_tab_background ];
Error = red;
StatusLine = [ active_tab_foreground "${active_tab_background}+b" ];
StatusLineMode = orange;
StatusLineInfo = blue;
StatusLineValue = foreground;
StatusCursor = [ "default" "!${blue}80" ];
Prompt = yellow;
MatchingChar = [ "default" comment ];
Whitespace = comment;
InfoDefault = "Information";
InfoBlock = "block";
InfoBlockQuote = "quote";
InfoBullet = "bullet";
InfoHeader = "header";
InfoLink = "link";
InfoLinkMono = "header";
InfoMono = "mono";
InfoRule = "comment";
InfoDiagnosticError = "InlayDiagnosticError";
InfoDiagnosticHint = "InlayDiagnosticHint";
InfoDiagnosticInformation = "InlayDiagnosticInfo";
InfoDiagnosticWarning = "InlayDiagnosticWarning";
};
in
{
home.packages = with pkgs; [
kak-lsp
];
programs.kakoune = {
enable = true;
extras.colors.enable = true;
extras.colors.dark = colorsToKakoune pkgs.lib.colors.tokyonight.dark;
extras.colors.light = colorsToKakoune pkgs.lib.colors.tokyonight.light;
config = {
autoReload = "yes";
hooks = [
# smarttab hooks
{
name = "BufOpenFile";
option = ".*";
commands = "expandtab";
}
{
name = "BufNewFile";
option = ".*";
commands = "expandtab";
}
{
name = "WinSetOption";
option = "filetype=(makefile)";
commands = "noexpandtab";
}
{
name = "ModuleLoaded";
option = "smarttab";
commands = ''
set-option global softtabstop %opt{indentwidth}
'';
}
# lsp hooks
{
name = "WinSetOption";
option = "filetype=(none)";
commands = ''
lsp-enable-window
lsp-auto-hover-enable
'';
}
# general hooks
{
name = "WinSetOption";
option = "filetype=(haskell|nix)";
commands = ''
set-option window indentwidth 2
'';
}
{
name = "WinCreate";
option = ".*";
commands = ''
kakboard-enable
'';
}
];
indentWidth = 4;
keyMappings = [
{
key = "<c-a-p>";
effect = ": fzf-mode<ret>";
mode = "normal";
docstring = "Open fzf-mode with ctrl-alt-p";
}
{
key = "<c-p>";
effect = ": fzf-mode<ret>f<ret>";
mode = "normal";
docstring = "Open fzf-mode file dialog with ctrl-p";
}
{
key = "<c-b>";
effect = ": fzf-mode<ret>b<ret>";
mode = "normal";
docstring = "Open fzf-mode buffer dialog with ctrl-b";
}
{
key = "v";
effect = ": vertical-selection-down<ret>";
mode = "user";
docstring = "Extend vertical selection down";
}
{
key = "<a-v>";
effect = ": vertical-selection-up<ret>";
mode = "user";
docstring = "Extend vertical selection up";
}
{
key = "V";
effect = ": vertical-selection-up-and-down<ret>";
mode = "user";
docstring = "Extend vertical selection both up and down";
}
];
numberLines.enable = true;
numberLines.highlightCursor = true;
numberLines.relative = true;
scrollOff.columns = 4;
scrollOff.lines = 2;
showMatching = true;
showWhitespace.enable = true;
showWhitespace.space = " ";
ui.assistant = "cat";
ui.enableMouse = true;
wrapLines.enable = true;
wrapLines.indent = true;
wrapLines.marker = "";
wrapLines.word = true;
};
extraConfig = ''
eval %sh{${pkgs.kak-lsp}/bin/kak-lsp --kakoune -s $kak_session}
enable-auto-pairs
alias global w!! sudo-write
'';
plugins = with pkgs.kakounePlugins; [
active-window-kak
auto-pairs-kak
connect-kak
fzf-kak
kak-lsp
kakboard
kakoune-state-save
kakoune-vertical-selection
pkgs.smarttab-kak
pkgs.kakoune-sudo-write
# disabled, tabs-kak tries to load before luar for some reason
# pkgs.luar
# tabs-kak
];
};
programs.fish.functions.set-kak-colors = {
body = ''
if test "$term_background" = light
kak-light
else
kak-dark
end
'';
onVariable = "term_background";
};
}