Compare commits

...

7 Commits

3 changed files with 90 additions and 3 deletions

1
autoload/default Symbolic link
View File

@ -0,0 +1 @@
/usr/share/kak/autoload

View File

@ -0,0 +1,34 @@
hook global BufSetOption filetype=go %{
set buffer snippets %opt{snippets} # keep global snippets (if any)
# Main structure of a go file
set -add buffer snippets 'init-structure' 'inist' \
%{ phantom-selection-clear ; snippets-insert %{package main
import(${})
func main() {${}}
}; phantom-selection-add-selection ; phantom-selection-iterate-next }
# Basic read file and populate array
set -add buffer snippets 'read-populate' 'rbufpop' \
%{ phantom-selection-clear ; snippets-insert %{file, err := os.Open("${}")
check(err)
defer file.Close()
${} := make([]string, 0)
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(${}, scanner.Text())
}
}; phantom-selection-add-selection ; phantom-selection-iterate-next }
}
# With phantom
#set -add buffer snippets 'name' 'short' \
# %{ phantom-selection-clear ; snippets-insert %{snippet-here
#}; phantom-selection-add-selection ; phantom-selection-iterate-next }
#
# Without phantom
#set -add buffer snippets 'name' 'short' %{ snippets-insert %snippet-here{
#}}

58
kakrc
View File

@ -1,6 +1,27 @@
# Load plug.kak
source "%val{config}/plugins/plug.kak/rc/plug.kak"
plug "alexherbo2/auto-pairs.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
@ -8,8 +29,8 @@ plug "kak-lsp/kak-lsp" do %{
} 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"
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}
@ -22,7 +43,7 @@ plug "kak-lsp/kak-lsp" do %{
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) %{
hook global WinSetOption filetype=(c|cpp|sh|cc|rust|javascript|typescript|go|python|java) %{
set-option window lsp_auto_highlight_references true
set-option window lsp_hover_anchor false
lsp-auto-hover-enable
@ -30,8 +51,30 @@ plug "kak-lsp/kak-lsp" do %{
lsp-enable-window
}
hook global WinSetOption filetype=(rust) %{
set window lsp_server_configuration rust.clippy_preference="on"
}
hook global WinSetOption filetype=rust %{
hook window BufWritePre .* %{
evaluate-commands %sh{
test -f rustfmt.toml && printf lsp-formatting-sync
}
}
}
map global user l %{:enter-user-mode lsp<ret>} -docstring "LSP mode"
map global insert <a-q> '<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 e '<a-semicolon>lsp-object Function Method<ret>' -docstring 'LSP function or method'
map global object k '<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'
hook global KakEnd .* lsp-exit
}
define-command ide %{ tmux-terminal-horizontal "KAK_SESSION=%val{session} KAK_CLIENT=%val{client} nnn" }
# Substitute c-n with tab
hook global InsertCompletionShow .* %{
try %{
@ -73,6 +116,15 @@ set global tabstop 4
add-highlighter global/ number-lines
add-highlighter global/ wrap
plug "andreyorst/kaktree" config %{
hook global WinSetOption filetype=kaktree %{
remove-highlighter buffer/numbers
remove-highlighter buffer/matching
remove-highlighter buffer/wrap
remove-highlighter buffer/show-whitespaces
}
kaktree-enable
}
# system clipboard usermode
map global user y '<a-|>xclip -in -selection clipboard >&- 2>&-<ret>' \
-docstring 'Copy selected text to system clipboard'