purarue/gitsigns-yadm.nvim
소개
gitsigns _on_attach_pre hook to show git decorations for files tracked by yadm
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 0
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalgitsigns-yadm.nvim
This uses the gitsigns _on_attach_pre function to check if the currently attached buffer is file tracked by yadm, highlighting the buffer properly if it is.
Installation
Install the plugin with your plugin manager, and then add a _on_attach_pre function to your gitsigns configuration, passing the callback to the yadm_signs function:
require("gitsigns").setup({
_on_attach_pre = function(bufnr, callback)
require("gitsigns-yadm").yadm_signs(callback, { bufnr = bufnr })
end,
-- other gitsigns configuration...
})
See below for examples using lazy.
Configuration
If using a standard yadm setup, you likely won't need to configure anything.
The default computed values are:
{
homedir = os.getenv("HOME"),
yadm_repo_git = vim.fs.normalize("~/.local/share/yadm/repo.git"),
shell_timeout_ms = 2000, -- how many milliseconds to wait for yadm to finish
disable_inside_gitdir = true -- disable if CWD is in a git repository
on_yadm_attach = nil, -- callback function that is called when we successfully attach to a yadm file
}
Call setup to override the defaults:
require("gitsigns-yadm").setup({
yadm_repo_git = "~/.config/yadm/repo.git",
shell_timeout_ms = 1000,
})
If you want to disable this when yadm is not installed (or optionally disable the check for any other reason), you can do so like this:
_on_attach_pre = function(bufnr, callback)
if vim.fn.executable("yadm") == 1 then
require("gitsigns-yadm").yadm_signs(callback, { bufnr = bufnr })
else
-- if optionally disabling the plugin, make sure to call
-- 'callback' with no arguments
callback()
end
end,
If you want to run some custom code when this attaches successfully, you can pass a on_yadm_attach callback function:
{
"purarue/gitsigns-yadm.nvim",
---@module 'gitsigns-yadm'
---@type GitsignsYadm.Config
opts = {
on_yadm_attach = function()
-- set a buffer-local variable so that other code can run custom
-- code if we're editing a yadm file
vim.b.yadm_tracked = true
-- setup vim-fugitive to work with yadm
vim.fn.FugitiveDetect(require("gitsigns-yadm").config.yadm_repo_git)
end,
},
}
Install Examples
With lazy:
{
"lewis6991/gitsigns.nvim",
dependencies = {
{
"purarue/gitsigns-yadm.nvim",
---@module 'gitsigns-yadm'
---@type GitsignsYadm.Config
opts = {
shell_timeout_ms = 1000,
},
},
},
opts = {
_on_attach_pre = function(bufnr, callback)
require("gitsigns-yadm").yadm_signs(callback, { bufnr = bufnr })
end,
-- other configuration for gitsigns...
},
}
Since this doesn't require calling setup (unless you want to configure the defaults), in accordance with lazys best practices you could also do the following:
{
{
"purarue/gitsigns-yadm.nvim",
lazy = true,
},
{
"lewis6991/gitsigns.nvim",
opts = {
_on_attach_pre = function(bufnr, callback)
require("gitsigns-yadm").yadm_signs(callback, { bufnr = bufnr })
end,
}
}
}
관련 프로젝트 살펴보기
불러오는 중…