dotfiles.nix/home/kakoune.nix

232 lines
5.8 KiB
Nix
Raw Normal View History

2022-07-26 04:22:16 +00:00
{ 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
];
2022-07-04 14:46:52 +00:00
programs.kakoune = {
enable = true;
2022-07-21 04:38:26 +00:00
2022-07-26 04:22:16 +00:00
extras.colors.enable = true;
extras.colors.dark = colorsToKakoune pkgs.lib.colors.tokyonight.dark;
extras.colors.light = colorsToKakoune pkgs.lib.colors.tokyonight.light;
2022-07-21 02:19:32 +00:00
config = {
2022-07-21 04:38:26 +00:00
autoReload = "yes";
2022-07-21 23:51:23 +00:00
hooks = [
# smarttab hooks
2022-07-21 23:51:23 +00:00
{
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
2022-07-21 23:51:23 +00:00
{
name = "WinSetOption";
2022-07-29 22:01:24 +00:00
option = "filetype=(none)";
2022-07-21 23:51:23 +00:00
commands = ''
lsp-enable-window
2022-07-29 22:01:24 +00:00
lsp-auto-hover-enable
2022-07-21 23:51:23 +00:00
'';
}
# general hooks
2022-07-21 23:51:23 +00:00
{
name = "WinSetOption";
option = "filetype=(haskell|nix)";
commands = ''
set-option window indentwidth 2
'';
}
2022-07-29 22:01:24 +00:00
{
name = "WinCreate";
option = ".*";
commands = ''
kakboard-enable
'';
}
2022-07-21 23:51:23 +00:00
];
indentWidth = 4;
2022-07-21 04:38:26 +00:00
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";
}
{
2022-07-21 23:51:23 +00:00
key = "<c-b>";
effect = ": fzf-mode<ret>b<ret>";
mode = "normal";
docstring = "Open fzf-mode buffer dialog with ctrl-b";
2022-07-21 04:38:26 +00:00
}
2022-07-29 22:01:24 +00:00
{
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";
}
2022-07-21 04:38:26 +00:00
];
numberLines.enable = true;
numberLines.highlightCursor = true;
numberLines.relative = true;
scrollOff.columns = 4;
scrollOff.lines = 2;
showMatching = true;
2022-07-21 23:51:23 +00:00
showWhitespace.enable = true;
2022-07-26 04:22:16 +00:00
showWhitespace.space = " ";
2022-07-21 23:51:23 +00:00
2022-07-26 04:22:16 +00:00
ui.assistant = "cat";
2022-07-21 04:38:26 +00:00
ui.enableMouse = true;
2022-07-26 04:22:16 +00:00
wrapLines.enable = true;
wrapLines.indent = true;
wrapLines.marker = "";
wrapLines.word = true;
2022-07-21 02:19:32 +00:00
};
2022-07-21 04:38:26 +00:00
extraConfig = ''
eval %sh{${pkgs.kak-lsp}/bin/kak-lsp --kakoune -s $kak_session}
2022-07-29 22:01:24 +00:00
enable-auto-pairs
alias global w!! sudo-write
2022-07-21 04:38:26 +00:00
'';
2022-07-21 02:19:32 +00:00
plugins = with pkgs.kakounePlugins; [
active-window-kak
auto-pairs-kak
connect-kak
2022-07-21 02:19:32 +00:00
fzf-kak
kak-lsp
kakboard
kakoune-state-save
kakoune-vertical-selection
2022-07-21 23:51:23 +00:00
pkgs.smarttab-kak
2022-07-29 22:01:24 +00:00
pkgs.kakoune-sudo-write
# disabled, tabs-kak tries to load before luar for some reason
# pkgs.luar
# tabs-kak
2022-07-21 02:19:32 +00:00
];
2022-07-04 14:46:52 +00:00
};
2022-07-26 04:22:16 +00:00
programs.fish.functions.set-kak-colors = {
body = ''
if test "$term_background" = light
kak-light
else
kak-dark
end
'';
onVariable = "term_background";
};
2022-08-13 19:31:44 +00:00
programs.fish.shellAliases = {
vi = "kak";
vim = "kak";
nvim = "kak";
};
2022-07-04 14:46:52 +00:00
}