vim-jsx
vim-jsx copied to clipboard
Incorrect indentation
For some reason, indentation doesn't seem to work properly anymore :(

I just did a :PluginUpdate (using vundle), and am now getting some indentation but still not working properly...

Oh, I just noticed that indentation seems to be working when I end lines with a semi colon ;. Is that correct?
Looks like using
Plugin 'pangloss/vim-javascript'
instead of
Plugin 'othree/yajs.vim'
fixes the indentation issue.
I'm using
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
The indentation still doesn't work well while entering a new line between<>and</>.
<ul>
<li># I entered a new line here
</li>
</ul>
But it works well if the file set autoindent.
I found that vim-javascript set noautoindent to be default recently. Maybe it is a point.
I also have issues with the indentation:

vim-javascript keeps changing, and they don't want to merge code related to jsx, so I made https://github.com/neoclide/vim-jsx-improve
Just a heads up I had this same issue and fixed it by installing https://github.com/vim-scripts/JavaScript-Indent
Same issue here with straight-forward html in jsx - adding the JavaScript-Indent plugin didn't work (and anywqay, it's really stale). I'm using the latest vim-javascript plugin & vim-jsx plugins and I'm getting:

@jesii—Could you try minimizing your example and posting it as a Gist or a pastebin or in some other text format, along with a screenshot of the issue? I'll try to debug.
Bump - any news on this? Whenever I type in tags all nested tags just ignore indentation and it can be quite frustrating to use vim when developing React without fixing this.
The update is that I can't repro this and nobody has given me a reduced ~/.vimrc that yields a repro.
I've run into these indentation issues as well. I've forked vim-javascript and vim-jsx, moved back master to a previous commit in both, and referenced those repos in Vundle:
Plugin 'Emigre/vim-javascript'
Plugin 'Emigre/vim-jsx'
That seems to fix the issue, so the problem must have appeared recently. I've moved master in vim-jsx back to the 30th of July 2016 (13 commits behind right now) and vim-javascript to the 12th of July 2017 (also 13 commits behind, at the moment).
How to reproduce
I'm testing the issue with some JavaScript code similar to this one:
const whatever = () => ({
foo: 'bar', });
If the issue is present, positioning the cursor after 'bar', and clicking <enter> gives this result:
const whatever = () => ({
foo: 'bar',
});
When the issue is not present, positioning the cursor after 'bar', and clicking <enter> results in the right indentation:
const whatever = () => ({
foo: 'bar',
});
To test the issue I also add some JSX below that and check if it is indented properly when writing it, and if it is syntax-highlighted properly.
This is the minimal .vimrc to recreate the issue:
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
call vundle#end()
filetype plugin indent on
let g:jsx_ext_required = 0
Hope that this helps, and thanks for your plugin! :)
I've taken a look at this again and I think that the issue no longer seems to happen with the latest versions of the plugins. I think that we can close this issue @olalonde.
I have added:
filetype plugin indent on
Helped for me