mxw / vim-jsx

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

Broken auto indentation #185

Open jonashaag opened 5 years ago

jonashaag commented 5 years ago

Using vim-javascript and vim-jsx, JSX indentation is horribly broken. I've reduce to a minimal .vimrc that is attached – same behaviour.

asciicast

jonashaag commented 5 years ago

home.tar.gz

jonashaag commented 5 years ago
VIM - Vi IMproved 8.1 (2018 May 18 kompiliert am Jan 24 2019 00:25:24)
MacOS Version
Inklusive der Patches: 1-800
Übersetzt von Homebrew
Riesige Version ohne GUI. Ein- (+) oder ausschließlich (-) der Eigenschaften:
+acl               +extra_search      +mouse_netterm     +tag_old_static
+arabic            +farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    -tcl
+autochdir         +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +textprop
+byte_offset       -hangul_input      +num64             +timers
+channel           +iconv             +packages          +title
+cindent           +insert_expand     +path_extra        -toolbar
-clientserver      +job               +perl              +user_commands
+clipboard         +jumplist          +persistent_undo   +vartabs
+cmdline_compl     +keymap            +postscript        +vertsplit
+cmdline_hist      +lambda            +printer           +virtualedit
+cmdline_info      +langmap           +profile           +visual
+comments          +libcall           -python            +visualextra
+conceal           +linebreak         +python3           +viminfo
+cryptv            +lispindent        +quickfix          +vreplace
+cscope            +listcmds          +reltime           +wildignore
+cursorbind        +localmap          +rightleft         +wildmenu
+cursorshape       +lua               +ruby              +windows
+dialog_con        +menu              +scrollbind        +writebackup
+diff              +mksession         +signs             -X11
+digraphs          +modify_fname      +smartindent       -xfontset
-dnd               +mouse             +startuptime       -xim
-ebcdic            -mouseshape        +statusline        -xpm
+emacs_tags        +mouse_dec         -sun_workshop      -xsmp
+eval              -mouse_gpm         +syntax            -xterm_clipboard
+ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save
          System-vimrc-Datei: "$VIM/vimrc"
        Benutzer-vimrc-Datei: "$HOME/.vimrc"
 zweite Benutzer-vimrc-Datei: "~/.vim/vimrc"
         Benutzer-exrc-Datei: "$HOME/.exrc"
      defaults Datei: "$VIMRUNTIME/defaults.vim"
     Voreinstellung für $VIM: "/usr/local/share/vim"
Übersetzt: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linken: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -lintl -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.14 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.28.1/lib/perl5/5.28.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation  -lruby.2.6     
dhilst commented 5 years ago

I'm facing this on Fedora 29 too, vim 8.1

dhilst commented 5 years ago
au! BufWrite *.jsx :normal gg=G``

This make it less anoying

scottdiemer commented 5 years ago

I've been having this issue also on Manjaro with vim 8.1. The indention is all over the place. It's been driving me crazy! I tried what dhilst recommended which helped some but it's still an issue

au! BufWrite *.jsx :normal gg=G``

tankorsmash commented 5 years ago

I'm dealing with a similar issue. Every time I insert > or <, the lines indentation gets increased in that direction. As a wild guess I've done set noai nosi noci but that didn't help any either, short of disabling this plugin.

Installed the other jsx plugin instead, https://github.com/MaxMEllon/vim-jsx-pretty, and things seem to work out better, so people might want to give that a shot if they can't resolve the issue here.

JESii commented 5 years ago

Suggest you switch to another JSX formatter -- this repo appears to have been abandoned. I've switched to neoclide/vim-jsx-improve and am very happy with the results.