vim-jsx icon indicating copy to clipboard operation
vim-jsx copied to clipboard

Incorrect indentation

Open olalonde opened this issue 9 years ago • 14 comments
trafficstars

For some reason, indentation doesn't seem to work properly anymore :(

3smjs45lxj

olalonde avatar Oct 03 '16 02:10 olalonde

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

zaj4bvsyzk

olalonde avatar Oct 03 '16 02:10 olalonde

Oh, I just noticed that indentation seems to be working when I end lines with a semi colon ;. Is that correct?

olalonde avatar Oct 03 '16 03:10 olalonde

Looks like using

Plugin 'pangloss/vim-javascript'

instead of

Plugin 'othree/yajs.vim'

fixes the indentation issue.

olalonde avatar Oct 03 '16 03:10 olalonde

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.

ylhuang0423 avatar Oct 19 '16 13:10 ylhuang0423

I also have issues with the indentation: screen shot 2016-12-09 at 15 36 46

osenvosem avatar Dec 09 '16 12:12 osenvosem

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

chemzqm avatar Dec 19 '16 02:12 chemzqm

Just a heads up I had this same issue and fixed it by installing https://github.com/vim-scripts/JavaScript-Indent

liambutterworth avatar Mar 27 '17 03:03 liambutterworth

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: image

JESii avatar May 28 '17 20:05 JESii

@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.

mxw avatar Jul 14 '17 01:07 mxw

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.

marcus-grant avatar Jul 23 '17 05:07 marcus-grant

The update is that I can't repro this and nobody has given me a reduced ~/.vimrc that yields a repro.

mxw avatar Jul 23 '17 05:07 mxw

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! :)

emigre avatar Aug 06 '17 20:08 emigre

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.

emigre avatar Feb 05 '18 20:02 emigre

I have added:

filetype plugin indent on

Helped for me

slonofanya avatar Jun 25 '18 09:06 slonofanya