-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add highlighting for manpages? #523
Comments
Thank you for the feedback! I thought a little bit about this and played around with export MANPAGER="nvim -c 'set ft=man' -" you don't need to call One thing which is really neat is that they highlight the I'm not really sure if there is something that we could do even better than |
I have MANPAGER set like that already ( Thank you for considering it! |
What are changes or features you are looking for? |
I'm used to Also would in general be nice to decouple this from There's also |
I've been playing around with this for a little bit. Here is a rather hacky first version. If somebody wants to try it (or even work on this): Step 1Save the following syntax as %YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Man
file_extensions:
- man
scope: source.man
variables:
section_heading: '^\S.*$'
contexts:
main:
- match: ^
push: first_line
first_line:
- match: '([A-Z0-9]+)(\()([^)]+)(\))'
captures:
1: meta.preprocessor
2: keyword.operator
3: string.quoted.other
4: keyword.operator
- match: '$'
push: body
body:
- match: '^(SYNOPSIS|SYNTAX|SINTASSI|SKŁADNIA|СИНТАКСИС|書式)'
push: Packages/C/C.sublime-syntax
scope: markup.heading
with_prototype:
- match: '(?={{section_heading}})'
pop: true
- match: '^\S.*$'
scope: markup.heading
- match: '\b([a-z0-9_]+)(\()([^)]*)(\))'
captures:
1: entity.name.function
2: keyword.operator
3: constant.numeric
4: keyword.operator Step 2Run
Step 3Set up the pager: export MANPAGER="sh -c 'sed -e s/.\\\\x08//g | bat -l man -p'" Step 4Run man 2 select
man fopen
… |
Thanks, I will give it a run tomorrow. :)
…On Fri, Mar 15, 2019, 00:10 David Peter ***@***.*** wrote:
I've been playing around with this for a little bit. Here is a rather
hacky first version.
If somebody wants to try it (or even work on this):
Step 1
Save the following syntax as ~/.config/bat/syntaxes/Man.sublime-syntax.
%YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Man
file_extensions:
- man
scope: source.man
variables:
section_heading: '^\S.*$'
contexts:
main:
- match: ^
push: first_line
first_line:
- match: '([A-Z0-9]+)(\()([^)]+)(\))'
captures:
1: meta.preprocessor
2: keyword.operator
3: string.quoted.other
4: keyword.operator
- match: '$'
push: body
body:
- match: '^(SYNOPSIS|SYNTAX|SINTASSI|SKŁADNIA|СИНТАКСИС|書式)'
push: Packages/C/C.sublime-syntax
scope: markup.heading
with_prototype:
- match: '(?={{section_heading}})'
pop: true
- match: '^\S.*$'
scope: markup.heading
- match: '\b([a-z0-9_]+)(\()([^)]*)(\))'
captures:
1: entity.name.function
2: keyword.operator
3: constant.numeric
4: keyword.operator
Step 2
Run
bat cache --build
Step 3
Set up the pager:
export MANPAGER="sh -c 'sed -e s/.\\\\x08//g | bat -l man -p'"
Step 4
Run man. For now, we do not make any decision based on the man section.
man select
man fopen
…
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#523 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AlHeorvamIPb0S8cic6bc6P98ii0Zguuks5vWtbSgaJpZM4bm5ak>
.
|
Looks good, couple things I would consider:
Name at the top (SELECT) is colored differently from select() further down
select() (function call) shouldn't be highlighted OR be highlighted
differently from page reference (select(3))
I guess that may be ambiguous though, if something of the form f(n) is used
as an example...
Also maybe give page references one uniform color rather than 3 individual
ones (name, parens, section number)
…On Fri, Mar 15, 2019, 00:13 David Peter ***@***.*** wrote:
Here is how it looks like (if everything goes well):
[image: image]
<https://user-images.githubusercontent.com/4209276/54397543-22e67980-46b7-11e9-8e04-70db86ed51a6.png>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#523 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AlHeovwpbplZycpRl6PUfo5TXxkJzTkpks5vWteggaJpZM4bm5ak>
.
|
Slightly missed opportunity for the title "bat man page highlights". :P |
I have added my initial version from above to the repository so that everyone can contribute to the further development. See README for instructions. |
Thank you! 😊
…On Sat, Aug 31, 2019, 14:34 David Peter ***@***.***> wrote:
I have added my initial version from above to the repository so that
everyone can contribute to the further development. See README for
instructions.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#523?email_source=notifications&email_token=AJI55IWYIVXOO5LQGFJTD2DQHJQMTA5CNFSM4G43S2SKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5TL4QQ#issuecomment-526827074>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJI55IRSTRDLD2X26LAKQ6LQHJQMTANCNFSM4G43S2SA>
.
|
Released in bat v0.12. |
I tried using bat as my man pager, but it currently lacks the highlight of command line options.. |
Another advantage to bat over neovim is that it is, anecdotally, faster to open. |
I would like to use
bat
as myMANPAGER
. I am not a fan ofmost(1)
, my current alternative is usingnvim(1)
with the:Man!
command.The text was updated successfully, but these errors were encountered: