Mercurial > vim
annotate runtime/macros/less.vim @ 34329:a059fc613d55 v9.1.0098
patch 9.1.0098: CompletionChanged not triggered when new leader added without matches
Commit: https://github.com/vim/vim/commit/0d3c0a66a39570cbc52b9536604c39e324b989b3
Author: glepnir <glephunter@gmail.com>
Date: Sun Feb 11 17:52:40 2024 +0100
patch 9.1.0098: CompletionChanged not triggered when new leader added without matches
Problem: CompletionChanged not triggered when new leader added causing
no matching item in the completion menu
Solution: When completion is active but no items matched still trigger
CompletChanged event
(glepnir)
closes: #13982
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 11 Feb 2024 18:00:03 +0100 |
parents | 4027cefc2aab |
children | 9ddc74d06433 |
rev | line source |
---|---|
7 | 1 " Vim script to work like "less" |
32770
4027cefc2aab
Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents:
23305
diff
changeset
|
2 " Maintainer: The Vim Project <https://github.com/vim/vim> |
4027cefc2aab
Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents:
23305
diff
changeset
|
3 " Last Change: 2023 Aug 10 |
4027cefc2aab
Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
Christian Brabandt <cb@256bit.org>
parents:
23305
diff
changeset
|
4 " Former Maintainer: Bram Moolenaar <Bram@vim.org> |
7 | 5 |
6 " Avoid loading this file twice, allow the user to define his own script. | |
7 if exists("loaded_less") | |
8 finish | |
9 endif | |
10 let loaded_less = 1 | |
11 | |
12 " If not reading from stdin, skip files that can't be read. | |
13 " Exit if there is no file at all. | |
14 if argc() > 0 | |
15 let s:i = 0 | |
16 while 1 | |
17 if filereadable(argv(s:i)) | |
18 if s:i != 0 | |
19 sleep 3 | |
20 endif | |
21 break | |
22 endif | |
23 if isdirectory(argv(s:i)) | |
24 echomsg "Skipping directory " . argv(s:i) | |
25 elseif getftime(argv(s:i)) < 0 | |
26 echomsg "Skipping non-existing file " . argv(s:i) | |
27 else | |
28 echomsg "Skipping unreadable file " . argv(s:i) | |
29 endif | |
30 echo "\n" | |
31 let s:i = s:i + 1 | |
32 if s:i == argc() | |
33 quit | |
34 endif | |
35 next | |
36 endwhile | |
37 endif | |
38 | |
23305 | 39 " we don't want 'compatible' here |
40 if &cp | |
41 set nocp | |
42 endif | |
43 | |
44 " enable syntax highlighting if not done already | |
45 if !get(g:, 'syntax_on', 0) | |
46 syntax enable | |
47 endif | |
48 | |
7 | 49 set so=0 |
50 set hlsearch | |
51 set incsearch | |
52 nohlsearch | |
53 " Don't remember file names and positions | |
54 set viminfo= | |
55 set nows | |
56 " Inhibit screen updates while searching | |
57 let s:lz = &lz | |
58 set lz | |
59 | |
7245
8896150aba23
commit https://github.com/vim/vim/commit/e392eb41f8dfc01bd13634e534ac6b4d505326f4
Christian Brabandt <cb@256bit.org>
parents:
5908
diff
changeset
|
60 " Allow the user to define a function, which can set options specifically for |
8896150aba23
commit https://github.com/vim/vim/commit/e392eb41f8dfc01bd13634e534ac6b4d505326f4
Christian Brabandt <cb@256bit.org>
parents:
5908
diff
changeset
|
61 " this script. |
8896150aba23
commit https://github.com/vim/vim/commit/e392eb41f8dfc01bd13634e534ac6b4d505326f4
Christian Brabandt <cb@256bit.org>
parents:
5908
diff
changeset
|
62 if exists('*LessInitFunc') |
8896150aba23
commit https://github.com/vim/vim/commit/e392eb41f8dfc01bd13634e534ac6b4d505326f4
Christian Brabandt <cb@256bit.org>
parents:
5908
diff
changeset
|
63 call LessInitFunc() |
8896150aba23
commit https://github.com/vim/vim/commit/e392eb41f8dfc01bd13634e534ac6b4d505326f4
Christian Brabandt <cb@256bit.org>
parents:
5908
diff
changeset
|
64 endif |
8896150aba23
commit https://github.com/vim/vim/commit/e392eb41f8dfc01bd13634e534ac6b4d505326f4
Christian Brabandt <cb@256bit.org>
parents:
5908
diff
changeset
|
65 |
7 | 66 " Used after each command: put cursor at end and display position |
67 if &wrap | |
68 noremap <SID>L L0:redraw<CR>:file<CR> | |
69 au VimEnter * normal! L0 | |
70 else | |
71 noremap <SID>L Lg0:redraw<CR>:file<CR> | |
72 au VimEnter * normal! Lg0 | |
73 endif | |
74 | |
75 " When reading from stdin don't consider the file modified. | |
76 au VimEnter * set nomod | |
77 | |
20552 | 78 " Can't modify the text or write the file. |
79 set nomodifiable readonly | |
7 | 80 |
81 " Give help | |
82 noremap h :call <SID>Help()<CR> | |
83 map H h | |
84 fun! s:Help() | |
85 echo "<Space> One page forward b One page backward" | |
86 echo "d Half a page forward u Half a page backward" | |
87 echo "<Enter> One line forward k One line backward" | |
88 echo "G End of file g Start of file" | |
89 echo "N% percentage in file" | |
90 echo "\n" | |
91 echo "/pattern Search for pattern ?pattern Search backward for pattern" | |
92 echo "n next pattern match N Previous pattern match" | |
11347 | 93 if &foldmethod != "manual" |
94 echo "\n" | |
95 echo "zR open all folds zm increase fold level" | |
96 endif | |
7 | 97 echo "\n" |
98 echo ":n<Enter> Next file :p<Enter> Previous file" | |
99 echo "\n" | |
100 echo "q Quit v Edit file" | |
101 let i = input("Hit Enter to continue") | |
102 endfun | |
103 | |
104 " Scroll one page forward | |
105 noremap <script> <Space> :call <SID>NextPage()<CR><SID>L | |
106 map <C-V> <Space> | |
107 map f <Space> | |
108 map <C-F> <Space> | |
5908 | 109 map <PageDown> <Space> |
110 map <kPageDown> <Space> | |
111 map <S-Down> <Space> | |
11347 | 112 " If 'foldmethod' was changed keep the "z" commands, e.g. "zR" to open all |
113 " folds. | |
114 if &foldmethod == "manual" | |
115 map z <Space> | |
116 endif | |
7 | 117 map <Esc><Space> <Space> |
118 fun! s:NextPage() | |
119 if line(".") == line("$") | |
120 if argidx() + 1 >= argc() | |
3513 | 121 " Don't quit at the end of the last file |
122 return | |
7 | 123 endif |
124 next | |
125 1 | |
126 else | |
127 exe "normal! \<C-F>" | |
128 endif | |
129 endfun | |
130 | |
131 " Re-read file and page forward "tail -f" | |
132 map F :e<CR>G<SID>L:sleep 1<CR>F | |
133 | |
134 " Scroll half a page forward | |
135 noremap <script> d <C-D><SID>L | |
136 map <C-D> d | |
137 | |
138 " Scroll one line forward | |
139 noremap <script> <CR> <C-E><SID>L | |
140 map <C-N> <CR> | |
141 map e <CR> | |
142 map <C-E> <CR> | |
143 map j <CR> | |
144 map <C-J> <CR> | |
5908 | 145 map <Down> <CR> |
7 | 146 |
147 " Scroll one page backward | |
148 noremap <script> b <C-B><SID>L | |
149 map <C-B> b | |
5908 | 150 map <PageUp> b |
151 map <kPageUp> b | |
152 map <S-Up> b | |
7 | 153 map w b |
154 map <Esc>v b | |
155 | |
156 " Scroll half a page backward | |
157 noremap <script> u <C-U><SID>L | |
158 noremap <script> <C-U> <C-U><SID>L | |
159 | |
160 " Scroll one line backward | |
161 noremap <script> k <C-Y><SID>L | |
162 map y k | |
163 map <C-Y> k | |
164 map <C-P> k | |
165 map <C-K> k | |
5908 | 166 map <Up> k |
7 | 167 |
168 " Redraw | |
169 noremap <script> r <C-L><SID>L | |
170 noremap <script> <C-R> <C-L><SID>L | |
171 noremap <script> R <C-L><SID>L | |
172 | |
173 " Start of file | |
174 noremap <script> g gg<SID>L | |
175 map < g | |
176 map <Esc>< g | |
5908 | 177 map <Home> g |
178 map <kHome> g | |
7 | 179 |
180 " End of file | |
181 noremap <script> G G<SID>L | |
182 map > G | |
183 map <Esc>> G | |
5908 | 184 map <End> G |
185 map <kEnd> G | |
7 | 186 |
187 " Go to percentage | |
188 noremap <script> % %<SID>L | |
189 map p % | |
190 | |
191 " Search | |
192 noremap <script> / H$:call <SID>Forward()<CR>/ | |
193 if &wrap | |
194 noremap <script> ? H0:call <SID>Backward()<CR>? | |
195 else | |
196 noremap <script> ? Hg0:call <SID>Backward()<CR>? | |
197 endif | |
198 | |
199 fun! s:Forward() | |
200 " Searching forward | |
201 noremap <script> n H$nzt<SID>L | |
202 if &wrap | |
203 noremap <script> N H0Nzt<SID>L | |
204 else | |
205 noremap <script> N Hg0Nzt<SID>L | |
206 endif | |
1125 | 207 cnoremap <silent> <script> <CR> <CR>:cunmap <lt>CR><CR>zt<SID>L |
7 | 208 endfun |
209 | |
210 fun! s:Backward() | |
211 " Searching backward | |
212 if &wrap | |
213 noremap <script> n H0nzt<SID>L | |
214 else | |
215 noremap <script> n Hg0nzt<SID>L | |
216 endif | |
217 noremap <script> N H$Nzt<SID>L | |
1125 | 218 cnoremap <silent> <script> <CR> <CR>:cunmap <lt>CR><CR>zt<SID>L |
7 | 219 endfun |
220 | |
221 call s:Forward() | |
5908 | 222 cunmap <CR> |
7 | 223 |
224 " Quitting | |
225 noremap q :q<CR> | |
226 | |
227 " Switch to editing (switch off less mode) | |
228 map v :silent call <SID>End()<CR> | |
229 fun! s:End() | |
230 set ma | |
874 | 231 if exists('s:lz') |
7 | 232 let &lz = s:lz |
233 endif | |
234 unmap h | |
235 unmap H | |
236 unmap <Space> | |
237 unmap <C-V> | |
238 unmap f | |
239 unmap <C-F> | |
240 unmap z | |
241 unmap <Esc><Space> | |
242 unmap F | |
243 unmap d | |
244 unmap <C-D> | |
245 unmap <CR> | |
246 unmap <C-N> | |
247 unmap e | |
248 unmap <C-E> | |
249 unmap j | |
250 unmap <C-J> | |
251 unmap b | |
252 unmap <C-B> | |
253 unmap w | |
254 unmap <Esc>v | |
255 unmap u | |
256 unmap <C-U> | |
257 unmap k | |
258 unmap y | |
259 unmap <C-Y> | |
260 unmap <C-P> | |
261 unmap <C-K> | |
262 unmap r | |
263 unmap <C-R> | |
264 unmap R | |
265 unmap g | |
266 unmap < | |
267 unmap <Esc>< | |
268 unmap G | |
269 unmap > | |
270 unmap <Esc>> | |
271 unmap % | |
272 unmap p | |
273 unmap n | |
274 unmap N | |
275 unmap q | |
276 unmap v | |
277 unmap / | |
278 unmap ? | |
5908 | 279 unmap <Up> |
280 unmap <Down> | |
281 unmap <PageDown> | |
282 unmap <kPageDown> | |
283 unmap <PageUp> | |
284 unmap <kPageUp> | |
285 unmap <S-Down> | |
286 unmap <S-Up> | |
287 unmap <Home> | |
288 unmap <kHome> | |
289 unmap <End> | |
290 unmap <kEnd> | |
7 | 291 endfun |
292 | |
293 " vim: sw=2 |