git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] docs: add vim syntax modeline [RFC]

From
D. Ben Knoble <ben.knoble@gmail.com>
Date
Jan 13, 2025, 22:37 UTC
Message-ID
<CALnO6CCLhsQbkC6nsaeiFDksbh_UAxC9igFD3r5V1Bz+YLyWaw@mail.gmail.com>
In-Reply-To
<pull.1874.git.git.1736802194760.gitgitgadget@gmail.com>

On Mon, Jan 13, 2025 at 4:05 PM M Hickford via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 8 quoted lines
>
> From: M Hickford <mirth.hickford@gmail.com>
>
> Git documentation is written in AsciiDoc. This format is easily
> mistaken for the pervasive Markdown.
>
> Add a vim modeline to help editors identify the format and provide
> syntax highlighting, rendering and autocomplete.

FWIW, Vim by default only has a single autocommand for *.txt files, and it's to see if they are help files.

Now, there is a fallback $VIMRUNTIME/scripts.vim mechanism that performs various "heuristic" checks, but I can't find a reference to markdown in it either. So stock Vim treats them as "filetype=text."

Show 7 quoted lines
>
> This makes editing the documentation easier for prospective
> contributors. This is particularly important because new contributors
> often start with documentation changes.
>
> An alternative could be to move the modeline up or down the file (the
> location is not important).
Not quite. :help modeline says
    The number of lines that are checked can be set with the 'modelines' option.
    If 'modeline' is off or 'modelines' is 0 no lines are checked.
and the default value of 'modelines' is 5.
>
> A simpler alternative could be to rename files *.adoc. This would have
> the advantage of being recognised by even more tools.
Indeed, Vim knows that *.adoc and *.asciidoc are "filetype=asciidoc".

You could also see about submitting a patch to Vim to check *.txt files for asciidoc syntax, or add your own ftdetect rules [1] that say that files with %:p matching "git.*/Documentation" (for example) get the filetype asciidoc.

[1]: https://vi.stackexchange.com/a/23251/10604, https://vi.stackexchange.com/a/18493/10604, https://vi.stackexchange.com/a/28109/10604, etc.

-- 
D. Ben Knoble
Previous: M Hickford
Message 6 of 6 in “docs: add vim syntax modeline [RFC]”
  1. docs: add vim syntax modeline [RFC]M Hickford via GitGitGadget, Jan 13, 2025
  2. brian m. carlsonJan 13, 2025
  3. M HickfordJan 13, 2025
  4. Junio C HamanoJan 13, 2025
  5. M HickfordJan 16, 2025
  6. D. Ben KnobleJan 13, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.