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

Incorrect indentation #120

Open
olalonde opened this issue Oct 3, 2016 · 14 comments
Open

Incorrect indentation #120

olalonde opened this issue Oct 3, 2016 · 14 comments

Comments

@olalonde
Copy link

olalonde commented Oct 3, 2016

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

3smjs45lxj

@olalonde
Copy link
Author

olalonde commented Oct 3, 2016

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

zaj4bvsyzk

@olalonde
Copy link
Author

olalonde commented Oct 3, 2016

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

@olalonde
Copy link
Author

olalonde commented Oct 3, 2016

Looks like using

Plugin 'pangloss/vim-javascript'

instead of

Plugin 'othree/yajs.vim'

fixes the indentation issue.

@ylhuang0423
Copy link

ylhuang0423 commented Oct 19, 2016

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.

@osenvosem
Copy link

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

@chemzqm
Copy link

chemzqm commented Dec 19, 2016

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

@liambutterworth
Copy link

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

@JESii
Copy link

JESii commented May 28, 2017

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

@mxw
Copy link
Owner

mxw commented Jul 14, 2017

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

@marcus-grant
Copy link

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.

@mxw
Copy link
Owner

mxw commented Jul 23, 2017

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

@emigre
Copy link

emigre commented Aug 6, 2017

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

emigre commented Feb 5, 2018

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.

@slonofanya
Copy link

I have added:

filetype plugin indent on

Helped for me

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

10 participants