aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/decoration.c
diff options
context:
space:
mode:
authorThomas Vigouroux <thomas.vigouroux@protonmail.com>2022-07-18 14:21:40 +0200
committerLewis Russell <lewis6991@gmail.com>2022-09-06 10:14:11 +0100
commit75adfefc85bcf0d62d2c0f51a951e6003b595cea (patch)
tree98e20f97a5c5ce818ade4f330bca45ca1d4d26bf /src/nvim/decoration.c
parent05893aea391d91e159a41f03acc20049c7049510 (diff)
downloadrneovim-75adfefc85bcf0d62d2c0f51a951e6003b595cea.tar.gz
rneovim-75adfefc85bcf0d62d2c0f51a951e6003b595cea.tar.bz2
rneovim-75adfefc85bcf0d62d2c0f51a951e6003b595cea.zip
feat(extmarks,ts,spell): full support for spelling
- Added 'spell' option to extmarks: Extmarks with this set will have the region spellchecked. - Added 'noplainbuffer' option to 'spelloptions': This is used to tell Neovim not to spellcheck the buffer. The old behaviour was to spell check the whole buffer unless :syntax was set. - Added spelling support to the treesitter highlighter: @spell captures in highlights.scm are used to define regions which should be spell checked. - Added support for navigating spell errors for extmarks: Works for both ephemeral and static extmarks - Added '_on_spell_nav' callback for decoration providers: Since ephemeral callbacks are only drawn for the visible screen, providers must implement this callback to instruct Neovim which regions in the buffer need can be spell checked. The callback takes a start position and an end position. Note: this callback is subject to change hence the _ prefix. - Added spell captures for built-in support languages Co-authored-by: Lewis Russell <lewis6991@gmail.com> Co-authored-by: Björn Linse <bjorn.linse@gmail.com>
Diffstat (limited to 'src/nvim/decoration.c')
-rw-r--r--src/nvim/decoration.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index 8955048f45..778f9293fb 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -69,7 +69,7 @@ void bufhl_add_hl_pos_offset(buf_T *buf, int src_id, int hl_id, lpos_T pos_start
void decor_redraw(buf_T *buf, int row1, int row2, Decoration *decor)
{
if (row2 >= row1) {
- if (!decor || decor->hl_id || decor_has_sign(decor) || decor->conceal) {
+ if (!decor || decor->hl_id || decor_has_sign(decor) || decor->conceal || decor->spell) {
redraw_buf_range_later(buf, row1 + 1, row2 + 1);
}
}
@@ -116,6 +116,11 @@ void decor_free(Decoration *decor)
}
}
+void decor_state_free(DecorState *state)
+{
+ xfree(state->active.items);
+}
+
void clear_virttext(VirtText *text)
{
for (size_t i = 0; i < kv_size(*text); i++) {
@@ -306,6 +311,7 @@ next_mark:
bool conceal = 0;
int conceal_char = 0;
int conceal_attr = 0;
+ bool spell = false;
for (size_t i = 0; i < kv_size(state->active); i++) {
DecorRange item = kv_A(state->active, i);
@@ -339,6 +345,9 @@ next_mark:
conceal_attr = item.attr_id;
}
}
+ if (active && item.decor.spell) {
+ spell = true;
+ }
if ((item.start_row == state->row && item.start_col <= col)
&& decor_virt_pos(item.decor)
&& item.decor.virt_text_pos == kVTOverlay && item.win_col == -1) {
@@ -355,6 +364,7 @@ next_mark:
state->conceal = conceal;
state->conceal_char = conceal_char;
state->conceal_attr = conceal_attr;
+ state->spell = spell;
return attr;
}