summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Bielik <mx.bielik@gmail.com>2024-03-09 19:37:55 +0100
committerMartin Bielik <mx.bielik@gmail.com>2024-03-09 19:37:55 +0100
commitf4130feb986760a8d956983cb5cfe8d7106e7d4a (patch)
treef5ea9e125cd52fbb2bc8cdd59abfe8358104fef8
parent9db190c977d1f76e2f574882e4edde062eecbb0d (diff)
downloadvim-ai-f4130feb986760a8d956983cb5cfe8d7106e7d4a.tar.gz
roles example file
Diffstat (limited to '')
-rw-r--r--autoload/vim_ai.vim1
-rw-r--r--autoload/vim_ai_config.vim5
-rw-r--r--py/roles.py2
-rw-r--r--py/utils.py2
-rw-r--r--roles-example.ini22
5 files changed, 29 insertions, 3 deletions
diff --git a/autoload/vim_ai.vim b/autoload/vim_ai.vim
index 302ef1d..b6f4617 100644
--- a/autoload/vim_ai.vim
+++ b/autoload/vim_ai.vim
@@ -1,6 +1,5 @@
call vim_ai_config#load()
-
let s:plugin_root = expand('<sfile>:p:h:h')
let s:complete_py = s:plugin_root . "/py/complete.py"
let s:chat_py = s:plugin_root . "/py/chat.py"
diff --git a/autoload/vim_ai_config.vim b/autoload/vim_ai_config.vim
index ef3c863..41932de 100644
--- a/autoload/vim_ai_config.vim
+++ b/autoload/vim_ai_config.vim
@@ -1,3 +1,5 @@
+let s:plugin_root = expand('<sfile>:p:h:h')
+
let g:vim_ai_complete_default = {
\ "engine": "complete",
\ "options": {
@@ -73,6 +75,9 @@ endif
if !exists("g:vim_ai_token_file_path")
let g:vim_ai_token_file_path = "~/.config/openai.token"
endif
+if !exists("g:vim_ai_roles_config_file")
+ let g:vim_ai_roles_config_file = s:plugin_root . "/roles-example.ini"
+endif
function! vim_ai_config#ExtendDeep(defaults, override) abort
let l:result = a:defaults
diff --git a/py/roles.py b/py/roles.py
index 8f7f161..7c7cf13 100644
--- a/py/roles.py
+++ b/py/roles.py
@@ -2,7 +2,7 @@ import vim
import os
import configparser
-roles_config_path = os.path.expanduser('~/.vim/roles.ini') # TODO configure
+roles_config_path = os.path.expanduser(vim.eval("g:vim_ai_roles_config_file"))
roles = configparser.ConfigParser()
roles.read(roles_config_path)
diff --git a/py/utils.py b/py/utils.py
index 52e538d..6600fc3 100644
--- a/py/utils.py
+++ b/py/utils.py
@@ -264,7 +264,7 @@ def clear_echo_message():
vim.command("call feedkeys(':','nx')")
def load_role_config(role):
- roles_config_path = os.path.expanduser('~/.vim/roles.ini') # TODO configure
+ roles_config_path = os.path.expanduser(vim.eval("g:vim_ai_roles_config_file"))
roles = configparser.ConfigParser()
roles.read(roles_config_path)
if not role in roles:
diff --git a/roles-example.ini b/roles-example.ini
new file mode 100644
index 0000000..90d32bc
--- /dev/null
+++ b/roles-example.ini
@@ -0,0 +1,22 @@
+# .ini file structure:
+# - https://docs.python.org/3/library/configparser.html#supported-ini-file-structure
+
+[grammar]
+prompt = fix spelling and grammar
+
+[refactor]
+prompt =
+ You are a Clean Code expert, I have the following code,
+ please refactor it in a more clean and concise way so that my colleagues
+ can maintain the code more easily. Also, explain why you want to refactor
+ the code so that I can add the explanation to the Pull Request.
+
+# common options for all engines
+[refactor.options]
+temperature = 0.4
+
+# engine specific options:
+[refactor.options-chat]
+model = gpt-4
+
+[refactor.options-complete]