vscode-todo-highlight icon indicating copy to clipboard operation
vscode-todo-highlight copied to clipboard

Options should support the per-language feature

Open tobiasdiez opened this issue 5 years ago • 6 comments

It would be nice if one could apply different highlights in different file types. For example, the following should highlight only in java files:

"[java]": {
    "todohighlight.keywords": [ "why do you use java in the first place??" ]
}

For this, the scope needs to be set to language-overridable I think, see https://code.visualstudio.com/api/references/contribution-points#contributes.configuration.

Ps: Thanks for revive this extension!

tobiasdiez avatar Jul 28 '20 20:07 tobiasdiez

Thanks for the issue and suggestion, @tobiasdiez. I've added language-overridable scope to the keywords configuration item. In my testing this doesn't work, with additional ones ignored in a [markdown] configuration section.

But perhaps it will for you? Please try installing https://github.com/jgclark/vscode-todo-highlight/blob/jgclark/issue2/vscode-todo-highlight-1.2.3.vsix to try this out.

I'm learning VSC as I go, so at the moment I don't know how I might set about finding what the problem is. If you know more, please send me a PR.

jgclark avatar Jul 31 '20 23:07 jgclark

Did this work for you @tobiasdiez ? I've now published this new version to the Marketplace, so it would be good to know. Thanks.

jgclark avatar Sep 19 '20 21:09 jgclark

Thank you and all the contributors for reviving this project with regex.

jon-a-miller avatar Nov 18 '20 19:11 jon-a-miller

Thanks, @jon-a-miller. Please do rate the extension on the marketplace, so more can find it.

On Wed, 18 Nov 2020 at 19:57, jon-a-miller [email protected] wrote:

Thank you and all the contributors for reviving this project with regex.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/jgclark/vscode-todo-highlight/issues/2#issuecomment-729918741, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMYESXLY7CBQR73OY5KBDTSQQRLHANCNFSM4PK3YNYQ .

-- -- Jonathan

jgclark avatar Nov 19 '20 10:11 jgclark

Sorry for the late feedback. In the most recent version, one can specify language-specific settings (at least VS code is no longer complaining), but as you say above these keywords are ignored.

I think the problem is that getConfiguration here https://github.com/jgclark/vscode-todo-highlight/blob/8681f3d356a6b96e2264bd2fbef32ca3e17d9284/src/extension.js#L19 is called without the scope parameter (see https://code.visualstudio.com/api/references/vscode-api#workspace for docs). And this second parameter only gives the language-specific settings back. Thus one probably needs to update the settings in the onDidChangeActiveTextEditor event, and passes the active document to getConfiguration.

tobiasdiez avatar Sep 11 '21 12:09 tobiasdiez

For my info from the API:

/**
 * Read language configuration.
 */
const textDocumentConfiguration = vscode.workspace.getConfiguration('sample', {resource, languageId});
textDocumentConfiguration.get('languageSetting');

/**
 * Listen language configuration changes
 */
workspace.onDidChangeConfiguration(e => {
    if(e.affectsConfiguration('sample.languageSetting',  {resource, languageId}) {
    }
});

Also, languageId comes from workspace.TextDocument[].languageId and is a string, typically lowercased programming language name.

jgclark avatar Oct 01 '21 21:10 jgclark