airblade/vim-gitgutter

GitGutterDiffOrig filetype/syntax-highlighting

ds2606 opened this issue · 4 comments

What is the latest commit SHA in your installed vim-gitgutter?
2f35907
What vim/nvim version are you on?
8.2

When GitGutterDiffOrig opens a diff in a scratch-buffer split, the filetype is unset, so no syntax highlighting is shown. GitGutter should automatically set the scratch-buffer filetype to the same as the original buffer so that syntax highlighting is shown.

Hopefully this should be an easy win?

Example:
image

After a manual :set ft=javascript in the scratch buffer:
image

In general I like to stay consistent with Vim's behaviour, and Vim's :DiffOrig command does not set the filetype.

However I think it's a reasonable thing to do.

Thanks for the suggestion.

Cool I understand, for now I have my :GitGutterDiffOrig mapped to

function! GitGutterDiffWithSyntax()
    let l:ft_syntax = &ft
    call GitGutterDiffOrigToggle()
    +windo let &ft = l:ft_syntax
    wincmd p
endfunction

Making use of the + range I learned from you in #834! thanks :-)

You don't need that, it's in 719d4ec above.

Oh I misunderstood and thought you weren't implementing it - great, thank you!