plugin: spell checker f0r 2025
This commit is contained in:
parent
2e17297355
commit
d285335e1c
BIN
distributables/lyng-idea-0.0.2-SNAPSHOT.zip
(Stored with Git LFS)
BIN
distributables/lyng-idea-0.0.2-SNAPSHOT.zip
(Stored with Git LFS)
Binary file not shown.
BIN
distributables/lyng-idea-0.0.3-SNAPSHOT.zip
(Stored with Git LFS)
BIN
distributables/lyng-idea-0.0.3-SNAPSHOT.zip
(Stored with Git LFS)
Binary file not shown.
@ -4,6 +4,7 @@ import lyng.io.fs
|
|||||||
import lyng.stdlib
|
import lyng.stdlib
|
||||||
|
|
||||||
val files = Path("../..").list().toList()
|
val files = Path("../..").list().toList()
|
||||||
|
// most long is longest?
|
||||||
val longestNameLength = files.maxOf { it.name.length }
|
val longestNameLength = files.maxOf { it.name.length }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -129,22 +129,10 @@ class LyngGrazieAnnotator : ExternalAnnotator<LyngGrazieAnnotator.Input, LyngGra
|
|||||||
}
|
}
|
||||||
log.info("LyngGrazieAnnotator.apply: used=${chosenEntry ?: "<none>"}, totalFindings=$totalReturned, painting=${findings.size}")
|
log.info("LyngGrazieAnnotator.apply: used=${chosenEntry ?: "<none>"}, totalFindings=$totalReturned, painting=${findings.size}")
|
||||||
|
|
||||||
// Guarded fallback: if Grazie returned nothing but we clearly have fragments, try legacy spellchecker via reflection
|
// IMPORTANT: Do NOT fallback to the tiny bundled vocabulary on modern IDEs.
|
||||||
if (findings.isEmpty() && fragments.isNotEmpty()) {
|
// If Grazie/Natural Languages processing returned nothing, we simply exit here
|
||||||
val added = fallbackWithLegacySpellcheckerIfAvailable(file, fragments, holder)
|
// to avoid low‑quality results from the legacy dictionary.
|
||||||
log.info("LyngGrazieAnnotator.apply: fallback painted=$added (0 means no legacy and heuristic may have painted separately)")
|
if (findings.isEmpty()) return
|
||||||
// Ensure at least one visible mark for diagnostics: paint a small WARNING at the first fragment range
|
|
||||||
try {
|
|
||||||
val first = fragments.first().second
|
|
||||||
val diagRange = TextRange(first.startOffset, (first.startOffset + 2).coerceAtMost(first.endOffset))
|
|
||||||
val ab = holder.newAnnotation(HighlightSeverity.INFORMATION, "[LyngSpell] active").range(diagRange)
|
|
||||||
applyTypoStyleIfRequested(file, ab)
|
|
||||||
ab.create()
|
|
||||||
log.info("LyngGrazieAnnotator.apply: painted diagnostic marker at ${diagRange.startOffset}..${diagRange.endOffset}")
|
|
||||||
} catch (_: Throwable) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (f in findings) {
|
for (f in findings) {
|
||||||
val ab = holder.newAnnotation(HighlightSeverity.INFORMATION, f.message).range(f.range)
|
val ab = holder.newAnnotation(HighlightSeverity.INFORMATION, f.message).range(f.range)
|
||||||
|
|||||||
@ -36,6 +36,8 @@ class LyngFormatterSettingsConfigurable(private val project: Project) : Configur
|
|||||||
private var grazieIdsAsCommentsCb: JCheckBox? = null
|
private var grazieIdsAsCommentsCb: JCheckBox? = null
|
||||||
private var grazieLiteralsAsCommentsCb: JCheckBox? = null
|
private var grazieLiteralsAsCommentsCb: JCheckBox? = null
|
||||||
private var debugShowSpellFeedCb: JCheckBox? = null
|
private var debugShowSpellFeedCb: JCheckBox? = null
|
||||||
|
private var showTyposGreenCb: JCheckBox? = null
|
||||||
|
private var offerQuickFixesCb: JCheckBox? = null
|
||||||
|
|
||||||
override fun getDisplayName(): String = "Lyng Formatter"
|
override fun getDisplayName(): String = "Lyng Formatter"
|
||||||
|
|
||||||
@ -53,6 +55,8 @@ class LyngFormatterSettingsConfigurable(private val project: Project) : Configur
|
|||||||
grazieIdsAsCommentsCb = JCheckBox("Natural Languages/Grazie: treat identifiers as comments (forces spelling checks in 2024.3)")
|
grazieIdsAsCommentsCb = JCheckBox("Natural Languages/Grazie: treat identifiers as comments (forces spelling checks in 2024.3)")
|
||||||
grazieLiteralsAsCommentsCb = JCheckBox("Natural Languages/Grazie: treat string literals as comments when literals are not processed")
|
grazieLiteralsAsCommentsCb = JCheckBox("Natural Languages/Grazie: treat string literals as comments when literals are not processed")
|
||||||
debugShowSpellFeedCb = JCheckBox("Debug: show spell-feed ranges (weak warnings)")
|
debugShowSpellFeedCb = JCheckBox("Debug: show spell-feed ranges (weak warnings)")
|
||||||
|
showTyposGreenCb = JCheckBox("Show Lyng typos with green underline (TYPO styling)")
|
||||||
|
offerQuickFixesCb = JCheckBox("Offer Lyng typo quick fixes (Replace…, Add to dictionary) without Spell Checker")
|
||||||
|
|
||||||
// Tooltips / short help
|
// Tooltips / short help
|
||||||
spacingCb?.toolTipText = "Applies minimal, safe spacing (e.g., around commas/operators, control-flow parens)."
|
spacingCb?.toolTipText = "Applies minimal, safe spacing (e.g., around commas/operators, control-flow parens)."
|
||||||
@ -65,6 +69,8 @@ class LyngFormatterSettingsConfigurable(private val project: Project) : Configur
|
|||||||
grazieIdsAsCommentsCb?.toolTipText = "Grazie-only fallback: route identifiers as COMMENTS domain so Grazie applies spelling in 2024.3."
|
grazieIdsAsCommentsCb?.toolTipText = "Grazie-only fallback: route identifiers as COMMENTS domain so Grazie applies spelling in 2024.3."
|
||||||
grazieLiteralsAsCommentsCb?.toolTipText = "Grazie-only fallback: when Grammar doesn't process literals, route strings as COMMENTS so they are checked."
|
grazieLiteralsAsCommentsCb?.toolTipText = "Grazie-only fallback: when Grammar doesn't process literals, route strings as COMMENTS so they are checked."
|
||||||
debugShowSpellFeedCb?.toolTipText = "Show the exact ranges we feed to spellcheckers (ids/comments/strings) as weak warnings."
|
debugShowSpellFeedCb?.toolTipText = "Show the exact ranges we feed to spellcheckers (ids/comments/strings) as weak warnings."
|
||||||
|
showTyposGreenCb?.toolTipText = "Render Lyng typos using the platform's green TYPO underline instead of generic warnings."
|
||||||
|
offerQuickFixesCb?.toolTipText = "Provide lightweight Replace… and Add to dictionary quick-fixes without requiring the legacy Spell Checker."
|
||||||
p.add(spacingCb)
|
p.add(spacingCb)
|
||||||
p.add(wrappingCb)
|
p.add(wrappingCb)
|
||||||
p.add(reindentClosedBlockCb)
|
p.add(reindentClosedBlockCb)
|
||||||
@ -76,6 +82,8 @@ class LyngFormatterSettingsConfigurable(private val project: Project) : Configur
|
|||||||
p.add(grazieIdsAsCommentsCb)
|
p.add(grazieIdsAsCommentsCb)
|
||||||
p.add(grazieLiteralsAsCommentsCb)
|
p.add(grazieLiteralsAsCommentsCb)
|
||||||
p.add(debugShowSpellFeedCb)
|
p.add(debugShowSpellFeedCb)
|
||||||
|
p.add(showTyposGreenCb)
|
||||||
|
p.add(offerQuickFixesCb)
|
||||||
panel = p
|
panel = p
|
||||||
reset()
|
reset()
|
||||||
return p
|
return p
|
||||||
@ -93,7 +101,9 @@ class LyngFormatterSettingsConfigurable(private val project: Project) : Configur
|
|||||||
grazieChecksIdentifiersCb?.isSelected != s.grazieChecksIdentifiers ||
|
grazieChecksIdentifiersCb?.isSelected != s.grazieChecksIdentifiers ||
|
||||||
grazieIdsAsCommentsCb?.isSelected != s.grazieTreatIdentifiersAsComments ||
|
grazieIdsAsCommentsCb?.isSelected != s.grazieTreatIdentifiersAsComments ||
|
||||||
grazieLiteralsAsCommentsCb?.isSelected != s.grazieTreatLiteralsAsComments ||
|
grazieLiteralsAsCommentsCb?.isSelected != s.grazieTreatLiteralsAsComments ||
|
||||||
debugShowSpellFeedCb?.isSelected != s.debugShowSpellFeed
|
debugShowSpellFeedCb?.isSelected != s.debugShowSpellFeed ||
|
||||||
|
showTyposGreenCb?.isSelected != s.showTyposWithGreenUnderline ||
|
||||||
|
offerQuickFixesCb?.isSelected != s.offerLyngTypoQuickFixes
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun apply() {
|
override fun apply() {
|
||||||
@ -109,6 +119,8 @@ class LyngFormatterSettingsConfigurable(private val project: Project) : Configur
|
|||||||
s.grazieTreatIdentifiersAsComments = grazieIdsAsCommentsCb?.isSelected == true
|
s.grazieTreatIdentifiersAsComments = grazieIdsAsCommentsCb?.isSelected == true
|
||||||
s.grazieTreatLiteralsAsComments = grazieLiteralsAsCommentsCb?.isSelected == true
|
s.grazieTreatLiteralsAsComments = grazieLiteralsAsCommentsCb?.isSelected == true
|
||||||
s.debugShowSpellFeed = debugShowSpellFeedCb?.isSelected == true
|
s.debugShowSpellFeed = debugShowSpellFeedCb?.isSelected == true
|
||||||
|
s.showTyposWithGreenUnderline = showTyposGreenCb?.isSelected == true
|
||||||
|
s.offerLyngTypoQuickFixes = offerQuickFixesCb?.isSelected == true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun reset() {
|
override fun reset() {
|
||||||
@ -124,5 +136,7 @@ class LyngFormatterSettingsConfigurable(private val project: Project) : Configur
|
|||||||
grazieIdsAsCommentsCb?.isSelected = s.grazieTreatIdentifiersAsComments
|
grazieIdsAsCommentsCb?.isSelected = s.grazieTreatIdentifiersAsComments
|
||||||
grazieLiteralsAsCommentsCb?.isSelected = s.grazieTreatLiteralsAsComments
|
grazieLiteralsAsCommentsCb?.isSelected = s.grazieTreatLiteralsAsComments
|
||||||
debugShowSpellFeedCb?.isSelected = s.debugShowSpellFeed
|
debugShowSpellFeedCb?.isSelected = s.debugShowSpellFeed
|
||||||
|
showTyposGreenCb?.isSelected = s.showTyposWithGreenUnderline
|
||||||
|
offerQuickFixesCb?.isSelected = s.offerLyngTypoQuickFixes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user