Files
dotfiles/vim/.vim/lua/utils.lua
Christian Nieves e588888143 bs blink/cmp
2025-04-01 19:08:23 +00:00

61 lines
1.1 KiB
Lua

local M = {
use_google_cache = nil,
flags = { blink = true },
}
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
options = vim.tbl_extend("force", options, opts)
end
-- vim.api.nvim_set_keymap(mode, lhs, rhs, options)
vim.keymap.set(mode, lhs, rhs, options)
end
function M.use_google()
if M.use_google_cache == nil then
M.use_google_cache = M.file_exists(vim.env.HOME .. "/use_google")
end
return M.use_google_cache
end
function M.file_exists(name)
local f = io.open(name, "r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
function M.log(message)
local log_file_path = vim.fn.expand("$HOME/nvim.log")
local log_file = io.open(log_file_path, "a")
io.output(log_file)
io.write(message .. "\n")
io.close(log_file)
end
function M.TableConcat(t1, t2)
for i = 1, #t2 do
t1[#t1 + 1] = t2[i]
end
return t1
end
M.flags.blink = not M.use_google()
return M