idk i made a lot of changes
This commit is contained in:
parent
f17fb26069
commit
55099cdad2
10 changed files with 171 additions and 21 deletions
|
|
@ -31,3 +31,64 @@ end)
|
|||
vim.keymap.set("n", "<leader>v", function()
|
||||
vim.cmd("vsplit")
|
||||
end)
|
||||
|
||||
-- u can put delta inside of neovim omg they are spoiling me <3
|
||||
local git_diff_win = nil
|
||||
|
||||
vim.api.nvim_create_autocmd("VimResized", {
|
||||
callback = function()
|
||||
if git_diff_win and vim.api.nvim_win_is_valid(git_diff_win) then
|
||||
local width = math.floor(vim.o.columns * 0.9)
|
||||
local height = math.floor((vim.o.lines - 2) * 0.9)
|
||||
|
||||
vim.api.nvim_win_set_config(git_diff_win, {
|
||||
relative = "editor",
|
||||
width = width,
|
||||
height = height,
|
||||
col = math.floor((vim.o.columns - width) / 2),
|
||||
row = math.floor((vim.o.lines - height) / 2) - 2,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>gd", function()
|
||||
if git_diff_win and vim.api.nvim_win_is_valid(git_diff_win) then
|
||||
vim.api.nvim_win_close(git_diff_win, true)
|
||||
git_diff_win = nil
|
||||
return
|
||||
end
|
||||
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
|
||||
vim.bo[buf].filetype = "terminal"
|
||||
|
||||
-- deletes the last two lines of the buffer when the process exits :3
|
||||
vim.api.nvim_create_autocmd("TermClose", {
|
||||
buffer = buf,
|
||||
callback = function()
|
||||
vim.defer_fn(function()
|
||||
vim.bo[buf].modifiable = true
|
||||
vim.api.nvim_buf_set_lines(buf, -3, -1, false, {})
|
||||
vim.bo[buf].modifiable = false
|
||||
end, 10)
|
||||
end,
|
||||
})
|
||||
|
||||
local width = math.floor(vim.o.columns * 0.9)
|
||||
local height = math.floor((vim.o.lines - 2) * 0.9)
|
||||
|
||||
git_diff_win = vim.api.nvim_open_win(buf, true, {
|
||||
relative = "editor",
|
||||
width = width,
|
||||
height = height,
|
||||
col = math.floor((vim.o.columns - width) / 2),
|
||||
row = math.floor((vim.o.lines - height) / 2) - 2,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
})
|
||||
|
||||
vim.fn.jobstart("git diff | delta --pager=never", { term = true })
|
||||
|
||||
vim.keymap.set("n", "q", "<cmd>close<CR>", { buffer = buf })
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue