summaryrefslogtreecommitdiff
path: root/py/roles.py
diff options
context:
space:
mode:
authorMartin Bielik <martin.bielik@instea.sk>2024-12-15 23:32:55 +0100
committerMartin Bielik <martin.bielik@instea.sk>2024-12-16 00:08:23 +0100
commitcb2ac5f7a672faeb7b81886b6c1f1481ef51f90d (patch)
tree12a9045749c3468e57555a13320871937bbb54e7 /py/roles.py
parentf26bee941bf9e5a5452ee0d75e7f2f2ea3c5216a (diff)
downloadvim-ai-cb2ac5f7a672faeb7b81886b6c1f1481ef51f90d.tar.gz
refactoring: import python when needed, run as functions
Diffstat (limited to '')
-rw-r--r--py/roles.py26
1 files changed, 10 insertions, 16 deletions
diff --git a/py/roles.py b/py/roles.py
index b7d19e1..16aa4e9 100644
--- a/py/roles.py
+++ b/py/roles.py
@@ -1,23 +1,17 @@
import vim
-# import utils
-plugin_root = vim.eval("s:plugin_root")
-vim.command(f"py3file {plugin_root}/py/utils.py")
+roles_py_imported = True
-roles_config_path = os.path.expanduser(vim.eval("g:vim_ai_roles_config_file"))
-if not os.path.exists(roles_config_path):
- raise Exception(f"Role config file does not exist: {roles_config_path}")
+def load_ai_role_names():
+ roles_config_path = os.path.expanduser(vim.eval("g:vim_ai_roles_config_file"))
+ if not os.path.exists(roles_config_path):
+ raise Exception(f"Role config file does not exist: {roles_config_path}")
-roles = configparser.ConfigParser()
-roles.read(roles_config_path)
+ roles = configparser.ConfigParser()
+ roles.read(roles_config_path)
-enhance_roles_with_custom_function(roles)
+ enhance_roles_with_custom_function(roles)
-role_names = [name for name in roles.sections() if not '.' in name]
+ role_names = [name for name in roles.sections() if not '.' in name]
-role_list = [f'"{name}"' for name in role_names]
-role_list = ", ".join(role_list)
-
-role_list = f"[{role_list}]"
-
-vim.command(f'let l:role_list = {role_list}')
+ return role_names