cleanup ts logs; utils get build tags renaming

pull/196/head
ray-x 2 years ago
parent ddbb30a38e
commit ce73ef43f0

@ -272,7 +272,8 @@ local setups = {
local function get_build_flags()
local get_build_tags = require("go.gotest").get_build_tags
local tags = get_build_tags({})
local tags = get_build_tags({}, true)
log(vim.inspect(tags))
if tags then
return tags
else

@ -164,21 +164,19 @@ M.get_all_nodes = function(query, lang, defaults, bufnr, pos_row, pos_col, type_
-- stylua: ignore
ulog(
"node ", vim.inspect(node),
"\n path: " .. path .. " op: " .. op
.. " type: " .. type .. "\n txt: "
.. dbg_txt .. "\n range: " .. tostring(a1 or 0)
"node ", vim.inspect(node), "\n path: " .. path .. " op: " .. op
.. " type: " .. type .. "\n txt: " .. dbg_txt .. "\n range: " .. tostring(a1 or 0)
.. ":" .. tostring(b1 or 0) .. " TO " .. tostring(c1 or 0) .. ":" .. tostring(d1 or 0)
)
-- stylua: ignore end
--
-- may not handle complex node
if op == "name" then
ulog("node name " .. name)
-- ulog("node name " .. name)
name = get_node_text(node, bufnr) or ""
type_node = node
elseif op == "declaration" or op == "clause" then
ulog("declare node name " .. op)
declaration_node = node
sRow, sCol, eRow, eCol = ts_utils.get_vim_range({ ts_utils.get_node_range(node) }, bufnr)
else

@ -670,7 +670,7 @@ end
function util.get_build_tags(buf)
local tags = {}
buf = buf or '%'
local pattern = [[^//\s*[+]build\s\+\(.\+\)]]
local pattern = [[^//\s*[+|(go:)]*build\s\+\(.\+\)]]
local cnt = vim.fn.getbufinfo(buf)[1]['linecount']
cnt = math.min(cnt, 10)
for i = 1, cnt do
@ -679,6 +679,9 @@ function util.get_build_tags(buf)
break
end
local t = vim.fn.substitute(line, pattern, [[\1]], '')
-- print(vim.inspect(vim.fn.substitute([[// go:build ui]], [[^//\s*[+|(go:)]*build\s\+\(.\+\)]], [[\1]], '')))
-- print(vim.inspect(vim.fn.substitute([[//go:build ci]], [[^//\s*[+|(go:)]*build\s\+\(.\+\)]], [[\1]], '')))
if t ~= line then -- tag found
t = vim.fn.substitute(t, [[ \+]], ',', 'g')
table.insert(tags, t)

Loading…
Cancel
Save