From 46040f3ffd35c4a981ca1f3713934f55b58bb525 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 6 Sep 2020 23:37:24 +0200 Subject: Add heuristics for .h extension --- autoload/polyglot.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'autoload/polyglot.vim') diff --git a/autoload/polyglot.vim b/autoload/polyglot.vim index ffb3c43f..1ed71826 100644 --- a/autoload/polyglot.vim +++ b/autoload/polyglot.vim @@ -154,6 +154,25 @@ func! polyglot#DetectAspFiletype() setf aspvbs | return endfunc +func! polyglot#DetectHFiletype() + for lnum in range(1, min([line("$"), 200])) + let line = getline(lnum) + if line =~# '^\s*\(@\(interface\|class\|protocol\|property\|end\|synchronised\|selector\|implementation\)\(\<\|\>\)\|#import\s\+.\+\.h[">]\)' + if exists("g:c_syntax_for_h") + setf objc | return + endif + setf objcpp | return + endif + endfor + if exists("g:c_syntax_for_h") + setf c | return + endif + if exists("g:ch_syntax_for_h") + setf ch | return + endif + setf cpp | return +endfunc + func! polyglot#DetectMFiletype() let saw_comment = 0 for lnum in range(1, min([line("$"), 100])) -- cgit v1.2.3