aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--vim/ftplugin/php.vim38
2 files changed, 44 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 13a7db7a..70209907 100644
--- a/Makefile
+++ b/Makefile
@@ -47,6 +47,7 @@
install-vim-compiler \
install-vim-config \
install-vim-ftdetect \
+ install-vim-fplugin \
install-vim-gui \
install-vim-gui-config \
install-vim-indent \
@@ -503,6 +504,7 @@ install-vim: install-vim-after \
install-vim-config \
install-vim-doc \
install-vim-ftdetect \
+ install-vim-ftplugin \
install-vim-indent \
install-vim-plugin
@@ -554,6 +556,10 @@ install-vim-ftdetect:
mkdir -p -- $(HOME)/.vim/ftdetect
cp -p -- vim/ftdetect/*.vim $(HOME)/.vim/ftdetect
+install-vim-ftplugin:
+ mkdir -p -- $(HOME)/.vim/ftplugin
+ cp -p -- vim/ftplugin/*.vim $(HOME)/.vim/ftplugin
+
install-vim-indent:
mkdir -p -- $(HOME)/.vim/indent
cp -p -- vim/indent/*.vim $(HOME)/.vim/indent
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