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

Change custom request types to LSP commands #473

Merged
merged 6 commits into from
Sep 8, 2024
Merged

Conversation

remcohaszing
Copy link
Member

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

LSP commands are the intended way to implement custom behaviour.

LSP commands are the intended way to implement custom behaviour.
@remcohaszing remcohaszing added 🦋 type/enhancement This is great to have 🗄 area/interface This affects the public interface 🧑 semver/major This is a change 🙆 yes/confirmed This is confirmed and ready to be worked on 👍 phase/yes Post is accepted and can be worked on labels Aug 30, 2024
Copy link

changeset-bot bot commented Aug 30, 2024

🦋 Changeset detected

Latest commit: 08da27f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@mdx-js/language-service Minor
@mdx-js/language-server Minor
@mdx-js/typescript-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This comment has been minimized.

Copy link
Member

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests look like they're failing 🤔


export const implementations = {
'mdx.toggleDelete': createSyntaxToggle('delete', '~'),
'mdx.toggleEmphasis': createSyntaxToggle('emphasis', '_'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn’t really matter. I know remark stringifies uses * in its output by default. I personally feel * is a bit overloaded. Emphasis and strong text share the same characters, but * is also used for list items. Also Prettier uses _, which I think added to making that character option more popular.

TL;DR I prefer _, but we can change it to * if you feel very strongly about it. This should be done in a follow-up PR though, as it’s an unrelated change.

Copy link
Member

@wooorm wooorm Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it not matter? Yes, it matters. _ and * get parsed differently. _ occurs more often in natural language.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both exist, but have relatively rare use cases in natural language. It’s really just a preference, and it’s ok your preference differs from mine.

I will change it in a follow-up PR anyway, as I believe the strongest argument is that it’s good to match the remark-stringify default. If we enable configurable formatting for #456, I think we should respect the same configuration optionn for syntax toggles.

@@ -146,3 +139,12 @@ export function createSyntaxToggle(context, type, separator) {
}
}
}

export const implementations = {
'mdx.toggleDelete': createSyntaxToggle('delete', '~'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where’s this word from, delete? Perhaps strikethrough is better. Also, it’s a GFM-only feature. And, 2 tildes work there too. One tilde was forbidden by the GFM spec for a while, until recently, even though it worked.

Copy link
Member Author

@remcohaszing remcohaszing Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete is the mdast node type. Based on your comment, I agree inserting 2 tildes is better. This changed be done in a follow-up PR though, as it’s an unrelated change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn’t particularly have to match the node type, as it’s injecting into a document.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s a toggle. It either injects or removes, depending on whether the cursor position matches a node of this type.

@remcohaszing
Copy link
Member Author

The tests look like they're failing 🤔

Yes, because of a timing issue. I think we were just lucky the tests weren’t failing before. I’ll look into it.

@johnsoncodehk
Copy link
Contributor

The failing test is due to the fact that the language feature was never triggered on the test file and therefore the language service instance was not established. The issue has been fixed by volarjs/volar.js@e53022a.

Commands now use a switch to differentiate between commands. Existing
logic was too clever. The currently existing commands are similar, but
future commands might not be. The new pattern is more flexible.
This means clients need to implement less custom logic.
It’s no longer used in production code.
@remcohaszing
Copy link
Member Author

I’ll merge this as-is and process the comments in follow-up PRs.

@remcohaszing remcohaszing merged commit 2854c38 into main Sep 8, 2024
8 checks passed
@remcohaszing remcohaszing deleted the lsp-commands branch September 8, 2024 14:32

This comment has been minimized.

@github-actions github-actions bot mentioned this pull request Sep 8, 2024
@remcohaszing remcohaszing added the 💪 phase/solved Post is done label Sep 8, 2024
@github-actions github-actions bot removed 👍 phase/yes Post is accepted and can be worked on 🙆 yes/confirmed This is confirmed and ready to be worked on labels Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗄 area/interface This affects the public interface 💪 phase/solved Post is done 🧑 semver/major This is a change 🦋 type/enhancement This is great to have
Development

Successfully merging this pull request may close these issues.

4 participants