diff options
| author | francisco souza <108725+fsouza@users.noreply.github.com> | 2022-04-21 10:23:36 -0400 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2022-04-21 23:57:35 +0200 |
| commit | 44b7c8100269161e20d585f24bce322f6dcdf8d2 (patch) | |
| tree | db78c5707331e3218f58643c0d27c86906683771 /lua/nvim-treesitter.lua | |
| parent | Update lockfile.json (diff) | |
| download | nvim-treesitter-44b7c8100269161e20d585f24bce322f6dcdf8d2.tar nvim-treesitter-44b7c8100269161e20d585f24bce322f6dcdf8d2.tar.gz nvim-treesitter-44b7c8100269161e20d585f24bce322f6dcdf8d2.tar.bz2 nvim-treesitter-44b7c8100269161e20d585f24bce322f6dcdf8d2.tar.lz nvim-treesitter-44b7c8100269161e20d585f24bce322f6dcdf8d2.tar.xz nvim-treesitter-44b7c8100269161e20d585f24bce322f6dcdf8d2.tar.zst nvim-treesitter-44b7c8100269161e20d585f24bce322f6dcdf8d2.zip | |
fix(ts_utils): fix swap_nodes after get_node_text change
After some discussion, it looks like the easiest thing to do for now is
to keep a private copy of get_node_text (just to skip the deprecation
message) and invoke that, until core provides an equivalent function
that can return the node content in a table representing the node
"lines".
Also fixes the statusline by calling the private version for
get_node_text until a change is made in core.
Diffstat (limited to 'lua/nvim-treesitter.lua')
| -rw-r--r-- | lua/nvim-treesitter.lua | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/lua/nvim-treesitter.lua b/lua/nvim-treesitter.lua index 0165b5383..efdf21e98 100644 --- a/lua/nvim-treesitter.lua +++ b/lua/nvim-treesitter.lua @@ -3,7 +3,6 @@ local utils = require "nvim-treesitter.utils" local info = require "nvim-treesitter.info" local configs = require "nvim-treesitter.configs" local parsers = require "nvim-treesitter.parsers" -local ts_query = vim.treesitter.query local ts_utils = require "nvim-treesitter.ts_utils" -- Registers all query predicates @@ -22,23 +21,6 @@ function M.define_modules(...) configs.define_modules(...) end -local get_line_for_node = function(node, type_patterns, transform_fn, bufnr) - local node_type = node:type() - local is_valid = false - for _, rgx in ipairs(type_patterns) do - if node_type:find(rgx) then - is_valid = true - break - end - end - if not is_valid then - return "" - end - local line = transform_fn(vim.trim(ts_query.get_node_text(node, bufnr) 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*[%[%(%{]*%s*$", "") @@ -67,7 +49,7 @@ function M.statusline(opts) local expr = current_node while expr do - local line = get_line_for_node(expr, type_patterns, transform_fn, bufnr) + local line = ts_utils._get_line_for_node(expr, type_patterns, transform_fn, bufnr) if line ~= "" and not vim.tbl_contains(lines, line) then table.insert(lines, 1, line) end |
