This commit is contained in:
Christian Nieves
2024-11-25 19:19:53 +00:00
parent 22d681a3d2
commit 33e88f60ba
2 changed files with 92 additions and 90 deletions

View File

@ -1,14 +1,16 @@
require("bigfile").setup { return {
filesize = 2, -- size of the file in MiB, the plugin round file sizes to the closest MiB require("bigfile").setup {
pattern = { "*" }, -- autocmd pattern or function see <### Overriding the detection of big files> filesize = 2, -- size of the file in MiB, the plugin round file sizes to the closest MiB
features = { -- features to disable pattern = { "*" }, -- autocmd pattern or function see <### Overriding the detection of big files>
"indent_blankline", features = { -- features to disable
"illuminate", "indent_blankline",
"lsp", "illuminate",
"treesitter", "lsp",
"syntax", "treesitter",
"matchparen", "syntax",
"vimopts", "matchparen",
"filetype", "vimopts",
}, "filetype",
},
}
} }

View File

@ -1,108 +1,108 @@
local M = { local M = {
use_google_cache = nil, use_google_cache = nil,
} }
function M.exec(command, args) function M.exec(command, args)
local Job = require("plenary.job") local Job = require("plenary.job")
local job = Job:new({ local job = Job:new({
command = command, command = command,
args = args, args = args,
}) })
job:sync() job:sync()
job:wait() job:wait()
return job:result() return job:result()
end end
function M.map(mode, lhs, rhs, opts) function M.map(mode, lhs, rhs, opts)
local options = { noremap = true } local options = { noremap = true }
if opts then if opts then
options = vim.tbl_extend("force", options, opts) options = vim.tbl_extend("force", options, opts)
end end
-- vim.api.nvim_set_keymap(mode, lhs, rhs, options) -- vim.api.nvim_set_keymap(mode, lhs, rhs, options)
vim.keymap.set(mode, lhs, rhs, options) vim.keymap.set(mode, lhs, rhs, options)
end end
function M.file_too_large(filename) function M.file_too_large(filename)
local max_filesize = 2000 * 1024 -- 2MB local max_filesize = 2000 * 1024 -- 2MB
local ok, stats = pcall(vim.loop.fs_stat, filename) local ok, stats = pcall(vim.loop.fs_stat, filename)
if ok and stats and stats.size > max_filesize then if ok and stats and stats.size > max_filesize then
return true return true
end end
return false return false
end end
function M.use_google() function M.use_google()
if M.use_google_cache == nil then if M.use_google_cache == nil then
M.use_google_cache = M.file_exists(os.getenv("HOME") .. "/use_google") M.use_google_cache = M.file_exists(os.getenv("HOME") .. "/use_google")
end end
return M.use_google_cache return M.use_google_cache
end end
function M.file_exists(name) function M.file_exists(name)
local f = io.open(name, "r") local f = io.open(name, "r")
if f ~= nil then if f ~= nil then
io.close(f) io.close(f)
return true return true
else else
return false return false
end end
end end
function M.dump(o) function M.dump(o)
if type(o) == "table" then if type(o) == "table" then
local s = "{ " local s = "{ "
for k, v in pairs(o) do for k, v in pairs(o) do
if type(k) ~= "number" then if type(k) ~= "number" then
k = '"' .. k .. '"' k = '"' .. k .. '"'
end end
s = s .. "[" .. k .. "] = " .. M.dump(v) .. "," s = s .. "[" .. k .. "] = " .. M.dump(v) .. ","
end end
return s .. "} " return s .. "} "
else else
return tostring(o) return tostring(o)
end end
end end
function M.tprint(tbl, indent) function M.tprint(tbl, indent)
if not indent then if not indent then
indent = 0 indent = 0
end end
local toprint = string.rep(" ", indent) .. "{\r\n" local toprint = string.rep(" ", indent) .. "{\r\n"
indent = indent + 2 indent = indent + 2
for k, v in pairs(tbl) do for k, v in pairs(tbl) do
toprint = toprint .. string.rep(" ", indent) toprint = toprint .. string.rep(" ", indent)
if type(k) == "number" then if type(k) == "number" then
toprint = toprint .. "[" .. k .. "] = " toprint = toprint .. "[" .. k .. "] = "
elseif type(k) == "string" then elseif type(k) == "string" then
toprint = toprint .. k .. "= " toprint = toprint .. k .. "= "
end end
if type(v) == "number" then if type(v) == "number" then
toprint = toprint .. v .. ",\r\n" toprint = toprint .. v .. ",\r\n"
elseif type(v) == "string" then elseif type(v) == "string" then
toprint = toprint .. '"' .. v .. '",\r\n' toprint = toprint .. '"' .. v .. '",\r\n'
elseif type(v) == "table" then elseif type(v) == "table" then
toprint = toprint .. M.tprint(v, indent + 2) .. ",\r\n" toprint = toprint .. M.tprint(v, indent + 2) .. ",\r\n"
else else
toprint = toprint .. '"' .. tostring(v) .. '",\r\n' toprint = toprint .. '"' .. tostring(v) .. '",\r\n'
end end
end end
toprint = toprint .. string.rep(" ", indent - 2) .. "}" toprint = toprint .. string.rep(" ", indent - 2) .. "}"
return toprint return toprint
end end
function M.log(message) function M.log(message)
local log_file_path = vim.fn.expand("$HOME/nvim.log") local log_file_path = vim.fn.expand("$HOME/nvim.log")
local log_file = io.open(log_file_path, "a") local log_file = io.open(log_file_path, "a")
io.output(log_file) io.output(log_file)
io.write(message .. "\n") io.write(message .. "\n")
io.close(log_file) io.close(log_file)
end end
function M.TableConcat(t1, t2) function M.TableConcat(t1, t2)
for i = 1, #t2 do for i = 1, #t2 do
t1[#t1 + 1] = t2[i] t1[#t1 + 1] = t2[i]
end end
return t1 return t1
end end
return M return M