4 ms·
Is the extension you wrote public?
by xoranth 2y ago
Is the extension you wrote public?
- thot_experiment 2y agono but it's super super janky and simple hodgepode of stack overflow and gemma:27b generated code, i'll just put it in the comment here, you just need CURL on your path and vim that's compiled with some specific flag function! GetSurroundingLines(n) let l:current_line = line('.') let l:start_line = max([1, l:current_line - a:n]) let l:end_line = min([line('$'), l:current_line + a:n]) let l:lines_before = getline(l:start_line, l:current_line - 1) let l:lines_after = getline(l:current_line + 1, l:end_line) return [l:lines_before, l:lines_after] endfunction function! AIComplete() let l:n = 256 let [l:lines_before, l:lines_after] = GetSurroundingLines(l:n) let l:prompt = '<PRE>' . join(l:lines_before, "\n") . ' <SUF>' . join(l:lines_after, "\n") . ' <MID>' let l:json_data = json_encode({ \ 'model': 'codellama:13b-code-q6_K', \ 'keep_alive': '30m', \ 'stream': v:false, \ 'prompt': l:prompt \ }) let l:response = system('curl -s -X POST -H "Content-Type: application/json" -d ' . shellescape(l:json_data) . ' http://localhost:11434/api/generate') let l:completion = json_decode(l:response)['response'] let l:paste_mode = &paste set paste execute "normal! a" . l:completion let &paste = l:paste_mode endfunction nnoremap <leader>c :call AIComplete()<CR>
- xoranth 2y agoThanks!