diff options
author | Christian Clason <c.clason@uni-graz.at> | 2021-11-26 17:34:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-26 17:34:45 +0100 |
commit | afbf89dc0120b1db5782a0bf807dc7c8db70ccf6 (patch) | |
tree | 367138d9cc00a88b8720686dae30c7d3497208d4 | |
parent | 7ded8802279434aefd007b19d9bff62c6ba88781 (diff) | |
download | rneovim-afbf89dc0120b1db5782a0bf807dc7c8db70ccf6.tar.gz rneovim-afbf89dc0120b1db5782a0bf807dc7c8db70ccf6.tar.bz2 rneovim-afbf89dc0120b1db5782a0bf807dc7c8db70ccf6.zip |
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)
https://github.com/vim/vim/commit/7329cfab36356c48edab7ed68f6244eb9e20a5b1
-rw-r--r-- | runtime/autoload/dist/ft.vim | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_filetype.vim | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 7484149a26..344889249b 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -272,6 +272,8 @@ func dist#ft#FTm() " excluding end(for|function|if|switch|while) common to Murphi 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 saw_comment = 0 " Whether we've seen a multiline comment leader. while n < 100 @@ -282,7 +284,7 @@ func dist#ft#FTm() " anything more definitive. let saw_comment = 1 endif - if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|//\)' + if line =~ '^\s*//' || line =~ '^\s*@import\>' || line =~ objc_preprocessor setf objc return endif diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 9651b8dce0..7560303e22 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -866,6 +866,16 @@ func Test_m_file() call assert_equal('objc', &filetype) 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 call writefile(['# Octave line comment'], 'Xfile.m') |