You are reading a single comment by @neshanjo and its replies. Click here to read the full conversation.
  • @JumJum Sorry for the delay and thanks very much for your code. This is exactly the kind of starting point I needed.

    Prettier doesn't need an internet connection, either. Here is what I did based on your initial example using prettier: https://github.com/neshanjo/EspruinoWebI­DE/tree/code-formatting-prettier
    Anybody here interested in this, can just checkout my fork and run npm install followed by npm start.

    My code also respects the indentation settings (tab width and tabs versus spaces).

    Indeed, there is still some work to do:

    1. Save the current cursor position
    2. Hide the icon in Blockly mode
    3. Add a keyboard shortcut
    4. Maybe another icon.

    I don't think, we need a settings page, though. I even think we should not have one in order to follow one code style. That's the idea behind prettier.

    I also made another branch using js-beautify: https://github.com/neshanjo/EspruinoWebI­DE/tree/code-formatting-js-beautify

    IMO, the main (only?) advantage of js-beautify over prettier is the smaller size. Prettier is more or less THE standard in modern JS development and available in many code editors and even from the command line. This is a nice feature, especially for BangleJS where every app uses its own code formatting style. Furthermore, it is actively developed by a large team, while js-beautify claims on their Github page that they are in need of more contributors.

    Just my 2ct. I'd be very happy to have any kind of code formatting soon.

    My next steps are to work on point 1 (see list above) and submit a MR. 2+3 should be done very easily by someone more familiar with the project.

About

Avatar for neshanjo @neshanjo started