Updated kak config

This commit is contained in:
James Dugan 2025-04-26 14:26:50 -06:00
parent a4833bc635
commit c047fe2d55
21 changed files with 766 additions and 62 deletions

View file

@ -1,8 +1,8 @@
map global normal <F2> :toggle-whitespace<ret> map global user 'b' ':fzf-buflist<ret>' -docstring 'Select buffer from list'
map global normal <F4> :buffer-switcher<ret> map global user 'f' ':xplr<ret>' -docstring 'File finder'
map global normal <F5> :xplr<ret> map global user 'g' ':lazygit<ret>' -docstring 'Open lazygit'
map global normal <F6> :lazygit<ret> map global user 'l' ':fzf-lines<ret>' -docstring 'Jump to line'
map global user 'p' ':paste-sys-after<ret>' -docstring 'Paste from clipboard after selection'
map global user 'p' '<a-!>pbpaste<ret>' -docstring 'Paste from clipboard' map global user 'P' ':paste-sys-before<ret>' -docstring 'Paste from clipboard before selection'
map global user 'P' '!pbpaste<ret>' -docstring 'Paste from clipboard' map global user 'w' ':toggle-whitespace<ret>' -docstring 'Toggle whitespace highlighter'
map global user 'y' '<a-|>pbcopy<ret>' -docstring 'Yank to clipboard' map global user 'y' ':yank-sys<ret>' -docstring 'Yank to clipboard'

View file

@ -1,17 +1,20 @@
colorscheme everforest-dark-soft colorscheme everforest-dark-soft
set-option global ui_options terminal_set_title=no terminal_assistant=cat # The cat is critically important. set-option global ui_options terminal_set_title=no
set-option global tabstop 4 set-option global tabstop 4
set-option global indentwidth 4 set-option global indentwidth 4
add-highlighter global/ show-matching add-highlighter global/ show-matching
declare-option str windowing_placement horizontal #declare-option str windowing_placement horizontal
# With the way that Kakoune's windowing detection is currently set up, the wezterm module will never be loaded. # With the way that Kakoune's windowing detection is currently set up, the wezterm module will never be loaded.
# So, we need to fix the order in which windowing modules are declared. # So, we need to fix the order in which windowing modules are declared.
# TODO: submit a PR to Kakoune fixing this.
declare-option str-list windowing_modules 'tmux' 'screen' 'zellij' 'kitty' 'wezterm' 'iterm' 'appleterminal' 'sway' 'wayland' 'x11' declare-option str-list windowing_modules 'tmux' 'screen' 'zellij' 'kitty' 'wezterm' 'iterm' 'appleterminal' 'sway' 'wayland' 'x11'
set-option global windowing_placement horizontal
hook global WinCreate .* %{ hook global WinCreate .* %{
add-highlighter window/number-lines number-lines -hlcursor add-highlighter window/number-lines number-lines -hlcursor
} }

View file

