diff --git a/.github/workflows/bump-commons.yml b/.github/workflows/bump-commons.yml index 79dc442..4ddc0ef 100644 --- a/.github/workflows/bump-commons.yml +++ b/.github/workflows/bump-commons.yml @@ -26,4 +26,4 @@ jobs: - uses: stefanzweifel/git-auto-commit-action@v5 if: ${{ github.ref != 'refs/heads/master' }} with: - commit_message: "chore(pr): auto-commit" + commit_message: "build(deps): bump commons.nvim deps" diff --git a/lua/gitlinker.lua b/lua/gitlinker.lua index 9a9ede1..2b4ec78 100644 --- a/lua/gitlinker.lua +++ b/lua/gitlinker.lua @@ -262,16 +262,16 @@ local _link = function(opts) end if lk.file_changed and warn_on_file_change then local warning = string.format( - "Line numbers can be wrong, %s has changed since %s", + "line numbers can be wrong, %s has changed since %s", lk.file, string.sub(lk.rev, 1, 8) ) - vim.notify(warning:gsub("%%", "%%%%"), vim.log.levels.WARN) + log.warn(warning:gsub("%%", "%%%%")) end if message then ---@diagnostic disable-next-line: need-check-nil - vim.notify(url:gsub("%%", "%%%%") --[[@as string]]) + log.info(url:gsub("%%", "%%%%") --[[@as string]]) end return url diff --git a/lua/gitlinker/commons/log.lua b/lua/gitlinker/commons/log.lua index 3479642..f2a9bcf 100644 --- a/lua/gitlinker/commons/log.lua +++ b/lua/gitlinker/commons/log.lua @@ -31,7 +31,7 @@ local LogConfigs = { file_name = nil, } ---- @param opts {name: string, level: integer?, use_console: boolean?, use_file: boolean?, file_name: string?}? +--- @param opts {name: string?, level: integer?, use_console: boolean?, use_file: boolean?, file_name: string?}? local function setup(opts) opts = opts or {} local level = opts.level or LogLevels.INFO @@ -45,7 +45,9 @@ local function setup(opts) local name = opts.name local file_name = opts.file_name - LogConfigs.name = name + if type(name) == "string" and string.len(name) > 0 then + LogConfigs.name = name + end LogConfigs.level = level LogConfigs.use_console = use_console LogConfigs.use_file = use_file @@ -66,14 +68,11 @@ local function log(level, msg) if LogConfigs.use_console and level >= LogLevels.INFO then for _, line in ipairs(msg_lines) do if type(line) == "string" and string.len(line) > 0 then - local msg_chunks = {} - table.insert(msg_chunks, { - string.format("[%s] %s", LogConfigs.name, line), - LogHighlights[level], - }) - vim.schedule(function() - vim.api.nvim_echo(msg_chunks, true, {}) - end) + local fmt_line = line + if type(LogConfigs.name) == "string" and string.len(LogConfigs.name) > 0 then + fmt_line = string.format("[%s] %s", LogConfigs.name, line) + end + vim.notify(fmt_line, level) end end end