Replace print() with vim.notify() (#64)

pull/67/head
Craig Rodrigues 3 years ago committed by GitHub
parent 3a35bff71e
commit 483b56f4a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -48,7 +48,7 @@ end
function go.setup(cfg)
cfg = cfg or {}
if cfg.max_len then
print("go.nvim max_len renamed to max_line_len")
vim.notify("go.nvim max_len renamed to max_line_len", vim.lsp.log_levels.WARN)
end
_GO_NVIM_CFG = vim.tbl_extend("force", _GO_NVIM_CFG, cfg)
@ -192,7 +192,7 @@ go.set_test_runner = function(runner)
return
end
end
print("runner not supported " .. runner)
vim.notify("runner not supported " .. runner, vim.lsp.log_levels.ERROR)
end
go.dbg_complete = function(arglead, cmdline, cursorpos)

@ -4,7 +4,7 @@ function M.switch(bang, cmd)
local root = ""
local alt_file = ""
if #file <= 1 then
print("no buffer name")
vim.notify("no buffer name", vim.lsp.log_levels.ERROR)
return
end
local s, e = string.find(file, "_test%.go$")
@ -16,10 +16,10 @@ function M.switch(bang, cmd)
root = vim.fn.split(file, '.go')[1]
alt_file = root .. '_test.go'
else
print('not a go file')
vim.notify('not a go file', vim.lsp.log_levels.ERROR)
end
if not vim.fn.filereadable(alt_file) and not vim.fn.bufexists(alt_file) and not bang then
print("couldn't find " .. alt_file)
vim.notify("couldn't find " .. alt_file, vim.lsp.log_levels.ERROR)
return
elseif #cmd <= 1 then
local ocmd = "e " .. alt_file

@ -118,7 +118,7 @@ function M.make(...)
if type(cmd) == "table" then
cmd = table.concat(cmd, " ")
end
print(cmd .. " finished")
vim.notify(cmd .. " finished", vim.lsp.log_levels.WARN)
end
end

@ -53,7 +53,7 @@ function M.define(bufnr, name, opts, redefine)
sign_define_cache[bufnr] = {}
end
-- log(bufnr, name, opts, redefine)
-- print(bufnr, name, opts, redefine)
-- vim.notify(bufnr .. name .. opts .. redefine, vim.lsp.log_levels.DEBUG)
if redefine then
sign_define_cache[bufnr][name] = nil
vim.fn.sign_undefine(name)
@ -271,12 +271,12 @@ M.run = function(...)
vim.list_extend(lines, data)
end,
on_stderr = function(job_id, data, event)
print("go coverage finished with message: " .. vim.inspect(tag) .. "error: " .. vim.inspect(data) .. "job"
.. tostring(job_id) .. "ev" .. event)
vim.notify("go coverage finished with message: " .. vim.inspect(tag) .. "error: " .. vim.inspect(data) .. "job"
.. tostring(job_id) .. "ev" .. event, vim.lsp.log_levels.ERROR)
end,
on_exit = function(job_id, data, event)
if event ~= "exit" then
print(job_id, event, vim.inspect(data))
vim.notify(string.format("%s %s %s", job_id, event, vim.inspect(data)), vim.lsp.log_levels.ERROR)
end
log("test finished")
coverage = M.read_cov(cov)

@ -127,7 +127,7 @@ M.run = function(...)
stdout:close()
handle:close()
if code ~= 0 then
print("Delve exited with exit code: ", code)
vim.notify(string.format("Delve exited with exit code: %d", code), vim.lsp.log_levels.WARN)
end
end)
assert(handle, "Error running dlv: " .. tostring(pid_or_err))

@ -100,7 +100,7 @@ M.run = function(type, args)
vim.lsp.util.open_floating_preview(data, 'go', config)
-- local result = vim.fn.json_decode(data)
-- if result.errors ~= nil or result.lines == nil or result["start"] == nil or result["start"] == 0 then
-- print("failed to get doc" .. vim.inspect(result))
-- vim.notify("failed to get doc" .. vim.inspect(result), vim.lsp.log_levels.ERROR)
-- end
end
})

