0

I just figured out how to combine those creepy plugins to work together to achieve the following auto-indent:

before / after pressing o:

But then this only works on file extension .jsx as shown above, while most of the legacy files I'm working on have file extension .js but all using .jsx syntax, and in those files the above behaviour won't work:

before / after pressing o:

As you can see the indentation is incorrect. So as my title, how can I make (neo)Vim consider all .js as .jsx by default?

7
  • source the jsx indent scripts in your js filetype configuration – Christian Brabandt Apr 23 at 10:00
  • 2
    See :help new-filetype. Either of the techniques in section A or C will work. – Rich Apr 23 at 10:33
  • Please don't post images of text. I'm inclined to agree that this is a duplicate of vi.stackexchange.com/questions/13623/…; does it answer your question? – D. Ben Knoble Apr 23 at 13:31
  • @D.BenKnoble: I'm not sure about it, since all of these settings about indentation are from some plugins I downloaded. I imported these plugins in my .vimrc file, and some of them work without additional settings while others require some variables like let g:closetag_filenames = '*.js,*.jsx,*.html,*.xhtml,*.phtml' to be set/customized. But what I want to achieve is let .js be seen as .jsx from the perspective of plugin-in makers. – job_start Apr 23 at 14:36
  • 1
    @job_start Switching the filetype should be enough to do that; alternatively, as Christian points out, you can make your js filetype :runtime[!] scripts for jsx. If this is plugin specific, please edit the question with all the relevant details. – D. Ben Knoble Apr 23 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.