-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspellcheck_cgo.go
More file actions
40 lines (32 loc) · 1.06 KB
/
spellcheck_cgo.go
File metadata and controls
40 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//go:build cgo && !windows
package main
import "github.com/slzatz/vimango/hunspell"
func init() {
// Override the default - spell check is available with CGO
isSpellCheckAvailableDefault = true
}
// CGOSpellChecker provides hunspell-based spell checking
type CGOSpellChecker struct {
hunspell *hunspell.Hunhandle
}
// createCGOSpellChecker creates a new CGO-based spell checker
func createCGOSpellChecker() SpellChecker {
// Use the same paths as the original implementation
h := hunspell.Hunspell("/usr/share/hunspell/en_US.aff", "/usr/share/hunspell/en_US.dic")
return &CGOSpellChecker{hunspell: h}
}
func (c *CGOSpellChecker) IsAvailable() bool {
return c.hunspell != nil
}
func (c *CGOSpellChecker) Spell(word string) bool {
if c.hunspell == nil {
return true // Fallback: assume words are correct if hunspell failed to initialize
}
return c.hunspell.Spell(word)
}
func (c *CGOSpellChecker) Suggest(word string) []string {
if c.hunspell == nil {
return []string{} // Return empty suggestions if hunspell failed to initialize
}
return c.hunspell.Suggest(word)
}