aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-10-12 21:38:24 +0530
committerAkshay Nair <phenax5@gmail.com>2025-10-21 13:39:44 +0530
commit2333c7d56be15e697c8f8ca40622021776a1dd42 (patch)
tree50aa7d471266adc013c4e90b19c7f23db06f3997
parent467d4238db8725d9349619d7421898b46eb01ed9 (diff)
downloadkakoune-config-2333c7d56be15e697c8f8ca40622021776a1dd42.tar.gz
kakoune-config-2333c7d56be15e697c8f8ca40622021776a1dd42.zip
Kakoune setup init
-rw-r--r--autoload/+init.kak115
-rw-r--r--autoload/cursorword.kak12
-rw-r--r--autoload/lsp-config.kak14
l---------autoload/standard-library1
-rw-r--r--colors/phenax.kak109
5 files changed, 251 insertions, 0 deletions
diff --git a/autoload/+init.kak b/autoload/+init.kak
new file mode 100644
index 0000000..c3987f9
--- /dev/null
+++ b/autoload/+init.kak
@@ -0,0 +1,115 @@
+# Link builtin autoloads
+nop %sh{ ln -s "$kak_runtime/rc" "$kak_config/autoload/standard-library" 2>/dev/null || true }
+# evaluate-commands %sh{kak-tree-sitter -dksvv --init "${kak_session}"}
+evaluate-commands %sh{kcr init kakoune}
+
+colorscheme phenax
+set-option global autoreload yes
+set-option global incsearch true
+set-option global indentwidth 2
+set-option global tabstop 2
+set-option global path -add "**"
+set-option global startup_info_version 20250603
+set-option global scrolloff 10,3
+set-option global makecmd 'make -j8' # Override for others
+set-option -add global ui_options \
+ terminal_assistant=none \
+ terminal_enable_mouse=false
+set-option global modelinefmt \
+ '{StatusLineDetails}{{context_info}} {{mode_info}}
+%val{cursor_line}/%val{buf_line_count}:%val{cursor_char_column}
+{StatusLineBufname}%sh{echo "$kak_bufname" | awk -F/ "{if (NF >= 2) {print \$(NF-1) \"/\" \$NF} else {print \$NF}}"}'
+
+# Highlighters
+add-highlighter global/ number-lines -relative -hlcursor -min-digits 3 -separator ' '
+add-highlighter global/ column '%opt{autowrap_column}' WrapLine
+add-highlighter global/ column '%val{cursor_char_column}' ColumnLine
+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/search dynregex '%reg{/}' 0:search
+hook global RegisterModified '/' %{ add-highlighter -override global/search regex "%reg{/}" 0:search }
+map global user '<esc>' ':set-register slash ""<ret>'
+
+# Mode cursors
+set-face global InsertCursor default,red+B
+hook global ModeChange .*:.*:insert %{
+ set-face window PrimaryCursor InsertCursor
+ set-face window PrimaryCursorEol InsertCursor
+}
+hook global ModeChange .*:insert:.* %{ try %{
+ unset-face window PrimaryCursor
+ unset-face window PrimaryCursorEol
+} }
+
+# File/buffer management
+def find -docstring "find files" -menu -params 1 %{ edit -existing %arg{1} } \
+ -shell-script-candidates %{ fd -t f --hidden --color=never -E .git }
+set-option global grepcmd "rg -S --vimgrep --hidden -g '!**/.git/**'"
+
+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'
+
+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 g ':grep ' -docstring 'Grep'
+map global file n ':file-manager %val{buffile}<ret>' -docstring 'File manager'
+
+# TODO: Proper mappings for next/prev on results
+hook global -always BufOpenFifo '\*grep\*' %{ map global normal <minus> ': grep-next-match<ret>' }
+hook global -always BufOpenFifo '\*make\*' %{ map global normal <minus> ': make-next-error<ret>' }
+
+# Git
+def gitui -params .. %{ connect terminal env "EDITOR=kcr edit" gitu %arg{@} }
+
+declare-user-mode git
+map global user g ':enter-user-mode git<ret>' -docstring 'Git mode'
+map global git n ':git next-hunk<ret>' -docstring 'Next hunk'
+map global git p ':git prev-hunk<ret>' -docstring 'Previous hunk'
+map global git s ':gitui<ret>' -docstring 'Git status UI'
+set-option global git_diff_add_char "+"
+set-option global git_diff_del_char "-"
+set-option global git_diff_mod_char "~"
+set-option global git_diff_top_char "^"
+# hook global -group git-diff ModeChange .*:.*:normal %{ try %{git show-diff} }
+# hook global -group git-diff WinCreate .* %{ try %{git show-diff} }
+
+# 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 'Find files'
+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'
+
+# 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 code
+map global user c ':enter-user-mode code<ret>' -docstring 'Code mode'
+map global code c :comment-line<ret> -docstring 'Comment/uncomment lines'
+def casecamel %{ exec '`s[-_<space>]<ret>d~<a-i>w' }
+def casesnake %{ exec '<a-:><a-;>s-|[a-z][A-Z]<ret>;a<space><esc>s[-\s]+<ret>c_<esc><a-i>w`' }
+def casekebab %{ exec '<a-:><a-;>s_|[a-z][A-Z]<ret>;a<space><esc>s[_\s]+<ret>c-<esc><a-i>w`' }
+map global code <a-k> :casekebab<ret> -docstring 'kebab-casing'
+map global code <a-s> :casesnake<ret> -docstring 'snake_casing'
+map global code <a-c> :casecamel<ret> -docstring 'camelCasing'
+
+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} }
+
diff --git a/autoload/cursorword.kak b/autoload/cursorword.kak
new file mode 100644
index 0000000..9c30f99
--- /dev/null
+++ b/autoload/cursorword.kak
@@ -0,0 +1,12 @@
+declare-option -hidden regex curword
+
+hook global NormalIdle .* %{
+ eval -draft %{try %{
+ exec <space><a-i>w <a-k>\A\w+\z<ret>
+ set-option buffer curword "\b\Q%val{selection}\E\b"
+ } catch %{
+ set-option buffer curword ''
+ }}
+}
+
+add-highlighter global/ dynregex '%opt{curword}' 0:CurWord
diff --git a/autoload/lsp-config.kak b/autoload/lsp-config.kak
new file mode 100644
index 0000000..cea1f3d
--- /dev/null
+++ b/autoload/lsp-config.kak
@@ -0,0 +1,14 @@
+eval %sh{kak-lsp}
+
+lsp-enable
+
+map global user l ':enter-user-mode lsp<ret>' -docstring 'LSP mode'
+
+map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
+
+map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
+map global object <a-a> '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol'
+map global object f '<a-semicolon>lsp-object Function Method<ret>' -docstring 'LSP function or method'
+map global object t '<a-semicolon>lsp-object Class Interface Struct<ret>' -docstring 'LSP class interface or struct'
+map global object d '<a-semicolon>lsp-diagnostic-object --include-warnings<ret>' -docstring 'LSP errors and warnings'
+map global object D '<a-semicolon>lsp-diagnostic-object<ret>' -docstring 'LSP errors'
diff --git a/autoload/standard-library b/autoload/standard-library
new file mode 120000
index 0000000..f679584
--- /dev/null
+++ b/autoload/standard-library
@@ -0,0 +1 @@
+/nix/store/ag5zk1qgp13as02psyql5bkc76wgc5a0-kakoune-2025.06.03/share/kak/rc \ No newline at end of file
diff --git a/colors/phenax.kak b/colors/phenax.kak
new file mode 100644
index 0000000..7118bf3
--- /dev/null
+++ b/colors/phenax.kak
@@ -0,0 +1,109 @@
+evaluate-commands %sh{
+ foreground="rgb:c5c8c6"
+ foreground2="rgb:809090"
+ background="default"
+ accent1="rgb:007070"
+ accent2="rgb:009090"
+ selection="rgb:373b41"
+ window="rgb:282a2e"
+ linenr_bg="default"
+ linenr_fg="rgb:606262"
+ linenr_fg_cur="rgb:ffffff"
+ menu="rgb:101414"
+ mildhighlight="rgb:101414"
+ comment="rgb:434545"
+ red="rgb:cc6666"
+ orange="rgb:de935f"
+ yellow="rgb:f0c674"
+ green="rgb:b3f6c0"
+ lightblue="rgb:81a2be"
+ brightblue="rgb:82aaff"
+ aqua="rgb:8abeb7"
+ purple="rgb:b294bb"
+
+ ## code
+ echo "
+ face global value ${orange}
+ face global type ${yellow}
+ face global variable ${red}
+ face global module ${lightblue}
+ face global function ${lightblue}
+ face global string ${green}
+ face global keyword ${accent2}
+ face global operator ${aqua}
+ face global attribute ${lightblue}
+ face global comment ${comment}
+ face global documentation comment
+ face global meta ${foreground}
+ face global builtin ${yellow}
+ "
+
+ ## markup
+ echo "
+ face global title ${lightblue}
+ face global header ${aqua}
+ face global mono ${green}
+ face global block ${orange}
+ face global link ${lightblue}
+ face global bullet ${red}
+ face global list ${red}
+ "
+
+ ## Custom
+ echo "
+ face global search default,rgb:212121+b
+ face global CurWord default,default+u
+ face global ColumnLine default,rgb:101010
+ face global RowLine default,rgb:101010
+ face global WrapLine default,rgb:101010
+ face global StatusLineBufname ${accent1},default+b
+ face global StatusLineDetails ${comment},default+b
+ "
+
+ ## builtin
+ echo "
+ face global Default ${foreground},${background}
+ face global PrimarySelection ${foreground},${selection}+fg
+ face global SecondarySelection ${foreground},${window}+fg
+ face global PrimaryCursor ${background},${foreground}+fg
+ face global SecondaryCursor ${background},${aqua}+fg
+ face global PrimaryCursorEol ${background},${green}+fg
+ face global SecondaryCursorEol ${background},${green}+fg
+ face global LineNumbers ${linenr_fg},${linenr_bg}
+ face global LineNumberCursor ${linenr_fg_cur},${linenr_bg}+b
+ face global LineNumbersWrapped ${mildhighlight},${linenr_bg}+b
+ face global MenuForeground ${menu},${foreground}
+ face global MenuBackground ${foreground},${menu}
+ face global MenuInfo ${red}
+ face global Information ${foreground2},${background}
+ face global Error ${foreground},${red}
+ face global DiagnosticError ${red}
+ face global DiagnosticWarning ${yellow}
+ face global StatusLine ${foreground},${background}
+ face global StatusLineMode ${yellow}+b
+ face global StatusLineInfo ${aqua},default
+ face global StatusLineValue ${green}
+ face global StatusCursor ${window},${aqua}
+ face global Prompt ${accent1},${background}
+ face global MatchingChar ${yellow},${background}+b
+ face global BufferPadding ${aqua},${background}
+ face global Whitespace ${comment}+f
+ "
+
+ ## code
+ echo "
+ face global ts_value value
+ face global ts_type type
+ face global ts_variable variable
+ face global ts_module module
+ face global ts_function function
+ face global ts_string string
+ face global ts_keyword keyword
+ face global ts_operator operator
+ face global ts_attribute attribute
+ face global ts_comment comment
+ face global ts_documentation documentation
+ face global ts_meta meta
+ face global ts_builtin builtin
+ "
+}