Skip to content
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

docs: set vim filetype on man pages for syntax highlighting #5296

Merged
merged 1 commit into from
Aug 14, 2022

Conversation

kmk3
Copy link
Collaborator

@kmk3 kmk3 commented Aug 5, 2022

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.

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 netblue30#5290.
@kmk3 kmk3 added the documentation Issues and pull requests related to the documentation label Aug 5, 2022
@kmk3 kmk3 added this to In progress in Release 0.9.72 via automation Aug 5, 2022
@netblue30 netblue30 merged commit 9fed798 into netblue30:master Aug 14, 2022
@netblue30
Copy link
Owner

merged!

@kmk3 kmk3 deleted the docs-man-vim-ft branch August 14, 2022 23:10
kmk3 added a commit that referenced this pull request Aug 18, 2022
@kmk3 kmk3 moved this from In progress to Done (on RELNOTES) in Release 0.9.72 Aug 18, 2022
kmk3 added a commit that referenced this pull request Aug 20, 2022
Some man pages are missing it.

This amends commit aacd2e7 ("docs: set vim filetype on man pages for
syntax highlighting", 2022-08-04) / PR #5296.
kmk3 added a commit to kmk3/firejail that referenced this pull request Nov 24, 2022
Ignore the following paths:

- 'src/man/*.txt'
- contrib/vim

To avoid running CI unnecessarily.

Note: build-extra essentially only builds with clang and runs linters on
the C code, so changes to the man pages and vim files should not affect
the result.

Do not ignore them on .github/workflows/build.yml because they are part
of DISTFILES (see the root Makefile).

Misc: I noticed this on netblue30#5296 (man pages).
kmk3 added a commit to kmk3/firejail that referenced this pull request Nov 24, 2022
Ignore the following paths:

- 'contrib/vim/**'
- 'src/man/*.txt'

To avoid running CI unnecessarily.

Note: build-extra essentially only builds with clang and runs linters on
the C code, so changes to the man pages and vim files should not affect
the result.

Do not ignore them on .github/workflows/build.yml because they are part
of DISTFILES (see the root Makefile).

Misc: I noticed this on netblue30#5296 (man pages).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues and pull requests related to the documentation
Projects
No open projects
Release 0.9.72
  
Done (on RELNOTES)
Development

Successfully merging this pull request may close these issues.

None yet

3 participants