config/modules/kak/default.nix

169 lines
4.3 KiB
Nix
Raw Normal View History

2022-01-10 19:25:34 +01:00
{ lib, pkgs, config, ... }:
let kakrc = pkgs.writeTextFile (rec {
name = "kakrc.kak";
destination = "/share/kak/autoload/${name}";
2022-01-12 00:20:57 +01:00
text = with config.riley.theme; ''
2022-01-10 19:25:34 +01:00
# Line numbering
add-highlighter global/ number-lines -separator ' ' -hlcursor
# Setting the tabstop to 4 (even though I have an ultrawide monitor)
set-option global tabstop 4
set global ui_options ncurses_assistant=cat
# Use Alt-Tab to switch between open buffers
map global insert <a-tab> <esc>:buffer-next<ret>
map global normal <a-tab> :buffer-next<ret>
def new-tab %{ prompt -file-completion '>' 'terminal kak -c %val{session} %val{text}' }
map global normal <a-ret> ': new-tab<ret>'
2022-01-10 19:25:34 +01:00
colorscheme common
face global LineNumbers rgb:${background.slight}
face global BufferPadding rgb:${background.slight}
face global LineNumberCursor rgb:${foreground.primary}
face global crosshairs_line "default,rgb:${background.normal}"
face global MenuForeground "default,blue"
face global MenuBackground "default,rgb:313131"
face global InlayHint rgb:828282
face global comment rgb:${foreground.slight}
'' + (lib.optionalString (config.riley.kak.ide) ''
2022-01-10 19:25:34 +01:00
eval %sh{ kak-lsp --kakoune -s $kak_session }
hook global -group yeet ModuleLoaded rust %{
# Override the Rust highlighting with semantic
# tokens supplied by the LSP client
remove-hooks global rust-highlight
remove-highlighter shared/rust
# Request tokens
lsp-semantic-tokens
# Self-destruct this hook (it should only run once)
remove-hooks global yeet
2022-01-10 19:25:34 +01:00
}
# Load language-specific color schemes
hook global WinSetOption filetype=(haskell) %{
colorscheme haskell
lsp-enable-window
2022-03-08 06:56:23 +01:00
lsp-inlay-diagnostics-enable window
2022-01-10 19:25:34 +01:00
2022-03-08 06:56:23 +01:00
map global normal <tab> ': lsp-code-actions<ret>'
map global normal <ret> ': lsp-hover<ret>'
hook window ModeChange .*:.*:insert %{
remove-highlighter window/lsp_diagnostics
}
hook window ModeChange .*:insert:normal %{
lsp-inlay-diagnostics-enable window
}
set global lsp_inlay_diagnostic_sign '>'
map global insert <tab> '<a-;><gt>'
2022-01-10 19:25:34 +01:00
}
hook global WinSetOption filetype=(rust) %{
lsp-enable-window
lsp-inlay-diagnostics-enable window
colorscheme rust
git show-diff
hook buffer BufReload .* %{
git update-diff
}
hook buffer NormalIdle .* %{ git update-diff }
hook buffer InsertIdle .* %{ git update-diff }
2022-01-10 19:25:34 +01:00
hook window -group semtok BufReload .* lsp-semantic-tokens
hook window -group semtok NormalIdle .* lsp-semantic-tokens
hook window -group semtok InsertIdle .* lsp-semantic-tokens
hook -once -always window WinSetOption filetype=.* %{
remove-hooks window semtok
}
hook window ModeChange .*:.*:insert %{
remove-highlighter window/lsp_diagnostics
}
hook window ModeChange .*:insert:normal %{
lsp-inlay-diagnostics-enable window
}
set global lsp_inlay_diagnostic_sign '>'
map global normal <tab> ': lsp-code-actions<ret>'
map global normal <ret> ': lsp-hover<ret>'
}
hook global WinSetOption filetype=(nix) %{
colorscheme nix
lsp-enable-window
}
face global InlayDiagnosticWarning rgb:a39e31+f
face global InlayDiagnosticError rgb:ad494f+f
face global InlayDiagnosticHint rgb:4d965a+f
2022-03-08 06:56:23 +01:00
face global InlayDiagnosticInfo rgb:4d965a+f
2022-01-10 19:25:34 +01:00
'');
});
# Syntax colors
colors = (import ./colors {
2022-01-12 00:20:57 +01:00
theme = config.riley.theme;
2022-01-10 19:25:34 +01:00
inherit lib pkgs;
});
in with lib; {
2022-05-15 23:32:21 +02:00
options.editor = {
kak.enable = (mkEnableOption "kakoune editor") // { default = true; };
2022-05-15 23:32:21 +02:00
kak.rust = mkEnableOption "Rust support in Kakoune";
2022-05-16 17:44:49 +02:00
kak.ts = mkEnableOption "TypeScript support in Kakoune";
2022-05-15 23:32:21 +02:00
kak.haskell = mkEnableOption "Haskell support in Kakoune";
2022-05-16 17:44:49 +02:00
kak.python = mkEnableOption "Python 3.9 support in Kakoune";
kak.nix = (mkEnableOption "Nix support in Kakoune") // { default = true; };
2022-05-15 23:32:21 +02:00
};
2022-05-16 17:44:49 +02:00
config = mkIf (config.editor.kak.enable) {
environment.systemPackages = with pkgs; [
(pkgs.kakoune.override {
plugins = [
# Custom config
kakrc
] ++ (lib.optionals config.riley.kak.ide (import ./lsp.nix {
inherit pkgs lib config;
})) ++ colors;
})
];
};
2022-01-10 19:25:34 +01:00
}