Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gruvbox is interfering with Typescript indent #102

Closed
ianliu opened this issue Jun 7, 2019 · 5 comments
Closed

gruvbox is interfering with Typescript indent #102

ianliu opened this issue Jun 7, 2019 · 5 comments

Comments

@ianliu
Copy link

ianliu commented Jun 7, 2019

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 added a commit that referenced this issue Jun 7, 2019
@rbong
Copy link

rbong commented Jun 7, 2019

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.

rbong added a commit that referenced this issue Jun 7, 2019
@ianliu
Copy link
Author

ianliu commented Jun 7, 2019

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

@rbong
Copy link

rbong commented Jun 7, 2019

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
Copy link

rbong commented Jun 7, 2019

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

@rbong
Copy link

rbong commented Jun 7, 2019

That should tie up any lose ends from our side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants