mirror of
https://github.com/cap153/nvim.git
synced 2026-04-17 09:45:29 +08:00
添加git signs插件
This commit is contained in:
parent
81b9d5964e
commit
c3a1663bdb
5 changed files with 60 additions and 17 deletions
37
lua/pack/configs/gitsigns.lua
Normal file
37
lua/pack/configs/gitsigns.lua
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
-- === git signs ===
|
||||
if vim.g.vscode then return end
|
||||
|
||||
local P = {
|
||||
name = "gitsigns.nvim",
|
||||
build_cmd = ":TSUpdate",
|
||||
}
|
||||
|
||||
-- 注册构建监听器
|
||||
PackUtils.setup_listener(P.name, P.build_cmd)
|
||||
|
||||
-- 懒加载触发器
|
||||
vim.api.nvim_create_autocmd({
|
||||
"UIEnter", -- vim.schedule(function()
|
||||
}, {
|
||||
callback = function()
|
||||
vim.schedule(function()
|
||||
PackUtils.load(P, function()
|
||||
require('gitsigns').setup {
|
||||
on_attach = function()
|
||||
local gitsigns = require('gitsigns')
|
||||
local map = require("core.keymap")
|
||||
-- Navigation
|
||||
map:lua('t=', function()
|
||||
gitsigns.nav_hunk('next')
|
||||
end)
|
||||
map:lua('t-', function()
|
||||
gitsigns.nav_hunk('prev')
|
||||
end)
|
||||
-- show diff
|
||||
map:lua('<leader>hd', gitsigns.diffthis)
|
||||
end
|
||||
}
|
||||
end)
|
||||
end)
|
||||
end
|
||||
})
|
||||
|
|
@ -23,7 +23,7 @@ end, { desc = "Lazy load and open Peek" })
|
|||
|
||||
vim.api.nvim_create_user_command("PeekClose", function()
|
||||
-- 如果插件没加载,Close 命令通常不需要做任何事,或者也触发加载
|
||||
if PackUtils.is_initialized[P.name] then
|
||||
if PackUtils.plugin_loaded[P.name] then
|
||||
require("peek").close()
|
||||
end
|
||||
end, { desc = "Close Peek" })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue