znck / grammarly

Grammarly for VS Code
https://marketplace.visualstudio.com/items?itemName=znck.grammarly
MIT License
1.64k stars 117 forks source link

Ignore patterns using regex #260

Open davidkristoffersen opened 2 years ago

davidkristoffersen commented 2 years ago

It would be great if we can add a list of regex patterns to ignore in the vscode settings file.

znck commented 2 years ago

Do you want to exclude files or parts of text in files?

universemaster commented 2 years ago

I'm not the original poster, but I would find it useful to exclude parts of text in files.

For example, I write a lot of mathematical content where with respect to is fine to write, but Grammarly suggests I reword.

I would like the ability to add that phrase so that it always excluded. It would also be great to be able to use the full power of regular expressions for this.

universemaster commented 2 years ago

Another example of the kind of thing I would like to exclude is of order $n$ or of order $2$. This, again, is fine in mathematical writing (see this wikipedia article where the phrase of order __ appears nine times).

davidkristoffersen commented 2 years ago

I'm talking about text parts in files, just like what universemaster described. I'm writing technical language in markdown, where I sometimes use phrases that I'd like to exclude.

I also write in a customized flavor of markdown, such that sometimes Grammarly fails to parse a custom operator. I can use regex to exclude such patterns in those cases, which would be a tremendous help!

davidkristoffersen commented 2 years ago

Currently grammarly support including and excluding files using globbing as such:

"grammarly.files.include": ["**/foo.md"],
"grammarly.files.exclude": ["**/bar.md"]

I propose using text as a category for regex patterns, thus:

"grammarly.text.include": ["\[operator\]"],
"grammarly.text.exclude": ["of order \$\d+\$"]

Possibly using grammarly.regex would work as well. It would be nice to be able to choose regex flags as well, such as case sensitivity:

"grammarly.regex.flags": ["i"]

There are several flavors of regex, so the flags(and sometimes syntax) vary. Thus I think it would be useful to link the flavor used. Since this project uses JavaScript/TypeScript this would be the documentation: Flags

chapeiro commented 2 years ago

Supporting replacements through the regexes, similarly to Overleaf Textarea would also be a nice addition: I often mix latex commands with markdown and the mix causes some false positives and false negatives.

For example, consider the following cases: The following command \ifdraft{accepts some}{does not accept} text as input. and This command generates \text{}.. In the first example, the regex could replace \ifdraft{...}{...} with the first input (or later on in the document lifetime with the second one) and in the second example it would replace the command with the actual text.

ainar commented 2 years ago

This feature would actually be a way to meet https://github.com/znck/grammarly/issues/17. Each regex also should be file type specific.

MabezDev commented 2 years ago

One feature I am looking for would be to ignore any suggestions about words/phrases inside an inline-code block i.e "this should be checked but not anything in here". I think this issue could cover that?

silopolis commented 1 year ago

Couldn't it also solve #262 ?! Very much like @davidkristoffersen proposal. Together with selectable User/Workspace/Folder scopes, that'd be close to perfect :)