Leverage local LLM via Vim to boost bug breading within your code
- ⬆️ Top of Document
- 🏗️ Requirements
- ⚡ Quick Start
- 🧰 Usage
- 🗒 Notes
- 📈 Contributing
- 📇 Attribution
- ⚖️ Licensing
This repository requires the Vim text editor to be installed the
source code is available on GitHub -- vim/vim
, and most GNU
Linux package managers are able to install Vim directly, eg...
- Arch based Operating Systems
sudo packman -Syy sudo packman -S vim
- Debian derived Distributions
sudo apt-get update sudo apt-get install vim
... Additionally for local LLM interactions this plugin expects
ollama to be installed and running, as well
as Python run-time to facilitate
scripts/proompter-channel-proxy.py
service.
- Vim Doc for help from doc-comments
git clone https://github.com/vim-utilities/vimdoc pushd vimdoc python setup.py config python setup.py build pipx install . popd
Execute with
vimdoc .
Note; until certain bugs are fixed upstream it is necessary to use the patched version of
vimdoc
which handles longer lines, and Vim 8 parameters a bit more correctly. - Vader for testing code
call plug#begin('~/.vim/plugged') Plug 'junegunn/vader.vim' call plug#end()
Execute with
scripts/vader-run-tests.sh --cicd --test units
systemd-analyze --user unit-paths | grep $HOME
Example output
~/.config/systemd/user.control
~/.config/systemd/user
~/.config/kdedefaults/systemd/user
~/.local/share/systemd/user
Plug 'vim-utilities/proompter' {
\ 'do': 'scripts/proompter-channel-proxy.py --install-systemd "' . $HOME . '/.local/share/systemd/user/proompter-channel-proxy.service"'
\ }
Note: if installing manually, such as cloning via Git, then you may invoke the proxy installation directly;
scripts/proompter-channel-proxy.py --install-systemd "$HOME/.local/share/systemd/user/proompter-channel-proxy.service"
Dev tip: if modifying the installed SystemD configuration you may pop warnings, about changes detected on disk here's how to fix that;
systemctl --user daemon-reload
systemctl is-active --quiet ollama.service || {
sudo systemctl restart ollama.service
}
systemctl --user is-active --quiet proompter-channel-proxy.service || {
systemctl --user proompter-channel-proxy.service
}
Currently no Motions or Commands are provided, and such customization is an
exercise for each entity using this plugin. Instead there are a kit of helper
functions, and some examples/
, for creating your own Vim/LLM integration
experience!
Tip: find example callback functions within;
autoload/proompter/callback/channel.vim
autoload/proompter/callback/prompt.vim
function! MyProompterLineStreamCallback(channel_response, api_response, ...) abort
let l:http_response = proompter#parse#HTTPResponse(a:api_response)
for l:http_body_data in l:http_response.body
let l:api_data = proompter#parse#MessageOrResponseFromAPI(l:http_body_data)
echoe 'l:api_data ->' l:api_data
endfor
endfunction
let g:proompter = {
\ 'select': {
\ 'model_name': 'codellama',
\ },
\ 'api': {
\ 'url': 'http://127.0.0.1:11434/api/generate',
\ },
\ 'channel': {
\ 'address': '127.0.0.1:11435',
\ 'options': {
\ 'mode': 'raw',
\ 'callback': function('MyProompterLineStreamCallback'),
\ },
\ },
\ 'models': {
\ 'codellama': {
\ 'data': {
\ 'prompt': '<<SYS>>Pretend you are a senior software engineer<</SYS>>',
\ 'raw': v:false,
\ 'stream': v:true,
\ },
\ },
\ },
\ }
Tip: check
:help proompter-configuration
for some more advanced example(s)
This repository may not be feature complete and/or fully functional, Pull Requests that add features or fix bugs are certainly welcomed.
Tip: check the
CHANGELOG.md
for features and/or bugs that may want attentions of those so inclined.
Most of the code and documentation, at least up to tagged version 0.0.1
, is
authored by a human. LLMs were no help with Vim script.
Options for contributing to Proompter and Vim Utilities
Start making a Fork of this repository to an account that you have write permissions for.
- Add remote for fork URL. The URL syntax is
[email protected]:<NAME>/<REPO>.git
...
cd ~/git/hub/vim-utilities/proompter
git remote add fork [email protected]:<NAME>/proompter.git
-
Adjust your package manager configuration
Plug '~/git/hub/vim-utilities/proompter' { 'do': '' }
-
Commit your changes and push to your fork, eg. to fix an issue...
cd ~/git/hub/vim-utilities/proompter
git commit -F- <<'EOF'
:bug: Fixes #42 Issue
**Edits**
- `<SCRIPT-NAME>` script, fixes some bug reported in issue
EOF
git push fork main
Note, the
-u
option may be used to setfork
as the default remote, eg.git push -u fork main
however, this will also default thefork
remote for pulling from too! Meaning that pulling updates fromorigin
must be done explicitly, eg.git pull origin main
- Then on GitHub submit a Pull Request through the Web-UI, the URL syntax is
https://github.com/<NAME>/<REPO>/pull/new/<BRANCH>
Note; to decrease the chances of your Pull Request needing modifications before being accepted, please check the dot-github repository for detailed contributing guidelines.
Thanks for even considering it!
Via Liberapay you may on a repeating basis.
Regardless of if you're able to financially support projects such as proompter that vim-utilities maintains, please consider sharing projects that are useful with others, because one of the goals of maintaining Open Source repositories is to provide value to the community.
This project is licensed based on use-case
If a project is either commercial or (||
) proprietary, then please
contact the author for pricing and licensing options to make use of code and/or
features from this repository.
If a project is both non-commercial and (&&
) published with a license
compatible with AGPL-3.0, then it may utilize code from this repository under
the following terms.
Leverage local LLM via Vim to boost bug breading within your code
Copyright (C) 2024 S0AndS0
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For further details review full length version of AGPL-3.0 License.