mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 23:18:33 +00:00
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>
This commit is contained in:

committed by
Lewis Russell

parent
05893aea39
commit
75adfefc85
@@ -7,6 +7,7 @@
|
||||
#include "nvim/decoration.h"
|
||||
#include "nvim/decoration_provider.h"
|
||||
#include "nvim/highlight.h"
|
||||
#include "nvim/lib/kvec.h"
|
||||
#include "nvim/lua/executor.h"
|
||||
|
||||
static kvec_t(DecorProvider) decor_providers = KV_INITIAL_VALUE;
|
||||
@@ -14,7 +15,7 @@ static kvec_t(DecorProvider) decor_providers = KV_INITIAL_VALUE;
|
||||
#define DECORATION_PROVIDER_INIT(ns_id) (DecorProvider) \
|
||||
{ ns_id, false, LUA_NOREF, LUA_NOREF, \
|
||||
LUA_NOREF, LUA_NOREF, LUA_NOREF, \
|
||||
LUA_NOREF, -1, false }
|
||||
LUA_NOREF, -1, false, false }
|
||||
|
||||
static bool decor_provider_invoke(NS ns_id, const char *name, LuaRef ref, Array args,
|
||||
bool default_true, char **perr)
|
||||
@@ -47,11 +48,33 @@ static bool decor_provider_invoke(NS ns_id, const char *name, LuaRef ref, Array
|
||||
return false;
|
||||
}
|
||||
|
||||
void decor_providers_invoke_spell(win_T *wp, int start_row, int start_col, int end_row, int end_col,
|
||||
char **err)
|
||||
{
|
||||
for (size_t i = 0; i < kv_size(decor_providers); i++) {
|
||||
DecorProvider *p = &kv_A(decor_providers, i);
|
||||
if (!p->active) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p->spell_nav != LUA_NOREF) {
|
||||
MAXSIZE_TEMP_ARRAY(args, 6);
|
||||
ADD_C(args, INTEGER_OBJ(wp->handle));
|
||||
ADD_C(args, INTEGER_OBJ(wp->w_buffer->handle));
|
||||
ADD_C(args, INTEGER_OBJ(start_row));
|
||||
ADD_C(args, INTEGER_OBJ(start_col));
|
||||
ADD_C(args, INTEGER_OBJ(end_row));
|
||||
ADD_C(args, INTEGER_OBJ(end_col));
|
||||
decor_provider_invoke(p->ns_id, "spell", p->spell_nav, args, true, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// For each provider invoke the 'start' callback
|
||||
///
|
||||
/// @param[out] providers Decoration providers
|
||||
/// @param[out] err Provider err
|
||||
void decor_providers_start(DecorProviders *providers, int type, char **err)
|
||||
void decor_providers_start(DecorProviders *providers, char **err)
|
||||
{
|
||||
kvi_init(*providers);
|
||||
|
||||
@@ -65,7 +88,6 @@ void decor_providers_start(DecorProviders *providers, int type, char **err)
|
||||
if (p->redraw_start != LUA_NOREF) {
|
||||
MAXSIZE_TEMP_ARRAY(args, 2);
|
||||
ADD_C(args, INTEGER_OBJ((int)display_tick));
|
||||
ADD_C(args, INTEGER_OBJ(type));
|
||||
active = decor_provider_invoke(p->ns_id, "start", p->redraw_start, args, true, err);
|
||||
} else {
|
||||
active = true;
|
||||
@@ -116,8 +138,8 @@ void decor_providers_invoke_win(win_T *wp, DecorProviders *providers,
|
||||
/// @param row Row to invoke line callback for
|
||||
/// @param[out] has_decor Set when at least one provider invokes a line callback
|
||||
/// @param[out] err Provider error
|
||||
void providers_invoke_line(win_T *wp, DecorProviders *providers, int row, bool *has_decor,
|
||||
char **err)
|
||||
void decor_providers_invoke_line(win_T *wp, DecorProviders *providers, int row, bool *has_decor,
|
||||
char **err)
|
||||
{
|
||||
for (size_t k = 0; k < kv_size(*providers); k++) {
|
||||
DecorProvider *p = kv_A(*providers, k);
|
||||
@@ -215,6 +237,7 @@ void decor_provider_clear(DecorProvider *p)
|
||||
NLUA_CLEAR_REF(p->redraw_win);
|
||||
NLUA_CLEAR_REF(p->redraw_line);
|
||||
NLUA_CLEAR_REF(p->redraw_end);
|
||||
NLUA_CLEAR_REF(p->spell_nav);
|
||||
p->active = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user