patch 9.2.0489: filetype: some Objective-C files are not recognized

Problem:  filetype: some Objective-C files are not recognized
Solution: Add g:filetype_mm override variable, improve the objective c
          pattern detection (Keith Smiley).

closes: #20221

Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Keith Smiley
2026-05-16 07:46:25 +00:00
committed by Christian Brabandt
parent 7cb86f46cb
commit bc7f736a39
4 changed files with 42 additions and 3 deletions
+7 -2
View File
@@ -3,7 +3,7 @@ vim9script
# Vim functions for file type detection
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
# Last Change: 2026 Apr 23
# Last Change: 2026 May 16
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
# These functions are moved here from runtime/filetype.vim to make startup
@@ -798,9 +798,14 @@ export def FTnroff(): number
enddef
export def FTmm()
if exists("g:filetype_mm")
exe "setf " .. g:filetype_mm
return
endif
var n = 1
while n < 20
if getline(n) =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\)'
if getline(n) =~ '^\s*\(//\|#\s*\(include\|import\)\>\|@import\>\|/\*\)'
setf objcpp
return
endif
+2 -1
View File
@@ -1,4 +1,4 @@
*filetype.txt* For Vim version 9.2. Last change: 2026 Apr 13
*filetype.txt* For Vim version 9.2. Last change: 2026 May 16
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -164,6 +164,7 @@ variables can be used to overrule the filetype used for certain extensions:
*.int g:filetype_int
*.lsl g:filetype_lsl
*.m g:filetype_m |ft-mathematica-syntax|
*.mm g:filetype_mm
*.mac g:filetype_mac
*[mM]makefile,*.mk,*.mak,[mM]akefile*
g:make_flavor |ft-make-syntax|