diff --git a/doc/carbon.txt b/doc/carbon.txt index 128d7d2..955c6f5 100644 --- a/doc/carbon.txt +++ b/doc/carbon.txt @@ -40,7 +40,7 @@ USAGE *carbon-usag directly anywhere in your |$MYVIMRC| file since such packages are automatically loaded. - Carbon replaces |netrw| by default and remaps NetRW's |Explore| and Lexplore + Carbon replaces |netrw| by default and remaps NetRW's |Explore| and |Lexplore| commands to Carbon's |carbon-command-Carbon| and |carbon-command-Lcarbon| commands respectively. For more specific usage and configuration information, see: @@ -817,9 +817,9 @@ UTIL *carbon-uti Signature: `require('carbon.util').add_highlight(`{buf}, {...}`)` - Calls |vim.hl.range| like this: + Calls |nvim_buf_add_highlight| like this: - `vim.hl.range(`{buf}, , {...}`)` + `vim.api.nvim_buf_add_highlight(`{buf}, , {...}`)` will be set to |carbon-constant-hl|. @@ -1520,15 +1520,16 @@ VIEW *carbon-vie , } < - |carbon-view-render| uses |vim.hl.range| to set the highlights. + |carbon-view-render| uses |nvim_buf_add_highlight| to set the highlights. It is called the following way: - `vim.hl.range(` + `vim.api.nvim_buf_add_highlight(` |carbon-view-buffer|, |carbon-constant-hl|, `highlight[1],` - `{lnum - 1, highlight[2]},` - `{lnum - 1, highlight[3]},` + `lnum - 1,` + `highlight[2],` + `highlight[3],` `)` Property: `path` @@ -1816,7 +1817,7 @@ VIEW *carbon-vie Highlights a region from {start} to {finish} with {group} for {duration} milliseconds. {start} and {finish} must be values accepted by - |vim.hl.range|. + |vim.highlight.range|. See |carbon-view-flash-bang| for more information about customizing the highlighting properties when entries are revealed. diff --git a/lua/carbon/util.lua b/lua/carbon/util.lua index d8dac14..a2fe331 100644 --- a/lua/carbon/util.lua +++ b/lua/carbon/util.lua @@ -203,7 +203,7 @@ function util.clear_extmarks(buf, ...) end function util.add_highlight(buf, ...) - vim.hl.range(buf, constants.hl, ...) + vim.api.nvim_buf_add_highlight(buf, constants.hl, ...) end function util.window_neighbors(window_id, sides) diff --git a/lua/carbon/view.lua b/lua/carbon/view.lua index bb1eb02..bdeb27b 100644 --- a/lua/carbon/view.lua +++ b/lua/carbon/view.lua @@ -58,18 +58,8 @@ local function create_insert_move(ctx) vim.api.nvim_buf_set_lines(0, ctx.edit_lnum, ctx.edit_lnum + 1, 1, { text }) util.clear_extmarks(0, { ctx.edit_lnum, 0 }, { ctx.edit_lnum, -1 }, {}) - util.add_highlight( - 0, - 'CarbonDir', - { ctx.edit_lnum, 0 }, - { ctx.edit_lnum, last_slash_col } - ) - util.add_highlight( - 0, - 'CarbonFile', - { ctx.edit_lnum, last_slash_col }, - { ctx.edit_lnum, -1 } - ) + util.add_highlight(0, 'CarbonDir', ctx.edit_lnum, 0, last_slash_col) + util.add_highlight(0, 'CarbonFile', ctx.edit_lnum, last_slash_col, -1) util.cursor(ctx.edit_lnum + 1, math.max(ctx.edit_col, vim.fn.col('.'))) end end @@ -388,7 +378,14 @@ function view:render() end for _, hl in ipairs(hls) do - vim.hl.range(buf, constants.hl, hl[1], { hl[2], hl[3] }, { hl[2], hl[4] }) + vim.api.nvim_buf_add_highlight( + buf, + constants.hl, + hl[1], + hl[2], + hl[3], + hl[4] + ) end if cursor then @@ -412,7 +409,7 @@ end function view:focus_flash(duration, group, start, finish) local buf = self:buffer() - vim.hl.range(buf, constants.hl_tmp, group, start, finish, {}) + vim.highlight.range(buf, constants.hl_tmp, group, start, finish, {}) vim.defer_fn(function() if vim.api.nvim_buf_is_valid(buf) then @@ -860,12 +857,7 @@ function view:delete() end util.clear_extmarks(0, { lnum_idx, highlight[2] }, { lnum_idx, -1 }, {}) - util.add_highlight( - 0, - 'CarbonDanger', - { lnum_idx, highlight[2] }, - { lnum_idx, -1 } - ) + util.add_highlight(0, 'CarbonDanger', lnum_idx, highlight[2], -1) vim.cmd.redraw() @@ -899,7 +891,7 @@ function view:delete() util.clear_extmarks(0, { lnum_idx, 0 }, { lnum_idx, -1 }, {}) for _, lhl in ipairs(cursor.line.highlights) do - util.add_highlight(0, lhl[1], { lnum_idx, lhl[2] }, { lnum_idx, lhl[3] }) + util.add_highlight(0, lhl[1], lnum_idx, lhl[2], lhl[3]) end self:render() @@ -932,12 +924,7 @@ function view:move() end util.clear_extmarks(0, { lnum_idx, start_hl }, { lnum_idx, -1 }, {}) - util.add_highlight( - 0, - 'CarbonPending', - { lnum_idx, start_hl }, - { lnum_idx, -1 } - ) + util.add_highlight(0, 'CarbonPending', lnum_idx, start_hl, -1) vim.cmd.redraw({ bang = true }) vim.cmd.echohl('CarbonPending')