diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-10-20 22:21:17 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-10-21 13:39:46 +0530 |
| commit | 87a96e7c86ef7a718246dfe6fc37b219c66dc557 (patch) | |
| tree | 3715263544ee5b2b10019988d17c100aa5888d3d /autoload | |
| parent | 717ed5d90813ac7610b8d9cf1e110b6f31e87efc (diff) | |
| download | kakoune-config-87a96e7c86ef7a718246dfe6fc37b219c66dc557.tar.gz kakoune-config-87a96e7c86ef7a718246dfe6fc37b219c66dc557.zip | |
Refactored bits out into files
Diffstat (limited to 'autoload')
| -rw-r--r-- | autoload/+init.kak | 77 | ||||
| -rw-r--r-- | autoload/build.kak | 8 | ||||
| -rw-r--r-- | autoload/files.kak | 14 | ||||
| -rw-r--r-- | autoload/formatter.kak | 9 | ||||
| -rw-r--r-- | autoload/git.kak | 2 | ||||
| -rw-r--r-- | autoload/orgmode/orgmode.kak | 42 | ||||
| -rw-r--r-- | autoload/surround.kak | 24 | ||||
| -rw-r--r-- | autoload/syntax/mdx.kak | 3 | ||||
| -rw-r--r-- | autoload/syntax/org.kak | 41 | ||||
| -rw-r--r-- | autoload/window.kak | 12 |
10 files changed, 120 insertions, 112 deletions
diff --git a/autoload/+init.kak b/autoload/+init.kak index b1290fb..243df1d 100644 --- a/autoload/+init.kak +++ b/autoload/+init.kak @@ -30,13 +30,23 @@ add-highlighter global/ line '%val{cursor_line}' RowLine add-highlighter global/ regex \h+$ 0:Error # Highlight trailing whitespaces add-highlighter global/ wrap -word -indent # Softwrap long lines add-highlighter global/ show-matching -previous -add-highlighter global/ show-whitespaces -spc ' ' -tab '│' -tabpad 'y' -lf '¬' -indent '│' +add-highlighter global/ show-whitespaces -spc ' ' -tab '│' -lf '¬' -indent '│' +hook global RegisterModified '/' %{ + # Highlight current searchterm + add-highlighter -override global/search regex "%reg{/}" 0:search +} -# Search -hook global RegisterModified '/' %{ add-highlighter -override global/search regex "%reg{/}" 0:search } -map global user '<esc>' ': set-register slash ""<ret>' -map global user '/' '/(?i)' -map global user 'r' '*%s<ret>' +# System keys +map global user '<esc>' ': set-register slash ""<ret>' -docstring 'Clear search highlighting' +map global normal '/' '/(?i)' # Remap / to case-insensitive search +map global user '/' '/' +map global user r '*%s<ret>' -docstring 'Replace selection' +map global user s ': w<ret>' -docstring 'Save' +map global normal <c-j> 15j -docstring '15 down' +map global normal <c-k> 15k -docstring '15 up' +# Clipboard management mappings +map global user y "<a-|> xclip -selection clipboard<ret>" -docstring "yank the selection into the clipboard" +map global user p "<a-!> xclip -selection clipboard -o<ret>" -docstring "paste the clipboard" declare-user-mode system map global user q ': enter-user-mode system<ret>' -docstring 'System mode' @@ -63,22 +73,6 @@ hook global ModeChange .*:insert:.* %{ try %{ unset-face window PrimaryCursorEol } } -# Tmux window mode -declare-user-mode win -map global normal <c-w> ':enter-user-mode win<ret>' -docstring 'Window mode' -map global win q ': quit<ret>' -docstring 'Quit' -map global win v ': tmux-terminal-horizontal kak -c %val{session}<ret>' -docstring 'Split vertical' -map global win s ': tmux-terminal-vertical kak -c %val{session}<ret>' -docstring 'Split horizontal' -map global win h ': nop %sh{tmux select-pane -L}<ret>' -docstring 'Jump left' -map global win j ': nop %sh{tmux select-pane -D}<ret>' -docstring 'Jump down' -map global win k ': nop %sh{tmux select-pane -U}<ret>' -docstring 'Jump up' -map global win l ': nop %sh{tmux select-pane -R}<ret>' -docstring 'Jump right' -map global win z ': wq<ret>' - -# Clipboard management mappings -map global user y "<a-|> xclip -selection clipboard<ret>" -docstring "yank the selection into the clipboard" -map global user p "<a-!> xclip -selection clipboard -o<ret>" -docstring "paste the clipboard" - # Code mode declare-user-mode code map global user c ':enter-user-mode code<ret>' -docstring 'Code mode' @@ -91,41 +85,6 @@ map global code <a-k> :casekebab<ret> -docstring 'kebab-casing' map global code <a-_> :casesnake<ret> -docstring 'snake_casing' map global code <a-c> :casecamel<ret> -docstring 'camelCasing' -# Quick move -map global normal <c-j> 15j -map global normal <c-k> 15k - # Editorconfig -hook global BufOpenFile .* %{ try %{editorconfig-load} } -hook global BufNewFile .* %{ try %{editorconfig-load} } - -declare-user-mode surround -declare-user-mode surround-append -declare-user-mode surround-delete -map global user s ': enter-user-mode surround<ret>' -map global surround a ': enter-user-mode surround-append<ret>' -map global surround d ': enter-user-mode surround-delete<ret>' - -define-command define-surround -params 3 %{ - evaluate-commands %sh{ - echo "map global surround-append %{${1}} %{i${2}<esc>a${3}}" - echo "map global surround-delete %{${1}} %{<a-a>${2}<a-S>d,}" - } -} - -# hook global KakBegin .* %{ -# define-surround ( ( ) -# define-surround [ [ ] -# # define-surround < < > -# # define-surround '{' '{' '}' -# # define-surround '<' '<' '>' -# # define-surround '`' '`' '`' -# define-surround '"' '"' '"' -# # define-surround "'" "'" "'" -# } - - -hook global BufCreate .*[.]mdx %{ - set-option buffer filetype markdown -} - +hook global BufOpenFile .* %{ try %{ editorconfig-load } } +hook global BufNewFile .* %{ try %{ editorconfig-load } } diff --git a/autoload/build.kak b/autoload/build.kak index 6547309..e882b9e 100644 --- a/autoload/build.kak +++ b/autoload/build.kak @@ -4,3 +4,11 @@ set-option global makecmd 'make -j8' hook global BufSetOption filetype=(?:typescript|javascript) %{ set-option global makecmd "%val{config}/scripts/tsc-vimgrep.sh" } + +hook global BufSetOption filetype=haskell %{ + set-option global makecmd "cabal build" +} + +hook global BufSetOption filetype=rust %{ + set-option global makecmd "cargo build" +} diff --git a/autoload/files.kak b/autoload/files.kak index 09477c1..eb03a87 100644 --- a/autoload/files.kak +++ b/autoload/files.kak @@ -4,12 +4,12 @@ def find -docstring "find files" -menu -params 1 %{ edit -existing %arg{1} } \ def file-manager -params .. %{ connect terminal env "EDITOR=kcr edit" daffm -c @kak %arg{@} } declare-user-mode buffer -map global user b ':enter-user-mode buffer<ret>' -docstring 'Buffer mode' -map global buffer b ':buffer ' -docstring 'Switch buffer' -map global buffer d ':delete-buffer<ret>' -docstring 'Delete buffer' -map global buffer s ':write<ret>' -docstring 'Save' +map global user b ': enter-user-mode buffer<ret>' -docstring 'Buffer mode' +map global buffer b ': buffer ' -docstring 'Switch buffer' +map global buffer d ': delete-buffer<ret>' -docstring 'Delete buffer' +map global buffer s ': write<ret>' -docstring 'Save' declare-user-mode file -map global user f ':enter-user-mode file<ret>' -docstring 'File mode' -map global file f ':find ' -docstring 'Find files' -map global file n ':file-manager %val{buffile}<ret>' -docstring 'File manager' +map global user f ': enter-user-mode file<ret>' -docstring 'File mode' +map global file f ': find ' -docstring 'Find files' +map global file n ': file-manager %val{buffile}<ret>' -docstring 'File manager' diff --git a/autoload/formatter.kak b/autoload/formatter.kak index 741e9e8..6012604 100644 --- a/autoload/formatter.kak +++ b/autoload/formatter.kak @@ -1,7 +1,9 @@ -# TODO: Use a single hook? hook global BufSetOption filetype=json %{ set-option buffer formatcmd "jq" } + hook global BufSetOption filetype=fennel %{ set-option buffer formatcmd "fnlfmt -" } + hook global BufSetOption filetype=nix %{ set-option buffer formatcmd "nixfmt -" } + hook global BufSetOption filetype=(?:javascript|typescript) %{ evaluate-commands %sh{ if [ -f "$PWD/biome.json" ]; then @@ -9,11 +11,10 @@ hook global BufSetOption filetype=(?:javascript|typescript) %{ fi } } + hook global BufSetOption filetype=(?:ruby) %{ evaluate-commands %sh{ - if [ -f "$PWD/.rubocop.yml" ]; then - echo "set-option buffer formatcmd %{rubocop -x --stderr -s '$kak_buffile'}" - fi + echo "set-option buffer formatcmd %{rubocop -x --stderr -s '$kak_buffile'}" } } diff --git a/autoload/git.kak b/autoload/git.kak index 20eab1e..2ef96a0 100644 --- a/autoload/git.kak +++ b/autoload/git.kak @@ -9,10 +9,10 @@ map global git s ': gitui<ret>' -docstring 'Git tui' map global git A ': git add %val{buffile}<ret>' -docstring 'Add file' map global git c ': git add commit<ret>' -docstring 'Commit' map global git C ': git add commit --amend<ret>' -docstring 'Amend commit' +map global git m ': git-line-blame<ret>' -docstring 'Blame selection lines' map global git r ': enter-user-mode git-r<ret>' -docstring 'Git re(base/set) mode' map global git-r f ': git reset HEAD^1 -- %val{buffile}<ret>' -docstring 'Split file out of last commit' -map global git m ': git-line-blame<ret>' -docstring 'Blame selection lines' # Hunk map global git n ': git next-hunk<ret>' -docstring 'Next hunk' diff --git a/autoload/orgmode/orgmode.kak b/autoload/orgmode/orgmode.kak index 370ea14..170a73b 100644 --- a/autoload/orgmode/orgmode.kak +++ b/autoload/orgmode/orgmode.kak @@ -1,13 +1,6 @@ -hook global BufCreate .*[.]org %{ - set-option buffer filetype org -} - declare-user-mode org hook global WinSetOption filetype=org %{ - add-highlighter window/org ref org - require-module orgmode-highlight - - map window normal <ret> ': orgmode-jump-link<ret>' + map window normal <ret> ': orgmode-jump-link<ret>' -docstring 'Jump to link' map window user o ': enter-user-mode org<ret>' -docstring 'Org mode' map window org <tab> ': orgmode-toggle<ret>' -docstring 'Toggle checkbox/task' } @@ -66,36 +59,3 @@ define-command orgmode-toggle-task-state %{ } } } - -provide-module orgmode-highlight %{ - add-highlighter shared/org regions - add-highlighter shared/org/inline default-region regions - add-highlighter shared/org/inline/text default-region group - - add-highlighter shared/org/inline/text/ regex \*[^\n*]+\* 0:inlineBold - add-highlighter shared/org/inline/text/ regex /[^\n/]+/ 0:inlineItalic - add-highlighter shared/org/inline/text/ regex _[^\n_]+_ 0:inlineUnderline - add-highlighter shared/org/inline/text/ regex \+[^\n+]+\+ 0:inlineStrikethrough - add-highlighter shared/org/inline/text/ regex ~[^\n~]+~ 0:inlineCode - add-highlighter shared/org/inline/text/ regex \[\[[^\n]+\]\] 0:inlineLink - add-highlighter shared/org/codeblock region -match-capture \ - ^\h*#\+(?:begin|BEGIN)_([a-zA-Z]*)[^\n]*$ \ - ^\h*#\+(?:end|END)_([a-zA-Z]*)[^\n]*$ \ - regions - add-highlighter shared/org/codeblock/ default-region fill orgCodeBlock - - add-highlighter shared/org/inline/text/ regex ^[*]{1}[^\n]* 0:header1 - add-highlighter shared/org/inline/text/ regex ^[*]{2}[^\n]* 0:header2 - add-highlighter shared/org/inline/text/ regex ^[*]{3}[^\n]* 0:header3 - add-highlighter shared/org/inline/text/ regex ^[*]{4}[^\n]* 0:header4 - add-highlighter shared/org/inline/text/ regex ^[*]{5}[^\n]* 0:header5 - add-highlighter shared/org/inline/text/ regex ^[*]{6}[^\n]* 0:header6 - - add-highlighter shared/org/inline/text/ regex ^[*]*\s+(TODO) 1:orgTaskStateTodo - add-highlighter shared/org/inline/text/ regex ^[*]*\s+(DONE) 1:orgTaskStateDone - add-highlighter shared/org/inline/text/ regex ^[*]*\s+(ACTIVE) 1:orgTaskStateActive - - add-highlighter shared/org/inline/text/ regex ^\s*-\s*(\[[xX]\])\h([^\n]+)$ 1:checkboxChecked 2:checkboxCheckedText - add-highlighter shared/org/inline/text/ regex ^\s*-\s*(\[[\s]\]) 1:checkboxTodo - add-highlighter shared/org/inline/text/ regex ^\s*-\s*(\[[-]\]) 1:checkboxPending -} diff --git a/autoload/surround.kak b/autoload/surround.kak new file mode 100644 index 0000000..9409935 --- /dev/null +++ b/autoload/surround.kak @@ -0,0 +1,24 @@ +# declare-user-mode surround +# declare-user-mode surround-append +# declare-user-mode surround-delete +# map global user s ': enter-user-mode surround<ret>' +# map global surround a ': enter-user-mode surround-append<ret>' +# map global surround d ': enter-user-mode surround-delete<ret>' + +# define-command define-surround -params 3 %{ +# evaluate-commands %sh{ +# echo "map global surround-append %{${1}} %{i${2}<esc>a${3}}" +# echo "map global surround-delete %{${1}} %{<a-a>${2}<a-S>d,}" +# } +# } + +# hook global KakBegin .* %{ +# define-surround ( ( ) +# define-surround [ [ ] +# # define-surround < < > +# # define-surround '{' '{' '}' +# # define-surround '<' '<' '>' +# # define-surround '`' '`' '`' +# define-surround '"' '"' '"' +# # define-surround "'" "'" "'" +# } diff --git a/autoload/syntax/mdx.kak b/autoload/syntax/mdx.kak new file mode 100644 index 0000000..b5c4b0a --- /dev/null +++ b/autoload/syntax/mdx.kak @@ -0,0 +1,3 @@ +hook global BufCreate .*[.]mdx %{ + set-option buffer filetype markdown +} diff --git a/autoload/syntax/org.kak b/autoload/syntax/org.kak new file mode 100644 index 0000000..79f6291 --- /dev/null +++ b/autoload/syntax/org.kak @@ -0,0 +1,41 @@ +hook global BufCreate .*[.]org %{ + set-option buffer filetype org +} + +hook global WinSetOption filetype=org %{ + add-highlighter window/org ref org + require-module orgmode-highlight +} + +provide-module orgmode-highlight %{ + add-highlighter shared/org regions + add-highlighter shared/org/inline default-region regions + add-highlighter shared/org/inline/text default-region group + + add-highlighter shared/org/inline/text/ regex \*[^\n*]+\* 0:inlineBold + add-highlighter shared/org/inline/text/ regex /[^\n/]+/ 0:inlineItalic + add-highlighter shared/org/inline/text/ regex _[^\n_]+_ 0:inlineUnderline + add-highlighter shared/org/inline/text/ regex \+[^\n+]+\+ 0:inlineStrikethrough + add-highlighter shared/org/inline/text/ regex ~[^\n~]+~ 0:inlineCode + add-highlighter shared/org/inline/text/ regex \[\[[^\n]+\]\] 0:inlineLink + add-highlighter shared/org/codeblock region -match-capture \ + ^\h*#\+(?:begin|BEGIN)_([a-zA-Z]*)[^\n]*$ \ + ^\h*#\+(?:end|END)_([a-zA-Z]*)[^\n]*$ \ + regions + add-highlighter shared/org/codeblock/ default-region fill orgCodeBlock + + add-highlighter shared/org/inline/text/ regex ^[*]{1}[^\n]* 0:header1 + add-highlighter shared/org/inline/text/ regex ^[*]{2}[^\n]* 0:header2 + add-highlighter shared/org/inline/text/ regex ^[*]{3}[^\n]* 0:header3 + add-highlighter shared/org/inline/text/ regex ^[*]{4}[^\n]* 0:header4 + add-highlighter shared/org/inline/text/ regex ^[*]{5}[^\n]* 0:header5 + add-highlighter shared/org/inline/text/ regex ^[*]{6}[^\n]* 0:header6 + + add-highlighter shared/org/inline/text/ regex ^[*]*\s+(TODO) 1:orgTaskStateTodo + add-highlighter shared/org/inline/text/ regex ^[*]*\s+(DONE) 1:orgTaskStateDone + add-highlighter shared/org/inline/text/ regex ^[*]*\s+(ACTIVE) 1:orgTaskStateActive + + add-highlighter shared/org/inline/text/ regex ^\s*-\s*(\[[xX]\])\h([^\n]+)$ 1:checkboxChecked 2:checkboxCheckedText + add-highlighter shared/org/inline/text/ regex ^\s*-\s*(\[[\s]\]) 1:checkboxTodo + add-highlighter shared/org/inline/text/ regex ^\s*-\s*(\[[-]\]) 1:checkboxPending +} diff --git a/autoload/window.kak b/autoload/window.kak new file mode 100644 index 0000000..8986914 --- /dev/null +++ b/autoload/window.kak @@ -0,0 +1,12 @@ +declare-user-mode win +map global normal <c-w> ':enter-user-mode win<ret>' -docstring 'Window mode' + +map global win q ': quit<ret>' -docstring 'Quit' +map global win <c-q> ': quit<ret>' -docstring 'Quit' +map global win v ': tmux-terminal-horizontal kak -c %val{session}<ret>' -docstring 'Split vertical' +map global win s ': tmux-terminal-vertical kak -c %val{session}<ret>' -docstring 'Split horizontal' +map global win h ': nop %sh{tmux select-pane -L}<ret>' -docstring 'Jump left' +map global win j ': nop %sh{tmux select-pane -D}<ret>' -docstring 'Jump down' +map global win k ': nop %sh{tmux select-pane -U}<ret>' -docstring 'Jump up' +map global win l ': nop %sh{tmux select-pane -R}<ret>' -docstring 'Jump right' +map global win z ': wq<ret>' |
