Add lsp and rc
This commit is contained in:
parent
8e886fd13b
commit
8a19a3d900
9 changed files with 560 additions and 6 deletions
191
packages/common/nki-kakoune/kakrc
Normal file
191
packages/common/nki-kakoune/kakrc
Normal file
|
@ -0,0 +1,191 @@
|
|||
# Enable kak-tree-sitter
|
||||
eval %sh{test -z "$WE_STARTED_KAK" && kak-tree-sitter --kakoune -d --server --init $kak_session}
|
||||
map global normal <c-t> ": enter-user-mode tree-sitter<ret>"
|
||||
# ## Set some color overrides
|
||||
# set global kts_yellow "rgb:e2b75e"
|
||||
# set global kts_teal "rgb:008080"
|
||||
# set global kts_mauve "rgb:c264ff"
|
||||
# set global kts_sky "rgb:6aa622"
|
||||
# Color scheme
|
||||
colorscheme catppuccin-latte
|
||||
set global base "default"
|
||||
|
||||
# Set indentation guides
|
||||
add-highlighter global/indent-guides show-whitespaces -tab " " -spc " " -lf " " -nbsp " "
|
||||
set-face global Whitespace default,default
|
||||
set-face global WhitespaceIndent +d@comment
|
||||
|
||||
# Assistant
|
||||
set global ui_options terminal_assistant=cat
|
||||
|
||||
# Enable line numbers
|
||||
hook global WinCreate .* %{
|
||||
addhl window/number-lines number-lines
|
||||
}
|
||||
|
||||
set global grepcmd "rg --line-number --no-column --no-heading --color=never "
|
||||
|
||||
# Kitty-specific options
|
||||
hook -group windowing global KakBegin .* %{
|
||||
set global kitty_window_type os-window
|
||||
}
|
||||
|
||||
# Comment line and block
|
||||
map global normal <#> ': comment-line<ret>'
|
||||
map global normal <a-#> ': comment-block<ret>'
|
||||
|
||||
# Go to grep-jump
|
||||
map global goto f -docstring "current grep-jump match" '<esc>: grep-jump<ret>'
|
||||
|
||||
# System clipboard interactions
|
||||
hook global RegisterModified '"' %{ nop %sh{
|
||||
printf "%s" "$kak_main_reg_dquote" | pbcopy >/dev/null 2>/dev/null &
|
||||
}}
|
||||
map global user P -docstring "Paste before cursor from clipboard" '! pbpaste -n | cat<ret>'
|
||||
map global user p -docstring "Paste after cursor from clipboard" '<a-!> pbpaste -n | cat<ret>'
|
||||
map global user R -docstring "Replace selection with text from clipboard" '<a-d>! pbpaste -n | cat<ret>'
|
||||
define-command -params 0 -docstring "Copy line down" copyline %{
|
||||
execute-keys -draft 'xy'%val{count}'P'
|
||||
}
|
||||
map global normal <+> -docstring "Copy line down" ': copyline<ret>'
|
||||
define-command -params 0 -docstring "Delete current pair of brackets" delete-current-brackets %{
|
||||
execute-keys 'm<a-:>'
|
||||
execute-keys -draft '<a-S>d'
|
||||
execute-keys 'H'
|
||||
}
|
||||
map global normal D ": delete-current-brackets<ret>"
|
||||
|
||||
# Disable write-to
|
||||
# unalias global w
|
||||
# define-command -params 0 -docstring "Writes the current file" w "write"
|
||||
|
||||
# Tab sizes
|
||||
hook global InsertChar \t %{ exec -draft -itersel h@ }
|
||||
set global tabstop 2
|
||||
set global indentwidth 2
|
||||
|
||||
# Language-specific tabstop with override
|
||||
hook global WinSetOption filetype=(rust) %{
|
||||
set window tabstop 4
|
||||
set window indentwidth 4
|
||||
}
|
||||
|
||||
# Ctrl + a in insert mode = esc
|
||||
map global insert <c-a> '<esc>'
|
||||
|
||||
# Tab completion
|
||||
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 global InsertCompletionHide .* %{
|
||||
unmap window insert <tab> <c-n>
|
||||
unmap window insert <s-tab> <c-p>
|
||||
}
|
||||
|
||||
# <a-a> in Insert mode moves to end of line.
|
||||
map global insert <a-a> '<esc>A'
|
||||
|
||||
hook global WinSetOption filetype=(fsharp) %{
|
||||
set-option window comment_line "//"
|
||||
# Set up formatting
|
||||
# set-option window formatcmd "~/.dotnet/tools/fantomas --stdin --stdout"
|
||||
# hook window -group fsharp-format BufWritePre .* %{ format }
|
||||
}
|
||||
|
||||
hook global WinSetOption filetype=(ocaml) %{
|
||||
unset-option buffer comment_line
|
||||
set-option buffer comment_block_begin "(*"
|
||||
set-option buffer comment_block_end "*)"
|
||||
}
|
||||
|
||||
hook global WinSetOption filetype=(haskell) %{
|
||||
set-option buffer makecmd "cabal build"
|
||||
}
|
||||
|
||||
hook global WinSetOption filetype=(rust) %{
|
||||
set-option buffer makecmd "cargo check"
|
||||
}
|
||||
|
||||
hook global WinSetOption filetype=(scala) %{
|
||||
# Format the document if possible
|
||||
hook -group scala-fmt window BufWritePre .* %{ lsp-formatting-sync }
|
||||
}
|
||||
|
||||
hook global WinSetOption filetype=(typst) %{
|
||||
set-option window comment_line "//"
|
||||
set-option window comment_block_begin "/*"
|
||||
set-option window comment_block_end "*/"
|
||||
|
||||
# borrow markdown's hooks
|
||||
require-module markdown
|
||||
|
||||
hook window ModeChange pop:insert:.* -group markdown-trim-indent markdown-trim-indent
|
||||
hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line
|
||||
hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line
|
||||
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ }
|
||||
}
|
||||
|
||||
define-command -params 0 -docstring "Set up build" scala-build-connect %{
|
||||
lsp-execute-command 'build-connect' '"[]"'
|
||||
}
|
||||
|
||||
define-command -params 0 -docstring "Import build" scala-build-import %{
|
||||
lsp-execute-command 'build-import' '"[]"'
|
||||
}
|
||||
|
||||
def -hidden insert-c-n %{
|
||||
try %{
|
||||
lsp-snippets-select-next-placeholders
|
||||
exec '<a-;>d'
|
||||
} catch %{
|
||||
exec -with-hooks '<c-n>'
|
||||
}
|
||||
}
|
||||
map global insert <c-n> "<a-;>: insert-c-n<ret>"
|
||||
|
||||
# Use C++ for .h headers
|
||||
hook global BufCreate .*[.](h) %{
|
||||
set-option buffer filetype cpp
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.]kakrc %{
|
||||
set-option buffer filetype kak
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.]md %{
|
||||
add-highlighter buffer/ wrap
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.](sc|sbt) %{
|
||||
set-option buffer filetype scala
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.]typ %{
|
||||
set-option buffer filetype typst
|
||||
add-highlighter buffer/ wrap
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.]templ %{
|
||||
set-option buffer filetype templ
|
||||
set-option buffer comment_line "//"
|
||||
}
|
||||
|
||||
hook global BufCreate .*[.]hylo %{
|
||||
set-option buffer filetype hylo
|
||||
set-option buffer comment_line "//"
|
||||
}
|
||||
|
||||
hook global BufOpenFile .* %{
|
||||
modeline-parse
|
||||
}
|
||||
|
||||
map global normal <a-[> ':inc-dec-modify-numbers + %val{count}<ret>'
|
||||
map global normal <a-]> ':inc-dec-modify-numbers - %val{count}<ret>'
|
Loading…
Add table
Add a link
Reference in a new issue