Search code examples
python-3.xvimsyntax-highlightingwindows-subsystem-for-linuxopensuse

Vim, WSL and syntax highlighting


I've tried to write a python script on OpenSuSE running as WSL on Windows 10. I've got my .vimrc that has been working both on Mac and OpenSuSE, but now a few things are broken:

  • no syntax highlighting
  • no automatic indentation, i.e. when I type def foo(): <ENTER>, the indentation remains at position 0.

Setting as some have suggested

set term=screen-256color
set t_ut=

didn't help.

The rest seems to work: YCM shows suggestions, relative line numbers are displayed, etc.

I've tried to move both .vimrc and .vim, and then just :set syntax. Vim recognizes it as Python showing syntax=python, but this is it. So, it seems to be irrelevant to my .vimrc.

Does anyone have an idea how this can be fixed?

EDIT:

:filetype 
filetype detection:ON  plugin:ON  indent:ON

:verbose set ft? 
filetype=python

:scriptnames  

  1: /etc/vimrc
  2: /usr/share/vim/vim80/syntax/syntax.vim
  3: /usr/share/vim/vim80/syntax/synload.vim
  4: /usr/share/vim/vim80/syntax/syncolor.vim
  5: /usr/share/vim/vim80/filetype.vim
  6: /usr/share/vim/vim80/defaults.vim
  7: /usr/share/vim/vim80/syntax/nosyntax.vim
  8: /usr/share/vim/vim80/ftplugin.vim
  9: /usr/share/vim/vim80/indent.vim

Solution

  • It seems your Vim install was incomplete, since it was missing files syntax/python.vim and indent/python.vim under /usr/share/vim/vim80, which should have been loaded when editing a file of type Python.

    It's possible that OpenSuSE ships the complete Vim runtimes in a separate RPM and for some reason you didn't have it installed?

    Ensuring those files are present should fix the issue you're having with syntax and indentation of Python files.