gruvbox-community / gruvbox

Retro groove color scheme for Vim - community maintained edition
MIT License
801 stars 62 forks source link

gruvbox is interfering with Typescript indent #102

Closed ianliu closed 5 years ago

ianliu commented 5 years ago

Preparation

  1. Make sure you are using a xterm-256color compatible terminal, such as gnome-terminal.

  2. Copy the following to a Dockerfile and execute docker build -t gruvbox-bug .

FROM alpine:3.9

WORKDIR /root/.vim/pack/bug/start/
RUN apk add git vim \
    && git clone https://github.com/MaxMEllon/vim-jsx-pretty \
    && git clone https://github.com/leafgarland/typescript-vim \
    && git clone https://github.com/gruvbox-community/gruvbox \
    && echo -e 'set nocp sw=2 et sta\nsyntax on\nfiletype plugin indent on\ncolorscheme gruvbox' > /root/.vim/vimrc \
    && echo -e 'const foo = () => (\n<div>\n{}\n</div>\n)' > /root/test.tsx
WORKDIR /root/
CMD [ "/bin/sh" ]
  1. Run docker run --rm -ti gruvbox-bug, you are going to log into a shell.

Tests with colorscheme gruvbox

The .vim/vimrc already has the colorscheme gruvbox set. Now execute the following tests:

  1. Execute TERM=xterm-256color vim test.tsx and issue the =G command to reindent the file. The file should be wrongly indented.

  2. Execute TERM=xterm vim test.tsx and issue the =G command to reindent the file. The file should be correctly indented.

Tests without colorscheme gruvbox

Comment out the line setting the colorscheme in .vim/vimrc and rerun the two previous tests, and you will see that, no matter the TERM variable, it will work.

rbong commented 5 years ago

I'm sure there are other cases, but it looks like for this particular case, setting the typeScriptBraces highlight group in a colorscheme causes this bug (but not after initialization - likely an issue with execution order). I've pushed up a branch 102-workaround that comments out this line. If you're having this issue and it lasts much longer while I look more into this, please check to see if it resolves indentation issues.

ianliu commented 5 years ago

@rbong yes, I can confirm the workaround works. Why does xterm-256color matter here?

rbong commented 5 years ago

The fix turns out to be simple from our side... the highlight groups are formatted in the fashion typescriptGroup, not typeScriptGroup. I've changed this on master and the issue seems to go away.

For some reason, using the latter breaks indentation. I am sure there is a bug somewhere in the typescript plugin or Vim, so I am keeping this open for now until I can pin down an issue and submit it or determine if it's intended behaviour just so I can keep us from breaking other plugins in the same way.

I have no idea why xterm-256color matters here, it's a very odd issue. Overwriting a highlight group should not impact indentation AFAIK and I can't find any references to typescriptBraces, TERM, or xterm that seem to matter in the typescript plugin.

rbong commented 5 years ago

Problem is this line in vim-jsx-pretty, it is case sensitive. Going to submit a PR.

rbong commented 5 years ago

That should tie up any lose ends from our side.