diff options
author | ZyX <kp-pav@yandex.ru> | 2017-09-03 19:53:41 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-10-08 22:12:00 +0300 |
commit | 1265da028882d9877a5ebbd3f3f52cb4b52a4b94 (patch) | |
tree | b6fe57d3a2a674cc4a0ab48d2f0eefae33b27f7e /src/nvim/viml/parser/parser.h | |
parent | 2d8b9937deae3731143f4ea44e5c41715fe1363a (diff) | |
download | rneovim-1265da028882d9877a5ebbd3f3f52cb4b52a4b94.tar.gz rneovim-1265da028882d9877a5ebbd3f3f52cb4b52a4b94.tar.bz2 rneovim-1265da028882d9877a5ebbd3f3f52cb4b52a4b94.zip |
viml/parser: Add helper functions for highlighting
Diffstat (limited to 'src/nvim/viml/parser/parser.h')
-rw-r--r-- | src/nvim/viml/parser/parser.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h index 231e43b4c7..a17edac403 100644 --- a/src/nvim/viml/parser/parser.h +++ b/src/nvim/viml/parser/parser.h @@ -156,4 +156,33 @@ static inline void viml_parser_advance(ParserState *const pstate, } } +static inline void viml_parser_highlight(ParserState *const pstate, + const ParserPosition start, + const size_t end_col, + const char *const group) + REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL; + +/// Record highlighting of some region of text +/// +/// @param pstate Parser state to work with. +/// @param[in] start Start position of the highlight. +/// @param[in] len Highlighting chunk length. +/// @param[in] group Highlight group. +static inline void viml_parser_highlight(ParserState *const pstate, + const ParserPosition start, + const size_t len, + const char *const group) +{ + if (pstate->colors == NULL) { + return; + } + // TODO(ZyX-I): May do some assert() sanitizing here. + // TODO(ZyX-I): May join chunks. + kvi_push(*pstate->colors, ((ParserHighlightChunk) { + .start = start, + .end_col = start.col + len, + .group = group, + })); +} + #endif // NVIM_VIML_PARSER_PARSER_H |