diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2024-03-24 11:29:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-24 11:29:43 +0100 |
| commit | edd54923c2caa81066e637da50f76905bb1c3a11 (patch) | |
| tree | 160568ea3abdabbca1273acb9bc423cfa98f1a53 /py/roles.py | |
| parent | eb333e39e17d4d5240dbbc186a65bc6e9ab6b44e (diff) | |
| parent | 6a053767af08d6edfb46b4be72f05a9b3bc7be04 (diff) | |
| download | vim-ai-edd54923c2caa81066e637da50f76905bb1c3a11.tar.gz | |
Merge pull request #85 from madox2/custom-roles
Custom roles
Diffstat (limited to '')
| -rw-r--r-- | py/roles.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/py/roles.py b/py/roles.py new file mode 100644 index 0000000..b7d19e1 --- /dev/null +++ b/py/roles.py @@ -0,0 +1,23 @@ +import vim + +# import utils +plugin_root = vim.eval("s:plugin_root") +vim.command(f"py3file {plugin_root}/py/utils.py") + +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) + +enhance_roles_with_custom_function(roles) + +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}') |