rbong / vim-flog

A blazingly fast, stunningly beautiful, exceptionally powerful git branch viewer for Vim/Neovim.
750 stars 22 forks source link

Guidance on how to change default output format? #113

Closed wadcom closed 10 months ago

wadcom commented 10 months ago

I'm trying to change the output format of Flog. Being an nvim newbie I'm lost in where to actually make this change (I've found references to flog_default_format, but changing it doesn't seem to affect anything).

I've tried passing the -format argument, but it seems to lose colors in the output then...

I think many people come to plugins like Flog trying to mimic behavior of their IDEs and having clear instructions on how to achieve this would greatly help.

In my particular case I'd like the output to look something like:

•  Add deprecation warning 
[7d862f2] 2023-11-07 13:55:01 (HEAD -> vlad/branch-name)
rbong commented 10 months ago

flog_default_format is not a setting, see :help flog-settings for the full list of settings.

What you're looking for is g:flog_permanent_default_opts, which is an object, and you want to set the format key.

In Vimscript:

let g:flog_permanent_default_opts = { 'format': '%s%n[%h] %ad%d' }

In Lua:

vim.g.flog_permanent_default_opts = { format = "%s%n[%h] %ad%d" }

Run man git-log on the CLI and search for format:<format-string> (using / just like in Vim) to see the full list of format specifiers.

Concerning highlighting not working when you use this format, see this line in :help :Flog_-format:

To support highlighting, special items should go at the start. This includes date, hash, author, and refs.

Highlighting already has to be very flexible in order to work considering that omitting or re-ordering all of the date, hash, author, and refs format specifiers is supported (also that diffs can be part of multi-line commits).

We already get (warranted) complaints about the fuzziness of highlighting - I am not likely going to make it even more fuzzy by supporting putting highlighted format specifiers on any line.

I recommend one of the following:

Let me know if there are any problems.

wookayin commented 4 months ago

What's the format string you use for the screenshot in the README?

It's apparently not the default one'%ad [%h] {%an}%d %s'. (see https://git-scm.com/docs/pretty-formats)

Also highlight is not working very well in general for arbitrary format due to #66.

rbong commented 4 months ago

What's the format string you use for the screenshot in the README?

Looks like %ad [%h]%d %s.

Looks also like -date=short was used.

Date format is something I haven't mentioned before in this issue. If you like this date format, you can use:

let g:flog_permanent_default_opts = { 'date': 'short' }

Also highlight is not working very well in general for arbitrary format

If there is something specific that's not working please post it if you can and I will see if I can fix, unless if you're sure it's not fixable in the current system. I want to support as much as I can within the limitations we currently have.