pub struct Dictionary { /* private fields */ }Expand description
Manages custom dictionaries for the language checker. Words in the dictionary are excluded from spelling diagnostics.
Internally, user-added words and bundled words are kept in separate sets.
Only user words are persisted to dictionary.txt.
Implementations§
Source§impl Dictionary
impl Dictionary
pub fn new() -> Self
Sourcepub fn load(workspace_root: &Path) -> Result<Self>
pub fn load(workspace_root: &Path) -> Result<Self>
Load dictionaries from a workspace root. Reads from .languagecheck/dictionary.txt (one word per line).
Sourcepub fn load_bundled(&mut self)
pub fn load_bundled(&mut self)
Load the bundled dictionaries that ship with the extension. These contain domain-specific technical terms from open-source wordlists. Bundled words are kept separate and never persisted to the user’s dictionary file.
Sourcepub fn load_bundled_except(&mut self, disabled: &[String])
pub fn load_bundled_except(&mut self, disabled: &[String])
Load every bundled dictionary whose name is not listed in disabled.
Names match those in bundled::ALL and the section headings of
dictionaries/THIRD_PARTY_NOTICES.md, case-insensitively. An unrecognised
name is warned about rather than rejected: a config that silently does
nothing is harder to diagnose than one that says so.
Sourcepub fn load_wordlist_file(&mut self, path: &Path, base: &Path) -> Result<()>
pub fn load_wordlist_file(&mut self, path: &Path, base: &Path) -> Result<()>
Load additional words from a file path. The file is expected to contain
one word per line; lines starting with # and blank lines are skipped.
Paths are resolved relative to base if they are not absolute.
Sourcepub fn add_word(&mut self, word: &str) -> Result<()>
pub fn add_word(&mut self, word: &str) -> Result<()>
Add a word to the user dictionary and persist to disk.
The word’s regular inflections are derived at the same time, so adding functor
also accepts functors — that is the whole point of the feature, and a user who
has to add both has not been helped. Only the word itself is written to disk.
Sourcepub fn derive_inflections(&mut self)
pub fn derive_inflections(&mut self)
Generate the regular inflections of every word loaded so far.
Call once, after every wordlist is in place: the expansion is a snapshot, and
words added later are inflected by Self::add_word instead.
Sourcepub fn contains(&self, word: &str) -> bool
pub fn contains(&self, word: &str) -> bool
Check if a word is in the dictionary (case-insensitive). Checks both user words and bundled/external wordlists.
A hyphenated compound also matches when every one of its parts is known
on its own, so Chern-Simons resolves from chern and simons. The
word handed to us is whatever span the engine reported, and the engines
disagree about whether a compound is one token or two — matching both
shapes here is the only place that can be correct for either.
Sourcepub fn words(&self) -> impl Iterator<Item = &String>
pub fn words(&self) -> impl Iterator<Item = &String>
Return all words the user configured (user + bundled), excluding derived forms.
Sourcepub fn fingerprint(&self) -> u64
pub fn fingerprint(&self) -> u64
Return the number of words loaded (user + bundled), excluding derived forms. A value that changes whenever the accepted words do.
Read by the check cache. Adding a word to the dictionary must make the misspelling it covers disappear, which cannot happen if a stored result from before the addition is still served.
pub fn len(&self) -> usize
Sourcepub fn derived_len(&self) -> usize
pub fn derived_len(&self) -> usize
How many inflected forms were generated from those words.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Dictionary
impl RefUnwindSafe for Dictionary
impl Send for Dictionary
impl Sync for Dictionary
impl Unpin for Dictionary
impl UnsafeUnpin for Dictionary
impl UnwindSafe for Dictionary
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more