diff options
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | autoload/vim_ai_config.vim | 3 | ||||
| -rw-r--r-- | plugin/vim-ai.vim | 2 | ||||
| -rw-r--r-- | py/utils.py | 2 |
4 files changed, 11 insertions, 2 deletions
@@ -40,6 +40,12 @@ echo "YOUR_OPENAI_API_KEY,YOUR_OPENAI_ORG_ID" > ~/.config/openai.token export OPENAI_API_KEY="YOUR_OPENAI_API_KEY,YOUR_OPENAI_ORG_ID" ``` +The default api key file location is `~/.config/openai.token`, but you can change it by setting the `g:vim_ai_token_file_path` in your `.vimrc` file: + +```vim +let g:vim_ai_token_file_path = '~/.config/openai.token' +``` + ### Using `vim-plug` ```vim diff --git a/autoload/vim_ai_config.vim b/autoload/vim_ai_config.vim index 6119e4f..ef3c863 100644 --- a/autoload/vim_ai_config.vim +++ b/autoload/vim_ai_config.vim @@ -70,6 +70,9 @@ endif if !exists("g:vim_ai_debug_log_file") let g:vim_ai_debug_log_file = "/tmp/vim_ai_debug.log" endif +if !exists("g:vim_ai_token_file_path") + let g:vim_ai_token_file_path = "~/.config/openai.token" +endif function! vim_ai_config#ExtendDeep(defaults, override) abort let l:result = a:defaults diff --git a/plugin/vim-ai.vim b/plugin/vim-ai.vim index 5d156c3..0e4957f 100644 --- a/plugin/vim-ai.vim +++ b/plugin/vim-ai.vim @@ -18,5 +18,5 @@ command! -range -nargs=? AIEdit <line1>,<line2>call vim_ai#AIEditRun({}, <q " AIChat defaults to passing nothing which is achieved by -range=0 and passing " <count> as described at https://stackoverflow.com/a/20133772 command! -range=0 -nargs=? AIChat <line1>,<line2>call vim_ai#AIChatRun(<count>, {}, <q-args>) -command! -nargs=? AINewChat call vim_ai#AINewChatRun(<q-args>) +command! -nargs=? AINewChat call vim_ai#AINewChatRun(<f-args>) command! AIRedo call vim_ai#AIRedoRun() diff --git a/py/utils.py b/py/utils.py index a5c489f..19de7c4 100644 --- a/py/utils.py +++ b/py/utils.py @@ -19,7 +19,7 @@ class KnownError(Exception): pass def load_api_key(): - config_file_path = os.path.join(os.path.expanduser("~"), ".config/openai.token") + config_file_path = os.path.expanduser(vim.eval("g:vim_ai_token_file_path")) api_key_param_value = os.getenv("OPENAI_API_KEY") try: with open(config_file_path, 'r') as file: |