Add searching for Fig files

This commit is contained in:
Christian Nieves
2024-06-03 18:19:12 +00:00
parent 6e639bf24a
commit c233e7b78d
5 changed files with 74 additions and 12 deletions

View File

@ -2,6 +2,17 @@ local M = {
use_google_cache = nil,
}
function M.exec(command, args)
local Job = require("plenary.job")
local job = Job:new({
command = command,
args = args,
})
job:sync()
job:wait()
return job:result()
end
function M.map(mode, lhs, rhs, opts)
local options = { noremap = true }
if opts then
@ -11,6 +22,19 @@ function M.map(mode, lhs, rhs, opts)
vim.keymap.set(mode, lhs, rhs, options)
end
function M.file_too_large(filename)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, filename)
if ok and stats and stats.size > max_filesize then
return true
end
return false
end
function M.buf_too_large()
return M.file_too_large(vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()))
end
function M.use_google()
if M.use_google_cache == nil then
M.use_google_cache = M.file_exists(os.getenv("HOME") .. "/use_google")