diff options
| author | Aotrix <[email protected]> | 2026-07-23 22:47:01 +0200 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2026-07-23 22:47:01 +0200 |
| commit | 37fce10620f371499bcdb8768ebbf7c73e5be1a1 (patch) | |
| tree | 8bb04d477904b9be7e618f7d12a7b183594d4ee0 /lua | |
| parent | 9ec11a211c3a657c54de9838a3167cb61b34bcde (diff) | |
Add commands from parent dir
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/aotrix/build.lua | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/lua/aotrix/build.lua b/lua/aotrix/build.lua index 7e4e173..933c0ce 100644 --- a/lua/aotrix/build.lua +++ b/lua/aotrix/build.lua @@ -131,28 +131,34 @@ vim.api.nvim_create_user_command("AddCommand", addCommand, {}) vim.api.nvim_create_user_command("DeleteCommand", deleteCommand, {}) -local executeCommand = function(listOfCommands) +vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter', 'DirChanged'}, { + callback = function() + COMMANDS = {} + local current_json = readJsonFromFile(PERSONAL_COMMAND_JSON_PATH) + local current_path = vim.fn.getcwd() + if current_json ~= nil then + for existing_directory, _ in pairs(current_json) do + if (string.find(current_path, existing_directory) == 1) then + appendCommandsFromFile(COMMANDS, PERSONAL_COMMAND_JSON_PATH, + existing_directory) + end + end + end + end +}) + +vim.keymap.set("n", "mc", function() if (CURRENT_COMMAND == nil) then - selectCommand(listOfCommands, + selectCommand(COMMANDS, function() executeCommandInTerminal(CURRENT_COMMAND) end) else executeCommandInTerminal(CURRENT_COMMAND) end -end - -vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter', 'DirChanged'}, { - callback = function() - COMMANDS = {} - appendCommandsFromFile(COMMANDS, PERSONAL_COMMAND_JSON_PATH, - vim.fn.getcwd()) - end -}) +end) -vim.keymap.set("n", "mc", function() executeCommand(COMMANDS) end) vim.keymap.set("n", "mC", function() selectCommand(COMMANDS, function() executeCommandInTerminal(CURRENT_COMMAND) end) end) - |
