Git Product home page Git Product logo

Comments (20)

ubaldot avatar ubaldot commented on June 12, 2024 1

What is the output :CondaChangeEnv after you tried the solution I proposed?

from vim-conda.

ubaldot avatar ubaldot commented on June 12, 2024 1

No worries, we have been all beginners :)

I dare to give you a small suggestion given your beginner state: earning vim takes LOT of time (at some point you will ask yourself if that was worth) and many of the information you need you can find in the :help user-manual. I heavily suggest you to read that BEFORE you try to guess how things work with trial and error approach because vim is everything but intuitive. You'll see how things will unfold much more easily. ;-)

Back to the problem, what I meant is this:

&pythonthreehome = fnamemodify(trim(system("which python")), ":h:h")
&pythonthreedll = trim(system("which python"))

call plug#begin()
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'cjrh/vim-conda'
call plug#end()

Next, run the command I wrote above and let us know the outcome.

from vim-conda.

accuracy-maker avatar accuracy-maker commented on June 12, 2024 1

oh, great work, I'll willing to test it in my win laptop.

from vim-conda.

cjrh avatar cjrh commented on June 12, 2024 1

Hi @ubaldot vim-conda-activate looks great! If you would like to add a PR here to mention it in my README, that would perfectly fine by me. I haven't made meaningful changes in vim-conda for many years so it's good that you have continued the work 👍🏼

I'll add you as a collaborator on vim-conda. nvm you already are :)

from vim-conda.

ubaldot avatar ubaldot commented on June 12, 2024

I am not sure what is that problem, but I would start by removing this part

let g:python3_host_prog = expand("/Users/gaohaitao/opt/anaconda3/envs/pytorch/bin/python")
let g:conda_python3_executable = expand("/Users/gaohaitao/opt/anaconda3/envs/traffic/bin/python")
let g:conda_executable = expand('/Users/gaohaitao/opt/anaconda3/bin/conda')

" 设置CondaChangeEnv命令为自动加载
augroup conda_autogroup
autocmd!
autocmd VimEnter * CondaChangeEnv
augroup END

from the section delimited by the call plug#begin() and call plug#end().
Well, I would completely remove these definitions and I would instead include the following in my .vimrc

    &pythonthreehome = fnamemodify(trim(system("which python")), ":h:h")
    &pythonthreedll = trim(system("which python"))

I would then run :echo has('python3') that should return 1 and then :python3 print('Hello World!') that should return Hello World!

from vim-conda.

accuracy-maker avatar accuracy-maker commented on June 12, 2024

Thanks for your help, but I still get confused. Because I have a lot of virtual envs in Anaconda, in order to make command "CondaChangeEnv" work, what types of pathroot should I use? base or env I created?

from vim-conda.

accuracy-maker avatar accuracy-maker commented on June 12, 2024

Actually I am newplayer of shell and vim, I write the config file in ~/.config/nvim/init.vim, Did the solution you proposed mean this way?

call plug#begin()

Plug 'octol/vim-cpp-enhanced-highlight'

Plug 'cjrh/vim-conda'
&pythonthreehome = fnamemodify(trim(system("which python")), ":h:h")
&pythonthreedll = trim(system("which python"))

call plug#end()

from vim-conda.

accuracy-maker avatar accuracy-maker commented on June 12, 2024

when I rewrite the config file in ~/.config/nvim/init.vim, like this:
`&pythonthreehome = fnamemodify(trim(system("which python")), ":h:h")
&pythonthreedll = trim(system("which python"))

call plug#begin()
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'cjrh/vim-conda'
call plug#end()`

when I recommnad <sudo nvim ~/.config/nvim/init.vim>, there's an error:
Processing/Users/gaohaitao/config/nvim/init. If the error occurs when vim: Line 1: E33: Does not have the previous replacement regular expression Line 2: E33: Does not have the previous replacement regular expression Press ENTER or another command to continue

Then, I check this command , I do have a python env in </Users/gaohaitao/opt/anaconda3/bin/python>
But When I input ":CondaChangeEnv", the editor show this:
E492: Not editor command: CondaChangeEnv

