aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/_meta/api.lua3
-rw-r--r--runtime/lua/vim/_meta/builtin_types.lua4
-rw-r--r--runtime/lua/vim/_meta/options.lua2
-rw-r--r--runtime/lua/vim/_meta/vimfn.lua4
-rw-r--r--runtime/lua/vim/diagnostic.lua5
-rw-r--r--runtime/lua/vim/health.lua8
-rw-r--r--runtime/lua/vim/iter.lua6
-rw-r--r--runtime/lua/vim/lsp.lua16
-rw-r--r--runtime/lua/vim/lsp/buf.lua2
-rw-r--r--runtime/lua/vim/lsp/completion.lua10
-rw-r--r--runtime/lua/vim/lsp/rpc.lua6
-rw-r--r--runtime/lua/vim/lsp/util.lua2
-rw-r--r--runtime/lua/vim/shared.lua3
13 files changed, 44 insertions, 27 deletions
diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua
index b890b64174..63a7bcc37d 100644
--- a/runtime/lua/vim/_meta/api.lua
+++ b/runtime/lua/vim/_meta/api.lua
@@ -630,8 +630,7 @@ function vim.api.nvim_buf_line_count(buffer) end
--- otherwise the same as "trunc".
--- - ephemeral : for use with `nvim_set_decoration_provider()`
--- callbacks. The mark will only be used for the current
---- redraw cycle, and not be permantently stored in the
---- buffer.
+--- redraw cycle, and not be permanently 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.
diff --git a/runtime/lua/vim/_meta/builtin_types.lua b/runtime/lua/vim/_meta/builtin_types.lua
index eae76d80d7..9dd0374486 100644
--- a/runtime/lua/vim/_meta/builtin_types.lua
+++ b/runtime/lua/vim/_meta/builtin_types.lua
@@ -259,12 +259,12 @@
--- write. The number is the write count. The
--- first write has number 1, the last one the
--- "save_last" mentioned above.
---- @field save integer
+--- @field save? integer
---
--- Alternate entry. This is again a List of undo
--- blocks. Each item may again have an "alt"
--- item.
---- @field alt vim.fn.undotree.entry[]
+--- @field alt? vim.fn.undotree.entry[]
--- @class vim.fn.undotree.ret
---
diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua
index 59e65b0585..775dda59f7 100644
--- a/runtime/lua/vim/_meta/options.lua
+++ b/runtime/lua/vim/_meta/options.lua
@@ -1109,7 +1109,7 @@ vim.go.cia = vim.go.completeitemalign
--- combination with "menu" or "menuone".
---
--- @type string
-vim.o.completeopt = "menu,preview"
+vim.o.completeopt = "menu,popup"
vim.o.cot = vim.o.completeopt
vim.bo.completeopt = vim.o.completeopt
vim.bo.cot = vim.bo.completeopt
diff --git a/runtime/lua/vim/_meta/vimfn.lua b/runtime/lua/vim/_meta/vimfn.lua
index 6ffd0e9619..2b4f1a32b0 100644
--- a/runtime/lua/vim/_meta/vimfn.lua
+++ b/runtime/lua/vim/_meta/vimfn.lua
@@ -5868,7 +5868,7 @@ function vim.fn.matchend(expr, pat, start, count) end
---
--- @param list any[]
--- @param str string
---- @param dict? string
+--- @param dict? table
--- @return any
function vim.fn.matchfuzzy(list, str, dict) end
@@ -5895,7 +5895,7 @@ function vim.fn.matchfuzzy(list, str, dict) end
---
--- @param list any[]
--- @param str string
---- @param dict? string
+--- @param dict? table
--- @return any
function vim.fn.matchfuzzypos(list, str, dict) end
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 1473b8dd47..2cfa97ac40 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -1871,7 +1871,10 @@ local function render_virtual_lines(namespace, bufnr, diagnostics)
end
end
- api.nvim_buf_set_extmark(bufnr, namespace, lnum, 0, { virt_lines = virt_lines })
+ api.nvim_buf_set_extmark(bufnr, namespace, lnum, 0, {
+ virt_lines_overflow = 'scroll',
+ virt_lines = virt_lines,
+ })
end
end
diff --git a/runtime/lua/vim/health.lua b/runtime/lua/vim/health.lua
index 0d42e8fed6..75cbfdef4a 100644
--- a/runtime/lua/vim/health.lua
+++ b/runtime/lua/vim/health.lua
@@ -118,7 +118,13 @@ local function filepath_to_healthcheck(path)
func = 'health#' .. name .. '#check'
filetype = 'v'
else
- local subpath = path:gsub('.*/lua/', '')
+ local rtp = vim
+ .iter(vim.api.nvim_list_runtime_paths())
+ :map(vim.fs.normalize)
+ :find(function(rtp0)
+ return vim.fs.relpath(rtp0, path)
+ end)
+ local subpath = path:gsub('^' .. vim.pesc(rtp .. '/lua/'), '')
if vim.fs.basename(subpath) == 'health.lua' then
-- */health.lua
name = vim.fs.dirname(subpath)
diff --git a/runtime/lua/vim/iter.lua b/runtime/lua/vim/iter.lua
index 4bbcaf16db..bdbe2be95a 100644
--- a/runtime/lua/vim/iter.lua
+++ b/runtime/lua/vim/iter.lua
@@ -652,7 +652,7 @@ end
---
--- ```
---
----@see Iter.find
+---@see |Iter:find()|
---
---@param f any
---@return any
@@ -757,7 +757,7 @@ end
--- -- 4
--- ```
---
----@see Iter.last
+---@see |Iter:last()|
---
---@return any
function Iter:rpeek()
@@ -942,7 +942,7 @@ end
---
--- ```
---
----@see Iter.rpeek
+---@see |Iter:rpeek()|
---
---@return any
function Iter:last()
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 6c23c24220..bb4e1cd28f 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -1365,16 +1365,26 @@ end
--- Provides an interface between the built-in client and a `foldexpr` function.
---
---- To use, check for the "textDocument/foldingRange" capability in an
---- |LspAttach| autocommand. Example:
+--- To use, set 'foldmethod' to "expr" and set the value of 'foldexpr':
---
--- ```lua
+--- vim.o.foldmethod = 'expr'
+--- vim.o.foldexpr = 'v:lua.vim.lsp.foldexpr()'
+--- ```
+---
+--- Or use it only when supported by checking for the "textDocument/foldingRange"
+--- capability in an |LspAttach| autocommand. Example:
+---
+--- ```lua
+--- vim.o.foldmethod = 'expr'
+--- -- Default to treesitter folding
+--- vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
+--- -- Prefer LSP folding if client supports it
--- vim.api.nvim_create_autocmd('LspAttach', {
--- callback = function(args)
--- local client = vim.lsp.get_client_by_id(args.data.client_id)
--- if client:supports_method('textDocument/foldingRange') then
--- local win = vim.api.nvim_get_current_win()
---- vim.wo[win][0].foldmethod = 'expr'
--- vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()'
--- end
--- end,
diff --git a/runtime/lua/vim/lsp/buf.lua b/runtime/lua/vim/lsp/buf.lua
index 2da591e9bb..bd78f1ad50 100644
--- a/runtime/lua/vim/lsp/buf.lua
+++ b/runtime/lua/vim/lsp/buf.lua
@@ -1152,7 +1152,7 @@ local function on_code_action_results(results, opts)
return
end
- if not action.edit or not action.command and client:supports_method(ms.codeAction_resolve) then
+ if not (action.edit and action.command) and client:supports_method(ms.codeAction_resolve) then
client:request(ms.codeAction_resolve, action, function(err, resolved_action)
if err then
-- If resolve fails, try to apply the edit/command from the original code action.
diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua
index 4064e02597..dcb7b5fa9b 100644
--- a/runtime/lua/vim/lsp/completion.lua
+++ b/runtime/lua/vim/lsp/completion.lua
@@ -536,7 +536,7 @@ local function on_insert_char_pre(handle)
local ctx = { triggerKind = protocol.CompletionTriggerKind.TriggerForIncompleteCompletions }
if debounce_ms == 0 then
vim.schedule(function()
- M.trigger({ ctx = ctx })
+ M.get({ ctx = ctx })
end)
else
completion_timer = new_timer()
@@ -544,7 +544,7 @@ local function on_insert_char_pre(handle)
debounce_ms,
0,
vim.schedule_wrap(function()
- M.trigger({ ctx = ctx })
+ M.get({ ctx = ctx })
end)
)
end
@@ -791,13 +791,13 @@ function M.enable(enable, client_id, bufnr, opts)
end
--- @inlinedoc
---- @class vim.lsp.completion.trigger.Opts
+--- @class vim.lsp.completion.get.Opts
--- @field ctx? lsp.CompletionContext Completion context. Defaults to a trigger kind of `invoked`.
--- Triggers LSP completion once in the current buffer.
---
---- @param opts? vim.lsp.completion.trigger.Opts
-function M.trigger(opts)
+--- @param opts? vim.lsp.completion.get.Opts
+function M.get(opts)
opts = opts or {}
local ctx = opts.ctx or { triggerKind = protocol.CompletionTriggerKind.Invoked }
local bufnr = api.nvim_get_current_buf()
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua
index a0d1fe776b..d31d94cab7 100644
--- a/runtime/lua/vim/lsp/rpc.lua
+++ b/runtime/lua/vim/lsp/rpc.lua
@@ -278,10 +278,8 @@ function Client:encode_and_send(payload)
if self.transport:is_closing() then
return false
end
- local jsonstr = assert(
- vim.json.encode(payload),
- string.format("Couldn't encode payload '%s'", vim.inspect(payload))
- )
+ local jsonstr = vim.json.encode(payload)
+
self.transport:write(format_message_with_content_length(jsonstr))
return true
end
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 307a55c2a2..056cb0c73c 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1345,7 +1345,7 @@ local function close_preview_window(winnr, bufnrs)
return
end
- local augroup = 'preview_window_' .. winnr
+ local augroup = 'nvim.preview_window_' .. winnr
pcall(api.nvim_del_augroup_by_name, augroup)
pcall(api.nvim_win_close, winnr, true)
end)
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index f370cbfb4e..3aeda1586d 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -7,7 +7,8 @@
-- so this wouldn't be a separate case to consider)
---@nodoc
-_G.vim = _G.vim or {} --[[@as table]] -- TODO(lewis6991): better fix for flaky luals
+_G.vim = _G.vim or {} --[[@as table]]
+-- TODO(lewis6991): better fix for flaky luals
---@generic T
---@param orig T