mxw / vim-jsx

React JSX syntax highlighting and indenting for vim.
1.59k stars 95 forks source link

auto-indentation broken #63

Closed seadb closed 9 years ago

seadb commented 9 years ago

auto-indent doesn't work in jsx files for me currently specifically, chunks of code get un-indented automatically

For example, the "handleUserInput" function on line 36

step1 step2

mxw commented 9 years ago

It doesn't look like the syntax highlighting is on for you either. Did you follow all the installation instructions? If you're using the default settings, did you make sure to use the .jsx extension for your filename?

seadb commented 9 years ago

The file is named react.jsx and my status bar tells me that "javascript.jsx" is being used.

The syntax highlighting may look weird because I'm running vim on a virtual machine that I'm ssh-ed into. I'm also using ConEmu on top of that.

I'm using pathogen, so I just cloned the repo into my ~/.vim/bundle folder. Is there something additional I need to do?

mxw commented 9 years ago

Unless your VM -> emulator workflow gives you fewer than the standard eight terminal colors, you should at least have some amount of highlighting for the JSX components. It's possible the default XML syntax highlighting on your machine is not good?

There are a number of other things besides just cloning into ~/.vim/bundle that you need to do—e.g., set up pathogen, do syntax enable, etc., but if you see "javascript.jsx" as the language, you probably did those things correctly.

If you send me gists or pastes or other links to your code and your ~/.vimrc, I'll have a look when I get a chance.

seadb commented 9 years ago

I installed the vim-javascript highlighting which fixed it. I appreciate the help! https://github.com/pangloss/vim-javascript

mxw commented 9 years ago

_> Please read the README fully next time :]

seadb commented 9 years ago

It might be helpful to include the dependencies in the installation instructions. A lot of people just skip ahead to that.

jjhuff commented 9 years ago

Actually, I think that this was a bug at some point in vim-javascript. I followed the install instructions a month ago and had this problem. Today, I just pulled the latest head for both vim-jsx and vim-javascript and it's fixed.

seadb commented 9 years ago

Yeah I thought I already had vim-javascript installed. I guess when I re-cloned it fixed the problem. On Oct 22, 2015 5:00 PM, "Justin Huff" notifications@github.com wrote:

Actually, I think that this was a bug at some point in vim-javascript. I followed the install instructions a month ago and had this problem. Today, I just pulled the latest head for both vim-jsx and vim-javascript and it's fixed.

— Reply to this email directly or view it on GitHub https://github.com/mxw/vim-jsx/issues/63#issuecomment-150354814.

gma commented 9 years ago

I've just installed vim-jsx and vim-javascript (with Pathogen, so have the latest version of both) on Vim 7.3 (the version that ships with Mac OS X Yosemite).

I've got broken indentation in .js files, and have let g:jsx_ext_required = 0 in my .vimrc. Removing the vim-jsx bundle and restarting Vim lead to indentation working properly again.

mxw commented 9 years ago

Do you have a small example where the indentation breaks?

gma commented 9 years ago

Yes, this does it:

function() {                                                         
  var f = 1;                                                         

}

If I position my cursor after the semicolon on line 2 and hit enter, it ends up in column 1 on line 3.

The code then looks like this:

function() {                                                         
var f = 1;                                                         

}

I just discovered something interesting, that may or may not be useful. Line 2 was outdented when I positioned the cursor at the end of an existing line and pressed return. If I delete and then re-write line 2 without leaving insert mode and press enter, line 2 isn't outdented (but the cursor still ends up in column 1 of line 3).

mxw commented 9 years ago

I can't repro. Can you provide the git hashes for both vim-jsx and pangloss/vim-javascript?

gma commented 9 years ago

Thanks for trying. I've got mxw/vim-jsx@c6d0fd7d4d9d1e26c7643d02bb9abe5db91903c8 and pangloss/vim-javascript@1d8c2677d26d6b3950b90dc1636e63334c8efc3b.

mxw commented 9 years ago

Does the problem persist if you disable all other plugins you have in your Pathogen bundle? If so—can you send me a gist of your ~/.vimrc?

gma commented 9 years ago

You were on the right lines. I found I had some old ~/.vim/indent/{html,javascript}.vim files from 2011 that must have been interfering.

Deleting them got everything working beautifully. Sorry for the spam, and cheers for the plugin!