add command runner to nvim

This commit is contained in:
Artur Gurgul1 2025-08-08 07:55:29 +02:00
parent dd1c82e804
commit 2054a68af0
5 changed files with 47 additions and 3 deletions

View file

@ -1,3 +1,4 @@
require("command_runner")
require("plugins")
require("options")
require("keymaps")

View file

@ -0,0 +1,36 @@
local M = {}
function M.run_shell_command_under_cursor()
local cmd = vim.api.nvim_get_current_line()
if cmd == "" then
print("No command on this line.")
return
end
-- Run command and capture output
local output = vim.fn.systemlist(cmd)
-- Save current window to return later
local current_win = vim.api.nvim_get_current_win()
-- Move to the right window (assumes it's already split)
vim.cmd("wincmd l")
-- Optional: clear buffer before writing
vim.api.nvim_buf_set_lines(0, 0, -1, false, {})
-- Set output in current buffer (right side)
vim.api.nvim_buf_set_lines(0, 0, -1, false, output)
-- Optional: make it editable plain text
vim.bo.filetype = "text"
vim.bo.modifiable = true
vim.bo.readonly = false
-- Return to the left window
vim.api.nvim_set_current_win(current_win)
end
return M

View file

@ -5,6 +5,11 @@ map('n', '<leader>fg', require('telescope.builtin').live_grep, { desc = "Live gr
map('n', '<leader>fb', require('telescope.builtin').buffers, { desc = "Buffers" })
map('n', '<leader>fh', require('telescope.builtin').help_tags, { desc = "Help tags" })
vim.keymap.set("n", "zr", function()
require("command_runner").run_shell_command_under_cursor()
end, { desc = "Run shell command under cursor and show output in right split" })
-- Project-specific ignored dirs for Telescope
local function load_local_ignore()
local cwd = vim.fn.getcwd()

View file

@ -5,8 +5,9 @@ packages:
repository:
url: https://github.com/neovim/neovim.git
branch: release-0.11
version: 0.11
steps:
- make distclean
- make CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX=$HOME/.local
- make install
- make CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX=$PREFIX
- $SUDO make install

View file

@ -16,6 +16,7 @@ packages:
repository:
url: https://github.com/ruby/ruby.git
branch: v3_4_5
version: 3.4.5
steps:
- ./autogen.sh