Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML (JSON) schema for the config file? #206

Closed
kachkaev opened this issue Jun 7, 2020 · 14 comments
Closed

YAML (JSON) schema for the config file? #206

kachkaev opened this issue Jun 7, 2020 · 14 comments
Labels
documentation focused on updating the documentation; files to be updated are documentation/*.tex enhancement enhancement which might be to an existing feature or the development of a new feature feature-request user-centred feature request for an enhancement to an existing feature, or for a new feature implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix

Comments

@kachkaev
Copy link

kachkaev commented Jun 7, 2020

👋 @cmhughes, may thanks for creating latexindent!

I’m new to the tool, so haven’t got much further than creating latexindent.yaml in my LaTeX Project and configuring VSCode LaTeX Workshop to apply my local config file on save.

settings.json
{
  "latex-workshop.latexindent.path": "/usr/local/texlive/2020/texmf-dist/scripts/latexindent/latexindent.pl",
  "[latex]": {
    "editor.defaultFormatter": "James-Yu.latex-workshop"
  },
  "latex-workshop.latexindent.args": [
    "--local",
    "%DIR%/latexindent.yaml",
    "--modifylinebreaks",
    "-cruft",
    "%DIR%/",
    "%TMPFILE%"
  ]
}

My feature request is about the user experience for editing latexindent.yml. At the moment, the only way to know which options are valid is to read latexindent pdf or the website. If there is a typo in the config key of if a key is under a wrong section, there is no feedback until some tex file is saved. Besides, there is no intellisense (autocompletion) for keys and values.

VSCode can read YAML (JSON) schemas and thus significantly improve the UX. Here is an example of what autocompletion looks like when I edit a Kubernetes deployment or ESLint config:

Screenshot 2020-06-07 at 12 41 21


Screenshot 2020-06-07 at 13 00 22


Screenshot 2020-06-07 at 13 00 47

Autocompletion for ESLint seems to come from https://json.schemastore.org/eslintrc, because somebody once contributed to https://www.schemastore.org/json/ and VSCode picked that up. The k8s schemas probably come from a corresponding VSCode extension – I haven’t fully traced that.

YAML / JSON schemas are not only useful for intellisense, but can also be picked by linting tools such as yaml-schema-validator (I'm sure there are plenty of such of a kind).

A schema for latexindent.pl YAMLs can enable some nice scenarios, so it’d be great if you could consider creating it. What do you think?

@kachkaev kachkaev changed the title Schema for the config file? YAML (JSON) schema for the config file? Jun 7, 2020
@cmhughes
Copy link
Owner

cmhughes commented Jun 7, 2020

Hi @kachkaev ,
Many thanks for this, it sounds like an interesting idea, and it's always good to try to improve the user experience

The links you've provided should help me to look into this, thank you.

As I do so, could you help me with the following questions:

  • is VSCode available for Linux?
  • would other editors (such as vim, for example) have natural ways to connect with this...?

Thanks again!
Chris

@kachkaev
Copy link
Author

kachkaev commented Jun 7, 2020

Thanks for your reply and for the potential interest @cmhughes!

is VSCode available for Linux?

Yep, VSCode has *.deb and *.rpm distributions: https://code.visualstudio.com/download

There’s also https://vscodium.com, which is the same editor, but built by the community instead of Microsoft.

would other editors (such as vim, for example) have natural ways to connect with this...?

I believe so, yes. YAML / JSON schemas are a pretty wide-spread concept, so I’m sure there is a solid integration into many editors and other tools. I first encountered it long before switching to VSCode a few years ago.

Check out this page for example: https://vega.github.io/editor/#/examples/vega-lite/rect_binned_heatmap. Because the JSON starts with "$schema": "https://vega.github.io/schema/vega-lite/v4.json", the rest of the document can be statically analysed to a certain extent. Try replacing "width" with "widthx" or shorten it down to "w" and press ctrl+space.

Since JSON and YAML files are essentially the same thing, a once-generated schema is applicable to both formats. The spec can be found at https://json-schema.org

@cmhughes
Copy link
Owner

cmhughes commented Jun 7, 2020 via email

@cmhughes cmhughes added enhancement enhancement which might be to an existing feature or the development of a new feature feature-request user-centred feature request for an enhancement to an existing feature, or for a new feature labels Jun 9, 2020
@cmhughes cmhughes added the documentation focused on updating the documentation; files to be updated are documentation/*.tex label Aug 1, 2021
@cmhughes cmhughes added the Help-wanted I'd like assistance with this issue, please! label Nov 26, 2021
@cmhughes
Copy link
Owner

If anyone feels like taking this on (or, simply starting it), please do feel free. All pull requests to the develop branch :)

@cmhughes
Copy link
Owner

Very sorry for the delay on this. Development is slow at the moment for various reasons.

If anyone feels like starting it, please feel free :) all pull requests to develop branch.

@cmhughes
Copy link
Owner

cmhughes commented Jan 1, 2022

@kachkaev some good news, I've made created https://github.com/cmhughes/latexindent.pl/blob/develop/documentation/latexindent-yaml-schema.json :) It's on the develop branch.

If you'd like to take a look, I'd welcome any feedback. Documentation is in https://github.com/cmhughes/latexindent.pl/blob/develop/documentation/appendices.tex :)

@cmhughes cmhughes added the implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix label Jan 1, 2022
@kachkaev
Copy link
Author

kachkaev commented Jan 1, 2022

Hi @cmhughes 👋 That’s great news indeed, thanks a lot for your effort!

I’m not actively working on any LaTeX documents at the moment, so won’t be able to check out the new feature any time soon – sorry. I’m sure I’ll benefit from it next time, so thanks a lot again! And a happy New Year! 🎉

@cmhughes
Copy link
Owner

cmhughes commented Jan 2, 2022

@kachkaev many thanks, that's great :)

I've implemented this as of https://github.com/cmhughes/latexindent.pl/releases/tag/V3.13.5 and have uploaded it to ctan.

Improvements and feedback welcome as and when you (and others) come to it. Happy new year!

@cmhughes cmhughes closed this as completed Jan 2, 2022
@cmhughes cmhughes removed the Help-wanted I'd like assistance with this issue, please! label Jan 2, 2022
@cmhughes
Copy link
Owner

cmhughes commented Jan 2, 2022

Relevant part of documentation at https://latexindentpl.readthedocs.io/en/latest/appendices.html#latexindent-yaml-schema-json

@Freed-Wu
Copy link

Freed-Wu commented Jan 11, 2024

@cmhughes
Copy link
Owner

If you can make this happen using github actions, contrubuitions welcome!

@Freed-Wu
Copy link

schema store needs a URL. https://github.com/SchemaStore/schemastore/pull/3510/files#diff-1b8f038f5afb1158263a1fc83b9c0ca5a7438cceb90adad99d87168f70edc815R476

Keep the json schema's URL not changed is OK to get updated 😄

@cmhughes
Copy link
Owner

cmhughes commented Jan 11, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation focused on updating the documentation; files to be updated are documentation/*.tex enhancement enhancement which might be to an existing feature or the development of a new feature feature-request user-centred feature request for an enhancement to an existing feature, or for a new feature implemented implemented tag means that either an enhancement or feature request has been implemented, or bugfix
Projects
None yet
Development

No branches or pull requests

3 participants