-
-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom pagers, e.g. *Delta* #1593
base: master
Are you sure you want to change the base?
Conversation
8dfdb1c
to
7812a3f
Compare
7812a3f
to
d935c02
Compare
Very cool work - I didn't think it would be this straightforward. |
bc6ab47
to
5bfc499
Compare
ec0fc42
to
5bfc499
Compare
5bfc499
to
1af5eea
Compare
Hm I'm not sure where the strange colors come from. These minimal settings should hopefully work: I set these options:
In Git settings: [delta]
side-by-side = true See if that makes it display properly. |
Ok I made a minimal config that's 100% reproducible with Docker. Maybe it's cause you didn't install Bat. Create this # syntax = docker/dockerfile:1.2
FROM alpine:3.21.0
# Install packages
RUN apk add \
bat \
delta \
git \
neovim Build and run it:
Create -- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
local out = vim.fn.system({ 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ 'Failed to clone lazy.nvim:\n', 'ErrorMsg' },
{ out, 'WarningMsg' },
{ '\nPress any key to exit...' },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = ' '
vim.g.maplocalleader = '\\'
vim.env.DELTA_FEATURES = '+side-by-side'
-- Setup lazy.nvim
require('lazy').setup({
spec = {
{
dir = '/tmp/nvim/neogit/',
dependencies = {
'nvim-lua/plenary.nvim',
'sindrets/diffview.nvim',
'm00qek/baleia.nvim',
'nvim-telescope/telescope.nvim',
},
opts = {
disable_context_highlighting = true,
graph_style = 'kitty',
log_pager = { 'delta', '--width', '120' },
commit_editor = {
staged_diff_split_kind = 'vsplit_left',
},
},
},
{
'm00qek/baleia.nvim',
version = '*',
config = function() vim.g.baleia = require('baleia').setup({}) end,
},
},
})
vim.cmd('Neogit cwd=/tmp/nvim/neogit/') In the container run:
|
Any luck on getting this to show properly on your end? I hope my Docker example helps. I can provide a screenshot if needed. |
Hi, I am trying your repository @stevenxxiu (thanks for the pull request!). It works great with "side-by-side", but without it, I have |
@misaflo I'm guessing baleia doesn't handle this ANSI control sequence. I removed that part of the line now. |
c04cfcb
to
1a8ce40
Compare
@CKolkey I finally figured the issue out. Turns out for baleia, I used The following should work now. Create this # syntax = docker/dockerfile:1.2
FROM alpine:3.21.0
# Install packages
RUN apk add \
less \
delta \
git \
neovim Build and run it:
Create -- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
vim.env.DELTA_FEATURES = "+side-by-side"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
{
dir = "/tmp/nvim/neogit/",
dependencies = {
"nvim-lua/plenary.nvim",
"sindrets/diffview.nvim",
"m00qek/baleia.nvim",
"nvim-telescope/telescope.nvim",
},
opts = {
disable_context_highlighting = true,
graph_style = "kitty",
log_pager = { "delta", "--width", "119" },
commit_editor = {
staged_diff_split_kind = "vsplit_left",
},
},
},
{
"m00qek/baleia.nvim",
config = function()
vim.g.baleia = require("baleia").setup({})
end,
},
},
})
vim.cmd("Neogit cwd=/tmp/nvim/neogit/") In the container run:
|
It fixes the issue, but introduces an other: it highlights (greeen or red) an extra line, where there is no diff. |
1a8ce40
to
9b904fd
Compare
Ok I took a more detailed look. Now it shouldn't affect the next line, but it won't color the rest of the line's background either, like it should in the terminal. That requires baleia to properly support this ANSI escape sequence. |
9b904fd
to
99db158
Compare
99db158
to
659aa82
Compare
659aa82
to
7fc750c
Compare
I rebased and got unit tests to pass. |
I'll try to do a good review soon as I can. I have some newborns (twin boys) at home right now so bear with me ;) |
Congrats on having 2 twin boys! Take your time. |
68537b0
to
1c1abf2
Compare
This is a great work! Looking forward to the merger. |
Add the `log_pager` option, which can be set to `delta`.
- This improves the speed. - If not done, for large diffs we can get the error `PANIC: unprotected error in call to Lua API (EMFILE: too many open files)`.
…fer:set_ansi_highlights()`, to avoid finding hunk line numbers manually with the hard-coded `NeogitDiffContext` - Add `ansi_hl` to `ComponentOptions`, to indicate whether the component needs ANSI highlighting. - Add `ansi_highlight` to `RendererBuffer`, to pass hunk line numbers.
We don't support coloring the rest of the line.
1c1abf2
to
d7c4e6f
Compare
This PR resolves #97, to support custom pagers. I made it configurable and tested it with Delta.
For Delta, an example config is:
I used baleia to colorize text with ANSI escape sequences.
It's recommended to set
disable_context_highlighting = true
, otherwise when the cursor is in the hunk, we lose background highlighting.To set a Delta theme, set the environment variables e.g.