1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
# Venomade's kakrc
# ------
# SOURCE
# ------
# Use Colemak keybinds
source ~/.config/kak/colemak.kak
source ~/.config/kak/compilation-mode.kak
# -------
# OPTIONS
# -------
# Set tab width
set-option global tabstop 2
set-option global indentwidth 2
# Display line numbers
add-highlighter global/ number-lines -hlcursor
# Softwrap long lines
add-highlighter global/ wrap -word -indent
# Set the colorscheme
colorscheme 'modus-vivendi'
# Move the modeline to the top of the screen
set-option global ui_options terminal_status_on_top=yes
# Don't show changelog at startup
set-option global startup_info_version 10000000000000
# Add scroll margin
set-option global scrolloff 5,5
# Use ripgrep instead of grep
set-option global grepcmd 'rg -HUn --no-heading --sort path --vimgrep'
# Remove trailing whitespace on save
hook -group auto-trim-whitespace global BufWritePre .* %{ try %{ execute-keys -draft \%s\h+$<ret>d } }
# Disable Clippy
set-option -add global ui_options terminal_assistant=none
# Disable word completion
set-option global completers filename
# --------
# KEYBINDS
# --------
# Buffer Keybinds
declare-user-mode buffer-mode
map global user b ':enter-user-mode buffer-mode<ret>' -docstring 'buffer...'
map global buffer-mode d ':delete-buffer<ret>' -docstring 'delete buffer'
map global buffer-mode k ':delete-buffer!<ret>' -docstring 'kill buffer'
map global buffer-mode n ':buffer-next<ret>' -docstring 'next buffer'
map global buffer-mode p ':buffer-previous<ret>' -docstring 'previous buffer'
# map global buffer-mode b '<esc>:prompt -buffer-completion buffer: %{ buffer %val{text} }<ret>' -docstring 'switch buffer'
# Comment line
map global normal "#" ":comment-line<ret>"
# File Keybinds
declare-user-mode file-mode
map global user f ':enter-user-mode file-mode<ret>' -docstring 'file...'
# map global file-mode f '<esc>:prompt -shell-script-candidates %{ fd --type f } file: %{ edit %val{text} }<ret>' -docstring "find file"
map global file-mode c ':e ~/.config/kak/kakrc<ret>' -docstring 'open config'
map global file-mode t ':e ~/Documents/Notes/TODO.md<ret>' -docstring 'open todo'
# Search case-insensitive by default
map global normal "/" "/(?Si)"
map global normal "?" "?(?Si)"
map global normal "<a-/>" "<a-/>(?Si)"
map global normal "<a-?>" "<a-?>(?Si)"
# Select inner line
map global normal X x_
# Use tab for autocomplete
# hook global InsertCompletionShow .* %{
# try %{
# execute-keys -draft 'h<a-K>\h<ret>'
# map window insert <tab> <c-n>
# map window insert <s-tab> <c-p>
# hook -once -always window InsertCompletionHide .* %{
# unmap window insert <tab> <c-n>
# unmap window insert <s-tab> <c-p>
# }
# }
# }
# Tab jumps to next snippet placeholder by default in insert mode
map global insert <tab> '<esc>: lsp-snippets-select-next-placeholders<ret>i'
map global insert <s-tab> '<esc>: lsp-snippets-select-next-placeholders<ret>i' # optional reverse
# When completion menu shows, remap tab to cycle completions — but only if not in a snippet
hook global InsertCompletionShow .* %{
try %{
execute-keys -draft 'h<a-K>\h<ret>'
try %{
eval %sh{ [ -n "${kak_opt_lsp_snippets_placeholder_groups}" ] && echo "fail" }
map window insert <tab> <c-n>
map window insert <s-tab> <c-p>
hook -once -always window InsertCompletionHide .* %{
unmap window insert <tab> <c-n>
unmap window insert <s-tab> <c-p>
}
}
}
}
# Map tab and shift-tab to indent and dedent in normal mode
map global normal <tab> '>'
map global normal <s-tab> '<'
# Terminal related bindings
declare-user-mode terminal-mode
map global user t ':enter-user-mode terminal-mode<ret>' -docstring 'terminal...'
map global terminal-mode t ':terminal zsh<ret>' -docstring 'open terminal'
map global terminal-mode s ':tmux-repl-horizontal <ret>' -docstring 'open terminal split (H)'
map global terminal-mode v ':tmux-repl-vertical<ret>' -docstring 'open terminal split (V)'
define-command smart-gh \
-docstring "Smart goto line start." \
%{
set-register c %val{cursor_column}
execute-keys gi
evaluate-commands %sh{
orig_col="${kak_reg_c}"
indent_col="${kak_cursor_column}"
if [ "${orig_col}" -le "${indent_col}" ]; then
echo "execute-keys gh"
fi
}
}
map global goto h <esc>:smart-gh<ret> -docstring 'line begin (smart)'
# Window Management
declare-user-mode window-mode
map global user w ':enter-user-mode window-mode<ret>' -docstring 'window...'
map global window-mode s ':tmux-terminal-horizontal kak -c %val{session}<ret>' -docstring 'open window split (H)'
map global window-mode v ':tmux-terminal-vertical kak -c %val{session}<ret>' -docstring 'open window split (V)'
# -------
# PLUGINS
# -------
# Nanoline is a cleaner alternative to the default modeline
set-option global nanoline_rw_face_dark rgb:11111b,rgb:b4befe
nanoline dark
nanoline-format
# Use auto-pairs
enable-auto-pairs
# Enable Copy-Paste with kakboard
hook global WinCreate .* %{ kakboard-enable }
# Load LSP
eval %sh{kak-lsp}
set-option global modelinefmt "%opt{lsp_modeline} %opt{modelinefmt}"
map global user l ':enter-user-mode lsp<ret>' -docstring 'lsp...'
map global goto d <esc>:lsp-definition<ret> -docstring 'LSP definition'
map global goto r <esc>:lsp-references<ret> -docstring 'LSP references'
map global goto y <esc>:lsp-type-definition<ret> -docstring 'LSP type definition'
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 Module Namespace Struct<ret>' -docstring 'LSP class or module'
map global object d '<a-semicolon>lsp-diagnostic-object error warning<ret>' -docstring 'LSP errors and warnings'
map global object D '<a-semicolon>lsp-diagnostic-object error<ret>' -docstring 'LSP errors'
hook global WinSetOption lsp_code_action_indicator=.* %{
set-option window lsp_code_action_indicator "[A]"
}
hook global WinSetOption lsp_progress_indicator=.* %{
set-option window lsp_progress_indicator "[P]"
}
hook global GlobalSetOption lsp_modeline_message_requests=.* %{
evaluate-commands %sh{
if [ -n "$kak_hook_param_capture_0" ]; then
echo "set-option global lsp_modeline_message_requests '[M]'"
fi
}
}
# Save with formatting with :W
define-command W %{
lsp-formatting-sync
w
}
set-face global InlayDiagnosticHint 'rgb:444444'
# FZF
require-module fzf
set-option global fzf_tmux_popup true
set-option global fzf_tmux_popup_width '80%'
set-option global fzf_default_opts '--color=base16'
set-option global fzf_highlight_command 'bat'
require-module fzf-file
set-option global fzf_file_command 'fd'
require-module fzf-grep
set-option global fzf_grep_command 'rg'
map global file-mode f ':require-module fzf-file; fzf-file<ret>' -docstring 'find file'
map global file-mode p ':require-module fzf-file; fzf-file buffile-dir<ret>' -docstring 'find file at path'
map global file-mode g ':require-module fzf-grep; fzf-grep<ret>' -docstring 'grep files'
map global file-mode d ':require-module fzf-cd; fzf-cd<ret>' -docstring 'change directory'
map global file-mode / ':require-module fzf-search; fzf-buffer-search<ret>' -docstring 'search current file'
map global buffer-mode b ':require-module fzf-buffer; fzf-buffer<ret>' -docstring 'switch buffer'
# map global user F ':fzf-mode<ret>' -docstring 'fzf...'
# Harpoon
harpoon-add-bindings
# Kakpipe
require-module kakpipe
set-option global compile_run_mode 'tmux_horizontal'
declare-user-mode compile-mode
map global user c ':enter-user-mode compile-mode<ret>' -docstring 'compile...'
map global compile-mode c '<esc>:prompt -shell-completion "compile: " %{ evaluate-commands %sh{ echo "compile $kak_text" } }<ret>' -docstring 'compile'
map global compile-mode r ':recompile<ret>' -docstring 'recompile'
# Kakoune Focus
declare-user-mode selection-mode
map global user s ':enter-user-mode selection-mode<ret>' -docstring 'selection...'
map global selection-mode f ':focus-toggle<ret>' -docstring "toggle selections focus"
define-command focus-live-enable %{
focus-selections
hook -group focus window NormalIdle .* %{ focus-extend }
}
define-command focus-live-disable %{
remove-hooks window focus
focus-clear
}
# ---------
# FILETYPES
# ---------
# Lua
hook global BufSetOption filetype=lua %{
set-option buffer lsp_servers %exp{
# Minimal setup for luals (Lua doesn't really work with LSP, I've tried)
[luals]
filetypes = ["lua"]
root_globs = [".git/", ".luarc.json", ".luarc.jsonc", ".editorconfig", ".kakrc"]
command = "lua-language-server"
[luals.settings.Lua]
codeLens.enable = false
completion.autoRequire = false # afaik not supported by kakoune
completion.enable = true
completion.callSnippet = "Replace"
completion.showWord = "Disable"
completion.postfix = "@"
diagnostics.enable = true
diagnostics.disable = [
"lowercase-global",
"spell-check",
]
format.enable = true
hint.enable = true
hint.paramName = "Disable"
hint.paramType = false
hover.enable = true
runtime.path = [
"?.lua",
"?/init.lua",
]
runtime.version = "Lua 5.4"
semantic.enable = false
[luals.settings.Lua.diagnostics.severity]
undefined-field = "Warning"
undefined-global = "Warning"
# [emmylua_ls]
# filetypes = ["lua"]
# root_globs = [".git/", ".luarc.json", ".editorconfig", ".kakrc", ".emmyrc.json"]
# command = "emmylua_ls"
}
}
hook global WinSetOption filetype=lua %{
add-highlighter window/emmylua_direct regex "---\s*(@(?:alias|as|class|enum|generic|return|type|overload))\s+([^\n]*)" 1:attribute 2:type
add-highlighter window/emmylua_labeled regex "---\s*(@(?:alias|cast|field|param))\s+([a-zA-Z0-9_\?]*) ([^\n]*)" 1:attribute 2:variable 3:type
add-highlighter window/emmylua_enum_variant regex '---\s*\|\s*("[^\n]*")' 1:string
}
# Markdown
hook global BufSetOption filetype=markdown %{
set-option buffer lsp_servers %exp{
[zk_lsp]
filetypes = ["markdown"]
root_globs = [".git/", ".zk/", ".kakrc"]
command = "zk"
args = ["lsp"]
[harper]
filetypes = ["markdown"]
root_globs = [".git/", ".zk/", ".kakrc"]
command = "harper-ls"
args = ["--stdio"]
settings_section = "_"
[harper.settings._.harper-ls]
#isolateEnglish = true # Currently very buggy
dialect = "British"
[harper.settings._.harper-ls.markdown]
IgnoreLinkTitle = true }
}
# ----
# MISC
# ----
# TODO: Fix this TODO Highlighter
hook -group todohighlight global BufCreate .* %{
add-highlighter buffer/todo-highlight regex "%opt{comment_line}[ \t]*\b(TODO|FIXME|HACK)\b" 1:default+bu@comment
}
# Enable LSP (Must come just before settings, after everything else lsp)
lsp-enable
lsp-diagnostic-lines-disable global
lsp-inlay-diagnostics-enable global
# lsp-inlay-code-lenses-enable global
lsp-inlay-hints-enable global
set-option global lsp_hover_anchor true
# lsp-auto-hover-enable
lsp-auto-signature-help-enable
|