diff options
| author | Martin Bielik <mx.bielik@gmail.com> | 2024-03-11 21:45:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-11 21:45:41 +0100 |
| commit | 1ae3ebccf6d790e669311d9556335a8fa55b07cc (patch) | |
| tree | 3ff148f263f708ee6861a8a4671b8675be6a678d /py/utils.py | |
| parent | 5709ab1ce75f05e9b57bf052f3ad92aa74f61c16 (diff) | |
| parent | 881fd24a6d2c0de387256b4d6e05f5d0a53cc8e2 (diff) | |
| download | vim-ai-1ae3ebccf6d790e669311d9556335a8fa55b07cc.tar.gz | |
Merge pull request #87 from Konfekt/custom-roles
Ensure role config file exists and optional Vim source
Diffstat (limited to 'py/utils.py')
| -rw-r--r-- | py/utils.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/py/utils.py b/py/utils.py index 6bd90a1..471b5c4 100644 --- a/py/utils.py +++ b/py/utils.py @@ -271,6 +271,13 @@ def load_role_config(role): roles = configparser.ConfigParser() roles.read(roles_config_path) + if vim.eval("exists('g:vim_ai_roles_config_function')") == '1': + roles_config_function = vim.eval("g:vim_ai_roles_config_function") + if not vim.eval("exists('*" + roles_config_function + "')"): + raise Exception(f"Role config function does not exist: {roles_config_function}") + else: + roles.update(vim.eval(roles_config_function + "()")) + if not role in roles: raise Exception(f"Role `{role}` not found") |