aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/spell.c
diff options
context:
space:
mode:
authorThomas Vigouroux <thomas.vigouroux@protonmail.com>2022-09-13 09:44:24 +0200
committerLewis Russell <lewis6991@gmail.com>2022-11-12 10:19:01 +0000
commit7e6d785d19926714615758e75c4d43e856d13a6f (patch)
tree4fdd44a500626fd1950cd1c85b30bf370b26b26a /src/nvim/spell.c
parent7335a67b5754255f0e892303a0f4e3521035e7d8 (diff)
downloadrneovim-7e6d785d19926714615758e75c4d43e856d13a6f.tar.gz
rneovim-7e6d785d19926714615758e75c4d43e856d13a6f.tar.bz2
rneovim-7e6d785d19926714615758e75c4d43e856d13a6f.zip
feat(extmarks): allow preventing spellchecking with spell = false
Diffstat (limited to 'src/nvim/spell.c')
-rw-r--r--src/nvim/spell.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index f24af5c3bf..b1daf4ed23 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -1216,7 +1216,14 @@ static bool decor_spell_nav_col(win_T *wp, linenr_T lnum, linenr_T *decor_lnum,
*decor_lnum = lnum;
}
decor_redraw_col(wp->w_buffer, col, col, false, &decor_state);
- return decor_state.spell;
+ return decor_state.spell == kTrue;
+}
+
+static inline bool can_syn_spell(win_T *wp, linenr_T lnum, int col)
+{
+ bool can_spell;
+ (void)syn_get_id(wp, lnum, col, false, &can_spell, false);
+ return can_spell;
}
/// Moves to the next spell error.
@@ -1346,15 +1353,9 @@ size_t spell_move_to(win_T *wp, int dir, bool allwords, bool curline, hlf_T *att
: p - buf) > wp->w_cursor.col)) {
col = (colnr_T)(p - buf);
- bool can_spell = decor_spell_nav_col(wp, lnum, &decor_lnum, col, &decor_error);
-
- if (!can_spell) {
- if (has_syntax) {
- (void)syn_get_id(wp, lnum, col, false, &can_spell, false);
- } else {
- can_spell = (wp->w_s->b_p_spo_flags & SPO_NPBUFFER) == 0;
- }
- }
+ bool can_spell = (!has_syntax && (wp->w_s->b_p_spo_flags & SPO_NPBUFFER) == 0)
+ || decor_spell_nav_col(wp, lnum, &decor_lnum, col, &decor_error)
+ || (has_syntax && can_syn_spell(wp, lnum, col));
if (!can_spell) {
attr = HLF_COUNT;