aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/api.txt20
-rw-r--r--runtime/doc/lsp.txt60
-rw-r--r--runtime/doc/lua.txt14
-rw-r--r--runtime/doc/options.txt6
-rw-r--r--runtime/doc/treesitter.txt3
-rw-r--r--runtime/filetype.vim34
-rw-r--r--runtime/lua/vim/lsp.lua51
-rw-r--r--runtime/lua/vim/lsp/handlers.lua1
-rw-r--r--runtime/lua/vim/treesitter/languagetree.lua18
-rw-r--r--runtime/lua/vim/treesitter/query.lua19
-rw-r--r--runtime/nvim.appdata.xml1
-rw-r--r--runtime/scripts.vim4
12 files changed, 192 insertions, 39 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt
index 12e39fdbac..dd3469372e 100644
--- a/runtime/doc/api.txt
+++ b/runtime/doc/api.txt
@@ -663,6 +663,17 @@ nvim_del_var({name}) *nvim_del_var()*
Parameters: ~
{name} Variable name
+nvim_echo({chunks}, {history}, {opts}) *nvim_echo()*
+ Echo a message.
+
+ Parameters: ~
+ {chunks} A list of [text, hl_group] arrays, each
+ representing a text chunk with specified
+ highlight. `hl_group` element can be omitted
+ for no highlight.
+ {history} if true, add to |message-history|.
+ {opts} Optional parameters. Reserved for future use.
+
nvim_err_write({str}) *nvim_err_write()*
Writes a message to the Vim error buffer. Does not append
"\n", the message is buffered (won't display) until a linefeed
@@ -2152,6 +2163,15 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {opts})
mark will only be used for the current redraw
cycle, and not be permantently stored in the
buffer.
+ • right_gravity : boolean that indicates the
+ direction the extmark will be shifted in when
+ new text is inserted (true for right, false
+ for left). defaults to true.
+ • end_right_gravity : boolean that indicates the
+ direction the extmark end position (if it
+ exists) will be shifted in when new text is
+ inserted (true for right, false for left).
+ Defaults to false.
Return: ~
Id of the created/updated extmark
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index 193593be13..06666c3a27 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -639,8 +639,9 @@ client() *vim.lsp.client*
automatically escalate and force shutdown.
• is_stopped() Checks whether a client is stopped. Returns:
true if the 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.
+ • on_attach(client, bufnr) Runs the on_attach function from
+ the client's config if it was defined. Useful for
+ buffer-local setup.
• Members
• {id} (number): The id allocated to the client.
@@ -678,6 +679,14 @@ get_active_clients() *vim.lsp.get_active_clients()*
Return: ~
Table of |vim.lsp.client| objects
+ *vim.lsp.get_buffers_by_client_id()*
+get_buffers_by_client_id({client_id})
+ Parameters: ~
+ {client_id} client id
+
+ Return: ~
+ list of buffer ids
+
get_client_by_id({client_id}) *vim.lsp.get_client_by_id()*
Gets a client by id, or nil if the id is invalid. The returned
client may not yet be fully initialized.
@@ -776,8 +785,9 @@ start_client({config}) *vim.lsp.start_client()*
{handlers} Map of language server method names to
|lsp-handler|
{settings} Map with language server specific
- settings. These are returned to the language server if
- requested via `workspace/configuration`. Keys are
+ settings. These are returned to the
+ language server if requested via
+ `workspace/configuration` . Keys are
case-sensitive.
{init_options} Values to pass in the initialization
request as `initializationOptions` .
@@ -815,7 +825,14 @@ start_client({config}) *vim.lsp.start_client()*
`capabilities.offsetEncoding` was sent
to it. You can only modify the
`client.offset_encoding` here before
- any notifications are sent.
+ any notifications are sent. Most
+ language servers expect to be sent
+ client specified settings after
+ initialization. Neovim does not make
+ this assumption. A
+ `workspace/didChangeConfiguration`
+ notification should be sent to the
+ server during on_init.
{on_exit} Callback (code, signal, client_id)
invoked on client exit.
• code: exit code of the process
@@ -1342,6 +1359,10 @@ set_signs({diagnostics}, {bufnr}, {client_id}, {sign_ns}, {opts})
{sign_ns} number|nil
{opts} table Configuration for signs. Keys:
• priority: Set the priority of the signs.
+ • severity_limit (DiagnosticSeverity):
+ • Limit severity of diagnostics found.
+ E.g. "Warning" means { "Error",
+ "Warning" } will be valid.
*vim.lsp.diagnostic.set_underline()*
set_underline({diagnostics}, {bufnr}, {client_id}, {diagnostic_ns}, {opts})
@@ -1420,7 +1441,16 @@ show_line_diagnostics({opts}, {bufnr}, {line_nr}, {client_id})
{client_id} number|nil the client id
Return: ~
- {popup_bufnr, win_id}
+ table {popup_bufnr, win_id}
+
+
+==============================================================================
+Lua module: vim.lsp.handlers *lsp-handlers*
+
+ *vim.lsp.handlers.progress_callback()*
+progress_callback({_}, {_}, {params}, {client_id})
+ See also: ~
+ https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_executeCommand
==============================================================================
@@ -1615,6 +1645,9 @@ get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()*
See also: ~
|softtabstop|
+get_progress_messages() *vim.lsp.util.get_progress_messages()*
+ TODO: Documentation
+
jump_to_location({location}) *vim.lsp.util.jump_to_location()*
Jumps to a location.
@@ -1636,6 +1669,19 @@ locations_to_items({locations}) *vim.lsp.util.locations_to_items()*
Return: ~
(table) list of items
+lookup_section({settings}, {section}) *vim.lsp.util.lookup_section()*
+ Helper function to return nested values in language server
+ settings
+
+ Parameters: ~
+ {settings} a table of language server settings
+ {section} a string indicating the field of the settings
+ table
+
+ Return: ~
+ (table or string) The value of settings accessed via
+ section
+
*vim.lsp.util.make_floating_popup_options()*
make_floating_popup_options({width}, {height}, {opts})
Creates a table with sensible default options for a floating
@@ -1716,7 +1762,7 @@ make_workspace_params({added}, {removed})
Create the workspace params
Parameters: ~
- {added}
+ {added}
{removed}
*vim.lsp.util.open_floating_preview()*
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 92898cfad1..0bbed56662 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -1265,14 +1265,12 @@ validate({opt}) *vim.validate()*
vim.validate{arg1={{'foo'}, 'table'}, arg2={'foo', 'string'}}
=> NOP (success)
-<
->
- vim.validate{arg1={1, 'table'}}
- => error('arg1: expected table, got number')
-<
->
- vim.validate{arg1={3, function(a) return (a % 2) == 0 end, 'even number'}}
- => error('arg1: expected even number, got 3')
+
+ vim.validate{arg1={1, 'table'}}
+ => error('arg1: expected table, got number')
+
+ vim.validate{arg1={3, function(a) return (a % 2) == 0 end, 'even number'}}
+ => error('arg1: expected even number, got 3')
<
Parameters: ~
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 2a757bbed9..a497efa47e 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -5536,6 +5536,12 @@ A jump table for the options with a short description can be found at |Q_op|.
"auto" only when there is a sign to display
"auto:[1-9]" resize to accommodate multiple signs up to the
given number (maximum 9), e.g. "auto:4"
+ "auto:[1-8]-[2-9]"
+ resize to accommodate multiple signs up to the
+ given maximum number (maximum 9) while keeping
+ at least the given minimum (maximum 8) fixed
+ space. The minimum number should always be less
+ than the maximum number, e.g. "auto:2-5"
"no" never
"yes" always
"yes:[1-9]" always, with fixed space for signs up to the given
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt
index 911e7b8b47..1696d3b9ba 100644
--- a/runtime/doc/treesitter.txt
+++ b/runtime/doc/treesitter.txt
@@ -195,7 +195,8 @@ query:iter_captures({node}, {bufnr}, {start_row}, {end_row})
text of the buffer. {start_row} and {end_row} can be used to limit
matches inside a row range (this is typically used with root node
as the node, i e to get syntax highlight matches in the current
- viewport)
+ viewport). When omitted the start and end row values are used from
+ the given node.
The iterator returns three values, a numeric id identifying the capture,
the captured node, and metadata from any directives processing the match.
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 9104519451..53fd66c4df 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -585,6 +585,9 @@ au BufNewFile,BufRead *.fan,*.fwt setf fan
" Factor
au BufNewFile,BufRead *.factor setf factor
+" Fennel
+autocmd BufRead,BufNewFile *.fnl setf fennel
+
" Fetchmail RC file
au BufNewFile,BufRead .fetchmailrc setf fetchmail
@@ -1169,9 +1172,10 @@ au BufNewFile,BufRead *.papp,*.pxml,*.pxsl setf papp
" Password file
au BufNewFile,BufRead */etc/passwd,*/etc/passwd-,*/etc/passwd.edit,*/etc/shadow,*/etc/shadow-,*/etc/shadow.edit,*/var/backups/passwd.bak,*/var/backups/shadow.bak setf passwd
-" Pascal (also *.p)
+" Pascal (also *.p, *.pp, *.inc)
au BufNewFile,BufRead *.pas setf pascal
+" Pascal or Puppet manifest
au BufNewFile,BufRead *.pp call dist#ft#FTpp()
" Delphi or Lazarus program file
@@ -1262,7 +1266,7 @@ au BufNewFile,BufRead *.pov setf pov
" Povray configuration
au BufNewFile,BufRead .povrayrc setf povini
-" Povray, PHP or assembly
+" Povray, Pascal, PHP or assembly
au BufNewFile,BufRead *.inc call dist#ft#FTinc()
" Printcap and Termcap
@@ -1271,13 +1275,19 @@ au BufNewFile,BufRead *printcap
au BufNewFile,BufRead *termcap
\ let b:ptcap_type = "term" | setf ptcap
-" PCCTS / ANTRL
-"au BufNewFile,BufRead *.g setf antrl
+" PCCTS / ANTLR
+"au BufNewFile,BufRead *.g setf antlr
au BufNewFile,BufRead *.g setf pccts
" PPWizard
au BufNewFile,BufRead *.it,*.ih setf ppwiz
+" Puppet
+au BufNewFile,BufRead Puppetfile setf ruby
+
+" Embedded Puppet
+au BufNewFile,BufRead *.epp setf epuppet
+
" Obj 3D file format
" TODO: is there a way to avoid MS-Windows Object files?
au BufNewFile,BufRead *.obj setf obj
@@ -1427,8 +1437,8 @@ au BufNewFile,BufRead *.rb,*.rbw setf ruby
" RubyGems
au BufNewFile,BufRead *.gemspec setf ruby
-" Rust
-au BufNewFile,BufRead *.rs setf rust
+" RBS (Ruby Signature)
+au BufNewFile,BufRead *.rbs setf rbs
" Rackup
au BufNewFile,BufRead *.ru setf ruby
@@ -1442,6 +1452,9 @@ au BufNewFile,BufRead *.builder,*.rxml,*.rjs setf ruby
" Rantfile and Rakefile is like Ruby
au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake setf ruby
+" Rust
+au BufNewFile,BufRead *.rs setf rust
+
" S-lang (or shader language, or SmallLisp)
au BufNewFile,BufRead *.sl setf slang
@@ -1733,8 +1746,13 @@ au BufNewFile,BufRead *.tli setf tli
" Telix Salt
au BufNewFile,BufRead *.slt setf tsalt
-" Tera Term Language
-au BufRead,BufNewFile *.ttl setf teraterm
+" Tera Term Language or Turtle
+au BufRead,BufNewFile *.ttl
+ \ if getline(1) =~ '^@\?\(prefix\|base\)' |
+ \ setf turtle |
+ \ else |
+ \ setf teraterm |
+ \ endif
" Terminfo
au BufNewFile,BufRead *.ti setf terminfo
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 9e05eeae89..a6f118abde 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -121,6 +121,9 @@ local active_clients = {}
local all_buffer_active_clients = {}
local uninitialized_clients = {}
+-- Tracks all buffers attached to a client.
+local all_client_active_buffers = {}
+
--@private
--- Invokes a function for each LSP client attached to the buffer {bufnr}.
---
@@ -226,6 +229,7 @@ local function validate_client_config(config)
on_error = { config.on_error, "f", true };
on_exit = { config.on_exit, "f", true };
on_init = { config.on_init, "f", true };
+ settings = { config.settings, "t", true };
before_init = { config.before_init, "f", true };
offset_encoding = { config.offset_encoding, "s", true };
flags = { config.flags, "t", true };
@@ -399,6 +403,10 @@ end
---
--@param handlers Map of language server method names to |lsp-handler|
---
+--@param settings Map with language server specific settings. These are
+--- returned to the language server if requested via `workspace/configuration`.
+--- Keys are case-sensitive.
+---
--@param init_options Values to pass in the initialization request
--- as `initializationOptions`. See `initialize` in the LSP spec.
---
@@ -425,7 +433,10 @@ end
--- the server may send. For example, clangd sends
--- `initialize_result.offsetEncoding` if `capabilities.offsetEncoding` was
--- sent to it. You can only modify the `client.offset_encoding` here before
---- any notifications are sent.
+--- any notifications are sent. Most language servers expect to be sent client specified settings after
+--- initialization. Neovim does not make this assumption. A
+--- `workspace/didChangeConfiguration` notification should be sent
+--- to the server during on_init.
---
--@param on_exit Callback (code, signal, client_id) invoked on client
--- exit.
@@ -458,6 +469,7 @@ function lsp.start_client(config)
local cmd, cmd_args, offset_encoding = cleaned_config.cmd, cleaned_config.cmd_args, cleaned_config.offset_encoding
config.flags = config.flags or {}
+ config.settings = config.settings or {}
local client_id = next_client_id()
@@ -879,9 +891,7 @@ end
function lsp._text_document_did_save_handler(bufnr)
bufnr = resolve_bufnr(bufnr)
local uri = vim.uri_from_bufnr(bufnr)
- local text = once(function()
- return table.concat(nvim_buf_get_lines(bufnr, 0, -1, false), '\n')
- end)
+ local text = once(buf_get_full_text)
for_each_buffer_client(bufnr, function(client, _client_id)
if client.resolved_capabilities.text_document_save then
local included_text
@@ -924,7 +934,7 @@ function lsp.buf_attach_client(bufnr, client_id)
on_lines = text_document_did_change_handler;
on_detach = function()
local params = { textDocument = { uri = uri; } }
- for_each_buffer_client(bufnr, function(client, _client_id)
+ for_each_buffer_client(bufnr, function(client, _)
if client.resolved_capabilities.text_document_open_close then
client.notify('textDocument/didClose', params)
end
@@ -938,6 +948,13 @@ function lsp.buf_attach_client(bufnr, client_id)
utf_sizes = true;
})
end
+
+ if not all_client_active_buffers[client_id] then
+ all_client_active_buffers[client_id] = {}
+ end
+
+ table.insert(all_client_active_buffers[client_id], bufnr)
+
if buffer_client_ids[client_id] then return end
-- This is our first time attaching this client to this buffer.
buffer_client_ids[client_id] = true
@@ -969,6 +986,19 @@ function lsp.get_client_by_id(client_id)
return active_clients[client_id] or uninitialized_clients[client_id]
end
+--- Returns list of buffers attached to client_id.
+--
+--@param client_id client id
+--@returns list of buffer ids
+function lsp.get_buffers_by_client_id(client_id)
+ local active_client_buffers = all_client_active_buffers[client_id]
+ if active_client_buffers then
+ return active_client_buffers
+ else
+ return {}
+ end
+end
+
--- Stops a client(s).
---
--- You can also use the `stop()` function on a |vim.lsp.client| object.
@@ -986,12 +1016,23 @@ end
function lsp.stop_client(client_id, force)
local ids = type(client_id) == 'table' and client_id or {client_id}
for _, id in ipairs(ids) do
+ local resolved_client_id
if type(id) == 'table' and id.stop ~= nil then
id.stop(force)
+ resolved_client_id = id.id
elseif active_clients[id] then
active_clients[id].stop(force)
+ resolved_client_id = id
elseif uninitialized_clients[id] then
uninitialized_clients[id].stop(true)
+ resolved_client_id = id
+ end
+ if resolved_client_id then
+ local client_buffers = lsp.get_buffers_by_client_id(resolved_client_id)
+ for idx = 1, #client_buffers do
+ lsp.diagnostic.clear(client_buffers[idx], resolved_client_id)
+ end
+ all_client_active_buffers[resolved_client_id] = nil
end
end
end
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index b4a1eff316..7eac3febd9 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -162,6 +162,7 @@ M['workspace/configuration'] = function(err, _, params, client_id)
local client = vim.lsp.get_client_by_id(client_id)
if not client then
err_message("LSP[id=", client_id, "] client has shut down after sending the message")
+ return
end
if err then error(vim.inspect(err)) end
if not params.items then
diff --git a/runtime/lua/vim/treesitter/languagetree.lua b/runtime/lua/vim/treesitter/languagetree.lua
index 9c620c422c..c864fe5878 100644
--- a/runtime/lua/vim/treesitter/languagetree.lua
+++ b/runtime/lua/vim/treesitter/languagetree.lua
@@ -425,23 +425,21 @@ function LanguageTree:register_cbs(cbs)
end
end
-local function region_contains(region, range)
- for _, node in ipairs(region) do
- local start_row, start_col, end_row, end_col = node:range()
- local start_fits = start_row < range[1] or (start_row == range[1] and start_col <= range[2])
- local end_fits = end_row > range[3] or (end_row == range[3] and end_col >= range[4])
+local function tree_contains(tree, range)
+ local start_row, start_col, end_row, end_col = tree:root():range()
+ local start_fits = start_row < range[1] or (start_row == range[1] and start_col <= range[2])
+ local end_fits = end_row > range[3] or (end_row == range[3] and end_col >= range[4])
- if start_fits and end_fits then
- return true
- end
+ if start_fits and end_fits then
+ return true
end
return false
end
function LanguageTree:contains(range)
- for _, region in pairs(self._regions) do
- if region_contains(region, range) then
+ for _, tree in pairs(self._trees) do
+ if tree_contains(tree, range) then
return true
end
end
diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua
index 5a27d740a2..e49f54681d 100644
--- a/runtime/lua/vim/treesitter/query.lua
+++ b/runtime/lua/vim/treesitter/query.lua
@@ -340,6 +340,19 @@ function Query:apply_directives(match, pattern, source, metadata)
end
end
+
+--- Returns the start and stop value if set else the node's range.
+-- When the node's range is used, the stop is incremented by 1
+-- to make the search inclusive.
+local function value_or_node_range(start, stop, node)
+ if start == nil and stop == nil then
+ local node_start, _, node_stop, _ = node:range()
+ return node_start, node_stop + 1 -- Make stop inclusive
+ end
+
+ return start, stop
+end
+
--- Iterates of the captures of self on a given range.
--
-- @param node The node under witch the search will occur
@@ -353,6 +366,9 @@ function Query:iter_captures(node, source, start, stop)
if type(source) == "number" and source == 0 then
source = vim.api.nvim_get_current_buf()
end
+
+ start, stop = value_or_node_range(start, stop, node)
+
local raw_iter = node:_rawquery(self.query, true, start, stop)
local function iter()
local capture, captured_node, match = raw_iter()
@@ -385,6 +401,9 @@ function Query:iter_matches(node, source, start, stop)
if type(source) == "number" and source == 0 then
source = vim.api.nvim_get_current_buf()
end
+
+ start, stop = value_or_node_range(start, stop, node)
+
local raw_iter = node:_rawquery(self.query, false, start, stop)
local function iter()
local pattern, match = raw_iter()
diff --git a/runtime/nvim.appdata.xml b/runtime/nvim.appdata.xml
index 025de1b5a9..e99c76a930 100644
--- a/runtime/nvim.appdata.xml
+++ b/runtime/nvim.appdata.xml
@@ -26,6 +26,7 @@
</screenshots>
<releases>
+ <release date="2020-08-04" version="0.4.4"/>
<release date="2019-11-06" version="0.4.3"/>
<release date="2019-09-15" version="0.4.2"/>
<release date="2019-09-15" version="0.4.1"/>
diff --git a/runtime/scripts.vim b/runtime/scripts.vim
index 536993d485..3b3409bf4b 100644
--- a/runtime/scripts.vim
+++ b/runtime/scripts.vim
@@ -186,6 +186,10 @@ if s:line1 =~# "^#!"
elseif s:name =~# 'instantfpc\>'
set ft=pascal
+ " Fennel
+ elseif s:name =~# 'fennel\>'
+ set ft=fennel
+
endif
unlet s:name