Skip to content
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

GH-70 - Add git sidebar coloring support #72

Merged
merged 3 commits into from
May 28, 2021

Conversation

ZNielsen
Copy link
Collaborator

@ZNielsen ZNielsen commented May 27, 2021

Check list

  • I have read through the README (especially F.A.Q section)
  • I have searched through the existing issues or pull requests
  • I have performed a self-review of my code and commented hard-to-understand areas
  • I have made corresponding changes to the documentation (when necessary)

Description

This implements GH-70 - Adding git coloration to the minimiap. New feature is disabled by default, so users should not notice a difference unless the feature is explicitly enabled.

Implementation details

The git diff is retrieved for the current file, and the diff blobs are parsed to determine the range and types of changes. Unfortunately, I did not see a way to retrieve just the diff blobs. In an effort to cut down the amount of text parsed, the -U0 option is passed to git, requesting just the changes with no additional context.

A list of IDs is created when coloring each section. The list needs to be kept around so we can clear out the IDs the next time the minimap is updated. The list just increments to the next ID - I don't have a whole lot of experience with id matching to know if that will cause a problem, but it seemed to work just fine during my testing.

Type of change

  • Bug fix
  • New feature
  • Improvement of existing features
  • Refactor
  • Breaking change
  • Documentation change
  • CI / CD

Test environment

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Others:
  • Vim
    • Neovim: NVIM v0.5.0-dev+1353-g0a653f7ab
    • Vim:

call s:set_range_color(a:winid, a:startpos, a:endpos, g:minimap_diffremove_color, g:minimap_rem_matchid)
endfunction
function! s:set_diff_range(winid, startpos, endpos) abort
call s:set_range_color(a:winid, a:startpos, a:endpos, g:minimap_diff_color, g:minimap_diff_matchid)
Copy link
Collaborator Author

@ZNielsen ZNielsen May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions (set_diff(add|remove|)_range) aren't actually used. I used them for a bit, but then went with the dictionary solution above. I left them in because they seemed like nice convenience functions, but they can be removed with no repercussions if desired.

Copy link
Collaborator

@rabirabirara rabirabirara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this on my Windows. Since I use g:minimap_auto_start_win_enter, it's actually s:open_window which is called to open the minimap, and not s:toggle_window as is default. The one change I requested should fix this case; beyond that everything else works and looks great to me.

autoload/minimap/vim.vim Outdated Show resolved Hide resolved
ZNielsen added 2 commits May 27, 2021 13:28
- Move definition of `g:id_list` to `s:open_window()` (from
  `s:toggle_window()`)
- Change default highlight groups to ones that ship with vim
- Change double quoted strings to single quoted strings
@ZNielsen ZNielsen requested a review from rabirabirara May 27, 2021 20:36
@rabirabirara rabirabirara merged commit 6ef0ac2 into wfxr:master May 28, 2021
@rabirabirara
Copy link
Collaborator

I'm not sure when Wenxuan will be able to see this, so I hope I'm not being presumptuous by merging this. I didn't encounter any problems with normal functionality using the branch (if there is a problem, the pr can be reverted and adjusted without incidence), and the added feature works great. Great work, and thank you for the significant contribution!

@wfxr
Copy link
Owner

wfxr commented May 28, 2021

@rabirabirara That's OK! I just tested this feature and it looks pretty. Thank for your great work @ZNielsen !

wfxr added a commit that referenced this pull request May 28, 2021
wfxr added a commit that referenced this pull request May 28, 2021
@ZNielsen ZNielsen deleted the feat-git_colors branch May 28, 2021 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants