kakrc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. source "%val{config}/plugins/plug.kak/rc/plug.kak"
  2. plug "andreyorst/plug.kak" noload
  3. plug "whereswaldon/shellcheck.kak"
  4. plug "https://gitlab.com/Screwtapello/kakoune-state-save"
  5. plug "andreyorst/fzf.kak" %{
  6. map global normal <c-p> ': fzf-mode<ret>'
  7. } defer fzf %{
  8. }
  9. plug "alexherbo2/prelude.kak"
  10. plug "alexherbo2/auto-pairs.kak" defer auto-pairs %{
  11. hook global WinCreate .* %{
  12. auto-pairs-enable
  13. }
  14. } demand
  15. plug "TeddyDD/kakoune-edit-or-dir" %{
  16. unalias global e edit
  17. alias global e edit-or-dir
  18. }
  19. plug "andreyorst/smarttab.kak" %{
  20. hook global WinSetOption filetype=python expandtab
  21. hook global BufCreate .* %{
  22. set-option buffer tabstop 2
  23. set-option buffer indentwidth 2
  24. smarttab
  25. }
  26. }
  27. plug "lePerdu/kakboard" %{
  28. hook global WinCreate .* %{ kakboard-enable }
  29. }
  30. plug "dmerejkowsky/kak-spell" config %{
  31. declare-user-mode kak-spell
  32. map global user s ': enter-user-mode -lock kak-spell<ret>' -docstring 'enter spell user mode'
  33. map global kak-spell a ': kak-spell-add<ret>' -docstring 'add the selection to the user dict'
  34. map global kak-spell d ': kak-spell-disable<ret>' -docstring 'clear spelling highlighters'
  35. map global kak-spell e ': kak-spell-enable en_GB<ret> :kak-spell <ret>' -docstring 'enable spell check in English'
  36. map global kak-spell f ': kak-spell-enable pl_PL<ret> :kak-spell <ret>' -docstring 'run spell check in Polish'
  37. map global kak-spell l ': kak-spell-list <ret>' -docstring 'list spelling errors in a buffer'
  38. map global kak-spell n ': kak-spell-next<ret>' -docstring 'go to next spell error'
  39. map global kak-spell p ': kak-spell-previous<ret>' -docstring 'go to next spell error'
  40. map global kak-spell r ': kak-spell-replace<ret>' -docstring 'suggest a list of replacements'
  41. map global kak-spell x ': kak-spell-remove<ret>' -docstring 'remove the selection from the user dict'
  42. }
  43. evaluate-commands %sh{
  44. if command -v kak-lsp > /dev/null 2>&1
  45. then
  46. kak-lsp --kakoune -s $kak_session
  47. echo "lsp-auto-hover-insert-mode-enable"
  48. echo "map global normal <c-a-l> ':lsp-formatting<ret>'"
  49. echo "map global normal <c-a-d> ':lsp-hover<ret>'"
  50. echo "map global normal <c-a-s> ':lsp-document-symbol<ret>'"
  51. echo "map global normal <c-a-r> ':lsp-rename-prompt<ret>'"
  52. echo "map global normal '#' ':lsp-highlight-references<ret>'"
  53. echo "set-option global lsp_hover_max_lines 3"
  54. echo "hook global WinSetOption filetype=(c|go) %{ \
  55. lsp-enable-window \
  56. }"
  57. echo "set-face global Reference blue,default+i"
  58. echo "set-face global DiagnosticWarning yellow+uf"
  59. echo "set-face global DiagnosticError red+uf"
  60. echo "map global normal <c-r> ':lsp-find-error --include-warnings<ret>' -docstring 'go to next error or warning'"
  61. echo "hook global KakEnd .* lsp-exit"
  62. fi
  63. }
  64. add-highlighter global/ number-lines -hlcursor
  65. hook global WinSetOption filetype=(c|go|kak|python) %{
  66. add-highlighter global/ column 80 default,rgb:00567e
  67. add-highlighter global/ column 120 default,rgb:7e2d2b
  68. add-highlighter global/ regex \b(TODO|todo|FIXME|fixme|XXX|xxx|NOTE|note)\b([^\n]*) 1:yellow+fbi 2:default+i
  69. }
  70. add-highlighter global/ show-matching
  71. add-highlighter global/ wrap -word -indent -marker 
  72. set-face global PrimaryCursor default+rb
  73. set-face global PrimaryCursorEol default,blue
  74. set-face global PrimarySelection default+rb
  75. set-face global SecondaryCursor default+r
  76. set-face global SecondaryCursorEol default,cyan
  77. set-face global SecondarySelection default+r
  78. set-face global Error black,red
  79. set-face global MatchingChar blue,default+b
  80. set-face global MenuBackground blue,black
  81. set-face global MenuForeground black,blue
  82. set-face global Information black,red
  83. set-face global StatusLineMode rgb:c0bcc0,rgb:1b2022
  84. set-face global StatusLineInfo rgb:c0bcc0,rgb:1b2022
  85. set-face global StatusLineValue blue,cyan
  86. # todo hook global ModeChange ".*:normal" %{ face ... }
  87. # todo hook global ModeChange ".*:insert" %{ face ... }
  88. declare-option str spell
  89. set-option global ui_options ncurses_assistant=cat
  90. define-command gohome %{
  91. eval -itersel %{
  92. try %{
  93. exec -draft %{ <a-h><a-k>\A\h+.\z<ret> }
  94. exec gh
  95. } catch %{
  96. exec gi
  97. }
  98. }
  99. }
  100. map global normal <c-a-c> ':comment-line<ret>'
  101. map global normal <c-a-t> 'be :ctags-search<ret>'
  102. map global goto t '\:buffer-next<ret>' -docstring 'next buffer'
  103. map global normal <home> :gohome<ret>
  104. map global normal <end> gl
  105. hook global NormalIdle .* %{ evaluate-commands %sh{
  106. fmt=""
  107. branch=$(git branch --show-current 2>/dev/null)
  108. if [ "$branch" ]
  109. then
  110. fmt="$fmt{rgb:1c9867,default}{rgb:1b2022,rgb:1c9867} $branch {rgb:892b30,rgb:1c9867}"
  111. else
  112. fmt="$fmt{rgb:892b30,default}"
  113. fi
  114. case "${kak_opt_filetype}" in
  115. sh) filetype=" " ;;
  116. c) filetype=" ﭰ" ;;
  117. go) filetype=" ﳑ" ;;
  118. plain) filetype=" " ;;
  119. asciidoc) filetype=" " ;;
  120. html) filetype=" " ;;
  121. css) filetype=" " ;;
  122. git*) filetype=" " ;;
  123. "") filetype="" ;;
  124. *) filetype=" [${kak_opt_filetype}]" ;;
  125. esac
  126. if [ -f ${kak_bufname} ]
  127. then
  128. lines=$(wc -l ${kak_bufname} | awk '{print $1}')
  129. position=$(( ${kak_cursor_line} * 100 / $lines))
  130. position=" ($position%%) "
  131. else
  132. position=" "
  133. fi
  134. # todo add spell
  135. fmt="$fmt{rgb:c0bcc0,rgb:892b30} %val{bufname}$filetype {rgb:db9d3b,rgb:892b30}{rgb:1b2022,rgb:db9d3b} %val{cursor_line}:%val{cursor_char_column}$position{rgb:1b2022,rgb:db9d3b}{rgb:c0bcc0,rgb:1b2022} {{context_info}} {{mode_info}} {rgb:317b9f,rgb:1b2022}{rgb:1b2022,rgb:317b9f} %val{session} "
  136. echo "set-option buffer modelinefmt '$fmt'"
  137. }
  138. }
  139. hook global WinCreate [^*].* %{
  140. editorconfig-load
  141. evaluate-commands %sh{
  142. if git status >/dev/null 2>&1
  143. then
  144. echo "git show-diff"
  145. fi
  146. }
  147. }
  148. hook global BufWritePost .* %{ evaluate-commands %sh{
  149. if git status >/dev/null 2>&1
  150. then
  151. echo "git show-diff"
  152. fi
  153. if [ -n "$kak_opt_lintcmd" ]; then
  154. echo 'lint'
  155. fi
  156. }
  157. }