Skip to content
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

[Window] Not found the CondaChangeEnv command in vim #41

Open
hungpham3112 opened this issue Feb 3, 2023 · 16 comments
Open

[Window] Not found the CondaChangeEnv command in vim #41

hungpham3112 opened this issue Feb 3, 2023 · 16 comments

Comments

@hungpham3112
Copy link

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

bandicam.2023-02-03.09-44-15-452.mp4
@knowblesse
Copy link

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)

@cjrh
Copy link
Owner

cjrh commented Feb 15, 2023

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

@cjrh
Copy link
Owner

cjrh commented Feb 15, 2023

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

@ubaldot
Copy link
Collaborator

ubaldot commented May 9, 2023

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?

@cjrh
Copy link
Owner

cjrh commented May 10, 2023

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.

@ubaldot
Copy link
Collaborator

ubaldot commented May 10, 2023

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
Copy link
Collaborator

ubaldot commented May 11, 2023

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

@cjrh
Copy link
Owner

cjrh commented May 11, 2023

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

@ubaldot
Copy link
Collaborator

ubaldot commented May 11, 2023

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

@hungpham3112
Copy link
Author

hungpham3112 commented May 11, 2023

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

@hungpham3112
Copy link
Author

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:

bandicam.2023-05-23.12-24-38-478.mp4

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

gvim:

bandicam.2023-05-23.12-28-13-836.mp4
  1. Changing env but linting doesn't recognize.

@ubaldot
Copy link
Collaborator

ubaldot commented May 23, 2023

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.

@hungpham3112
Copy link
Author

hungpham3112 commented May 24, 2023

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

@ubaldot
Copy link
Collaborator

ubaldot commented May 25, 2023

@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 :)

@hungpham3112
Copy link
Author

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

@cjrh
Copy link
Owner

cjrh commented May 27, 2023

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.

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

No branches or pull requests

4 participants