Skip to content

Commit

Permalink
Update runtime files
Browse files Browse the repository at this point in the history
  • Loading branch information
brammool committed Jan 31, 2022
1 parent 424bcae commit c4573eb
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 69 deletions.
63 changes: 29 additions & 34 deletions runtime/autoload/ccomplete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ vim9script noclear
# Language: C
# Maintainer: Bram Moolenaar <Bram@vim.org>
# Rewritten in Vim9 script by github user lacygoill
# Last Change: 2021 Dec 27
# Last Change: 2022 Jan 31

var prepended: string
var grepCache: dict<list<dict<any>>>

# This function is used for the 'omnifunc' option.
def ccomplete#Complete(findstart: bool, abase: string): any # {{{1
export def Complete(findstart: bool, abase: string): any # {{{1
if findstart
# Locate the start of the item, including ".", "->" and "[...]".
var line: string = getline('.')
Expand Down Expand Up @@ -202,7 +202,7 @@ def ccomplete#Complete(findstart: bool, abase: string): any # {{{1
|| !v['static']
|| bufnr('%') == bufnr(v['filename']))

res = extendnew(res, tags->map((_, v: dict<any>) => Tag2item(v)))
res = res->extend(tags->map((_, v: dict<any>) => Tag2item(v)))
endif

if len(res) == 0
Expand All @@ -216,9 +216,9 @@ def ccomplete#Complete(findstart: bool, abase: string): any # {{{1
for i: number in len(diclist)->range()
# New ctags has the "typeref" field. Patched version has "typename".
if diclist[i]->has_key('typename')
res = extendnew(res, diclist[i]['typename']->StructMembers(items[1 :], true))
res = res->extend(diclist[i]['typename']->StructMembers(items[1 :], true))
elseif diclist[i]->has_key('typeref')
res = extendnew(res, diclist[i]['typeref']->StructMembers(items[1 :], true))
res = res->extend(diclist[i]['typeref']->StructMembers(items[1 :], true))
endif

# For a variable use the command, which must be a search pattern that
Expand All @@ -227,7 +227,7 @@ def ccomplete#Complete(findstart: bool, abase: string): any # {{{1
var line: string = diclist[i]['cmd']
if line[: 1] == '/^'
var col: number = line->charidx(match(line, '\<' .. items[0] .. '\>'))
res = extendnew(res, line[2 : col - 1]->Nextitem(items[1 :], 0, true))
res = res->extend(line[2 : col - 1]->Nextitem(items[1 :], 0, true))
endif
endif
endfor
Expand Down Expand Up @@ -256,11 +256,10 @@ def ccomplete#Complete(findstart: bool, abase: string): any # {{{1
enddef

def GetAddition( # {{{1
line: string,
match: string,
memarg: list<dict<any>>,
bracket: bool
): string
line: string,
match: string,
memarg: list<dict<any>>,
bracket: bool): string
# Guess if the item is an array.
if bracket && match(line, match .. '\s*\[') > 0
return '['
Expand Down Expand Up @@ -403,10 +402,9 @@ def Tagline2item(val: dict<any>, brackets: string): dict<string> # {{{1
enddef

def Tagcmd2extra( # {{{1
cmd: string,
name: string,
fname: string
): string
cmd: string,
name: string,
fname: string): string
# Turn a command from a tag line to something that is useful in the menu
var x: string
if cmd =~ '^/^'
Expand All @@ -427,11 +425,10 @@ def Tagcmd2extra( # {{{1
enddef

def Nextitem( # {{{1
lead: string,
items: list<string>,
depth: number,
all: bool
): list<dict<string>>
lead: string,
items: list<string>,
depth: number,
all: bool): list<dict<string>>
# 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.
Expand Down Expand Up @@ -473,11 +470,11 @@ def Nextitem( # {{{1

# New ctags has the "typeref" field. Patched version has "typename".
if item->has_key('typeref')
res = extendnew(res, item['typeref']->StructMembers(items, all))
res = res->extend(item['typeref']->StructMembers(items, all))
continue
endif
if item->has_key('typename')
res = extendnew(res, item['typename']->StructMembers(items, all))
res = res->extend(item['typename']->StructMembers(items, all))
continue
endif

Expand Down Expand Up @@ -511,11 +508,11 @@ def Nextitem( # {{{1
endif
endfor
if name != ''
res = extendnew(res, StructMembers(cmdtokens[0] .. ':' .. name, items, all))
res = res->extend(StructMembers(cmdtokens[0] .. ':' .. name, items, all))
endif
elseif depth < 10
# Could be "typedef other_T some_T".
res = extendnew(res, cmdtokens[0]->Nextitem(items, depth + 1, all))
res = res->extend(cmdtokens[0]->Nextitem(items, depth + 1, all))
endif
endif
endif
Expand All @@ -529,10 +526,9 @@ def Nextitem( # {{{1
enddef

def StructMembers( # {{{1
atypename: string,
items: list<string>,
all: bool
): list<dict<string>>
atypename: string,
items: list<string>,
all: bool): list<dict<string>>

# Search for members of structure "typename" in tags files.
# Return a list with resulting matches.
Expand Down Expand Up @@ -641,10 +637,9 @@ def StructMembers( # {{{1
enddef

def SearchMembers( # {{{1
matches: list<dict<any>>,
items: list<string>,
all: bool
): list<dict<string>>
matches: list<dict<any>>,
items: list<string>,
all: bool): list<dict<string>>

# For matching members, find matches for following items.
# When "all" is true find all, otherwise just return 1 if there is any member.
Expand Down Expand Up @@ -674,7 +669,7 @@ def SearchMembers( # {{{1
endif

if typename != ''
res = extendnew(res, StructMembers(typename, items, all))
res = res->extend(StructMembers(typename, items, all))
else
# Use the search command (the declaration itself).
var sb: number = line->match('\t\zs/^')
Expand All @@ -683,7 +678,7 @@ def SearchMembers( # {{{1
var e: number = line
->charidx(match(line, '\<' .. matches[i]['match'] .. '\>', sb))
if e > 0
res = extendnew(res, line[s : e - 1]->Nextitem(items, 0, all))
res = res->extend(line[s : e - 1]->Nextitem(items, 0, all))
endif
endif
endif
Expand Down
6 changes: 4 additions & 2 deletions runtime/autoload/dist/ft.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
" Vim functions for file type detection
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2022 Jan 28
" Last Change: 2022 Jan 31

" These functions are moved here from runtime/filetype.vim to make startup
" faster.
Expand Down Expand Up @@ -67,7 +67,7 @@ func dist#ft#FTasmsyntax()
endif
endfunc

func dist#ft#FTbas()
func dist#ft#FTbas(alt = '')
if exists("g:filetype_bas")
exe "setf " . g:filetype_bas
return
Expand All @@ -88,6 +88,8 @@ func dist#ft#FTbas()
setf qb64
elseif match(lines, '\cVB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)') > -1
setf vb
elseif a:alt != ''
exe 'setf ' .. a:alt
else
setf basic
endif
Expand Down
11 changes: 10 additions & 1 deletion runtime/doc/indent.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*indent.txt* For Vim version 8.2. Last change: 2019 Dec 07
*indent.txt* For Vim version 8.2. Last change: 2022 Jan 31


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -778,6 +778,15 @@ You can set the indent for the first line after <script> and <style>
"auto" auto indent (same indent as the blocktag)
"inc" auto indent + one indent step

You can set the indent for attributes after an open <tag line: >
:let g:html_indent_attribute = 1
<
VALUE MEANING ~
1 auto indent, one indent step more than <tag
2 auto indent, two indent steps (default)
> 2 auto indent, more indent steps

Many tags increase the indent for what follows per default (see "Add Indent
Tags" in the script). You can add further tags with: >
Expand Down
6 changes: 1 addition & 5 deletions runtime/doc/tags
Original file line number Diff line number Diff line change
Expand Up @@ -7779,7 +7779,6 @@ interactive-functions usr_41.txt /*interactive-functions*
interfaces-5.2 version5.txt /*interfaces-5.2*
internal-variables eval.txt /*internal-variables*
internal-wordlist spell.txt /*internal-wordlist*
internal_get_nv_cmdchar() builtin.txt /*internal_get_nv_cmdchar()*
internet intro.txt /*internet*
interrupt() builtin.txt /*interrupt()*
intro intro.txt /*intro*
Expand Down Expand Up @@ -9919,10 +9918,7 @@ test_feedinput() testing.txt /*test_feedinput()*
test_garbagecollect_now() testing.txt /*test_garbagecollect_now()*
test_garbagecollect_soon() testing.txt /*test_garbagecollect_soon()*
test_getvalue() testing.txt /*test_getvalue()*
test_gui_drop_files() testing.txt /*test_gui_drop_files()*
test_gui_mouse_event() testing.txt /*test_gui_mouse_event()*
test_gui_tabline_event() testing.txt /*test_gui_tabline_event()*
test_gui_tabmenu_event() testing.txt /*test_gui_tabmenu_event()*
test_gui_event() testing.txt /*test_gui_event()*
test_ignore_error() testing.txt /*test_ignore_error()*
test_null_blob() testing.txt /*test_null_blob()*
test_null_channel() testing.txt /*test_null_channel()*
Expand Down
11 changes: 4 additions & 7 deletions runtime/doc/todo.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*todo.txt* For Vim version 8.2. Last change: 2022 Jan 29
*todo.txt* For Vim version 8.2. Last change: 2022 Jan 31


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -38,19 +38,16 @@ browser use: https://github.com/vim/vim/issues/1234
*known-bugs*
-------------------- Known bugs and current work -----------------------

Only find a global function from Vim9 script when using "g:" ? #9637

Disallow defining a script#Func() in Vim9 script.

Cannot use command modifier for "import 'name.vim' as vim9"

range() returns list<number>, but it's OK if map() changes the type.
#9665 Change internal_func_ret_type() to return current and declared type?

When making a copy of a list or dict, do not keep the type? #9644
With deepcopy() all, with copy() this still fails:
var l: list<list<number>> = [[1], [2]]
l->copy()[0][0] = 'x'

Remove EBCDIC support?

Once Vim9 is stable:
- Add all the error numbers in a good place in documentation.
done until E1145
Expand Down
11 changes: 5 additions & 6 deletions runtime/doc/vim9.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*vim9.txt* For Vim version 8.2. Last change: 2022 Jan 29
*vim9.txt* For Vim version 8.2. Last change: 2022 Jan 30


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -372,13 +372,12 @@ Global variables must be prefixed with "g:", also at the script level. >
g:global = 'value'
var Funcref = g:ThatFunction
Global functions must be prefixed with "g:" when defining them, but can be
called without "g:". >
Global functions must be prefixed with "g:": >
vim9script
def g:GlobalFunc(): string
return 'text'
enddef
echo GlobalFunc()
echo g:GlobalFunc()
The "g:" prefix is not needed for auto-load functions.

*vim9-function-defined-later*
Expand Down Expand Up @@ -1334,10 +1333,10 @@ variable was declared in a legacy function.
When a type has been declared this is attached to a list or string. When
later some expression attempts to change the type an error will be given: >
var ll: list<number> = [1, 2, 3]
ll->extend('x') # Error, 'x' is not a number
ll->extend(['x']) # Error, 'x' is not a number
If the type is inferred then the type is allowed to change: >
[1, 2, 3]->extend('x') # result: [1, 2, 3, 'x']
[1, 2, 3]->extend(['x']) # result: [1, 2, 3, 'x']
Stricter type checking ~
Expand Down
4 changes: 2 additions & 2 deletions runtime/filetype.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2022 Jan 29
" Last Change: 2022 Jan 31

" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
Expand Down Expand Up @@ -2051,7 +2051,7 @@ au BufRead,BufNewFile *.hw,*.module,*.pkg
\ endif

" Visual Basic (also uses *.bas) or FORM
au BufNewFile,BufRead *.frm call dist#ft#FTVB("form")
au BufNewFile,BufRead *.frm call dist#ft#FTbas('form')

" SaxBasic is close to Visual Basic
au BufNewFile,BufRead *.sba setf vb
Expand Down
15 changes: 12 additions & 3 deletions runtime/indent/html.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
" Vim indent script for HTML
" Maintainer: Bram Moolenaar
" Original Author: Andy Wokula <anwoku@yahoo.de>
" Last Change: 2021 Jun 13
" Last Change: 2022 Jan 31
" Version: 1.0 "{{{
" Description: HTML indent script with cached state for faster indenting on a
" range of lines.
Expand Down Expand Up @@ -149,6 +149,15 @@ func HtmlIndent_CheckUserSettings()
let b:html_indent_line_limit = 200
endif
endif

if exists('b:html_indent_attribute')
let b:hi_attr_indent = b:html_indent_attribute
elseif exists('g:html_indent_attribute')
let b:hi_attr_indent = g:html_indent_attribute
else
let b:hi_attr_indent = 2
endif

endfunc "}}}

" Init Script Vars
Expand Down Expand Up @@ -946,11 +955,11 @@ func s:InsideTag(foundHtmlString)
let idx = match(text, '<' . s:tagname . '\s\+\zs\w')
endif
if idx == -1
" after just "<tag" indent two levels more
" after just "<tag" indent two levels more by default
let idx = match(text, '<' . s:tagname . '$')
if idx >= 0
call cursor(lnum, idx + 1)
return virtcol('.') - 1 + shiftwidth() * 2
return virtcol('.') - 1 + shiftwidth() * b:hi_attr_indent
endif
endif
if idx > 0
Expand Down
13 changes: 12 additions & 1 deletion runtime/indent/testdir/html.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
" vim: set ft=html sw=4 :
" vim: set ft=html sw=4 ts=8 :


" START_INDENT
Expand Down Expand Up @@ -41,6 +41,11 @@ dd text
dt text
</dt>
</dl>
<div
class="test"
style="color: yellow">
text
</div>

</body>
</html>
Expand All @@ -50,6 +55,7 @@ dt text
% START_INDENT
% INDENT_EXE let g:html_indent_style1 = "inc"
% INDENT_EXE let g:html_indent_script1 = "zero"
% INDENT_EXE let g:html_indent_attribute = 1
% INDENT_EXE call HtmlIndent_CheckUserSettings()
<html>
<body>
Expand All @@ -61,6 +67,11 @@ div#d2 { color: green; }
var v1 = "v1";
var v2 = "v2";
</script>
<div
class="test"
style="color: yellow">
text
</div>
</body>
</html>
% END_INDENT

0 comments on commit c4573eb

Please sign in to comment.