added run command
This commit is contained in:
@@ -264,7 +264,8 @@ local function packer_startup(use)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
---@param name string
|
||||||
|
---@return boolean
|
||||||
local function file_exists(name)
|
local function file_exists(name)
|
||||||
local f = io.open(name,"r")
|
local f = io.open(name,"r")
|
||||||
|
|
||||||
@@ -303,8 +304,35 @@ do
|
|||||||
end,
|
end,
|
||||||
{ nargs = 0 }
|
{ nargs = 0 }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
---@type function
|
||||||
|
local run_file
|
||||||
|
do
|
||||||
|
local run_script_name = "run.sh"
|
||||||
|
|
||||||
|
run_file = function()
|
||||||
|
---@type "Linux" | "Darwin" | "Windows_NT"
|
||||||
|
local os_name = vim.loop.os_uname().sysname
|
||||||
|
if os_name ~= "Linux" then
|
||||||
|
error('run_file not implemented for non-linux platforms')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local run_script_path = vim.fn.getcwd() .. "/" .. run_script_name
|
||||||
|
if not file_exists(run_script_path) then
|
||||||
|
error( "The run script: '" .. run_script_path .. "' does not exist")
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.cmd('!sh ' .. run_script_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set(
|
||||||
|
'n',
|
||||||
|
keymap.test_execute_file,
|
||||||
|
run_file,
|
||||||
|
{ silent = true }
|
||||||
|
)
|
||||||
|
|
||||||
---Splits the line under the cursor into multiple lines.
|
---Splits the line under the cursor into multiple lines.
|
||||||
---Works on lines with properly opening and closing brackets: (),[],{}
|
---Works on lines with properly opening and closing brackets: (),[],{}
|
||||||
---Starts at the cursor position and moves to the right until it finds an opening bracket.
|
---Starts at the cursor position and moves to the right until it finds an opening bracket.
|
||||||
|
|||||||
Reference in New Issue
Block a user