From f2ef4cedecf554c0c9f0694f93df1d53a57bf70c Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Tue, 1 Sep 2020 23:02:36 +0200 Subject: Fix reason filetype detection, closes #532 --- autoload/polyglot.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'autoload') diff --git a/autoload/polyglot.vim b/autoload/polyglot.vim index 7d5aa867..3753dc8e 100644 --- a/autoload/polyglot.vim +++ b/autoload/polyglot.vim @@ -202,6 +202,16 @@ func! polyglot#DetectFsFiletype() setf forth | return endfunc +func! polyglot#DetectReFiletype() + for lnum in range(1, min([line("$"), 50])) + let line = getline(lnum) + if line =~# '^\s*#\%(\%(if\|ifdef\|define\|pragma\)\s\+\w\|\s*include\s\+[<"]\|template\s*<\)' + setf cpp | return + endif + setf reason | return + endfor +endfunc + " Restore 'cpoptions' let &cpo = s:cpo_save unlet s:cpo_save -- cgit v1.2.3