Mercurial > vim
annotate runtime/ftplugin/php.vim @ 34699:58825f14431b
Added tag v9.1.0229 for changeset e5d2d9024ad68a1a294910a950a77f49dc41594a
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 31 Mar 2024 18:00:06 +0200 |
parents | 8ae680be2a51 |
children | 7c7432a53a6c |
rev | line source |
---|---|
7 | 1 " Vim filetype plugin file |
29659 | 2 " Language: PHP |
3 " Maintainer: Doug Kearns <dougkearns@gmail.com> | |
4 " Previous Maintainer: Dan Sharp | |
34134
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
29659
diff
changeset
|
5 " Last Change: 2024 Jan 14 |
7 | 6 |
29659 | 7 if exists("b:did_ftplugin") |
8 finish | |
9 endif | |
7 | 10 |
11 " Make sure the continuation lines below do not cause problems in | |
12 " compatibility mode. | |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
3410
diff
changeset
|
13 let s:keepcpo= &cpo |
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
3410
diff
changeset
|
14 set cpo&vim |
7 | 15 |
16 " Define some defaults in case the included ftplugins don't set them. | |
17 let s:undo_ftplugin = "" | |
34134
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
29659
diff
changeset
|
18 let s:browsefilter = "HTML Files (*.html, *.htm)\t*.html;*.htm\n" |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
29659
diff
changeset
|
19 if has("win32") |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
29659
diff
changeset
|
20 let s:browsefilter ..= "All Files (*.*)\t*\n" |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
29659
diff
changeset
|
21 else |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
29659
diff
changeset
|
22 let s:browsefilter ..= "All Files (*)\t*\n" |
8ae680be2a51
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"
Christian Brabandt <cb@256bit.org>
parents:
29659
diff
changeset
|
23 endif |
7 | 24 let s:match_words = "" |
25 | |
26 runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim | |
27 let b:did_ftplugin = 1 | |
28 | |
29 " Override our defaults if these were set by an included ftplugin. | |
30 if exists("b:undo_ftplugin") | |
29659 | 31 " let b:undo_ftplugin = "setlocal comments< commentstring< formatoptions< omnifunc<" |
32 let s:undo_ftplugin = b:undo_ftplugin | |
7 | 33 endif |
34 if exists("b:browsefilter") | |
29659 | 35 " let b:undo_ftplugin ..= " | unlet! b:browsefilter b:html_set_browsefilter" |
36 let s:browsefilter = b:browsefilter | |
7 | 37 endif |
38 if exists("b:match_words") | |
29659 | 39 " let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words b:html_set_match_words" |
40 let s:match_words = b:match_words | |
7 | 41 endif |
1125 | 42 if exists("b:match_skip") |
29659 | 43 unlet b:match_skip |
1125 | 44 endif |
7 | 45 |
29659 | 46 setlocal comments=s1:/*,mb:*,ex:*/,://,:# |
47 setlocal commentstring=/*%s*/ | |
48 setlocal formatoptions+=l formatoptions-=t | |
49 | |
50 if get(g:, "php_autocomment", 1) | |
51 setlocal formatoptions+=croq | |
52 " NOTE: set g:PHP_autoformatcomment = 0 to prevent the indent plugin from | |
53 " overriding this 'comments' value | |
54 setlocal comments-=:# | |
55 " space after # comments to exclude attributes | |
56 setlocal comments+=b:# | |
7 | 57 endif |
58 | |
29659 | 59 if exists('&omnifunc') |
60 setlocal omnifunc=phpcomplete#CompletePHP | |
61 endif | |
62 | |
63 setlocal suffixesadd=.php | |
64 | |
7 | 65 " ### |
66 " Provided by Mikolaj Machowski <mikmach at wp dot pl> | |
67 setlocal include=\\\(require\\\|include\\\)\\\(_once\\\)\\\? | |
1622 | 68 " Disabled changing 'iskeyword', it breaks a command such as "*" |
69 " setlocal iskeyword+=$ | |
70 | |
29659 | 71 let b:undo_ftplugin = "setlocal include< suffixesadd<" |
72 | |
73 if exists("loaded_matchit") && exists("b:html_set_match_words") | |
74 let b:match_ignorecase = 1 | |
75 let b:match_words = 'PhpMatchWords()' | |
76 | |
77 if !exists("*PhpMatchWords") | |
78 function! PhpMatchWords() | |
79 " The PHP syntax file uses the Delimiter syntax group for the phpRegion | |
80 " matchgroups, without a "php" prefix, so use the stack to test for the | |
81 " outer phpRegion group. This also means the closing ?> tag which is | |
82 " outside of the matched region just uses the Delimiter group for the | |
83 " end match. | |
84 let stack = synstack(line('.'), col('.')) | |
85 let php_region = !empty(stack) && synIDattr(stack[0], "name") =~# '\<php' | |
86 if php_region || getline(".") =~ '.\=\%.c\&?>' | |
87 let b:match_skip = "PhpMatchSkip('html')" | |
88 return '<?php\|<?=\=:?>,' .. | |
89 \ '\<if\>:\<elseif\>:\<else\>:\<endif\>,' .. | |
90 \ '\<switch\>:\<case\>:\<break\>:\<continue\>:\<endswitch\>,' .. | |
91 \ '\<while\>.\{-})\s*\::\<break\>:\<continue\>:\<endwhile\>,' .. | |
92 \ '\<do\>:\<break\>:\<continue\>:\<while\>,' .. | |
93 \ '\<for\>:\<break\>:\<continue\>:\<endfor\>,' .. | |
94 \ '\<foreach\>:\<break\>:\<continue\>:\<endforeach\>,' .. | |
95 \ '\%(<<<\s*\)\@<=''\=\(\h\w*\)''\=:^\s*\1\>' | |
96 | |
97 " TODO: these probably aren't worth adding and really need syntax support | |
98 " '<\_s*script\_s*language\_s*=\_s*[''"]\=\_s*php\_s*[''"]\=\_s*>:<\_s*\_s*/\_s*script\_s*>,' .. | |
99 " '<%:%>,' .. | |
100 else | |
101 let b:match_skip = "PhpMatchSkip('php')" | |
102 return s:match_words | |
103 endif | |
104 endfunction | |
105 endif | |
106 if !exists("*PhpMatchSkip") | |
107 function! PhpMatchSkip(skip) | |
108 let name = synIDattr(synID(line('.'), col('.'), 1), 'name') | |
109 if a:skip == "html" | |
110 " ?> in line comments will also be correctly matched as Delimiter | |
111 return name =~? 'comment\|string' || name !~? 'php\|delimiter' | |
112 else " php | |
113 return name =~? 'comment\|string\|php' | |
114 endif | |
115 endfunction | |
116 endif | |
117 let b:undo_ftplugin ..= " | unlet! b:match_skip" | |
7 | 118 endif |
119 " ### | |
120 | |
29659 | 121 " Change the :browse e filter to primarily show PHP-related files. |
122 if (has("gui_win32") || has("gui_gtk")) && exists("b:html_set_browsefilter") | |
123 let b:browsefilter = "PHP Files (*.php)\t*.php\n" .. | |
124 \ "PHP Test Files (*.phpt)\t*.phpt\n" .. | |
125 \ s:browsefilter | |
714 | 126 endif |
127 | |
29659 | 128 if !exists("no_plugin_maps") && !exists("no_php_maps") |
129 " Section jumping: [[ and ]] provided by Antony Scriven <adscriven at gmail dot com> | |
130 let s:function = '\%(abstract\s\+\|final\s\+\|private\s\+\|protected\s\+\|public\s\+\|static\s\+\)*function' | |
131 let s:class = '\%(abstract\s\+\|final\s\+\)*class' | |
132 let s:section = escape('^\s*\zs\%(' .. s:function .. '\|' .. s:class .. '\|interface\|trait\|enum\)\>', "|") | |
714 | 133 |
29659 | 134 function! s:Jump(pattern, count, flags) |
135 normal! m' | |
136 for i in range(a:count) | |
137 if !search(a:pattern, a:flags) | |
138 break | |
139 endif | |
140 endfor | |
141 endfunction | |
7 | 142 |
29659 | 143 for mode in ["n", "o", "x"] |
144 exe mode .. "noremap <buffer> <silent> ]] <Cmd>call <SID>Jump('" .. s:section .. "', v:count1, 'W')<CR>" | |
145 exe mode .. "noremap <buffer> <silent> [[ <Cmd>call <SID>Jump('" .. s:section .. "', v:count1, 'bW')<CR>" | |
146 let b:undo_ftplugin ..= " | sil! exe '" .. mode .. "unmap <buffer> ]]'" .. | |
147 \ " | sil! exe '" .. mode .. "unmap <buffer> [['" | |
148 endfor | |
149 endif | |
150 | |
151 let b:undo_ftplugin ..= " | " .. s:undo_ftplugin | |
7 | 152 |
153 " Restore the saved compatibility options. | |
3496
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
3410
diff
changeset
|
154 let &cpo = s:keepcpo |
d1e4abe8342c
Fixed compatible mode in most runtime files.
Bram Moolenaar <bram@vim.org>
parents:
3410
diff
changeset
|
155 unlet s:keepcpo |
29659 | 156 |
157 " vim: nowrap sw=2 sts=2 ts=8 noet: |