Navigation Menu

Skip to content

Commit

Permalink
Update runtime files
Browse files Browse the repository at this point in the history
  • Loading branch information
brammool committed Nov 21, 2020
1 parent 2d71826 commit 4466ad6
Show file tree
Hide file tree
Showing 21 changed files with 203 additions and 112 deletions.
18 changes: 9 additions & 9 deletions README_VIM9.md
Expand Up @@ -159,18 +159,18 @@ thing I have been thinking of is assignments without ":let". I often
make that mistake (after writing JavaScript especially). I think it is
possible, if we make local variables shadow commands. That should be OK,
if you shadow a command you want to use, just rename the variable.
Using "let" and "const" to declare a variable, like in JavaScript and
Using "var" and "const" to declare a variable, like in JavaScript and
TypeScript, can work:


``` vim
def MyFunction(arg: number): number
let local = 1
let todo = arg
var local = 1
var todo = arg
const ADD = 88
while todo > 0
local += ADD
--todo
todo -= 1
endwhile
return local
enddef
Expand All @@ -192,7 +192,7 @@ function and export it:
``` vim
vim9script " Vim9 script syntax used here
let local = 'local variable is not exported, script-local'
var local = 'local variable is not exported, script-local'
export def MyFunction() " exported function
...
Expand Down Expand Up @@ -248,10 +248,10 @@ END
return luaeval('sum')
endfunc
def VimNew()
let sum = 0
def VimNew(): number
var sum = 0
for i in range(1, 2999999)
let sum += i
sum += i
endfor
return sum
enddef
Expand All @@ -277,7 +277,7 @@ echo 'Vim new: ' .. reltimestr(reltime(start))

``` vim
def VimNew(): number
let totallen = 0
var totallen = 0
for i in range(1, 100000)
setline(i, ' ' .. getline(i))
totallen += len(getline(i))
Expand Down
36 changes: 18 additions & 18 deletions runtime/autoload/ccomplete.vim
@@ -1,13 +1,13 @@
" Vim completion script
" Language: C
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2020 Apr 08
" Last Change: 2020 Nov 14

let s:cpo_save = &cpo
set cpo&vim

" This function is used for the 'omnifunc' option.
function! ccomplete#Complete(findstart, base)
func ccomplete#Complete(findstart, base)
if a:findstart
" Locate the start of the item, including ".", "->" and "[...]".
let line = getline('.')
Expand Down Expand Up @@ -244,7 +244,7 @@ function! ccomplete#Complete(findstart, base)
return map(res, 's:Tagline2item(v:val, brackets)')
endfunc

function! s:GetAddition(line, match, memarg, bracket)
func s:GetAddition(line, match, memarg, bracket)
" Guess if the item is an array.
if a:bracket && match(a:line, a:match . '\s*\[') > 0
return '['
Expand All @@ -260,13 +260,13 @@ function! s:GetAddition(line, match, memarg, bracket)
endif
endif
return ''
endfunction
endfunc

" Turn the tag info "val" into an item for completion.
" "val" is is an item in the list returned by taglist().
" If it is a variable we may add "." or "->". Don't do it for other types,
" such as a typedef, by not including the info that s:GetAddition() uses.
function! s:Tag2item(val)
func s:Tag2item(val)
let res = {'match': a:val['name']}

let res['extra'] = s:Tagcmd2extra(a:val['cmd'], a:val['name'], a:val['filename'])
Expand All @@ -289,10 +289,10 @@ function! s:Tag2item(val)
endif

return res
endfunction
endfunc

" Use all the items in dictionary for the "info" entry.
function! s:Dict2info(dict)
func s:Dict2info(dict)
let info = ''
for k in sort(keys(a:dict))
let info .= k . repeat(' ', 10 - len(k))
Expand All @@ -307,7 +307,7 @@ function! s:Dict2info(dict)
endfunc

" Parse a tag line and return a dictionary with items like taglist()
function! s:ParseTagline(line)
func s:ParseTagline(line)
let l = split(a:line, "\t")
let d = {}
if len(l) >= 3
Expand All @@ -334,12 +334,12 @@ function! s:ParseTagline(line)
endif

return d
endfunction
endfunc

" Turn a match item "val" into an item for completion.
" "val['match']" is the matching item.
" "val['tagline']" is the tagline in which the last part was found.
function! s:Tagline2item(val, brackets)
func s:Tagline2item(val, brackets)
let line = a:val['tagline']
let add = s:GetAddition(line, a:val['match'], [a:val], a:brackets == '')
let res = {'word': a:val['match'] . a:brackets . add }
Expand Down Expand Up @@ -377,10 +377,10 @@ function! s:Tagline2item(val, brackets)
let res['menu'] = s:Tagcmd2extra(s, a:val['match'], matchstr(line, '[^\t]*\t\zs[^\t]*\ze\t'))
endif
return res
endfunction
endfunc

" Turn a command from a tag line to something that is useful in the menu
function! s:Tagcmd2extra(cmd, name, fname)
func s:Tagcmd2extra(cmd, name, fname)
if a:cmd =~ '^/^'
" The command is a search command, useful to see what it is.
let x = matchstr(a:cmd, '^/^\s*\zs.*\ze$/')
Expand All @@ -395,13 +395,13 @@ function! s:Tagcmd2extra(cmd, name, fname)
let x = a:cmd . ' - ' . a:fname
endif
return x
endfunction
endfunc

" Find composing type in "lead" and match items[0] with it.
" Repeat this recursively for items[1], if it's there.
" When resolving typedefs "depth" is used to avoid infinite recursion.
" Return the list of matches.
function! s:Nextitem(lead, items, depth, all)
func s:Nextitem(lead, items, depth, all)

" Use the text up to the variable name and split it in tokens.
let tokens = split(a:lead, '\s\+\|\<')
Expand Down Expand Up @@ -485,15 +485,15 @@ function! s:Nextitem(lead, items, depth, all)
endfor

return res
endfunction
endfunc


" Search for members of structure "typename" in tags files.
" Return a list with resulting matches.
" Each match is a dictionary with "match" and "tagline" entries.
" When "all" is non-zero find all, otherwise just return 1 if there is any
" member.
function! s:StructMembers(typename, items, all)
func s:StructMembers(typename, items, all)
" Todo: What about local structures?
let fnames = join(map(tagfiles(), 'escape(v:val, " \\#%")'))
if fnames == ''
Expand Down Expand Up @@ -586,12 +586,12 @@ function! s:StructMembers(typename, items, all)

" Failed to find anything.
return []
endfunction
endfunc

" For matching members, find matches for following items.
" When "all" is non-zero find all, otherwise just return 1 if there is any
" member.
function! s:SearchMembers(matches, items, all)
func s:SearchMembers(matches, items, all)
let res = []
for i in range(len(a:matches))
let typename = ''
Expand Down
6 changes: 5 additions & 1 deletion runtime/doc/autocmd.txt
@@ -1,4 +1,4 @@
*autocmd.txt* For Vim version 8.2. Last change: 2020 Oct 26
*autocmd.txt* For Vim version 8.2. Last change: 2020 Nov 12


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -70,6 +70,10 @@ effects. Be careful not to destroy your text.
The special pattern <buffer> or <buffer=N> defines a buffer-local autocommand.
See |autocmd-buflocal|.

If the `:autocmd` is in Vim9 script then {cmd} will be executed as in Vim9
script. Thus this depends on where the autocmd is defined, not where it is
triggered.

Note: The ":autocmd" command can only be followed by another command when the
'|' appears before {cmd}. This works: >
:augroup mine | au! BufRead | augroup END
Expand Down
4 changes: 3 additions & 1 deletion runtime/doc/change.txt
@@ -1,4 +1,4 @@
*change.txt* For Vim version 8.2. Last change: 2020 Nov 03
*change.txt* For Vim version 8.2. Last change: 2020 Nov 21


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -1852,6 +1852,8 @@ found here: |sort()|, |uniq()|.
When /{pattern}/ is specified and there is no [r] flag
the text matched with {pattern} is skipped, so that
you sort on what comes after the match.
'ignorecase' applies to the pattern, but 'smartcase'
is not used.
Instead of the slash any non-letter can be used.
For example, to sort on the second comma-separated
field: >
Expand Down
25 changes: 16 additions & 9 deletions runtime/doc/eval.txt
@@ -1,4 +1,4 @@
*eval.txt* For Vim version 8.2. Last change: 2020 Nov 04
*eval.txt* For Vim version 8.2. Last change: 2020 Nov 11


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -3473,8 +3473,8 @@ byteidx({expr}, {nr}) *byteidx()*
Return byte index of the {nr}'th character in the string
{expr}. Use zero for the first character, it then returns
zero.
This function is only useful when there are multibyte
characters, otherwise the returned value is equal to {nr}.
If there are no multibyte characters the returned value is
equal to {nr}.
Composing characters are not counted separately, their byte
length is added to the preceding base character. See
|byteidxcomp()| below for counting composing characters
Expand Down Expand Up @@ -7433,7 +7433,9 @@ matchfuzzy({list}, {str} [, {dict}]) *matchfuzzy()*
matchfuzzypos({list}, {str} [, {dict}]) *matchfuzzypos()*
Same as |matchfuzzy()|, but returns the list of matched
strings and the list of character positions where characters
in {str} matches.
in {str} matches. You can use |byteidx()|to convert a
character position to a byte position.


If {str} matches multiple times in a string, then only the
positions for the best match is returned.
Expand Down Expand Up @@ -8728,11 +8730,16 @@ search({pattern} [, {flags} [, {stopline} [, {timeout} [, {skip}]]]])

'ignorecase', 'smartcase' and 'magic' are used.

When the 'z' flag is not given, searching always starts in
column zero and then matches before the cursor are skipped.
When the 'c' flag is present in 'cpo' the next search starts
after the match. Without the 'c' flag the next search starts
one column further.
When the 'z' flag is not given, forward searching always
starts in column zero and then matches before the cursor are
skipped. When the 'c' flag is present in 'cpo' the next
search starts after the match. Without the 'c' flag the next
search starts one column further. This matters for
overlapping matches.
When searching backwards and the 'z' flag is given then the
search starts in column zero, thus no match in the current
line will be found (unless wrapping around the end of the
file).

When the {stopline} argument is given then the search stops
after searching this line. This is useful to restrict the
Expand Down
13 changes: 8 additions & 5 deletions runtime/doc/map.txt
@@ -1,4 +1,4 @@
*map.txt* For Vim version 8.2. Last change: 2020 Nov 12
*map.txt* For Vim version 8.2. Last change: 2020 Nov 21


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -319,13 +319,16 @@ Example of using <Cmd> halfway Insert mode: >
nnoremap <F3> aText <Cmd>echo mode(1)<CR> Added<Esc>
Unlike <expr> mappings, there are no special restrictions on the <Cmd>
command: it is executed as if an (unrestricted) |autocmd| was invoked.
command: it is executed as if an (unrestricted) |autocommand| was invoked.

Note:
- Because <Cmd> avoids mode-changes it does not trigger |CmdlineEnter| and
|CmdlineLeave| events, because no user interaction is expected.
- For the same reason, |keycodes| like <C-R><C-W> are interpreted as plain,
unmapped keys.
- The command is not echo'ed, no need for <silent>.
- In Visual mode you can use `line('v')` and `col('v')` to get one end of the
Visual area, the cursor is at the other end.
- In Select mode, |:map| and |:vmap| command mappings are executed in
Visual mode. Use |:smap| to handle Select mode differently.

Expand Down Expand Up @@ -1238,9 +1241,9 @@ Otherwise, using "<SID>" outside of a script context is an error.

If you need to get the script number to use in a complicated script, you can
use this function: >
function s:SID()
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')
endfun
func s:ScriptNumber()
return matchstr(expand('<SID>'), '<SNR>\zs\d\+\ze_')
endfunc
The "<SNR>" will be shown when listing functions and mappings. This is useful
to find out what they are defined to.
Expand Down
4 changes: 2 additions & 2 deletions runtime/doc/popup.txt
@@ -1,4 +1,4 @@
*popup.txt* For Vim version 8.2. Last change: 2020 Oct 17
*popup.txt* For Vim version 8.2. Last change: 2020 Nov 07


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -101,7 +101,7 @@ CLOSING THE POPUP WINDOW *popup-close*

Normally the plugin that created the popup window is also in charge of closing
it. If somehow a popup hangs around, you can close all of them with: >
call popup_clear()
call popup_clear(1)
Some popups, such as notifications, close after a specified time. This can be
set with the "time" property on `popup_create()`.
Otherwise, a popup can be closed by clicking on the X in the top-right corner
Expand Down
2 changes: 1 addition & 1 deletion runtime/doc/syntax.txt
Expand Up @@ -3006,7 +3006,7 @@ vimrc file: >
(Adapted from the html.vim help text by Claudio Fleiner <claudio@fleiner.com>)


*ft-posix-synax* *ft-dash-syntax*
*ft-posix-syntax* *ft-dash-syntax*
SH *sh.vim* *ft-sh-syntax* *ft-bash-syntax* *ft-ksh-syntax*

This covers syntax highlighting for the older Unix (Bourne) sh, and newer
Expand Down
9 changes: 8 additions & 1 deletion runtime/doc/tags
Expand Up @@ -2125,6 +2125,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
:bad windows.txt /*:bad*
:badd windows.txt /*:badd*
:ball windows.txt /*:ball*
:balt windows.txt /*:balt*
:bar cmdline.txt /*:bar*
:bd windows.txt /*:bd*
:bdel windows.txt /*:bdel*
Expand Down Expand Up @@ -2724,6 +2725,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
:map-<unique> map.txt /*:map-<unique>*
:map-alt-keys map.txt /*:map-alt-keys*
:map-arguments map.txt /*:map-arguments*
:map-cmd map.txt /*:map-cmd*
:map-commands map.txt /*:map-commands*
:map-expression map.txt /*:map-expression*
:map-local map.txt /*:map-local*
Expand Down Expand Up @@ -3506,6 +3508,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
<CSI> intro.txt /*<CSI>*
<Char-> map.txt /*<Char->*
<Char> map.txt /*<Char>*
<Cmd> map.txt /*<Cmd>*
<CursorHold> autocmd.txt /*<CursorHold>*
<D- intro.txt /*<D-*
<D-c> os_mac.txt /*<D-c>*
Expand Down Expand Up @@ -3923,6 +3926,9 @@ E1112 eval.txt /*E1112*
E1113 eval.txt /*E1113*
E112 eval.txt /*E112*
E113 eval.txt /*E113*
E1135 map.txt /*E1135*
E1136 map.txt /*E1136*
E1137 map.txt /*E1137*
E114 eval.txt /*E114*
E115 eval.txt /*E115*
E116 eval.txt /*E116*
Expand Down Expand Up @@ -6549,7 +6555,7 @@ ft-php-syntax syntax.txt /*ft-php-syntax*
ft-php3-syntax syntax.txt /*ft-php3-syntax*
ft-phtml-syntax syntax.txt /*ft-phtml-syntax*
ft-plaintex-syntax syntax.txt /*ft-plaintex-syntax*
ft-posix-synax syntax.txt /*ft-posix-synax*
ft-posix-syntax syntax.txt /*ft-posix-syntax*
ft-postscr-syntax syntax.txt /*ft-postscr-syntax*
ft-ppwiz-syntax syntax.txt /*ft-ppwiz-syntax*
ft-printcap-syntax syntax.txt /*ft-printcap-syntax*
Expand Down Expand Up @@ -7745,6 +7751,7 @@ mapmode-s map.txt /*mapmode-s*
mapmode-t map.txt /*mapmode-t*
mapmode-v map.txt /*mapmode-v*
mapmode-x map.txt /*mapmode-x*
mapnew() eval.txt /*mapnew()*
mapping map.txt /*mapping*
mapping-functions usr_41.txt /*mapping-functions*
mapset() eval.txt /*mapset()*
Expand Down

0 comments on commit 4466ad6

Please sign in to comment.