diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2024-10-22 19:26:04 +0200 |
|---|---|---|
| committer | Christian Clason <ch.clason+github@icloud.com> | 2024-10-23 09:38:19 +0200 |
| commit | 9210b9a4fa106247333495e19c843710f4d62102 (patch) | |
| tree | 1715808990bde45f4ca4969380bd0e16590c5c4b /lua | |
| parent | bot(lockfile): update editorconfig, erlang, sql (diff) | |
| download | nvim-treesitter-9210b9a4fa106247333495e19c843710f4d62102.tar nvim-treesitter-9210b9a4fa106247333495e19c843710f4d62102.tar.gz nvim-treesitter-9210b9a4fa106247333495e19c843710f4d62102.tar.bz2 nvim-treesitter-9210b9a4fa106247333495e19c843710f4d62102.tar.lz nvim-treesitter-9210b9a4fa106247333495e19c843710f4d62102.tar.xz nvim-treesitter-9210b9a4fa106247333495e19c843710f4d62102.tar.zst nvim-treesitter-9210b9a4fa106247333495e19c843710f4d62102.zip | |
fix(predicates): remove upstreamed predicates and directives
Problem: Overriding upstreamed predicates replaces optimized versions on
Nvim 0.11.
Solution: Now that nvim-treesitter requires Nvim 0.10, simply remove the
upstreamed predicates and directives.
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/query_predicates.lua | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/lua/nvim-treesitter/query_predicates.lua b/lua/nvim-treesitter/query_predicates.lua index 5caaaa8b8..7539170dc 100644 --- a/lua/nvim-treesitter/query_predicates.lua +++ b/lua/nvim-treesitter/query_predicates.lua @@ -64,42 +64,6 @@ end, opts) ---@param match (TSNode|nil)[] ---@param _pattern string ----@param _bufnr integer ----@param pred string[] ----@return boolean|nil -local function has_ancestor(match, _pattern, _bufnr, pred) - if not valid_args(pred[1], pred, 2) then - return - end - - local node = match[pred[2]] - local ancestor_types = { unpack(pred, 3) } - if not node then - return true - end - - local just_direct_parent = pred[1]:find("has-parent", 1, true) - - node = node:parent() - while node do - if vim.tbl_contains(ancestor_types, node:type()) then - return true - end - if just_direct_parent then - node = nil - else - node = node:parent() - end - end - return false -end - -query.add_predicate("has-ancestor?", has_ancestor, opts) - -query.add_predicate("has-parent?", has_ancestor, opts) - ----@param match (TSNode|nil)[] ----@param _pattern string ---@param bufnr integer ---@param pred string[] ---@return boolean|nil @@ -201,41 +165,3 @@ query.add_directive("downcase!", function(match, _, bufnr, pred, metadata) end metadata[id].text = string.lower(text) end, opts) - --- Trim blank lines from end of the region --- Arguments are the captures to trim. ----@param match (TSNode|nil)[] ----@param _ string ----@param bufnr integer ----@param pred string[] ----@param metadata table -query.add_directive("trim!", function(match, _, bufnr, pred, metadata) - for _, id in ipairs { select(2, unpack(pred)) } do - local node = match[id] - local start_row, start_col, end_row, end_col = node:range() - - -- Don't trim if region ends in middle of a line - if end_col ~= 0 then - return - end - - while true do - -- As we only care when end_col == 0, always inspect one line above end_row. - local end_line = vim.api.nvim_buf_get_lines(bufnr, end_row - 1, end_row, true)[1] - - if end_line ~= "" then - break - end - - end_row = end_row - 1 - end - - -- If this produces an invalid range, we just skip it. - if start_row < end_row or (start_row == end_row and start_col <= end_col) then - if not metadata[id] then - metadata[id] = {} - end - metadata[id].range = { start_row, start_col, end_row, end_col } - end - end -end, opts) |
