vscode-spell-checker
vscode-spell-checker copied to clipboard
whitelist python modules, not just keywords
cSpell flags itertools
, functools
and ctypes
as being misspelled when the python dictionary is activated (and virtually any other module I try and import that is not in the en_us dictionary).
from itertools import combinations
from functools import reduce
from ctypes import *
I have verified the python dictionary is enabled.
I would suggest adding not just the python keywords, but the names of modules at least within the standard library to be whitelisted.
Love the plugin, thanks for the awesome work.
Thank you. This is also an issue with Go and C++.
A half fix would be to ignore imports:
"cSpell.languageSettings": [
{
// use with Python files
"languageId": "python",
// Exclude code.
"ignoreRegExpList": [
"/^\\s*from.*import/gm"
]
}
]
adding built in modules to the dictionary file won't help with non-standard modules (which ignoring the import line would).
I'm new to VSCode so I have no idea what the difficulty here would be, but is there a way to look into the words from intellisense and whitelist them?
Sadly, extensions do not have access to the intellisense results or even the code formatting results. Both of these could have been used to exclude imported modules.
I am busy with an alternate method. That is to have the spell checker understand language grammars and exclude things based upon the grammar instead of just checking all words.
But that is a rather extensive change and it will take some time before it is production ready.
Sounds good, if there is anything I can do to help, let me know.
On Sun, Apr 1, 2018, 2:00 AM Jason Dent [email protected] wrote:
Sadly, extensions do not have access to the intellisense results or even the code formatting results. Both of these could have been used to exclude imported modules.
I am busy with an alternate method. That is to have the spell checker understand language grammars and exclude things based upon the grammar instead of just checking all words.
But that is a rather extensive change and it will take some time before it is production ready.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Jason-Rev/vscode-spell-checker/issues/203#issuecomment-377773039, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnc_mcRUZG6eBO7RX9E-kqT98gZ55Ckks5tkJcagaJpZM4TA9kE .
Can I just add a comment here my python code (:
from struct import unpack
...
default = unpack('<BBHBBBB', data)[2]
Spell checking that first parameter of unpack makes no sense, I would be happy to add a manual rule to stop this being checked, but adding the string to the dictionary makes no sense.
Can this issue be closed in favor of #273?
I'm good with that
Can I just add a comment here my python code (:
from struct import unpack ... default = unpack('<BBHBBBB', data)[2]
@fordp2002 you can tell the spell checker to ignore that string:
# cspell:ignore BBHBBBB
default = unpack('<BBHBBBB', data)[2]
I may have hundreds of unpack calls all of which should be ignored I would not litter my code with extra lines just to stop the spell checker logging errors.
Same issue, for third-party libraries, we won't modify them usually, so it's meaningless for checking words in them, but spell checker will still check them (like softmax
, optim
).
Regular expression won't fulfill our requirements, because we may give alias to imported libraries.
Sadly, extensions do not have access to the intellisense results or even the code formatting results. Both of these could have been used to exclude imported modules.
I am busy with an alternate method. That is to have the spell checker understand language grammars and exclude things based upon the grammar instead of just checking all words.
But that is a rather extensive change and it will take some time before it is production ready.
Is this still the case now with the Language Server Protocol? I don't have experience with making extensions so I could be totally misunderstanding, but I think that's meant to make it much easier for extensions to access things like intellisense results (or maybe the underlying information that intellisense results are derived from, I'm not sure). I could explore this more and see if I can help, but please let me know if I'm off base, or if you can already see a clear path to a solution on this.
Would it be possible to understand the language syntax well enough to exclude cases like the following?
- Members of imported modules. For example, if I
import numpy as np
thennp.ndarray
should be ignored. - Named parameters of functions meeting the above criteria. For example, if I call
np.ndarray
thendtype = ...
should be ignored.
The above examples are Python-centric, but the concept applies to other languages as well.