You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Updated plugin-based implementation from provided feedback.
- Switched to a task-based system.
- Reworked the plugins so they return full paths to a `require`able instance.
- Modified the activation/deactivation to create a single background task for all checking.
- Initial request for corrections will have a delay while an in-process manager is created.
- Added flow control via `send` and `emit` to communicate configuration changes with the task process.
- Changed to a word-based searching implementation.
- Added a simplified tokenizer that includes some accented characters.
- An internal cache is used for a single round of check to reduce overhead.
- Removed the use of integer ranges and simplified processing logic.
- Removed a number of `console.log` calls used for debugging.
- Updated documentation.
- Split out plugin creation into a separate document with a reference in the `README.md`.
The `spell-check` allows for additional dictionaries to be used at the same time using Atom's `providedServices` element in the `package.json` file.
4
+
5
+
"providedServices": {
6
+
"spell-check": {
7
+
"versions": {
8
+
"1.0.0": "nameOfFunctionToProvideSpellCheck"
9
+
}
10
+
}
11
+
}
12
+
13
+
The `nameOfFunctionToProvideSpellCheck` function may return either a single `require`able path or an array of them. This must be an absolute path to a class that provides a checker instance (below).
14
+
15
+
provideSpellCheck: ->
16
+
require.resolve './project-checker.coffee'
17
+
18
+
The path given must resolve to a singleton instance of a class.
19
+
20
+
class ProjectChecker
21
+
# Magical code
22
+
checker = new ProjectChecker()
23
+
module.exports = checker
24
+
25
+
See the `spell-check-project` for an example implementation.
26
+
27
+
# Checker
28
+
29
+
A common parameter type is `checkArgs`, this is a hash with the following signature.
30
+
31
+
args = {
32
+
projectPath: "/absolute/path/to/project/root,
33
+
relativePath: "relative/path/from/projet/root"
34
+
}
35
+
36
+
Below the required methods for the checker instance.
37
+
38
+
* getId(): string
39
+
* This returns the canonical identifier for this plugin. Typically, this will be the package name with an optional suffix for options, such as `spell-check-project` or `spell-check:en-US`. This identifier will be used for some control plugins (such as `spell-check-project`) to enable or disable the plugin.
40
+
* This will also used to pass information from the Atom process into the background task once that is implemented.
41
+
* getPriority(): number
42
+
* Determines how significant the plugin is for information with lower numbers being more important. Typically, user-entered data (such as the config `knownWords` configuration or a project's dictionary) will be lower than system data (priority 100).
43
+
* isEnabled(): boolean
44
+
* If this returns true, then the plugin will considered for processing.
45
+
* providesSpelling(checkArgs): boolean
46
+
* If this returns true, then the plugin will be included when looking for incorrect and correct words via the `check` function.
* This takes an array of words in a given line. This will be called once for every line inside the buffer. It also also not include words already requested earlier in the buffer.
49
+
* The output is an array of the same length as words which has three values, one for each word given:
50
+
*`null`: The checker provides no opinion on correctness.
51
+
*`false`: The word is specifically false.
52
+
*`true`: The word is correctly spelled.
53
+
* True always takes precedence, then false. If every checker provides `null`, then the word is considered spelled correctly.
54
+
* providesSuggestions(checkArgs): boolean
55
+
* If this returns true, then the plugin will be included when querying for suggested words via the `suggest` function.
Copy file name to clipboardExpand all lines: README.md
+4-40Lines changed: 4 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,46 +26,10 @@ for the _Spell Check_ package. Here are some examples: `source.coffee`,
26
26
27
27
## Changing the dictionary
28
28
29
-
Currently, only the English (US) dictionary is supported. Follow [this issue](https://github.com/atom/spell-check/issues/11) for updates.
29
+
To change the language of the dictionary, set the "Locales" configuration option to the IEFT tag (en-US, fr-FR, etc). More than one language can be used, simply separate them by commas.
30
30
31
-
## Writing Providers
31
+
For Windows 8 and 10, you must install the language using the regional settings before the language can be chosen inside Atom.
32
32
33
-
The `spell-check` allows for additional dictionaries to be used at the same time using Atom's `providedServices` element in the `package.json` file.
33
+
## Plugins
34
34
35
-
"providedServices": {
36
-
"spell-check": {
37
-
"versions": {
38
-
"1.0.0": "nameOfFunctionToProvideSpellCheck"
39
-
}
40
-
}
41
-
}
42
-
43
-
The `nameOfFunctionToProvideSpellCheck` function may return either a single object describing the spell-check plugin or an array of them. Each spell-check plugin must implement the following:
44
-
45
-
* getId(): string
46
-
* This returns the canonical identifier for this plugin. Typically, this will be the package name with an optional suffix for options, such as `spell-check-project` or `spell-check:en-US`. This identifier will be used for some control plugins (such as `spell-check-project`) to enable or disable the plugin.
47
-
* getName(): string
48
-
* Returns the human-readable name for the plugin. This is used on the status screen and in various dialogs/popups.
49
-
* getPriority(): number
50
-
* Determines how significant the plugin is for information with lower numbers being more important. Typically, user-entered data (such as the config `knownWords` configuration or a project's dictionary) will be lower than system data (priority 100).
51
-
* isEnabled(): boolean
52
-
* If this returns true, then the plugin will considered for processing.
53
-
* getStatus(): string
54
-
* Returns a string that describes the current status or state of the plugin. This is to allow a plugin to identify why it is disabled or to indicate version numbers. This can be formatted for Markdown, including links, and will be displayed on a status screen (eventually).
55
-
* providesSpelling(buffer): boolean
56
-
* If this returns true, then the plugin will be included when looking for incorrect and correct words via the `check` function.
*`correct` and `incorrect` are both optional. If they are skipped, then it means the plugin does not contribute to the correctness or incorrectness of any word. If they are present but empty, it means there are no correct or incorrect words respectively.
59
-
* The `range` objects have a signature of `{ start: X, end: Y }`.
60
-
* providesSuggestions(buffer): boolean
61
-
* If this returns true, then the plugin will be included when querying for suggested words via the `suggest` function.
* Returns a list of suggestions for a given word ordered so the most important is at the beginning of the list.
64
-
* providesAdding(buffer): boolean
65
-
* If this returns true, then the dictionary allows a word to be added to the dictionary.
66
-
* getAddingTargets(buffer): [target]
67
-
* Gets a list of targets to show to the user.
68
-
* The `target` object has a minimum signature of `{ label: stringToShowTheUser }`. For example, `{ label: "Ignore word (case-sensitive)" }`.
69
-
* This is a list to allow plugins to have multiple options, such as adding it as a case-sensitive or insensitive, temporary verses configuration, etc.
70
-
* add(buffer, target, word)
71
-
* Adds a word to the dictionary, using the target for identifying which one is used.
35
+
_Spell Check_ allows for plugins to provide additional spell checking functionality. See the `PLUGINS.md` file in the repository on how to write a plugin.
0 commit comments