105 lines
4.1 KiB
Plaintext
105 lines
4.1 KiB
Plaintext
# Load plug.kak
|
|
source "%val{config}/plugins/plug.kak/rc/plug.kak"
|
|
plug "andreyorst/plug.kak" noload
|
|
# plug kakoune-snippets
|
|
plug "occivink/kakoune-snippets"
|
|
plug "occivink/kakoune-phantom-selection" config %{
|
|
map global user f ": phantom-selection-add-selection<ret>"
|
|
map global user F ": phantom-selection-select-all; phantom-selection-clear<ret>"
|
|
map global user <a-f> ": phantom-selection-iterate-next<ret>"
|
|
map global user <a-F> ": phantom-selection-iterate-prev<ret>"
|
|
|
|
# this would be nice, but currrently doesn't work
|
|
# see https://github.com/mawww/kakoune/issues/1916
|
|
#map global insert <a-f> "<a-;>: phantom-selection-iterate-next<ret>"
|
|
#map global insert <a-F> "<a-;>: phantom-selection-iterate-prev<ret>"
|
|
# so instead, have an approximate version that uses 'i'
|
|
map global insert <a-f> "<esc>: phantom-selection-iterate-next<ret>i"
|
|
map global insert <a-F> "<esc>: phantom-selection-iterate-prev<ret>i"
|
|
}
|
|
# plug collection of snippets
|
|
plug "andreyorst/kakoune-snippet-collection"
|
|
# plug auto-pairs
|
|
plug "alexherbo2/auto-pairs.kak"
|
|
# plug kak-lsp
|
|
plug "kak-lsp/kak-lsp" do %{
|
|
cargo build --release --locked
|
|
cargo install --force --path .
|
|
} config %{
|
|
|
|
# uncomment to enable debugging
|
|
eval %sh{echo ${kak_opt_lsp_cmd} >> /tmp/kak-lsp.log}
|
|
set global lsp_cmd "kak-lsp -s %val{session} -vvv --log /tmp/kak-lsp.log"
|
|
|
|
# this is not necessary; the `lsp-enable-window` will take care of it
|
|
# eval %sh{${kak_opt_lsp_cmd} --kakoune -s $kak_session}
|
|
|
|
set global lsp_diagnostic_line_error_sign '║'
|
|
set global lsp_diagnostic_line_warning_sign '┊'
|
|
|
|
define-command ne -docstring 'go to next error/warning from lsp' %{ lsp-find-error --include-warnings }
|
|
define-command pe -docstring 'go to previous error/warning from lsp' %{ lsp-find-error --previous --include-warnings }
|
|
define-command ee -docstring 'go to current error/warning from lsp' %{ lsp-find-error --include-warnings; lsp-find-error --previous --include-warnings }
|
|
|
|
define-command lsp-restart -docstring 'restart lsp server' %{ lsp-stop; lsp-start }
|
|
hook global WinSetOption filetype=(c|cpp|sh|python|go|java) %{
|
|
set-option window lsp_auto_highlight_references true
|
|
set-option window lsp_hover_anchor false
|
|
lsp-auto-hover-enable
|
|
echo -debug "Enabling LSP for filtetype %opt{filetype}"
|
|
lsp-enable-window
|
|
}
|
|
|
|
hook global KakEnd .* lsp-exit
|
|
}
|
|
# Substitute c-n with tab
|
|
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 .* %{
|
|
map window insert <tab> <tab>
|
|
map window insert <s-tab> <s-tab>
|
|
}
|
|
}
|
|
}
|
|
# enable auto pair closing
|
|
enable-auto-pairs
|
|
# yaml linter
|
|
hook global WinSetOption filetype=yaml %{
|
|
# set-option window lintcmd "yamllint -f parsable"
|
|
set-option window lintcmd %{
|
|
run() {
|
|
# change [message-type] to message-type:
|
|
yamllint -f parsable "$1" | sed 's/ \[\(.*\)\] / \1: /'
|
|
} && run }
|
|
}
|
|
# yaml formatter
|
|
hook global WinSetOption filetype=yaml %{
|
|
set window formatcmd 'prettier --parser yaml'
|
|
}
|
|
# C linter
|
|
hook global WinSetOption filetype=c %{
|
|
set-option window lintcmd "cppcheck --language=c --enable=warning,style,information --template='{file}:{line}:{column}: {severity}: {message}' --suppress='*:*.h' 2>&1"
|
|
}
|
|
# C formatter
|
|
hook global BufSetOption filetype=c %{
|
|
set-option buffer formatcmd 'astyle'
|
|
}
|
|
|
|
set global indentwidth 4
|
|
set global tabstop 4
|
|
add-highlighter global/ number-lines
|
|
add-highlighter global/ wrap
|
|
|
|
# system clipboard usermode
|
|
map global user y '<a-|>xclip -in -selection clipboard >&- 2>&-<ret>' \
|
|
-docstring 'Copy selected text to system clipboard'
|
|
map global user P '!xclip -out -selection clipboard<ret>' \
|
|
-docstring 'Paste system clipboard before'
|
|
map global user p '<a-!>xclip -out -selection clipboard<ret>' \
|
|
-docstring 'Paste system clipboard after'
|
|
map global user R '|xclip -out -selection clipboard<ret>' \
|
|
-docstring 'Replace selection from system clipboard'
|