vim-conda icon indicating copy to clipboard operation
vim-conda copied to clipboard

[Window] Not found the CondaChangeEnv command in vim

Open hungpham3112 opened this issue 2 years ago • 16 comments

I downloaded the plugin today but not found the command on my machine. Maybe I missed something?

https://user-images.githubusercontent.com/75968004/216567523-ff27e4e3-2f94-4bd3-a64f-521b0b257c01.mp4

hungpham3112 avatar Feb 03 '23 09:02 hungpham3112

I've run into the very same problem today. While debugging the code, I found that if the system both respond to the 'python' and 'python3' then the initialization prosess does not begin in the plug in. Check this commend :echo !has('python3') && !has('python') if it returns 1, then the plugin would just exit without running.

I guess the original author designed this way when the plugin does not sure which python to use.(I gave up too. this is really annoying problem)

knowblesse avatar Feb 03 '23 15:02 knowblesse

I'm the original author. Would love a PR to fix this! :)

cjrh avatar Feb 15 '23 08:02 cjrh

I think we just favour python3 if found first. Otherwise fallback to others.

cjrh avatar Feb 15 '23 08:02 cjrh

I've run into the very same problem today. While debugging the code, I found that if the system both respond to the 'python' and 'python3' then the initialization prosess does not begin in the plug in. Check this commend :echo !has('python3') && !has('python') if it returns 1, then the plugin would just exit without running.

I guess the original author designed this way when the plugin does not sure which python to use.(I gave up too. this is really annoying problem)

This is the way it should be, isn't it? If you don't have python3 nor python how the plugin is supposed to run? Note that with the exception of the plugin script, the whole plugin is basically written in Python.

As it is today (2023) I guess you should have python3, therefore be sure that :echo has('python3') returns 1. If not, then you should set your pythonthreedll option in vim. This is the way I set it on my .vimrc (based on this : https://stackoverflow.com/questions/74718716/how-to-get-my-vim-and-macvim-to-find-python3) :

if has("gui_win32") || has("win32")
    set pythonthreehome=$HOME."\\Miniconda3"
    set pythonthreedll=$HOME."\\Miniconda3\\python39.dll"
elseif has("mac")
    &pythonthreehome = fnamemodify(trim(system("which python")), ":h:h")
    &pythonthreedll = trim(system("which python"))
endif

Also, try to run :python3 print('Hello world') and see what happens.

Unrelated: at startup, I get the following message:

Could not find a matching env in the list. 
This probably means that you are using a local 
(prefix) Conda env.
 
This should be fine, but changing to a named env 
may make it difficult to reactivate the prefix env.

may that be because in conda now the default environment is called base instead of root?

ubaldot avatar May 09 '23 18:05 ubaldot

Unrelated: at startup, I get the following message:

Very possible. I haven't personally used vim-conda in a very long time. I will still merge PRs though so if you can fix it to be better for how conda is today, I'll happily accept that.

cjrh avatar May 10 '23 07:05 cjrh

I was thinking to do that but in-spite the code looks very neat and not super hard to understand that would require me to study how to use Python in a different context than "data-science" + how to vimscript with python (I only used 100% vim9script) = lot of time which unfortunately at the moment I don't have (other life's priorities).

Nevertheless, if I will find some time in the future I will definitely try to send some PR :)

ubaldot avatar May 10 '23 08:05 ubaldot

I actually found some time this morning and I just issued a PR. :)

ubaldot avatar May 11 '23 08:05 ubaldot

Thank you, I merged the PR and sent you an invite to be a collaborator on this project. Can this issue be closed now?

cjrh avatar May 11 '23 09:05 cjrh

I don't know, I wasn't the issue opener :)

ubaldot avatar May 11 '23 09:05 ubaldot

Hi, I'm an issue opener. I will check and return feedback.

hungpham3112 avatar May 11 '23 10:05 hungpham3112

I'm tested with Windows 11 terminal vim , the plugin works correctly when apply Lazy load in plug.vim settings.

Plug 'https://github.com/cjrh/vim-conda.git', {'for': ['python']}

I have some concerns towards the performance.

  1. It took ~2-3 seconds to run at startup. It is within acceptable range but I believe startup time can improve for the better

  2. The plugin will show the message and I have to confirm if not lazy load.

vim-terminal:

https://github.com/cjrh/vim-conda/assets/75968004/a93146e0-319b-4fc8-be99-2cfcba15a09f

in the video, first time I loaded plugin without lazy behavior, then I set it back so we can see the different result.

gvim:

https://github.com/cjrh/vim-conda/assets/75968004/5a45f737-c464-4aa2-a50c-62f5676aea53

  1. Changing env but linting doesn't recognize.

hungpham3112 avatar May 23 '23 12:05 hungpham3112

Hi!

  1. Same here. I think that is the combination of two factors: conda itself is not very fast in changing environment and the plugin is written in Python which is notoriously slow. I think that this plugin is super useful and perhaps today it could be rewritten in VimScript for at least two reasons that come on top my head: Vim9 is faster and Vim9Script is much easier to write; Conda has changed in the meantime; we have LSP today so we don't need to consider a dedicated path for Jedi perhaps. I am personally considering to rewrite it "as-is" in Vim9script but don't hold your breath because I don't know "if" nor "when".

  2. The second does not look like an error message but rather a notification. What you get when you type :messages after Vim started up?

  3. For the linting I suggest you to use this. You can give the LSP server complete path so you don't have to bother about changing environment. You can check my .vimrc profile that I store in my github profile to take some inspiration, but if you have any question feel free to ask.

ubaldot avatar May 23 '23 16:05 ubaldot

2. The second does not look like an error message but rather a notification. What you get when you type `:messages` after Vim started up?

Yes, it's a notification. It's show base at the first time I open vim if I'm in conda base. My thought in here is another way to this message because opening without lazy load cause you have to confirm to enter vim, it's noisy. image

How about adding option to VimEnter? Pseudo code: ```

autocmd VimEnter * silent call ActivateEnv()

function! ActivateEnv() " Your function code here echo "base" endfunction

hungpham3112 avatar May 24 '23 03:05 hungpham3112

@hungpham3112 You could try this: https://github.com/ubaldot/vim-conda-activate It is brand new so it will most likely have some bugs, and it has been tested only on OSX. You could give it a shot anyway, it should be faster as it is 99% in VimScript.

I wrote a new plugin due to that this plugin is not being maintained anymore (but still accept PR:s) and because conda has changed throughout the years, Vim script has substantially improved. So, I thought it would have been easier to rewrite it in Vim9. I hope it does not bother :)

ubaldot avatar May 25 '23 16:05 ubaldot

I wrote a new plugin due to that this plugin is not being maintained anymore (but still accept PR:s) and because conda has changed throughout the years, Vim script has substantially improved. So, I thought it would have been easier to rewrite it in Vim9. I hope it does not bother :)

I checked your plugin. It's nice and clean with popup feature, I love that. @cjrh How about adding new reference to README.md to help new people know about @ubaldot plugin? It would be good for community. Thanks

hungpham3112 avatar May 26 '23 03:05 hungpham3112

I suggested same to @ubaldot in the other issue. He is a collaborator on this project and I've encouraged him to add at reference in the README. Higher up is better.

cjrh avatar May 27 '23 13:05 cjrh