@ -1,5 +1,5 @@
source "%val{config}/bundle/kak-bundle/rc/kak-bundle.kak" source "%val{config}/bundle/kak-bundle/rc/kak-bundle.kak"
bundle-noload kak-bundle "ln -sf ~/workspace/kak-bundle/" bundle-noload kak-bundle "https://codeberg.org/jdugan6240/kak-bundle"
bundle kakoune-lsp "https://github.com/kakoune-lsp/kakoune-lsp" %{ bundle kakoune-lsp "https://github.com/kakoune-lsp/kakoune-lsp" %{
set-option global lsp_diagnostic_line_error_sign  set-option global lsp_diagnostic_line_error_sign 
@ -7,6 +7,8 @@ bundle kakoune-lsp "https://github.com/kakoune-lsp/kakoune-lsp" %{
set-option global lsp_diagnostic_line_info_sign set-option global lsp_diagnostic_line_info_sign
set-option global lsp_diagnostic_line_warning_sign  set-option global lsp_diagnostic_line_warning_sign 
set-option global lsp_hover_anchor true
# kakoune-lsp doesn't have a command to enable auto-hover per buffer, # kakoune-lsp doesn't have a command to enable auto-hover per buffer,
# only supporting enabling auto-hover globally, # only supporting enabling auto-hover globally,
# which causes issues in filetypes that don't have lsp set up. # which causes issues in filetypes that don't have lsp set up.
@ -35,40 +37,43 @@ bundle kakoune-lsp "https://github.com/kakoune-lsp/kakoune-lsp" %{
# We want to be explicit about lsp server settings per filetype # We want to be explicit about lsp server settings per filetype
# So, we are disabling the default lsp server hooks # So, we are disabling the default lsp server hooks
remove-hooks global lsp-filetype-.* remove-hooks global lsp-filetype-.*
set global lsp_debug true
} }
bundle-install-hook kakoune-lsp %{ bundle-install-hook kakoune-lsp %{
CARGO_PROFILE_RELEASE_LTO=false cargo install --locked --force --path . CARGO_PROFILE_RELEASE_LTO=false cargo install --locked --force --path .
} }
bundle-noload everforest.kak "ln -sf ~/workspace/everforest.kak/" bundle-theme everforest.kak "https://codeberg.org/jdugan6240/everforest.kak"
bundle-install-hook everforest.kak %{
mkdir -p "${kak_config}/colors"
ln -sf "${kak_opt_bundle_path}/everforest.kak" "${kak_config}/colors/"
}
bundle-cleaner everforest.kak %{
rm "${kak_config}/colors/everforest.kak"
}
bundle luar "https://github.com/gustavo-hms/luar" %@ bundle luar "https://github.com/gustavo-hms/luar" %@
require-module luar require-module luar
# Luar's highlighters are very subtly broken so we need to replace them # Luar's highlighters are very subtly broken so we need to replace them.
# TODO: submit a PR to luar with these fixes. # These aren't perfect either, as they assume the "lua" or "fennel" command invocation is the first thing in the line,
# but whatever - when both "lua" and "fennel" can appear in many contexts, it's hard to be robust without a true parser.
remove-highlighter shared/kakrc/code/lua
remove-highlighter shared/kakrc/lua1 remove-highlighter shared/kakrc/lua1
remove-highlighter shared/kakrc/lua2 remove-highlighter shared/kakrc/lua2
remove-highlighter shared/kakrc/lua3 remove-highlighter shared/kakrc/lua3
remove-highlighter shared/kakrc/lua4 remove-highlighter shared/kakrc/lua4
add-highlighter shared/kakrc/lua1 region -recurse '\{' '(^|\h)lua\s(([\s{}\w%/$-|''"])* )?%\{\K' '\}' ref lua remove-highlighter shared/kakrc/code/fennel
add-highlighter shared/kakrc/lua2 region -recurse '\(' '(^|\h)lua\s(([\s{}\w%/$-|''"])* )?%\(\K' '\)' ref lua remove-highlighter shared/kakrc/fennel1
add-highlighter shared/kakrc/lua3 region -recurse '\[' '(^|\h)lua\s(([\s{}\w%/$-|''"])* )?%\[\K' '\]' ref lua remove-highlighter shared/kakrc/fennel2
add-highlighter shared/kakrc/lua4 region -recurse '<' '(^|\h)lua\s(([\s{}\w%/$-|''"])* )?%<\K' '>' ref lua remove-highlighter shared/kakrc/fennel3
remove-highlighter shared/kakrc/fennel4
add-highlighter shared/kakrc/code/lua regex (^\s*)lua(?:(?=\s)|\z) 0:keyword
add-highlighter shared/kakrc/lua1 region -recurse '\{' '^\s*lua\s(([\s{}\w%/$-|''"])* )?%\{\K' '\}' ref lua
add-highlighter shared/kakrc/lua2 region -recurse '\(' '^\s*lua\s(([\s{}\w%/$-|''"])* )?%\(\K' '\)' ref lua
add-highlighter shared/kakrc/lua3 region -recurse '\[' '^\s*lua\s(([\s{}\w%/$-|''"])* )?%\[\K' '\]' ref lua
add-highlighter shared/kakrc/lua4 region -recurse '<' '^\s*lua\s(([\s{}\w%/$-|''"])* )?%<\K' '>' ref lua
add-highlighter shared/kakrc/code/fennel regex (^\s*)fennel(?:(?=\s)|\z) 0:keyword
add-highlighter shared/kakrc/fennel1 region -recurse '\{' '^\s*fennel\s(([\s{}\w%/$-|''"])* )?%\{\K' '\}' ref fennel
add-highlighter shared/kakrc/fennel2 region -recurse '\(' '^\s*fennel\s(([\s{}\w%/$-|''"])* )?%\(\K' '\)' ref fennel
add-highlighter shared/kakrc/fennel3 region -recurse '\[' '^\s*fennel\s(([\s{}\w%/$-|''"])* )?%\[\K' '\]' ref fennel
add-highlighter shared/kakrc/fennel4 region -recurse '<' '^\s*fennel\s(([\s{}\w%/$-|''"])* )?%<\K' '>' ref fennel
@ @
bundle kakoune-buffer-switcher "https://github.com/occivink/kakoune-buffer-switcher" %{
# Make the current buffer more visible
set-face global BufferSwitcherCurrent value
}
bundle kakoune-focus "https://github.com/caksoylar/kakoune-focus" %{ bundle kakoune-focus "https://github.com/caksoylar/kakoune-focus" %{
map global user <space> ':focus-toggle<ret>' -docstring "toggle selections focus" map global user <space> ':focus-toggle<ret>' -docstring "toggle selections focus"
} }
@ -78,45 +83,83 @@ bundle kakship https://github.com/eburghar/kakship %{
} }
bundle-install-hook kakship %{ bundle-install-hook kakship %{
cargo install --force --path . --root ~/.local cargo install --force --path . --root ~/.local
[ ! -e $kak_config/starship.toml ] && cp starship.toml $kak_config/ if [ ! -e $kak_config/starship.toml ]; then
cp starship.toml $kak_config/
fi
} }
bundle-cleaner kakship %{ bundle-cleaner kakship %{
rm ~/.local/bin/kakship rm ~/.local/bin/kakship
} }
bundle popup.kak https://github.com/enricozb/popup.kak
bundle-install-hook popup.kak %{
cargo install --force --path .
}
bundle-cleaner popup.kak %{
cargo uninstall kak-popup
}
bundle-customload kak-tree-sitter https://git.sr.ht/~hadronized/kak-tree-sitter %{ bundle-customload kak-tree-sitter https://git.sr.ht/~hadronized/kak-tree-sitter %{
evaluate-commands %sh{ kak-tree-sitter -dks --init $kak_session } evaluate-commands %sh{ kak-tree-sitter -dks --init $kak_session --with-highlighting -vvvvv }
# kak-tree-sitter sometimes gets out of sync during editing, especially with large files
# so, whenever we get back to normal mode, force an update
hook global ModeChange .*:normal %{
tree-sitter-buffer-update
}
} }
bundle-install-hook kak-tree-sitter %{ bundle-install-hook kak-tree-sitter %{
cargo install --force --path ./kak-tree-sitter cargo install --force --path kak-tree-sitter
cargo install --force --path ./ktsctl cargo install --force --path ktsctl
} }
bundle-cleaner kak-tree-sitter %{ bundle-cleaner kak-tree-sitter %{
cargo uninstall kak-tree-sitter cargo uninstall kak-tree-sitter
cargo uninstall ktsctl cargo uninstall ktsctl
} }
bundle-noload kakeidoscope "git clone --recurse-submodules https://git.sr.ht/~orchid/kakeidoscope" bundle kakeidoscope https://git.sr.ht/~orchid/kakeidoscope %{
#hook global WinCreate .* kakeidoscope-enable-window
}
bundle-install-hook kakeidoscope %{ bundle-install-hook kakeidoscope %{
cd src cargo install --force --path .
make
mv kakeidoscope ~/.local/bin/
} }
bundle-cleaner kakeidoscope %{ bundle-cleaner kakeidoscope %{
rm ~/.local/bin/kakeidoscope cargo uninstall kakeidoscope
}
bundle-updater kakeidoscope %{
git pull --recurse-submodules
} }
bundle peneira https://github.com/gustavo-hms/peneira %{ bundle-noload kak-rainbower %{
require-module peneira # This is the last commit of kak-rainbower that worked
git clone https://github.com/crizan/kak-rainbower
cd kak-rainbower
git reset --hard 692c196650edd97da9ed6c275bb9b261630d063d
}%{
set-option global rainbow_mode 0
hook global WinCreate .* %{
rainbow-enable-window
}
} }
bundle-install-hook kak-rainbower %{
c++ rc/rainbower.cpp -o rc/rainbower
}
bundle-updater kak-rainbower %{
# This is the last commit of kak-rainbower that worked
#git reset --hard 692c196650edd97da9ed6c275bb9b261630d063d
git reset --hard frederick-the-great
}
bundle kak-rainbow https://github.com/Bodhizafa/kak-rainbow %{
hook global WinCreate .* %{
rainbow-enable-window
}
}
bundle pairs.kak https://github.com/42xel/pairs.kak %{
pairs_enable
}
bundle parinfer-rust https://github.com/eraserhd/parinfer-rust %{
hook global WinSetOption filetype=(clojure|fennel|lisp|picolisp|racket|scheme) %{
parinfer-enable-window -smart
}
}
bundle-install-hook parinfer-rust %{
cargo install --force --path .
}
bundle-cleaner parinfer-rust %{
cargo uninstall parinfer-rust
}
# Automatically clean any unregistered plugins
bundle-clean

View file

@ -0,0 +1,22 @@
hook global WinSetOption filetype=fennel %{
set-option buffer lsp_servers %{
[fennel-ls]
root_globs = [".git", ".hg", "fennel.lua"]
command = "/home/ANT.AMAZON.COM/dugajame/fennel-ls/fennel-ls"
}
lsp-enable-buffer
softtab-enable
}
hook global ModuleLoaded fennel %{
# By default, Kakoune highlights colon strings in the "keyword" face.
# This is incorrect - they should be highlighted as strings.
# So, we override the builtin highlighter with our own.
remove-highlighter shared/fennel/colon-string
add-highlighter shared/fennel/colon-string region '\W\K:[-\w?\\^_!$%&*+./@|<=>]' '(?![-\w?\\^_!$%&*+./@|<=>])' fill string
# Kakoune's default fennel support also doesn't properly highlight values,
# so we patch the lua highlighter in here
remove-highlighter shared/fennel/code/value
add-highlighter shared/fennel/code/value regex \b(false|nil|true|self|[0-9]+(:?\.[0-9])?(:?[eE]-?[0-9]+)?|0x[0-9a-fA-F]+)\b 0:value
}

View file

@ -19,4 +19,6 @@ hook global WinSetOption filetype=go %{
} }
lsp-enable-buffer lsp-enable-buffer
lsp-semantic-tokens-enable lsp-semantic-tokens-enable
set-option buffer indentwidth 0 # Use tabs
} }

View file

@ -10,4 +10,10 @@ hook global ModuleLoaded kak %@
~ catch %$ ~ catch %$
echo -debug "Error: kakrc: can't declare additional kakrc highlighters: %val{error}" echo -debug "Error: kakrc: can't declare additional kakrc highlighters: %val{error}"
$ $
# highlighting for bundle_sh_code
try %~
add-highlighter shared/kakrc/bundle_sh_code region -recurse '\{' '\bbundle_sh_code\s+%\{' '\}' ref sh
~ catch %$
echo -debug "Error: kakrc: can't declare additional kakrc highlighters: %val{error}"
$
@ @

9
.config/kak/filetypes/kdl.kak Executable file
View file

@ -0,0 +1,9 @@
hook global WinSetOption filetype=kdl %{
set-option buffer lsp_servers %{
[kdl-lsp]
root_globs = [".git", ".hg"]
command = "kdl-lsp"
}
lsp-enable-buffer
softtab-enable
}

View file

@ -2,9 +2,17 @@ hook global WinSetOption filetype=lua %{
set-option buffer lsp_servers %{ set-option buffer lsp_servers %{
[lua-language-server] [lua-language-server]
root_globs = [".luarc.json", ".git", ".hg"] root_globs = [".luarc.json", ".git", ".hg"]
command = "lua-language-server" command = "/home/ANT.AMAZON.COM/dugajame/lua-language-server/bin/lua-language-server"
# [emmylua_ls]
# root_globs = [".luarc.json", ".git", ".hg"]
# command = "emmylua_ls"
} }
lsp-semantic-tokens-enable lsp-semantic-tokens-enable
softtab-enable softtab-enable
lsp-enable-buffer lsp-enable-buffer
} }
hook global ModuleLoaded lua %{
# Support highlighting shebangs
add-highlighter shared/lua/shebang region '^#!' '$' fill comment
}

View file

@ -7,7 +7,7 @@ hook global WinSetOption filetype=python %{
[ruff] [ruff]
root_globs = ["requirements.txt", "setup.py", "pyrightconfig.json", ".git", ".hg"] root_globs = ["requirements.txt", "setup.py", "pyrightconfig.json", ".git", ".hg"]
command = "ruff" command = "ruff"
args = ["server", "--preview"] args = ["server"]
} }
lsp-enable-buffer lsp-enable-buffer
lsp-semantic-tokens-enable lsp-semantic-tokens-enable

16
.config/kak/filetypes/rust.kak Executable file
View file

