Coder Social home page Coder Social logo

Breaks JS indenting about vim-jsx HOT 35 CLOSED

mxw avatar mxw commented on June 8, 2024
Breaks JS indenting

from vim-jsx.

Comments (35)

JofArnold avatar JofArnold commented on June 8, 2024 5

I had this issue. Turns out it was conflicting with sheerun/vim-polyglot. Removed that plugin and everything is fine.

For anyone else having this issue, grep for javascript.vim and see where it appears. Then selectively remove those which aren't vim-jsx, vim-javascript

from vim-jsx.

mxw avatar mxw commented on June 8, 2024

I'm unable to repro this. My best guess is that you aren't using pangloss's https://github.com/pangloss/vim-javascript syntax and indentation, which is a dependency specified in the README.

If you aren't, including that bundle should fix your issue. If you are, can you give me a list of the bundles you are using, and possibly a link or paste to your .vimrc?

from vim-jsx.

mxw avatar mxw commented on June 8, 2024

Oh, but if you aren't using vim-javascript, I would expect the syntax to break, too... hm.

from vim-jsx.

imiric avatar imiric commented on June 8, 2024

Yeah, I was definitely using vim-javascript. I've uninstalled both plugins now, but here's my .vimrc (sorry, it's a mess).

from vim-jsx.

mxw avatar mxw commented on June 8, 2024

Would you mind seeing what happens if you comment out all your plugins except for vim-javascript and vim-jsx? If indenting in a new vim session still doesn't work right, then something is very wrong—vim-jsx should definitely be indenting both JSX and regular JS correctly.

If commenting out all the other plugins fixes the issue, you can try adding back each plugin individually to see which one commits, at which point I can take a look. No guarantees though in that case—plugin conflicts are sort of just par for the course when you have a lot of plugins though (especially one like mine which tries to reach into existing language plugins and muck around with things).

from vim-jsx.

imiric avatar imiric commented on June 8, 2024

Uff, that sounds like a lot of work, and I was only using this plugin for highlighting HTML in JSX files, which I can live without. Is there any way you can make the syntax highlighting a separate plugin?

from vim-jsx.

mxw avatar mxw commented on June 8, 2024

Just the first of those (i.e., commenting out your other plugins) should be pretty quick, right? If it's still broken after that, it's probably vim-jsx's fault, and I'll give you a fix.

Also, just noticed this—I don't actually know how Vundle works, but in their README, they have filetype off before the vundle#rc() or vundle#begin() invocation and list of plugins. If you move that line to the top of the file, do things get better?

If neither of these reveals the issue and it's just a plugin conflict you don't want to dig into, I don't want to split off the syntax and indentation (especially since one relies on the other)—your best be in that case is just to wipe away the after/indent directory locally.

from vim-jsx.

imiric avatar imiric commented on June 8, 2024

I'll look into it when I have some free time and let you know. If I don't reply to this issue in a week or two, feel free to close it. :)

Thanks for your help!

from vim-jsx.

julienaubert avatar julienaubert commented on June 8, 2024

I had the same issue, and.. had missed pangloss/javascript - works fine.

from vim-jsx.

blast-hardcheese avatar blast-hardcheese commented on June 8, 2024

Same here, somehow pangloss/javascript had gotten commented out-- putting it back resolved this issue for me.

from vim-jsx.

mxw avatar mxw commented on June 8, 2024

@imiric—If you figure out the conflicting bundle, let me know and I can try to fix things for you. Closing for now.

from vim-jsx.

jarodtaylor avatar jarodtaylor commented on June 8, 2024

I'm having this same issue and I have pangloss/vim-javascript loaded.

from vim-jsx.

mxw avatar mxw commented on June 8, 2024

@jarodtaylor—Can you send me a paste or a gist of your ~/.vimrc?

from vim-jsx.

jarodtaylor avatar jarodtaylor commented on June 8, 2024

I'm using a dotfiles config so I am using .local on my configs. So this is just "my" vimrc.local file.

set number
set t_ti= t_te=
set ts=2

set smarttab
set nolist
set tabstop=2
set expandtab
set shiftwidth=2
set softtabstop=2

set background=dark
let g:solarized_visibility = "high"
let g:solarized_contrast = "high"
colorscheme solarized

let g:user_emmet_expandabbr_key = '<C-g>'
let g:use_zen_complete_tag = 1

let g:jsx_ext_required = 0

from vim-jsx.

mxw avatar mxw commented on June 8, 2024

@jarodtaylor—If that's your entire config, you don't have this package included...

from vim-jsx.

musically-ut avatar musically-ut commented on June 8, 2024

The reason for my woes along similar lines turned out to be a stray javascript.vim file in my local computer's .vim/indent folder. Removing that file did the trick for me.

It is a little surprising that a file took precedence over the plugins I had installed (using vim-plug). I wonder if vundle and pathogen also yield precedence in similar ways or whether this is hard-coded within vim.

from vim-jsx.

Goblinlordx avatar Goblinlordx commented on June 8, 2024

Had this same issue and removed the /indent/javascript file to resolve this.

from vim-jsx.

xream avatar xream commented on June 8, 2024

If you use vim-plug, this may help: Plug 'mxw/vim-jsx', { 'do': 'rm ~/.vim/plugged/vim-jsx/after/indent/jsx.vim' }

from vim-jsx.

musically-ut avatar musically-ut commented on June 8, 2024

@xream But that will remove the indentation-aid for XML embedded in the Javascript.

from vim-jsx.

patreeceeo avatar patreeceeo commented on June 8, 2024

