colorscheme mygruvbox
add-highlighter global/ number-lines -hlcursor

# Highlight trailing whitespace
# Softwrap long lines
add-highlighter global/ wrap -word -indent -marker ">>>"
add-highlighter global/ show-whitespaces

set-option -add global ui_options terminal_status_on_top=true
set-option -add global ui_options terminal_assistant=cat

set-option global tabstop 4
set-option global indentwidth 4
set-option global scrolloff 1,3

# Clipboard management mappings
map -docstring "yank the selection into the clipboard" global user y "<a-|> wl-copy<ret>"
map -docstring "paste the clipboard" global user p "<a-!> wl-paste<ret>"

map -docstring "Show filetype" global user t ': echo %opt{filetype}<ret>'
map -docstring "Open file" global user o ': tmux-repl-vertical "echo ""evaluate-commands -client %val{client} e $(fzf)"" | kak -p %val{session}"<ret>'
map -docstring "Zeile auskommentieren" global normal <C-l> ":comment-line<ret>"
map -docstring "Speichern" global normal <C-s> ":w<ret>"
map -docstring "Beenden" global normal <C-q> ":q<ret>"
map -docstring "Cursor nach oben erweitern" global normal <C-k> "<a-C><ret>"
map -docstring "Cursor nach unten erweitern" global normal <C-j> "<C><ret>"

map global normal <C-up> '|echo "$(($kak_selection + 1))"<ret>'
map global normal <C-down> '|echo "$(($kak_selection - 1))"<ret>'

#   Convert spaces to   tabs
hook global BufWritePre .* %{
    try %{ execute-keys -draft '%@' }
}

# hook global BufWritePost .* %{
#     echo %sh{ sassc main.scss > main.css }
# }


eval %sh{kak-debug init --session $kak_session}
map global user d ':enter-user-mode dap<ret>' -docstring 'DAP mode'

eval %sh{kak-lsp}
lsp-enable

lsp-inlay-diagnostics-enable global

# gd -> zur Definition springen
map global goto d '<esc>: lsp-definition<ret>' -docstring 'definition'
# gr -> Referenzen (Aufrufstellen) auflisten
map global goto r '<esc>: lsp-references<ret>' -docstring 'references'


# LLM-Integration (FIM + smartcat)
source "%val{config}/llm.kak"