@ -0,0 +1,16 @@
hook global WinSetOption filetype=rust %{
set-option buffer lsp_servers %{
# [rust-analyzer]
# root_globs = ["Cargo.toml"]
# single_instance = true
# command = "rust-analyzer"
# [rls]
# root_globs = ["Cargo.toml"]
# command = "rls"
[ra-multiplex]
root_globs = ["Cargo.toml"]
command = "ra-multiplex"
}
lsp-enable-buffer
#lsp-semantic-tokens-enable
}

View file

@ -11,7 +11,11 @@ load config plugins
# Additional syntaxes # Additional syntaxes
load syntaxes capnp load syntaxes capnp
load syntaxes hjson
load syntaxes hyprlang
load syntaxes json5
load syntaxes kdl load syntaxes kdl
load syntaxes kitty
load syntaxes rainbow_csv load syntaxes rainbow_csv
load syntaxes sshconfig load syntaxes sshconfig
@ -22,6 +26,9 @@ load utils whitespace
# Tool integration # Tool integration
load tools clipboard
load tools fzf
load tools kitty
load tools lazygit load tools lazygit
load tools xplr load tools xplr
@ -35,10 +42,13 @@ load config mappings
# Filetype-specific configs # Filetype-specific configs
load filetypes fennel
load filetypes go load filetypes go
load filetypes kak load filetypes kak
load filetypes kdl
load filetypes lua load filetypes lua
load filetypes python load filetypes python
load filetypes rust
load filetypes sh load filetypes sh
load filetypes yaml load filetypes yaml

112
.config/kak/syntaxes/hjson.kak Executable file
View file

