some nice changes
This commit is contained in:
parent
2086e7e5d3
commit
19fc44af80
6 changed files with 58 additions and 79 deletions
|
@ -7,7 +7,6 @@ nomap("n", "<C-k>", "")
|
|||
nomap("n", "q", "")
|
||||
nomap("v", "q", "")
|
||||
nomap("v", "<leader>S", "")
|
||||
nomap({ "i", "v", "n" }, "<C-q>", "")
|
||||
|
||||
local map = vim.keymap.set
|
||||
|
||||
|
@ -58,33 +57,3 @@ map("n", "<leader>R", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
|||
-- window management
|
||||
map("n", "<leader>sv", "<C-w>v", { desc = "Split window vertically" }) -- split window vertically
|
||||
map("n", "<leader>sh", "<C-w>s", { desc = "Split window horizontally" }) -- split window horizontally
|
||||
|
||||
vim.keymap.set({ "n", "i" }, "<leader>tt", function()
|
||||
-- Frage den Shell-Command ab
|
||||
vim.ui.input({ prompt = "Shell Command: " }, function(cmd)
|
||||
if cmd == nil or cmd == "" then
|
||||
return
|
||||
end
|
||||
|
||||
local result = vim.fn.system(cmd)
|
||||
local exit_code = vim.v.shell_error
|
||||
|
||||
if exit_code ~= 0 then
|
||||
vim.notify("Shell Error:\n" .. result, vim.log.levels.ERROR, { title = "Shell Command Failed" })
|
||||
return
|
||||
end
|
||||
|
||||
local lines = vim.split(result, "\n", { trimempty = true })
|
||||
|
||||
-- Insert at cursor position
|
||||
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
if #lines == 1 then
|
||||
-- Insert inline if the result is a single line
|
||||
local current_line = vim.api.nvim_get_current_line()
|
||||
local new_line = current_line:sub(1, col) .. lines[1] .. current_line:sub(col + 1)
|
||||
vim.api.nvim_set_current_line(new_line)
|
||||
else
|
||||
vim.api.nvim_buf_set_lines(0, row, row, false, lines)
|
||||
end
|
||||
end)
|
||||
end, { desc = "Insert Shell Output at Cursor" })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue