Skip to content

Commit

Permalink
docs: set vim filetype on man pages for syntax highlighting
Browse files Browse the repository at this point in the history
Since the man pages in src/man use a ".txt" file extension (rather than
".1" or ".5"), their filetype is detected by (neo)vim as "text".

So at the bottom of every man page, add a vim modeline in a comment and
set the filetype to "groff", to enable syntax highlighting.

Note: All of the generated ".man", ".1" and ".5" files are currently
being detected as "nroff".

Note2: Set the filetype to "groff" rather than "nroff" because at least
.UR and .UE are groff extensions.  These macros look the same with
either filetype, but there may be more extensions being used and the
nroff.vim syntax file (which is included by groff.vim) does things
differently based on which filetype is used.

Based on the following example from (neo)vim's filetype.txt:

    or add this modeline to the file:
            /* vim: set filetype=idl : */

See `:help groff.vim` and `:help filetype.txt` in (neo)vim.

See also groff_man(7) for the man page macros (including extensions).

Environment: neovim 0.7.2-3 on Artix Linux.

Misc: I noticed this on #5290.
  • Loading branch information
kmk3 committed Aug 5, 2022
1 parent 316749a commit aacd2e7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/man/firecfg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,4 @@ Homepage: https://firejail.wordpress.com
.BR firejail-login (5),
.BR firejail-users (5),
.BR jailcheck (1)
.\" vim: set filetype=groff :
1 change: 1 addition & 0 deletions src/man/firejail-login.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ Homepage: https://firejail.wordpress.com
.BR firejail-profile (5),
.BR firejail-users (5),
.BR jailcheck (1)
.\" vim: set filetype=groff :
1 change: 1 addition & 0 deletions src/man/firejail-profile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1031,3 +1031,4 @@ Homepage: https://firejail.wordpress.com

.UR https://github.com/netblue30/firejail/wiki/Creating-Profiles
.UE
.\" vim: set filetype=groff :
1 change: 1 addition & 0 deletions src/man/firejail-users.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ Homepage: https://firejail.wordpress.com
.BR firejail-profile (5),
.BR firejail-login (5),
.BR jailcheck (1)
.\" vim: set filetype=groff :
1 change: 1 addition & 0 deletions src/man/firejail.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3611,3 +3611,4 @@ Homepage: https://firejail.wordpress.com
.UE ,
.UR https://github.com/netblue30/firejail
.UE
.\" vim: set filetype=groff :

0 comments on commit aacd2e7

Please sign in to comment.