aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2022-05-09 11:23:51 +0200
committerChristian Clason <c.clason@uni-graz.at>2022-05-09 16:31:55 +0200
commitaefdc6783cb77f09786542c90901a9e7120bea42 (patch)
treeddce6de8f084ab96270f6111d8e423d0b1533171 /runtime
parent676e9e9334043ce74af74f85f889b0327a443d0b (diff)
downloadrneovim-aefdc6783cb77f09786542c90901a9e7120bea42.tar.gz
rneovim-aefdc6783cb77f09786542c90901a9e7120bea42.tar.bz2
rneovim-aefdc6783cb77f09786542c90901a9e7120bea42.zip
chore: format runtime with stylua
Diffstat (limited to 'runtime')
-rw-r--r--runtime/filetype.lua24
-rw-r--r--runtime/ftplugin/query.lua2
-rw-r--r--runtime/indent/query.lua2
-rw-r--r--runtime/lua/man.lua28
-rw-r--r--runtime/lua/vim/F.lua10
-rw-r--r--runtime/lua/vim/_editor.lua214
-rw-r--r--runtime/lua/vim/_init_packages.lua28
-rw-r--r--runtime/lua/vim/_meta.lua233
-rw-r--r--runtime/lua/vim/compat.lua4
-rw-r--r--runtime/lua/vim/diagnostic.lua446
-rw-r--r--runtime/lua/vim/filetype.lua3075
-rw-r--r--runtime/lua/vim/filetype/detect.lua169
-rw-r--r--runtime/lua/vim/highlight.lua20
-rw-r--r--runtime/lua/vim/inspect.lua108
-rw-r--r--runtime/lua/vim/keymap.lua30
-rw-r--r--runtime/lua/vim/lsp.lua535
-rw-r--r--runtime/lua/vim/lsp/_snippet.lua167
-rw-r--r--runtime/lua/vim/lsp/buf.lua169
-rw-r--r--runtime/lua/vim/lsp/codelens.lua54
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua107
-rw-r--r--runtime/lua/vim/lsp/handlers.lua182
-rw-r--r--runtime/lua/vim/lsp/health.lua9
-rw-r--r--runtime/lua/vim/lsp/log.lua70
-rw-r--r--runtime/lua/vim/lsp/protocol.lua542
-rw-r--r--runtime/lua/vim/lsp/rpc.lua240
-rw-r--r--runtime/lua/vim/lsp/sync.lua43
-rw-r--r--runtime/lua/vim/lsp/util.lua604
-rw-r--r--runtime/lua/vim/shared.lua144
-rw-r--r--runtime/lua/vim/treesitter.lua48
-rw-r--r--runtime/lua/vim/treesitter/health.lua12
-rw-r--r--runtime/lua/vim/treesitter/highlighter.lua189
-rw-r--r--runtime/lua/vim/treesitter/language.lua6
-rw-r--r--runtime/lua/vim/treesitter/languagetree.lua97
-rw-r--r--runtime/lua/vim/treesitter/query.lua118
-rw-r--r--runtime/lua/vim/ui.lua10
-rw-r--r--runtime/lua/vim/uri.lua36
-rw-r--r--runtime/syntax/query.lua2
37 files changed, 4203 insertions, 3574 deletions
diff --git a/runtime/filetype.lua b/runtime/filetype.lua
index 47d55d8465..d2510c5494 100644
--- a/runtime/filetype.lua
+++ b/runtime/filetype.lua
@@ -7,23 +7,23 @@ if vim.g.do_filetype_lua ~= 1 then
return
end
-vim.api.nvim_create_augroup("filetypedetect", {clear = false})
+vim.api.nvim_create_augroup('filetypedetect', { clear = false })
-vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
- group = "filetypedetect",
+vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
+ group = 'filetypedetect',
callback = function()
- vim.filetype.match(vim.fn.expand("<afile>"))
+ vim.filetype.match(vim.fn.expand('<afile>'))
end,
})
-- These *must* be sourced after the autocommand above is created
if not vim.g.did_load_ftdetect then
- vim.cmd [[
+ vim.cmd([[
augroup filetypedetect
runtime! ftdetect/*.vim
runtime! ftdetect/*.lua
augroup END
- ]]
+ ]])
end
-- Set a marker so that the ftdetect scripts are not sourced a second time by filetype.vim
@@ -31,17 +31,17 @@ vim.g.did_load_ftdetect = 1
-- If filetype.vim is disabled, set up the autocmd to use scripts.vim
if vim.g.did_load_filetypes then
- vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
- group = "filetypedetect",
+ vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
+ group = 'filetypedetect',
command = "if !did_filetype() && expand('<amatch>') !~ g:ft_ignore_pat | runtime! scripts.vim | endif",
})
- vim.api.nvim_create_autocmd("StdinReadPost", {
- group = "filetypedetect",
- command = "if !did_filetype() | runtime! scripts.vim | endif",
+ vim.api.nvim_create_autocmd('StdinReadPost', {
+ group = 'filetypedetect',
+ command = 'if !did_filetype() | runtime! scripts.vim | endif',
})
end
if not vim.g.ft_ignore_pat then
- vim.g.ft_ignore_pat = "\\.\\(Z\\|gz\\|bz2\\|zip\\|tgz\\)$"
+ vim.g.ft_ignore_pat = '\\.\\(Z\\|gz\\|bz2\\|zip\\|tgz\\)$'
end
diff --git a/runtime/ftplugin/query.lua b/runtime/ftplugin/query.lua
index c1694961af..3b99d67247 100644
--- a/runtime/ftplugin/query.lua
+++ b/runtime/ftplugin/query.lua
@@ -3,4 +3,4 @@
-- Last Change: 2022 Mar 29
-- it's a lisp!
-vim.cmd [[ runtime! ftplugin/lisp.vim ]]
+vim.cmd([[ runtime! ftplugin/lisp.vim ]])
diff --git a/runtime/indent/query.lua b/runtime/indent/query.lua
index 55cb73e62b..c86948e95e 100644
--- a/runtime/indent/query.lua
+++ b/runtime/indent/query.lua
@@ -3,4 +3,4 @@
-- Last Change: 2022 Mar 29
-- it's a lisp!
-vim.cmd [[ runtime! indent/lisp.vim ]]
+vim.cmd([[ runtime! indent/lisp.vim ]])
diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua
index ba6b9d09c9..5da3d2a92f 100644
--- a/runtime/lua/man.lua
+++ b/runtime/lua/man.lua
@@ -8,7 +8,7 @@ local function highlight_line(line, linenr)
local overstrike, escape = false, false
local hls = {} -- Store highlight groups as { attr, start, final }
local NONE, BOLD, UNDERLINE, ITALIC = 0, 1, 2, 3
- local hl_groups = {[BOLD]="manBold", [UNDERLINE]="manUnderline", [ITALIC]="manItalic"}
+ local hl_groups = { [BOLD] = 'manBold', [UNDERLINE] = 'manUnderline', [ITALIC] = 'manItalic' }
local attr = NONE
local byte = 0 -- byte offset
@@ -47,7 +47,7 @@ local function highlight_line(line, linenr)
end
if continue_hl then
- hls[#hls + 1] = {attr=attr, start=byte, final=-1}
+ hls[#hls + 1] = { attr = attr, start = byte, final = -1 }
else
if attr == NONE then
for a, _ in pairs(hl_groups) do
@@ -63,7 +63,7 @@ local function highlight_line(line, linenr)
-- can be represented in one byte. Any code point above that is represented by
-- a leading byte (0xc0 and above) and continuation bytes (0x80 to 0xbf, or
-- decimal 128 to 191).
- for char in line:gmatch("[^\128-\191][\128-\191]*") do
+ for char in line:gmatch('[^\128-\191][\128-\191]*') do
if overstrike then
local last_hl = hls[#hls]
if char == prev_char then
@@ -93,7 +93,7 @@ local function highlight_line(line, linenr)
if last_hl and last_hl.attr == attr and last_hl.final == byte then
last_hl.final = byte + #char
else
- hls[#hls + 1] = {attr=attr, start=byte, final=byte + #char}
+ hls[#hls + 1] = { attr = attr, start = byte, final = byte + #char }
end
overstrike = false
@@ -106,25 +106,25 @@ local function highlight_line(line, linenr)
-- We only want to match against SGR sequences, which consist of ESC
-- followed by '[', then a series of parameter and intermediate bytes in
-- the range 0x20 - 0x3f, then 'm'. (See ECMA-48, sections 5.4 & 8.3.117)
- local sgr = prev_char:match("^%[([\032-\063]*)m$")
+ local sgr = prev_char:match('^%[([\032-\063]*)m$')
-- Ignore escape sequences with : characters, as specified by ITU's T.416
-- Open Document Architecture and interchange format.
- if sgr and not string.find(sgr, ":") then
+ if sgr and not string.find(sgr, ':') then
local match
while sgr and #sgr > 0 do
-- Match against SGR parameters, which may be separated by ';'
- match, sgr = sgr:match("^(%d*);?(.*)")
+ match, sgr = sgr:match('^(%d*);?(.*)')
add_attr_hl(match + 0) -- coerce to number
end
escape = false
- elseif not prev_char:match("^%[[\032-\063]*$") then
+ elseif not prev_char:match('^%[[\032-\063]*$') then
-- Stop looking if this isn't a partial CSI sequence
escape = false
end
- elseif char == "\027" then
+ elseif char == '\027' then
escape = true
prev_char = ''
- elseif char == "\b" then
+ elseif char == '\b' then
overstrike = true
prev_char = chars[#chars]
byte = byte - #prev_char
@@ -143,7 +143,7 @@ local function highlight_line(line, linenr)
hl_groups[hl.attr],
linenr - 1,
hl.start,
- hl.final
+ hl.final,
}
end
end
@@ -152,8 +152,8 @@ local function highlight_line(line, linenr)
end
local function highlight_man_page()
- local mod = vim.api.nvim_buf_get_option(0, "modifiable")
- vim.api.nvim_buf_set_option(0, "modifiable", true)
+ local mod = vim.api.nvim_buf_get_option(0, 'modifiable')
+ vim.api.nvim_buf_set_option(0, 'modifiable', true)
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
for i, line in ipairs(lines) do
@@ -166,7 +166,7 @@ local function highlight_man_page()
end
buf_hls = {}
- vim.api.nvim_buf_set_option(0, "modifiable", mod)
+ vim.api.nvim_buf_set_option(0, 'modifiable', mod)
end
return { highlight_man_page = highlight_man_page }
diff --git a/runtime/lua/vim/F.lua b/runtime/lua/vim/F.lua
index 9327c652db..bca5ddf68b 100644
--- a/runtime/lua/vim/F.lua
+++ b/runtime/lua/vim/F.lua
@@ -5,13 +5,17 @@ local F = {}
---@param a
---@param b
function F.if_nil(a, b)
- if a == nil then return b end
+ if a == nil then
+ return b
+ end
return a
end
-- Use in combination with pcall
function F.ok_or_nil(status, ...)
- if not status then return end
+ if not status then
+ return
+ end
return ...
end
@@ -29,7 +33,7 @@ end
--- like {...} except preserve the length explicitly
function F.pack_len(...)
- return {n=select('#', ...), ...}
+ return { n = select('#', ...), ... }
end
--- like unpack() but use the length set by F.pack_len if present
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 119467de16..9bdbf6d1c7 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -40,26 +40,28 @@ local vim = assert(vim)
-- These are for loading runtime modules lazily since they aren't available in
-- the nvim binary as specified in executor.c
-for k,v in pairs {
- treesitter=true;
- filetype = true;
- F=true;
- lsp=true;
- highlight=true;
- diagnostic=true;
- keymap=true;
- ui=true;
-} do vim._submodules[k] = v end
+for k, v in pairs({
+ treesitter = true,
+ filetype = true,
+ F = true,
+ lsp = true,
+ highlight = true,
+ diagnostic = true,
+ keymap = true,
+ ui = true,
+}) do
+ vim._submodules[k] = v
+end
vim.log = {
levels = {
- TRACE = 0;
- DEBUG = 1;
- INFO = 2;
- WARN = 3;
- ERROR = 4;
- OFF = 5;
- }
+ TRACE = 0,
+ DEBUG = 1,
+ INFO = 2,
+ WARN = 3,
+ ERROR = 4,
+ OFF = 5,
+ },
}
-- Internal-only until comments in #8107 are addressed.
@@ -77,14 +79,14 @@ function vim._os_proc_info(pid)
if pid == nil or pid <= 0 or type(pid) ~= 'number' then
error('invalid pid')
end
- local cmd = { 'ps', '-p', pid, '-o', 'comm=', }
+ local cmd = { 'ps', '-p', pid, '-o', 'comm=' }
local err, name = vim._system(cmd)
if 1 == err and vim.trim(name) == '' then
- return {} -- Process not found.
+ return {} -- Process not found.
elseif 0 ~= err then
- error('command failed: '..vim.fn.string(cmd))
+ error('command failed: ' .. vim.fn.string(cmd))
end
- local _, ppid = vim._system({ 'ps', '-p', pid, '-o', 'ppid=', })
+ local _, ppid = vim._system({ 'ps', '-p', pid, '-o', 'ppid=' })
-- Remove trailing whitespace.
name = vim.trim(name):gsub('^.*/', '')
ppid = tonumber(ppid) or -1
@@ -101,12 +103,12 @@ function vim._os_proc_children(ppid)
if ppid == nil or ppid <= 0 or type(ppid) ~= 'number' then
error('invalid ppid')
end
- local cmd = { 'pgrep', '-P', ppid, }
+ local cmd = { 'pgrep', '-P', ppid }
local err, rv = vim._system(cmd)
if 1 == err and vim.trim(rv) == '' then
- return {} -- Process not found.
+ return {} -- Process not found.
elseif 0 ~= err then
- error('command failed: '..vim.fn.string(cmd))
+ error('command failed: ' .. vim.fn.string(cmd))
end
local children = {}
for s in rv:gmatch('%S+') do
@@ -124,8 +126,8 @@ end
---
---@see https://github.com/kikito/inspect.lua
---@see https://github.com/mpeterv/vinspect
-local function inspect(object, options) -- luacheck: no unused
- error(object, options) -- Stub for gen_vimdoc.py
+local function inspect(object, options) -- luacheck: no unused
+ error(object, options) -- Stub for gen_vimdoc.py
end
do
@@ -160,11 +162,11 @@ do
local now = vim.loop.now()
local is_first_chunk = phase < 2
local is_last_chunk = phase == -1 or phase == 3
- if is_first_chunk then -- Reset flags.
+ if is_first_chunk then -- Reset flags.
tdots, tick, got_line1, undo_started, trailing_nl = now, 0, false, false, false
end
if #lines == 0 then
- lines = {''}
+ lines = { '' }
end
if #lines == 1 and lines[1] == '' and not is_last_chunk then
-- An empty chunk can cause some edge cases in streamed pasting,
@@ -172,7 +174,7 @@ do
return true
end
-- Note: mode doesn't always start with "c" in cmdline mode, so use getcmdtype() instead.
- if vim.fn.getcmdtype() ~= '' then -- cmdline-mode: paste only 1 line.
+ if vim.fn.getcmdtype() ~= '' then -- cmdline-mode: paste only 1 line.
if not got_line1 then
got_line1 = (#lines > 1)
-- Escape control characters
@@ -187,9 +189,9 @@ do
if undo_started then
vim.api.nvim_command('undojoin')
end
- if mode:find('^i') or mode:find('^n?t') then -- Insert mode or Terminal buffer
+ if mode:find('^i') or mode:find('^n?t') then -- Insert mode or Terminal buffer
vim.api.nvim_put(lines, 'c', false, true)
- elseif phase < 2 and mode:find('^R') and not mode:find('^Rv') then -- Replace mode
+ elseif phase < 2 and mode:find('^R') and not mode:find('^Rv') then -- Replace mode
-- TODO: implement Replace mode streamed pasting
-- TODO: support Virtual Replace mode
local nchars = 0
@@ -197,26 +199,26 @@ do
nchars = nchars + line:len()
end
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
- local bufline = vim.api.nvim_buf_get_lines(0, row-1, row, true)[1]
+ local bufline = vim.api.nvim_buf_get_lines(0, row - 1, row, true)[1]
local firstline = lines[1]
- firstline = bufline:sub(1, col)..firstline
+ firstline = bufline:sub(1, col) .. firstline
lines[1] = firstline
- lines[#lines] = lines[#lines]..bufline:sub(col + nchars + 1, bufline:len())
- vim.api.nvim_buf_set_lines(0, row-1, row, false, lines)
- elseif mode:find('^[nvV\22sS\19]') then -- Normal or Visual or Select mode
- if mode:find('^n') then -- Normal mode
+ lines[#lines] = lines[#lines] .. bufline:sub(col + nchars + 1, bufline:len())
+ vim.api.nvim_buf_set_lines(0, row - 1, row, false, lines)
+ elseif mode:find('^[nvV\22sS\19]') then -- Normal or Visual or Select mode
+ if mode:find('^n') then -- Normal mode
-- When there was a trailing new line in the previous chunk,
-- the cursor is on the first character of the next line,
-- so paste before the cursor instead of after it.
vim.api.nvim_put(lines, 'c', not trailing_nl, false)
- else -- Visual or Select mode
+ else -- Visual or Select mode
vim.api.nvim_command([[exe "silent normal! \<Del>"]])
local del_start = vim.fn.getpos("'[")
local cursor_pos = vim.fn.getpos('.')
- if mode:find('^[VS]') then -- linewise
- if cursor_pos[2] < del_start[2] then -- replacing lines at eof
+ if mode:find('^[VS]') then -- linewise
+ if cursor_pos[2] < del_start[2] then -- replacing lines at eof
-- create a new line
- vim.api.nvim_put({''}, 'l', true, true)
+ vim.api.nvim_put({ '' }, 'l', true, true)
end
vim.api.nvim_put(lines, 'c', false, false)
else
@@ -227,7 +229,7 @@ do
-- put cursor at the end of the text instead of one character after it
vim.fn.setpos('.', vim.fn.getpos("']"))
trailing_nl = lines[#lines] == ''
- else -- Don't know what to do in other modes
+ else -- Don't know what to do in other modes
return false
end
undo_started = true
@@ -240,9 +242,9 @@ do
vim.api.nvim_command(('echo "%s"'):format(dots))
end
if is_last_chunk then
- vim.api.nvim_command('redraw'..(tick > 1 and '|echo ""' or ''))
+ vim.api.nvim_command('redraw' .. (tick > 1 and '|echo ""' or ''))
end
- return true -- Paste will not continue if not returning `true`.
+ return true -- Paste will not continue if not returning `true`.
end
end
@@ -252,10 +254,12 @@ end
---@see |vim.schedule()|
---@see |vim.in_fast_event()|
function vim.schedule_wrap(cb)
- return (function (...)
+ return function(...)
local args = vim.F.pack_len(...)
- vim.schedule(function() cb(vim.F.unpack_len(args)) end)
- end)
+ vim.schedule(function()
+ cb(vim.F.unpack_len(args))
+ end)
+ end
end
-- vim.fn.{func}(...)
@@ -264,7 +268,7 @@ vim.fn = setmetatable({}, {
local _fn
if vim.api[key] ~= nil then
_fn = function()
- error(string.format("Tried to call API function with vim.fn: use vim.api.%s instead", key))
+ error(string.format('Tried to call API function with vim.fn: use vim.api.%s instead', key))
end
else
_fn = function(...)
@@ -273,7 +277,7 @@ vim.fn = setmetatable({}, {
end
t[key] = _fn
return _fn
- end
+ end,
})
vim.funcref = function(viml_func_name)
@@ -291,9 +295,9 @@ do
--@private
local function make_dict_accessor(scope, handle)
- validate {
- scope = {scope, 's'};
- }
+ validate({
+ scope = { scope, 's' },
+ })
local mt = {}
function mt:__newindex(k, v)
return vim._setvar(scope, handle or 0, k, v)
@@ -343,7 +347,7 @@ function vim.region(bufnr, pos1, pos2, regtype, inclusive)
local region = {}
for l = pos1[1], pos2[1] do
local c1, c2
- if regtype:byte() == 22 then -- block selection: take width from regtype
+ if regtype:byte() == 22 then -- block selection: take width from regtype
c1 = pos1[2]
c2 = c1 + regtype:sub(2)
-- and adjust for non-ASCII characters
@@ -355,10 +359,10 @@ function vim.region(bufnr, pos1, pos2, regtype, inclusive)
c2 = vim.str_byteindex(bufline, c2)
end
else
- c1 = (l == pos1[1]) and (pos1[2]) or 0
+ c1 = (l == pos1[1]) and pos1[2] or 0
c2 = (l == pos2[1]) and (pos2[2] + (inclusive and 1 or 0)) or -1
end
- table.insert(region, l, {c1, c2})
+ table.insert(region, l, { c1, c2 })
end
return region
end
@@ -372,19 +376,22 @@ end
---@param timeout Number of milliseconds to wait before calling `fn`
---@return timer luv timer object
function vim.defer_fn(fn, timeout)
- vim.validate { fn = { fn, 'c', true}; }
+ vim.validate({ fn = { fn, 'c', true } })
local timer = vim.loop.new_timer()
- timer:start(timeout, 0, vim.schedule_wrap(function()
- timer:stop()
- timer:close()
+ timer:start(
+ timeout,
+ 0,
+ vim.schedule_wrap(function()
+ timer:stop()
+ timer:close()
- fn()
- end))
+ fn()
+ end)
+ )
return timer
end
-
--- Display a notification to the user.
---
--- This function can be overridden by plugins to display notifications using a
@@ -398,9 +405,9 @@ function vim.notify(msg, level, opts) -- luacheck: no unused args
if level == vim.log.levels.ERROR then
vim.api.nvim_err_writeln(msg)
elseif level == vim.log.levels.WARN then
- vim.api.nvim_echo({{msg, 'WarningMsg'}}, true, {})
+ vim.api.nvim_echo({ { msg, 'WarningMsg' } }, true, {})
else
- vim.api.nvim_echo({{msg}}, true, {})
+ vim.api.nvim_echo({ { msg } }, true, {})
end
end
@@ -453,10 +460,10 @@ function vim.on_key(fn, ns_id)
return #on_key_cbs
end
- vim.validate {
- fn = { fn, 'c', true},
- ns_id = { ns_id, 'n', true }
- }
+ vim.validate({
+ fn = { fn, 'c', true },
+ ns_id = { ns_id, 'n', true },
+ })
if ns_id == nil or ns_id == 0 then
ns_id = vim.api.nvim_create_namespace('')
@@ -481,10 +488,13 @@ function vim._on_key(char)
end
if failed_ns_ids[1] then
- error(string.format(
- "Error executing 'on_key' with ns_ids '%s'\n Messages: %s",
- table.concat(failed_ns_ids, ", "),
- table.concat(failed_messages, "\n")))
+ error(
+ string.format(
+ "Error executing 'on_key' with ns_ids '%s'\n Messages: %s",
+ table.concat(failed_ns_ids, ', '),
+ table.concat(failed_messages, '\n')
+ )
+ )
end
end
@@ -511,8 +521,10 @@ function vim._expand_pat(pat, env)
-- Probably just need to do a smarter match than just `:match`
-- Get the last part of the pattern
- local last_part = pat:match("[%w.:_%[%]'\"]+$")
- if not last_part then return {}, 0 end
+ local last_part = pat:match('[%w.:_%[%]\'"]+$')
+ if not last_part then
+ return {}, 0
+ end
local parts, search_index = vim._expand_pat_get_parts(last_part)
@@ -529,7 +541,7 @@ function vim._expand_pat(pat, env)
-- Normally, we just have a string
-- Just attempt to get the string directly from the environment
- if type(part) == "string" then
+ if type(part) == 'string' then
key = part
else
-- However, sometimes you want to use a variable, and complete on it
@@ -554,7 +566,7 @@ function vim._expand_pat(pat, env)
local field = rawget(final_env, key)
if field == nil then
local mt = getmetatable(final_env)
- if mt and type(mt.__index) == "table" then
+ if mt and type(mt.__index) == 'table' then
field = rawget(mt.__index, key)
elseif final_env == vim and vim._submodules[key] then
field = vim[key]
@@ -570,18 +582,18 @@ function vim._expand_pat(pat, env)
local keys = {}
---@private
local function insert_keys(obj)
- for k,_ in pairs(obj) do
- if type(k) == "string" and string.sub(k,1,string.len(match_part)) == match_part then
- table.insert(keys,k)
+ for k, _ in pairs(obj) do
+ if type(k) == 'string' and string.sub(k, 1, string.len(match_part)) == match_part then
+ table.insert(keys, k)
end
end
end
- if type(final_env) == "table" then
+ if type(final_env) == 'table' then
insert_keys(final_env)
end
local mt = getmetatable(final_env)
- if mt and type(mt.__index) == "table" then
+ if mt and type(mt.__index) == 'table' then
insert_keys(mt.__index)
end
if final_env == vim then
@@ -602,12 +614,12 @@ vim._expand_pat_get_parts = function(lua_string)
for idx = 1, #lua_string do
local s = lua_string:sub(idx, idx)
- if not in_brackets and (s == "." or s == ":") then
+ if not in_brackets and (s == '.' or s == ':') then
table.insert(parts, accumulator)
accumulator = ''
search_index = idx + 1
- elseif s == "[" then
+ elseif s == '[' then
in_brackets = true
table.insert(parts, accumulator)
@@ -619,7 +631,7 @@ vim._expand_pat_get_parts = function(lua_string)
in_brackets = false
search_index = idx + 1
- if string_char == "VAR" then
+ if string_char == 'VAR' then
table.insert(parts, { accumulator })
accumulator = ''
@@ -631,7 +643,7 @@ vim._expand_pat_get_parts = function(lua_string)
if s == '"' or s == "'" then
string_char = s
elseif s ~= ' ' then
- string_char = "VAR"
+ string_char = 'VAR'
accumulator = s
end
elseif string_char then
@@ -649,7 +661,9 @@ vim._expand_pat_get_parts = function(lua_string)
end
end
- parts = vim.tbl_filter(function(val) return #val > 0 end, parts)
+ parts = vim.tbl_filter(function(val)
+ return #val > 0
+ end, parts)
return parts, search_index
end
@@ -677,20 +691,20 @@ function vim._cs_remote(rcid, server_addr, connect_error, args)
local function connection_failure_errmsg(consequence)
local explanation
if server_addr == '' then
- explanation = "No server specified with --server"
+ explanation = 'No server specified with --server'
else
explanation = "Failed to connect to '" .. server_addr .. "'"
- if connect_error ~= "" then
- explanation = explanation .. ": " .. connect_error
+ if connect_error ~= '' then
+ explanation = explanation .. ': ' .. connect_error
end
end
- return "E247: " .. explanation .. ". " .. consequence
+ return 'E247: ' .. explanation .. '. ' .. consequence
end
local f_silent = false
local f_tab = false
- local subcmd = string.sub(args[1],10)
+ local subcmd = string.sub(args[1], 10)
if subcmd == 'tab' then
f_tab = true
elseif subcmd == 'silent' then
@@ -713,16 +727,18 @@ function vim._cs_remote(rcid, server_addr, connect_error, args)
print(vim.fn.rpcrequest(rcid, 'nvim_eval', args[2]))
return { should_exit = true, tabbed = false }
elseif subcmd ~= '' then
- return { errmsg='Unknown option argument: ' .. args[1] }
+ return { errmsg = 'Unknown option argument: ' .. args[1] }
end
if rcid == 0 then
if not f_silent then
- vim.notify(connection_failure_errmsg("Editing locally"), vim.log.levels.WARN)
+ vim.notify(connection_failure_errmsg('Editing locally'), vim.log.levels.WARN)
end
else
local command = {}
- if f_tab then table.insert(command, 'tab') end
+ if f_tab then
+ table.insert(command, 'tab')
+ end
table.insert(command, 'drop')
for i = 2, #args do
table.insert(command, vim.fn.fnameescape(args[i]))
@@ -745,11 +761,11 @@ end
---@param plugin string|nil Plugin name that the function will be removed
--- from. Defaults to "Nvim".
function vim.deprecate(name, alternative, version, plugin)
- local message = name .. ' is deprecated'
- plugin = plugin or "Nvim"
- message = alternative and (message .. ', use ' .. alternative .. ' instead.') or message
- message = message .. ' See :h deprecated\nThis function will be removed in ' .. plugin .. ' version ' .. version
- vim.notify_once(message, vim.log.levels.WARN)
+ local message = name .. ' is deprecated'
+ plugin = plugin or 'Nvim'
+ message = alternative and (message .. ', use ' .. alternative .. ' instead.') or message
+ message = message .. ' See :h deprecated\nThis function will be removed in ' .. plugin .. ' version ' .. version
+ vim.notify_once(message, vim.log.levels.WARN)
end
require('vim._meta')
diff --git a/runtime/lua/vim/_init_packages.lua b/runtime/lua/vim/_init_packages.lua
index 7d27741f1b..7e3c73667e 100644
--- a/runtime/lua/vim/_init_packages.lua
+++ b/runtime/lua/vim/_init_packages.lua
@@ -3,8 +3,8 @@ local vim = assert(vim)
local pathtrails = {}
vim._so_trails = {}
-for s in (package.cpath..';'):gmatch('[^;]*;') do
- s = s:sub(1, -2) -- Strip trailing semicolon
+for s in (package.cpath .. ';'):gmatch('[^;]*;') do
+ s = s:sub(1, -2) -- Strip trailing semicolon
-- Find out path patterns. pathtrail should contain something like
-- /?.so, \?.dll. This allows not to bother determining what correct
-- suffixes are.
@@ -17,29 +17,29 @@ end
function vim._load_package(name)
local basename = name:gsub('%.', '/')
- local paths = {"lua/"..basename..".lua", "lua/"..basename.."/init.lua"}
- local found = vim.api.nvim__get_runtime(paths, false, {is_lua=true})
+ local paths = { 'lua/' .. basename .. '.lua', 'lua/' .. basename .. '/init.lua' }
+ local found = vim.api.nvim__get_runtime(paths, false, { is_lua = true })
if #fo