- Add and configure Gnuplot - Add agenda shortcut to kakoune - Add programming support for Go, Java, Fennel and Python - Add Lux package manager for lua
318 lines
10 KiB
Kakoune
318 lines
10 KiB
Kakoune
|
|
# ~~~~~~~
|
|
# OPTIONS
|
|
# ~~~~~~~
|
|
|
|
# Set Colorscheme to nix
|
|
colorscheme nix-colorscheme
|
|
|
|
# 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
|
|
|
|
# Don't show changelog at startup
|
|
set-option global startup_info_version 9999
|
|
|
|
# Add scroll margin
|
|
set-option global scrolloff 5,5
|
|
|
|
# Use ripgrep instead of grep
|
|
require-module 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 completions (reduce completer functions to just filenames)
|
|
set-option global completers filename
|
|
|
|
# ~~~~~~~
|
|
# KEYBIND
|
|
# ~~~~~~~
|
|
|
|
# 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 ':buffer ' -docstring 'buffer switch'
|
|
|
|
# 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 p '<esc>:prompt -shell-script-candidates %{ fd --type f . "$(dirname "$kak_buffile")" } file: %{ edit %val{text} }<ret>' -docstring 'find file from buffer'
|
|
map global file-mode g ':grep -i ' -docstring 'grep files'
|
|
|
|
map global file-mode c ':e ~/.config/home-manager/config/kakoune/config.kak<ret>' -docstring 'open config'
|
|
map global file-mode t ':e ~/Documents/Notes/TODO.md<ret>' -docstring 'open todo'
|
|
map global file-mode a ':e ~/Documents/Notes/Agenda.md<ret>' -docstring 'open todo'
|
|
map global file-mode n ':e ~/.config/home-manager/home.nix' -docstring 'open nix'
|
|
|
|
# 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_
|
|
|
|
# Jump to next snippet entry in insert mode
|
|
map global insert <c-tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>c-tab> }<ret>' -docstring 'Select next snippet placeholder'
|
|
|
|
# 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>
|
|
# }
|
|
# }
|
|
# }
|
|
# }
|
|
|
|
hook global InsertCompletionShow .* %{
|
|
try %{
|
|
# this command temporarily removes cursors preceded by whitespace;
|
|
# if there are no cursors left, it raises an error, does not
|
|
# continue to execute the mapping commands, and the error is eaten
|
|
# by the `try` command so no warning appears.
|
|
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>
|
|
}
|
|
}
|
|
}
|
|
|
|
# Map tab and shift-tab to indent and dedent in normal mode
|
|
map global normal <tab> '>'
|
|
map global normal <s-tab> '<'
|
|
|
|
# Go to start of line intelligently based on indentation
|
|
define-command smart-gh -docstring 'smart goto line start' \
|
|
%{
|
|
set-register c %val{cursor_column}
|
|
execute-keys gi
|
|
evaluate-commands %sh{
|
|
origin='${kak_reg_c}'
|
|
indent='${kak_cursor_column}'
|
|
if [ '${origin}' -le '${indent}' ]; 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 c ':kitty-terminal-window kak -c %val{session}<ret>' -docstring 'create new window'
|
|
map global window-mode t ':kitty-terminal-window %opt{shellpath}<ret>' -docstring 'create terminal window'
|
|
|
|
# Selection binds
|
|
declare-user-mode select-mode
|
|
map global user s ':enter-user-mode select-mode<ret>' -docstring 'select...'
|
|
map global select-mode i '<a-i>' -docstring 'select inside object'
|
|
map global select-mode a '<a-a>' -docstring 'select around object'
|
|
|
|
# Tab Indenting
|
|
hook global WinSetOption filetype=(?!makefile).* %{
|
|
map buffer insert <tab> '<a-;><a-gt>'
|
|
map buffer insert <s-tab> '<a-;><a-lt>'
|
|
}
|
|
|
|
# ~~~
|
|
# 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
|
|
}
|
|
|
|
# LSP language configs
|
|
# 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
|
|
}
|
|
|
|
# Typst
|
|
hook global BufSetOption filetype=typst %{
|
|
set-option buffer lsp_servers %exp{
|
|
[tinymist]
|
|
filetypes = ["typst"]
|
|
root_globs = ["*.typ"]
|
|
command = "tinymist"
|
|
[tinymist.settings]
|
|
exportPdf = "onType"
|
|
outputPath = "$root/target/$dir/$name"
|
|
[harper]
|
|
filetypes = ["typst"]
|
|
root_globs = ["*.typst"]
|
|
command = "harper-ls"
|
|
args = ["--stdio"]
|
|
settings_section = "_"
|
|
[harper.settings._.harper-ls]
|
|
#isolateEnglish = true # Currently very buggy
|
|
dialect = "British"
|
|
}
|
|
}
|
|
|
|
# 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
|
|
}
|
|
}
|
|
|
|
hook global BufSetOption filetype=fennel %{
|
|
set-option buffer lsp_servers %exp{
|
|
[fennel-ls]
|
|
filetypes = ["fennel"]
|
|
root_globs = [".git/", "flsproject.fnl", ".editorconfig", ".kakrc"]
|
|
command = "fennel-ls"
|
|
}
|
|
}
|
|
|
|
hook global BufSetOption filetype=python %{
|
|
set-option buffer lsp_servers %exp{
|
|
[basedpyright]
|
|
filetypes = ["python"]
|
|
root_globs = [".git/", "requirements.txt", ".editorconfig", ".kakrc"]
|
|
command = "basedpyright-langserver"
|
|
args = ["--stdio"]
|
|
}
|
|
}
|
|
|
|
# Enable LSP (Must come just before settings, after everything else lsp)
|
|
lsp-enable
|
|
|
|
# LSP Settings
|
|
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
|