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

Re: [RFC/PATCH] remove vim syntax highlighting in favor of upstream

From
BHBob Hiestand <bob.hiestand@gmail.com>
Date
Sep 25, 2008, 14:00 UTC
Message-ID
<cc29171c0809250700s3efa7601pbdb96d1bd94ab89b@mail.gmail.com>
In-Reply-To
<20080925124817.GC6816@neumann>
On Thu, Sep 25, 2008 at 7:48 AM, SZEDER Gábor <szeder@ira.uka.de> wrote:
Show 44 quoted lines
> Hi,
>
> OK, so I'm complaining a bit.
>
> On Wed, Sep 24, 2008 at 09:56:58PM +0200, SZEDER Gábor wrote:
>> +To install:
>> +
>> +  1. Copy these files to vim's syntax directory $HOME/.vim/syntax
>> +  2. Auto-detect the editing of various git-related filetypes:
>> +     $ cat >>$HOME/.vimrc <<'EOF'
>> +     autocmd BufNewFile,BufRead *.git/COMMIT_EDITMSG    setf gitcommit
>> +     autocmd BufNewFile,BufRead *.git/config,.gitconfig setf gitconfig
>> +     autocmd BufNewFile,BufRead git-rebase-todo         setf gitrebase
>> +     autocmd BufNewFile,BufRead .msg.[0-9]*
>> +             \ if getline(1) =~ '^From.*# This line is ignored.$' |
>> +             \   setf gitsendemail |
>> +             \ endif
>> +     autocmd BufNewFile,BufRead *.git/**
>> +             \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' |
>> +             \   setf git |
>> +             \ endif
>> +     EOF
>
> There are issues with this second step.  If I append this code to my
> .vimrc, then vim sometimes overrides the filetype with conf.
>
> vim has a guessing rule for detecting conf files, which triggers if
> one of the first five lines of the file begins with a '#'.  So if I
> start to write a new commit message or I interactively rebase 4 or
> less commits, then this rule triggers and vim overrides the git
> filetype with filetype conf.  If I do a commit --amend with a long
> enough original commit message or an interactive rebase with more than
> 4 commit, then this rule no more triggers and everything is fine.
>
> But what's really puzzling is that if I insert the above code into
> $VIMRUNTIME/filetype.vim (at the spot where it can be found in vim
> 7.2's filetype.vim), then everything works as expected, git filetypes
> are never overridden.
>
> This is not related to the changes in this patch.  git's original vim
> syntax highlight for commit messages has the exact same behaviour.
>
> The first step is OK: it doesn't matter whether I put git-related
> syntax files under $HOME/.vim/syntax/ or under $VIMRUNTIME/syntax/.

I'd guess that your autocommands defined in .vimrc take effect after the default file type settings. When you use ':setf', it intentionally will not override the existing file type if one has already been detected.

Use ':help new-filetype' to see the various ways you can interact with and/or override the default filetype detection.

bob
Previous: SZEDER GáborNext: Shawn O. Pearce
Message 10 of 14 in “vim syntax: highlight the diff in commit message template”
  1. vim syntax: highlight the diff in commit message templateSZEDER Gábor, Sep 24, 2008
  2. Jeff KingSep 24, 2008
  3. SZEDER GáborSep 24, 2008
  4. remove vim syntax highlighting in favor of upstreamJeff King, Sep 24, 2008
  5. Shawn O. PearceSep 24, 2008
  6. Garry DolleySep 24, 2008
  7. SZEDER GáborSep 24, 2008
  8. Jeff KingSep 24, 2008
  9. SZEDER GáborSep 25, 2008
  10. Bob HiestandSep 25, 2008
  11. Shawn O. PearceSep 29, 2008
  12. remove vim syntax highlighting in favor of upstreamSZEDER Gábor, Sep 29, 2008
  13. Jeff KingSep 29, 2008
  14. Michael J GruberSep 30, 2008

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.