z_mirror/dotfiles
git clone https://git.raiguard.me/z_mirror/dotfiles
84104cc
uraya-alpine
1# -------------------------------------------------- 2# PLUGINS 3 4source "%val{config}/bundle/kak-bundle/rc/kak-bundle.kak" 5bundle-noload kak-bundle https://github.com/jdugan6240/kak-bundle 6 7bundle auto-pairs.kak "https://github.com/alexherbo2/auto-pairs.kak" %{ 8 enable-auto-pairs 9} 10 11bundle kak-ansi "https://github.com/eraserhd/kak-ansi" %{ 12 hook global BufSetOption filetype=make ansi-enable 13 hook global BufCreate \*frun\* ansi-enable 14} 15 16bundle kak-fastbuild "https://github.com/raiguard/kak-fastbuild" 17 18bundle kak-harpoon "https://github.com/raiguard/kak-harpoon" %{ 19 harpoon-add-bindings 20} 21 22bundle kak-mark "https://github.com/raiguard/kak-mark" %{ 23 set-face global MarkedPrimaryCursor ,,magenta+ua 24 set-face global MarkedPrimarySelection ,,magenta+ua 25 set-face global MarkedSecondaryCursor ,,cyan+ua 26 set-face global MarkedSecondarySelection ,,cyan+ua 27} 28 29bundle kak-mirror "https://github.com/raiguard/kak-mirror" %{ 30 map global normal "'" ':enter-user-mode -lock mirror<ret>' -docstring 'mirror lock' 31} 32 33bundle kak-move-lines "https://github.com/raiguard/kak-move-lines" %{ 34 map global normal <c-a-j> ':move-lines-down %val{count}<ret>' 35 map global normal <c-a-k> ':move-lines-up %val{count}<ret>' 36} 37 38bundle kak-live-grep "https://github.com/raiguard/kak-live-grep" %{ 39 map global user / ":live-grep<ret>" -docstring "live grep" 40 hook global User ColorschemeLoaded %{ 41 set-face global LiveGrepMatch ",,rgb:%opt{orange}+u" 42 } 43} 44 45bundle kak-lsp "https://github.com/kak-lsp/kak-lsp" %{ 46 set-option global lsp_auto_highlight_references true 47 set-option global lsp_hover_max_lines 1000 48 set-option global lsp_hover_anchor true 49 set-option global lsp_snippet_support false # This breaks my muscle memory 50 51 map global normal <c-h> ":lsp-hover<ret>" 52 map global normal <c-a-h> ":lsp-hover-buffer<ret>" 53 map global normal <c-a> ":lsp-code-actions<ret>" 54 map global normal <c-r> ":lsp-rename-prompt<ret>" 55 map global normal <c-e> ":lsp-diagnostics<ret>" 56 57 map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol' 58 map global object <a-a> '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol' 59 map global object f '<a-semicolon>lsp-object Function Method<ret>' -docstring 'LSP function or method' 60 map global object t '<a-semicolon>lsp-object Class Interface Struct<ret>' -docstring 'LSP class interface or struct' 61 map global object d '<a-semicolon>lsp-diagnostic-object --include-warnings<ret>' -docstring 'LSP errors and warnings' 62 map global object D '<a-semicolon>lsp-diagnostic-object<ret>' -docstring 'LSP errors' 63 64 map global goto m "<esc><c-s>:lsp-implementation<ret>" -docstring "implementations" 65 66 map global user l ":enter-user-mode lsp<ret>" -docstring "lsp..." 67 map global lsp m ":lsp-show-message-request-next<ret>" 68 69 lsp-inlay-diagnostics-enable global 70 lsp-auto-signature-help-enable 71 72 # Custom status line 73 declare-option -hidden str lsp_modeline_progress "" 74 define-command -hidden -params 6 -override lsp-handle-progress %{ 75 set-option global lsp_modeline_progress %sh{ 76 if ! "$6"; then 77 echo "$2${5:+" ($5%)"}${4:+": $4"}" 78 fi 79 } 80 } 81} 82bundle-install-hook kak-lsp %{ cargo install --locked --force --path . } 83 84bundle kak-rainbower "https://github.com/crizan/kak-rainbower" %{ 85 set-option global rainbow_mode 0 86 set-option global rainbow_check_templates Y 87 88 hook global WinCreate .* %{ 89 rainbow-enable-window 90 } 91} 92 93bundle kak-replace-mode "https://github.com/raiguard/kak-replace-mode" %{ 94 map global normal <a-r> ":enter-replace-mode<ret>" 95} 96 97bundle kakoune-focus "https://github.com/caksoylar/kakoune-focus" %{ 98 map global user <space> ':focus-toggle<ret>' -docstring "toggle selections focus" 99} 100 101bundle kakoune-gdb "https://github.com/occivink/kakoune-gdb" %{ 102 define-command tmux-gdb -params 1.. %{ 103 tmux-terminal-impl 'split-window -v -l 25%' %arg{@} 104 } 105 # define-command custom-gdb-session-connect %{ 106 # alias window terminal tmux-gdb 107 # gdb-session-connect 108 # unalias window terminal 109 # osc-yank "new-ui mi3 %opt{gdb_dir}/pty" 110 # gdb-enable-autojump 111 # } 112 # define-command -override -params .. custom-gdb-session-new %{ 113 # alias window terminal tmux-gdb 114 # gdb-session-new %arg{@} 115 # unalias window terminal 116 # gdb-enable-autojump 117 # trigger-user-hook GDBPostInit 118 # } 119 # map global normal <s-F5> ':prompt -menu -shell-script-candidates %{ fd --type f --hidden ".*" bin } file: %{ custom-gdb-session-new %val{text} }<ret>' -docstring "new GDB session" 120 # map global normal <s-F5> ":custom-gdb-session-connect<ret>" -docstring "connect to GDB session" 121 map global normal <F9> ":gdb-toggle-breakpoint<ret>" -docstring "GDB toggle breakpoint" 122 map global normal <F10> ":gdb-next<ret>" -docstring "GDB next" 123 map global normal <F11> ":gdb-step<ret>" -docstring "GDB step" 124 map global normal <F12> ":gdb-continue<ret>" -docstring "GDB continue" 125} 126 127bundle kakoune-grep-write "https://github.com/JacobTravers/kakoune-grep-write" %{ 128 hook global WinSetOption filetype=(grep|lsp-goto) %{ 129 alias buffer w grep-write 130 } 131} 132 133bundle kakoune-sort-selections "https://github.com/occivink/kakoune-sort-selections" 134 135bundle kakoune-state-save "https://gitlab.com/Screwtapello/kakoune-state-save" %{ 136 hook global KakBegin .* %{ 137 state-save-reg-load @ 138 } 139 hook global KakEnd .* %{ 140 state-save-reg-save @ 141 } 142} 143 144bundle grep-expand.kak "https://github.com/JacobTravers/grep-expand.kak" 145 146bundle smarttab.kak "https://github.com/andreyorst/smarttab.kak" %{ 147 hook global BufCreate .* %{ 148 expandtab 149 set-option buffer tabstop 2 150 set-option buffer softtabstop 2 151 set-option buffer indentwidth 2 152 } 153} 154 155bundle-theme kak-tokyo-night "https://codeberg.org/raiguard/kak-tokyo-night" 156 157# -------------------------------------------------- 158# GENERAL 159 160# Colorscheme 161colorscheme tokyo-night-night 162trigger-user-hook ColorschemeLoaded 163 164# General highlighters 165add-highlighter global/ number-lines -relative -separator " " -hlcursor 166add-highlighter global/ show-matching 167add-highlighter global/ line '%val{cursor_line}' SubBg 168add-highlighter global/ show-whitespaces -indent │ -tab " " -tabpad " " -spc " " -lf " " -nbsp " " 169 170# UI settings 171set-option global ui_options terminal_assistant=off terminal_set_title=false terminal_info_max_width=100 terminal_info_inline_borders=true terminal_scroll_bar=true 172set-option global startup_info_version 10000000000000 # Don't show changelog 173set-option global scrolloff 5,5 174 175# Scroll bar 176set-face global ScrollBarGutter ",rgb:%opt{subbg}" 177set-face global ScrollBarHandle +r@Default 178 179# Enable LSP 180# This has to be after general highlighters so that line numbers appear closest to the buffer contents 181lsp-enable 182 183# Auto-reload please 184set-option global autoreload yes 185 186# Use ripgrep instead of grep 187set-option global grepcmd 'rg -Hn --no-heading --sort path --vimgrep' 188 189# More lenient make errors 190set-option global make_error_pattern "^\h*(?:\w:)?([^:\n]+):(\d+):(?:(\d+):)? (?:fatal )?(?:(error|warning|info|hint|note):)?([^\n]+)?" 191 192# Conveniently edit config 193define-command edit-kakrc %{ e ~/.config/kak/kakrc } 194 195# Convenient wrap highlighter 196define-command addwrap %{ 197 add-highlighter window/wrap wrap -word -indent 198} 199 200# Remove trailing whitespace on save 201hook -group auto-trim-whitespace global BufWritePre .* %{ try %{ execute-keys -draft \%s\h+$<ret>d } } 202 203# Automatically parse modelines 204hook global BufOpenFile .* modeline-parse 205 206alias global terminal-floating terminal 207alias global terminal-overlay terminal 208 209# Add extra sway commands 210hook global ModuleLoaded wayland %{ 211 set-option global termcmd 'foot sh -c' 212} 213hook global ModuleLoaded sway %{ 214 define-command -params .. terminal-floating %{ 215 set-option window termcmd 'foot -a foot.floating sh -c' 216 terminal %arg{@} 217 unset-option window termcmd 218 } 219 define-command -params .. -command-completion splith %{ 220 nop %sh{ swaymsg splith } 221 new %arg{@} 222 } 223 define-command -params .. -command-completion splitv %{ 224 nop %sh{ swaymsg splitv } 225 new %arg{@} 226 } 227 alias global terminal-overlay terminal-floating 228} 229 230# Add extra tmux commands 231hook global ModuleLoaded tmux %{ 232 alias global terminal tmux-terminal-horizontal 233 define-command -params .. terminal-floating %{ 234 tmux-terminal-impl 'display-popup -E' %arg{@} 235 } 236 define-command -params .. terminal-overlay %{ 237 tmux-terminal-window %arg{@} 238 } 239 define-command splitv %{ 240 alias local terminal tmux-terminal-vertical 241 new 242 } 243 define-command splith %{ 244 alias local terminal tmux-terminal-horizontal 245 new 246 } 247} 248 249# -------------------------------------------------- 250# MAPPINGS 251 252# NORMAL 253 254# Comment 255map global normal "#" ":comment-line<ret>" 256map global normal "<a-#>" ":comment-block<ret>" 257 258# Go to file (basic fuzzy finder) 259map global user f '<esc>:prompt -shell-script-candidates %{ fd --type f } file: %{ edit %val{text} }<ret>' -docstring "file" 260 261# Go to buffer 262map global user b '<esc>:prompt -buffer-completion buffer: %{ buffer %val{text} }<ret>' -docstring "buffer" 263 264# Pick a file with NNN 265map global normal <minus> ':terminal-overlay "%val{config}/nnn-pick.sh" "%val{buffile}" "%val{client}" "%val{session}"<ret>' 266 267# Pipe the primary selection to a command and echo the output to the statusline 268map global normal <a-$> ':prompt -shell-completion echo-pipe: %{ echo %sh{ printf "%s" "$kak_selection" | $kak_text }}<ret>' 269 270# Search case-insensitive by default 271map global normal "/" "/(?i)" 272map global normal "?" "?(?i)" 273map global normal "<a-/>" "<a-/>(?i)" 274map global normal "<a-?>" "<a-?>(?i)" 275 276# Always select entire lines 277map global normal J "Jx" 278map global normal K "Kx" 279 280# Select inner line 281map global normal X x_ 282 283# Select all occurances of current selection in file 284map global normal "<a-*>" "*<percent>s<ret>" -docstring "Select all matching in file" 285 286map global normal <c-y> ":osc-yank<ret>" 287define-command -hidden osc-yank -params .. \ 288-docstring "yank argument or selections to terminal clipboard using OSC 52" %{ 289 nop %sh{ 290 if [ $# = 0 ]; then 291 eval set -- "$kak_quoted_selections" 292 fi 293 copy=$1 294 shift 295 for sel; do 296 copy=$(printf '%s\n%s' "$copy" "$sel") 297 done 298 encoded=$(printf %s "$copy" | base64 | tr -d '\n') 299 if [ -n "$TMUX" ]; then 300 printf "\e]52;c;%s\a" "$encoded" > "$(tmux display-message -p '#{client_tty}')" 301 else 302 printf "\e]52;c;%s\a" "$encoded" > "/proc/$kak_client_pid/fd/0" 303 fi 304 } 305} 306 307map global normal <F5> ':prompt -menu -shell-script-candidates %{ fd --type f --hidden ".*" bin } file: %{ terminal lldb %val{text} }<ret>' -docstring "new LLDB session" 308 309# Jumps centered please 310map global normal <c-o> <c-o>vv 311map global normal <c-i> <c-i>vv 312 313# INSERT 314 315# Delete words in insert mode 316map global insert <c-w> "<a-;>h<a-;>B<a-;>d" 317 318# USER 319 320map global user n ':new edit %val{bufname}<ret>' -docstring "new window" 321map global user d ':osc-yank "b %val{buffile}:%val{cursor_line}"<ret>' -docstring "lldb breakpoint" 322 323# Sort 324declare-user-mode sort 325map global user s ":enter-user-mode sort<ret>" -docstring "sort..." 326map global sort l "|sort<ret>" -docstring "lines" 327map global sort s "<esc>:sort-selections<ret>" -docstring "selections" 328 329# Toggle 330declare-user-mode toggle 331map global user t ":enter-user-mode toggle<ret>" -docstring "toggle..." 332map global toggle i ':show-tab-info<ret>' -docstring "tab settings" 333define-command show-tab-info %{ 334 info -title "tab settings" "tabstop: %opt{tabstop} 335softtabstop: %opt{softtabstop} 336indentwidth: %opt{indentwidth}" 337} 338map global toggle s ':show-session-info<ret>' -docstring "session info" 339define-command -hidden show-session-info %{ 340 info -title "session info" "%val{client}/%val{session} 341%sh{pwd}" 342} 343 344# Git 345declare-user-mode git 346map global user g ":enter-user-mode git<ret>" -docstring "git..." 347map global git b ":git blame<ret>" -docstring "blame" 348map global git d ":git diff<ret>" -docstring "diff" 349map global git g ":terminal-overlay lazygit -p %sh{echo $PWD}<ret>" -docstring "lazygit" 350map global git u ":terminal-overlay gitu<ret>" -docstring "gitu" 351map global git f ":git-file-history<ret>" -docstring "file history" 352map global git l ":git-line-history<ret>" -docstring "line history" 353define-command -hidden git-line-history %{ 354 git log "-L%val{cursor_line},+1:%val{buffile}" 355} 356define-command -hidden git-file-history %{ 357 git log "%val{buffile}" 358} 359map global git o ":git-open-on-github<ret>" -docstring "open on GitHub" 360define-command git-open-on-github %{ 361 nop %sh{ gh browse "$kak_bufname:$kak_cursor_line" & } 362} 363 364# Wrap paragraphs 365map global user w ":wrap-paragraph<ret>" -docstring "wrap paragraph" 366define-command wrap-paragraph %{ 367 execute-keys "<a-i>p<a-j>|fold -s -w %opt{autowrap_column}<ret>|sed 's/\s*$//g'<ret><esc>" 368} 369 370# IDE 371declare-user-mode ide 372map global user i ":enter-user-mode ide<ret>" -docstring "ide..." 373map global ide t ':set-option global toolsclient %val{client}<ret>' -docstring "set toolsclient" 374map global ide j ':set-option global jumpclient %val{client}<ret>' -docstring "set jumpclient" 375map global ide d ':set-option global docsclient %val{client}<ret>' -docstring "set docsclient" 376 377# Other 378map global user e ":edit -scratch<ret>" -docstring "scratch buffer" 379 380evaluate-commands %sh{ 381 if [ -f "justfile" ]; then 382 echo " 383 hook global ModuleLoaded make %{ 384 set-option global makecmd just 385 alias global just make 386 } 387 " 388 fi 389} 390 391# -------------------------------------------------- 392# FILETYPE HOOKS 393 394# Default window settings 395hook global BufCreate .* %{ 396 editorconfig-load 397 # Show and automatically update git diff on write 398 evaluate-commands %sh{ 399 branch=$(git -C "${kak_buffile%/*}" rev-parse --abbrev-ref HEAD 2>/dev/null) 400 if [ -n "$branch" ]; then 401 printf %s\\n " 402 git show-diff 403 hook buffer BufWritePost .* %{ git update-diff } 404 hook buffer BufReload .* %{ git update-diff } 405 " 406 fi 407 } 408} 409 410hook global BufSetOption filetype=(c|cpp) %{ 411 set-option buffer lsp_servers %{ 412 [clangd] 413 filetypes = ["c", "cpp"] 414 root_globs = ["compile_commands.json", ".clangd", ".git", ".hg"] 415 command = "clangd" 416 args = ["--limit-references=0", "--header-insertion=never", "--pch-storage=memory"] 417 } 418 419 map buffer user a ":clangd-switch-source-header<ret>" 420} 421 422hook global WinSetOption filetype=(c|cpp) %{ 423 # Better highlighting 424 add-highlighter -override "shared/%opt{filetype}/code/operator" regex (\+|-|\*|&|=|\\|\?|%|\^|\|-|!|\||->|<|>|\^|/|~|\[|\]) 0:operator 425 add-highlighter -override "shared/%opt{filetype}/code/constant" regex \b([A-Z0-9_]*)\b 1:value 426 add-highlighter -override "shared/%opt{filetype}/code/functioncall" regex \b([a-zA-Z0-9_]*)\( 1:function 427 428 # Factorio doc comments 429 430 remove-highlighter "shared/%opt{filetype}/line_comment" 431 add-highlighter "shared/%opt{filetype}/line_comment" region //[^\?] (?<!\\)(?=\n) fill comment 432 433 require-module markdown 434 435 add-highlighter "shared/%opt{filetype}/factorio_documentation" region //\? (?<!\\)(?=\n) regions 436 add-highlighter "shared/%opt{filetype}/factorio_documentation/text" default-region group 437 add-highlighter "shared/%opt{filetype}/factorio_documentation/text/" fill comment 438 add-highlighter "shared/%opt{filetype}/factorio_documentation/text/" ref markdown 439 add-highlighter "shared/%opt{filetype}/factorio_documentation/text/comment_prefix" regex //\? 0:meta 440 add-highlighter "shared/%opt{filetype}/factorio_documentation/text/tag" regex \$[a-z_]+ 0:function 441 442 add-highlighter "shared/%opt{filetype}/factorio_documentation/tag" region -recurse \$[a-z_]+\( \$[a-z_]+\( \) group 443 add-highlighter "shared/%opt{filetype}/factorio_documentation/tag/variable" regex [a-zA-Z0-9_:\.-]+ 0:type 444 add-highlighter "shared/%opt{filetype}/factorio_documentation/tag/tag" regex \$[a-z_]+ 0:function 445 add-highlighter "shared/%opt{filetype}/factorio_documentation/tag/property" regex (\$(|param|return|raises|subclass|property))\( 1:keyword 446 add-highlighter "shared/%opt{filetype}/factorio_documentation/tag/value" regex \b(\d+|true|false)\b 1:value 447 add-highlighter "shared/%opt{filetype}/factorio_documentation/tag/string" regex '".*?"' 0:string 448} 449# GNU STL has a really stupid indentation format 450hook global BufCreate /usr/include/c\+\+/.* %{ 451 set-option buffer tabstop 8 452 set-option buffer softabstop 4 453 set-option buffer indentwidth 4 454} 455 456hook global BufCreate ".*changelog\.txt$" %{ 457 try %{ 458 execute-keys -draft ggxs---------------------------------------------------------------------------------------------------<ret> 459 set-option buffer filetype factorio-changelog 460 } 461} 462hook global BufSetOption filetype=factorio-changelog %{ 463 add-highlighter buffer/changelog_date regex ^(Date):\s(.*?)$ 1:type 2:function 464 add-highlighter buffer/changelog_entry regex ^(\s\s)*(-)\s(.*?)$ 2:value 3:string 465 add-highlighter buffer/changelog_section regex "^\s*(Balancing|Bugfixes|Changes|Circuit Network|Combat Balancing|Compatibility|Control|Debug|Ease Of Use|Features|Graphics|Gui|Info|Locale|Major Features|Minor Features|Modding|Optimizations|Other|Scripting|Sounds|Translation):" 1:type 466 add-highlighter buffer/changelog_separator regex ^-+$ 0:keyword 467 add-highlighter buffer/changelog_version regex ^(Version):\s(\d+\.\d+\.\d+)$ 1:type 2:value 468} 469 470hook global BufCreate (.*locale/.*/.*\.cfg) %{ 471 set-option buffer filetype factorio-locale 472} 473hook global BufSetOption filetype=factorio-locale %{ 474 require-module conf 475 add-highlighter buffer/conf ref conf 476 add-highlighter buffer/locale_macro regex __[^\n]*?__ 0:meta 477 add-highlighter buffer/locale_rich_text regex \[(achievement|armor|color|entity|fluid|font|gps|item|item-group|recipe|special-item|technology|tile|tooltip|train|train-stop|virtual-signal)=.*?\] 0:function 478 add-highlighter buffer/locale_rich_text_close regex \[/(achievement|armor|color|entity|fluid|font|gps|item|item-group|recipe|special-item|technology|tile|tooltip|train|train-stop|virtual-signal)\] 0:function 479} 480 481hook global BufSetOption filetype=(git-commit|mail) %{ 482 set-option buffer autowrap_column 72 483 set-option buffer autowrap_format_paragraph true 484 autowrap-enable 485} 486 487hook global BufCreate .*[.](glsl|vert|tesc|tese|geom|frag|comp) %{ 488 set-option buffer filetype glsl 489} 490 491hook global BufSetOption filetype=glsl %{ 492 add-highlighter buffer/glsl regions 493 add-highlighter buffer/glsl/code default-region group 494 add-highlighter buffer/glsl/line_comment region '//' $ fill comment 495 add-highlighter buffer/glsl/comment region '/\*' '\*/' fill comment 496 add-highlighter buffer/glsl/code/operator regex (\+|-|\*|&|=|\\|\?|%|\^|\|-|!|\||->|<|>|\^|/|~|\[|\]) 0:operator 497 add-highlighter buffer/glsl/code/function_call regex \b([a-zA-Z0-9_]*)\h*\( 1:function 498 add-highlighter buffer/glsl/code/constant regex \b([A-Z0-9_]*)\b 1:value 499 add-highlighter buffer/glsl/code/types regex \b(void|bool|int|uint|float|double|(b|i|u|d)?vec(2|3|4)|mat(2|3|4)|mat(2|3|4)x(2|3|4)|sampler(1|2|3)D)\b 1:type 500 add-highlighter buffer/glsl/code/keyword regex \b(out|in|uniform|layout|if|else|for|struct|return)\b 1:keyword 501 add-highlighter buffer/glsl/code/macro regex (#version) 1:meta 502 add-highlighter buffer/glsl/code/export regex \b(gl_Position)\b 1:string 503} 504 505hook global BufSetOption filetype=go %{ 506 noexpandtab 507 set-option buffer indentwidth 0 508 set-option buffer tabstop 4 509 set-option buffer softtabstop 4 510 511 hook buffer BufWritePre .* lsp-formatting-sync 512 513 map buffer user a :go-alternative-file<ret> -docstring "alternative file" 514} 515 516hook global BufSetOption filetype=hare %{ 517 noexpandtab 518 set-option buffer tabstop 8 519 set-option buffer softtabstop 0 520 set-option buffer indentwidth 0 521} 522 523hook global BufSetOption filetype=java %{ 524 set-option buffer tabstop 4 525 set-option buffer softtabstop 4 526 set-option buffer indentwidth 4 527 528 hook global BufWritePre .*\.java lsp-formatting-sync 529 530 add-highlighter -override shared/java/code/operator regex (=|==|&&|\|\||\+|-|/|\*|\+=|-=|\*=|/=|!|<=|>=|<|>) 1:operator 531} 532 533hook global BufSetOption filetype=json %{ 534 set-option buffer formatcmd 'jq .' 535} 536 537hook global BufSetOption filetype=lua %{ 538 set-option buffer lsp_servers %exp{ 539 # [luapls] 540 # filetypes = ["lua"] 541 # root_globs = [".git/", ".luarc.json", ".editorconfig", ".kakrc"] 542 # command = "/home/rai/dev/personal/luapls/luapls" 543 # args = ["lsp", "3"] 544 # settings_section = "luapls" 545 546 # [luapls.settings.luapls] 547 # roots = ["demo.lua"] 548 549 # [emmylua_ls] 550 # filetypes = ["lua"] 551 # root_globs = [".git/", ".luarc.json", ".editorconfig", ".kakrc"] 552 # command = "emmylua_ls" 553 554 [luals] 555 filetypes = ["lua"] 556 root_globs = [".git/", ".luarc.json", ".editorconfig", ".kakrc"] 557 command = "lua-language-server" 558 args = ["--logpath=/home/rai/.local/share/lua-language-server/log"] 559 560 [luals.settings.Lua] 561 diagnostics.disable = ["lowercase-global"] 562 diagnostics.severity = { unused-local = "Error", undefined-global = "Error", undefined-field = "Error" } 563 hover.expandAlias = false 564 hover.previewFields = 0 565 semantic.enable = false 566 telemetry.enable = false 567 workspace.userThirdParty = ["/home/rai/dev/luals"] 568 569 [fmtk-locale] 570 filetypes = ["factorio-locale", "lua"] 571 root_globs = ["info.json"] 572 command = "fmtk" 573 args = ["lsp", "--stdio"] 574 575 [fmtk-changelog] 576 filetypes = ["factorio-changelog", "lua"] 577 root_globs = ["info.json"] 578 command = "fmtk" 579 args = ["lsp", "--stdio"] 580 } 581 582 set-option buffer formatcmd "stylua -" 583 # Only auto-format if it is our own Factorio project 584 evaluate-commands %sh{ 585 if [ -f "info.json" ] && [ $(jq -r ".author" < info.json) = "raiguard" ]; then 586 echo "hook buffer BufWritePre .* format" 587 fi 588 } 589} 590 591hook global WinSetOption filetype=lua %{ 592 # Highlight EmmyLua annotations 593 add-highlighter window/emmylua_direct regex "---\s*(@(?:alias|as|class|enum|generic|return|type|overload))\s+([^\n]*)" 1:attribute 2:type 594 add-highlighter window/emmylua_labeled regex "---\s*(@(?:alias|cast|field|param))\s+([a-zA-Z0-9_]*) ([^\n]*)" 1:attribute 2:variable 3:type 595 add-highlighter window/emmylua_enum_variant regex '---\s*\|\s*("[^\n]*")' 1:string 596 597} 598 599hook global WinSetOption filetype=makefile %{ 600 noexpandtab 601 set-option window indentwidth 0 602} 603 604hook global WinSetOption filetype=python %{ 605 set-option window tabstop 4 606 set-option window softtabstop 4 607 set-option window indentwidth 4 608 609 set-option window formatcmd "autopep8 -" 610 611 add-highlighter -override shared/python/code/functioncall regex '\b([a-zA-Z0-9_]*)\h*\(' 1:function 612} 613 614hook global WinSetOption filetype=rust %{ 615 lsp-inlay-hints-enable window 616 617 set-option window tabstop 4 618 set-option window softtabstop 4 619 set-option window indentwidth 4 620 621 hook window BufWritePre .* lsp-formatting-sync 622} 623 624# TODO: Create a kak plugin for this filetype 625hook global BufCreate .+\.scd %{ 626 set-option buffer filetype scdoc 627} 628hook global WinSetOption filetype=scdoc %{ 629 noexpandtab 630 631 set-option window autowrap_format_paragraph true 632 autowrap-enable 633 634 add-highlighter window/scdoc_header regex "^##?\s*.*?$" 0:+b 635 add-highlighter window/scdoc_bold regex "\*.*?\*" 0:+b 636 add-highlighter window/scdoc_underline regex "\b_.*?_\b" 0:+u 637} 638 639hook global WinSetOption filetype=zig %{ 640 set-option window tabstop 4 641 set-option window softtabstop 4 642 set-option window indentwidth 4 643} 644hook global ModuleLoaded zig %{ 645 add-highlighter shared/zig/code/function_call regex \b([a-zA-Z0-9]+)\( 1:function 646 add-highlighter shared/zig/code/builtin_function regex (@[a-zA-Z0-9]+)\( 1:builtin 647} 648 649hook global WinCreate '/tmp/\.nnn.*' %{ 650 hook -once window WinDisplay .* %{ 651 execute-keys '%<a-s><a-s-k>^#<ret><a-;>;' 652 } 653} 654 655# -------------------------------------------------- 656# TODO Mode 657 658# Highlight TODO and other related comment tags 659hook global WinSetOption comment_line=(.*) %{ 660 add-highlighter -override window/todo regex "\Q%val{hook_param_capture_1}\E\h*(TODO(?: raiguard)?:)[^\n]*" 1:string 661 add-highlighter -override window/fixme regex "\Q%val{hook_param_capture_1}\E\h*((?:FIXME|XXX)(?: raiguard)?:)[^\n]*" 1:Error 662} 663# Show list of TODOs in the current project 664map global toggle t ":grep '(BUG|FIXME|TODO|TEMPORARY)( raiguard)?:'<ret>" -docstring "TODOs" 665 666# -------------------------------------------------- 667# MODELINE 668 669# Git branch 670declare-option -hidden str modeline_git_branch 671hook global WinDisplay .* %{ 672 set-option window modeline_git_branch %sh{ 673 branch=$(git -C "${kak_buffile%/*}" rev-parse --abbrev-ref HEAD 2>/dev/null) 674 if [ -n "$branch" ]; then 675 printf "$branch " 676 fi 677 } 678} 679 680set-option global modelinefmt '{keyword}%opt{lsp_modeline_breadcrumbs}%opt{lsp_modeline_code_actions}%opt{lsp_modeline_progress}%opt{lsp_modeline_message_requests} {StatusLine}{string}%opt{modeline_git_branch}{type}%sh{ [ -n "$kak_opt_filetype" ] && echo "$kak_opt_filetype " }{default}%val{bufname}{{context_info}}{default} {{mode_info}} {meta}%val{cursor_line}:%val{cursor_char_column}' 681 682# -------------------------------------------------- 683# OTHER 684 685# Wrapper commands 686define-command -params .. -docstring "fmm [<arguments>]: fmm utility wrapper" fmm %{ 687 fifo -name *fmm* -scroll -- fmm %arg{@} 688 set-option buffer filetype make 689 set-option buffer jump_current_line 0 690} 691define-command -params .. -docstring "frun [<arguments>]: frun utility wrapper" frun %{ 692 fifo -name *frun* -scroll -- frun %arg{@} 693 set-option buffer filetype grep 694 set-option buffer jump_current_line 0 695} 696 697# Quickly test faces 698declare-option range-specs test_ranges 699define-command add-test-face -params 1 %{ 700 set-option -add window test_ranges "%val{selection_desc}|%arg{1}" 701 add-highlighter -override window/test_ranges ranges test_ranges 702} 703alias global tface add-test-face 704 705define-command run-selected-commands %{ 706 evaluate-commands -itersel -draft %exp{ %val{selection} } 707} 708 709# Load local configuration 710evaluate-commands %sh{ 711 if [ -f ".kakrc" ]; then 712 echo "source ./.kakrc" 713 fi 714} 715 716source "%val{config}/delete-all-buffers.kak" 717source "%val{config}/jump-stack.kak"