From: Robin Krens Date: Thu, 2 Jan 2025 14:32:54 +0000 (+0100) Subject: use local vars X-Git-Url: https://robinkrens.nl/gitweb/?a=commitdiff_plain;h=b568acb9d5eebaa4533950a49de83a8608b64f4c;p=vim-claudy use local vars --- diff --git a/claudy.vim b/claudy.vim index 2b8fe1e..ab39d57 100644 --- a/claudy.vim +++ b/claudy.vim @@ -52,27 +52,30 @@ function! ClaudyRefactor(user_prompt) let l:start_line = line("'<") let l:end_line = line("'>") - let selected_text = a:user_prompt . shellescape(join(getline(l:start_line, l:end_line))) + let l:selected_text = a:user_prompt . shellescape(join(getline(l:start_line, l:end_line))) - let system_prompt = "reply with one C function (do not implement other functions) code should be able to copied right into an editor, no explaining text" + let l:system_prompt = "detect programming language, reply with one function (do not implement other functions) code should be able to copied right into an editor, no explaining text, start always with ```c and end with ```" " Prepare the JSON payload - let json_data = { + let l:json_data = { \ 'model': 'claude-3-5-sonnet-20241022', \ 'max_tokens': 1024, - \ 'system': system_prompt, + \ 'system': l:system_prompt, \ 'messages': [ \ { \ 'role': 'user', - \ 'content': selected_text + \ 'content': l:selected_text \ } \ ] \ } - let refactored_code = ClaudyRequest(json_data) + let l:refactored_code = ClaudyRequest(l:json_data) vnew - put =refactored_code + setlocal syntax=c + setlocal buftype=nofile + put =l:refactored_code endfunction vnoremap c :call ClaudyRefactor() vnoremap i :call ClaudyImplement() +vnoremap b :call ClaudyTest()