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

Support for MyST #312

Closed
alcarney opened this issue Mar 7, 2022 · 9 comments
Closed

Support for MyST #312

alcarney opened this issue Mar 7, 2022 · 9 comments
Labels
enhancement New feature or request lsp Issues that relate to the language server

Comments

@alcarney
Copy link
Member

alcarney commented Mar 7, 2022

MyST is a flavour of markdown that is compatible with Sphinx.
It should be possible to add just by calling out to the existing directive/roles logic where applicable

@alcarney alcarney added enhancement New feature or request lsp Issues that relate to the language server labels Mar 7, 2022
@haiyangToAI
Copy link
Contributor

Hi @alcarney,

I like the idea of Esbonio to support Sphinx directives and roles for MyST/Markdown files. It will be helpful.

Directives and roles in MyST/Markdown look like this, see MyST Docs:

  • directive patterns:

    • Using YAML frontmatter for directive options:

       ```{directivename} arguments
       ---
       key1: val1
       key2: val2
       ---
       This is
       directive content
       ```
      
    • Using short-hand options with : characters

       ```{directivename} arguments
       :key1: val1
       :key2: val2
      
       This is
       directive content
       ```
      
    • Using eval-rst directive

       ```{eval-rst}
       .. {directivename}:: arguments
          :key1: val1
          :key2: val2
      
          This is directive content.
       ```
      
  • role pattern

    • {role-name}role content

To support directives and roles for MyST/Markdown, Esbonio need to:

  • For directives:

    * if {eval-rst} used, then it's no different as rst file. Esbonio language server doesn't need to do anything.
    
    * if pattern ```{directive} used, then Esbonio need to add new trigger, the { character,  left curly bracket, then check string pattern starts with ```{.
    
    * if directive option using YAML frontmatter, the triger for options can be tricky, maybe need another trigger, but don't know how yet.
    
    * if directive option using : character, then it's the same for rst file. Esbonio does not need to do anything.
    
  • For roles:

    • Esbonio need to add new trigger, the { character.

What do you think this approach? @alcarney @danwos

By adding a new trigger {, then Esbonio can already support roles and directives that using short-hand options and eval-rst. If you think this is the way, then I will prepare a PR.

@alcarney
Copy link
Member Author

Overall it makes sense, though I did do a very basic proof of concept for roles a while ago and so have some thoughts on how I think the implementation should look :)

  • It should be a separate LanguageFeature, that way it can easily be enabled/disabled by the user
  • On the note of trigger characters, I'd like to tweak the LanguageFeature API so that features can declare the trigger characters they'd like to use. This should prevent features from being limited by whatever the 'core' has decided a trigger character should be. I've opened Language features should be able to contribute completion triggers. #413 to track this.
  • I wondering if completions in the Roles and Directives features should be split into two stages - perhaps suggest and complete. Where suggest simply generates a list of candidates and complete converts them into CompletionItems. This would allow the MyST feature to call out to the Roles and Directives features for suggestions but handle the markdown formatting itself.

Of course, it would take quite a while to line all that up and probably only the first point is necessary to get something shipped so happy to go and forth on this a bit.

Let me know your thoughts 😄

@davbeek
Copy link

davbeek commented Jul 13, 2022

I am completely new to MyST, had a look at some online documentation and must say that it looks very promising. I would like to try and switch to MyST, when supported by esbonio.

@astrojuanlu
Copy link
Contributor

Yes please 🙏🏽 I've been using MyST for 2 years and I'm not looking back (disclaimer: I wrote the Sphinx tutorial https://www.sphinx-doc.org/en/master/tutorial/ and worked at Read the Docs for 1 year)

@alcarney
Copy link
Member Author

alcarney commented Oct 9, 2023

It's definitely on the list for the 1.0 release :)

@alcarney
Copy link
Member Author

There is now a hint of MyST support in the current pre-release of the language server v1.0.0b1

To quote myself from another thread

The beginnings of MyST support!

  • Assuming you have the relevant dependencies installed, builds and previews of MyST source files should mostly "Just Work"TM
  • Document symbols, workspace symbols and diagnostics should also mostly work
  • Limited support for completions of directives (::: syntax and nested directives not currently supported)

@chrisjsewell
Copy link

FYI you might want to consider adding https://github.com/chrisjsewell/vscode-myst-syntax in the extensionDependencies

@alcarney
Copy link
Member Author

Thanks, that looks useful! :)

@alcarney
Copy link
Member Author

Closing in favour of smaller, focused issues.
The current pre-release has MyST support for all currently implemented features

@github-project-automation github-project-automation bot moved this from Todo to Done in Esbonio Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lsp Issues that relate to the language server
Projects
Status: Done
Development

No branches or pull requests

5 participants