ets-labs/python-vimrc

syntax error when using f"string {my_var}"

eAmoeba opened this issue · 6 comments

really nice work here on this vimrc. really enjoying the work you put into it.

Would you know how to fix the syntax error when using the new f"string {}" format in python3.6+ I went through all the help pages for pymode and syntastic. I am completly lost. pretty new to vim in general (loving it though, omg my work flow is so much faster now that I learned vim)

can you point me in the right direction or maybe you have a solution?
when I change
let g:pymode_python='python'
to
let g:pymode_python='python3'
I get lots of errors.
Seen here: https://i.imgur.com/gif2Yze.png

Thanks.

Hi @eAmoeba ,

Well, I don't think there is any easy way to achieve Python 3 support... In fact, ViM can work only with one version of Python (2 or 3, not 2 and 3) - the version of Python that was used for ViM compilation. Basically, if you want to get support of Python 3 syntax - what you should do is to look for a way to get ViM compiled with Python3. Keep in mind, that one ViM distribution could not be compiled with both Python 2 & Python 3 - you need to choose one of them.

What I was doing some time earlier is compiling ViM from sources with Python 3 support and use it in parallel with system ViM with Python 2 support. Basically, I have had two aliases - vimpy2 & vimpy3, regular vim just pointed to system ViM.

I'm not sure what OS do you use, so it's hard to recommend some particular way to make this compilation done. What I was doing on my Mac - just compiling ViM from sources with specifying path to python3-config & some paths to link other libraries.

Finally, you should get something like that (-python +python3):

$ vim --version | grep python
+comments          +libcall           -python            +visualextra
+conceal           +linebreak         +python3           +viminfo

After you done with this - now you should go ahead with changing paths in .vimrc file like you're already doing (e. g. let g:pymode_python='python3', etc...). One more important thing is that I have 2 vimrc's files - one for vimpy2 and another for vimpy3. Particular .vimrc file was specified in appropriate alias like that $ alias vimpy3='vim -u /path/to/custom/.vimrc'.

Thanks a lot for the feedback, I'm really glad that you've found it useful. Hope you will be enjoying ViM even thorough these little complications... :)

Thanks,
Roman

Thank you for the reply,

to answer the OS Question I am on Fedora. Obviously, ViM is pre-installed and so is Python2 and 3.

That's a good push in the right direction. Thank you. I will play around with the solution you suggested. If it worked on your Mac it should be able to get it working on Linux fairly easy. I have no need to write anything currently in Python2. So if I can getting working on 3 I should be good.

I wonder now giving it a thought... neovim. I wonder if it would work directly under that... hmmm...

Again, Thanks for the information and even more thanks for the nice working environment with the vimrc.

You're welcome, not at all.

I wonder now giving it a thought... neovim. I wonder if it would work directly under that... hmmm...

Try it... I tried it some time ago as well and faced some issues, but I don't remember what were they :) Hopefully you would be more lucky!

Thanks for not hesitating to ask a question!

Have a good one,
Roman

Closing this issue, please feel free to reopen / add comments if needed.

Thanks for the help I did both. tried neovim and I ran into a few issues, so I compiled vim with:

./configure --with-features=huge --enable-multibyte --enable-python3interp=yes --with-python3-config-dir=/usr/lib/python3.7/config --prefix=/usr/local

Totally works no issues with python 3.7
again. Thanks for the help.

So if anyone else runs into this issue These are the steps I took.
cd ~
git clone https://github.com/vim/vim.git
cd vim
./configure --with-features=huge --enable-multibyte --enable-python3interp=yes --with-python3-config-dir=/usr/lib/python3.7/config --prefix=/usr/local
sudo make install

Appreciate the help!

Awesome, perfect news! @eAmoeba , thanks for sharing this - I'm sure it will help lots of people!

Roman