aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/api.txt4
-rw-r--r--runtime/doc/develop.txt6
-rw-r--r--runtime/doc/lsp.txt4
-rw-r--r--runtime/doc/lua.txt27
-rw-r--r--runtime/doc/luaref.txt4
-rw-r--r--runtime/doc/news.txt2
-rw-r--r--runtime/doc/options.txt10
-rw-r--r--runtime/doc/syntax.txt34
-rw-r--r--runtime/doc/vim_diff.txt2
-rw-r--r--runtime/lua/man.lua2
-rw-r--r--runtime/lua/vim/_meta/api.lua4
-rw-r--r--runtime/lua/vim/_meta/options.lua10
-rw-r--r--runtime/lua/vim/diagnostic.lua12
-rw-r--r--runtime/lua/vim/keymap.lua2
-rw-r--r--runtime/lua/vim/lsp.lua8
-rw-r--r--runtime/lua/vim/lsp/protocol.lua2
-rw-r--r--runtime/lua/vim/shared.lua70
-rw-r--r--runtime/lua/vim/version.lua6
-rw-r--r--runtime/syntax/fortran.vim227
-rw-r--r--runtime/syntax/vim.vim12
20 files changed, 235 insertions, 213 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index e3063b0591..07e4473ac2 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -2841,9 +2841,7 @@ nvim_set_decoration_provider({ns_id}, {*opts})
• on_buf: called for each buffer being redrawn (before window
callbacks) ["buf", bufnr, tick]
• on_win: called when starting to redraw a specific window.
- botline_guess is an approximation that does not exceed the
- last line number. ["win", winid, bufnr, topline,
- botline_guess]
+ ["win", winid, bufnr, topline, botline]
• on_line: called for each buffer line being redrawn. (The
interaction with fold lines is subject to change) ["win",
winid, bufnr, row]
diff --git a/runtime/doc/develop.txt b/runtime/doc/develop.txt
index f1d74326c7..28f43a70e0 100644
--- a/runtime/doc/develop.txt
+++ b/runtime/doc/develop.txt
@@ -102,11 +102,11 @@ Examples:
The provider framework invokes Vimscript from C. It is composed of two
functions in eval.c:
-- eval_call_provider(name, method, arguments, discard): calls
- provider#{name}#Call with the method and arguments. If discard is true, any
+- eval_call_provider({name}, {method}, {arguments}, {discard}): Calls
+ `provider#{name}#Call` with {method} and {arguments}. If {discard} is true, any
value returned by the provider will be discarded and empty value will be
returned.
-- eval_has_provider(name): Checks the `g:loaded_{name}_provider` variable
+- eval_has_provider({name}): Checks the `g:loaded_{name}_provider` variable
which must be set to 2 by the provider script to indicate that it is
"enabled and working". Called by |has()| to check if features are available.
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index d53a7b4c11..bbf19f9569 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -745,6 +745,10 @@ client() *vim.lsp.client*
client is fully stopped.
• on_attach(client, bufnr) Runs the on_attach function from the client's
config if it was defined. Useful for buffer-local setup.
+ • supports_method(method, [opts]): boolean Checks if a client supports a
+ given method. Always returns true for unknown off-spec methods. [opts]
+ is a optional `{bufnr?: integer}` table. Some language server
+ capabilities can be file specific.
• Members
• {id} (number): The id allocated to the client.
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index a8d36d7062..e01e16b8f4 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -121,16 +121,14 @@ languages like Python and C#. Example: >lua
func_with_opts { foo = true, filename = "hello.world" }
<
-There's nothing special going on here except that parentheses are treated as
-whitespace. But visually, this small bit of sugar gets reasonably close to
-a "keyword args" interface. Nvim code tends to prefer this style.
-
-------------------------------------------------------------------------------
-LUA PATTERNS *lua-patterns*
+There's nothing special going on here except that parentheses are implicitly
+added. But visually, this small bit of sugar gets reasonably close to a
+"keyword args" interface.
+ *lua-regex*
Lua intentionally does not support regular expressions, instead it has limited
-"patterns" |lua-pattern| which avoid the performance pitfalls of extended
-regex. Lua scripts can also use Vim regex via |vim.regex()|.
+|lua-patterns| which avoid the performance pitfalls of extended regex. Lua
+scripts can also use Vim regex via |vim.regex()|.
Examples: >lua
@@ -1907,15 +1905,24 @@ vim.deep_equal({a}, {b}) *vim.deep_equal()*
Return: ~
(boolean) `true` if values are equals, else `false`
-vim.deepcopy({orig}) *vim.deepcopy()*
+vim.deepcopy({orig}, {noref}) *vim.deepcopy()*
Returns a deep copy of the given object. Non-table objects are copied as
in a typical Lua assignment, whereas table objects are copied recursively.
Functions are naively copied, so functions in the copied table point to
the same functions as those in the input table. Userdata and threads are
not copied and will throw an error.
+ Note: `noref=true` is much more performant on tables with unique table
+ fields, while `noref=false` is more performant on tables that reuse table
+ fields.
+
Parameters: ~
- • {orig} (table) Table to copy
+ • {orig} (table) Table to copy
+ • {noref} (boolean|nil) When `false` (default) a contained table is
+ only copied once and all references point to this single
+ copy. When `true` every occurrence of a table results in a
+ new copy. This also means that a cyclic reference can cause
+ `deepcopy()` to fail.
Return: ~
(table) Table of copied keys and (nested) values.
diff --git a/runtime/doc/luaref.txt b/runtime/doc/luaref.txt
index 467b5760cf..e7b62f4c6c 100644
--- a/runtime/doc/luaref.txt
+++ b/runtime/doc/luaref.txt
@@ -4150,7 +4150,7 @@ string.upper({s}) *string.upper()*
locale.
------------------------------------------------------------------------------
-5.4.1 Patterns *lua-patterns
+5.4.1 Patterns *lua-patterns*
A character class is used to represent a set of characters. The following
combinations are allowed in describing a character class:
@@ -4811,7 +4811,7 @@ debug.setupvalue({func}, {up}, {value}) *debug.setupvalue()*
upvalue with the given index. Otherwise, it returns the name of the
upvalue.
-debug.traceback([{thread},] [{message}] [,{level}]) *debug.traceback()*
+debug.traceback([{thread},] [{message} [,{level}]]) *debug.traceback()*
Returns a string with a traceback of the call stack. An optional
{message} string is appended at the beginning of the traceback. An
optional {level} number tells at which level to start the traceback
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 03e1989e62..d3ace5f33b 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -282,6 +282,8 @@ The following new APIs and features were added.
|vim.diagnostic.get()| when only the number of diagnostics is needed, but
not the diagnostics themselves.
+• |vim.deepcopy()| has a `noref` argument to avoid hashing table values.
+
==============================================================================
CHANGED FEATURES *news-changed*
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 176c8ca3db..117e9c9ec8 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -5923,9 +5923,13 @@ A jump table for the options with a short description can be found at |Q_op|.
%s sign column for currently drawn line
%C fold column for currently drawn line
- NOTE: To draw the sign and fold columns, their items must be included in
- 'statuscolumn'. Even when they are not included, the status column width
- will adapt to the 'signcolumn' and 'foldcolumn' width.
+ The 'statuscolumn' width follows that of the default columns and
+ adapts to the |'numberwidth'|, |'signcolumn'| and |'foldcolumn'| option
+ values (regardless of whether the sign and fold items are present).
+ Aditionally, the 'statuscolumn' grows with the size of the evaluated
+ format string, up to a point (following the maximum size of the default
+ fold, sign and number columns). Shrinking only happens when the number
+ of lines in a buffer changes, or the 'statuscolumn' option is set.
The |v:lnum| variable holds the line number to be drawn.
The |v:relnum| variable holds the relative line number to be drawn.
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 40c102341b..84121be4d6 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -1224,7 +1224,7 @@ To highlight KDE-reserved features, set >
g:desktop_enable_kde follows g:desktop_enable_nonstd if not supplied
-DIFF *diff.vim*
+DIFF *diff.vim* *ft-diff-syntax*
The diff highlighting normally finds translated headers. This can be slow if
there are very long lines in the file. To disable translations: >
@@ -1233,7 +1233,15 @@ there are very long lines in the file. To disable translations: >
Also see |diff-slow|.
+Since the Vim 9.1 release the diff filetype links the diffAdded,
+diffRemoved and diffChanged highlighting groups to |hl-DiffAdd|,
+|hl-DiffDelete| and |hl-DiffChange| by default. If you do not want this, you
+can change it to the previous groups like this in your |vimrc| >
+ hi link diffRemoved Special
+ hi link diffChanged PreProc
+ hi link diffAdded Identifier
+<
DIRCOLORS *dircolors.vim* *ft-dircolors-syntax*
The dircolors utility highlighting definition has one option. It exists to
@@ -1628,27 +1636,19 @@ Unfortunately, the use of tabs will mean that the syntax file will not be able
to detect incorrect margins.
Syntax folding of Fortran files ~
-If you wish to use foldmethod=syntax, then you must first set the variable
-fortran_fold with a command such as >
+Vim will fold your file using foldmethod=syntax, if you set the variable
+fortran_fold in your .vimrc with a command such as >
:let fortran_fold=1
to instruct the syntax script to define fold regions for program units, that
is main programs starting with a program statement, subroutines, function
-subprograms, modules, submodules, and block data units. Block, interface,
-associate, critical, type definition, and change team constructs will also be
-folded. If you also set the variable fortran_fold_conditionals with a command
-such as >
+subprograms, modules, submodules, blocks of comment lines, and block data
+units. Block, interface, associate, critical, type definition, and change team
+constructs will also be folded. If you also set the variable
+fortran_fold_conditionals with a command such as >
:let fortran_fold_conditionals=1
then fold regions will also be defined for do loops, if blocks, select case,
-select type, and select rank constructs. If you also set the variable
-fortran_fold_multilinecomments with a command such as >
- :let fortran_fold_multilinecomments=1
-then fold regions will also be defined for three or more consecutive comment
-lines. Note that defining fold regions can be slow for large files.
-
-If fortran_fold, and possibly fortran_fold_conditionals and/or
-fortran_fold_multilinecomments, have been set, then vim will fold your file.
-Comments or blank lines placed between two program units are not folded
-because they are seen as not belonging to any program unit.
+select type, and select rank constructs. Note that defining fold regions can
+be slow for large files.
The syntax/fortran.vim script contains embedded comments that tell you how to
comment and/or uncomment some lines to (a) activate recognition of some
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index 5b0b5655b4..279fdd646f 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -302,8 +302,6 @@ Options:
global-local string options work.
'autoread' works in the terminal (if it supports "focus" events)
- 'background' colorscheme is only reloaded if value is changed, not every
- time it is set
'cpoptions' flags: |cpo-_|
'diffopt' "linematch" feature
'exrc' searches for ".nvim.lua", ".nvimrc", or ".exrc" files. The
diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua
index dcdfc2b87f..ac15aff60c 100644
--- a/runtime/lua/man.lua
+++ b/runtime/lua/man.lua
@@ -238,7 +238,7 @@ local function get_path(sect, name, silent)
-- If you run man -w strlen and string.3 comes up first, this is a problem. We
-- should search for a matching named one in the results list.
-- However, if you search for man -w clock_gettime, you will *only* get
- -- clock_getres.2, which is the right page. Searching the resuls for
+ -- clock_getres.2, which is the right page. Searching the results for
-- clock_gettime will no longer work. In this case, we should just use the
-- first one that was found in the correct section.
--
diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua
index b6ce3fce8a..e85f81f5f9 100644
--- a/runtime/lua/vim/_meta/api.lua
+++ b/runtime/lua/vim/_meta/api.lua
@@ -1764,9 +1764,7 @@ function vim.api.nvim_set_current_win(window) end
--- • on_buf: called for each buffer being redrawn (before window
--- callbacks) ["buf", bufnr, tick]
--- • on_win: called when starting to redraw a specific window.
---- botline_guess is an approximation that does not exceed the
---- last line number. ["win", winid, bufnr, topline,
---- botline_guess]
+--- ["win", winid, bufnr, topline, botline]
--- • on_line: called for each buffer line being redrawn. (The
--- interaction with fold lines is subject to change) ["win",
--- winid, bufnr, row]
diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua
index 46497179ac..7ad720b6b2 100644
--- a/runtime/lua/vim/_meta/options.lua
+++ b/runtime/lua/vim/_meta/options.lua
@@ -6359,9 +6359,13 @@ vim.go.sol = vim.go.startofline
--- %s sign column for currently drawn line
--- %C fold column for currently drawn line
---
---- NOTE: To draw the sign and fold columns, their items must be included in
---- 'statuscolumn'. Even when they are not included, the status column width
---- will adapt to the 'signcolumn' and 'foldcolumn' width.
+--- The 'statuscolumn' width follows that of the default columns and
+--- adapts to the `'numberwidth'`, `'signcolumn'` and `'foldcolumn'` option
+--- values (regardless of whether the sign and fold items are present).
+--- Aditionally, the 'statuscolumn' grows with the size of the evaluated
+--- format string, up to a point (following the maximum size of the default
+--- fold, sign and number columns). Shrinking only happens when the number
+--- of lines in a buffer changes, or the 'statuscolumn' option is set.
---
--- The `v:lnum` variable holds the line number to be drawn.
--- The `v:relnum` variable holds the relative line number to be drawn.
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index a447463dff..897837a5ce 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -134,7 +134,7 @@ local function prefix_source(diagnostics)
return d
end
- local t = vim.deepcopy(d)
+ local t = vim.deepcopy(d, true)
t.message = string.format('%s: %s', d.source, d.message)
return t
end, diagnostics)
@@ -146,7 +146,7 @@ local function reformat_diagnostics(format, diagnostics)
diagnostics = { diagnostics, 't' },
})
- local formatted = vim.deepcopy(diagnostics)
+ local formatted = vim.deepcopy(diagnostics, true)
for _, diagnostic in ipairs(formatted) do
diagnostic.message = format(diagnostic)
end
@@ -373,7 +373,7 @@ local function get_diagnostics(bufnr, opts, clamp)
or d.col < 0
or d.end_col < 0
then
- d = vim.deepcopy(d)
+ d = vim.deepcopy(d, true)
d.lnum = math.max(math.min(d.lnum, line_count), 0)
d.end_lnum = math.max(math.min(d.end_lnum, line_count), 0)
d.col = math.max(d.col, 0)
@@ -636,7 +636,7 @@ function M.config(opts, namespace)
if not opts then
-- Return current config
- return vim.deepcopy(t)
+ return vim.deepcopy(t, true)
end
for k, v in pairs(opts) do
@@ -723,7 +723,7 @@ end
---
---@return table A list of active diagnostic namespaces |vim.diagnostic|.
function M.get_namespaces()
- return vim.deepcopy(all_namespaces)
+ return vim.deepcopy(all_namespaces, true)
end
---@class Diagnostic
@@ -756,7 +756,7 @@ function M.get(bufnr, opts)
opts = { opts, 't', true },
})
- return vim.deepcopy(get_diagnostics(bufnr, opts, false))
+ return vim.deepcopy(get_diagnostics(bufnr, opts, false), true)
end
--- Get current diagnostics count.
diff --git a/runtime/lua/vim/keymap.lua b/runtime/lua/vim/keymap.lua
index bdea95f9ab..8e4e123fe0 100644
--- a/runtime/lua/vim/keymap.lua
+++ b/runtime/lua/vim/keymap.lua
@@ -44,7 +44,7 @@ function keymap.set(mode, lhs, rhs, opts)
opts = { opts, 't', true },
})
- opts = vim.deepcopy(opts or {})
+ opts = vim.deepcopy(opts or {}, true)
---@cast mode string[]
mode = type(mode) == 'string' and { mode } or mode
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 3105413b53..b2aa943359 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -425,6 +425,12 @@ end
--- Runs the on_attach function from the client's config if it was defined.
--- Useful for buffer-local setup.
---
+--- - supports_method(method, [opts]): boolean
+--- Checks if a client supports a given method.
+--- Always returns true for unknown off-spec methods.
+--- [opts] is a optional `{bufnr?: integer}` table.
+--- Some language server capabilities can be file specific.
+---
--- - Members
--- - {id} (number): The id allocated to the client.
---
@@ -1347,7 +1353,7 @@ function lsp.start_client(config)
---@param context? {bufnr: integer}
---@param handler? lsp.Handler only called if a server command
function client._exec_cmd(command, context, handler)
- context = vim.deepcopy(context or {}) --[[@as lsp.HandlerContext]]
+ context = vim.deepcopy(context or {}, true) --[[@as lsp.HandlerContext]]
context.bufnr = context.bufnr or api.nvim_get_current_buf()
context.client_id = client.id
local cmdname = command.command
diff --git a/runtime/lua/vim/lsp/protocol.lua b/runtime/lua/vim/lsp/protocol.lua
index df12c36396..35eb0305d7 100644
--- a/runtime/lua/vim/lsp/protocol.lua
+++ b/runtime/lua/vim/lsp/protocol.lua
@@ -314,7 +314,7 @@ local constants = {
}
for k, v in pairs(constants) do
- local tbl = vim.deepcopy(v)
+ local tbl = vim.deepcopy(v, true)
vim.tbl_add_reverse_lookup(tbl)
protocol[k] = tbl
end
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index fd795aae49..24bc97bf8e 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -9,43 +9,36 @@
---@diagnostic disable-next-line: lowercase-global
vim = vim or {}
-local function _id(v)
- return v
-end
+---@generic T
+---@param orig T
+---@param cache? table<any,any>
+---@return T
+local function deepcopy(orig, cache)
+ if orig == vim.NIL then
+ return vim.NIL
+ elseif type(orig) == 'userdata' or type(orig) == 'thread' then
+ error('Cannot deepcopy object of type ' .. type(orig))
+ elseif type(orig) ~= 'table' then
+ return orig
+ end
-local deepcopy
+ --- @cast orig table<any,any>
-local deepcopy_funcs = {
- table = function(orig, cache)
- if cache[orig] then
- return cache[orig]
- end
- local copy = {}
+ if cache and cache[orig] then
+ return cache[orig]
+ end
+ local copy = {} --- @type table<any,any>
+
+ if cache then
cache[orig] = copy
- local mt = getmetatable(orig)
- for k, v in pairs(orig) do
- copy[deepcopy(k, cache)] = deepcopy(v, cache)
- end
- return setmetatable(copy, mt)
- end,
- number = _id,
- string = _id,
- ['nil'] = _id,
- boolean = _id,
- ['function'] = _id,
-}
-
-deepcopy = function(orig, _cache)
- local f = deepcopy_funcs[type(orig)]
- if f then
- return f(orig, _cache or {})
- else
- if type(orig) == 'userdata' and orig == vim.NIL then
- return vim.NIL
- end
- error('Cannot deepcopy object of type ' .. type(orig))
end
+
+ for k, v in pairs(orig) do
+ copy[deepcopy(k, cache)] = deepcopy(v, cache)
+ end
+
+ return setmetatable(copy, getmetatable(orig))
end
--- Returns a deep copy of the given object. Non-table objects are copied as
@@ -54,11 +47,20 @@ end
--- same functions as those in the input table. Userdata and threads are not
--- copied and will throw an error.
---
+--- Note: `noref=true` is much more performant on tables with unique table
+--- fields, while `noref=false` is more performant on tables that reuse table
+--- fields.
+---
---@generic T: table
---@param orig T Table to copy
+---@param noref? boolean
+--- When `false` (default) a contained table is only copied once and all
+--- references point to this single copy. When `true` every occurrence of a
+--- table results in a new copy. This also means that a cyclic reference can
+--- cause `deepcopy()` to fail.
---@return T Table of copied keys and (nested) values.
-function vim.deepcopy(orig)
- return deepcopy(orig)
+function vim.deepcopy(orig, noref)
+ return deepcopy(orig, not noref and {} or nil)
end
--- Gets an |iterator| that splits a string at each instance of a separator, in "lazy" fashion
diff --git a/runtime/lua/vim/version.lua b/runtime/lua/vim/version.lua
index 306eef90d3..0873402e29 100644
--- a/runtime/lua/vim/version.lua
+++ b/runtime/lua/vim/version.lua
@@ -158,7 +158,7 @@ end
function M._version(version, strict) -- Adapted from https://github.com/folke/lazy.nvim
if type(version) == 'table' then
if version.major then
- return setmetatable(vim.deepcopy(version), Version)
+ return setmetatable(vim.deepcopy(version, true), Version)
end
return setmetatable({
major = version[1] or 0,
@@ -228,7 +228,7 @@ function VersionRange:has(version)
version = M.parse(version)
elseif getmetatable(version) ~= Version then
-- Need metatable to compare versions.
- version = setmetatable(vim.deepcopy(version), Version)
+ version = setmetatable(vim.deepcopy(version, true), Version)
end
if version then
if version.prerelease ~= self.from.prerelease then
@@ -298,7 +298,7 @@ function M.range(spec) -- Adapted from https://github.com/folke/lazy.nvim
local semver = M.parse(version)
if semver then
local from = semver
- local to = vim.deepcopy(semver)
+ local to = vim.deepcopy(semver, true)
if mods == '' or mods == '=' then
to.patch = to.patch + 1
elseif mods == '<' then
diff --git a/runtime/syntax/fortran.vim b/runtime/syntax/fortran.vim
index 99e11528de..1fb8a1c424 100644
--- a/runtime/syntax/fortran.vim
+++ b/runtime/syntax/fortran.vim
@@ -1,6 +1,6 @@
" Vim syntax file
" Language: Fortran 2023 (and Fortran 2018, 2008, 2003, 95, 90, and 77)
-" Version: (v109) 2023 December 29
+" Version: (v110) 2024 January 03
" Maintainers: Ajit J. Thakkar <ajit@unb.ca>; <https://ajit.ext.unb.ca/>
" Joshua Hollett <j.hollett@uwinnipeg.ca>
" Usage: For instructions, do :help fortran-syntax from Vim
@@ -68,18 +68,18 @@ if b:fortran_fixed_source == 1
else
syn match fortranConstructName "^\s*\zs\a\w*\ze\s*:"
endif
-syn match fortranConstructName "\(\<end\s*do\s\+\)\@11<=\a\w*"
-syn match fortranConstructName "\(\<end\s*if\s\+\)\@11<=\a\w*"
-syn match fortranConstructName "\(\<end\s*select\s\+\)\@15<=\a\w*"
-syn match fortranConstructName "\(\<end\s*where\s\+\)\@14<=\a\w*"
-syn match fortranConstructName "\(\<end\s*block\s\+\)\@14<=\a\w*"
-syn match fortranConstructName "\(\<\%(exit\|cycle\)\s\+\)\@11<=\a\w*"
-syn match fortranConstructName "\(\<end\s*forall\s\+\)\@15<=\a\w*\>"
-syn match fortranConstructName "\(\<end\s*critical\s\+\)\@17<=\a\w*\>"
-syn match fortranConstructName "\(\<end\s*associate\s\+\)\@18<=\a\w*\>"
-
-syn match fortranUnitName "\(\(end\s*\)\?\(subroutine\|function\|module\|program\|submodule\)\s\+\)\@12<=\a\w\+"
-syn match fortranUnitHeader "\<end\s*$"
+syn match fortranConstructName "\%(\<end\s*do\s\+\)\@11<=\a\w*"
+syn match fortranConstructName "\%(\<end\s*if\s\+\)\@11<=\a\w*"
+syn match fortranConstructName "\%(\<end\s*select\s\+\)\@15<=\a\w*"
+syn match fortranConstructName "\%(\<end\s*where\s\+\)\@14<=\a\w*"
+syn match fortranConstructName "\%(\<end\s*block\s\+\)\@14<=\a\w*"
+syn match fortranConstructName "\%(\<\%(exit\|cycle\)\s\+\)\@11<=\a\w*"
+syn match fortranConstructName "\%(\<end\s*forall\s\+\)\@15<=\a\w*\>"
+syn match fortranConstructName "\%(\<end\s*critical\s\+\)\@17<=\a\w*\>"
+syn match fortranConstructName "\%(\<end\s*associate\s\+\)\@18<=\a\w*\>"
+
+syn match fortranUnitName "\%(\<\%(end\s*\)\?\%(subroutine\|function\|module\|program\|submodule\)\s\+\)\@12<=\a\w\+"
+syn match fortranUnitHeader "\<end\>\ze\s*\%(!.*\)\?$"
syn keyword fortranIntrinsic abs acos aimag aint anint asin atan atan2 char cmplx conjg cos cosh exp ichar index int log log10 max min nint sign sin sinh sqrt tan tanh
syn keyword fortranIntrinsicR achar iachar transfer dble dprod dim lge lgt lle llt mod
@@ -91,7 +91,7 @@ syn keyword fortranIntrinsic dot_product eoshift exponent floor fraction iand
syn keyword fortranIntrinsic modulo mvbits nearest pack precision present radix random_number random_seed range repeat reshape rrspacing scale scan set_exponent shape size spacing
"syn keyword fortranIntrinsic count epsilon maxval minval product sum huge tiny
" intrinsic names often used for variables in older Fortran code
-syn match fortranIntrinsic '\<\(count\|epsilon\|maxval\|minval\|product\|sum\|huge\|tiny\)\>\ze\s*('
+syn match fortranIntrinsic '\<\%(count\|epsilon\|maxval\|minval\|product\|sum\|huge\|tiny\)\>\ze\s*('
syn keyword fortranIntrinsic spread system_clock transpose trim ubound unpack verify
syn keyword fortranIntrinsic atomic_define atomic_ref execute_command_line leadz trailz storage_size merge_bits
syn keyword fortranIntrinsic bge bgt ble blt dshiftl dshiftr findloc iall iany iparity image_index lcobound ucobound maskl maskr num_images parity popcnt poppar shifta shiftl shiftr this_image
@@ -116,30 +116,30 @@ syn keyword fortranExtraIntrinsic algama cdabs cdcos cdexp cdlog cdsin cdsqrt cq
syn keyword fortranType generic final enumerator import
syn keyword fortranType c_ptr c_funptr elemental pure impure recursive non_recursive
-syn match fortranTypeOb "^\s*\(character\s*\)\@15<=\*"
-syn match fortranType "^\s*\(implicit \)\?\s*\(real\|integer\|logical\|complex\|character\|type\)\>"
-syn match fortranType "^\s*implicit\s\+none"
-syn match fortranType "\(class\|type\)\(of\)\?"
-syn match fortranType "\(end\s*\)\?\<interface\>"
+syn match fortranTypeOb "^\s*\zs\%(character\s*\)\@15<=\*"
+syn match fortranType "^\s*\zs\%(implicit\s\+\)\?\%(real\|integer\|logical\|complex\|character\|type\)\>"
+syn match fortranType "^\s*\zsimplicit\s\+none\>"
+syn match fortranType "\<\%(class\|type\)\%(of\)\?\>"
+syn match fortranType "\<\%(end\s*\)\?interface\>"
syn match fortranType "\<enum\s*,\s*bind\s*(\s*c\s*)"
-syn match fortranType "\<end\s*\(enum\|type\)\>"
-syn match fortranType "\(end\s*\)\?enumeration\s\+type"
-syn match fortranType "\(end\s*\)\?\(\<module\s\+\)\?procedure\>"
-syn match fortranTypeR display "double\s*precision"
-syn match fortranTypeR display "double\s\+complex"
+syn match fortranType "\<end\s*\%(enum\|type\)\>"
+syn match fortranType "\<\%(end\s*\)\?enumeration\s\+type"
+syn match fortranType "\<\%(end\s*\)\?\%(module\s\+\)\?procedure\>"
+syn match fortranTypeR display "\<double\s*precision\>"
+syn match fortranTypeR display "\<double\s\+complex\>"
syn keyword fortranAttribute value bind deferred contiguous intrinsic non_intrinsic
syn keyword fortranAttribute asynchronous nopass non_overridable pass volatile extends
syn keyword fortranAttribute abstract external private public protected intent optional
syn keyword fortranAttribute pointer target allocatable dimension codimension sequence parameter save
syn keyword fortranUnitHeader result operator assignment
-syn match fortranUnitHeader "\<\(end\s*\)\?\(subroutine\|function\|module\|program\|submodule\)\>"
-syn match fortranBlock "\<\(end\s*\)\?\(block\|critical\|associate\)\>"
-syn match fortranCalled "\(call\s\+\)\@7<=\a\w*"
+syn match fortranUnitHeader "\<\%(end\s*\)\?\%(subroutine\|function\|module\|program\|submodule\)\>"
+syn match fortranBlock "\<\%(end\s*\)\?\%(block\|critical\|associate\)\>"
+syn match fortranCalled "\<\%(call\s\+\)\@7<=\a\w*"
syn match fortranRepeat "\<do\>"
syn keyword fortranRepeat concurrent
syn keyword fortranRepeatR while
-syn match fortranRepeat "\<end\s*do"
+syn match fortranRepeat "\<end\s*do\>"
syn keyword fortranRepeatOb forall
syn match fortranRepeatOb "\<end\s*forall\>"
@@ -150,16 +150,16 @@ syn region fortranParen transparent start="(" end=")" contains=ALLBUT,fortranPar
syn match fortranParenError ")"
syn match fortranOperator "\.\s*n\=eqv\s*\."
-syn match fortranOperator "\.\s*\(and\|or\|not\)\s*\."
-syn match fortranOperator "\(+\|-\|/\|\*\)"
-syn match fortranOperator "\(\(>\|<\)=\=\|==\|/=\|=\)"
-syn match fortranOperator "\(%\|?\|=>\)"
-syn match fortranOperator "\([\|]\)"
+syn match fortranOperator "\.\s*\%(and\|or\|not\)\s*\."
+syn match fortranOperator "\%(+\|-\|/\|\*\)"
+syn match fortranOperator "\%(\%(>\|<\)=\=\|==\|/=\|=\)"
+syn match fortranOperator "\%(%\|?\|=>\)"
+syn match fortranOperator "\%([\|]\)"
syn match fortranOperatorR "\.\s*[gl][et]\s*\."
-syn match fortranOperatorR "\.\s*\(eq\|ne\)\s*\."
+syn match fortranOperatorR "\.\s*\%(eq\|ne\)\s*\."
syn keyword fortranReadWrite print flush
-syn match fortranReadWrite '\<\(backspace\|close\|endfile\|inquire\|open\|read\|rewind\|write\)\ze\s*('
+syn match fortranReadWrite '\<\%(backspace\|close\|endfile\|inquire\|open\|read\|rewind\|write\)\ze\s*('
"If tabs are allowed then the left margin checks do not work
if exists("fortran_have_tabs")
@@ -170,17 +170,17 @@ endif
"Numbers of various sorts
" Integers
-syn match fortranNumber display "\<\d\+\(_\a\w*\)\=\>"
+syn match fortranNumber display "\<\d\+\%(_\a\w*\)\=\>"
" floating point number, without a decimal point
-syn match fortranFloatIll display "\<\d\+[deq][-+]\=\d\+\(_\a\w*\)\=\>"
+syn match fortranFloatIll display "\<\d\+[deq][-+]\=\d\+\%(_\a\w*\)\=\>"
" floating point number, starting with a decimal point
-syn match fortranFloatIll display "\.\d\+\([deq][-+]\=\d\+\)\=\(_\a\w*\)\=\>"
+syn match fortranFloatIll display "\.\d\+\%([deq][-+]\=\d\+\)\=\%(_\a\w*\)\=\>"
" floating point number, no digits after decimal
-syn match fortranFloatIll display "\<\d\+\.\([deq][-+]\=\d\+\)\=\(_\a\w*\)\=\>"
+syn match fortranFloatIll display "\<\d\+\.\%([deq][-+]\=\d\+\)\=\%(_\a\w*\)\=\>"
" floating point number, D or Q exponents
-syn match fortranFloatIll display "\<\d\+\.\d\+\([dq][-+]\=\d\+\)\=\(_\a\w*\)\=\>"
+syn match fortranFloatIll display "\<\d\+\.\d\+\%([dq][-+]\=\d\+\)\=\%(_\a\w*\)\=\>"
" floating point number
-syn match fortranFloat display "\<\d\+\.\d\+\(e[-+]\=\d\+\)\=\(_\a\w*\)\=\>"
+syn match fortranFloat display "\<\d\+\.\d\+\%(e[-+]\=\d\+\)\=\%(_\a\w*\)\=\>"
" binary number
syn match fortranBinary display "b["'][01]\+["']"
" octal number
@@ -189,30 +189,29 @@ syn match fortranOctal display "o["'][0-7]\+["']"
syn match fortranHex display "z["'][0-9A-F]\+["']"
" Numbers in formats
syn match fortranFormatSpec display "\d*f\d\+\.\d\+"
-syn match fortranFormatSpec display "\d*e[sn]\=\d\+\.\d\+\(e\d+\>\)\="
-syn match fortranFormatSpec display "\d*\(d\|q\|g\)\d\+\.\d\+\(e\d+\)\="
+syn match fortranFormatSpec display "\d*e[sn]\=\d\+\.\d\+\%(e\d+\>\)\="
+syn match fortranFormatSpec display "\d*\%(d\|q\|g\)\d\+\.\d\+\%(e\d+\)\="
syn match fortranFormatSpec display "\d\+x\>"
" The next match cannot be used because it would pick up identifiers as well
-" syn match fortranFormatSpec display "\<\(a\|i\)\d\+"
+" syn match fortranFormatSpec display "\<\%(a\|i\)\d\+"
" Numbers as labels
-syn match fortranLabelNumber display "^\d\{1,5}\s"me=e-1
-syn match fortranLabelNumber display "^ \d\{1,4}\s"ms=s+1,me=e-1
-syn match fortranLabelNumber display "^ \d\{1,3}\s"ms=s+2,me=e-1
-syn match fortranLabelNumber display "^ \d\d\=\s"ms=s+3,me=e-1
-syn match fortranLabelNumber display "^ \d\s"ms=s+4,me=e-1
+syn match fortranLabelNumber display "^\zs\d\{1,5}\ze\s"
+syn match fortranLabelNumber display "^ \zs\d\{1,4}\ze\s"
+syn match fortranLabelNumber display "^ \zs\d\{1,3}\ze\s"
+syn match fortranLabelNumber display "^ \zs\d\d\=\ze\s"
+syn match fortranLabelNumber display "^ \zs\d\ze\s"
" Numbers as targets
-syn match fortranTarget display "\(\<if\s*(.\+)\s*\)\@<=\(\d\+\s*,\s*\)\{2}\d\+\>"
-syn match fortranTarget display "\(\<do\s\+\)\@11<=\d\+\>"
-syn match fortranTarget display "\(\<go\s*to\s*(\=\)\@11<=\(\d\+\s*,\s*\)*\d\+\>"
+syn match fortranTarget display "\%(\<if\s*(.\+)\s*\)\@<=\%(\d\+\s*,\s*\)\{2}\d\+\>"
+syn match fortranTarget display "\%(\<do\s\+\)\@11<=\d\+\>"
+syn match fortranTarget display "\%(\<go\s*to\s*(\=\)\@11<=\%(\d\+\s*,\s*\)*\d\+\>"
-syn match fortranBoolean "\.\s*\(true\|false\)\s*\."
+syn match fortranBoolean "\.\s*\%(true\|false\)\s*\."
-syn match fortranKeyword "call"
+syn keyword fortranKeyword call
syn keyword fortranKeyword use only contains
-syn match fortranKeyword "fail\s\+image\>"
-syn match fortranKeyword "\(error\s\+\)\=stop"
-syn match fortranKeyword "\<continue\>"
-syn match fortranKeyword "^\s*\d\+\s\+continue\>"
+syn match fortranKeyword "\<fail\s\+image\>"
+syn match fortranKeyword "\<\%(error\s\+\)\=stop\>"
+syn keyword fortranKeyword continue
syn match fortranKeyword "\<go\s*to\>"
syn match fortranKeywordDel "\<go\s*to\ze\s\+.*,\s*(.*$"
syn match fortranKeywordOb "\<go\s*to\ze\s*(\d\+.*$"
@@ -222,40 +221,40 @@ syn keyword fortranKeyword allocate deallocate nullify return cycle exit
syn region fortranString start=+'+ end=+'+ contains=fortranLeftMargin,fortranContinueMark,fortranSerialNumber
syn region fortranString start=+"+ end=+"+ contains=fortranLeftMargin,fortranContinueMark,fortranSerialNumber
-syn match fortranIO '\%(\((\|,\|, *&\n\)\s*\)\@<=\(access\|blank\|direct\|exist\|file\|fmt\|form\|formatted\|iostat\|name\|named\|nextrec\|number\|opened\|rec\|recl\|sequential\|status\|unformatted\|unit\)\ze\s*='
+syn match fortranIO '\%(\%((\|,\|, *&\n\)\s*\)\@<=\%(access\|blank\|direct\|exist\|file\|fmt\|form\|formatted\|iostat\|name\|named\|nextrec\|number\|opened\|rec\|recl\|sequential\|status\|unformatted\|unit\)\ze\s*='
syn keyword fortranIOR format namelist
syn keyword fortranIO pad position action delim readwrite
syn keyword fortranIO eor advance nml
syn keyword fortranIO newunit decimal round iomsg
-syn match fortranIO contains=fortranOperator "\<e\(nd\|rr\)\s*=\s*\d\+"
+syn match fortranIO contains=fortranOperator "\<e\%(nd\|rr\)\s*=\s*\d\+"
syn keyword fortranConditional else then where elsewhere
syn match fortranConditional "\<if\>"
-syn match fortranConditional "\<else\s*if"
-syn match fortranConditional "\(end\s*\)\?\(if\|where\|select\)"
-syn match fortranConditional "\<select\s\+\(case\|rank\|type\)"
-syn match fortranConditional "\(class\|type\)\s\+is\>"
-syn match fortranConditional "\(case\|rank\)\(\s\+default\)\?"
+syn match fortranConditional "\<else\s*if\>"
+syn match fortranConditional "\<\%(end\s*\)\?\%(if\|where\|select\)\>"
+syn match fortranConditional "\<select\s\+\%(case\|rank\|type\)\>"
+syn match fortranConditional "\<\%(class\|type\)\s\+is\>"
+syn match fortranConditional "\<\%(case\|rank\)\%(\s\+default\)\?\>"
syn match fortranConditionalDel "\<if\s*(.*)\s*\d\+\s*,\s*\d\+\s*,\s*\d\+\s*$"
syn keyword fortranInclude include
-syn match fortranImageControl "sync\s\+\(all\|images\|memory\|team\)\>"
-syn match fortranImageControl "\(change\|form\|end\)\s\+team\>"
-syn match fortranImageControl "event\s\+\(post\|wait\)"
-syn match fortranImageControl "\(un\)\?lock\ze\s*("
-syn match fortranImageControl "notify\s\+wait\ze\s*("
+syn match fortranImageControl "\<sync\s\+\%(all\|images\|memory\|team\)\>"
+syn match fortranImageControl "\<\%(change\|form\|end\)\s\+team\>"
+syn match fortranImageControl "\<event\s\+\%(post\|wait\)"
+syn match fortranImageControl "\<\%(un\)\?lock\ze\s*("
+syn match fortranImageControl "\<notify\s\+wait\ze\s*("
syn keyword fortranUnitHeaderOb entry
-syn match fortranUnitHeaderOb display "block\s*data"
+syn match fortranUnitHeaderOb display "\<block\s*data\>"
syn keyword fortranStorageClass in out
syn match fortranStorageClass "\<in\s*out\>"
syn match fortranStorageClass "\<kind\s*="me=s+4
syn match fortranStorageClass "\<len\s*="me=s+3
-syn match fortranStorageClass "^\s*data\>\(\s\+\a\w*\s*/\)\@="
-syn match fortranStorageClassOb "^\s*common\>"
-syn match fortranStorageClassOb "^\s*common\>\(\s*/\)\@="
+syn match fortranStorageClass "^\s*\zsdata\>\%(\s\+\a\w*\s*/\)\@="
+syn match fortranStorageClassOb "^\s*\zscommon\>"
+syn match fortranStorageClassOb "^\s*\zscommon\>\%(\s*/\)\@="
syn keyword fortranStorageClassOb equivalence
syn keyword fortranConstant c_null_char c_alert c_backspace c_form_feed c_new_line c_carriage_return c_horizontal_tab c_vertical_tab
@@ -284,10 +283,10 @@ if exists("fortran_CUDA")
syn keyword fortranTypeCUDA cudaErrorNotReady cudaSuccess cudaErrorInvalidValue
syn keyword fortranTypeCUDA c_devptr
- syn match fortranStringCUDA "blockidx%[xyz]"
- syn match fortranStringCUDA "blockdim%[xyz]"
- syn match fortranStringCUDA "griddim%[xyz]"
- syn match fortranStringCUDA "threadidx%[xyz]"
+ syn match fortranStringCUDA "\<blockidx%[xyz]\>"
+ syn match fortranStringCUDA "\<blockdim%[xyz]\>"
+ syn match fortranStringCUDA "\<griddim%[xyz]\>"
+ syn match fortranStringCUDA "\<threadidx%[xyz]\>"
syn keyword fortranIntrinsicCUDA warpsize syncthreads syncthreads_and syncthreads_count syncthreads_or threadfence threadfence_block threadfence_system gpu_time allthreads anythread ballot
syn keyword fortranIntrinsicCUDA atomicadd atomicsub atomicmax atomicmin atomicand atomicor atomicxor atomicexch atomicinc atomicdec atomiccas sizeof __shfl __shfl_up __shfl_down __shfl_xor
@@ -325,14 +324,14 @@ else
endif
syn match fortranComment excludenl "!.*$" contains=@fortranCommentGroup,@spell
-syn match fortranOpenMP excludenl "^\s*!\$\(OMP\)\=&\=\s.*$"
+syn match fortranOpenMP excludenl "^\s*\zs!\$\%(OMP\)\=&\=\s.*$"
syn match fortranEndStatement display ";"
"cpp is often used with Fortran
-syn match cPreProc "^\s*#\s*\(define\|ifdef\)\>.*"
-syn match cPreProc "^\s*#\s*\(elif\|if\)\>.*"
-syn match cPreProc "^\s*#\s*\(ifndef\|undef\)\>.*"
-syn match cPreCondit "^\s*#\s*\(else\|endif\)\>.*"
+syn match cPreProc "^\s*#\s*\%(define\|ifdef\)\>.*"
+syn match cPreProc "^\s*#\s*\%(elif\|if\)\>.*"
+syn match cPreProc "^\s*#\s*\%(ifndef\|undef\)\>.*"
+syn match cPreCondit "^\s*#\s*\%(else\|endif\)\>.*"
syn region cIncluded contained start=+"[^("]+ skip=+\\\\\|\\"+ end=+"+ contains=fortranLeftMargin,fortranContinueMark,fortranSerialNumber
"syn region cIncluded contained start=+"[^("]+ skip=+\\\\\|\\"+ end=+"+
syn match cIncluded contained "<[^>]*>"
@@ -353,61 +352,50 @@ if exists("fortran_fold")
setlocal foldmethod=syntax
endif
if (b:fortran_fixed_source == 1)
- syn region fortranProgram transparent fold keepend start="^\s*program\s\+\z(\a\w*\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*\(program\(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranModule
- syn region fortranModule transparent fold keepend start="^\s*submodule\s\+(\a\w*\s*\(:\a\w*\s*\)*)\s*\z\(\a\w*\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*\(submodule\(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranProgram,fortranModule
- syn region fortranModule transparent fold keepend start="^\s*module\s\+\(procedure\)\@!\z(\a\w*\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*\(module\(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranProgram
- syn region fortranFunction transparent fold keepend extend start="^\s*\(elemental \|pure \|impure \|module \|recursive \)\=\s*\(\(\(real \|integer \|logical \|complex \|double \s*precision \)\s*\((\(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\|type\s\+(\s*\w\+\s*) \|character \((\(\s*len\s*=\)\=\s*\d\+\s*)\|(\(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\=\s*function\s\+\z(\a\w*\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*\($\|function\(\s\+\z1\>\)\=\)" contains=ALLBUT,fortranProgram,fortranModule
- syn region fortranSubroutine transparent fold keepend extend start="^\s*\(elemental \|pure \|impure \|module \|recursive \)\=\s*subroutine\s\+\z(\a\w*\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*\($\|subroutine\(\s\+\z1\>\)\=\)" contains=ALLBUT,fortranProgram,fortranModule
+ syn region fortranProgram transparent fold keepend start="^\s*program\s\+\z(\a\w*\)" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\<end\s*\%(program\%(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranModule
+ syn region fortranModule transparent fold keepend start="^\s*submodule\s\+(\a\w*\s*\%(:\a\w*\s*\)*)\s*\z\(\a\w*\)" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\<end\s*\%(submodule\%(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranProgram,fortranModule
+ syn region fortranModule transparent fold keepend start="^\s*module\s\+\%(procedure\)\@!\z(\a\w*\)" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\<end\s*\%(module\%(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranProgram
+ syn region fortranFunction transparent fold keepend extend start="^\s*\%(elemental \|pure \|impure \|module \|recursive \)\=\s*\%(\%(\%(real \|integer \|logical \|complex \|double \s*precision \)\s*\%((\%(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\|type\s\+(\s*\w\+\s*) \|character \%((\%(\s*len\s*=\)\=\s*\d\+\s*)\|(\%(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\=\s*function\s\+\z(\a\w*\)" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\<end\s*\%($\|function\%(\s\+\z1\>\)\=\)" contains=ALLBUT,fortranProgram,fortranModule
+ syn region fortranSubroutine transparent fold keepend extend start="^\s*\%(elemental \|pure \|impure \|module \|recursive \)\=\s*subroutine\s\+\z(\a\w*\)" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\<end\s*\%($\|subroutine\%(\s\+\z1\>\)\=\)" contains=ALLBUT,fortranProgram,fortranModule
syn region fortranBlockData transparent fold keepend start="\<block\>" skip="^\s*[!#].*$" excludenl end="\<end\s*block\>" contains=ALLBUT,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortran77Loop,fortranCase,fortran90Loop,fortranIfBlock
- syn region fortranAssociate transparent fold keepend start="^\s*\<associate\s\+" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*associate" contains=ALLBUT,fortranProgram,fortranModule,fortranSubroutine,fortranFunction
- syn region fortranCritical transparent fold keepend start="^\s*\<critical\s\+" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*critical" contains=ALLBUT,fortranProgram,fortranModule,fortranSubroutine,fortranFunction
- syn region fortranTeam transparent fold keepend start="^\s*\<change\s\+team\>" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*team\>" contains=ALLBUT,fortranProgram,fortranModule,fortranSubroutine,fortranFunction
- syn region fortranInterface transparent fold keepend extend start="^\s*\(abstract \)\=\s*interface\>" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*interface\>" contains=ALLBUT,fortranProgram,fortranModule,fortran77Loop,fortranCase,fortran90Loop,fortranIfBlock
- syn region fortranTypeDef transparent fold keepend extend start="^\s*type\s*\(,\s*\(public\|private\|abstract\)\)\=\s*::" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*type\>" contains=ALLBUT,fortranProgram,fortranModule,fortran77Loop,fortranCase,fortran90Loop,fortranIfBlock,fortranInterface
+ syn region fortranAssociate transparent fold keepend start="^\s*\<associate\s\+" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\<end\s*associate" contains=ALLBUT,fortranProgram,fortranModule,fortranSubroutine,fortranFunction
+ syn region fortranCritical transparent fold keepend start="^\s*\<critical\s\+" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\<end\s*critical" contains=ALLBUT,fortranProgram,fortranModule,fortranSubroutine,fortranFunction
+ syn region fortranTeam transparent fold keepend start="^\s*\<change\s\+team\>" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\<end\s*team\>" contains=ALLBUT,fortranProgram,fortranModule,fortranSubroutine,fortranFunction
+ syn region fortranInterface transparent fold keepend extend start="^\s*\%(abstract \)\=\s*interface\>" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\<end\s*interface\>" contains=ALLBUT,fortranProgram,fortranModule,fortran77Loop,fortranCase,fortran90Loop,fortranIfBlock
+ syn region fortranTypeDef transparent fold keepend extend start="^\s*type\s*\%(,\s*\%(public\|private\|abstract\)\)\=\s*::" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\<end\s*type\>" contains=ALLBUT,fortranProgram,fortranModule,fortran77Loop,fortranCase,fortran90Loop,fortranIfBlock,fortranInterface
+ syn region fortranMultiComments fold start="^\zs[!c*].*\_s*[!c*]" skip="^[!c*]" end='^\ze\s*[^!c*]'
else
- syn region fortranProgram transparent fold keepend start="^\s*program\s\+\z(\a\w*\)" skip="^\s*[!#].*$" excludenl end="\<end\s*\(program\(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranModule
- syn region fortranModule transparent fold keepend start="^\s*submodule\s\+(\a\w*\s*\(:\a\w*\s*\)*)\s*\z\(\a\w*\)" skip="^\s*[!#].*$" excludenl end="\<end\s*\(submodule\(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranProgram,fortranModule
- syn region fortranModule transparent fold keepend start="^\s*module\s\+\(procedure\)\@!\z(\a\w*\)" skip="^\s*[!#].*$" excludenl end="\<end\s*\(module\(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranProgram
- syn region fortranFunction transparent fold keepend extend start="^\s*\(elemental \|pure \|impure \|module \|recursive \)\=\s*\(\(\(real \|integer \|logical \|complex \|double \s*precision \)\s*\((\(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\|type\s\+(\s*\w\+\s*) \|character \((\(\s*len\s*=\)\=\s*\d\+\s*)\|(\(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\=\s*function\s\+\z(\a\w*\)" skip="^\s*[!#].*$" excludenl end="\<end\s*\($\|function\(\s\+\z1\>\)\=\)" contains=ALLBUT,fortranProgram,fortranModule
- syn region fortranSubroutine transparent fold keepend extend start="^\s*\(elemental \|pure \|impure \|module \|recursive \)\=\s*subroutine\s\+\z(\a\w*\)" skip="^\s*[!#].*$" excludenl end="\<end\s*\($\|subroutine\(\s\+\z1\>\)\=\)" contains=ALLBUT,fortranProgram,fortranModule
+ syn region fortranProgram transparent fold keepend start="^\s*program\s\+\z(\a\w*\)" skip="^\s*[!#].*$" excludenl end="\<end\s*\%(program\%(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranModule
+ syn region fortranModule transparent fold keepend start="^\s*submodule\s\+(\a\w*\s*\%(:\a\w*\s*\)*)\s*\z\(\a\w*\)" skip="^\s*[!#].*$" excludenl end="\<end\s*\%(submodule\%(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranProgram,fortranModule
+ syn region fortranModule transparent fold keepend start="^\s*module\s\+\%(procedure\)\@!\z(\a\w*\)" skip="^\s*[!#].*$" excludenl end="\<end\s*\%(module\%(\s\+\z1\>\)\=\|$\)" contains=ALLBUT,fortranProgram
+ syn region fortranFunction transparent fold keepend extend start="^\s*\%(elemental \|pure \|impure \|module \|recursive \)\=\s*\%(\%(\%(real \|integer \|logical \|complex \|double \s*precision \)\s*\%((\%(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\|type\s\+(\s*\w\+\s*) \|character \%((\%(\s*len\s*=\)\=\s*\d\+\s*)\|(\%(\s*kind\s*=\)\=\s*\w\+\s*)\)\=\)\=\s*function\s\+\z(\a\w*\)" skip="^\s*[!#].*$" excludenl end="\<end\s*\%($\|function\%(\s\+\z1\>\)\=\)" contains=ALLBUT,fortranProgram,fortranModule
+ syn region fortranSubroutine transparent fold keepend extend start="^\s*\%(elemental \|pure \|impure \|module \|recursive \)\=\s*subroutine\s\+\z(\a\w*\)" skip="^\s*[!#].*$" excludenl end="\<end\s*\%($\|subroutine\%(\s\+\z1\>\)\=\)" contains=ALLBUT,fortranProgram,fortranModule
syn region fortranBlockData transparent fold keepend start="\<block\>" skip="^\s*[!#].*$" excludenl end="\<end\s*block\>" contains=ALLBUT,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortran77Loop,fortranCase,fortran90Loop,fortranIfBlock
syn region fortranAssociate transparent fold keepend start="\<associate\>" skip="^\s*[!#].*$" excludenl end="\<end\s*associate\>" contains=ALLBUT,fortranProgram,fortranModule,fortranSubroutine,fortranFunction
syn region fortranCritical transparent fold keepend start="\<critical\>" skip="^\s*[!#].*$" excludenl end="\<end\s*critical\>" contains=ALLBUT,fortranProgram,fortranModule,fortranSubroutine,fortranFunction
syn region fortranTeam transparent fold keepend start="\<change\s\+team\>" skip="^\s*[!#].*$" excludenl end="\<end\s*team\>" contains=ALLBUT,fortranProgram,fortranModule,fortranSubroutine,fortranFunction
- syn region fortranInterface transparent fold keepend extend start="^\s*\(abstract \)\=\s*interface\>" skip="^\s*[!#].*$" excludenl end="\<end\s*interface\>" contains=ALLBUT,fortranProgram,fortranModule,fortran77Loop,fortranCase,fortran90Loop,fortranIfBlock
- syn region fortranTypeDef transparent fold keepend extend start="^\s*type\s*\(,\s*\(public\|private\|abstract\)\)\=\s*::" skip="^\s*[!#].*$" excludenl end="\<end\s*type\>" contains=ALLBUT,fortranProgram,fortranModule,fortran77Loop,fortranCase,fortran90Loop,fortranIfBlock,fortranInterface
+ syn region fortranInterface transparent fold keepend extend start="^\s*\%(abstract \)\=\s*interface\>" skip="^\s*[!#].*$" excludenl end="\<end\s*interface\>" contains=ALLBUT,fortranProgram,fortranModule,fortran77Loop,fortranCase,fortran90Loop,fortranIfBlock
+ syn region fortranTypeDef transparent fold keepend extend start="^\s*type\s*\%(,\s*\%(public\|private\|abstract\)\)\=\s*::" skip="^\s*[!#].*$" excludenl end="\<end\s*type\>" contains=ALLBUT,fortranProgram,fortranModule,fortran77Loop,fortranCase,fortran90Loop,fortranIfBlock,fortranInterface
+ syn region fortranMultiComments fold start="^\zs\s*!.*\_s*!" skip="^\s*!" end='^\ze\s*[^!]'
endif
if exists("fortran_fold_conditionals")
if (b:fortran_fixed_source == 1)
syn region fortran77Loop transparent fold keepend start="\<do\s\+\z(\d\+\)" end="^\s*\z1\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
- syn region fortran90Loop transparent fold keepend extend start="\(\<end\s\+\)\@<!\<do\(\s\+\a\|\s*$\)" skip="^\([!c*]\|\s*#\).*$" excludenl end="\<end\s*do\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
- syn region fortranIfBlock transparent fold keepend extend start="\(\<e\(nd\|lse\)\s\+\)\@<!\<if\s*(.\+)\s*then\>" skip="^\([!c*]\|\s*#\).*$" end="\<end\s*if\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
- syn region fortranCase transparent fold keepend extend start="\<select\s*\(case\|type\|rank\)\>" skip="^\([!c*]\|\s*#\).*$" end="\<end\s*select\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
+ syn region fortran90Loop transparent fold keepend extend start="\%(\<end\s\+\)\@<!\<do\%(\s\+\a\|\s*$\)" skip="^\%([!c*]\|\s*#\).*$" excludenl end="\<end\s*do\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
+ syn region fortranIfBlock transparent fold keepend extend start="\%(\<e\%(nd\|lse\)\s\+\)\@<!\<if\s*(.\+)\s*then\>" skip="^\%([!c*]\|\s*#\).*$" end="\<end\s*if\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
+ syn region fortranCase transparent fold keepend extend start="\<select\s*\%(case\|type\|rank\)\>" skip="^\%([!c*]\|\s*#\).*$" end="\<end\s*select\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
else
syn region fortran77Loop transparent fold keepend start="\<do\s\+\z(\d\+\)" end="^\s*\z1\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
- syn region fortran90Loop transparent fold keepend extend start="\(\<end\s\+\)\@<!\<do\(\s\+\a\|\s*$\)" skip="^\s*[!#].*$" excludenl end="\<end\s*do\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
- syn region fortranIfBlock transparent fold keepend extend start="\(\<e\(nd\|lse\)\s\+\)\@<!\<if\s*(\(.\|&\s*\n\)\+)\(\s\|&\s*\n\)*then\>" skip="^\s*[!#].*$" end="\<end\s*if\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
- syn region fortranCase transparent fold keepend extend start="\<select\s*\(case\|type\|rank\)\>" skip="^\s*[!#].*$" end="\<end\s*select\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
+ syn region fortran90Loop transparent fold keepend extend start="\%(\<end\s\+\)\@<!\<do\%(\s\+\a\|\s*$\)" skip="^\s*[!#].*$" excludenl end="\<end\s*do\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
+ syn region fortranIfBlock transparent fold keepend extend start="\%(\<e\%(nd\|lse\)\s\+\)\@<!\<if\s*(\%(.\|&\s*\n\)\+)\%(\s\|&\s*\n\)*then\>" skip="^\s*[!#].*$" end="\<end\s*if\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
+ syn region fortranCase transparent fold keepend extend start="\<select\s*\%(case\|type\|rank\)\>" skip="^\s*[!#].*$" end="\<end\s*select\>" contains=ALLBUT,fortranUnitHeader,fortranAttribute,fortranStorageClass,fortranType,fortranProgram,fortranModule,fortranSubroutine,fortranFunction,fortranBlockData
endif
endif
- if exists("fortran_fold_multilinecomments")
- if (b:fortran_fixed_source == 1)
- syn match fortranMultiLineComments transparent fold "\(^[!c*].*\(\n\|\%$\)\)\{4,}" contains=ALLBUT,fortranMultiCommentLines
- else
- syn match fortranMultiLineComments transparent fold "\(^\s*!.*\(\n\|\%$\)\)\{4,}" contains=ALLBUT,fortranMultiCommentLines
- endif
- endif
endif
" Define the default highlighting.
-" Transparent groups:
-" fortranParen, fortranLeftMargin
-" fortranProgram, fortranModule, fortranSubroutine, fortranFunction,
-" fortranBlockData
-" fortran77Loop, fortran90Loop, fortranIfBlock, fortranCase
-" fortranMultiCommentLines
hi def link fortranKeyword Keyword
hi def link fortranConstructName Identifier
hi def link fortranConditional Conditional
@@ -481,6 +469,7 @@ hi def link cPreCondit PreCondit
hi def link fortranOpenMP PreProc
hi def link fortranParenError Error
hi def link fortranComment Comment
+hi def link fortranMultiComments Comment
hi def link fortranSerialNumber Todo
hi def link fortranTab Error
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index e494e40204..049c18bba1 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -436,7 +436,7 @@ syn match vimMenuBang "!" contained skipwhite nextgroup=@vimMenuList
" Angle-Bracket Notation: (tnx to Michael Geddes) {{{2
" ======================
syn case ignore
-syn match vimNotation "\%#=1\(\\\|<lt>\)\=<\([scamd]-\)\{0,4}x\=\(f\d\{1,2}\|[^ \t:]\|cmd\|cr\|lf\|linefeed\|return\|enter\|k\=del\%[ete]\|bs\|backspace\|tab\|esc\|right\|left\|help\|undo\|insert\|ins\|mouse\|k\=home\|k\=end\|kplus\|kminus\|kdivide\|kmultiply\|kenter\|kpoint\|space\|k\=\(page\)\=\(\|down\|up\|k\d\>\)\)>" contains=vimBracket
+syn match vimNotation "\%#=1\(\\\|<lt>\)\=<\([scamd]-\)\{0,4}x\=\(f\d\{1,2}\|[^ \t:]\|cmd\|scriptcmd\|cr\|lf\|linefeed\|return\|enter\|k\=del\%[ete]\|bs\|backspace\|tab\|esc\|right\|left\|help\|undo\|insert\|ins\|mouse\|k\=home\|k\=end\|kplus\|kminus\|kdivide\|kmultiply\|kenter\|kpoint\|space\|k\=\(page\)\=\(\|down\|up\|k\d\>\)\)>" contains=vimBracket
syn match vimNotation "\%#=1\(\\\|<lt>\)\=<\([scam2-4]-\)\{0,4}\(right\|left\|middle\)\(mouse\)\=\(drag\|release\)\=>" contains=vimBracket
syn match vimNotation "\%#=1\(\\\|<lt>\)\=<\(bslash\|plug\|sid\|space\|bar\|nop\|nul\|lt\)>" contains=vimBracket
syn match vimNotation '\(\\\|<lt>\)\=<C-R>[0-9a-z"%#:.\-=]'he=e-1 contains=vimBracket
@@ -505,6 +505,13 @@ syn match vimGroupAdd contained "add=" nextgroup=vimGroupList
syn match vimGroupRem contained "remove=" nextgroup=vimGroupList
syn cluster vimFuncBodyList add=vimSynType,vimGroupAdd,vimGroupRem
+" Syntax: foldlevel {{{2
+syn keyword vimSynType contained foldlevel skipwhite nextgroup=vimSynFoldMethod,vimSynFoldMethodError
+if !exists("g:vimsyn_noerror") && !exists("g:vimsyn_novimsynfoldmethoderror")
+ syn match vimSynFoldMethodError contained "\i\+"
+endif
+syn keyword vimSynFoldMethod contained start minimum
+
" Syntax: iskeyword {{{2
syn keyword vimSynType contained iskeyword skipwhite nextgroup=vimIskList
syn match vimIskList contained '\S\+' contains=vimIskSep
@@ -853,6 +860,7 @@ if !exists("skip_vim_syntax_inits")
hi def link vimMapModErr vimError
hi def link vimSubstFlagErr vimError
hi def link vimSynCaseError vimError
+ hi def link vimSynFoldMethodError vimError
hi def link vimBufnrWarn vimWarn
endif
@@ -989,6 +997,8 @@ if !exists("skip_vim_syntax_inits")
hi def link vimSyncNone Type
hi def link vimSynContains vimSynOption
hi def link vimSynError Error
+ hi def link vimSynFoldMethodError Error
+ hi def link vimSynFoldMethod Type
hi def link vimSynKeyContainedin vimSynContains
hi def link vimSynKeyOpt vimSynOption
hi def link vimSynMtchGrp vimSynOption