fix: add force to all predicates/directives

So that when any of them are upstreamed, there will not be an issue with
re-adding directives anymore
This commit is contained in:
Pham Huy Hoang 2023-07-01 19:22:23 +09:00 committed by Christian Clason
parent aab2274e2c
commit 58d4b924eb

View file

@ -57,7 +57,7 @@ query.add_predicate("nth?", function(match, _pattern, _bufnr, pred)
end end
return false return false
end) end, true)
---@param match (TSNode|nil)[] ---@param match (TSNode|nil)[]
---@param _pattern string ---@param _pattern string
@ -117,7 +117,7 @@ query.add_predicate("is?", function(match, _pattern, bufnr, pred)
local _, _, kind = locals.find_definition(node, bufnr) local _, _, kind = locals.find_definition(node, bufnr)
return vim.tbl_contains(types, kind) return vim.tbl_contains(types, kind)
end) end, true)
---@param match (TSNode|nil)[] ---@param match (TSNode|nil)[]
---@param _pattern string ---@param _pattern string
@ -137,7 +137,7 @@ query.add_predicate("has-type?", function(match, _pattern, _bufnr, pred)
end end
return vim.tbl_contains(types, node:type()) return vim.tbl_contains(types, node:type())
end) end, true)
---@param match (TSNode|nil)[] ---@param match (TSNode|nil)[]
---@param _ string ---@param _ string
@ -158,7 +158,7 @@ query.add_directive("set-lang-from-mimetype!", function(match, _, bufnr, pred, m
local parts = vim.split(type_attr_value, "/", {}) local parts = vim.split(type_attr_value, "/", {})
metadata.language = parts[#parts] metadata.language = parts[#parts]
end end
end) end, true)
---@param match (TSNode|nil)[] ---@param match (TSNode|nil)[]
---@param _ string ---@param _ string
@ -173,10 +173,10 @@ query.add_directive("set-lang-from-info-string!", function(match, _, bufnr, pred
end end
local injection_alias = vim.treesitter.get_node_text(node, bufnr) local injection_alias = vim.treesitter.get_node_text(node, bufnr)
metadata.language = get_parser_from_markdown_info_string(injection_alias) metadata.language = get_parser_from_markdown_info_string(injection_alias)
end) end, true)
-- Just avoid some annoying warnings for this directive -- Just avoid some annoying warnings for this directive
query.add_directive("make-range!", function() end) query.add_directive("make-range!", function() end, true)
---@param match (TSNode|nil)[] ---@param match (TSNode|nil)[]
---@param _ string ---@param _ string
@ -209,7 +209,7 @@ query.add_directive("downcase!", function(match, _, bufnr, pred, metadata)
else else
metadata[key] = string.lower(text) metadata[key] = string.lower(text)
end end
end) end, true)
---@param match (TSNode|nil)[] ---@param match (TSNode|nil)[]
---@param _pattern string ---@param _pattern string
@ -240,7 +240,7 @@ query.add_directive("exclude_children!", function(match, _pattern, _bufnr, pred,
table.insert(ranges, { start_row, start_col, end_row, end_col }) table.insert(ranges, { start_row, start_col, end_row, end_col })
end end
metadata.content = ranges metadata.content = ranges
end) end, true)
-- Trim blank lines from end of the region -- Trim blank lines from end of the region
-- Arguments are the captures to trim. -- Arguments are the captures to trim.
@ -278,4 +278,4 @@ query.add_directive("trim!", function(match, _, bufnr, pred, metadata)
metadata[id].range = { start_row, start_col, end_row, end_col } metadata[id].range = { start_row, start_col, end_row, end_col }
end end
end end
end) end, true)