It currently checks ALL text in a document.
It would be nice to have the option to check only strings (quoted string literals and comments).
I can see how that could be useful.
Don't get me wrong, the fact that this plugin provides a way to check camelCase method names, etc. is unique and often useful. The problem is it shows 200 warnings in just a part of a file. Sometimes I have time to add those words to the dictionary, and sometimes I don't.
Ahh, thank you for the clarification. My goal is to make adding words to your personal/project dictionary a one click action.
Question: are most of the words "keywords" in a programming language or library? Or are they part of your naming convention?
Some examples:
struct keyword, strconv package name, omitempty tag value. In fact, this list can be generated automatically.Samsung, TODO.wasn't is marked since wasn is not a valid word.If you get me a list of Go keywords and common library names, I'll add them.
A future enhancement is to have keywords per language (Go, PHP, C#, etc.) that way someone can program in French and the keys words would still be correct.
If you get me a list of Go keywords and common library names, I'll add them.
Some forms of general words:
wasn'tis marked sincewasnis not a valid word.
Should I create a separate issue for that?
I took care of the wasn't issue by making sure the word splitter kept words together across the ' if both sides had letters.
Back to your original request:
Being able to only check strings.
This falls under a more general problem of being able to support different languages within the same document. I was hoping that there was a way for vscode to tell me which part of the document a second of text falls under. Vscode uses a set of rules for colorization. It would be nice to tap into that, but I am not sure how.
I'll keep looking.
I'm second to this. An option to check strings/comments only (with configurable string/comment delimiters per language ID) would be very useful indeed.
I'm using your spell checker for C code and option to check only comments (and strings) would be great feature. There are to many names I cannot control and adding all to workspace dictionary is tedious work.
I've just stumbled on vscode TODO Parser:
https://marketplace.visualstudio.com/items?itemName=minhthai.vscode-todo-parser
They are searching for comments using regexps:
https://github.com/kantlove/vscode-todo-parser/blob/master/src/const/RegexStrings.ts
https://github.com/kantlove/vscode-todo-parser/blob/master/src/types/LanguageType.ts#L38
The challenge here is to create a solution that can work for multiple languages.
Ideally we could use the syntax highlighter system, but there isn't an exposed interface. In the short term, I could put is a regex solution, like you pointed out.
In case of c/cpp projects the regex solution would be major improvement, because we don't mix languages inside one file. Also, when I see the TODO Parser with regex-only solution, it would help in many more environments.
Btw, did you open Visual Studio Code request for syntax highlighted interface?
Are variables excluded from that check? It would be useful when variables get spell checked, it would also solve lots of typos...
This issue is starting to drift a bit.
Please check out 0.14.0 release and let me know if it solves any of your issues.
Turning on allowCompoundWords: true in the settings will also take care of many of the issues seen in .cpp and .c files.
It is now possible to check only strings and comments, but it is a bit difficult to turn on.
You can try it out by adding file level settings like this:
// cSpell:includeRegExp string
// cSpell:includeRegExp CStyleComment
See the Updated README
Personally, after adding Go keywords, I no longer have the original problem. :)
Good to hear. I'll close this issue for now.
"cSpell.includeRegExpList": [
"CStyleComment",
"string"
],
Works fine for C project. Thank you.
I am glad to hear it.
Sorry to comment on a closed issue, but I was wondering if there is a way to achieve this (only spell checking comments and strings) without disabling spell checking for plain text documents (like txt and markdown)?
I tried the above (setting includeRegExpList) and it works great for code. But now all my text documents aren't spell checked because they don't have comments in them!
Can regular expressions be applied per-language via languageSettings? Or is there an "ignore regular expressions" setting that could be used for plaintext file types?
Many thanks for any help!
Most helpful comment
Works fine for C project. Thank you.