@ -18,9 +18,9 @@ local run = function(fmtargs, from_buffer, cmd)
local args = vim.deepcopy(fmtargs)
if not from_buffer then
table.insert(args, api.nvim_buf_get_name(0))
print('formatting buffer... ' .. api.nvim_buf_get_name(0) .. vim.inspect(args))
vim.notify('formatting buffer... ' .. api.nvim_buf_get_name(0) .. vim.inspect(args), vim.lsp.log_levels.DEBUG)
else
print('formatting... ' .. vim.inspect(args))
vim.notify('formatting... ' .. vim.inspect(args), vim.lsp.log_levels.DEBUG)
end
local old_lines = api.nvim_buf_get_lines(0, 0, -1, true)
@ -38,11 +38,11 @@ local run = function(fmtargs, from_buffer, cmd)
return
end
if not utils.check_same(old_lines, data) then
print("updating codes")
vim.notify("updating codes", vim.lsp.log_levels.DEBUG)
api.nvim_buf_set_lines(0, 0, -1, false, data)
api.nvim_command("write")
else
print("already formatted")
vim.notify("already formatted", vim.lsp.log_levels.DEBUG)
end
-- log("stdout" .. vim.inspect(data))
old_lines = nil

@ -7,7 +7,7 @@ function m.help_complete(arglead, cmdline, cursorpos)
if #help_items < 1 then
local doc = vim.fn.systemlist('go help')
if vim.v.shell_error ~= 0 then
print('failed to run go help ', vim.v.shell_error)
vim.notify(string.format("failed to run go help %d", vim.v.shell_error), vim.lsp.log_levels.ERROR)
return
end

@ -9,7 +9,7 @@ local run = function(...)
local arg = {...}
if #arg < 3 then
print("Usage: GoImpl f *File io.Reader")
vim.notify("Usage: GoImpl f *File io.Reader", vim.lsp.log_levels.WARN)
end
local rec1 = select(1, ...)

@ -40,7 +40,7 @@ end
local function go_install(pkg)
local u = url[pkg]
if u == nil then
print("command " .. pkg .. " not supported, please update install.lua, or manually install it")
vim.notify("command " .. pkg .. " not supported, please update install.lua, or manually install it", vim.lsp.log_levels.WARN)
return
end
@ -58,19 +58,19 @@ local function go_install(pkg)
if #data > 1 then
msg = msg .. data
end
print(msg)
vim.notify(msg, vim.lsp.log_levels.DEBUG)
end,
})
end
local function install(bin, verbose)
if not is_installed(bin) then
print("installing " .. bin)
vim.notify("installing " .. bin, vim.lsp.log_levels.INFO)
go_install(bin)
else
if verbose then
print(bin .. " already install, use GoUpdateBinary to update it")
end
vim.notify(bin .. " already install, use GoUpdateBinary to update it", vim.lsp.log_levels.INFO)
end
end
end

@ -53,7 +53,7 @@ local function fill(cmd)
end
local json = fn.json_decode(str)
if #json == 0 then
print('reftools', cmd, 'finished with no result')
vim.notify('reftools ' .. cmd .. ' finished with no result', vim.lsp.log_levels.DEBUG)
end
local result = json[1]
@ -89,7 +89,7 @@ function reftool.fixplurals()
vim.fn.jobstart(setup, {
on_stdout = function(jobid, data, event)
vim.cmd(cdback)
-- print("fixplurals finished ")
-- vim.notify('fixplurals finished ', vim.lsp.log_levels.DEBUG)
end
})
end

@ -41,14 +41,14 @@ local run = function(to_identifier, ...)
local setup = {gorename, "-offset", offset, "-to", to_identifier}
-- print("setup: ", vim.inspect(setup))
-- vim.notify("setup: " .. vim.inspect(setup), vim.lsp.log_levels.DEBUG)
--
-- local arg = {...}
-- for i, v in ipairs(arg) do
-- table.insert(setup, v)
-- end
--
-- print(vim.inspect(setup))
-- vim.notify(vim.inspect(setup), vim.lsp.log_levels.DEBUG)
local j = vim.fn.jobstart(setup, {
on_stdout = function(jobid, data, event)
data = utils.handle_job_data(data)
@ -58,9 +58,9 @@ local run = function(to_identifier, ...)
-- local result = vim.fn.json_decode(data)
local result = vim.json.decode(data)
if result.errors ~= nil or result.lines == nil or result["start"] == nil or result["start"] == 0 then
print("failed to rename" .. vim.inspect(result))
vim.notify("failed to rename" .. vim.inspect(result), vim.lsp.log_levels.ERROR)
end
print("renamed to " .. to_identifier)
vim.notify("renamed to " .. to_identifier, vim.lsp.log_levels.DEBUG)
end
})
end

