pangloss / vim-javascript

Vastly improved Javascript indentation and syntax support in Vim.
http://www.vim.org/scripts/script.php?script_id=4452
3.8k stars 358 forks source link

JSX + IndentLine and Indentation Bug #742

Closed amadeus closed 7 years ago

amadeus commented 7 years ago

This may not be fixable, but I figured I would post here just in case.

It appears when I use this plugin https://github.com/Yggdroot/indentLine, it breaks indentation.

Specificially, if you set the following indent settings (tabstop=2, shiftwidth=2, expandtab) and use a JSX snippet like so (| is the cursor):

const Example = () => (
  <section>
    <div className="content"></div>|
  </section>
);

Then press return/enter, the indentation is completely borked. I think it might have something to do with the conceal chars that IndentLine creates, and if this is the case, you may not be able to work around it :(

bounceme commented 7 years ago

https://github.com/hynek/vim-python-pep8-indent/blob/master/indent/python.vim#L65

I don't know if something like this will help though. I'll test soon

bounceme commented 7 years ago

I can't reproduce the problem. indent is fine for me without the workaround

bounceme commented 7 years ago

also, technically the xml indenter would be the problem

amadeus commented 7 years ago

Hmm, you don't get:

const Example = () => (
  <section>
    <div className="content"></div>
  |
  </section>
);

I actually get this regardless of whether the filetype is javascript.jsx or not (in other words, this happens when the filetype is even just javascript). Are there perhaps other settings I could have that would be causing this?

bounceme commented 7 years ago

that would be the correct indent level ( everything within () are uniformly lined up ( try indenting line 3) ) with plain javascript. that means you probably have something wrong with the jsx plugin, since for me this indents where you would expect ( at the level of the div ) thanks to the mxw/vim-jsx.