feat: blamer;

refactor: tab sizes;
feat: hyprlang;
refactor: git add/git restore binds
This commit is contained in:
2025-10-05 15:36:56 +03:00
parent 986512f648
commit 032634fc91
3 changed files with 70 additions and 25 deletions

View File

@@ -15,7 +15,7 @@ vim.keymap.set("n", "<leader>tt", base46.toggle_transparency)
-- Toggle wrap
vim.keymap.set("n", "<leader>ww", function ()
vim.wo.wrap = not vim.wo.wrap
vim.wo.wrap = not vim.wo.wrap
end)
-- Debbuger binds
@@ -31,8 +31,8 @@ end)
local dap = require "dap"
vim.keymap.set("n", "<F1>", function()
vim.cmd('NvimTreeClose')
dap.continue()
vim.cmd('NvimTreeClose')
dap.continue()
end)
vim.keymap.set("n", "<F2>", dap.step_into, { desc = "Dap Step into" })
vim.keymap.set("n", "<F3>", dap.step_over, { desc = "Dap Step over" })
@@ -48,21 +48,44 @@ local function toggle_terminal()
require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" }
end
local function toggle_git_add()
-- Git add current file
local function git_add_current_file()
local filepath = vim.fn.expand("%:p") -- Get the full path of the current file
local handle = io.popen("git ls-files --cached --error-unmatch " .. filepath .. " 2>/dev/null") -- Check if the file is staged
local result = handle:read("*a")
handle:close()
local command = "git add " .. vim.fn.shellescape(filepath)
local output = vim.fn.system(command)
if result ~= "" then
os.execute("git reset " .. filepath) -- Unstage the file if it's already staged
print("Unstaged: " .. filepath)
if vim.v.shell_error ~= 0 then
print("Error adding file: " .. output)
else
os.execute("git add " .. filepath) -- Stage the file if it's not staged
print("Staged: " .. filepath)
print("Added: " .. filepath)
end
end
-- Git unstage (reset) current file
local function git_unstage_current_file()
local filepath = vim.fn.expand("%:p") -- Get the full path of the current file
local command = "git reset HEAD -- " .. vim.fn.shellescape(filepath)
local output = vim.fn.system(command)
if vim.v.shell_error ~= 0 then
print("Error unstaging file: " .. output)
else
print("Unstaged: " .. filepath)
end
end
-- Alternative unstage using restore (Git 2.23+)
local function git_unstage_current_file_restore()
local filepath = vim.fn.expand("%:p") -- Get the full path of the current file
local command = "git restore --staged " .. vim.fn.shellescape(filepath)
local output = vim.fn.system(command)
if vim.v.shell_error ~= 0 then
print("Error unstaging file: " .. output)
else
print("Unstaged: " .. filepath)
end
end
map({ "n", "t" }, "<A-b>", toggle_terminal, { desc = "terminal toggleable horizontal term" })
map({ "n", "t" }, "<C-`>", toggle_terminal, { desc = "terminal toggleable horizontal term" })
@@ -73,10 +96,10 @@ map("t", "<C-Esc>", "<C-\\><C-N>", { desc = "terminal escape terminal mode" })
local hop = require('hop')
local directions = require('hop.hint').HintDirection
vim.keymap.set('', 'f', function()
hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = false })
hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = false })
end, {remap=true})
vim.keymap.set('', 'F', function()
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = false })
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = false })
end, {remap=true})
-- vim.keymap.set('', 't', function()
-- hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = false, hint_offset = -1 })
@@ -103,20 +126,22 @@ vim.keymap.set("n", "<leader>ft", '<cmd>TodoTelescope<cr>', { desc = "Telescope
vim.keymap.set("n", "<leader>tr", '<cmd>NvimTreeRefresh<cr>', { desc = "Nvimtree Refresh" })
-- toggle git add current file
vim.keymap.set("n", "<leader>ga", toggle_git_add, { desc = "Toggle git add for current file" })
vim.keymap.set("n", "<leader>ga", git_add_current_file, { desc = "Git add file" })
vim.keymap.set("n", "<leader>gd", git_unstage_current_file, { desc = "Git unstage file" })
vim.keymap.set("n", "<leader>gr", git_unstage_current_file_restore, { desc = "Git unstage file (restore)" })
-- nvimtree open file without focusing
vim.keymap.set("n", "T",
function(node)
local nt_api = require("nvim-tree.api")
nt_api.node.open.edit(node)
nt_api.tree.focus()
end,
{ desc = "Nvimtree Open without focusing" })
function(node)
local nt_api = require("nvim-tree.api")
nt_api.node.open.edit(node)
nt_api.tree.focus()
end,
{ desc = "Nvimtree Open without focusing" })
-- nvchad tabs
vim.keymap.set("n", "<leader>tn", '<cmd>tabNext<cr>', { desc = "Tab Next" })
vim.keymap.set("n", "<leader>tp", '<cmd>tabprevious<cr>', { desc = "Tab Previous" })
vim.keymap.set("n", "<leader>tp", '<cmd>tabprevious<cr>', { desc = "Tab Previous" })
vim.keymap.set("n", "<leader>tm", '<cmd>tabnew<cr>', { desc = "Tab More!" })
vim.keymap.set("n", "<leader>tc", '<cmd>tabclose<cr>', { desc = "Tab Close" })