I was having the same issue, then I commented out the entire contents of ~/.vim/plugged/vim-jsx/after/indent/jsx.vim, restarted vim then autoindent was working again in my javascript (but not in the embedded html, of course). I think that's good evidence that the problem is with that file.

from vim-jsx.

mxw avatar mxw commented on June 8, 2024

...or it conflicts with some other file from some other package.

from vim-jsx.

webOS101 avatar webOS101 commented on June 8, 2024

I'm also having the same issue with the broken indent. Happy to help trace this down. I don't seem to have a stray .vim/indent folder. Am using vim-javascript.

from vim-jsx.

webOS101 avatar webOS101 commented on June 8, 2024

As a followup, I disabled all add-ons except vim-javascript and vim-jsx and i still have the issue. This is running on MacVim with pathogen, if that's relevant.

from vim-jsx.

webOS101 avatar webOS101 commented on June 8, 2024

In debugging further I discovered I had somehow deleted the contents of my vim-javascript folder. Once I restored the contents of the folder, it was all good again. 😭

from vim-jsx.

micheleb avatar micheleb commented on June 8, 2024

I also had a javascript.vim file (in my ~/.vim/syntax folder) which prevented vim-jsx from working, but what fooled me was that I was using js as FileType in my .vimrc to set 2-space tabs for javascript files, when I should have used javascript.jsx. This is the correct line:

au FileType javascript.jsx setlocal sw=2 sts=2 et

from vim-jsx.

mxw avatar mxw commented on June 8, 2024

javascript should be fine there. Are you sure there wasn't another intervening file that was setting up a different autocmd?

from vim-jsx.

micheleb avatar micheleb commented on June 8, 2024

javascript works, too, thanks. But I wrote js, which didn't.

from vim-jsx.

wincent avatar wincent commented on June 8, 2024

Was broken for me too, fixed by updating from d0ad98c to eb656ed. (Didn't bother to bisect.)

from vim-jsx.

StandardNerd avatar StandardNerd commented on June 8, 2024

I removed (respectively renamed) vim-jsx/after/indent/jsx.vim - file and got proper indentation in jsx again.

from vim-jsx.

ObserverZero avatar ObserverZero commented on June 8, 2024

I am having this problem as well. I'm currently using NeoVim, is that a problem? Here is my init.vim:

[deprecated]

from vim-jsx.

mxw avatar mxw commented on June 8, 2024

@ObserverZero—Do you really need everything in that config in order to repro? Could you try to trim down until you have a minimal repo ~/.vimrc?

from vim-jsx.

ObserverZero avatar ObserverZero commented on June 8, 2024

Ok, I've taken out what must be irrelevant.

"-----------------------LOADING PACKAGES--------------------
source ~/.config/nvim/autoload/autoclose.vim
source ~/.config/nvim/autoload/plug.vim
source ~/.config/nvim/autoload/pathogen.vim
source ~/.config/nvim/autoload/common-functions.vim
source ~/.config/nvim/autoload/indent-object.vim
source ~/.config/nvim/autoload/type_helpers.vim
source ~/.config/nvim/autoload/kwbd.vim
source ~/.config/nvim/autoload/syntastic-conf.vim
source ~/.config/nvim/autoload/restore_view.vim
source ~/.config/nvim/bundle/vim-slime/plugin/slime.vim
"-----------------------------------------------------------

"----------SETS VIM LANGUAGE AND MINIMAL INTERFACE----------
lan en_US
set nosmd
set noru
set noshowmode
set laststatus=0
set linebreak
set fo+=t
set cmdheight=1
set ignorecase
set autoindent
set smartindent
set incsearch
set fillchars=" "
set nocompatible
set hidden
set t_Co=256
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab|retab
set clipboard=unnamed
execute 'highlight FoldColumn ctermbg=0'
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
filetype plugin on
"-----------------------------------------------------------

" ------------------JS SYNTAX AND REACT NATIVE--------------
let g:jsx_ext_required = 0
set conceallevel=1
filetype plugin indent on
filetype off
"-----------------------------------------------------------

"------------------------PLUG MODULES-----------------------
call plug#begin('~/.config/nvim/plugged')

Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'justinmk/vim-sneak'
Plug 'tpope/vim-surround'
Plug 'junegunn/fzf.vim'
Plug 'altercation/vim-colors-solarized'
Plug 'critiqjo/lldb.nvim'
Plug 'honza/vim-snippets'
Plug 'chrisbra/NrrwRgn'
Plug 'wellle/targets.vim'
Plug 'flazz/vim-colorschemes'
Plug 'kana/vim-textobj-user'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
call plug#end()
"-----------------------------------------------------------

from vim-jsx.

mxw avatar mxw commented on June 8, 2024

So your issue only repros when you have all those plugins enabled? If not, please disable them until you figure out the minimal possible ~/.vimrc which repros.

from vim-jsx.

mvattuone avatar mvattuone commented on June 8, 2024

I've noticed that if I have let g:jsx_ext_required = 0 in my ~/.vimrc, this issue occurs.

As soon as I comment it out, I am able to indent again.

from vim-jsx.

rogeriopvl avatar rogeriopvl commented on June 8, 2024

I used a customized version of @xream 's suggestion:

Plug 'sheerun/vim-polyglot', { 'do': 'rm ~/.vim/plugged/vim-polyglot/after/indent/javascript.vim' }

This fixed the problem. The vim-polyglot indent file should be irrelevant enough for not having a noticeable impact.

from vim-jsx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.