diff options
| -rw-r--r-- | doc/nvim-treesitter.txt | 2 | ||||
| -rw-r--r-- | lua/nvim-treesitter.lua | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index c6ea4ed30..dee1ff8b7 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -425,7 +425,7 @@ Default options (lua syntax): { indicator_size = 100, type_patterns = {'class', 'function', 'method'}, - transform_fn = function(line) return line:gsub('[%[%(%{]*%s*$', '') end, + transform_fn = function(line) return line:gsub('%s*[%[%(%{]*%s*$', '') end, separator = ' -> ' } < diff --git a/lua/nvim-treesitter.lua b/lua/nvim-treesitter.lua index 1eb5276f2..cd1b68509 100644 --- a/lua/nvim-treesitter.lua +++ b/lua/nvim-treesitter.lua @@ -37,15 +37,14 @@ local get_line_for_node = function(node, type_patterns, transform_fn) end end if not is_valid then return '' end - local range = {node:range()} - local line = transform_fn(vim.trim(vim.fn.getline(range[1] + 1))) + local line = transform_fn(vim.trim(ts_utils.get_node_text(node)[1] or '')) -- Escape % to avoid statusline to evaluate content as expression return line:gsub('%%', '%%%%') end -- Trim spaces and opening brackets from end local transform_line = function(line) - return line:gsub('[%[%(%{]*%s*$', '') + return line:gsub('%s*[%[%(%{]*%s*$', '') end function M.statusline(opts) |
