From d64ba1fc04d925c8b819b334a429ab93bac63434 Mon Sep 17 00:00:00 2001 From: JafarAbdi Date: Sat, 26 Mar 2022 07:30:24 +0300 Subject: [PATCH] Add option to highlight cursor in case cursorlineopt is set to only number --- lua/nvim-treesitter-refactor.lua | 1 + lua/nvim-treesitter-refactor/highlight_current_scope.lua | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/nvim-treesitter-refactor.lua b/lua/nvim-treesitter-refactor.lua index 38cb36f..697ebfa 100644 --- a/lua/nvim-treesitter-refactor.lua +++ b/lua/nvim-treesitter-refactor.lua @@ -18,6 +18,7 @@ function M.init() disable = {}, is_supported = queries.has_locals, highlight_eol = false, + highlight_cursor = false, }, smart_rename = { module_path = "nvim-treesitter-refactor.smart_rename", diff --git a/lua/nvim-treesitter-refactor/highlight_current_scope.lua b/lua/nvim-treesitter-refactor/highlight_current_scope.lua index 9ad7302..53bd531 100644 --- a/lua/nvim-treesitter-refactor/highlight_current_scope.lua +++ b/lua/nvim-treesitter-refactor/highlight_current_scope.lua @@ -17,9 +17,9 @@ function M.highlight_current_scope(bufnr) local current_scope = locals.containing_scope(node_at_point, bufnr) if current_scope then + local config = configs.get_module "refactor.highlight_current_scope" -- Highlight range [start_line, end_line) 0-based local highlighter = function(start_line, end_line) - local config = configs.get_module "refactor.highlight_current_scope" vim.api.nvim_buf_set_extmark(bufnr, current_scope_namespace, math.max(vim.fn.line("w0") - 1, start_line), 0, { end_row = math.min(vim.fn.line("w$"), end_line), end_col = 0, @@ -30,7 +30,7 @@ function M.highlight_current_scope(bufnr) local start_line, _, end_line, _ = current_scope:range() if start_line ~= 0 or end_line ~= vim.fn.line("$") then - highlighter(start_line, vim.fn.line(".") - 1) + highlighter(start_line, vim.fn.line(".") + (config.highlight_cursor and 0 or -1)) highlighter(vim.fn.line("."), end_line + 1) end end