add command runner to nvim
This commit is contained in:
parent
dd1c82e804
commit
2054a68af0
5 changed files with 47 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
|
require("command_runner")
|
||||||
require("plugins")
|
require("plugins")
|
||||||
require("options")
|
require("options")
|
||||||
require("keymaps")
|
require("keymaps")
|
||||||
require("lsp")
|
require("lsp")
|
||||||
|
|
36
home/.config/nvim/lua/command_runner.lua
Normal file
36
home/.config/nvim/lua/command_runner.lua
Normal 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
|
||||||
|
|
|
@ -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>fb', require('telescope.builtin').buffers, { desc = "Buffers" })
|
||||||
map('n', '<leader>fh', require('telescope.builtin').help_tags, { desc = "Help tags" })
|
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
|
-- Project-specific ignored dirs for Telescope
|
||||||
local function load_local_ignore()
|
local function load_local_ignore()
|
||||||
local cwd = vim.fn.getcwd()
|
local cwd = vim.fn.getcwd()
|
||||||
|
|
|
@ -5,8 +5,9 @@ packages:
|
||||||
repository:
|
repository:
|
||||||
url: https://github.com/neovim/neovim.git
|
url: https://github.com/neovim/neovim.git
|
||||||
branch: release-0.11
|
branch: release-0.11
|
||||||
|
version: 0.11
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- make distclean
|
- make distclean
|
||||||
- make CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX=$HOME/.local
|
- make CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX=$PREFIX
|
||||||
- make install
|
- $SUDO make install
|
||||||
|
|
|
@ -16,6 +16,7 @@ packages:
|
||||||
repository:
|
repository:
|
||||||
url: https://github.com/ruby/ruby.git
|
url: https://github.com/ruby/ruby.git
|
||||||
branch: v3_4_5
|
branch: v3_4_5
|
||||||
|
version: 3.4.5
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- ./autogen.sh
|
- ./autogen.sh
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue