Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add words? #293

Open
ehuss opened this issue Jan 22, 2023 · 2 comments
Open

How to add words? #293

ehuss opened this issue Jan 22, 2023 · 2 comments
Assignees

Comments

@ehuss
Copy link

ehuss commented Jan 22, 2023

How to add words interactively?

I'm trying to figure out how to add words to a dictionary (or at least to ignore the same word). Most spell checkers I am used to have an "Add to Dictionary" option or an "Ignore" option that will ignore the same word for the rest of the document. None of the options in the cargo spellcheck fix menu seem to provide that:

y - apply this suggestion
n - do not apply the suggested correction
q - quit; do not stage this hunk or any of the remaining ones
d - do not apply this suggestion and skip the rest of the file
g - select a suggestion to go to
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
e - manually edit the current hunk
? - print help

How to manually set up a dictionary?

Assuming it doesn't support adding words automatically, I tried several things to set up a custom dictionary. However, I found several roadblocks.

  1. Add to extra_dictionaries in the config mentioned at https://github.com/drahnr/cargo-spellcheck/blob/master/docs/configuration.md. I created .config/spellcheck.toml with the contents:
[Hunspell]
extra_dictionaries = ["spelling.txt"]

Got error: 0: Could not find extra dictionary spelling.txt in any of the search paths

  1. Tried extra_dictionaries = ["./spelling.txt"], go the same error.

  2. Tried with an absolute path, got 0: Failed to find any en_US.dic / en_US.aff in any search dir or no search provided

  3. After lots of messing around, figured out that creating a table disabled the default settings, so I had to add:

[Hunspell]
extra_dictionaries = ["/path/to/spelling.txt"]
use_builtin = true

Got an error:

   0: First line of extra dictionary must a number, but is: >foobar<
   1: invalid digit found in string
  1. I thought the extra dictionaries would be a "personal dictionary" according to the hunspell docs, which says it should be a text file with words. But apparently it is a .dic file. I added a random number at the top of the file, and was able to progress.

  2. However, now after each word, I have to stop, edit the file, restart cargo spellcheck (which takes a long time to start up).

I think I am missing something fundamental, or maybe I am very confused?

@drahnr
Copy link
Owner

drahnr commented Jan 22, 2023

It's a missing feature, to interactively modify the dictionary.
Happy to review a PR to enhance the UI on it.

@ehuss I'd really appreciate a PR on the docs from a first-time user and what would have helped you to avoid you tripping up issue to issue.

@dpc
Copy link

dpc commented Feb 11, 2023

@ehuss Thank you for your details post. I was able to get it working

> cat .config/spellcheck.toml 
[Hunspell]
use_builtin = true
skip_os_lookups = false
search_dirs = [ "." ]
extra_dictionaries = [ "spellcheck.dic" ]
> cat .config/spellcheck.dic 
1000
config
tx

I would like to confirm that the current config setup is not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants