Execute shell commands, surrounds.nvim, ...

Signed-off-by: Hadi <hadi@example.com>
This commit is contained in:
Hadi
2026-06-09 13:59:52 +02:00
parent 2f89759ca7
commit 1e83efd78a
3 changed files with 51 additions and 0 deletions
+47
View File
@@ -1,6 +1,7 @@
{ {
vim = { vim = {
globals.mapleader = " "; globals.mapleader = " ";
keymaps = [ keymaps = [
{ {
key = "s"; key = "s";
@@ -144,6 +145,52 @@
desc = "Todo (Trouble)"; desc = "Todo (Trouble)";
} }
# Shell
{
key = "<leader>!";
mode = "n";
silent = true;
lua = true;
desc = "Insert command output";
action = ''
function()
local cmd = vim.fn.input("Command: ")
if cmd == "" then return end
local lines = vim.fn.systemlist(cmd)
while #lines > 0 and lines[#lines] == "" do
table.remove(lines)
end
if #lines == 0 then return end
vim.api.nvim_put(lines, "l", true, true)
end
'';
}
{
key = "<leader>!";
mode = "v";
silent = true;
lua = true;
desc = "Run command with selection";
action = ''
function()
local start_line = vim.fn.line("'<")
local end_line = vim.fn.line("'>")
local lines = vim.api.nvim_buf_get_lines(0, start_line - 1, end_line, false)
local input_text = table.concat(lines, "\n")
local cmd = vim.fn.input("$ ")
if cmd == "" then return end
local result = vim.fn.system({"bash", "-c", cmd}, input_text)
local output = vim.split(result, "\n", { plain = true })
if output[#output] == "" then table.remove(output) end
if #output == 0 then return end
vim.api.nvim_buf_set_lines(0, start_line - 1, end_line, false, output)
end
'';
}
# QOL # QOL
{ {
key = ">"; key = ">";
+1
View File
@@ -24,6 +24,7 @@
autotagHtml = true; autotagHtml = true;
context.enable = true; context.enable = true;
highlight.enable = true; highlight.enable = true;
textobjects.enable = true;
}; };
lsp = { lsp = {
enable = true; enable = true;
+3
View File
@@ -27,6 +27,8 @@
{ mode = 'n', keys = '<Leader>u', desc = '+ui' }, { mode = 'n', keys = '<Leader>u', desc = '+ui' },
{ mode = 'n', keys = '<Leader>l', desc = '+lsp' }, { mode = 'n', keys = '<Leader>l', desc = '+lsp' },
{ mode = 'n', keys = '<Leader>x', desc = '+trouble' }, { mode = 'n', keys = '<Leader>x', desc = '+trouble' },
{ mode = 'n', keys = '<Leader>!', desc = 'shell' },
{ mode = 'v', keys = '<Leader>!', desc = 'shell' },
}, },
window = { delay = 300 }, window = { delay = 300 },
}) })
@@ -44,5 +46,6 @@
jump2d.enable = true; jump2d.enable = true;
statusline.enable = true; statusline.enable = true;
clue.enable = true; clue.enable = true;
surround.enable = true;
}; };
} }