-
-
Notifications
You must be signed in to change notification settings - Fork 180
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
feat: languages (identifiers) as setting #368
base: main
Are you sure you want to change the base?
Conversation
This PR does not seem to address the activation concerns I raised in the issue you link to: #228 (comment) Or, rather, it tries to by using the I consider that bad behavior by an extension (imagine if they all behaved that way) and it's why I tagged the issue |
Sorry, I initially aimed to open this as draft as I was still tinkering with the code mostly for the points in your comment. A middle ground could be to keep the current activation event, but keep the settings to allow markdownlint to lint any kind of files. What do you think? (current version of the PR) Screen.Recording.2025-02-02.at.00.35.34.mov |
FWIW, the first attempt ( |
The addition of the setting (no changes in activation conditions) will allow to use "activationEvents": [
"onLanguage:quarto"
],
"contributes": [
"configurationDefaults": {
"markdownlint.languages": [
"markdown",
"quarto"
]
}
] const extensionsToActivate = ["DavidAnson.vscode-markdownlint"];
extensionsToActivate.forEach(async (extensionId) => {
const extension = await vscode.extensions.getExtension(extensionId);
LOG.appendLine(`Activating ${extensionId}...`);
if (extension) {
if (!extension.isActive) {
await extension.activate();
}
LOG.appendLine(`${extensionId} activated.`);
} else {
LOG.appendLine(`Failed to activate ${extensionId}.`);
}
}); |
What thing are you suggesting should contain the configuration above for "onLanguage:quarto"? If that's not present in the configuration for THIS extension, it will not be activated for quarto files and will not perform linting if a quarto file is opened (unless the extension has already been loaded for some other reason - but that's unpredictable). This is the essence of the problem: if languages are to be configurable, the metadata for this extension must ALSO be updated (as far as I know) - and that's not possible for a user to do. |
The code (#368 (comment)) about how to activate markdownlint is to be added not by markdownlint (you) but by anyone wanting to use markdownlint to lint files that has not "markdown" as language identifier, "quarto" VSCode extension to use markdownlint on Quarto files, VSCode-R to add support for RMarkdown documents, etc. The only thing needed for that is the current change in the PR, the Sorry if I was not clear. |
I don't think these questions have good answers, which is why I don't think this feature is practical today. |
-> it means opening the file won't trigger activation but opening a markdown file and going back to the other will work as an activated extension is not deactivated.
-> Same as above.
-> There is no convincing. If the developers of a markdown-like language wants support markdownlint, they will otherwise, they won't. It will be up to the developers. No burden for you or maybe user asking why it's not working (that's already the case).
-> That's documentation and messages, but again a note in the description would shift the burden on the developers of markdown-like languages. For instance, the
To be sure I understand what you are saying here, does it mean you prefer to block any support at all rather than offers the ability for other to extend your extension support via their own extension and a setting? (I'm fine if the answer is yes, it would only mean to fork your entire extension) |
To be clear, I fully agree that this is not perfect but the issue is opened on VSCode since November 2017. |
Please feel free to close the PR if the setting it's adding is not desirable for you. I would not want to take up any more of your time. Thank you for your work on |
I don't want behavior to be inconsistent, so I'm not ready to accept this PR. However, I'm on the fence about the suggestion in the issue you link to and if that's a reasonable approach in practice, then my concerns here are mostly addressed. I need to play around with that approach myself to see how well it works, especially in the context of bundling and in the web (versus desktop) editor scenario. I'm going to leave this PR open for now and will follow up once I do some experimentation there. |
Thanks for considering! |
I edited one of my message and in case you did not see, it's possible (actually it should) for an extension to declare other extensions as dependencies via |
@alexdima, is the "iceberg" approach you recommend in microsoft/vscode#38125 (comment) still considered the best workaround? Are there any tips on implementing that with bundling and in web context? |
Introduce a new configuration setting for specifying an array of language identifiers to lint. This enhancement broadens the "activation" function to include multiple languages, allowing for improved handling of documents beyond just Markdown such as RMarkdown and Quarto without maintenance burden.
Note that language identifiers provided won't trigger the activation of the extension, only the presence of a file with the language identifier being
markdown
will.The settings will only only linting of any files in a workspace with one
markdown
file.Fixes partially #228 as extension activation is delegated to other extensions.