Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Allow the user to easily add words to the spell check dictionary #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/spell-check-handler.coffee
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
SpellChecker = require 'spellchecker'

module.exports = ({id, text}) ->
module.exports = ({id, text, dict}) ->
SpellChecker.add("GitHub")
SpellChecker.add("github")

dict.filter((word) ->
word
).forEach (word) ->
word = word.trim()
capitalized = word.charAt(0).toUpperCase() + word.slice(1)
SpellChecker.add(word)
if word isnt capitalized
SpellChecker.add(capitalized)

misspelledCharacterRanges = SpellChecker.checkSpelling(text)

row = 0
Expand Down
3 changes: 2 additions & 1 deletion lib/spell-check-task.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ class SpellCheckTask
@constructor.task = null

start: (text) ->
dict = atom.config.get('spell-check.dictionary')
@constructor.task ?= new Task(require.resolve('./spell-check-handler'))
@constructor.task?.start {@id, text}, @constructor.dispatchMisspellings
@constructor.task?.start {@id, text, dict}, @constructor.dispatchMisspellings

onDidSpellCheck: (callback) ->
@constructor.callbacksById[@id] = callback
Expand Down
3 changes: 3 additions & 0 deletions lib/spell-check-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class SpellCheckView
@disposables.add atom.config.onDidChange 'spell-check.grammars', =>
@subscribeToBuffer()

@disposables.add atom.config.onDidChange 'spell-check.dictionary', =>
@subscribeToBuffer()

@subscribeToBuffer()

@disposables.add @editor.onDidDestroy(@destroy.bind(this))
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
"text.plain.null-grammar"
],
"description": "List of scopes for languages which will be checked for misspellings. See [the README](https://github.com/atom/spell-check#spell-check-package-) for more information on finding the correct scope for a specific language."
},
"dictionary": {
"type": "array",
"default": [],
"description": "list of custom words to accept"
}
},
"devDependencies": {
Expand Down