mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Use utils get_node_text to get line content and trim all whitespaces.
This commit is contained in:
parent
3aa7e575e2
commit
9ad47c65bd
2 changed files with 3 additions and 4 deletions
|
|
@ -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 = ' -> '
|
||||
}
|
||||
<
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue