aboutsummaryrefslogtreecommitdiff
path: root/vim/ftplugin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-02-01 17:57:35 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-02-01 17:57:35 +1300
commit3234d03ed04f52fdfa00a932978a548019212365 (patch)
tree1f78e291c6ef0cf43bc6a7d0c25fe63b7dcb81a4 /vim/ftplugin
parent9ca75421a60362f5a1ebc2c42d208f832f83de16 (diff)
downloaddotfiles-3234d03ed04f52fdfa00a932978a548019212365.tar.gz
dotfiles-3234d03ed04f52fdfa00a932978a548019212365.zip
Replace ftplugin/php.vim with custom version
Per the comment in the new file, this is to avoid loading in HTML ftplugins as well, a curiosity of the stock ftplugin/php.vim file that's probably a well-intentioned way of accommodating templated files with a mix of PHP and HTML in them.
Diffstat (limited to 'vim/ftplugin')
-rw-r--r--vim/ftplugin/php.vim38
1 files changed, 38 insertions, 0 deletions
diff --git a/vim/ftplugin/php.vim b/vim/ftplugin/php.vim
new file mode 100644
index 00000000..b545e18a
--- /dev/null
+++ b/vim/ftplugin/php.vim
@@ -0,0 +1,38 @@
+"
+" Replace Vim's stock PHP filetype plugin, reimplementing only the part I
+" actually need (the matchit.vim keyword pairs).
+"
+" This is mostly because the stock file pulls in HTML's filetype plugins too,
+" without providing a variable check to stop it. That causes absurd problems
+" with defining HTML checkers/linters in the rest of my files.
+"
+if exists('b:did_ftplugin')
+ finish
+endif
+let b:did_ftplugin = 1
+
+" Support line continuation for this file
+if &compatible
+ let s:cpoptions_save = &cpoptions
+ set cpoptions-=C
+endif
+
+" Define keywords for matchit.vim
+if exists('g:loaded_matchit')
+ let b:match_words = '<?php:?>'
+ \ . ',\<do\>:\<while\>'
+ \ . ',\<for\>:\<endfor\>'
+ \ . ',\<foreach\>:\<endforeach\>'
+ \ . ',\<if\>:\<elseif\>:\<else\>:\<endif\>'
+ \ . ',\<switch\>:\<endswitch\>'
+ \ . ',\<while\>:\<endwhile\>'
+endif
+
+" Define how to undo this plugin's settings
+let b:undo_ftplugin = 'unlet b:match_words'
+
+" Restore 'cpoptions' setting if we touched it
+if exists('s:cpoptions_save')
+ let &cpoptions = s:cpoptions_save
+ unlet s:cpoptions_save
+endif