40 lines
1.2 KiB
Lua
40 lines
1.2 KiB
Lua
-- lua/custom-functions.lua
|
|
-- A library file with custom functions for cleaner code elsewhere
|
|
|
|
local C = {}
|
|
function C.RunCommand(Command)
|
|
-- TODO IMplement an autocompiler function based on context
|
|
local tt = require("toggleterm")
|
|
local command = string.lower(Command)
|
|
if command == "l" or command == "last" then tt.exec("clear && fc -e -\r") end
|
|
if command == "c" or command == "compile" then tt.exec("clear && make\r") end
|
|
vim.defer_fn(function ()
|
|
vim.api.nvim_echo({
|
|
{ "▶ Terminal: ", "WarningMsg" },
|
|
{ "Running previous terminal command... ", "Normal" },
|
|
}, true, {})
|
|
end, 50)
|
|
return ""
|
|
end
|
|
-- Save current layout snapshot
|
|
-- vim.keymap.set("n", "<leader>ss", function()
|
|
function C.saveSnapshot()
|
|
vim.cmd("mksession! " .. vim.fn.stdpath("config") .. "/layout_snap.vim")
|
|
print("Layout snapshot saved.")
|
|
end
|
|
|
|
-- Restore layout snapshot
|
|
-- vim.keymap.set("n", "<leader>sr", function()
|
|
function C.returnSnapshot()
|
|
local path = vim.fn.stdpath("config") .. "/layout_snap.vim"
|
|
if vim.fn.filereadable(path) == 1 then
|
|
vim.cmd("source " .. path)
|
|
print("Layout snapshot restored.")
|
|
else
|
|
print("No layout snapshot found.")
|
|
end
|
|
end
|
|
|
|
|
|
return C
|