226 lines
8.2 KiB
Nix
226 lines
8.2 KiB
Nix
{ pkgs, lib, config, specialArgs, options, modulesPath }:
|
||
|
||
with pkgs;
|
||
with pkgs.kakouneUtils;
|
||
|
||
let
|
||
config = writeTextFile (rec {
|
||
name = "kakrc.kak";
|
||
destination = "/share/kak/autoload/${name}";
|
||
text = ''
|
||
hook global KakBegin .* %{
|
||
colorscheme colors
|
||
}
|
||
map global user y <a-|>${wl-clipboard}/bin/wl-copy<ret>
|
||
map global user p !${wl-clipboard}/bin/wl-paste<ret>
|
||
addhl global/ wrap
|
||
|
||
hook global WinSetOption filetype=kaktree %{
|
||
remove-highlighter buffer/numbers
|
||
remove-highlighter buffer/matching
|
||
remove-highlighter buffer/wrap
|
||
set-option global kaktree_indentation 1
|
||
set-option global kaktree_dir_icon_open '▾ 🗁 '
|
||
set-option global kaktree_dir_icon_close '▸ 🗀 '
|
||
set-option global kaktree_file_icon '⠀⠀🖺'
|
||
remove-highlighter buffer/show-whitespaces
|
||
set window modelinefmt ' '
|
||
}
|
||
|
||
hook global WinSetOption filetype=(javascript|typescript) %{
|
||
map buffer normal <tab> ': lsp-code-actions<ret>'
|
||
map buffer normal <ret> ': lsp-hover<ret>'
|
||
|
||
lsp-enable-window
|
||
hook window ModeChange .*:.*:insert %{
|
||
lsp-inlay-diagnostics-disable window
|
||
remove-highlighter window/lsp_diagnostics
|
||
}
|
||
hook window ModeChange .*:insert:normal %{
|
||
lsp-inlay-diagnostics-enable window
|
||
}
|
||
|
||
}
|
||
|
||
hook global WinCreate [^*]* %{
|
||
editorconfig-load
|
||
kaktree-enable
|
||
}
|
||
|
||
'';
|
||
});
|
||
lsp-config = writeTextFile (rec {
|
||
name = "kak-lsp.toml";
|
||
destination = "/share/kak-lsp/${name}";
|
||
text = ''
|
||
[language.typescript]
|
||
filetypes = ["typescript", "javascript"]
|
||
roots = ["package.json"]
|
||
command = "rslint-lsp"
|
||
'';
|
||
});
|
||
colors = writeTextFile (rec {
|
||
name = "colors.kak";
|
||
destination = "/share/kak/colors/${name}";
|
||
text = ''# Kanagawa theme for Kakoune
|
||
|
||
# Color palette
|
||
# declare-option str black 'rgb:0a0e14'
|
||
declare-option str black default
|
||
declare-option str dark 'rgb:090618'
|
||
declare-option str gray 'rgb:727169'
|
||
declare-option str aqua 'rgb:6A9589'
|
||
declare-option str white 'rgb:DCD7BA'
|
||
declare-option str blue 'rgb:7E9CD8'
|
||
declare-option str cyan 'rgb:7FB4CA'
|
||
declare-option str blue_green 'rgb:7AA89F'
|
||
declare-option str green 'rgb:98BB6C'
|
||
declare-option str light_orange 'rgb:DCA561'
|
||
declare-option str orange 'rgb:FFA066'
|
||
declare-option str pink 'rgb:D27E99'
|
||
declare-option str purple 'rgb:957fb8'
|
||
declare-option str red 'rgb:C34043'
|
||
declare-option str yellow 'rgb:E6C384'
|
||
declare-option str lime 'rgb:C0A36E'
|
||
declare-option str psel 'rgba:2D4F6780'
|
||
declare-option str ssel 'rgba:22324980'
|
||
declare-option str dimgray 'rgb:54546D'
|
||
|
||
declare-option str background %opt{black}
|
||
declare-option str dimmed_background %opt{gray}
|
||
declare-option str foreground %opt{white}
|
||
|
||
# Reference
|
||
# https://github.com/mawww/kakoune/blob/master/colors/default.kak
|
||
# For code
|
||
set-face global value "%opt{yellow}"
|
||
set-face global type "%opt{cyan}"
|
||
set-face global variable "%opt{yellow}"
|
||
set-face global module "%opt{white}"
|
||
set-face global function "%opt{blue}"
|
||
set-face global string "%opt{green}"
|
||
set-face global keyword "%opt{purple}"
|
||
set-face global operator "%opt{lime}"
|
||
set-face global attribute "%opt{blue_green}"
|
||
set-face global bracket "%opt{white}+b"
|
||
set-face global arguement "%opt{light_orange}"
|
||
set-face global comma "%opt{white}"
|
||
set-face global constant "%opt{blue_green}+b"
|
||
set-face global class "%opt{pink}"
|
||
set-face global comment "%opt{gray}+i"
|
||
set-face global meta "%opt{aqua}"
|
||
set-face global builtin "%opt{cyan}+b"
|
||
|
||
# For markup
|
||
set-face global title "%opt{pink}"
|
||
set-face global header "%opt{orange}"
|
||
set-face global bold "%opt{pink}"
|
||
set-face global italic "%opt{purple}"
|
||
set-face global mono "%opt{green}"
|
||
set-face global block "%opt{cyan}"
|
||
set-face global link "%opt{green}"
|
||
set-face global bullet "%opt{green}"
|
||
set-face global list "%opt{white}"
|
||
|
||
# Builtin faces
|
||
set-face global Default "%opt{white},%opt{black}"
|
||
# set-face global Default "%opt{white},default"
|
||
set-face global PrimarySelection "default,%opt{psel}"
|
||
set-face global SecondarySelection "default,%opt{ssel}"
|
||
set-face global PrimaryCursor "%opt{dark},%opt{cyan}"
|
||
set-face global SecondaryCursor "%opt{dark},%opt{aqua}"
|
||
set-face global PrimaryCursorEol "%opt{dark},%opt{light_orange}"
|
||
set-face global SecondaryCursorEol "%opt{dark},%opt{blue}"
|
||
set-face global LineNumbers "%opt{gray},%opt{black}"
|
||
set-face global LineNumberCursor "%opt{purple},%opt{black}+b"
|
||
set-face global LineNumbersWrapped "%opt{gray},%opt{black}+i"
|
||
set-face global MenuForeground "%opt{dark},%opt{white}+b"
|
||
set-face global MenuBackground "%opt{white},%opt{dark}"
|
||
set-face global MenuInfo "%opt{dark},%opt{orange}"
|
||
set-face global Information "%opt{yellow},%opt{black}"
|
||
set-face global Error "%opt{red},%opt{black}"
|
||
set-face global StatusLine "%opt{white},%opt{black}"
|
||
set-face global StatusLineMode "%opt{aqua},%opt{black}"
|
||
set-face global StatusLineInfo "%opt{purple},%opt{black}"
|
||
set-face global StatusLineValue "%opt{orange},%opt{black}"
|
||
set-face global StatusCursor "%opt{white},%opt{blue}"
|
||
set-face global Prompt "%opt{green},%opt{black}"
|
||
set-face global MatchingChar "%opt{blue},%opt{black}"
|
||
set-face global Whitespace "%opt{dimgray},%opt{black}+f"
|
||
set-face global WrapMarker Whitespace
|
||
set-face global BufferPadding "%opt{black},%opt{black}"
|
||
|
||
|
||
|
||
'';
|
||
});
|
||
lsp = symlinkJoin {
|
||
|
||
name = "kak-lsp-${kak-lsp.version}";
|
||
nativeBuildInputs = [ makeWrapper ];
|
||
|
||
paths = with kakounePlugins; [
|
||
kakoune-lsp
|
||
lsp-config
|
||
];
|
||
|
||
|
||
postBuild = ''
|
||
wrapProgram $out/bin/kak-lsp --add-flags "--config $out/share/kak-lsp/kak-lsp.toml"
|
||
'';
|
||
|
||
};
|
||
kak-crosshairs = buildKakounePlugin (rec {
|
||
name = "kak-crosshairs";
|
||
src = (pkgs.fetchFromGitHub {
|
||
owner = "insipx";
|
||
repo = name;
|
||
rev = "7edba13c535ce1bc67356b1c9461f5d261949d29";
|
||
sha256 = "sha256-VOn9GGHludJasEwcCv6t1Q3/63w9139MCEkdRDnTw6E";
|
||
});
|
||
});
|
||
kaktree = buildKakounePlugin (rec {
|
||
name = "kaktree";
|
||
src = (pkgs.fetchFromGitHub {
|
||
owner = "andreyorst";
|
||
repo = name;
|
||
rev = "acd47e0c8549afe1634a79a5bbd6d883daa8ba0a";
|
||
sha256 = "sha256-9wiJFVxm+xZndUUpqrQ9eld/Df3wcp7gFDZTdInGPQQ=";
|
||
});
|
||
});
|
||
kak-wrap = (writeShellApplication {
|
||
name = "edit";
|
||
runtimeInputs = [ myKakoune ];
|
||
text = ''
|
||
CMND=$(cat <<'END'
|
||
BUFFER_NAME=''$(echo -n "''$PWD" | xxd -ps -c 200 | tr -d '\n' | shasum | head -c -4)
|
||
|
||
tmux -L "$BUFFER_NAME" has-session -t "$BUFFER_NAME" || {
|
||
tmux -L "$BUFFER_NAME" new-session -d -s "$BUFFER_NAME" "kak -e 'kaktree-enable; kaktree-toggle'"
|
||
tmux -L "$BUFFER_NAME" set -g status off
|
||
tmux -L "$BUFFER_NAME" set -g pane-border-style fg=#0c0c0c
|
||
tmux -L "$BUFFER_NAME" set -g pane-active-border-style "bg=default fg=#0c0c0c"
|
||
}
|
||
|
||
tmux -L "$BUFFER_NAME" attach -t "$BUFFER_NAME"
|
||
END
|
||
)
|
||
|
||
if [ -f "shell.nix" ] && [ -z ''${IN_NIX_SHELL+x} ]; then
|
||
nix-shell --command "$CMND"
|
||
else
|
||
eval "$CMND"
|
||
fi
|
||
'';
|
||
});
|
||
|
||
|
||
|
||
myKakoune = kakoune.override {
|
||
plugins = with kakounePlugins; [ config lsp colors kak-crosshairs kaktree kakoune-state-save ];
|
||
};
|
||
in
|
||
{
|
||
environment.systemPackages = [ myKakoune kak-wrap ];
|
||
}
|