comparison runtime/autoload/dist/ft.vim @ 26296:9f32ccdadd22 v8.2.3679

patch 8.2.3679: objc file detected as Octave Commit: https://github.com/vim/vim/commit/7329cfab36356c48edab7ed68f6244eb9e20a5b1 Author: Doug Kearns <dougkearns@gmail.com> Date: Fri Nov 26 13:01:41 2021 +0000 patch 8.2.3679: objc file detected as Octave Problem: objc file detected as Octave. (Antony Lee) Solution: Detect objc by preprocessor lines. (Doug Kearns, closes https://github.com/vim/vim/issues/9223, closes #9220)
author Bram Moolenaar <Bram@vim.org>
date Fri, 26 Nov 2021 14:15:05 +0100
parents 374adc90efa5
children ce3678583211
comparison
equal deleted inserted replaced
26295:84d52b86a6b3 26296:9f32ccdadd22
270 endif 270 endif
271 271
272 " excluding end(for|function|if|switch|while) common to Murphi 272 " excluding end(for|function|if|switch|while) common to Murphi
273 let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|methods\|parfor\|properties\)\>' 273 let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|methods\|parfor\|properties\)\>'
274 274
275 let objc_preprocessor = '^\s*#\s*\%(import\|include\|define\|if\|ifn\=def\|undef\|line\|error\|pragma\)\>'
276
275 let n = 1 277 let n = 1
276 let saw_comment = 0 " Whether we've seen a multiline comment leader. 278 let saw_comment = 0 " Whether we've seen a multiline comment leader.
277 while n < 100 279 while n < 100
278 let line = getline(n) 280 let line = getline(n)
279 if line =~ '^\s*/\*' 281 if line =~ '^\s*/\*'
280 " /* ... */ is a comment in Objective C and Murphi, so we can't conclude 282 " /* ... */ is a comment in Objective C and Murphi, so we can't conclude
281 " it's either of them yet, but track this as a hint in case we don't see 283 " it's either of them yet, but track this as a hint in case we don't see
282 " anything more definitive. 284 " anything more definitive.
283 let saw_comment = 1 285 let saw_comment = 1
284 endif 286 endif
285 if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|//\)' 287 if line =~ '^\s*//' || line =~ '^\s*@import\>' || line =~ objc_preprocessor
286 setf objc 288 setf objc
287 return 289 return
288 endif 290 endif
289 if line =~ '^\s*\%(#\|%!\)' || line =~ '^\s*unwind_protect\>' || 291 if line =~ '^\s*\%(#\|%!\)' || line =~ '^\s*unwind_protect\>' ||
290 \ line =~ '\%(^\|;\)\s*' .. octave_block_terminators 292 \ line =~ '\%(^\|;\)\s*' .. octave_block_terminators