1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-12-24 01:41:14 +01:00
nixvim/plugins/by-name/gitsigns/settings-options.nix
Austin Horstman ebacf86f2b plugins/gitsigns: drop deprecated nvim_buf_set_keymap
Use vim.keymap.set({ buffer = bufnr }) instead.
2025-12-17 08:44:16 +00:00

43 lines
1.3 KiB
Nix

lib:
let
inherit (lib.nixvim) defaultNullOpts mkNullOrLuaFn;
in
{
on_attach = mkNullOrLuaFn ''
Callback called when attaching to a buffer. Mainly used to setup keymaps
when `config.keymaps` is empty. The buffer number is passed as the first
argument.
This callback can return `false` to prevent attaching to the buffer.
Example:
```lua
function(bufnr)
if vim.api.nvim_buf_get_name(bufnr):match(<PATTERN>) then
-- Don't attach to specific buffers whose name matches a pattern
return false
end
-- Setup keymaps
vim.keymap.set('n', 'hs', '<cmd>lua require"gitsigns".stage_hunk()<CR>', { buffer = bufnr })
... -- More keymaps
end
```
'';
status_formatter = defaultNullOpts.mkLuaFn ''
function(status)
local added, changed, removed = status.added, status.changed, status.removed
local status_txt = {}
if added and added > 0 then
table.insert(status_txt, '+' .. added)
end
if changed and changed > 0 then
table.insert(status_txt, '~' .. changed)
end
if removed and removed > 0 then
table.insert(status_txt, '-' .. removed)
end
return table.concat(status_txt, ' ')
end
'' "Function used to format `b:gitsigns_status`.";
}