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