refactor(iferr): use vim.system

This commit is contained in:
Oleksandr Smirnov 2025-02-28 14:39:52 +02:00
parent f4e20f1a51
commit fd47bc3f6c
No known key found for this signature in database
2 changed files with 36 additions and 11 deletions

View file

@ -3,8 +3,9 @@ local log = require "gopher._utils.log"
local utils = {}
---@param msg string
---@param lvl number
---@param lvl? number
function utils.deferred_notify(msg, lvl)
lvl = lvl or vim.log.levels.INFO
vim.defer_fn(function()
vim.notify(msg, lvl, {
title = c.___plugin_name,
@ -23,4 +24,22 @@ function utils.notify(msg, lvl)
log.debug(msg)
end
---@param path string
---@return string
function utils.readfile_joined(path)
return table.concat(vim.fn.readfile(path), "\n")
end
---@param t string[]
---@return string[]
function utils.remove_empty_lines(t)
local res = {}
for _, line in ipairs(t) do
if line ~= "" then
table.insert(res, line)
end
end
return res
end
return utils