Skip to content

Switching to installed python when vim is not compiled with +python3 #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scarbajali
Copy link
Contributor

@scarbajali scarbajali commented Jul 25, 2025

I usually work with preinstalled versions of vim which doesn't have +python3 compiled and I see that in this case the plugin is fully disabled.

This PR will switch to the python version installed in the system in case embedded python is not found and only OllamaEdit will be disabled (error messages are displayed if the user tries to use it).

Copy link
Contributor

@ilya-bobyr ilya-bobyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that

@@ -5,6 +5,31 @@ let s:buf = -1
" avoid starting a 2nd edit job while one is in progress
let g:edit_in_progress = 0

if !exists('g:ollama_embedded_python') || g:ollama_embedded_python == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be better to perform the "is embedded Python" available check as the first expression of the corresponding function?

This way it would be closer to the reset of the relevant code.
When a function that uses embedded Python is added or removed, it is easier to see that one also needs to think about a case when Python is not available.

@@ -379,6 +379,8 @@ function! ollama#setup#EnsureVenv() abort
endfunction

" Loads the plugin's python modules

if g:ollama_embedded_python
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In autoload/ollama/edit.vim you defined alternative function body, but here you are skipping the function definition.
Both works, but it seems a bit inconsistent.

I would suggest doing a check as the first statement and show a helpful error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants