diff options
Diffstat (limited to 'runtime/lua/vim/highlight.lua')
-rw-r--r-- | runtime/lua/vim/highlight.lua | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/runtime/lua/vim/highlight.lua b/runtime/lua/vim/highlight.lua index ce0a3de520..0012dce081 100644 --- a/runtime/lua/vim/highlight.lua +++ b/runtime/lua/vim/highlight.lua @@ -2,6 +2,22 @@ local api = vim.api local highlight = {} +--@private +function highlight.create(higroup, hi_info, default) + local options = {} + -- TODO: Add validation + for k, v in pairs(hi_info) do + table.insert(options, string.format("%s=%s", k, v)) + end + vim.cmd(string.format([[highlight %s %s %s]], default and "default" or "", higroup, table.concat(options, " "))) +end + +--@private +function highlight.link(higroup, link_to, force) + vim.cmd(string.format([[highlight%s link %s %s]], force and "!" or " default", higroup, link_to)) +end + + --- Highlight range between two positions --- --@param bufnr number of buffer to apply highlighting to @@ -14,7 +30,7 @@ function highlight.range(bufnr, ns, higroup, start, finish, rtype, inclusive) inclusive = inclusive or false -- sanity check - if start[2] < 0 or finish[2] < start[2] then return end + if start[2] < 0 or finish[1] < start[1] then return end local region = vim.region(bufnr, start, finish, rtype, inclusive) for linenr, cols in pairs(region) do |