This commit is contained in:
Riley Apeldoorn 2022-05-16 17:57:58 +02:00
parent b313f64189
commit a646e3e016
3 changed files with 23 additions and 153 deletions

View file

@ -23,5 +23,6 @@ pkgs.writeTextFile (rec {
face global crosshairs_line "default,rgb:${background.normal}" face global crosshairs_line "default,rgb:${background.normal}"
face global MenuForeground "default,rgb:${blue.normal}" face global MenuForeground "default,rgb:${blue.normal}"
face global MenuBackground "default,rgb:313131" face global MenuBackground "default,rgb:313131"
''; '';
}) })

View file

@ -1,140 +1,8 @@
{ lib, pkgs, config, ... }: { lib, pkgs, config, ... }:
let kakrc = pkgs.writeTextFile (rec { let kakoune = import ./kakoune.nix; in
name = "kakrc.kak";
destination = "/share/kak/autoload/${name}";
text = with config.riley.theme; ''
# Line numbering with lib; {
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>'
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) ''
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
}
# Load language-specific color schemes
hook global WinSetOption filetype=(haskell) %{
colorscheme haskell
lsp-enable-window
lsp-inlay-diagnostics-enable window
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>'
}
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 }
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
face global InlayDiagnosticInfo rgb:4d965a+f
'');
});
# Syntax colors
colors = (import ./colors {
theme = config.riley.theme;
inherit lib pkgs;
});
in with lib; {
options.editor = { options.editor = {
@ -148,18 +16,19 @@ in with lib; {
}; };
config = mkIf (config.editor.kak.enable) { config = with config.editor; mkIf (kak.enable) {
environment.systemPackages = with pkgs; [ environment.systemPackages = [
(pkgs.kakoune.override { (kakoune {
plugins = [
# Custom config inherit (kak) haskell python rust nix;
kakrc typescript = kak.ts;
kak-crosshairs = pkgs.kakounePlugins.kak-crosshairs;
inherit pkgs lib;
theme = config.riley.theme;
] ++ (lib.optionals config.riley.kak.ide (import ./lsp.nix {
inherit pkgs lib config;
})) ++ colors;
}) })
]; ];

View file

@ -23,17 +23,10 @@ let keybinds = ''
''; '';
# Initialization code for IDE mode needed for every supported # Initialization code for IDE mode needed for every supported
# language. # language, and inlay diagnostics.
ide-init = '' ide-init = ''
eval %sh{ kak-lsp --kakoune -s $kak_session } eval %sh{ kak-lsp --kakoune -s $kak_session }
lsp-enable-window lsp-enable-window
'';
# Implies `ide-init`. Adds inlay diagnostics support, code actions
# and hover.
ide-core = ''
${ide-init}
lsp-inlay-diagnostics-enable window lsp-inlay-diagnostics-enable window
@ -45,6 +38,13 @@ let keybinds = ''
lsp-inlay-diagnostics-enable window lsp-inlay-diagnostics-enable window
} }
'';
# Implies `ide-init`. Adds code actions and hover.
ide-core = ''
${ide-init}
map buffer normal <tab> ': lsp-code-actions<ret>' map buffer normal <tab> ': lsp-code-actions<ret>'
map buffer normal <ret> ': lsp-hover<ret>' map buffer normal <ret> ': lsp-hover<ret>'