mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
vim-patch:8.2.3679: objc file detected as Octave (#16446)
Problem: objc file detected as Octave. (Antony Lee)
Solution: Detect objc by preprocessor lines. (Doug Kearns, closes vim/vim#9223,
closes vim/vim#9220)
7329cfab36
This commit is contained in:
parent
7ded880227
commit
afbf89dc01
4
runtime/autoload/dist/ft.vim
vendored
4
runtime/autoload/dist/ft.vim
vendored
@ -272,6 +272,8 @@ func dist#ft#FTm()
|
|||||||
" excluding end(for|function|if|switch|while) common to Murphi
|
" excluding end(for|function|if|switch|while) common to Murphi
|
||||||
let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|methods\|parfor\|properties\)\>'
|
let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|methods\|parfor\|properties\)\>'
|
||||||
|
|
||||||
|
let objc_preprocessor = '^\s*#\s*\%(import\|include\|define\|if\|ifn\=def\|undef\|line\|error\|pragma\)\>'
|
||||||
|
|
||||||
let n = 1
|
let n = 1
|
||||||
let saw_comment = 0 " Whether we've seen a multiline comment leader.
|
let saw_comment = 0 " Whether we've seen a multiline comment leader.
|
||||||
while n < 100
|
while n < 100
|
||||||
@ -282,7 +284,7 @@ func dist#ft#FTm()
|
|||||||
" anything more definitive.
|
" anything more definitive.
|
||||||
let saw_comment = 1
|
let saw_comment = 1
|
||||||
endif
|
endif
|
||||||
if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|//\)'
|
if line =~ '^\s*//' || line =~ '^\s*@import\>' || line =~ objc_preprocessor
|
||||||
setf objc
|
setf objc
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
@ -866,6 +866,16 @@ func Test_m_file()
|
|||||||
call assert_equal('objc', &filetype)
|
call assert_equal('objc', &filetype)
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
|
call writefile(['#include <header.h>'], 'Xfile.m')
|
||||||
|
split Xfile.m
|
||||||
|
call assert_equal('objc', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
call writefile(['#define FORTY_TWO'], 'Xfile.m')
|
||||||
|
split Xfile.m
|
||||||
|
call assert_equal('objc', &filetype)
|
||||||
|
bwipe!
|
||||||
|
|
||||||
" Octave
|
" Octave
|
||||||
|
|
||||||
call writefile(['# Octave line comment'], 'Xfile.m')
|
call writefile(['# Octave line comment'], 'Xfile.m')
|
||||||
|
Loading…
Reference in New Issue
Block a user