mirror of
https://github.com/windwp/nvim-ts-autotag.git
synced 2024-12-28 21:19:16 -06:00
Merge pull request #175 from PriceHiller/fix/0.9.5-funcs
fix: use `0.9.5` compatible vim funcs
This commit is contained in:
commit
cb57b07803
@ -1,3 +1,5 @@
|
||||
local utils = require("nvim-ts-autotag.utils")
|
||||
|
||||
---@alias nvim-ts-autotag.FiletypeConfigPattern string[] A single array of patterns
|
||||
|
||||
---@alias nvim-ts-autotag.FiletypeConfig.filetype string The supported filetype for a given Filetype Config
|
||||
@ -83,7 +85,7 @@ function FiletypeConfig:extend(filetype, patterns)
|
||||
new.filetype = filetype
|
||||
for pat_key, pats in pairs(patterns or {}) do
|
||||
for _, pat in ipairs(pats) do
|
||||
if not vim.list_contains(new.patterns[pat_key], pat) then
|
||||
if not utils.list_contains(new.patterns[pat_key], pat) then
|
||||
table.insert(new.patterns[pat_key], pat)
|
||||
end
|
||||
end
|
||||
|
@ -214,7 +214,7 @@ local function check_close_tag(close_slash_tag)
|
||||
})
|
||||
if tag_node ~= nil then
|
||||
local tag_name = get_tag_name(tag_node)
|
||||
if tag_name ~= nil and vim.list_contains(ts_tag.skip_tag_pattern, tag_name) then
|
||||
if tag_name ~= nil and utils.list_contains(ts_tag.skip_tag_pattern, tag_name) then
|
||||
return false
|
||||
end
|
||||
if tag_node ~= nil then
|
||||
|
@ -7,6 +7,25 @@ M.get_node_text = function(node)
|
||||
return vim.split(txt, "\n") or {}
|
||||
end
|
||||
|
||||
-- Stolen from nvim `0.10.0` for `0.9.5` users
|
||||
--- Checks if a list-like table (integer keys without gaps) contains `value`.
|
||||
---
|
||||
---
|
||||
---@param t table Table to check (must be list-like, not validated)
|
||||
---@param value any Value to compare
|
||||
---@return boolean `true` if `t` contains `value`
|
||||
M.list_contains = function(t, value)
|
||||
vim.validate({ t = { t, "t" } })
|
||||
--- @cast t table<any,any>
|
||||
|
||||
for _, v in ipairs(t) do
|
||||
if v == value then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
M.verify_node = function(node, node_tag)
|
||||
local txt = get_node_text(node, vim.api.nvim_get_current_buf())
|
||||
if txt:match(string.format("^<%s>", node_tag)) and txt:match(string.format("</%s>$", node_tag)) then
|
||||
|
@ -72,7 +72,7 @@ local compare_text = function(linenr, text_after, name, cursor_add, end_cursor)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local islist = vim.islist or vim.tbl_islist
|
||||
M.Test_withfile = function(test_data, cb)
|
||||
for _, value in pairs(test_data) do
|
||||
it("test " .. value.name, function()
|
||||
@ -82,7 +82,7 @@ M.Test_withfile = function(test_data, cb)
|
||||
linenr = value.linenr,
|
||||
colnr = 0,
|
||||
}
|
||||
if not vim.islist(value.before) then
|
||||
if not islist(value.before) then
|
||||
value.before = { value.before }
|
||||
end
|
||||
for index, text in pairs(value.before) do
|
||||
@ -95,7 +95,7 @@ M.Test_withfile = function(test_data, cb)
|
||||
end
|
||||
end
|
||||
end
|
||||
if not vim.islist(value.after) then
|
||||
if not islist(value.after) then
|
||||
value.after = { value.after }
|
||||
end
|
||||
vim.bo.filetype = value.filetype or "text"
|
||||
|
@ -7,8 +7,9 @@ local M = {}
|
||||
local function search_dir_up(test_file)
|
||||
-- This is the path of the directory of the current file
|
||||
local cur_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p")
|
||||
local uv = vim.uv or vim.loop
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
while not vim.uv.fs_stat(cur_dir .. "/" .. test_file, nil) and cur_dir ~= "/" do
|
||||
while not uv.fs_stat(cur_dir .. "/" .. test_file, nil) and cur_dir ~= "/" do
|
||||
cur_dir = vim.fn.fnamemodify(cur_dir, ":h")
|
||||
end
|
||||
if cur_dir == "/" then
|
||||
|
@ -6,9 +6,7 @@ M.paths = path_utils
|
||||
--- Register the main plugin (`nvim-ts-autotag`) on the runtimepath if it hasn't already been
|
||||
--- registered
|
||||
M.rtp_register_ts_autotag = function()
|
||||
if not vim.list_contains(vim.opt.runtimepath, path_utils.static.ts_autotag_dir()) then
|
||||
vim.opt.runtimepath:append(path_utils.static.ts_autotag_dir())
|
||||
end
|
||||
vim.opt.runtimepath:append(path_utils.static.ts_autotag_dir())
|
||||
end
|
||||
|
||||
return M
|
||||
|
Loading…
Reference in New Issue
Block a user