jnurmine / Zenburn

Zenburn is a low-contrast color scheme for Vim.
http://kippura.org/zenburnpage
891 stars 149 forks source link

Python formatting broken #11

Closed arusahni closed 10 years ago

arusahni commented 10 years ago

With a fresh .vimrc, and t_Co=256, syntax on and colorscheme zenburn set, the import statements in a Python file are no longer formatted. screen shot 2014-08-25 at 9 56 26 am The code is highlighted properly with the default colorscheme. screen shot 2014-08-25 at 9 56 48 am

I'm using vim 7.4.335 on OS X.

jnurmine commented 10 years ago

I don't know why Vim behaves like this, but it's not due to any of the color schemes, including Zenburn. I think you also, like me, will see the same behaviour with any color scheme.

A symptom seems to be that when things look OK the pythonInclude highlight group maps to Include highlight group, and when things are broken, there are no highlight groups defined, at all. I suspect something either with Vim internals or with the filetype plugin since the detected syntax is re-set to nothing.

As a quick remedy, you can do :e! to re-load the file, the syntax highlights should re-appear. Or, you can set syntax=python.

I can sort of kind of reproduce the issue when re-loading a testrc (see below) with :so ~/testrc in a running Vim. Upon :e! things are back to normal, at least for me.

To illustrate how the highlight groups vanish, I did :set nocompatible then this:

map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>

Then, with the cursor at the "import" in the "import itertools"-line (or "from"-line, just as same) I hit F10 and got: hi<pythonInclude> trans<pythonInclude> lo<Include>

This means the pythonInclude group maps to Include, which it should.

With the "all white" mode triggered sometimes by re-sourcing the testrc, I just get: hi<> trans<> lo<> i.e. the whole syntax was cleared.

I was able to trigger the issue with other colorschemes too.

FYI the minimal .vimrc I used when investigating was:

$ cat testrc
"set nocompatible
set t_Co=256
syntax on
colorscheme zenburn

Then I did: vim -u testrc test.py (with the .py contents as in your example). The file shows up fine initially for me, though my Vim is a bit earlier version than yours.