@ -0,0 +1,112 @@
# http://hjson.github.io
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
# Detection
# ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](hjson) %{
set-option buffer filetype hjson
}
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=hjson %{
require-module hjson
hook window ModeChange pop:insert:.* -group hjson-trim-indent hjson-trim-indent
hook window InsertChar .* -group hjson-indent hjson-indent-on-char
hook window InsertChar \n -group hjson-indent hjson-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window hjson-.+ }
}
hook -group hjson-highlight global WinSetOption filetype=hjson %{
add-highlighter window/hjson ref hjson
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/hjson }
}
provide-module hjson %(
# Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter shared/hjson regions
add-highlighter shared/hjson/code default-region group
add-highlighter shared/hjson/string region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/hjson/string2 region "'" (?<!\\)(\\\\)*' fill string
add-highlighter shared/hjson/triple_string region -match-capture ("""|''') (?<!\\)(?:\\\\)*("""|''') fill string
add-highlighter shared/hjson/comment1 region '#' '$' fill comment
add-highlighter shared/hjson/comment2 region '//' '$' fill comment
add-highlighter shared/hjson/multiline_comment region /\* \*/ fill comment
# The below isn't perfect, as it doesn't work if multiple member-value pairs are defined on the same line,
# and it mistakenly highlights comments at the end of a quoteless string,
# but eh - it's good enough for the vast majority of real-world cases,
# and it's annoying to make this work right with Kakoune highlighters alone.
add-highlighter shared/hjson/code/ regex ^(\s*[^,:\[\]\{\}\s]+):\s+([^\{\}\[\]:,][^\r\n]*)? 1:variable 2:string
add-highlighter shared/hjson/code/ regex \b(true|false|null|\d+(?:\.\d+)?(?:[eE][+-]?\d*)?)\b 0:value
# Commands
# ‾‾‾‾‾‾‾‾
define-command -hidden hjson-trim-indent %{
# remove trailing white spaces
try %{ execute-keys -draft -itersel x s \h+$ <ret> d }
}
define-command -hidden hjson-indent-on-char %<
evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line
try %< execute-keys -draft <a-h> <a-k> ^\h+[\]}]$ <ret> m <a-S> 1<a-&> >
>
>
define-command -hidden hjson-indent-on-new-line %{
evaluate-commands -itersel -draft %{
execute-keys <semicolon>
try %{
evaluate-commands -draft -save-regs '/"' %{
# Ensure previous line is a comment
# This only supports "#" comments (because hjson supporting # and // comments was a mistake)
execute-keys -draft kxs^\h*#+\h*<ret>
# now handle the coment continuation logic
try %{
# try and match a regular block comment, copying the prefix
execute-keys -draft -save-regs '' k x 1s^(\h*#+\h*)\S.*$ <ret> y
execute-keys -draft P
} catch %{
try %{
# try and match a regular block comment followed by a single
# empty comment line
execute-keys -draft -save-regs '' kKx 1s^(\h*#+\h*)\S+\n\h*#+\h*$ <ret> y
execute-keys -draft P
} catch %{
try %{
# try and match a pair of empty comment lines, and delete
# them if we match
execute-keys -draft kKx <a-k> ^\h*#+\h*\n\h*#+\h*$ <ret> <a-d>
} catch %{
# finally, we need a special case for a new line inserted
# into a file that consists of a single empty comment - in
# that case we can't expect to copy the trailing whitespace,
# so we add our own
execute-keys -draft -save-regs '' k x1s^(\h*#+)\h*$<ret> y
execute-keys -draft P
execute-keys -draft i<space>
}
}
}
}
# trim trailing whitespace on the previous line
try %{ execute-keys -draft k x s\h+$<ret> d }
}
}
}
)

View file

@ -0,0 +1,76 @@
# https://hyprland.org/
hook global BufCreate .*/hypr/.*[.]conf %{
set-option buffer filetype hyprlang
}
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=hyprlang %{
require-module hyprlang
hook window ModeChange pop:insert:.* -group hyprlang-trim-indent hyprlang-trim-indent
hook window InsertChar .* -group hyprlang-indent hyprlang-indent-on-char
hook window InsertChar \n -group hyprlang-indent hyprlang-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window hyprlang-.+ }
}
hook -group hyprlang-highlight global WinSetOption filetype=hyprlang %{
add-highlighter window/hyprlang ref hyprlang
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/hyprlang }
}
provide-module hyprlang %@
# Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter shared/hyprlang regions
add-highlighter shared/hyprlang/code default-region group
add-highlighter shared/hyprlang/string region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/hyprlang/line_comment region '#' $ fill comment
add-highlighter shared/hyprlang/code/variable regex ((?<![-:])\b\w+)\s*= 1:variable
add-highlighter shared/hyprlang/code/dollarvar regex (\$\w+)\b 1:value
add-highlighter shared/hyprlang/code/builtin regex \b(true|false)\b 0:value
add-highlighter shared/hyprlang/code/binary regex \b(0b[01_]+)\b 0:value
add-highlighter shared/hyprlang/code/octal regex \b(0o[0-7_]+)\b 0:value
add-highlighter shared/hyprlang/code/hex regex \b(0x[a-fA-F0-9_]+)\b 0:value
add-highlighter shared/hyprlang/code/decimal regex \b([0-9-+][0-9_]*)\b 0:value
add-highlighter shared/hyprlang/code/float regex \b([0-9-+][0-9_]*\.[0-9_]+)\b 0:value
add-highlighter shared/hyprlang/code/float_exp regex \b([0-9-+][0-9_]*(\.[0-9_]+)?[eE][-+]?[0-9_]+)\b 0:value
# Commands
# ‾‾‾‾‾‾‾‾
define-command -hidden hyprlang-trim-indent %{
# remove trailing white spaces
try %{ execute-keys -draft -itersel x s \h+$ <ret> d }
}
define-command -hidden hyprlang-indent-on-char %<
evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line
try %< execute-keys -draft <a-h> <a-k> ^\h+[\]}]$ <ret> m <a-S> 1<a-&> >
>
>
define-command -hidden hyprlang-indent-on-new-line %<
evaluate-commands -draft -itersel %<
# preserve previous line indent
try %{ execute-keys -draft <semicolon> K <a-&> }
# filter previous line
try %{ execute-keys -draft k : hyprlang-trim-indent <ret> }
# indent after lines ending with opener token
try %< execute-keys -draft k x <a-k> [[{]\h*$ <ret> j <a-gt> >
# deindent closer token(s) when after cursor
try %< execute-keys -draft x <a-k> ^\h*[}\]] <ret> gh / [}\]] <ret> m <a-S> 1<a-&> >
>
>
@

78
.config/kak/syntaxes/json5.kak Executable file
View file

@ -0,0 +1,78 @@
# http://json5.org
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
# Detection
# ‾‾‾‾‾‾‾‾‾
hook global BufCreate .*[.](json5) %{
set-option buffer filetype json5
}
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook global WinSetOption filetype=json5 %{
require-module json5
hook window ModeChange pop:insert:.* -group json5-trim-indent json5-trim-indent
hook window InsertChar \n -group json5-insert json5-insert-on-new-line
hook window InsertChar \n -group json5-indent json5-indent-on-new-line
hook window InsertChar .* -group json5-indent json5-indent-on-char
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window json5-.+ }
}
hook -group json5-highlight global WinSetOption filetype=json5 %{
add-highlighter window/json5 ref json5
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/json5 }
}
provide-module json5 %(
# Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter shared/json5 regions
add-highlighter shared/json5/code default-region group
add-highlighter shared/json5/string region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/json5/string2 region "'" (?<!\\)(\\\\)*' fill string
add-highlighter shared/json5/comment region '//' '$' fill comment
add-highlighter shared/json5/multiline_comment region /\* \*/ fill comment
add-highlighter shared/json5/code/ regex \b(true|false|null|\d+(?:\.\d+)?(?:[eE][+-]?\d*)?|0x[\da-fA-F]+)\b 0:value
# Commands
# ‾‾‾‾‾‾‾‾
define-command -hidden json5-insert-on-new-line %[
# copy // comments prefix and following white spaces
try %{ execute-keys -draft <semicolon><c-s>kx s ^\h*\K/{2,}\h* <ret> y<c-o>P<esc> }
]
define-command -hidden json5-trim-indent %{
# remove trailing white spaces
try %{ execute-keys -draft -itersel x s \h+$ <ret> d }
}
define-command -hidden json5-indent-on-char %<
evaluate-commands -draft -itersel %<
# align closer token to its opener when alone on a line
try %< execute-keys -draft <a-h> <a-k> ^\h+[\]}]$ <ret> m <a-S> 1<a-&> >
>
>
define-command -hidden json5-indent-on-new-line %<
evaluate-commands -draft -itersel %<
# preserve previous line indent
try %{ execute-keys -draft <semicolon> K <a-&> }
# filter previous line
try %{ execute-keys -draft k : json5-trim-indent <ret> }
# indent after lines ending with opener token
try %< execute-keys -draft k x <a-k> [[{]\h*$ <ret> j <a-gt> >
# deindent closer token(s) when after cursor
try %< execute-keys -draft x <a-k> ^\h*[}\]] <ret> gh / [}\]] <ret> m <a-S> 1<a-&> >
>
>
)

View file

@ -1,4 +1,5 @@
# https://kdl.dev # https://kdl.dev
# Currently only supports kdl v1
hook global BufCreate .*[.](kdl) %{ hook global BufCreate .*[.](kdl) %{
set-option buffer filetype kdl set-option buffer filetype kdl

225
.config/kak/syntaxes/kitty.kak Executable file
View file

@ -0,0 +1,225 @@
# https://sw.kovidgoyal.net/kitty/
hook global BufCreate .*/kitty/.*[.]conf %{
set-option buffer filetype kitty-conf
}
hook global BufCreate .*/kitty/.*[.]session %{
set-option buffer filetype kitty-session
}
hook global WinSetOption filetype=kitty-conf %{
require-module kitty-conf
set-option window static_words %opt{kitty_conf_static_words}
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kitty-conf-.+ }
}
hook -group kitty-conf-highlight global WinSetOption filetype=kitty-conf %{
add-highlighter window/kitty-conf ref kitty-conf
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kitty-conf }
}
hook global WinSetOption filetype=kitty-session %{
require-module kitty-session
set-option window static_words %opt{kitty_session_static_words}
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kitty-session-.+ }
}
hook -group kitty-session-highlight global WinSetOption filetype=kitty-session %{
add-highlighter window/kitty-session ref kitty-session
hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kitty-session }
}
provide-module kitty-conf %{
# Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter shared/kitty-conf regions
add-highlighter shared/kitty-conf/code default-region group
add-highlighter shared/kitty-conf/line_comment region ^# $ fill comment
add-highlighter shared/kitty-conf/string region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/kitty-conf/string2 region "'" (?<!\\)(\\\\)*' fill string
add-highlighter shared/kitty-conf/code/keybind regex ^\s*map\s([^\s]+) 1:value
add-highlighter shared/kitty-conf/code/kitty_mod regex ^\s*kitty_mod\s([^\s]+) 1:value
add-highlighter shared/kitty-conf/code/include regex ^\s*include\s(.*) 1:string
add-highlighter shared/kitty-conf/code/globinclude regex ^\s*globinclude\s(.*) 1:string
add-highlighter shared/kitty-conf/code/geninclude regex ^\s*geninclude\s(.*) 1:string
add-highlighter shared/kitty-conf/code/envinclude regex ^\s*envinclude\s(.*) 1:string
add-highlighter shared/kitty-conf/code/ regex \b(yes|no|no-op)\b 0:value
add-highlighter shared/kitty-conf/code/ regex '(?i)\b0x[\da-f]+\b' 0:value
add-highlighter shared/kitty-conf/code/ regex '(?i)\b0o?[0-7]+\b' 0:value
add-highlighter shared/kitty-conf/code/ regex '(?i)\b([1-9]\d*|0)\b' 0:value
add-highlighter shared/kitty-conf/code/ regex '(?i)\b0b[01]+\b' 0:value
add-highlighter shared/kitty-conf/code/ regex '(?i)\bU\+[\da-f]+\b' 0:value
add-highlighter shared/kitty-conf/code/ regex (?i)\b"#([\da-f]{8}|[\da-f]{6}|[\da-f]{3})"\b 0:value
evaluate-commands %sh{
kitty_mods="alt super cmd command ⌘ control ctrl ^ kitty_mod opt option ⌥ shift ⇧"
kitty_keywords="action_alias active_border_color active_tab_background
active_tab_font_style active_tab_foreground active_tab_title_template
allow_cloning allow_hyperlinks allow_remote_control background
background_blur background_image background_image_layout
background_image_linear background_opacity background_tint
background_tint_gaps bell_border_color bell_on_tab bell_path bold_font
bold_italic_font box_drawing_scale clear_all_mouse_actions
clear_all_shortcuts clear_selection_on_clipboard_loss click_interval
clipboard_control clipboard_max_size clone_source_strategies
close_on_child_death color0 color1 color2 color3 color4 color5 color6
color7 color8 color9 color10 color11 color12 color13 color14 color15
color16 color17 color18 color19 color20 color21 color22 color23 color24
color25 color26 color27 color28 color29 color30 color31 color32 color33
color34 color35 color36 color37 color38 color39 color40 color41 color42
color43 color44 color45 color46 color47 color48 color49 color50 color51
color52 color53 color54 color55 color56 color57 color58 color59 color60
color61 color62 color63 color64 color65 color66 color67 color68 color69
color70 color71 color72 color73 color74 color75 color76 color77 color78
color79 color80 color81 color82 color83 color84 color85 color86 color87
color88 color89 color90 color91 color92 color93 color94 color95 color96
color97 color98 color99 color100 color101 color102 color103 color104
color105 color106 color107 color108 color109 color110 color111 color112
color113 color114 color115 color116 color117 color118 color119 color120
color121 color122 color123 color124 color125 color126 color127 color128
color129 color130 color131 color132 color133 color134 color135 color136
color137 color138 color139 color140 color141 color142 color143 color144
color145 color146 color147 color148 color149 color150 color151 color152
color153 color154 color155 color156 color157 color158 color159 color160
color161 color162 color163 color164 color165 color166 color167 color168
color169 color170 color171 color172 color173 color174 color175 color176
color177 color178 color179 color180 color181 color182 color183 color184
color185 color186 color187 color188 color189 color190 color191 color192
color193 color194 color195 color196 color197 color198 color199 color200
color201 color202 color203 color204 color205 color206 color207 color208
color209 color210 color211 color212 color213 color214 color215 color216
color217 color218 color219 color220 color221 color222 color223 color224
color225 color226 color227 color228 color229 color230 color231 color232
color233 color234 color235 color236 color237 color238 color239 color240
color241 color242 color243 color244 color245 color246 color247 color248
color249 color250 color251 color252 color253 color254 color255
command_on_bell confirm_os_window_close copy_on_select cursor
cursor_beam_thickness cursor_blink_interval cursor_shape
cursor_shape_unfocused cursor_stop_blinking_after cursor_text_color
cursor_trail cursor_trail_decay cursor_trail_start_threshold
cursor_underline_thickness default_pointer_shape detect_urls dim_opacity
disable_ligatures draw_minimal_borders dynamic_background_opacity editor
enable_audio_bell enabled_layouts env exe_search_path
file_transfer_confirmation_bypass filter_notification focus_follows_mouse
font_family font_features font_size force_ltr foreground forward_stdio
hide_window_decorations inactive_border_color inactive_tab_background
inactive_tab_font_style inactive_tab_foreground inactive_text_alpha
initial_window_height initial_window_width input_delay italic_font
kitten_alias kitty_mod linux_bell_theme linux_display_server listen_on
macos_colorspace macos_custom_beam_cursor macos_hide_from_tasks
macos_menubar_title_max_length macos_option_as_alt
macos_quit_when_last_window_closed macos_show_window_title_in
macos_thicken_font macos_titlebar_color macos_traditional_fullscreen
macos_window_resizable map mark1_background mark1_foreground
mark2_background mark2_foreground mark3_background mark3_foreground
menu_map modify_font mouse_hide_wait mouse_map narrow_symbols
notify_on_cmd_finish open_url_with paste_actions placement_strategy
pointer_shape_when_dragging pointer_shape_when_grabbed
remember_window_size remote_control_password repaint_delay
resize_debounce_time resize_in_steps scrollback_fill_enlarged_window
scrollback_indicator_opacity scrollback_lines scrollback_pager
scrollback_pager_history_size select_by_word_characters
select_by_word_characters_forward selection_background
selection_foreground shell shell_integration show_hyperlink_targets
single_window_margin_width single_window_padding_width startup_session
strip_trailing_spaces symbol_map sync_to_monitor tab_activity_symbol
tab_bar_align tab_bar_background tab_bar_edge tab_bar_margin_color
tab_bar_margin_height tab_bar_margin_width tab_bar_min_tabs tab_bar_style
tab_fade tab_powerline_style tab_separator tab_switch_strategy
tab_title_max_length tab_title_template term terminfo_type
text_composition_strategy text_fg_override_threshold
touch_scroll_multiplier transparent_background_colors undercurl_style
underline_exclusion underline_hyperlinks update_check_interval url_color
url_excluded_characters url_prefixes url_style visual_bell_color
visual_bell_duration visual_window_select_characters watcher
wayland_enable_ime wayland_titlebar_color wheel_scroll_min_lines
wheel_scroll_multiplier window_alert_on_bell window_border_width
window_logo_alpha window_logo_path window_logo_position window_logo_scale
window_margin_width window_padding_width window_resize_step_cells
window_resize_step_lines"
kitty_actions="change_font_size clear_selection clear_terminal click close_os_window
close_other_os_windows close_other_tabs_in_os_window
close_other_windows_in_tab close_shared_ssh_connections close_tab
close_window close_window_with_confirmation combine
copy_and_clear_or_interrupt copy_ansi_to_clipboard copy_or_interrupt
copy_to_buffer copy_to_clipboard create_marker debug_config detach_tab
detach_window disable_ligatures_in discard_event doubleclick doublepress
dump_lines_with_attrs edit_config_file eighth_window fifth_window
first_window focus_visible_window fourth_window goto_layout goto_tab
hide_macos_app hide_macos_other_apps input_unicode_character kitten
kitty_shell last_used_layout launch layout_action load_config_file
minimize_macos_window mouse_click_url mouse_click_url_or_select
mouse_handle_click mouse_select_command_output mouse_selection
mouse_show_command_output move_tab_backward move_tab_forward move_window
move_window_backward move_window_forward move_window_to_top
neighboring_window new_os_window new_os_window_with_cwd new_tab
new_tab_with_cwd new_window new_window_with_cwd next_layout next_tab
next_window ninth_window no-op nth_os_window nth_window open_url
open_url_with_hints pass_selection_to_program paste paste_from_buffer
paste_from_clipboard paste_from_selection paste_selection
paste_selection_or_clipboard pop_keyboard_mode press previous_tab
previous_window push_keyboard_mode quit release remote_control
remote_control_script remove_marker reset_window_sizes resize_window
scroll_end scroll_home scroll_line_down scroll_line_up scroll_page_down
scroll_page_up scroll_prompt_to_bottom scroll_prompt_to_top scroll_to_mark
scroll_to_prompt second_window select_tab send_key send_text
set_background_opacity set_colors set_tab_title set_window_title
seventh_window show_error show_first_command_output_on_screen
show_kitty_doc show_kitty_env_vars show_last_command_output
show_last_non_empty_command_output show_last_visited_command_output
show_scrollback signal_child sixth_window sleep start_resizing_window
swap_with_window tenth_window third_window toggle_fullscreen toggle_layout
toggle_macos_secure_keyboard_entry toggle_marker toggle_maximized
toggle_tab triplepress"
kitty_include="envinclude geninclude globinclude include"
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
printf %s\\n "declare-option str-list kitty_conf_static_words $(join "${kitty_mods}" ' ') $(join "${kitty_keywords}" ' ') $(join "${kitty_actions}" ' ') $(join "${kitty_include}" ' ')"
printf %s\\n "add-highlighter shared/kitty-conf/code/ regex '\b($(join "${kitty_mods}" '|'))\b' 0:keyword"
printf %s\\n "add-highlighter shared/kitty-conf/code/ regex '\b($(join "${kitty_keywords}" '|'))\b' 0:keyword"
printf %s\\n "add-highlighter shared/kitty-conf/code/ regex '\b($(join "${kitty_actions}" '|'))\b' 0:function"
printf %s\\n "add-highlighter shared/kitty-conf/code/ regex '\b($(join "${kitty_include}" '|'))\b' 0:keyword"
}
}
provide-module kitty-session %{
# Highlighters
# ‾‾‾‾‾‾‾‾‾‾‾‾
add-highlighter shared/kitty-session regions
add-highlighter shared/kitty-session/code default-region group
add-highlighter shared/kitty-session/line_comment region ^# $ fill comment
add-highlighter shared/kitty-session/string region '"' (?<!\\)(\\\\)*" fill string
add-highlighter shared/kitty-session/string2 region "'" (?<!\\)(\\\\)*' fill string
add-highlighter shared/kitty-session/code/ regex '(?i)\b0x[\da-f]+\b' 0:value
add-highlighter shared/kitty-session/code/ regex '(?i)\b0o?[0-7]+\b' 0:value
add-highlighter shared/kitty-session/code/ regex '(?i)\b([1-9]\d*|0)\b' 0:value
add-highlighter shared/kitty-session/code/ regex '(?i)\b0b[01]+\b' 0:value
add-highlighter shared/kitty-session/code/ regex '(?i)\bU\+[\da-f]+\b' 0:value
evaluate-commands %sh{
kitty_session_commands="new_tab new_os_window layout launch focus enabled_layouts cd title os_window_size os_window_class"
join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
printf %s\\n "declare-option str-list kitty_session_static_words $(join "${kitty_session_commands}" ' ')"
printf %s\\n "add-highlighter shared/kitty-session/code/ regex '\b($(join "${kitty_session_commands}" '|'))\b' 0:keyword"
}
}

16
.config/kak/tools/clipboard.kak Executable file
View file

@ -0,0 +1,16 @@
declare-option str yank_sys_clipboard_cmd %sh{
test "$(uname)" = "Darwin" && echo "pbcopy" || echo "xsel -ib"
}
declare-option str paste_sys_clipboard_cmd %sh{
test "$(uname)" = "Darwin" && echo "pbpaste" || echo "xsel -ob"
}
define-command yank-sys -docstring "yank into the system clipboard" %{
execute-keys -draft "<a-|>%opt{yank_sys_clipboard_cmd}<ret>"
}
define-command paste-sys-before -docstring "paste from the system clipboard before selection" %{
execute-keys -draft "!%opt{paste_sys_clipboard_cmd}<ret>"
}
define-command paste-sys-after -docstring "paste from the system clipboard after selection" %{
execute-keys -draft "<a-!>%opt{paste_sys_clipboard_cmd}<ret>"
}

29
.config/kak/tools/fzf.kak Executable file
View file

@ -0,0 +1,29 @@
# https://junegunn.github.io/fzf
define-command fzf-buflist -docstring "Use fzf to select buffer" %{
set-register f %sh{ printf "%s" "$kak_buflist" | tr ' ' '\n' }
wezterm-terminal-tab sh -c %{
PATH=$PATH:~/.fzf/bin/
kak_session=$1 kak_client=$2 buflist=$3
shift 3
# Note: we need to replace ~ with $HOME here; otherwise bat can't find the file for preview
output=$(printf "$buflist" | sed "s|~|$HOME|" | fzf --preview 'bat --color=always {}')
kak_cmd="evaluate-commands -client $kak_client buffer $output"
echo $kak_cmd | kak -p $kak_session
} -- %val{session} %val{client} %reg{f}
}
define-command fzf-lines -docstring "Use fzf to jump to line in current buffer" %{
set-register f %sh{ mktemp }
execute-keys -draft '%<a-|> nl -b a > $kak_reg_f<ret>'
wezterm-terminal-tab sh -c %{
PATH=$PATH:~/.fzf/bin/
kak_session=$1 kak_client=$2 buffile=$3
shift 3
output=$(fzf --layout=reverse < $buffile)
set -- $output
kak_cmd="evaluate-commands -client $kak_client execute-keys '${1}g'"
rm $buffile
echo $kak_cmd | kak -p $kak_session
} -- %val{session} %val{client} %reg{f}
}

39
.config/kak/tools/kitty.kak Executable file
View file

@ -0,0 +1,39 @@
# https://sw.kovidgoyal.net/kitty
# The following assumes the "splits" layout.
hook global ModuleLoaded kitty %{
define-command kitty-launch-impl -params 3.. %{
nop %sh{
location=$1
type=$2
shift 2
match=""
if [ -n "$kak_client_env_KITTY_WINDOW_ID" ]; then
match="--match=window_id:$kak_client_env_KITTY_WINDOW_ID"
fi
listen=""
if [ -n "$kak_client_env_KITTY_LISTEN_ON" ]; then
listen="--to=$kak_client_env_KITTY_LISTEN_ON"
fi
kitty @ $listen launch --no-response --location=$location --type=$type --cwd="$PWD" $match "$@"
}
} -hidden
define-command kitty-terminal-horizontal -params 1.. %{
kitty-launch-impl "vsplit" "window" %arg{@}
}
complete-command kitty-terminal-horizontal shell
define-command kitty-terminal-vertical -params 1.. %{
kitty-launch-impl "hsplit" "window" %arg{@}
}
complete-command kitty-terminal-vertical shell
define-command kitty-terminal-overlay -params 1.. %{
kitty-launch-impl "default" "overlay" %arg{@}
}
complete-command kitty-terminal-overlay shell
}

View file

@ -1,7 +1,7 @@
# https://github.com/jesseduffield/lazygit # https://github.com/jesseduffield/lazygit
define-command lazygit %{ define-command lazygit %{
popup lazygit kitty-terminal-overlay lazygit
} }
alias global lg lazygit alias global lg lazygit

View file

@ -1,9 +1,10 @@
# https://xplr.dev/ # https://xplr.dev/
# Seriously, xplr is awesome. Get it if you haven't already. # The reason to use xplr instead of fzf here is sometimes we want to edit a file
# not in the current working directory.
define-command xplr-open -params 1 %{ define-command xplr-open -params 1.. %{
evaluate-commands %sh{ evaluate-commands %sh{
for xplr_file in $1; do for xplr_file in $@; do
if [ -f "$xplr_file" ]; then if [ -f "$xplr_file" ]; then
printf "%s\n" "edit $xplr_file" printf "%s\n" "edit $xplr_file"
fi fi
@ -11,8 +12,16 @@ define-command xplr-open -params 1 %{
} }
} -hidden } -hidden
define-command xplr -params ..1 %{ define-command xplr -params ..1 -docstring "Use xplr to open file" %{
popup --title open --kak-script %{ xplr-open %opt{popup_output} } -- xplr %arg{@} wezterm-terminal-tab sh -c %{
PATH=$PATH:~/.fzf/bin/
kak_buffile=$1 kak_session=$2 kak_client=$3
shift 3
kak_pwd="${@:-$(dirname "${kak_buffile}")}"
output=$(xplr "${kak_pwd}")
kak_cmd="evaluate-commands -client $kak_client xplr-open $output"
echo $kak_cmd | kak -p $kak_session
} -- %val{buffile} %val{session} %val{client} %arg{@}
} }
# Utility command to edit a kak config file with xplr # Utility command to edit a kak config file with xplr