diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-12-22 13:47:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-22 13:47:45 +0100 |
commit | 9e9dcd4bd79cc5ea0fd240bcb242ceea07deabe2 (patch) | |
tree | b4c06d6b6485f364f502b97d8775546a9fced24f /src/nvim/api/vim.c | |
parent | e1d63c180cc38cec5a8bf3e543bfe18472352da4 (diff) | |
parent | 440695c29696f261337227e5c419aa1cf313c2dd (diff) | |
download | rneovim-9e9dcd4bd79cc5ea0fd240bcb242ceea07deabe2.tar.gz rneovim-9e9dcd4bd79cc5ea0fd240bcb242ceea07deabe2.tar.bz2 rneovim-9e9dcd4bd79cc5ea0fd240bcb242ceea07deabe2.zip |
Merge pull request #11113 from bfredl/tree-sitter-query
tree-sitter step 2: query API and highlighting prototype
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 19601b6539..2f59edee33 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -189,6 +189,15 @@ Dictionary nvim_get_hl_by_id(Integer hl_id, Boolean rgb, Error *err) return hl_get_attr_by_id(attrcode, rgb, err); } +/// Gets a highlight group by name +/// +/// similar to |hlID()|, but allocates a new ID if not present. +Integer nvim_get_hl_id_by_name(String name) + FUNC_API_SINCE(7) +{ + return syn_check_group((const char_u *)name.data, (int)name.size); +} + /// Sends input-keys to Nvim, subject to various quirks controlled by `mode` /// flags. This is a blocking call, unlike |nvim_input()|. /// @@ -2546,3 +2555,27 @@ Array nvim__inspect_cell(Integer grid, Integer row, Integer col, Error *err) } return ret; } + +/// Set attrs in nvim__buf_set_lua_hl callbacks +/// +/// TODO(bfredl): This is rather pedestrian. The final +/// interface should probably be derived from a reformed +/// bufhl/virttext interface with full support for multi-line +/// ranges etc +void nvim__put_attr(Integer id, Integer c0, Integer c1) + FUNC_API_LUA_ONLY +{ + if (!lua_attr_active) { + return; + } + if (id == 0 || syn_get_final_id((int)id) == 0) { + return; + } + int attr = syn_id2attr((int)id); + c0 = MAX(c0, 0); + c1 = MIN(c1, (Integer)lua_attr_bufsize); + for (Integer c = c0; c < c1; c++) { + lua_attr_buf[c] = (sattr_T)hl_combine_attr(lua_attr_buf[c], (int)attr); + } + return; +} |