kyoheiu / felix

tui file manager with vim-like key mapping

Home Page:https://kyoheiu.dev/felix/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can we offload syntax highlighting to bat or other external tools?

cloud-on-prem opened this issue · comments

Looks like syntax highlighting was removed.
Wondering if we can offload the syntax highlighting part to bat or other external tools?

Actually some time ago I'd tried to integrate bat to introduce syntax highlighting, and it did not work IIRC.
But things might change, so I'll look at that one more time.
Thank you for the suggestion.

I found the hard part is the same as before: In horizontally split preview area, bat might be work as intended, but not in vertically split preview (you can switch between them by s). because bat does not provide the option to adjust the starting position of the output.
Of course there might be another tool to archive this.

@kyoheiu Is there something wrong with the syntect solution from earlier? For me it works fine.

The biggest reason to drop it is the maintainability: IMO,having a syntax highlighting was not the role of a simple file manager like this, and the code was bloated by the feature.
As relatively minor issue, syntect cannot properly handle the wide char such as CJK for now, which is kind of irritating but not critical though.

Maybe they fixed this by CHANGELOG.md
but I'm not sure.

That was another problem of syntect, and I fixed it by this PR trishume/syntect#456 .
But still, syntect cannot handle the width of wide chars properly, so texts containing them are wrapped before reaching the end of the line.

@kyoheiu @cloud-on-prem

Maybe its naïve, but does the terminal-width and offset option of bat:

      --terminal-width <width>
          Explicitly set the width of the terminal instead of determining it automatically. If
          prefixed with '+' or '-', the value will be treated as an offset to the actual terminal
          width. See also: '--wrap'.

not exactly what is needed?

@rafo Thank you for the suggestion...

Wow. I've done it:
screenshot
I use bat <file-path> -fpP --wrap character --terminal-width {preview_space_x} -r {preview_space_y}.
I'm debugging, but it seems to way smoothly work.

Created PR #250

Thank you for the suggestion...

I'm happy to help! Looks good!

Merged and published as v2.10.0. Thank you all!

Edit: Fixed to show tab character as 4 spaces to not break the layout. Use v2.10.1.