Coder Social home page Coder Social logo

Support for Airbnb-style indentation about vim-jsx HOT 5 CLOSED

mxw avatar mxw commented on June 8, 2024
Support for Airbnb-style indentation

from vim-jsx.

Comments (5)

mxw avatar mxw commented on June 8, 2024

@ksmithbaylor—vim-jsx uses vim's native XML indentation to auto-indent within JSX blocks. It seems like your preference is not supported natively, so this is a wontfix.

Note that, historically, Facebook favored this style in all of its inline-XML fragments:

<Foo
  lol="lolololol"
  haha="hahahahahahah">
  <Bar />
</Foo>

This conveniently is also the style implicitly recommended by vim's XML support—you could consider changing your style guide to match this (more common? more prescribed?) styling.

from vim-jsx.

ksmithbaylor avatar ksmithbaylor commented on June 8, 2024

Got it. I understand why it can't be easily implemented, but I still think it has some merit.

The reason why I prefer the closing angle bracket on its own line (which admittedly looks uglier) is so that I can re-order, add, and remove props without having to think about moving it.

Since the Airbnb style guide is fairly popular in the React community (I don't work for Airbnb, I just like their guide), especially their eslint configuration (which I see used everywhere in various projects), is it infeasible to implement this behind an optional flag? Can the behavior that governs this behavior in vim's native XML indentation be overridden when this plugin is active?

I may be speaking out of ignorance, as I have never implemented a vim plugin and don't understand all the semantics.

from vim-jsx.

mxw avatar mxw commented on June 8, 2024

vim-jsx doesn't implement XML indentation at all—it relies on whatever XML indentation vim ships with to indent XML fragments. It does likewise with JS. vim-jsx merely glues two separate syntax and indentation packages together. Its surface area is very minimal, and I doubt it will ever include custom support for either sub-language.

This means that if you want a particular indentation for XML, you have to take it up with the indent/xml.vim script that shipped with your vim distro. If it supports your style, then your style is supported by vim-jsx; otherwise, it's not.

If your style is supported by another XML vim plugin, you should be able to hook that into vim-jsx (you may not even have to do anything but have it installed with your plugin manager).

from vim-jsx.

ksmithbaylor avatar ksmithbaylor commented on June 8, 2024

Okay, thanks! I'll give it a try.

from vim-jsx.

lencioni avatar lencioni commented on June 8, 2024

@ksmithbaylor I know this doesn't really solve your problem, but you can achieve the ESLint configuration that will support Vim's default closing bracket alignment by using the following configuration:

"jsx-closing-bracket-location": [2, {
  "nonEmpty": "props-aligned",
  "selfClosing": "tag-aligned"
}]

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.