wfxr / minimap.vim

📡 Blazing fast minimap / scrollbar for vim, powered by code-minimap written in Rust.
MIT License
1.2k stars 24 forks source link

Shows entire document as changed when in diff-mode #150

Closed freijon closed 2 years ago

freijon commented 2 years ago

Check list

Environment info

Version info

NVIM v0.7.0
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/bin/x86_64-pc-linux-gnu-gcc -march=native -O2 -pipe -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -Wsuggest-attribute=cold -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/var/tmp/portage/app-editors/neovim-0.7.0/work/neovim-0.7.0_build/config -I/var/tmp/portage/app-editors/neovim-0.7.0/work/neovim-0.7.0/src -I/usr/include -I/var/tmp/portage/app-editors/neovim-0.7.0/work/neovim-0.7.0_build/src/nvim/auto -I/var/tmp/portage/app-editors/neovim-0.7.0/work/neovim-0.7.0_build/include
Compiled by portage@localhost

Features: +acl +iconv +tui

Question / Problem and steps to reproduce

When the settings g:minimap_auto_start = 1 and g:minimap_auto_start_win_enter = 1 are enabled, the diff feature in nvim becomes unusable. The entire document is seen as a difference.

This happens when using nvim -d <file1> <file2> (it even happens when diff'ing a file with itself). Same with git difftool

screenshot

ZNielsen commented 2 years ago

I work around this by having a separate init.vim (or vimrc) for use with diffing. For example:

source $HOME/.vimrc

" Disable plugin settings that mess with diffs
let g:minimap_auto_start = 0
let g:minimap_auto_start_win_enter = 0

Then map an alias when you want to diff (you can change your git diff command too):

alias nvimd='nvim -u $HOME/init_no_mm.vim -d'

Some info on custom git difftool commands: https://stackoverflow.com/a/1339962/8862937

freijon commented 2 years ago

Indeed, this works fine as a workaround, thank you.

However, it would be nice to have working Minimap(s) in Diff-mode. Maybe even show the various diffs in the Minimap, like in normal mode. I could see this being very useful. Maybe we can convert this issue into a feature request, if you agree.

ZNielsen commented 2 years ago

I'm not sure if that is possible. The minimap is just another window. We put the source through the minimap generator which gives us a bunch of dots, and we put those dots in the minimap window. As far as vim is concerned, we are editing two buffers in a split view (not quite, but accurate enough for a high level summary). When vim/neovim is opened in diff mode, it diffs all the windows. So opening two files + a minimap becomes a 3-way diff, where of course nothing will match because one window is filled with only braille characters. So I believe this is just a limitation of vim/nvim and how we implemented the minimap. There might be a way to exclude certain windows from a diff, but I haven't looked into it. If you find something in the docs that indicates that is possible, I'll definitely add this as a feature request.

nevillelyh commented 2 years ago

Hi I stumbled upon this issue and ended up wrapping the settings like this which seems to work. Hope this helps.

if ! &diff
  let g:minimap_auto_start = 1
  let g:minimap_auto_start_win_enter = 1
endif