nvim: execute current buffer as lua script by :write and :luafile
This commit is contained in:
parent
62dacd2c04
commit
f0011b9eb1
1 changed files with 7 additions and 4 deletions
|
@ -40,12 +40,15 @@ M.execute_selection = function()
|
|||
M.execute_lines(unpack(selection))
|
||||
end
|
||||
|
||||
---Execute lua script in a file.
|
||||
---@param path string|nil Path to the file to execute. If nil, write and source
|
||||
--- current buffer.
|
||||
M.execute_file = function(path)
|
||||
if path then
|
||||
vim.cmd.luafile(path)
|
||||
else
|
||||
M.execute_lines(1, vim.fn.line("$"))
|
||||
if not path then
|
||||
path = vim.fn.expand("%")
|
||||
vim.cmd.write()
|
||||
end
|
||||
vim.cmd.luafile(path)
|
||||
end
|
||||
|
||||
---Edit a lua module.
|
||||
|
|
Loading…
Add table
Reference in a new issue