aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/cmdline.txt6
-rw-r--r--runtime/doc/map.txt16
-rw-r--r--runtime/doc/options.txt5
-rw-r--r--runtime/doc/quickfix.txt7
-rw-r--r--runtime/doc/repeat.txt5
-rw-r--r--runtime/filetype.vim2
-rw-r--r--runtime/ftplugin/meson.vim1
-rw-r--r--runtime/ftplugin/systemverilog.vim35
-rw-r--r--runtime/indent/meson.vim1
-rw-r--r--runtime/lua/vim/lsp/handlers.lua27
-rw-r--r--runtime/lua/vim/lsp/rpc.lua28
-rw-r--r--runtime/lua/vim/lsp/util.lua91
-rw-r--r--runtime/pack/dist/opt/termdebug/plugin/termdebug.vim6
-rw-r--r--runtime/syntax/dts.vim54
-rw-r--r--runtime/syntax/meson.vim53
15 files changed, 238 insertions, 99 deletions
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index ae43aeeb25..dcdc2384dc 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -759,13 +759,15 @@ three lines: >
3:d<CR> is translated into: .,.+2d<CR>
<
-Visual Mode and Range *v_:*
- *:star-visual-range*
+Visual Mode and Range
+ *v_:*
{Visual}: Starts a command-line with the Visual selected lines as a
range. The code `:'<,'>` is used for this range, which makes
it possible to select a similar line from the command-line
history for repeating a command on different Visually selected
lines.
+
+:* *:star* *:star-visual-range*
When Visual mode was already ended, a short way to use the
Visual area for a range is `:*`.
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index ee42edf154..77cbf7d9b7 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -360,6 +360,22 @@ Overview of which map command works in which mode. More details below.
:cmap :cnoremap :cunmap Command-line
:tmap :tnoremap :tunmap Terminal
+Same information in a table:
+ *map-table*
+ Mode | Norm | Ins | Cmd | Vis | Sel | Opr | Term | Lang | ~
+Command +------+-----+-----+-----+-----+-----+------+------+ ~
+[nore]map | yes | - | - | yes | yes | yes | - | - |
+n[nore]map | yes | - | - | - | - | - | - | - |
+[nore]map! | - | yes | yes | - | - | - | - | - |
+i[nore]map | - | yes | - | - | - | - | - | - |
+c[nore]map | - | - | yes | - | - | - | - | - |
+v[nore]map | - | - | - | yes | yes | - | - | - |
+x[nore]map | - | - | - | yes | - | - | - | - |
+s[nore]map | - | - | - | - | yes | - | - | - |
+o[nore]map | - | - | - | - | - | yes | - | - |
+t[nore]map | - | - | - | - | - | - | yes | - |
+l[nore]map | - | yes | yes | - | - | - | - | yes |
+
COMMANDS MODES ~
Normal Visual+Select Operator-pending ~
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index fd7af55e87..cc9696e536 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -595,10 +595,6 @@ A jump table for the options with a short description can be found at |Q_op|.
set to one of CJK locales. See Unicode Standard Annex #11
(http://www.unicode.org/reports/tr11).
- Vim may set this option automatically at startup time when Vim is
- compiled with the |+termresponse| feature and if t_u7 is set to the
- escape sequence to request cursor position report.
-
*'autochdir'* *'acd'* *'noautochdir'* *'noacd'*
'autochdir' 'acd' boolean (default off)
global
@@ -5056,6 +5052,7 @@ A jump table for the options with a short description can be found at |Q_op|.
global values for local options)
options all options and mappings (also global values for local
options)
+ skiprtp exclude 'runtimepath' and 'packpath' from the options
resize size of the Vim window: 'lines' and 'columns'
sesdir the directory in which the session file is located
will become the current directory (useful with
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index c67e52bd42..a937cfee98 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -1014,13 +1014,6 @@ commands can be combined to create a NewGrep command: >
updated. With the [!] any changes in the current
buffer are abandoned.
- 'f' When the 'f' flag is specified, fuzzy string
- matching is used to find matching lines. In this
- case, {pattern} is treated as a literal string
- instead of a regular expression. See
- |matchfuzzy()| for more info about fuzzy
- matching.
-
|QuickFixCmdPre| and |QuickFixCmdPost| are triggered.
A file that is opened for matching may use a buffer
number, but it is reused if possible to avoid
diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt
index b237d70760..dd05084652 100644
--- a/runtime/doc/repeat.txt
+++ b/runtime/doc/repeat.txt
@@ -50,6 +50,11 @@ Multiple repeats *multi-repeat*
:[range]v[global]/{pattern}/[cmd]
Same as :g!.
+Example: >
+ :g/^Obsolete/d _
+Using the underscore after `:d` avoids clobbering registers or the clipboard.
+This also makes it faster.
+
Instead of the '/' which surrounds the {pattern}, you can use any other
single byte character, but not an alphabetic character, '\', '"' or '|'.
This is useful if you want to include a '/' in the search pattern or
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 474a447284..ed70ac5ce8 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -714,7 +714,7 @@ au BufNewFile,BufRead *.haml setf haml
au BufNewFile,BufRead *.hsm setf hamster
" Haskell
-au BufNewFile,BufRead *.hs,*.hsc,*.hs-boot setf haskell
+au BufNewFile,BufRead *.hs,*.hsc,*.hs-boot,*.hsig setf haskell
au BufNewFile,BufRead *.lhs setf lhaskell
au BufNewFile,BufRead *.chs setf chaskell
au BufNewFile,BufRead cabal.project setf cabalproject
diff --git a/runtime/ftplugin/meson.vim b/runtime/ftplugin/meson.vim
index e432ebf196..d48fa1dfd1 100644
--- a/runtime/ftplugin/meson.vim
+++ b/runtime/ftplugin/meson.vim
@@ -1,6 +1,7 @@
" Vim filetype plugin file
" Language: meson
" License: VIM License
+" Maintainer: Liam Beguin <liambeguin@gmail.com>
" Original Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
" Last Change: 2018 Nov 27
diff --git a/runtime/ftplugin/systemverilog.vim b/runtime/ftplugin/systemverilog.vim
index 4d0f565fcc..e350427022 100644
--- a/runtime/ftplugin/systemverilog.vim
+++ b/runtime/ftplugin/systemverilog.vim
@@ -1,7 +1,7 @@
" Vim filetype plugin file
" Language: SystemVerilog
" Maintainer: kocha <kocha.lsifrontend@gmail.com>
-" Last Change: 12-Aug-2013.
+" Last Change: 07-May-2021
if exists("b:did_ftplugin")
finish
@@ -9,3 +9,36 @@ endif
" Behaves just like Verilog
runtime! ftplugin/verilog.vim
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+" Add SystemVerilog keywords for matchit plugin.
+if exists("loaded_matchit")
+ let b:match_words =
+ \ '\<begin\>:\<end\>,' .
+ \ '\<case\>\|\<casex\>\|\<casez\>:\<endcase\>,' .
+ \ '\<module\>:\<endmodule\>,' .
+ \ '\<if\>:`\@<!\<else\>,' .
+ \ '\<function\>:\<endfunction\>,' .
+ \ '`ifn\?def\>:`elsif\>:`else\>:`endif\>,' .
+ \ '\<task\>:\<endtask\>,' .
+ \ '\<specify\>:\<endspecify\>,' .
+ \ '\<config\>:\<endconfig\>,' .
+ \ '\<generate\>:\<endgenerate\>,' .
+ \ '\<fork\>:\<join\>\|\<join_any\>\|\<join_none\>,' .
+ \ '\<primitive\>:\<endprimitive\>,' .
+ \ '\<table\>:\<endtable\>,' .
+ \ '\<checker\>:\<endchecker\>,' .
+ \ '\<class\>:\<endclass\>,' .
+ \ '\<clocking\>:\<endclocking\>,' .
+ \ '\<gruop\>:\<endgruop\>,' .
+ \ '\<interface\>:\<endinterface\>,' .
+ \ '\<package\>:\<endpackage\>,' .
+ \ '\<program\>:\<endprogram\>,' .
+ \ '\<property\>:\<endproperty\>,' .
+ \ '\<sequence\>:\<endsequence\>'
+endif
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
diff --git a/runtime/indent/meson.vim b/runtime/indent/meson.vim
index f116781f74..549209ca33 100644
--- a/runtime/indent/meson.vim
+++ b/runtime/indent/meson.vim
@@ -2,6 +2,7 @@
" Language: Meson
" License: VIM License
" Maintainer: Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+" Liam Beguin <liambeguin@gmail.com>
" Original Authors: David Bustos <bustos@caltech.edu>
" Bram Moolenaar <Bram@vim.org>
" Last Change: 2019 Oct 18
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index 525ec4ce5b..18155ceb7e 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -271,9 +271,7 @@ function M.hover(_, method, result, _, _, config)
-- return { 'No information available' }
return
end
- local bufnr, winnr = util.fancy_floating_markdown(markdown_lines, {
- border = config.border
- })
+ local bufnr, winnr = util.fancy_floating_markdown(markdown_lines, config)
util.close_preview_autocmd({"CursorMoved", "BufHidden", "InsertCharPre"}, winnr)
return bufnr, winnr
end)
@@ -341,17 +339,20 @@ function M.signature_help(_, method, result, _, bufnr, config)
print('No signature help available')
return
end
- local lines = util.convert_signature_help_to_markdown_lines(result)
- lines = util.trim_empty_lines(lines)
- if vim.tbl_isempty(lines) then
- print('No signature help available')
- return
- end
- local syntax = api.nvim_buf_get_option(bufnr, 'syntax')
- local p_bufnr, _ = util.focusable_preview(method, function()
- return lines, util.try_trim_markdown_code_blocks(lines), config
+ local p_bufnr, winnr = util.focusable_float(method, function()
+ local ft = api.nvim_buf_get_option(bufnr, 'filetype')
+ local lines = util.convert_signature_help_to_markdown_lines(result, ft)
+ lines = util.trim_empty_lines(lines)
+ if vim.tbl_isempty(lines) then
+ print('No signature help available')
+ return
+ end
+ local p_bufnr, p_winnr = util.fancy_floating_markdown(lines, config)
+ util.close_preview_autocmd({"CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre"}, p_winnr)
+
+ return p_bufnr, p_winnr
end)
- api.nvim_buf_set_option(p_bufnr, 'syntax', syntax)
+ return p_bufnr, winnr
end
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua
index 0cabd1a0d4..98835d6708 100644
--- a/runtime/lua/vim/lsp/rpc.lua
+++ b/runtime/lua/vim/lsp/rpc.lua
@@ -523,27 +523,33 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params)
decoded.error = convert_NIL(decoded.error)
decoded.result = convert_NIL(decoded.result)
+ -- We sent a number, so we expect a number.
+ local result_id = tonumber(decoded.id)
+
-- Do not surface RequestCancelled or ContentModified to users, it is RPC-internal.
if decoded.error then
+ local mute_error = false
if decoded.error.code == protocol.ErrorCodes.RequestCancelled then
local _ = log.debug() and log.debug("Received cancellation ack", decoded)
+ mute_error = true
elseif decoded.error.code == protocol.ErrorCodes.ContentModified then
local _ = log.debug() and log.debug("Received content modified ack", decoded)
+ mute_error = true
end
- local result_id = tonumber(decoded.id)
- -- Clear any callback since this is cancelled now.
- -- This is safe to do assuming that these conditions hold:
- -- - The server will not send a result callback after this cancellation.
- -- - If the server sent this cancellation ACK after sending the result, the user of this RPC
- -- client will ignore the result themselves.
- if result_id then
- message_callbacks[result_id] = nil
+
+ if mute_error then
+ -- Clear any callback since this is cancelled now.
+ -- This is safe to do assuming that these conditions hold:
+ -- - The server will not send a result callback after this cancellation.
+ -- - If the server sent this cancellation ACK after sending the result, the user of this RPC
+ -- client will ignore the result themselves.
+ if result_id then
+ message_callbacks[result_id] = nil
+ end
+ return
end
- return
end
- -- We sent a number, so we expect a number.
- local result_id = tonumber(decoded.id)
local callback = message_callbacks[result_id]
if callback then
message_callbacks[result_id] = nil
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 83aa6747d2..7809c9b7e3 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -4,6 +4,7 @@ local validate = vim.validate
local api = vim.api
local list_extend = vim.list_extend
local highlight = require 'vim.highlight'
+local uv = vim.loop
local npcall = vim.F.npcall
local split = vim.split
@@ -73,7 +74,7 @@ function M.set_lines(lines, A, B, new_lines)
-- way the LSP describes the range including the last newline is by
-- specifying a line number after what we would call the last line.
local i_n = math.min(B[1] + 1, #lines)
- if not (i_0 >= 1 and i_0 <= #lines and i_n >= 1 and i_n <= #lines) then
+ if not (i_0 >= 1 and i_0 <= #lines + 1 and i_n >= 1 and i_n <= #lines) then
error("Invalid range: "..vim.inspect{A = A; B = B; #lines, new_lines})
end
local prefix = ""
@@ -804,9 +805,10 @@ end
--- Converts `textDocument/SignatureHelp` response to markdown lines.
---
--@param signature_help Response of `textDocument/SignatureHelp`
+--@param ft optional filetype that will be use as the `lang` for the label markdown code block
--@returns list of lines of converted markdown.
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_signatureHelp
-function M.convert_signature_help_to_markdown_lines(signature_help)
+function M.convert_signature_help_to_markdown_lines(signature_help, ft)
if not signature_help.signatures then
return
end
@@ -824,7 +826,12 @@ function M.convert_signature_help_to_markdown_lines(signature_help)
if not signature then
return
end
- vim.list_extend(contents, vim.split(signature.label, '\n', true))
+ local label = signature.label
+ if ft then
+ -- wrap inside a code block so fancy_markdown can render it properly
+ label = ("```%s\n%s\n```"):format(ft, label)
+ end
+ vim.list_extend(contents, vim.split(label, '\n', true))
if signature.documentation then
M.convert_input_to_markdown_lines(signature.documentation, contents)
end
@@ -951,7 +958,7 @@ end
---
--@param location a single `Location` or `LocationLink`
--@returns (bufnr,winnr) buffer and window number of floating window or nil
-function M.preview_location(location)
+function M.preview_location(location, opts)
-- location may be LocationLink or Location (more useful for the former)
local uri = location.targetUri or location.uri
if uri == nil then return end
@@ -962,7 +969,13 @@ function M.preview_location(location)
local range = location.targetRange or location.range
local contents = api.nvim_buf_get_lines(bufnr, range.start.line, range["end"].line+1, false)
local syntax = api.nvim_buf_get_option(bufnr, 'syntax')
- return M.open_floating_preview(contents, syntax)
+ if syntax == "" then
+ -- When no syntax is set, we use filetype as fallback. This might not result
+ -- in a valid syntax definition. See also ft detection in fancy_floating_win.
+ -- An empty syntax is more common now with TreeSitter, since TS disables syntax.
+ syntax = api.nvim_buf_get_option(bufnr, 'filetype')
+ end
+ return M.open_floating_preview(contents, syntax, opts)
end
--@private
@@ -1154,34 +1167,29 @@ function M.fancy_floating_markdown(contents, opts)
api.nvim_win_set_option(winnr, 'conceallevel', 2)
api.nvim_win_set_option(winnr, 'concealcursor', 'n')
+ vim.cmd("ownsyntax lsp_markdown")
+
local idx = 1
--@private
local function apply_syntax_to_region(ft, start, finish)
if ft == "" then
- vim.cmd(string.format("syntax region markdownCodeBlock start=+\\%%%dl+ end=+\\%%%dl+ keepend extend", start, finish + 1))
+ vim.cmd(string.format("syntax region markdownCode start=+\\%%%dl+ end=+\\%%%dl+ keepend extend", start, finish + 1))
return
end
local name = ft..idx
idx = idx + 1
local lang = "@"..ft:upper()
+ -- HACK: reset current_syntax, since some syntax files like markdown won't load if it is already set
+ pcall(vim.api.nvim_buf_del_var, bufnr, "current_syntax")
-- TODO(ashkan): better validation before this.
if not pcall(vim.cmd, string.format("syntax include %s syntax/%s.vim", lang, ft)) then
return
end
vim.cmd(string.format("syntax region %s start=+\\%%%dl+ end=+\\%%%dl+ contains=%s keepend", name, start, finish + 1, lang))
end
- -- Previous highlight region.
- local ph = 1
+
for _, h in ipairs(highlights) do
- if ph <= h.start - 1 then
- apply_syntax_to_region('lsp_markdown', ph, h.start - 1)
- end
apply_syntax_to_region(h.ft, h.start, h.finish)
- ph = h.finish + 1
- end
-
- if ph <= #stripped then
- apply_syntax_to_region('lsp_markdown', ph, #stripped)
end
vim.api.nvim_set_current_win(cwin)
@@ -1354,6 +1362,45 @@ local position_sort = sort_by_key(function(v)
return {v.start.line, v.start.character}
end)
+-- Gets the zero-indexed line from the given uri.
+-- For non-file uris, we load the buffer and get the line.
+-- If a loaded buffer exists, then that is used.
+-- Otherwise we get the line using libuv which is a lot faster than loading the buffer.
+--@param uri string uri of the resource to get the line from
+--@param row number zero-indexed line number
+--@return string the line at row in filename
+function M.get_line(uri, row)
+ -- load the buffer if this is not a file uri
+ -- Custom language server protocol extensions can result in servers sending URIs with custom schemes. Plugins are able to load these via `BufReadCmd` autocmds.
+ if uri:sub(1, 4) ~= "file" then
+ local bufnr = vim.uri_to_bufnr(uri)
+ vim.fn.bufload(bufnr)
+ return (vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false) or { "" })[1]
+ end
+
+ local filename = vim.uri_to_fname(uri)
+
+ -- use loaded buffers if available
+ if vim.fn.bufloaded(filename) == 1 then
+ local bufnr = vim.fn.bufnr(filename, false)
+ return (vim.api.nvim_buf_get_lines(bufnr, row, row + 1, false) or { "" })[1]
+ end
+
+ local fd = uv.fs_open(filename, "r", 438)
+ -- TODO: what should we do in this case?
+ if not fd then return "" end
+ local stat = uv.fs_fstat(fd)
+ local data = uv.fs_read(fd, stat.size, 0)
+ uv.fs_close(fd)
+
+ local lnum = 0
+ for line in string.gmatch(data, "([^\n]*)\n?") do
+ if lnum == row then return line end
+ lnum = lnum + 1
+ end
+ return ""
+end
+
--- Returns the items with the byte position calculated correctly and in sorted
--- order, for display in quickfix and location lists.
---
@@ -1382,14 +1429,12 @@ function M.locations_to_items(locations)
for _, uri in ipairs(keys) do
local rows = grouped[uri]
table.sort(rows, position_sort)
- local bufnr = vim.uri_to_bufnr(uri)
- vim.fn.bufload(bufnr)
local filename = vim.uri_to_fname(uri)
for _, temp in ipairs(rows) do
local pos = temp.start
local row = pos.line
- local line = (api.nvim_buf_get_lines(bufnr, row, row + 1, false) or {""})[1]
- local col = M.character_offset(bufnr, row, pos.character)
+ local line = M.get_line(uri, row)
+ local col = pos.character
table.insert(items, {
filename = filename,
lnum = row + 1,
@@ -1447,13 +1492,13 @@ function M.symbols_to_items(symbols, bufnr)
kind = kind,
text = '['..kind..'] '..symbol.name,
})
- elseif symbol.range then -- DocumentSymbole type
+ elseif symbol.selectionRange then -- DocumentSymbole type
local kind = M._get_symbol_kind_name(symbol.kind)
table.insert(_items, {
-- bufnr = _bufnr,
filename = vim.api.nvim_buf_get_name(_bufnr),
- lnum = symbol.range.start.line + 1,
- col = symbol.range.start.character + 1,
+ lnum = symbol.selectionRange.start.line + 1,
+ col = symbol.selectionRange.start.character + 1,
kind = kind,
text = '['..kind..'] '..symbol.name
})
diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
index a62df1dcec..ae1274f81f 100644
--- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
+++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
@@ -2,7 +2,7 @@
"
" Author: Bram Moolenaar
" Copyright: Vim license applies, see ":help license"
-" Last Change: 2021 Jan 03
+" Last Change: 2021 May 16
"
" WORK IN PROGRESS - Only the basics work
" Note: On MS-Windows you need a recent version of gdb. The one included with
@@ -246,7 +246,9 @@ func s:StartDebug_term(dict)
let s:gdbbuf = gdb_job_info['buffer']
let s:gdbwin = win_getid(winnr())
- " Set arguments to be run
+ " Set arguments to be run. First wait a bit to make detecting gdb a bit
+ " more reliable.
+ sleep 200m
if len(proc_args)
call chansend(s:gdb_job_id, 'set args ' . join(proc_args) . "\r")
endif
diff --git a/runtime/syntax/dts.vim b/runtime/syntax/dts.vim
index cd4bd776b7..d75b9c178a 100644
--- a/runtime/syntax/dts.vim
+++ b/runtime/syntax/dts.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: dts/dtsi (device tree files)
" Maintainer: Daniel Mack <vim@zonque.org>
-" Last Change: 2013 Oct 20
+" Last Change: 2021 May 15
if exists("b:current_syntax")
finish
@@ -9,7 +9,7 @@ endif
syntax region dtsComment start="/\*" end="\*/"
syntax match dtsReference "&[[:alpha:][:digit:]_]\+"
-syntax region dtsBinaryProperty start="\[" end="\]"
+syntax region dtsBinaryProperty start="\[" end="\]"
syntax match dtsStringProperty "\".*\""
syntax match dtsKeyword "/.\{-1,\}/"
syntax match dtsLabel "^[[:space:]]*[[:alpha:][:digit:]_]\+:"
@@ -18,6 +18,38 @@ syntax region dtsCellProperty start="<" end=">" contains=dtsReference,dtsBinar
syntax region dtsCommentInner start="/\*" end="\*/"
syntax match dtsCommentLine "//.*$"
+" Accept %: for # (C99)
+syn region cPreCondit start="^\s*\zs\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError
+syn match cPreConditMatch display "^\s*\zs\(%:\|#\)\s*\(else\|endif\)\>"
+if !exists("c_no_if0")
+ syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip
+ syn region cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold
+ syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse
+ if !exists("c_no_if0_fold")
+ syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell fold
+ else
+ syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
+ endif
+ syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit
+ syn region cCppInWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold
+ syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit
+ if !exists("c_no_if0_fold")
+ syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold
+ else
+ syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2
+ endif
+ syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
+ syn region cCppOutSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip
+ syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc
+endif
+syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
+syn match cIncluded display contained "<[^>]*>"
+syn match cInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
+"syn match cLineSkip "\\$"
+syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti,cBadBlock
+syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
+syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
+
hi def link dtsCellProperty Number
hi def link dtsBinaryProperty Number
hi def link dtsStringProperty String
@@ -26,5 +58,21 @@ hi def link dtsLabel Label
hi def link dtsNode Structure
hi def link dtsReference Macro
hi def link dtsComment Comment
-hi def link dtsCommentInner Comment
+hi def link dtsCommentInner Comment
hi def link dtsCommentLine Comment
+
+hi def link cInclude Include
+hi def link cPreProc PreProc
+hi def link cDefine Macro
+hi def link cIncluded cString
+hi def link cString String
+
+hi def link cCppInWrapper cCppOutWrapper
+hi def link cCppOutWrapper cPreCondit
+hi def link cPreConditMatch cPreCondit
+hi def link cPreCondit PreCondit
+hi def link cCppOutSkip cCppOutIf2
+
+hi def link cCppInElse2 cCppOutIf2
+hi def link cCppOutIf2 cCppOut
+hi def link cCppOut Comment
diff --git a/runtime/syntax/meson.vim b/runtime/syntax/meson.vim
index 78de2ab89e..7e6b565f19 100644
--- a/runtime/syntax/meson.vim
+++ b/runtime/syntax/meson.vim
@@ -2,6 +2,7 @@
" Language: Meson
" License: VIM License
" Maintainer: Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+" Liam Beguin <liambeguin@gmail.com>
" Last Change: 2019 Oct 18
" Credits: Zvezdan Petkovic <zpetkovic@acm.org>
" Neil Schemenauer <nas@meson.ca>
@@ -17,11 +18,7 @@
" let meson_space_error_highlight = 1
"
-" For version 5.x: Clear all syntax items.
-" For version 6.x: Quit when a syntax file was already loaded.
-if version < 600
- syntax clear
-elseif exists("b:current_syntax")
+if exists("b:current_syntax")
finish
endif
@@ -32,8 +29,9 @@ set cpo&vim
" http://mesonbuild.com/Syntax.html
syn keyword mesonConditional elif else if endif
-syn keyword mesonRepeat foreach endforeach
-syn keyword mesonOperator and not or
+syn keyword mesonRepeat foreach endforeach
+syn keyword mesonOperator and not or in
+syn keyword mesonStatement continue break
syn match mesonComment "#.*$" contains=mesonTodo,@Spell
syn keyword mesonTodo FIXME NOTE NOTES TODO XXX contained
@@ -117,10 +115,12 @@ syn keyword mesonBuiltin
\ subdir
\ subdir_done
\ subproject
+ \ summary
\ target_machine
\ test
\ vcs_tag
\ warning
+ \ range
if exists("meson_space_error_highlight")
" trailing whitespace
@@ -130,31 +130,20 @@ if exists("meson_space_error_highlight")
syn match mesonSpaceError display "\t\+ "
endif
-if version >= 508 || !exists("did_meson_syn_inits")
- if version <= 508
- let did_meson_syn_inits = 1
- command -nargs=+ HiLink hi link <args>
- else
- command -nargs=+ HiLink hi def link <args>
- endif
-
- " The default highlight links. Can be overridden later.
- HiLink mesonStatement Statement
- HiLink mesonConditional Conditional
- HiLink mesonRepeat Repeat
- HiLink mesonOperator Operator
- HiLink mesonComment Comment
- HiLink mesonTodo Todo
- HiLink mesonString String
- HiLink mesonEscape Special
- HiLink mesonNumber Number
- HiLink mesonBuiltin Function
- HiLink mesonConstant Number
- if exists("meson_space_error_highlight")
- HiLink mesonSpaceError Error
- endif
-
- delcommand HiLink
+" The default highlight links. Can be overridden later.
+hi def link mesonStatement Statement
+hi def link mesonConditional Conditional
+hi def link mesonRepeat Repeat
+hi def link mesonOperator Operator
+hi def link mesonComment Comment
+hi def link mesonTodo Todo
+hi def link mesonString String
+hi def link mesonEscape Special
+hi def link mesonNumber Number
+hi def link mesonBuiltin Function
+hi def link mesonConstant Number
+if exists("meson_space_error_higlight")
+ hi def link mesonSpaceError Error
endif
let b:current_syntax = "meson"