Made run script function work on all alphabetic characters instead
This commit is contained in:
@@ -21,7 +21,7 @@ local keymap = {
|
|||||||
-- [ ] c++
|
-- [ ] c++
|
||||||
|
|
||||||
--TODO find good keybindings
|
--TODO find good keybindings
|
||||||
test_execute_file = '<leader>e',
|
test_execute_script = '<leader>e',
|
||||||
test_debug_file = '<leader>d',
|
test_debug_file = '<leader>d',
|
||||||
test_toggle_breakpoint = '<leader>b',
|
test_toggle_breakpoint = '<leader>b',
|
||||||
test_step_over = nil,
|
test_step_over = nil,
|
||||||
@@ -305,19 +305,19 @@ vim.api.nvim_create_user_command(
|
|||||||
{ nargs = 0 }
|
{ nargs = 0 }
|
||||||
)
|
)
|
||||||
|
|
||||||
---@type function
|
---Returns function that runs the given script_name in the current working directory.
|
||||||
local run_file
|
---Only implemented for Linux. ( Uses the sh command )
|
||||||
do
|
---@param script_name string
|
||||||
local run_script_name = ".run.sh"
|
---@return fun()
|
||||||
|
local function get_run_script_function(script_name)
|
||||||
run_file = function()
|
return function()
|
||||||
---@type "Linux" | "Darwin" | "Windows_NT"
|
---@type "Linux" | "Darwin" | "Windows_NT"
|
||||||
local os_name = vim.loop.os_uname().sysname
|
local os_name = vim.loop.os_uname().sysname
|
||||||
if os_name ~= "Linux" then
|
if os_name ~= "Linux" then
|
||||||
error('run_file not implemented for non-linux platforms')
|
error('run_file not implemented for non-linux platforms')
|
||||||
end
|
end
|
||||||
|
|
||||||
local run_script_path = vim.fn.getcwd() .. "/" .. run_script_name
|
local run_script_path = vim.fn.getcwd() .. "/" .. script_name
|
||||||
if not file_exists(run_script_path) then
|
if not file_exists(run_script_path) then
|
||||||
error(
|
error(
|
||||||
"The run script: '" .. run_script_path .. "' does not exist.\n"..
|
"The run script: '" .. run_script_path .. "' does not exist.\n"..
|
||||||
@@ -329,12 +329,18 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.keymap.set(
|
do
|
||||||
|
local alphabet = 'abcdefghijklmnopqrstuvwxyzæøåABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ'
|
||||||
|
for i = 1, #alphabet do
|
||||||
|
local char = alphabet:sub(i, i)
|
||||||
|
vim.keymap.set(
|
||||||
'n',
|
'n',
|
||||||
keymap.test_execute_file,
|
keymap.test_execute_script .. char,
|
||||||
run_file,
|
get_run_script_function("." .. char .. ".sh"),
|
||||||
{ silent = true }
|
{ silent = true }
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---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: (),[],{}
|
||||||
|
|||||||
Reference in New Issue
Block a user