gopher.nvim/lua/gopher/_utils/init.lua
Smirnov Oleksandr c0b2834652
docs: update (#103)
* chore: add @dochide annotation

- it's easier to distinguish @private and something i dont want to see in docs

* docs: update

* refactor: move thing out to utils

* fix: lua-ls error

* fixup! refactor: move thing out to utils

* docs: update
2025-03-23 15:46:54 +02:00

41 lines
814 B
Lua

local c = require "gopher.config"
local log = require "gopher._utils.log"
local utils = {}
---@param msg string
---@param lvl? number
function utils.notify(msg, lvl)
lvl = lvl or vim.log.levels.INFO
vim.notify(msg, lvl, {
---@diagnostic disable-next-line:undefined-field
title = c.___plugin_name,
})
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
---@param s string
---@return string
function utils.trimend(s)
local r, _ = string.gsub(s, "%s+$", "")
return r
end
return utils