Kakoune-LLM-Erweiterungen
This commit is contained in:
@@ -6,7 +6,8 @@ add-highlighter global/ number-lines -hlcursor
|
|||||||
add-highlighter global/ wrap -word -indent -marker ">>>"
|
add-highlighter global/ wrap -word -indent -marker ">>>"
|
||||||
add-highlighter global/ show-whitespaces
|
add-highlighter global/ show-whitespaces
|
||||||
|
|
||||||
set-option global ui_options terminal_status_on_top=true
|
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 tabstop 4
|
||||||
set-option global indentwidth 4
|
set-option global indentwidth 4
|
||||||
@@ -27,24 +28,6 @@ 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-up> '|echo "$(($kak_selection + 1))"<ret>'
|
||||||
map global normal <C-down> '|echo "$(($kak_selection - 1))"<ret>'
|
map global normal <C-down> '|echo "$(($kak_selection - 1))"<ret>'
|
||||||
|
|
||||||
# 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 <ret> <c-m>
|
|
||||||
# map window insert <s-tab> <c-p>
|
|
||||||
# hook -once -always window InsertCompletionHide .* %{
|
|
||||||
# unmap window insert <tab> <c-n>
|
|
||||||
# unmap window insert <ret> <c-m>
|
|
||||||
# unmap window insert <s-tab> <c-p>
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
|
|
||||||
# Convert spaces to tabs
|
# Convert spaces to tabs
|
||||||
hook global BufWritePre .* %{
|
hook global BufWritePre .* %{
|
||||||
try %{ execute-keys -draft '%@' }
|
try %{ execute-keys -draft '%@' }
|
||||||
@@ -54,16 +37,20 @@ hook global BufWritePre .* %{
|
|||||||
# echo %sh{ sassc main.scss > main.css }
|
# 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}
|
eval %sh{kak-lsp}
|
||||||
lsp-enable
|
lsp-enable
|
||||||
|
|
||||||
lsp-inlay-diagnostics-enable global
|
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'
|
||||||
|
|
||||||
declare-option str fim_tmp "/tmp/kak-fim.buf"
|
|
||||||
|
|
||||||
define-command fim-complete -docstring "FIM-Completion am Cursor (Mistral)" %{
|
# LLM-Integration (FIM + smartcat)
|
||||||
write -force %opt{fim_tmp}
|
source "%val{config}/llm.kak"
|
||||||
execute-keys "!python3 %val{config}/mistral-fim.py %opt{fim_tmp} %val{cursor_line} %val{cursor_column}<ret>"
|
|
||||||
}
|
|
||||||
map global user f ': fim-complete<ret>' -docstring 'FIM complete'
|
|
||||||
|
|||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
# LLM-Integration (Mistral FIM + smartcat)
|
||||||
|
|
||||||
|
declare-option str llm_ctx "/tmp/kak-fim.buf"
|
||||||
|
declare-option str llm_gen "/tmp/kak-gen.out"
|
||||||
|
|
||||||
|
define-command fim-complete -docstring "FIM-Completion am Cursor (Mistral)" %{
|
||||||
|
write -force %opt{llm_ctx}
|
||||||
|
execute-keys "!python3 %val{config}/mistral-fim.py %opt{llm_ctx} %val{cursor_line} %val{cursor_column}<ret>"
|
||||||
|
}
|
||||||
|
map global user f ': fim-complete<ret>' -docstring 'FIM complete'
|
||||||
|
|
||||||
|
# Codeblock aus Anweisung generieren und am Cursor einfügen
|
||||||
|
define-command -params 1 gen -docstring 'LLM: Codeblock generieren & einfügen' %{
|
||||||
|
write -force %opt{llm_ctx}
|
||||||
|
nop %sh{
|
||||||
|
{ printf 'Anweisung: %s\n\nVorhandener Code als Kontext:\n' "$1"
|
||||||
|
cat "$kak_opt_llm_ctx"; } | sc default > "$kak_opt_llm_gen"
|
||||||
|
}
|
||||||
|
execute-keys "!cat %opt{llm_gen}<ret>"
|
||||||
|
}
|
||||||
|
map global user G ': gen ""<left>' -docstring 'Codeblock generieren'
|
||||||
|
|
||||||
|
# Selektion durch generierten Code ersetzen
|
||||||
|
define-command -params 1 gen-sel -docstring 'LLM: Selektion neu generieren' %{
|
||||||
|
nop %sh{
|
||||||
|
printf 'Anweisung: %s\n\nCode:\n%s' "$1" "$kak_selection" \
|
||||||
|
| sc default > "$kak_opt_llm_gen"
|
||||||
|
}
|
||||||
|
execute-keys "|cat %opt{llm_gen}<ret>"
|
||||||
|
}
|
||||||
|
map global user g ': gen-sel ""<left>' -docstring 'Selektion neu generieren'
|
||||||
|
|
||||||
|
|
||||||
|
# Frage zum GANZEN Buffer (z.B. "welche imports fehlen?")
|
||||||
|
define-command -params 1 ask -docstring 'LLM-Frage zum Buffer' %{
|
||||||
|
write -force %opt{llm_ctx}
|
||||||
|
evaluate-commands %sh{
|
||||||
|
ans=$( { printf 'Frage: %s\n\nCode:\n' "$1"; cat "$kak_opt_llm_ctx"; } \
|
||||||
|
| sc ask | sed "s/'/''/g")
|
||||||
|
printf "info -title 'Le Chat' '%s'" "$ans"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map global user A ': ask ""<left>' -docstring 'Ask about the buffer'
|
||||||
|
|
||||||
|
# Frage zur SELEKTION (vorher Region markieren)
|
||||||
|
define-command -params 1 ask-sel -docstring 'LLM-Frage zur Selektion' %{
|
||||||
|
evaluate-commands %sh{
|
||||||
|
ans=$(printf 'Frage: %s\n\nCode:\n%s' "$1" "$kak_selection" \
|
||||||
|
| sc ask | sed "s/'/''/g")
|
||||||
|
printf "info -title 'Le Chat' '%s'" "$ans"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map global user a ': ask-sel ""<left>' -docstring 'Ask about selection'
|
||||||
Reference in New Issue
Block a user