Adding gitsigns

This commit is contained in:
Zoe Roux
2022-03-10 01:07:13 +01:00
parent 1f373840a0
commit 5d82b5813b
7 changed files with 98 additions and 0 deletions
+3
View File
@@ -1,7 +1,10 @@
pcall(require, "impatient")
require "settings"
require "plugins"
require "colorscheme"
require "windows"
require "lsp"
require "treesitter"
require "utils"
+5
View File
@@ -40,6 +40,7 @@ packer.init {
return packer.startup(function(use)
use "wbthomason/packer.nvim"
use 'lewis6991/impatient.nvim'
use "tpope/vim-surround"
use "tpope/vim-unimpaired"
@@ -52,6 +53,7 @@ return packer.startup(function(use)
use {
{ 'nvim-telescope/telescope.nvim', requires = { {'nvim-lua/plenary.nvim'} } },
{ 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
'stevearc/dressing.nvim',
}
use "folke/which-key.nvim"
use "akinsho/toggleterm.nvim"
@@ -71,6 +73,9 @@ return packer.startup(function(use)
}
use { "lukas-reineke/virt-column.nvim", config = function() require("virt-column").setup() end }
use "lukas-reineke/indent-blankline.nvim"
use { "lewis6991/gitsigns.nvim", requires = { 'nvim-lua/plenary.nvim' } }
if PACKER_BOOTSTRAP then
require("packer").sync()
+6
View File
@@ -60,3 +60,9 @@ keymap("i", "<C-l>", "<Right>", opts)
keymap("i", "<C-BS>", "<C-w>", opts)
vim.cmd [[ augroup highlight_yank
autocmd!
autocmd TextYankPost * silent!lua require('vim.highlight').on_yank({higroup = 'Visual', timeout = 200})
augroup end
]]
@@ -0,0 +1,47 @@
local status_ok, indent_blankline = pcall(require, "indent_blankline")
if not status_ok then
return
end
vim.g.indent_blankline_buftype_exclude = { "terminal", "nofile" }
vim.g.indent_blankline_filetype_exclude = {
"help",
"startify",
"dashboard",
"packer",
"neogitstatus",
"NvimTree",
"Trouble",
}
vim.g.indentLine_enabled = 1
vim.g.indent_blankline_char = ""
vim.g.indent_blankline_show_trailing_blankline_indent = true
vim.g.indent_blankline_show_first_indent_level = true
vim.g.indent_blankline_use_treesitter = true
vim.g.indent_blankline_show_current_context = true
-- vim.g.indent_blankline_context_patterns = {
-- "class",
-- "return",
-- "function",
-- "method",
-- "^if",
-- "^while",
-- "jsx_element",
-- "^for",
-- "^object",
-- "^table",
-- "block",
-- "arguments",
-- "if_statement",
-- "else_clause",
-- "jsx_element",
-- "jsx_self_closing_element",
-- "try_statement",
-- "catch_clause",
-- "import_statement",
-- "operation_type",
-- }
indent_blankline.setup({
show_current_context = true,
})
@@ -1,2 +1,3 @@
require "treesitter.treesitter"
require "treesitter.indent-line"
@@ -0,0 +1,34 @@
local status_ok, gitsigns = pcall(require, "gitsigns")
if not status_ok then
return
end
gitsigns.setup({
signs = {
add = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
change = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
delete = { hl = "GitSignsDelete", text = "", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
topdelete = { hl = "GitSignsDelete", text = "", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" },
changedelete = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },
},
keymaps = {
['n ]h'] = { expr = true, "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'"},
['n [h'] = { expr = true, "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'"},
-- Text objects
['o ih'] = ':<C-U>Gitsigns select_hunk<CR>',
['x ih'] = ':<C-U>Gitsigns select_hunk<CR>'
},
})
local wk = require("which-key")
wk.register({
g = {
name = "Git",
p = { "<cmd>lua require 'gitsigns'.preview_hunk()<cr>", "Preview Hunk" },
r = { "<cmd>lua require 'gitsigns'.reset_hunk()<cr>", "Reset Hunk" },
R = { "<cmd>lua require 'gitsigns'.reset_buffer()<cr>", "Reset Buffer" },
},
}, {
prefix = "<leader>",
})
+2
View File
@@ -0,0 +1,2 @@
require "utils.gitsigns"