lucc / nvimpager

Use nvim as a pager to view manpages, diffs, etc with nvim's syntax highlighting
Other
372 stars 20 forks source link

tabstop and list settings are ignored on cat mode #35

Open tamirzb opened 3 years ago

tamirzb commented 3 years ago

Currently when printing tabs on cat mode, nvimpager ignores tabstop and list settings and just prints the tabs as is. This is different from pager mode, where those settings are used as expected. I was wondering if it's possible to add support for them for cat mode, so the output of cat mode and pager mode would be the same.

lucc commented 3 years ago

Interesting idea.

Interpreting ts in cat mode might involve keeping track of the current (virtual) position in the line to know where the next tabstop should start. There is also tabs(1) to handle tabstop definitions on the terminal side of things. Maybe it is as easy as calling system("tabs -".&ts). But as ts is buffer-local we have to do this in an BufferLoad auto command or so.

Reading the docs of &listchar it might be some work to implement the rendering with &list on. Especially the different possibilities for a tab. That might make the tabs(1) solution from above unsuitable.

Currently I am working on replacing the AnsiEsc plugin in the poc/ansi2syntax branch. So it might take some time before I get to this but I'm happy to explore and discuss this.

lucc commented 3 years ago

Currently I can not find the time to work on this but I am open for PRs.

lucc commented 3 years ago

@tamirzb today I had some time and started to implement this. Have a look at the feature/listchars branch. Tabs are still missing and the extends and precedes listchar settings are not applicable in cat mode. And for the listchar conceal setting I still have to figure out how it interacts with the general conceal setting. But eol, space nbsp and tailing spaces are implemented.

tamirzb commented 3 years ago

Cool! Will take a look soon

lucc commented 3 years ago

Please check out 6b0733e75cf959a78e33c95f26c098d3194acd24. I have implemented rendering of listchars in cat mode for spaces, trailing spaces, nbsp and EOL. Tabs are more complicated and have been skipped for now. They can be added later.

lucc commented 3 years ago

I released 0.10 which contains the above commit.

@tamirzb I was thinking about the tabs for some time again. I think it might be nice to only render tabs as the correct number of spaces if &expandtab is set. Normally the option is only used in insert mode, so it has no meaning in nvimpagers cat mode. So we can use it to decide if we should turn tags into the correct number of spaces to honour &ts or just print plain tab characters ad let the terminal handle it all. What do you think?