aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-06-25 21:20:19 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-06-25 21:20:26 -0400
commit62c7fcbdab28589b0efff03d7b26408362514a19 (patch)
treeb26eaefc81864e4a9b9d02674fb6b8fec4ac0ab4
parent10c983fabeae6f2cda93404f3aa4ee814baa43f3 (diff)
downloadrneovim-62c7fcbdab28589b0efff03d7b26408362514a19.tar.gz
rneovim-62c7fcbdab28589b0efff03d7b26408362514a19.tar.bz2
rneovim-62c7fcbdab28589b0efff03d7b26408362514a19.zip
vim-patch:8.1.1593: filetype not detected for C++ header files without extension
Problem: Filetype not detected for C++ header files without extension. Solution: Recognize the file by the Emacs file mode. (Dmitry Ilyin, closes vim/vim#4593) https://github.com/vim/vim/commit/6a7af8e2dbcb768a768831d9e6355c855c215ebc
-rw-r--r--runtime/scripts.vim13
-rw-r--r--src/nvim/testdir/test_filetype.vim2
2 files changed, 11 insertions, 4 deletions
diff --git a/runtime/scripts.vim b/runtime/scripts.vim
index ab66c0c0a1..8d460cd317 100644
--- a/runtime/scripts.vim
+++ b/runtime/scripts.vim
@@ -195,7 +195,7 @@ else
if s:line1 =~# '^:$'
call dist#ft#SetFileTypeSH(s:line1) " defined in filetype.vim
- " Z shell scripts
+ " Z shell scripts
elseif s:line1 =~# '^#compdef\>' || s:line1 =~# '^#autoload\>' ||
\ "\n".s:line1."\n".s:line2."\n".s:line3."\n".s:line4."\n".s:line5 =~# '\n\s*emulate\s\+\%(-[LR]\s\+\)\=[ckz]\=sh\>'
set ft=zsh
@@ -204,15 +204,20 @@ else
elseif s:line1 =~# '^From \([a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\=\|-\) .* \(19\|20\)\d\d$'
set ft=mail
- " Mason
+ " Mason
elseif s:line1 =~# '^<[%&].*>'
set ft=mason
- " Vim scripts (must have '" vim' as the first line to trigger this)
+ " Vim scripts (must have '" vim' as the first line to trigger this)
elseif s:line1 =~# '^" *[vV]im$'
set ft=vim
- " MOO
+ " libcxx and libstdc++ standard library headers like "iostream" do not have
+ " an extension, recognize the Emacs file mode.
+ elseif s:line1 =~? '-\*-.*C++.*-\*-'
+ set ft=cpp
+
+ " MOO
elseif s:line1 =~# '^\*\* LambdaMOO Database, Format Version \%([1-3]\>\)\@!\d\+ \*\*$'
set ft=moo
diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim
index 7a99a37be4..897f736d76 100644
--- a/src/nvim/testdir/test_filetype.vim
+++ b/src/nvim/testdir/test_filetype.vim
@@ -581,6 +581,8 @@ let s:script_checks = {
\ 'cfengine': [['#!/path/cfengine']],
\ 'erlang': [['#!/path/escript']],
\ 'haskell': [['#!/path/haskell']],
+ \ 'cpp': [['// Standard iostream objects -*- C++ -*-'],
+ \ ['// -*- C++ -*-']],
\ }
func Test_script_detection()