[PATCH] improve Objective-C filetype detection

43 views
Skip to first unread message

Kazuki Sakamoto

unread,
Jul 30, 2015, 1:34:12 PM7/30/15
to vim...@vim.org
Hi Bram,

I've created a patch to improve Objective-C filetype detection in ".m"
and ".mm" file. Could you check the patch?

Modern Objective-C code uses "@import" instead of "#include" or "#import".
http://clang.llvm.org/docs/Modules.html#objective-c-import-declaration

Regards,
Kazuki

Problem: Fail to detect modern Objective-C code.
Solution: Add @import detector
Files: runtime/filetype.vim

diff --git a/runtime/filetype.vim b/runtime/filetype.vim
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1168,7 +1168,7 @@ func! s:FTm()
let n = 1
while n < 10
let line = getline(n)
- if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\|//\)'
+ if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\|//\)'
setf objc
return
endif
@@ -1336,7 +1336,7 @@ func! s:FTmm()
let n = 1
while n < 10
let line = getline(n)
- if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
+ if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\)'
setf objcpp
return
endif

Bram Moolenaar

unread,
Jul 31, 2015, 4:28:26 PM7/31/15
to Kazuki Sakamoto, vim...@vim.org

Kazuki Sakamoto wrote:

> I've created a patch to improve Objective-C filetype detection in ".m"
> and ".mm" file. Could you check the patch?
>
> Modern Objective-C code uses "@import" instead of "#include" or "#import".
> http://clang.llvm.org/docs/Modules.html#objective-c-import-declaration

Thanks!


--
GALAHAD: No. Look, I can tackle this lot single-handed!
GIRLS: Yes, yes, let him Tackle us single-handed!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages