diff --git a/modules/nvim.nix b/modules/nvim.nix index 7f1198f..1f0e7cf 100644 --- a/modules/nvim.nix +++ b/modules/nvim.nix @@ -163,13 +163,13 @@ { mode = "n"; key = "o"; - action = ":silent !open %"; + action = ":lua open_file_with_system_app()"; options = { desc = "Open file with system default app"; }; } { mode = "n"; key = "f"; - action = ":silent !open -R %"; + action = ":lua show_file_in_finder()"; options = { desc = "Show current file in Finder"; }; } @@ -220,6 +220,27 @@ }, }, }) + + -- Unicode-safe file operations for macOS + function open_file_with_system_app() + local filepath = vim.fn.expand('%:p') + if filepath ~= "" then + local escaped_path = vim.fn.shellescape(filepath) + vim.fn.system('open ' .. escaped_path) + else + print("No file to open") + end + end + + function show_file_in_finder() + local filepath = vim.fn.expand('%:p') + if filepath ~= "" then + local escaped_path = vim.fn.shellescape(filepath) + vim.fn.system('open -R ' .. escaped_path) + else + print("No file to show") + end + end ''; }; }