Update runtime files
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 5f1231c..5e1f61e 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -1,4 +1,4 @@
-*autocmd.txt* For Vim version 8.2. Last change: 2021 May 29
+*autocmd.txt* For Vim version 8.2. Last change: 2021 Jul 02
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -679,8 +679,10 @@
CursorMoved After the cursor was moved in Normal or Visual
mode. Also when the text of the cursor line
has been changed, e.g., with "x", "rx" or "p".
- Not triggered when there is typeahead or when
- an operator is pending.
+ Not triggered when there is typeahead, when
+ an operator is pending or when moving to
+ another window while remaining at the same
+ cursor position.
For an example see |match-parens|.
Note: This can not be skipped with
`:noautocmd`.
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 401f055..e5f9b46 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 8.2. Last change: 2021 Jun 23
+*eval.txt* For Vim version 8.2. Last change: 2021 Jul 01
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1588,7 +1588,17 @@
Handler called
Handler called
-Note how execute() is used to execute an Ex command. That's ugly though.
+Note that it is possible to cause memory to be used and not freed if the
+closure is referenced by the context it depends on: >
+ function Function()
+ let x = 0
+ let F = {-> x}
+ endfunction
+The closure uses "x" from the function scope, and "F" in that same scope
+refers to the closure. This cycle results in the memory not being freed.
+Recommendation: don't do this.
+
+Notice how execute() is used to execute an Ex command. That's ugly though.
In Vim9 script you can use a command block, see |inline-function|.
Lambda expressions have internal names like '<lambda>42'. If you get an error
@@ -1963,7 +1973,8 @@
Vim behaves like it is empty, there is no warning message.
*v:fname* *fname-variable*
-v:fname The file name set by 'includeexpr'. Empty otherwise.
+v:fname When evaluating 'includeexpr': the file name that was
+ detected. Empty otherwise.
*v:fname_in* *fname_in-variable*
v:fname_in The name of the input file. Valid while evaluating:
@@ -5803,7 +5814,7 @@
are zero.
When the position is after the text then "column" is the
- length of the text in bytes.
+ length of the text in bytes plus one.
If the mouse is over a popup window then that window is used.
@@ -8921,6 +8932,10 @@
The "curscol" value is where the cursor would be placed. For
a Tab it would be the same as "endcol", while for a double
width character it would be the same as "col".
+ The |conceal| feature is ignored here, the column numbers are
+ as if 'conceallevel' is zero. You can set the cursor to the
+ right position and use |screencol()| to get the value with
+ |conceal| taken into account.
Can also be used as a |method|: >
GetWinid()->screenpos(lnum, col)
@@ -11892,6 +11907,7 @@
digraphs Compiled with support for digraphs.
directx Compiled with support for DirectX and 'renderoptions'.
dnd Compiled with support for the "~ register |quote_~|.
+drop_file Compiled with |drop_file| support.
ebcdic Compiled on a machine with ebcdic character set.
emacs_tags Compiled with support for Emacs tags.
eval Compiled with expression evaluation support. Always
diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt
index c93a050..decc7bf 100644
--- a/runtime/doc/gui.txt
+++ b/runtime/doc/gui.txt
@@ -1,4 +1,4 @@
-*gui.txt* For Vim version 8.2. Last change: 2021 May 01
+*gui.txt* For Vim version 8.2. Last change: 2021 Jun 27
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -411,7 +411,8 @@
3.7 Drag and drop *drag-n-drop*
You can drag and drop one or more files into the Vim window, where they will
-be opened as if a |:drop| command was used.
+be opened as if a |:drop| command was used. You can check if this is
+supported with the *drop_file* feature: `has('drop_file')`.
If you hold down Shift while doing this, Vim changes to the first dropped
file's directory. If you hold Ctrl Vim will always split a new window for the
diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt
index d70b3e6..3e77ee7 100644
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -1,4 +1,4 @@
-*insert.txt* For Vim version 8.2. Last change: 2020 Oct 16
+*insert.txt* For Vim version 8.2. Last change: 2021 Jul 05
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1073,7 +1073,8 @@
The function must return a List with the matching words. These matches
usually include the "a:base" text. When there are no matches return an empty
-List.
+List. Note that the cursor may have moved since the first invocation, the
+text may have been changed.
In order to return more information than the matching words, return a Dict
that contains the List. The Dict can have these items:
diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt
index 9e13bdb..e344ec7 100644
--- a/runtime/doc/repeat.txt
+++ b/runtime/doc/repeat.txt
@@ -1,4 +1,4 @@
-*repeat.txt* For Vim version 8.2. Last change: 2021 Jun 14
+*repeat.txt* For Vim version 8.2. Last change: 2021 Jun 27
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -846,7 +846,7 @@
":cont", ":next", ":finish" (or shorter).
*vim9-debug*
When debugging a compiled :def function, "step" will stop before every
-executed line, not every ingle nstruction. Thus it works mostly like a not
+executed line, not every single instruction. Thus it works mostly like a not
compiled function. Access to local variables is limited you can use: >
echo varname
But not much else.
diff --git a/runtime/doc/sponsor.txt b/runtime/doc/sponsor.txt
index bb8cc29..c0a8c51 100644
--- a/runtime/doc/sponsor.txt
+++ b/runtime/doc/sponsor.txt
@@ -1,4 +1,4 @@
-*sponsor.txt* For Vim version 8.2. Last change: 2008 Jun 21
+*sponsor.txt* For Vim version 8.2. Last change: 2021 Jul 07
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -11,9 +11,8 @@
your appreciation for the work and motivate Bram and others to continue
working on Vim please send a donation.
-Since Bram is back to a paid job the money will now be used to help children
-in Uganda. See |uganda|. But at the same time donations increase Bram's
-motivation to keep working on Vim!
+Since Bram does not need the money it will be used to help children in Uganda,
+see |uganda|. Donations increase Bram's motivation to keep working on Vim!
For the most recent information about sponsoring look on the Vim web site:
@@ -74,19 +73,6 @@
amount you transferred if you want to vote for features and
show others you are a registered Vim user or sponsor.
-Cash Small amounts can be sent with ordinary mail. Put something
- around the money, so that it's not noticeable from the
- outside. Mention your e-mail address if you want to vote for
- features and show others you are a registered Vim user or
- sponsor.
-
-You can use this permanent address:
- Bram Moolenaar
- Finsterruetihof 1
- 8134 Adliswil
- Switzerland
-
-
QUESTIONS AND ANSWERS *sponsor-faq* *register-faq*
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index da4bf8e..e8ff255 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -1,4 +1,4 @@
-*syntax.txt* For Vim version 8.2. Last change: 2021 Jun 22
+*syntax.txt* For Vim version 8.2. Last change: 2021 Jul 02
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1420,11 +1420,17 @@
auto-detecting the *.e and *.E file extensions as Euphoria file type,
add the following line to your startup file: >
- :let filetype_euphoria = "euphoria3"
+ :let g:filetype_euphoria = "euphoria3"
< or >
- :let filetype_euphoria = "euphoria4"
+ :let g:filetype_euphoria = "euphoria4"
+
+Elixir and Euphoria share the *.ex file extension. If the filetype is
+specifically set as Euphoria with the g:filetype_euphoria variable, or the
+file is determined to be Euphoria based on keywords in the file, then the
+filetype will be set as Euphoria. Otherwise, the filetype will default to
+Elixir.
ERLANG *erlang.vim* *ft-erlang-syntax*
@@ -1442,6 +1448,22 @@
:let g:erlang_highlight_special_atoms = 1
+ELIXIR *elixir.vim* *ft-elixir-syntax*
+
+Elixir is a dynamic, functional language for building scalable and maintainable
+applications.
+
+The following file extensions are auto-detected as Elixir file types:
+
+ *.ex, *.exs, *.eex, *.leex, *.lock
+
+Elixir and Euphoria share the *.ex file extension. If the filetype is
+specifically set as Euphoria with the g:filetype_euphoria variable, or the
+file is determined to be Euphoria based on keywords in the file, then the
+filetype will be set as Euphoria. Otherwise, the filetype will default to
+Elixir.
+
+
FLEXWIKI *flexwiki.vim* *ft-flexwiki-syntax*
FlexWiki is an ASP.NET-based wiki package available at http://www.flexwiki.com
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 2d3bb37..9c99429 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -6190,6 +6190,8 @@
dos-colors os_dos.txt /*dos-colors*
dos-file-formats os_dos.txt /*dos-file-formats*
dos-locations os_dos.txt /*dos-locations*
+dos-powershell os_dos.txt /*dos-powershell*
+dos-pwsh os_dos.txt /*dos-pwsh*
dos-shell os_dos.txt /*dos-shell*
dos-standard-mappings os_dos.txt /*dos-standard-mappings*
dos-temp-files os_dos.txt /*dos-temp-files*
@@ -6202,6 +6204,7 @@
drag-n-drop gui.txt /*drag-n-drop*
drag-n-drop-win32 gui_w32.txt /*drag-n-drop-win32*
drag-status-line term.txt /*drag-status-line*
+drop_file gui.txt /*drop_file*
dtd.vim syntax.txt /*dtd.vim*
dtd2vim insert.txt /*dtd2vim*
dying-variable eval.txt /*dying-variable*
@@ -6222,6 +6225,7 @@
efm-entries quickfix.txt /*efm-entries*
efm-ignore quickfix.txt /*efm-ignore*
eiffel.vim syntax.txt /*eiffel.vim*
+elixir.vim syntax.txt /*elixir.vim*
emacs-keys tips.txt /*emacs-keys*
emacs-tags tagsrch.txt /*emacs-tags*
emacs_tags tagsrch.txt /*emacs_tags*
@@ -6571,6 +6575,7 @@
ft-dosbatch-syntax syntax.txt /*ft-dosbatch-syntax*
ft-dtd-syntax syntax.txt /*ft-dtd-syntax*
ft-eiffel-syntax syntax.txt /*ft-eiffel-syntax*
+ft-elixir-syntax syntax.txt /*ft-elixir-syntax*
ft-erlang-syntax syntax.txt /*ft-erlang-syntax*
ft-euphoria-syntax syntax.txt /*ft-euphoria-syntax*
ft-flexwiki-syntax syntax.txt /*ft-flexwiki-syntax*
diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt
index 8dc6dc3..be2896e 100644
--- a/runtime/doc/testing.txt
+++ b/runtime/doc/testing.txt
@@ -1,4 +1,4 @@
-*testing.txt* For Vim version 8.2. Last change: 2021 Jun 23
+*testing.txt* For Vim version 8.2. Last change: 2021 Jul 07
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -82,7 +82,8 @@
*test_gui_drop_files()*
test_gui_drop_files({list}, {row}, {col}, {mods})
Drop one or more files in {list} in the window at {row}, {col}.
- This function only works when the GUI is running.
+ This function only works when the GUI is running and the
+ |drag-n-drop| feature is present.
The supported values for {mods} are:
0x4 Shift
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index 0735598..655b74a 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt* For Vim version 8.2. Last change: 2021 Jun 26
+*todo.txt* For Vim version 8.2. Last change: 2021 Jul 05
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -38,11 +38,9 @@
*known-bugs*
-------------------- Known bugs and current work -----------------------
-Memory eaten up by function returning a closure. #8439
-Circular reference. Should garbage collector find unused local variables?
-
Vim9 - Make everything work:
- possible leak in test_vim9_builtin ?
+- Make "for _ in range()" work, do not store the value in a var.
- use CheckLegacyAndVim9Success(lines) in many more places
- compile get_lambda_tv() in popup_add_timeout()
- For builtin functions using tv_get_string*() use check_for_string() to be
@@ -248,6 +246,10 @@
Mapping with partial match not executed properly in GTK. (Ingo Karkat, #7082)
+Problem that a previous silent ":throw" causes a following try/catch not to
+work. (ZyX, 2013 Sep 28) With examples: (Malcolm Rowe, 2015 Dec 24)
+Also see #8487 for an example.
+
Patch for Template string: #4634
Have another look at the implementation.
@@ -1420,9 +1422,6 @@
interfaces: https://github.com/k-takata/vim/tree/chrisbra-appveyor-build
result: https://ci.appveyor.com/project/k-takata/vim/history
-Problem that a previous silent ":throw" causes a following try/catch not to
-work. (ZyX, 2013 Sep 28) With examples: (Malcolm Rowe, 2015 Dec 24)
-
Problem using ":try" inside ":execute". (ZyX, 2013 Sep 15)
Patch to make tests pass with EBCDIC. (Owen Leibman, 2016 Apr 10)
diff --git a/runtime/doc/version6.txt b/runtime/doc/version6.txt
index abf1544..22a57aa 100644
--- a/runtime/doc/version6.txt
+++ b/runtime/doc/version6.txt
@@ -2696,7 +2696,7 @@
double-wide character.
- Overstrike mode for the cmdline replaced only the first byte of a multibyte
character.
-- The cursor in Replace mode (also in the cmdline) was to small on a
+- The cursor in Replace mode (also in the cmdline) was too small on a
double-wide character.
- When a multibyte character contained a 0x80 byte, it didn't work (was using
a CSI byte instead). (Muraoka Taro)
@@ -3546,7 +3546,7 @@
Added Russian keymap for yawerty keyboard.
Added an explanation of using the vimrc file in the tutor.
-Changed tutor.vim to get the right encoding for the Taiwainese tutor.
+Changed tutor.vim to get the right encoding for the Taiwanese tutor.
Added Russian tutor. (Andrey Kiselev)
Added Polish tutor. (Mikolaj Machowski)
diff --git a/runtime/doc/version8.txt b/runtime/doc/version8.txt
index 313c388..9ed74cc 100644
--- a/runtime/doc/version8.txt
+++ b/runtime/doc/version8.txt
@@ -35504,7 +35504,7 @@
src/testdir/test_xxd.vim
Patch 8.1.1545
-Problem: When the screen is to small there is no message about that.
+Problem: When the screen is too small there is no message about that.
(Daniel Hahler)
Solution: Do not use :cquit. (closes #4534)
Files: src/testdir/runtest.vim
@@ -41104,7 +41104,7 @@
Patch 8.1.2419
Problem: With a long file name the hit-enter prompt appears. (J. Lewis
Muir)
-Solution: When checking for text to wrap don't do this when outputing a CR.
+Solution: When checking for text to wrap don't do this when outputting a CR.
Files: src/message.c, src/testdir/test_display.vim,
src/testdir/dumps/Test_long_file_name_1.dump
diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt
index e8d97a9..8b91cdd 100644
--- a/runtime/doc/vim9.txt
+++ b/runtime/doc/vim9.txt
@@ -1,4 +1,4 @@
-*vim9.txt* For Vim version 8.2. Last change: 2021 Jun 25
+*vim9.txt* For Vim version 8.2. Last change: 2021 Jul 07
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -442,7 +442,8 @@
var Funcref = MyFunction
When using `function()` the resulting type is "func", a function with any
-number of arguments and any return type. The function can be defined later.
+number of arguments and any return type (including void). The function can be
+defined later.
Lambda using => instead of -> ~
@@ -579,13 +580,18 @@
restored after the :enddef.
In places where line continuation with a backslash is still needed, such as
-splitting up a long Ex command, comments can start with #\ instead of "\: >
- syn region Text
+splitting up a long Ex command, comments can start with '#\ ': >
+ syn region Text
\ start='foo'
#\ comment
\ end='bar'
-
-< *E1050*
+Like with legacy script '"\ ' is used. This is also needed when line
+continuation is used without a backslash and a line starts with a bar: >
+ au CursorHold * echom 'BEFORE bar'
+ #\ some comment
+ | echom 'AFTER bar'
+<
+ *E1050*
To make it possible for the operator at the start of the line to be
recognized, it is required to put a colon before a range. This example will
add "start" and print: >
@@ -1084,10 +1090,8 @@
Not supported yet:
tuple<a: {type}, b: {type}, ...>
-These types can be used in declarations, but no value will have this type:
- {type}|{type} {not implemented yet}
- void
- any
+These types can be used in declarations, but no simple value will actually
+have the "void" type.
There is no array type, use list<{type}> instead. For a list constant an
efficient implementation is used that avoids allocating lot of small pieces of
@@ -1096,8 +1100,16 @@
A partial and function can be declared in more or less specific ways:
func any kind of function reference, no type
checking for arguments or return value
+func: void any number and type of arguments, no return
+ value
func: {type} any number and type of arguments with specific
return type
+
+func() function with no argument, does not return a
+ value
+func(): void same
+func(): {type} function with no argument and return type
+
func({type}) function with argument type, does not return
a value
func({type}): {type} function with argument type and return type
@@ -1186,6 +1198,18 @@
['a', 'b', 'c'] list<string>
[1, 'x', 3] list<any>
+The common type of function references, if they do not all have the same
+number of arguments, uses "(...)" to indicate the number of arguments is not
+specified. For example: >
+ def Foo(x: bool)
+ enddef
+ def Bar(x: bool, y: bool)
+ enddef
+ var funclist = [Foo, Bar]
+ echo funclist->typename()
+Results in:
+ list<func(...)>
+
For script-local variables in Vim9 script the type is checked, also when the
variable was declared in a legacy function.
@@ -1202,16 +1226,24 @@
before, if the value used matches the expected type. There will sometimes be
an error, thus breaking backwards compatibility. For example:
- Using a number other than 0 or 1 where a boolean is expected. *E1023*
-- Using a string value when setting a number options.
+- Using a string value when setting a number option.
- Using a number where a string is expected. *E1024*
One consequence is that the item type of a list or dict given to map() must
not change. This will give an error in Vim9 script: >
- map([1, 2, 3], (i, v) => 'item ' .. i)
+ vim9 echo map([1, 2, 3], (i, v) => 'item ' .. i)
E1012: Type mismatch; expected number but got string
-Instead use |mapnew()|. If the item type was determined to be "any" it can
-change to a more specific type. E.g. when a list of mixed types gets changed
-to a list of numbers.
+Instead use |mapnew(): >
+ vim9 echo mapnew([1, 2, 3], (i, v) => 'item ' .. i)
+ ['item 0', 'item 1', 'item 2']
+
+If the item type was determined to be "any" it can change to a more specific
+type. E.g. when a list of mixed types gets changed to a list of numbers: >
+ var mylist = [1, 2.0, '3']
+ # typename(mylist) == "list<any>"
+ map(mylist, (i, v) => 'item ' .. i)
+ # typename(mylist) == "list<string>", no error
+
Same for |extend()|, use |extendnew()| instead, and for |flatten()|, use
|flattennew()| instead.
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 2cb3f0b..13f8e94 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2021 Jun 13
+" Last Change: 2021 Jul 03
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
diff --git a/runtime/ftplugin/jsonc.vim b/runtime/ftplugin/jsonc.vim
new file mode 100644
index 0000000..90d52cd
--- /dev/null
+++ b/runtime/ftplugin/jsonc.vim
@@ -0,0 +1,27 @@
+" Vim filetype plugin
+" Language: JSONC (JSON with Comments)
+" Original Author: Izhak Jakov <izhak724@gmail.com>
+" Acknowledgement: Based off of vim-jsonc maintained by Kevin Locke <kevin@kevinlocke.name>
+" https://github.com/kevinoid/vim-jsonc
+" License: MIT
+" Last Change: 2021-07-01
+
+runtime! ftplugin/json.vim
+
+if exists('b:did_ftplugin_jsonc')
+ finish
+else
+ let b:did_ftplugin_jsonc = 1
+endif
+
+" A list of commands that undo buffer local changes made below.
+let s:undo_ftplugin = []
+
+" Set comment (formatting) related options. {{{1
+setlocal commentstring=//%s comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
+call add(s:undo_ftplugin, 'commentstring< comments<')
+
+" Let Vim know how to disable the plug-in.
+call map(s:undo_ftplugin, "'execute ' . string(v:val)")
+let b:undo_ftplugin = join(s:undo_ftplugin, ' | ')
+unlet s:undo_ftplugin
diff --git a/runtime/indent/jsonc.vim b/runtime/indent/jsonc.vim
new file mode 100644
index 0000000..bf8e501
--- /dev/null
+++ b/runtime/indent/jsonc.vim
@@ -0,0 +1,189 @@
+" Vim indent file
+" Language: JSONC (JSON with Comments)
+" Original Author: Izhak Jakov <izhak724@gmail.com>
+" Acknowledgement: Based off of vim-json maintained by Eli Parra <eli@elzr.com>
+" https://github.com/elzr/vim-json
+" Last Change: 2021-07-01
+
+" 0. Initialization {{{1
+" =================
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal nosmartindent
+
+" Now, set up our indentation expression and keys that trigger it.
+setlocal indentexpr=GetJSONCIndent()
+setlocal indentkeys=0{,0},0),0[,0],!^F,o,O,e
+
+" Only define the function once.
+if exists("*GetJSONCIndent")
+ finish
+endif
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+" 1. Variables {{{1
+" ============
+
+let s:line_term = '\s*\%(\%(\/\/\).*\)\=$'
+" Regex that defines blocks.
+let s:block_regex = '\%({\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s:line_term
+
+" 2. Auxiliary Functions {{{1
+" ======================
+
+" Check if the character at lnum:col is inside a string.
+function s:IsInString(lnum, col)
+ return synIDattr(synID(a:lnum, a:col, 1), 'name') == 'jsonString'
+endfunction
+
+" Find line above 'lnum' that isn't empty, or in a string.
+function s:PrevNonBlankNonString(lnum)
+ let lnum = prevnonblank(a:lnum)
+ while lnum > 0
+ " If the line isn't empty or in a string, end search.
+ let line = getline(lnum)
+ if !(s:IsInString(lnum, 1) && s:IsInString(lnum, strlen(line)))
+ break
+ endif
+ let lnum = prevnonblank(lnum - 1)
+ endwhile
+ return lnum
+endfunction
+
+" Check if line 'lnum' has more opening brackets than closing ones.
+function s:LineHasOpeningBrackets(lnum)
+ let open_0 = 0
+ let open_2 = 0
+ let open_4 = 0
+ let line = getline(a:lnum)
+ let pos = match(line, '[][(){}]', 0)
+ while pos != -1
+ let idx = stridx('(){}[]', line[pos])
+ if idx % 2 == 0
+ let open_{idx} = open_{idx} + 1
+ else
+ let open_{idx - 1} = open_{idx - 1} - 1
+ endif
+ let pos = match(line, '[][(){}]', pos + 1)
+ endwhile
+ return (open_0 > 0) . (open_2 > 0) . (open_4 > 0)
+endfunction
+
+function s:Match(lnum, regex)
+ let col = match(getline(a:lnum), a:regex) + 1
+ return col > 0 && !s:IsInString(a:lnum, col) ? col : 0
+endfunction
+
+" 3. GetJSONCIndent Function {{{1
+" =========================
+
+function GetJSONCIndent()
+ if !exists("s:inside_comment")
+ let s:inside_comment = 0
+ endif
+
+ " 3.1. Setup {{{2
+ " ----------
+
+ " Set up variables for restoring position in file. Could use v:lnum here.
+ let vcol = col('.')
+
+ " 3.2. Work on the current line {{{2
+ " -----------------------------
+
+
+ " Get the current line.
+ let line = getline(v:lnum)
+ let ind = -1
+ if s:inside_comment == 0
+ " TODO iterate through all the matches in a line
+ let col = matchend(line, '\/\*')
+ if col > 0 && !s:IsInString(v:lnum, col)
+ let s:inside_comment = 1
+ endif
+ endif
+ " If we're in the middle of a comment
+ if s:inside_comment == 1
+ let col = matchend(line, '\*\/')
+ if col > 0 && !s:IsInString(v:lnum, col)
+ let s:inside_comment = 0
+ endif
+ return ind
+ endif
+ if line =~ '^\s*//'
+ return ind
+ endif
+
+ " If we got a closing bracket on an empty line, find its match and indent
+ " according to it.
+ let col = matchend(line, '^\s*[]}]')
+
+ if col > 0 && !s:IsInString(v:lnum, col)
+ call cursor(v:lnum, col)
+ let bs = strpart('{}[]', stridx('}]', line[col - 1]) * 2, 2)
+
+ let pairstart = escape(bs[0], '[')
+ let pairend = escape(bs[1], ']')
+ let pairline = searchpair(pairstart, '', pairend, 'bW')
+
+ if pairline > 0
+ let ind = indent(pairline)
+ else
+ let ind = virtcol('.') - 1
+ endif
+
+ return ind
+ endif
+
+ " If we are in a multi-line string, don't do anything to it.
+ if s:IsInString(v:lnum, matchend(line, '^\s*') + 1)
+ return indent('.')
+ endif
+
+ " 3.3. Work on the previous line. {{{2
+ " -------------------------------
+
+ let lnum = prevnonblank(v:lnum - 1)
+
+ if lnum == 0
+ return 0
+ endif
+
+ " Set up variables for current line.
+ let line = getline(lnum)
+ let ind = indent(lnum)
+
+ " If the previous line ended with a block opening, add a level of indent.
+ " if s:Match(lnum, s:block_regex)
+ " return indent(lnum) + shiftwidth()
+ " endif
+
+ " If the previous line contained an opening bracket, and we are still in it,
+ " add indent depending on the bracket type.
+ if line =~ '[[({]'
+ let counts = s:LineHasOpeningBrackets(lnum)
+ if counts[0] == '1' || counts[1] == '1' || counts[2] == '1'
+ return ind + shiftwidth()
+ else
+ call cursor(v:lnum, vcol)
+ end
+ endif
+
+ " }}}2
+
+ return ind
+endfunction
+
+" }}}1
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
+" vim:set sw=2 sts=2 ts=8 noet:
diff --git a/runtime/indent/pascal.vim b/runtime/indent/pascal.vim
index c7955d6..1f39fd1 100644
--- a/runtime/indent/pascal.vim
+++ b/runtime/indent/pascal.vim
@@ -2,7 +2,7 @@
" Language: Pascal
" Maintainer: Neil Carter <n.carter@swansea.ac.uk>
" Created: 2004 Jul 13
-" Last Change: 2017 Jun 13
+" Last Change: 2021 Jul 01
"
" This is version 2.0, a complete rewrite.
"
@@ -20,6 +20,8 @@
setlocal indentkeys+==program,==function,==procedure,==object,==private
setlocal indentkeys+==record,==if,==else,==case
+let b:undo_indent = "setl indentkeys< indentexpr<"
+
if exists("*GetPascalIndent")
finish
endif
diff --git a/runtime/syntax/go.vim b/runtime/syntax/go.vim
index e78f8cf..1439487 100644
--- a/runtime/syntax/go.vim
+++ b/runtime/syntax/go.vim
@@ -1,58 +1,109 @@
-" Vim syntax file
-" Language: Go
-" Maintainer: David Barnett (https://github.com/google/vim-ft-go)
-" Last Change: 2014 Aug 16
-
-" Options:
-" There are some options for customizing the highlighting; the recommended
-" settings are the default values, but you can write:
-" let OPTION_NAME = 0
-" in your ~/.vimrc file to disable particular options. You can also write:
-" let OPTION_NAME = 1
-" to enable particular options. At present, all options default to on.
+" Copyright 2009 The Go Authors. All rights reserved.
+" Use of this source code is governed by a BSD-style
+" license that can be found in the LICENSE file.
"
-" - g:go_highlight_array_whitespace_error
-" Highlights white space after "[]".
-" - g:go_highlight_chan_whitespace_error
-" Highlights white space around the communications operator that don't
-" follow the standard style.
-" - g:go_highlight_extra_types
-" Highlights commonly used library types (io.Reader, etc.).
-" - g:go_highlight_space_tab_error
-" Highlights instances of tabs following spaces.
-" - g:go_highlight_trailing_whitespace_error
-" Highlights trailing white space.
+" go.vim: Vim syntax file for Go.
+" Language: Go
+" Maintainer: Billie Cleek <bhcleek@gmail.com>
+" Latest Revision: 2021-06-26
+" License: BSD-style. See LICENSE file in source repository.
+" Repository: https://github.com/fatih/vim-go
" Quit when a (custom) syntax file was already loaded
-if exists('b:current_syntax')
+if exists("b:current_syntax")
finish
endif
-if !exists('g:go_highlight_array_whitespace_error')
- let g:go_highlight_array_whitespace_error = 1
-endif
-if !exists('g:go_highlight_chan_whitespace_error')
- let g:go_highlight_chan_whitespace_error = 1
-endif
-if !exists('g:go_highlight_extra_types')
- let g:go_highlight_extra_types = 1
-endif
-if !exists('g:go_highlight_space_tab_error')
- let g:go_highlight_space_tab_error = 1
-endif
-if !exists('g:go_highlight_trailing_whitespace_error')
- let g:go_highlight_trailing_whitespace_error = 1
-endif
+let s:keepcpo = &cpo
+set cpo&vim
+
+function! s:FoldEnable(...) abort
+ if a:0 > 0
+ return index(s:FoldEnable(), a:1) > -1
+ endif
+ return get(g:, 'go_fold_enable', ['block', 'import', 'varconst', 'package_comment'])
+endfunction
+
+function! s:HighlightArrayWhitespaceError() abort
+ return get(g:, 'go_highlight_array_whitespace_error', 0)
+endfunction
+
+function! s:HighlightChanWhitespaceError() abort
+ return get(g:, 'go_highlight_chan_whitespace_error', 0)
+endfunction
+
+function! s:HighlightExtraTypes() abort
+ return get(g:, 'go_highlight_extra_types', 0)
+endfunction
+
+function! s:HighlightSpaceTabError() abort
+ return get(g:, 'go_highlight_space_tab_error', 0)
+endfunction
+
+function! s:HighlightTrailingWhitespaceError() abort
+ return get(g:, 'go_highlight_trailing_whitespace_error', 0)
+endfunction
+
+function! s:HighlightOperators() abort
+ return get(g:, 'go_highlight_operators', 0)
+endfunction
+
+function! s:HighlightFunctions() abort
+ return get(g:, 'go_highlight_functions', 0)
+endfunction
+
+function! s:HighlightFunctionParameters() abort
+ return get(g:, 'go_highlight_function_parameters', 0)
+endfunction
+
+function! s:HighlightFunctionCalls() abort
+ return get(g:, 'go_highlight_function_calls', 0)
+endfunction
+
+function! s:HighlightFields() abort
+ return get(g:, 'go_highlight_fields', 0)
+endfunction
+
+function! s:HighlightTypes() abort
+ return get(g:, 'go_highlight_types', 0)
+endfunction
+
+function! s:HighlightBuildConstraints() abort
+ return get(g:, 'go_highlight_build_constraints', 0)
+endfunction
+
+function! s:HighlightStringSpellcheck() abort
+ return get(g:, 'go_highlight_string_spellcheck', 1)
+endfunction
+
+function! s:HighlightFormatStrings() abort
+ return get(g:, 'go_highlight_format_strings', 1)
+endfunction
+
+function! s:HighlightGenerateTags() abort
+ return get(g:, 'go_highlight_generate_tags', 0)
+endfunction
+
+function! s:HighlightVariableAssignments() abort
+ return get(g:, 'go_highlight_variable_assignments', 0)
+endfunction
+
+function! s:HighlightVariableDeclarations() abort
+ return get(g:, 'go_highlight_variable_declarations', 0)
+endfunction
syn case match
-syn keyword goDirective package import
-syn keyword goDeclaration var const type
-syn keyword goDeclType struct interface
+syn keyword goPackage package
+syn keyword goImport import contained
+syn keyword goVar var contained
+syn keyword goConst const contained
-hi def link goDirective Statement
+hi def link goPackage Statement
+hi def link goImport Statement
+hi def link goVar Keyword
+hi def link goConst Keyword
hi def link goDeclaration Keyword
-hi def link goDeclType Keyword
" Keywords within functions
syn keyword goStatement defer go goto return break continue fallthrough
@@ -78,28 +129,38 @@
hi def link goFloats Type
hi def link goComplexes Type
-" Treat func specially: it's a declaration at the start of a line, but a type
-" elsewhere. Order matters here.
-syn match goType /\<func\>/
-syn match goDeclaration /^func\>/
-
" Predefined functions and values
-syn keyword goBuiltins append cap close complex copy delete imag len
-syn keyword goBuiltins make new panic print println real recover
-syn keyword goConstants iota true false nil
+syn keyword goBuiltins append cap close complex copy delete imag len
+syn keyword goBuiltins make new panic print println real recover
+syn keyword goBoolean true false
+syn keyword goPredefinedIdentifiers nil iota
-hi def link goBuiltins Keyword
-hi def link goConstants Keyword
+hi def link goBuiltins Identifier
+hi def link goBoolean Boolean
+hi def link goPredefinedIdentifiers goBoolean
" Comments; their contents
syn keyword goTodo contained TODO FIXME XXX BUG
syn cluster goCommentGroup contains=goTodo
-syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell
-syn region goComment start="//" end="$" contains=@goCommentGroup,@Spell
+
+syn region goComment start="//" end="$" contains=goGenerate,@goCommentGroup,@Spell
+if s:FoldEnable('comment')
+ syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell fold
+ syn match goComment "\v(^\s*//.*\n)+" contains=goGenerate,@goCommentGroup,@Spell fold
+else
+ syn region goComment start="/\*" end="\*/" contains=@goCommentGroup,@Spell
+endif
hi def link goComment Comment
hi def link goTodo Todo
+if s:HighlightGenerateTags()
+ syn match goGenerateVariables contained /\%(\$GOARCH\|\$GOOS\|\$GOFILE\|\$GOLINE\|\$GOPACKAGE\|\$DOLLAR\)\>/
+ syn region goGenerate start="^\s*//go:generate" end="$" contains=goGenerateVariables
+ hi def link goGenerate PreProc
+ hi def link goGenerateVariables Special
+endif
+
" Go escapes
syn match goEscapeOctal display contained "\\[0-7]\{3}"
syn match goEscapeC display contained +\\[abfnrtv\\'"]+
@@ -118,8 +179,30 @@
" Strings and their contents
syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError
-syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup
-syn region goRawString start=+`+ end=+`+
+if s:HighlightStringSpellcheck()
+ syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup,@Spell
+ syn region goRawString start=+`+ end=+`+ contains=@Spell
+else
+ syn region goString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup
+ syn region goRawString start=+`+ end=+`+
+endif
+
+if s:HighlightFormatStrings()
+ " [n] notation is valid for specifying explicit argument indexes
+ " 1. Match a literal % not preceded by a %.
+ " 2. Match any number of -, #, 0, space, or +
+ " 3. Match * or [n]* or any number or nothing before a .
+ " 4. Match * or [n]* or any number or nothing after a .
+ " 5. Match [n] or nothing before a verb
+ " 6. Match a formatting verb
+ syn match goFormatSpecifier /\
+ \%([^%]\%(%%\)*\)\
+ \@<=%[-#0 +]*\
+ \%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\
+ \%(\.\%(\%(\%(\[\d\+\]\)\=\*\)\|\d\+\)\=\)\=\
+ \%(\[\d\+\]\)\=[vTtbcdoqxXUeEfFgGspw]/ contained containedin=goString,goRawString
+ hi def link goFormatSpecifier goSpecialString
+endif
hi def link goString String
hi def link goRawString String
@@ -131,71 +214,263 @@
hi def link goCharacter Character
" Regions
-syn region goBlock start="{" end="}" transparent fold
syn region goParen start='(' end=')' transparent
+if s:FoldEnable('block')
+ syn region goBlock start="{" end="}" transparent fold
+else
+ syn region goBlock start="{" end="}" transparent
+endif
+
+" import
+if s:FoldEnable('import')
+ syn region goImport start='import (' end=')' transparent fold contains=goImport,goString,goComment
+else
+ syn region goImport start='import (' end=')' transparent contains=goImport,goString,goComment
+endif
+
+" var, const
+if s:FoldEnable('varconst')
+ syn region goVar start='var (' end='^\s*)$' transparent fold
+ \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
+ syn region goConst start='const (' end='^\s*)$' transparent fold
+ \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
+else
+ syn region goVar start='var (' end='^\s*)$' transparent
+ \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
+ syn region goConst start='const (' end='^\s*)$' transparent
+ \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goParamName,goParamType,goSimpleParams,goPointerOperator
+endif
+
+" Single-line var, const, and import.
+syn match goSingleDecl /\%(import\|var\|const\) [^(]\@=/ contains=goImport,goVar,goConst
" Integers
-syn match goDecimalInt "\<\d\+\([Ee]\d\+\)\?\>"
-syn match goHexadecimalInt "\<0x\x\+\>"
-syn match goOctalInt "\<0\o\+\>"
-syn match goOctalError "\<0\o*[89]\d*\>"
+syn match goDecimalInt "\<-\=\(0\|[1-9]_\?\(\d\|\d\+_\?\d\+\)*\)\%([Ee][-+]\=\d\+\)\=\>"
+syn match goDecimalError "\<-\=\(_\(\d\+_*\)\+\|\([1-9]\d*_*\)\+__\(\d\+_*\)\+\|\([1-9]\d*_*\)\+_\+\)\%([Ee][-+]\=\d\+\)\=\>"
+syn match goHexadecimalInt "\<-\=0[xX]_\?\(\x\+_\?\)\+\>"
+syn match goHexadecimalError "\<-\=0[xX]_\?\(\x\+_\?\)*\(\([^ \t0-9A-Fa-f_)]\|__\)\S*\|_\)\>"
+syn match goOctalInt "\<-\=0[oO]\?_\?\(\o\+_\?\)\+\>"
+syn match goOctalError "\<-\=0[0-7oO_]*\(\([^ \t0-7oOxX_/)\]\}\:]\|[oO]\{2,\}\|__\)\S*\|_\|[oOxX]\)\>"
+syn match goBinaryInt "\<-\=0[bB]_\?\([01]\+_\?\)\+\>"
+syn match goBinaryError "\<-\=0[bB]_\?[01_]*\([^ \t01_)]\S*\|__\S*\|_\)\>"
hi def link goDecimalInt Integer
+hi def link goDecimalError Error
hi def link goHexadecimalInt Integer
+hi def link goHexadecimalError Error
hi def link goOctalInt Integer
+hi def link goOctalError Error
+hi def link goBinaryInt Integer
+hi def link goBinaryError Error
hi def link Integer Number
" Floating point
-syn match goFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>"
-syn match goFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>"
-syn match goFloat "\<\d\+[Ee][-+]\d\+\>"
+syn match goFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=\>"
+syn match goFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=\>"
hi def link goFloat Float
" Imaginary literals
-syn match goImaginary "\<\d\+i\>"
-syn match goImaginary "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>"
-syn match goImaginary "\<\.\d\+\([Ee][-+]\d\+\)\?i\>"
-syn match goImaginary "\<\d\+[Ee][-+]\d\+i\>"
+syn match goImaginary "\<-\=\d\+i\>"
+syn match goImaginary "\<-\=\d\+[Ee][-+]\=\d\+i\>"
+syn match goImaginaryFloat "\<-\=\d\+\.\d*\%([Ee][-+]\=\d\+\)\=i\>"
+syn match goImaginaryFloat "\<-\=\.\d\+\%([Ee][-+]\=\d\+\)\=i\>"
hi def link goImaginary Number
+hi def link goImaginaryFloat Float
" Spaces after "[]"
-if go_highlight_array_whitespace_error != 0
- syn match goSpaceError display "\(\[\]\)\@<=\s\+"
+if s:HighlightArrayWhitespaceError()
+ syn match goSpaceError display "\%(\[\]\)\@<=\s\+"
endif
" Spacing errors around the 'chan' keyword
-if go_highlight_chan_whitespace_error != 0
+if s:HighlightChanWhitespaceError()
" receive-only annotation on chan type
- syn match goSpaceError display "\(<-\)\@<=\s\+\(chan\>\)\@="
+ "
+ " \(\<chan\>\)\@<!<- (only pick arrow when it doesn't come after a chan)
+ " this prevents picking up 'chan<- chan<-' but not '<- chan'
+ syn match goSpaceError display "\%(\%(\<chan\>\)\@<!<-\)\@<=\s\+\%(\<chan\>\)\@="
+
" send-only annotation on chan type
- syn match goSpaceError display "\(\<chan\)\@<=\s\+\(<-\)\@="
+ "
+ " \(<-\)\@<!\<chan\> (only pick chan when it doesn't come after an arrow)
+ " this prevents picking up '<-chan <-chan' but not 'chan <-'
+ syn match goSpaceError display "\%(\%(<-\)\@<!\<chan\>\)\@<=\s\+\%(<-\)\@="
+
" value-ignoring receives in a few contexts
- syn match goSpaceError display "\(\(^\|[={(,;]\)\s*<-\)\@<=\s\+"
+ syn match goSpaceError display "\%(\%(^\|[={(,;]\)\s*<-\)\@<=\s\+"
endif
" Extra types commonly seen
-if go_highlight_extra_types != 0
- syn match goExtraType /\<bytes\.\(Buffer\)\>/
- syn match goExtraType /\<io\.\(Reader\|Writer\|ReadWriter\|ReadWriteCloser\)\>/
- syn match goExtraType /\<reflect\.\(Kind\|Type\|Value\)\>/
+if s:HighlightExtraTypes()
+ syn match goExtraType /\<bytes\.\%(Buffer\)\>/
+ syn match goExtraType /\<context\.\%(Context\)\>/
+ syn match goExtraType /\<io\.\%(Reader\|ReadSeeker\|ReadWriter\|ReadCloser\|ReadWriteCloser\|Writer\|WriteCloser\|Seeker\)\>/
+ syn match goExtraType /\<reflect\.\%(Kind\|Type\|Value\)\>/
syn match goExtraType /\<unsafe\.Pointer\>/
endif
" Space-tab error
-if go_highlight_space_tab_error != 0
+if s:HighlightSpaceTabError()
syn match goSpaceError display " \+\t"me=e-1
endif
" Trailing white space error
-if go_highlight_trailing_whitespace_error != 0
+if s:HighlightTrailingWhitespaceError()
syn match goSpaceError display excludenl "\s\+$"
endif
hi def link goExtraType Type
hi def link goSpaceError Error
+
+
+" included from: https://github.com/athom/more-colorful.vim/blob/master/after/syntax/go.vim
+"
+" Comments; their contents
+syn keyword goTodo contained NOTE
+hi def link goTodo Todo
+
+syn match goVarArgs /\.\.\./
+
+" Operators;
+if s:HighlightOperators()
+ " match single-char operators: - + % < > ! & | ^ * =
+ " and corresponding two-char operators: -= += %= <= >= != &= |= ^= *= ==
+ syn match goOperator /[-+%<>!&|^*=]=\?/
+ " match / and /=
+ syn match goOperator /\/\%(=\|\ze[^/*]\)/
+ " match two-char operators: << >> &^
+ " and corresponding three-char operators: <<= >>= &^=
+ syn match goOperator /\%(<<\|>>\|&^\)=\?/
+ " match remaining two-char operators: := && || <- ++ --
+ syn match goOperator /:=\|||\|<-\|++\|--/
+ " match ...
+
+ hi def link goPointerOperator goOperator
+ hi def link goVarArgs goOperator
+endif
+hi def link goOperator Operator
+
+" Functions;
+if s:HighlightFunctions() || s:HighlightFunctionParameters()
+ syn match goDeclaration /\<func\>/ nextgroup=goReceiver,goFunction,goSimpleParams skipwhite skipnl
+ syn match goReceiverVar /\w\+\ze\s\+\%(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained
+ syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl
+ syn match goFunction /\w\+/ nextgroup=goSimpleParams contained skipwhite skipnl
+ syn match goReceiverType /\w\+/ contained
+ if s:HighlightFunctionParameters()
+ syn match goSimpleParams /(\%(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType nextgroup=goFunctionReturn skipwhite skipnl
+ syn match goFunctionReturn /(\%(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goParamName,goType skipwhite skipnl
+ syn match goParamName /\w\+\%(\s*,\s*\w\+\)*\ze\s\+\%(\w\|\.\|\*\|\[\)/ contained nextgroup=goParamType skipwhite skipnl
+ syn match goParamType /\%([^,)]\|\_s\)\+,\?/ contained nextgroup=goParamName skipwhite skipnl
+ \ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock
+ hi def link goReceiverVar goParamName
+ hi def link goParamName Identifier
+ endif
+ syn match goReceiver /(\s*\w\+\%(\s\+\*\?\s*\w\+\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl
+else
+ syn keyword goDeclaration func
+endif
+hi def link goFunction Function
+
+" Function calls;
+if s:HighlightFunctionCalls()
+ syn match goFunctionCall /\w\+\ze(/ contains=goBuiltins,goDeclaration
+endif
+hi def link goFunctionCall Type
+
+" Fields;
+if s:HighlightFields()
+ " 1. Match a sequence of word characters coming after a '.'
+ " 2. Require the following but dont match it: ( \@= see :h E59)
+ " - The symbols: / - + * % OR
+ " - The symbols: [] {} <> ) OR
+ " - The symbols: \n \r space OR
+ " - The symbols: , : .
+ " 3. Have the start of highlight (hs) be the start of matched
+ " pattern (s) offsetted one to the right (+1) (see :h E401)
+ syn match goField /\.\w\+\
+ \%(\%([\/\-\+*%]\)\|\
+ \%([\[\]{}<\>\)]\)\|\
+ \%([\!=\^|&]\)\|\
+ \%([\n\r\ ]\)\|\
+ \%([,\:.]\)\)\@=/hs=s+1
+endif
+hi def link goField Identifier
+
+" Structs & Interfaces;
+if s:HighlightTypes()
+ syn match goTypeConstructor /\<\w\+{\@=/
+ syn match goTypeDecl /\<type\>/ nextgroup=goTypeName skipwhite skipnl
+ syn match goTypeName /\w\+/ contained nextgroup=goDeclType skipwhite skipnl
+ syn match goDeclType /\<\%(interface\|struct\)\>/ skipwhite skipnl
+ hi def link goReceiverType Type
+else
+ syn keyword goDeclType struct interface
+ syn keyword goDeclaration type
+endif
+hi def link goTypeConstructor Type
+hi def link goTypeName Type
+hi def link goTypeDecl Keyword
+hi def link goDeclType Keyword
+
+" Variable Assignments
+if s:HighlightVariableAssignments()
+ syn match goVarAssign /\v[_.[:alnum:]]+(,\s*[_.[:alnum:]]+)*\ze(\s*([-^+|^\/%&]|\*|\<\<|\>\>|\&\^)?\=[^=])/
+ hi def link goVarAssign Special
+endif
+
+" Variable Declarations
+if s:HighlightVariableDeclarations()
+ syn match goVarDefs /\v\w+(,\s*\w+)*\ze(\s*:\=)/
+ hi def link goVarDefs Special
+endif
+
+" Build Constraints
+if s:HighlightBuildConstraints()
+ syn match goBuildKeyword display contained "+build"
+ " Highlight the known values of GOOS, GOARCH, and other +build options.
+ syn keyword goBuildDirectives contained
+ \ android darwin dragonfly freebsd linux nacl netbsd openbsd plan9
+ \ solaris windows 386 amd64 amd64p32 arm armbe arm64 arm64be ppc64
+ \ ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc
+ \ s390 s390x sparc sparc64 cgo ignore race
+
+ " Other words in the build directive are build tags not listed above, so
+ " avoid highlighting them as comments by using a matchgroup just for the
+ " start of the comment.
+ " The rs=s+2 option lets the \s*+build portion be part of the inner region
+ " instead of the matchgroup so it will be highlighted as a goBuildKeyword.
+ syn region goBuildComment matchgroup=goBuildCommentStart
+ \ start="//\s*+build\s"rs=s+2 end="$"
+ \ contains=goBuildKeyword,goBuildDirectives
+ hi def link goBuildCommentStart Comment
+ hi def link goBuildDirectives Type
+ hi def link goBuildKeyword PreProc
+endif
+
+if s:HighlightBuildConstraints() || s:FoldEnable('package_comment')
+ " One or more line comments that are followed immediately by a "package"
+ " declaration are treated like package documentation, so these must be
+ " matched as comments to avoid looking like working build constraints.
+ " The he, me, and re options let the "package" itself be highlighted by
+ " the usual rules.
+ exe 'syn region goPackageComment start=/\v(\/\/.*\n)+\s*package/'
+ \ . ' end=/\v\n\s*package/he=e-7,me=e-7,re=e-7'
+ \ . ' contains=@goCommentGroup,@Spell'
+ \ . (s:FoldEnable('package_comment') ? ' fold' : '')
+ exe 'syn region goPackageComment start=/\v^\s*\/\*.*\n(.*\n)*\s*\*\/\npackage/'
+ \ . ' end=/\v\*\/\n\s*package/he=e-7,me=e-7,re=e-7'
+ \ . ' contains=@goCommentGroup,@Spell'
+ \ . (s:FoldEnable('package_comment') ? ' fold' : '')
+ hi def link goPackageComment Comment
+endif
+
+" :GoCoverage commands
+hi def link goCoverageNormalText Comment
+
" Search backwards for a global declaration to start processing the syntax.
"syn sync match goSync grouphere NONE /^\(const\|var\|type\|func\)\>/
@@ -203,6 +478,9 @@
" following as a more expensive/less precise workaround.
syn sync minlines=500
-let b:current_syntax = 'go'
+let b:current_syntax = "go"
+
+let &cpo = s:keepcpo
+unlet s:keepcpo
" vim: sw=2 sts=2 et
diff --git a/runtime/syntax/jsonc.vim b/runtime/syntax/jsonc.vim
new file mode 100644
index 0000000..d0df16b
--- /dev/null
+++ b/runtime/syntax/jsonc.vim
@@ -0,0 +1,44 @@
+" Vim syntax file
+" Language: JSONC (JSON with Comments)
+" Original Author: Izhak Jakov <izhak724@gmail.com>
+" Acknowledgement: Based off of vim-jsonc maintained by Kevin Locke <kevin@kevinlocke.name>
+" https://github.com/kevinoid/vim-jsonc
+" License: MIT
+" Last Change: 2021-07-01
+
+" Ensure syntax is loaded once, unless nested inside another (main) syntax
+" For description of main_syntax, see https://stackoverflow.com/q/16164549
+if !exists('g:main_syntax')
+ if exists('b:current_syntax') && b:current_syntax ==# 'jsonc'
+ finish
+ endif
+ let g:main_syntax = 'jsonc'
+endif
+
+" Based on vim-json syntax
+runtime! syntax/json.vim
+
+" Remove syntax group for comments treated as errors
+if !exists("g:vim_json_warnings") || g:vim_json_warnings
+ syn clear jsonCommentError
+endif
+
+syn match jsonStringMatch /"\([^"]\|\\\"\)\+"\ze\(\_s*\/\/.*\_s*\)*[}\]]/ contains=jsonString
+syn match jsonStringMatch /"\([^"]\|\\\"\)\+"\ze\_s*\/\*\_.*\*\/\_s*[}\]]/ contains=jsonString
+syn match jsonTrailingCommaError /\(,\)\+\ze\(\_s*\/\/.*\_s*\)*[}\]]/
+syn match jsonTrailingCommaError /\(,\)\+\ze\_s*\/\*\_.*\*\/\_s*[}\]]/
+
+" Define syntax matching comments and their contents
+syn keyword jsonCommentTodo FIXME NOTE TBD TODO XXX
+syn region jsonLineComment start=+\/\/+ end=+$+ contains=@Spell,jsonCommentTodo keepend
+syn region jsonComment start='/\*' end='\*/' contains=@Spell,jsonCommentTodo fold
+
+" Link comment syntax comment to highlighting
+hi! def link jsonLineComment Comment
+hi! def link jsonComment Comment
+
+" Set/Unset syntax to avoid duplicate inclusion and correctly handle nesting
+let b:current_syntax = 'jsonc'
+if g:main_syntax ==# 'jsonc'
+ unlet g:main_syntax
+endif
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index 2de81ae..625cf02 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -10,7 +10,7 @@
if exists("b:current_syntax")
finish
endif
-let s:keepcpo= &cpo
+let s:keepcpo = &cpo
set cpo&vim
" vimTodo: contains common special-notices for comments {{{2