@ -90,7 +90,7 @@ local run = function(cmd, opts)
uv.read_start(stderr, function(err, data)
assert(not err, err)
if data then
print("stderr chunk", stderr, data)
vim.notify(string.format("stderr chunk", stderr, data), vim.lsp.log_levels.DEBUG)
end
end)
stdout:read_start(update_chunk)

@ -24,7 +24,7 @@ tags.modify = function(...)
return
end
-- print("parnode" .. vim.inspect(ns))
-- vim.notify("parnode" .. vim.inspect(ns), vim.lsp.log_levels.DEBUG)
local struct_name = ns.name
local rs, re = ns.dim.s.r, ns.dim.e.r
local setup = {gomodify, "-format", "json", "-file", fname, '-w'}
@ -49,7 +49,7 @@ tags.modify = function(...)
if #arg == 1 and arg[1] ~= "-clear-tags" then
table.insert(setup, "json")
end
-- print(vim.inspect(setup))
-- vim.notify(vim.inspect(setup), vim.lsp.log_levels.DEBUG)
local j = vim.fn.jobstart(setup, {
on_stdout = function(jobid, data, event)
data = utils.handle_job_data(data)
@ -57,10 +57,10 @@ tags.modify = function(...)
return
end
local tagged = vim.fn.json_decode(data)
-- print(vim.inspect(tagged))
-- print(tagged["start"], tagged["end"], tagged.lines)
-- vim.notify(vim.inspect(tagged), vim.lsp.log_levels.DEBUG)
-- vim.notify(tagged["start"] .. " " .. tagged["end"] .. " " .. tagged.lines, vim.lsp.log_levels.ERROR)
if tagged.errors ~= nil or tagged.lines == nil or tagged["start"] == nil or tagged["start"] == 0 then
print("failed to set tags" .. vim.inspect(tagged))
vim.notify("failed to set tags" .. vim.inspect(tagged), vim.lsp.log_levels.ERROR)
end
for index, value in ipairs(tagged.lines) do
tagged.lines[index] = utils.rtrim(value)
@ -68,7 +68,7 @@ tags.modify = function(...)
-- trim tail spaces?
vim.api.nvim_buf_set_lines(0, tagged["start"] - 1, tagged["start"] - 1 + #tagged.lines, false, tagged.lines)
vim.cmd("write")
print("struct updated ")
vim.notify("struct updated ", vim.lsp.log_levels.DEBUG)
end
})
end

@ -199,13 +199,13 @@ M.nodes_at_cursor = function(query, default, bufnr, row, col)
end
local nodes = M.get_all_nodes(query, ft, default, bufnr, row, col)
if nodes == nil then
print("Unable to find any nodes. place your cursor on a go symbol and try again")
vim.notify("Unable to find any nodes. place your cursor on a go symbol and try again", vim.lsp.log_levels.WARN)
return nil
end
nodes = M.sort_nodes(M.intersect_nodes(nodes, row, col))
if nodes == nil or #nodes == 0 then
print("Unable to find any nodes at pos. " .. tostring(row) .. ":" .. tostring(col))
vim.notify("Unable to find any nodes at pos. " .. tostring(row) .. ":" .. tostring(col), vim.lsp.log_levels.WARN)
return nil
end

@ -128,7 +128,7 @@ util.log = function(...)
if log_path ~= nil and #log_path > 3 then
local f, err = io.open(log_path, "a+")
if err then
print("failed to open log", log_path, err)
vim.notify("failed to open log" .. log_path .. err, vim.lsp.log_levels.ERROR)
return
end
if not f then
@ -138,7 +138,7 @@ util.log = function(...)
io.write(str .. "\n")
io.close(f)
else
print(str .. "\n")
vim.notify(str .. "\n", vim.lsp.log_levels.DEBUG)
end
end
end

Loading…
Cancel
Save