feat: blamer;
refactor: tab sizes; feat: hyprlang; refactor: git add/git restore binds
This commit is contained in:
@@ -48,21 +48,44 @@ local function toggle_terminal()
|
|||||||
require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" }
|
require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" }
|
||||||
end
|
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 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 command = "git add " .. vim.fn.shellescape(filepath)
|
||||||
local result = handle:read("*a")
|
local output = vim.fn.system(command)
|
||||||
handle:close()
|
|
||||||
|
|
||||||
if result ~= "" then
|
if vim.v.shell_error ~= 0 then
|
||||||
os.execute("git reset " .. filepath) -- Unstage the file if it's already staged
|
print("Error adding file: " .. output)
|
||||||
print("Unstaged: " .. filepath)
|
|
||||||
else
|
else
|
||||||
os.execute("git add " .. filepath) -- Stage the file if it's not staged
|
print("Added: " .. filepath)
|
||||||
print("Staged: " .. filepath)
|
|
||||||
end
|
end
|
||||||
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" }, "<A-b>", toggle_terminal, { desc = "terminal toggleable horizontal term" })
|
||||||
map({ "n", "t" }, "<C-`>", toggle_terminal, { desc = "terminal toggleable horizontal term" })
|
map({ "n", "t" }, "<C-`>", toggle_terminal, { desc = "terminal toggleable horizontal term" })
|
||||||
|
|
||||||
@@ -103,7 +126,9 @@ vim.keymap.set("n", "<leader>ft", '<cmd>TodoTelescope<cr>', { desc = "Telescope
|
|||||||
vim.keymap.set("n", "<leader>tr", '<cmd>NvimTreeRefresh<cr>', { desc = "Nvimtree Refresh" })
|
vim.keymap.set("n", "<leader>tr", '<cmd>NvimTreeRefresh<cr>', { desc = "Nvimtree Refresh" })
|
||||||
|
|
||||||
-- toggle git add current file
|
-- 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
|
-- nvimtree open file without focusing
|
||||||
vim.keymap.set("n", "T",
|
vim.keymap.set("n", "T",
|
||||||
@@ -112,11 +137,11 @@ vim.keymap.set("n", "T",
|
|||||||
nt_api.node.open.edit(node)
|
nt_api.node.open.edit(node)
|
||||||
nt_api.tree.focus()
|
nt_api.tree.focus()
|
||||||
end,
|
end,
|
||||||
{ desc = "Nvimtree Open without focusing" })
|
{ desc = "Nvimtree Open without focusing" })
|
||||||
|
|
||||||
-- nvchad tabs
|
-- nvchad tabs
|
||||||
vim.keymap.set("n", "<leader>tn", '<cmd>tabNext<cr>', { desc = "Tab Next" })
|
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>tm", '<cmd>tabnew<cr>', { desc = "Tab More!" })
|
||||||
vim.keymap.set("n", "<leader>tc", '<cmd>tabclose<cr>', { desc = "Tab Close" })
|
vim.keymap.set("n", "<leader>tc", '<cmd>tabclose<cr>', { desc = "Tab Close" })
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,27 @@ local enable_providers = {
|
|||||||
-- disable wrap
|
-- disable wrap
|
||||||
vim.o.wrap = false
|
vim.o.wrap = false
|
||||||
|
|
||||||
|
-- amount of tabs
|
||||||
|
vim.opt.tabstop = 4
|
||||||
|
vim.opt.softtabstop = 4
|
||||||
|
vim.opt.shiftwidth = 4
|
||||||
|
|
||||||
-- disable auto comment
|
-- disable auto comment
|
||||||
vim.opt_local.formatoptions:remove("r")
|
vim.opt_local.formatoptions:remove("r")
|
||||||
|
|
||||||
vim.g.lua_snippets_path = "~/.config/nvim/lua/lua_snippets"
|
vim.g.lua_snippets_path = "~/.config/nvim/lua/lua_snippets"
|
||||||
|
|
||||||
|
-- enable blamer
|
||||||
|
vim.g.blamer_enabled = true
|
||||||
|
|
||||||
|
-- Hyprlang LSP
|
||||||
|
vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
|
||||||
|
pattern = {"*.hl", "hypr*.conf"},
|
||||||
|
callback = function()
|
||||||
|
vim.lsp.start {
|
||||||
|
name = "hyprlang",
|
||||||
|
cmd = {"hyprls"},
|
||||||
|
root_dir = vim.fn.getcwd(),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user