|
|
|
@ -6,8 +6,9 @@ vim.pack.add({
|
|
|
|
{ src = "https://github.com/mrcjkb/rustaceanvim" },
|
|
|
|
{ src = "https://github.com/mrcjkb/rustaceanvim" },
|
|
|
|
{ src = 'https://github.com/folke/which-key.nvim' },
|
|
|
|
{ src = 'https://github.com/folke/which-key.nvim' },
|
|
|
|
{ src = 'https://github.com/LunarWatcher/auto-pairs' },
|
|
|
|
{ src = 'https://github.com/LunarWatcher/auto-pairs' },
|
|
|
|
{ src = 'https://github.com/tpope/vim-fugitive' },
|
|
|
|
{ src = 'https://github.com/nvim-lua/plenary.nvim' },
|
|
|
|
{ src = 'https://github.com/airblade/vim-gitgutter' },
|
|
|
|
{ src = 'https://github.com/NeogitOrg/neogit' },
|
|
|
|
|
|
|
|
{ src = 'https://github.com/lewis6991/gitsigns.nvim' },
|
|
|
|
{ src = 'https://github.com/nvim-treesitter/nvim-treesitter' },
|
|
|
|
{ src = 'https://github.com/nvim-treesitter/nvim-treesitter' },
|
|
|
|
{ src = 'https://github.com/rayliwell/tree-sitter-rstml' },
|
|
|
|
{ src = 'https://github.com/rayliwell/tree-sitter-rstml' },
|
|
|
|
{ src = 'https://github.com/Saghen/blink.cmp', version = vim.version.range("v1.*") },
|
|
|
|
{ src = 'https://github.com/Saghen/blink.cmp', version = vim.version.range("v1.*") },
|
|
|
|
@ -123,15 +124,81 @@ vim.diagnostic.config({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Fugitive
|
|
|
|
-- Neogit
|
|
|
|
vim.keymap.set('n', '<leader>gs', '<CMD>G<CR>', { desc = "Git Status" })
|
|
|
|
vim.keymap.set('n', '<leader>gs', '<CMD>Neogit kind=split_above_all<CR>', { desc = "Git Status" })
|
|
|
|
vim.keymap.set('n', '<leader>gp', '<CMD>G pull<CR>', { desc = "Git Pull" })
|
|
|
|
vim.keymap.set('n', '<leader>gp', '<CMD>Neogit pull<CR>', { desc = "Git Pull" })
|
|
|
|
vim.keymap.set('n', '<leader>gP', '<CMD>G push<CR>', { desc = "Git Push" })
|
|
|
|
vim.keymap.set('n', '<leader>gP', '<CMD>Neogit push<CR>', { desc = "Git Push" })
|
|
|
|
vim.keymap.set('n', '<leader>gP', '<CMD>G push<CR>', { desc = "Git Push" })
|
|
|
|
require('gitsigns').setup {
|
|
|
|
|
|
|
|
on_attach = function(bufnr)
|
|
|
|
|
|
|
|
local gitsigns = require('gitsigns')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function map(mode, l, r, opts)
|
|
|
|
|
|
|
|
opts = opts or {}
|
|
|
|
|
|
|
|
opts.buffer = bufnr
|
|
|
|
|
|
|
|
vim.keymap.set(mode, l, r, opts)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Navigation
|
|
|
|
|
|
|
|
map('n', ']c', function()
|
|
|
|
|
|
|
|
if vim.wo.diff then
|
|
|
|
|
|
|
|
vim.cmd.normal({ ']c', bang = true })
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
gitsigns.nav_hunk('next')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end, { desc = "next hunk" })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map('n', '[c', function()
|
|
|
|
|
|
|
|
if vim.wo.diff then
|
|
|
|
|
|
|
|
vim.cmd.normal({ '[c', bang = true })
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
gitsigns.nav_hunk('prev')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end, { desc = "prev hunk" })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Actions
|
|
|
|
|
|
|
|
map('n', '<leader>hs', gitsigns.stage_hunk, { desc = "(un)stage hunk" })
|
|
|
|
|
|
|
|
map('n', '<leader>hr', gitsigns.reset_hunk, { desc = "reset hunk" })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map('v', '<leader>hs', function()
|
|
|
|
|
|
|
|
gitsigns.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') })
|
|
|
|
|
|
|
|
end, { desc = "(un)stage hunk" })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map('v', '<leader>hr', function()
|
|
|
|
|
|
|
|
gitsigns.reset_hunk({ vim.fn.line('.'), vim.fn.line('v') })
|
|
|
|
|
|
|
|
end, { desc = "reset hunk" })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--map('n', '<leader>hS', gitsigns.stage_buffer)
|
|
|
|
|
|
|
|
--map('n', '<leader>hR', gitsigns.reset_buffer)
|
|
|
|
|
|
|
|
map('n', '<leader>hp', gitsigns.preview_hunk, { desc = "preview hunk" })
|
|
|
|
|
|
|
|
map('n', '<leader>hi', gitsigns.preview_hunk_inline, { desc = "preview hunk inline" })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map('n', '<leader>hb', function()
|
|
|
|
|
|
|
|
gitsigns.blame_line({ full = true })
|
|
|
|
|
|
|
|
end, { desc = "blame line" })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map('n', '<leader>hd', gitsigns.diffthis, { desc = "diff buffer" })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map('n', '<leader>hD', function()
|
|
|
|
|
|
|
|
gitsigns.diffthis('~')
|
|
|
|
|
|
|
|
end, { desc = "diff buffer to HEAD" })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map('n', '<leader>hQ', function() gitsigns.setqflist('all') end,
|
|
|
|
|
|
|
|
{ desc = "set qflist with changes in all files and cwd" })
|
|
|
|
|
|
|
|
map('n', '<leader>hq', gitsigns.setqflist, { desc = "set qflist with changes in current buffer" })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Toggles
|
|
|
|
|
|
|
|
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = "toggle current line blame" })
|
|
|
|
|
|
|
|
map('n', '<leader>tw', gitsigns.toggle_word_diff, { desc = "toggle word diff" })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Text object
|
|
|
|
|
|
|
|
map({ 'o', 'x' }, 'ih', gitsigns.select_hunk, { desc = "inner hunk" })
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local wk = require "which-key"
|
|
|
|
local wk = require "which-key"
|
|
|
|
wk.add({
|
|
|
|
wk.add({
|
|
|
|
{ "<leader>g", group = "git" },
|
|
|
|
{ "<leader>g", group = "git" },
|
|
|
|
|
|
|
|
{ "<leader>h", group = "git_hunk" }
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
local statusline = {
|
|
|
|
local statusline = {
|
|
|
|
@ -141,7 +208,7 @@ local statusline = {
|
|
|
|
'%{v:lua.StatuslineBranch()}',
|
|
|
|
'%{v:lua.StatuslineBranch()}',
|
|
|
|
' %{v:lua.StatuslineFilename()} ',
|
|
|
|
' %{v:lua.StatuslineFilename()} ',
|
|
|
|
'%{%v:lua.StatuslineReadOnly()%}',
|
|
|
|
'%{%v:lua.StatuslineReadOnly()%}',
|
|
|
|
'%m',
|
|
|
|
'%{%v:lua.StatuslineModified()%}',
|
|
|
|
'%{%v:lua.StatuslineHighlight("Middle")%}',
|
|
|
|
'%{%v:lua.StatuslineHighlight("Middle")%}',
|
|
|
|
'%=',
|
|
|
|
'%=',
|
|
|
|
' ',
|
|
|
|
' ',
|
|
|
|
@ -280,7 +347,7 @@ function StatuslineMode()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function SpecialBuffer()
|
|
|
|
function SpecialBuffer()
|
|
|
|
local pattern = '\v(help|fugitive|qf|Trouble)'
|
|
|
|
local pattern = '\v(help|oil|qf|NeogitStatus)'
|
|
|
|
return string.match(pattern, vim.bo.filetype) ~= nil and true or false
|
|
|
|
return string.match(pattern, vim.bo.filetype) ~= nil and true or false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
@ -288,16 +355,24 @@ function StatuslineReadOnly()
|
|
|
|
return SpecialBuffer() and '' or '%r'
|
|
|
|
return SpecialBuffer() and '' or '%r'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function StatuslineModified()
|
|
|
|
|
|
|
|
if vim.b.modifiable then
|
|
|
|
|
|
|
|
return '%m'
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return ''
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function StatuslineBranch()
|
|
|
|
function StatuslineBranch()
|
|
|
|
local head = vim.fn.FugitiveHead()
|
|
|
|
local head = vim.b.gitsigns_head
|
|
|
|
return SpecialBuffer() ~= true and head ~= '' and fmt(' %s |', head) or ''
|
|
|
|
return SpecialBuffer() ~= true and head ~= nil and fmt(' %s |', head) or ''
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function StatuslineFilename()
|
|
|
|
function StatuslineFilename()
|
|
|
|
local special_files = {
|
|
|
|
local special_files = {
|
|
|
|
['help'] = "Help",
|
|
|
|
['help'] = "Help",
|
|
|
|
['qf'] = 'QuickFix',
|
|
|
|
['qf'] = 'QuickFix',
|
|
|
|
['fugitive'] = vim.fn.FugitiveStatusline()
|
|
|
|
['NeogitStatus'] = vim.b.gitsigns_head
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local filename = vim.fn.expand('%:t')
|
|
|
|
local filename = vim.fn.expand('%:t')
|
|
|
|
|