it seems that the config file didn't work. I still have a question:"Whether the functions of the config files vimrc and init.vim are the same"

from vim-conda.

ubaldot avatar ubaldot commented on June 12, 2024
  1. Why you use sudo?
  2. my bad, I use vim9 (not neovim) and the syntax for setting options is different

I am not sure but you need let. Try with the following:

let &pythonthreehome = fnamemodify(trim(system("which python")), ":h:h")
let &pythonthreedll = trim(system("which python"))
  1. I don't know the mechanism of nvim, but I suggest you to write the lines I gave you to .vimrc.

Check also the other commands I gave you.
For troubleshooting you could also check :messages just after startup.

from vim-conda.

accuracy-maker avatar accuracy-maker commented on June 12, 2024

I'll try your solution. It is embrassed for me that i need to take some time. When I finish them, I'll give you feedback. Thank for your help very much!!!

from vim-conda.

ubaldot avatar ubaldot commented on June 12, 2024

Don't be embarassed. It takes time for everyone. It is actually when you rush that things won't work and frustrate you. ;-) Good luck!

from vim-conda.

accuracy-maker avatar accuracy-maker commented on June 12, 2024

Hi, I uninstall the neovim and use vim. Surprisingly, I find that my computer has two types of vim -- one is installed by homebrew, the other is installed initially by Mac. And the init vim dosn't support python3. Then I aliase the vim to homebrew version and support the python3 finally.

I write the config file in ~/.vimrc like this:
image
it seems that the config file didn't work
image

the good news is when I input py3 print("hello world"), this command can work

from vim-conda.

ubaldot avatar ubaldot commented on June 12, 2024

It is normal, macosx is shipped with vim by default, but that is not super good since it misses lots of features.
Also, even if you install Vim through homebrew, terminal.app does not supports colorschemes very well. In that case you may think to install another terminal app like kitty or iterm2.

Otherwise, consider Macvim. ;-)
Don't forget to carefully read :h macvim for setting your terminal if you go that route.

Or, if you want to revert back to neovim to use stuff like telescope, treesitter, etc, check with neovim folks how to set :h options. In this case the options that you want to set are pythonthrehome and pythonthreedll.

from vim-conda.

accuracy-maker avatar accuracy-maker commented on June 12, 2024

Thanks for your help, I really excited that I succeed just now. I summarize two points that maybe helpful to other beginners.

  • Check out your vim version and test if python3 is supported
  • Remember to install pyvim. pip install pyvim in your base root of anaconda3
    Then your vim-conda works.
    image
    image
    Finally, thank ubaldot again. You are really a nice person!

from vim-conda.

ubaldot avatar ubaldot commented on June 12, 2024

No worries :)

Just a final note: I have no idea what pyvim is, but it is not a good idea to install stuff in the base environment.

from vim-conda.

accuracy-maker avatar accuracy-maker commented on June 12, 2024

ok, if I have the better solution, I'll leave another message

from vim-conda.

jiaqiwang969 avatar jiaqiwang969 commented on June 12, 2024

https://github.com/ubaldot/vim-conda-activate
thus may help?

from vim-conda.

ubaldot avatar ubaldot commented on June 12, 2024

https://github.com/ubaldot/vim-conda-activate
thus may help?

Thanks for the mention but that is an undergoing work. It has a major bug that perhaps it is solved by setting the sys.path but I have to figure out how in vimscript.
Or perhaps it will never been solved 🤣.
Well, if you have any clue feel free to add a PR 😄

from vim-conda.

ubaldot avatar ubaldot commented on June 12, 2024

Ok, I found some time and I completed the plugin.

https://github.com/ubaldot/vim-conda-activate

Being very new, it may contain bugs. I have tested only on OSX, but I am confident that it should work on other OS:s as well.

Thanks to @cjrh that paved the way! :)

from vim-conda.

ubaldot avatar ubaldot commented on June 12, 2024

Ok, I'll fix that.

from vim-conda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.