]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1764: filetype: CODEOWNERS file not recognized v9.1.1764
authorJon Parise <jon@indelible.org>
Mon, 15 Sep 2025 19:35:47 +0000 (19:35 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 15 Sep 2025 19:35:47 +0000 (19:35 +0000)
Problem:  filetype: CODEOWNERS file not recognized
Solution: Detect CODEOWNERS file as codeowners filetype, include a
          syntax and filetype plugin (Jon Parise).

CODEOWNERS files define code ownership rules for GitHub-hosted (and
other) repositories. The syntax is similar to 'gitignore' files but
differs in enough ways to warrant its own filetype.

References:
- https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

closes: #18299

Signed-off-by: Jon Parise <jon@indelible.org>
Signed-off-by: Christian Brabandt <cb@256bit.org>
.github/MAINTAINERS
runtime/filetype.vim
runtime/ftplugin/codeowners.vim [new file with mode: 0644]
runtime/syntax/codeowners.vim [new file with mode: 0644]
runtime/syntax/testdir/dumps/codeowners_00.dump [new file with mode: 0644]
runtime/syntax/testdir/input/codeowners.txt [new file with mode: 0644]
src/testdir/test_filetype.vim
src/version.c

index 43b7fb4a6923c3c9407b0561e20479d5ccf78e0b..a8099c4ec337c02027028871cc291c235f8a6319 100644 (file)
@@ -136,6 +136,7 @@ runtime/ftplugin/chatito.vim                                @ObserverOfTime
 runtime/ftplugin/chicken.vim                           @evhan
 runtime/ftplugin/clojure.vim                           @axvr
 runtime/ftplugin/cmakecache.vim                                @ribru17
+runtime/ftplugin/codeowners.vim                                @jparise
 runtime/ftplugin/cook.vim                              @ribru17
 runtime/ftplugin/cs.vim                                        @nickspoons
 runtime/ftplugin/csh.vim                               @dkearns
@@ -456,6 +457,7 @@ runtime/syntax/chatito.vim                          @ObserverOfTime
 runtime/syntax/chicken.vim                             @evhan
 runtime/syntax/chuck.vim                               @andreacfromtheapp
 runtime/syntax/clojure.vim                             @axvr
+runtime/syntax/codeowners.vim                          @jparise
 runtime/syntax/cs.vim                                  @nickspoons
 runtime/syntax/csv.vim                                 @habamax
 runtime/syntax/cucumber.vim                            @tpope
@@ -686,3 +688,5 @@ src/po/sr.po                                                @eevan78
 src/po/tr.po                                           @bitigchi
 src/po/uk.po                                           @sakhnik
 src/xxd/                                               @jnweiger
+
+# vim:ft=codeowners
index 5d27801f23ce3ab224de915af3233408cd29d860..934e4042f605780e7e3690c6bdf537cdad3ffcf0 100644 (file)
@@ -398,6 +398,9 @@ au BufNewFile,BufRead *.ck                  setf chuck
 " Comshare Dimension Definition Language
 au BufNewFile,BufRead *.cdl                    setf cdl
 
+" Codeowners
+au BufNewFile,BufRead CODEOWNERS               setf codeowners
+
 " Conary Recipe
 au BufNewFile,BufRead *.recipe                 setf conaryrecipe
 
diff --git a/runtime/ftplugin/codeowners.vim b/runtime/ftplugin/codeowners.vim
new file mode 100644 (file)
index 0000000..f1dad0d
--- /dev/null
@@ -0,0 +1,14 @@
+" Vim filetype plugin
+" Language:    codeowners
+" Maintainer:  Jon Parise <jon@indelible.org>
+" Last Change: 2025 Sep 14
+"
+if exists('b:did_ftplugin')
+  finish
+endif
+let b:did_ftplugin = 1
+
+setl comments=:# commentstring=#\ %s
+setl formatoptions-=t formatoptions+=croql
+
+let b:undo_ftplugin = 'setl com< cms< fo<'
diff --git a/runtime/syntax/codeowners.vim b/runtime/syntax/codeowners.vim
new file mode 100644 (file)
index 0000000..7370220
--- /dev/null
@@ -0,0 +1,23 @@
+" Vim syntax file
+" Language:    codeowners
+" Maintainer:  Jon Parise <jon@indelible.org>
+" Last Change: 2025 Sep 14
+
+if exists('b:current_syntax')
+  finish
+endif
+
+" Comments
+syn match codeownersComment /#.*$/ contains=codeownersTodo,@Spell
+syn keyword codeownersTodo TODO FIXME XXX contained
+
+" Patterns
+syn match codeownersPattern /^#\@![^#]*/ contains=codeownersGlob
+syn match codeownersGlob /^\S\+/ contained nextgroup=codeownersOwner skipwhite
+syn match codeownersOwner /\S\+/ contained nextgroup=codeownersOwner skipwhite
+
+hi def link codeownersComment Comment
+hi def link codeownersOwner Identifier
+hi def link codeownersTodo Todo
+
+let b:current_syntax = 'codeowners'
diff --git a/runtime/syntax/testdir/dumps/codeowners_00.dump b/runtime/syntax/testdir/dumps/codeowners_00.dump
new file mode 100644 (file)
index 0000000..41d7d37
--- /dev/null
@@ -0,0 +1,20 @@
+>#+0#0000e05#ffffff0| |T|h|i|s| |i|s| |a| |c|o|m@1|e|n|t|.| +0#0000000&@54
+|#+0#0000e05&| |E|a|c|h| |l|i|n|e| |i|s| |a| |f|i|l|e| |p|a|t@1|e|r|n| |f|o|l@1|o|w|e|d| |b|y| |o|n|e| |o|r| |m|o|r|e| |o|w|n|e|r|s|.| +0#0000000&@13
+@75
+|*| @6|@+0#00e0e07&|g|l|o|b|a|l|-|o|w|n|e|r|1| +0#0000000&|@+0#00e0e07&|g|l|o|b|a|l|-|o|w|n|e|r|2| +0#0000000&@37
+|*|.|j|s| @3|@+0#00e0e07&|j|s|-|o|w|n|e|r| +0#0000000&|#+0#0000e05&|T|h|i|s| |i|s| |a|n| |i|n|l|i|n|e| |c|o|m@1|e|n|t|.| +0#0000000&@29
+|*|.|g|o| @3|d+0#00e0e07&|o|c|s|@|e|x|a|m|p|l|e|.|c|o|m| +0#0000000&@50
+|*|.|t|x|t| @2|@+0#00e0e07&|o|c|t|o|-|o|r|g|/|o|c|t|o|c|a|t|s| +0#0000000&@48
+|/|a|/|b|/| @2|@+0#00e0e07&|d|o|c|t|o|c|a|t| +0#0000000&@57
+|d|o|c|s|/|*| @1|d+0#00e0e07&|o|c|s|@|e|x|a|m|p|l|e|.|c|o|m| +0#0000000&|@+0#00e0e07&|o|t|h|e|r| +0#0000000&@43
+|*@1|/|l|o|g|s| |@+0#00e0e07&|o|c|t|o|c|a|t| +0#0000000&@58
+@75
+|#+0#0000e05&| |v|i|m|:| |s|e|t| |f|t|=|c|o|d|e|o|w|n|e|r|s|:| +0#0000000&@49
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
diff --git a/runtime/syntax/testdir/input/codeowners.txt b/runtime/syntax/testdir/input/codeowners.txt
new file mode 100644 (file)
index 0000000..e72a770
--- /dev/null
@@ -0,0 +1,12 @@
+# This is a comment.
+# Each line is a file pattern followed by one or more owners.
+
+*       @global-owner1 @global-owner2
+*.js    @js-owner #This is an inline comment.
+*.go   docs@example.com
+*.txt  @octo-org/octocats
+/a/b/  @doctocat
+docs/* docs@example.com @other
+**/logs @octocat
+
+# vim: set ft=codeowners:
index 5752e7c4033d3d5bb1bd41d8dafec86ea47b4c97..7aa3197875a8c7ee0d38ce13228039fc07c36950 100644 (file)
@@ -189,6 +189,7 @@ def s:GetFilenameChecks(): dict<list<string>>
     cmusrc: ['any/.cmus/autosave', 'any/.cmus/rc', 'any/.cmus/command-history', 'any/.cmus/file.theme', 'any/cmus/rc', 'any/cmus/file.theme', '/.cmus/autosave', '/.cmus/command-history', '/.cmus/file.theme', '/.cmus/rc', '/cmus/file.theme', '/cmus/rc'],
     cobol: ['file.cbl', 'file.cob'],
     coco: ['file.atg'],
+    codeowners: ['CODEOWNERS'],
     conaryrecipe: ['file.recipe'],
     conf: ['auto.master', 'file.conf', 'texdoc.cnf', '.x11vncrc', '.chktexrc', '.ripgreprc', 'ripgreprc', 'file.ctags'],
     config: ['/etc/hostname.file', 'any/etc/hostname.file', 'configure.in', 'configure.ac', 'file.at', 'aclocal.m4'],
index 696fde76f46b17713117b6372eef5b636c6d607f..1e231bf31f508e6cf613d6fef38b4be446727222 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1764,
 /**/
     1763,
 /**/