Wasted way too much time on hydra.nvim shit
This commit is contained in:
parent
fe3c267ca9
commit
8a54d25b3b
17 changed files with 540 additions and 80 deletions
dotfiles/neovim/ftplugin
|
@ -2,24 +2,38 @@ local opts = function(desc)
|
|||
return { desc = desc, buffer = true }
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>lf", ":source %<cr>", opts("Run [l]ua [f]ile "))
|
||||
vim.keymap.set("n", "<leader>ls", function()
|
||||
local path = vim.api.nvim_buf_get_name(0)
|
||||
local status, M = pcall(dofile, path)
|
||||
local function runLocal(functionName)
|
||||
return function()
|
||||
local path = vim.api.nvim_buf_get_name(0)
|
||||
local status, M = pcall(dofile, path)
|
||||
|
||||
if status then
|
||||
if M ~= nil then
|
||||
if type(M.setup) == "function" then
|
||||
M.setup()
|
||||
print("M.setup() executed succesfully!")
|
||||
if status then
|
||||
if M ~= nil then
|
||||
if type(M[functionName]) == "function" then
|
||||
M[functionName]()
|
||||
print("M." .. functionName .. "() executed succesfully!")
|
||||
else
|
||||
print("Module does not return a " .. functionName .. " function")
|
||||
end
|
||||
else
|
||||
print("Module does not return a setup function")
|
||||
print("Module returned nil")
|
||||
end
|
||||
else
|
||||
print("Module returned nil")
|
||||
print("Cannot import current file :(")
|
||||
end
|
||||
else
|
||||
print("Cannot import current file :(")
|
||||
end
|
||||
end, opts("Run .setup() in current file"))
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>lf", ":source %<cr>", opts("Run [l]ua [f]ile "))
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<leader>ls",
|
||||
runLocal("setup"),
|
||||
opts("Run .[s]etup() in current file")
|
||||
)
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<leader>lc",
|
||||
runLocal("config"),
|
||||
opts("Run .[c]onfig() in current file")
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue