mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(test): typing
This commit is contained in:
parent
3fd8292aaf
commit
a7bbda121d
@ -1016,7 +1016,7 @@ Lua module: vim.lsp.client *lsp-client*
|
|||||||
• {capabilities} (`lsp.ClientCapabilities`) The capabilities
|
• {capabilities} (`lsp.ClientCapabilities`) The capabilities
|
||||||
provided by the client (editor or tool)
|
provided by the client (editor or tool)
|
||||||
• {dynamic_capabilities} (`lsp.DynamicCapabilities`)
|
• {dynamic_capabilities} (`lsp.DynamicCapabilities`)
|
||||||
• {request} (`fun(method: string, params: table?, handler: lsp.Handler?, bufnr: integer): boolean, integer?`)
|
• {request} (`fun(method: string, params: table?, handler: lsp.Handler?, bufnr: integer?): boolean, integer?`)
|
||||||
Sends a request to the server. This is a thin
|
Sends a request to the server. This is a thin
|
||||||
wrapper around {client.rpc.request} with some
|
wrapper around {client.rpc.request} with some
|
||||||
additional checking. If {handler} is not
|
additional checking. If {handler} is not
|
||||||
|
@ -225,7 +225,7 @@ local validate = vim.validate
|
|||||||
--- If {status} is `true`, the function returns {request_id} as the second
|
--- If {status} is `true`, the function returns {request_id} as the second
|
||||||
--- result. You can use this with `client.cancel_request(request_id)` to cancel
|
--- result. You can use this with `client.cancel_request(request_id)` to cancel
|
||||||
--- the request.
|
--- the request.
|
||||||
--- @field request fun(method: string, params: table?, handler: lsp.Handler?, bufnr: integer): boolean, integer?
|
--- @field request fun(method: string, params: table?, handler: lsp.Handler?, bufnr: integer?): boolean, integer?
|
||||||
---
|
---
|
||||||
--- Sends a request to the server and synchronously waits for the response.
|
--- Sends a request to the server and synchronously waits for the response.
|
||||||
--- This is a wrapper around {client.request}
|
--- This is a wrapper around {client.request}
|
||||||
@ -647,10 +647,10 @@ end
|
|||||||
--- checks for capabilities and handler availability.
|
--- checks for capabilities and handler availability.
|
||||||
---
|
---
|
||||||
--- @param method string LSP method name.
|
--- @param method string LSP method name.
|
||||||
--- @param params table|nil LSP request params.
|
--- @param params? table LSP request params.
|
||||||
--- @param handler lsp.Handler|nil Response |lsp-handler| for this method.
|
--- @param handler? lsp.Handler Response |lsp-handler| for this method.
|
||||||
--- @param bufnr integer Buffer handle (0 for current).
|
--- @param bufnr? integer Buffer handle (0 for current).
|
||||||
--- @return boolean status, integer|nil request_id {status} is a bool indicating
|
--- @return boolean status, integer? request_id {status} is a bool indicating
|
||||||
--- whether the request was successful. If it is `false`, then it will
|
--- whether the request was successful. If it is `false`, then it will
|
||||||
--- always be `false` (the client has shutdown). If it was
|
--- always be `false` (the client has shutdown). If it was
|
||||||
--- successful, then it will return {request_id} as the
|
--- successful, then it will return {request_id} as the
|
||||||
|
@ -15,7 +15,8 @@ local ok = global_helpers.ok
|
|||||||
local sleep = uv.sleep
|
local sleep = uv.sleep
|
||||||
local fail = global_helpers.fail
|
local fail = global_helpers.fail
|
||||||
|
|
||||||
local module = {}
|
--- @class test.functional.helpers: test.helpers
|
||||||
|
local module = vim.deepcopy(global_helpers)
|
||||||
|
|
||||||
local runtime_set = 'set runtimepath^=./build/lib/nvim/'
|
local runtime_set = 'set runtimepath^=./build/lib/nvim/'
|
||||||
module.nvim_prog = (os.getenv('NVIM_PRG') or global_helpers.paths.test_build_dir .. '/bin/nvim')
|
module.nvim_prog = (os.getenv('NVIM_PRG') or global_helpers.paths.test_build_dir .. '/bin/nvim')
|
||||||
@ -367,13 +368,6 @@ function module.feed(...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param ... string
|
|
||||||
function module.rawfeed(...)
|
|
||||||
for _, v in ipairs({ ... }) do
|
|
||||||
nvim_feed(dedent(v))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param ... string[]?
|
---@param ... string[]?
|
||||||
---@return string[]
|
---@return string[]
|
||||||
function module.merge_args(...)
|
function module.merge_args(...)
|
||||||
@ -583,7 +577,7 @@ function module.insert(...)
|
|||||||
nvim_feed('i')
|
nvim_feed('i')
|
||||||
for _, v in ipairs({ ... }) do
|
for _, v in ipairs({ ... }) do
|
||||||
local escaped = v:gsub('<', '<lt>')
|
local escaped = v:gsub('<', '<lt>')
|
||||||
module.rawfeed(escaped)
|
module.feed(escaped)
|
||||||
end
|
end
|
||||||
nvim_feed('<ESC>')
|
nvim_feed('<ESC>')
|
||||||
end
|
end
|
||||||
@ -853,7 +847,7 @@ function module.exc_exec(cmd)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @param cond boolean
|
--- @param cond boolean
|
||||||
--- @param reason string
|
--- @param reason? string
|
||||||
--- @return boolean
|
--- @return boolean
|
||||||
function module.skip(cond, reason)
|
function module.skip(cond, reason)
|
||||||
if cond then
|
if cond then
|
||||||
@ -1028,9 +1022,6 @@ function module.mkdir_p(path)
|
|||||||
return os.execute((is_os('win') and 'mkdir ' .. path or 'mkdir -p ' .. path))
|
return os.execute((is_os('win') and 'mkdir ' .. path or 'mkdir -p ' .. path))
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @class test.functional.helpers: test.helpers
|
|
||||||
module = vim.tbl_extend('error', module, global_helpers)
|
|
||||||
|
|
||||||
--- @return test.functional.helpers
|
--- @return test.functional.helpers
|
||||||
return function(after_each)
|
return function(after_each)
|
||||||
if after_each then
|
if after_each then
|
||||||
|
@ -54,7 +54,7 @@ describe('vim.fs', function()
|
|||||||
it('works', function()
|
it('works', function()
|
||||||
local test_dir = nvim_dir .. '/test'
|
local test_dir = nvim_dir .. '/test'
|
||||||
mkdir_p(test_dir)
|
mkdir_p(test_dir)
|
||||||
local dirs = {}
|
local dirs = {} --- @type string[]
|
||||||
for dir in vim.fs.parents(test_dir .. '/foo.txt') do
|
for dir in vim.fs.parents(test_dir .. '/foo.txt') do
|
||||||
dirs[#dirs + 1] = dir
|
dirs[#dirs + 1] = dir
|
||||||
if dir == test_build_dir then
|
if dir == test_build_dir then
|
||||||
@ -70,6 +70,7 @@ describe('vim.fs', function()
|
|||||||
it('works', function()
|
it('works', function()
|
||||||
eq(test_build_dir, vim.fs.dirname(nvim_dir))
|
eq(test_build_dir, vim.fs.dirname(nvim_dir))
|
||||||
|
|
||||||
|
--- @param paths string[]
|
||||||
local function test_paths(paths)
|
local function test_paths(paths)
|
||||||
for _, path in ipairs(paths) do
|
for _, path in ipairs(paths) do
|
||||||
eq(
|
eq(
|
||||||
@ -97,6 +98,7 @@ describe('vim.fs', function()
|
|||||||
it('works', function()
|
it('works', function()
|
||||||
eq(nvim_prog_basename, vim.fs.basename(nvim_prog))
|
eq(nvim_prog_basename, vim.fs.basename(nvim_prog))
|
||||||
|
|
||||||
|
--- @param paths string[]
|
||||||
local function test_paths(paths)
|
local function test_paths(paths)
|
||||||
for _, path in ipairs(paths) do
|
for _, path in ipairs(paths) do
|
||||||
eq(
|
eq(
|
||||||
@ -292,7 +294,7 @@ describe('vim.fs', function()
|
|||||||
eq('/', vim.fs.normalize('/'))
|
eq('/', vim.fs.normalize('/'))
|
||||||
end)
|
end)
|
||||||
it('works with ~', function()
|
it('works with ~', function()
|
||||||
eq(vim.fs.normalize(vim.uv.os_homedir()) .. '/src/foo', vim.fs.normalize('~/src/foo'))
|
eq(vim.fs.normalize(assert(vim.uv.os_homedir())) .. '/src/foo', vim.fs.normalize('~/src/foo'))
|
||||||
end)
|
end)
|
||||||
it('works with environment variables', function()
|
it('works with environment variables', function()
|
||||||
local xdg_config_home = test_build_dir .. '/.config'
|
local xdg_config_home = test_build_dir .. '/.config'
|
||||||
|
@ -73,12 +73,12 @@ describe('vim.loader', function()
|
|||||||
vim.loader.enable()
|
vim.loader.enable()
|
||||||
]]
|
]]
|
||||||
|
|
||||||
local tmp1, tmp2 = (function(t)
|
local t = helpers.tmpname()
|
||||||
assert(os.remove(t))
|
assert(os.remove(t))
|
||||||
assert(helpers.mkdir(t))
|
assert(helpers.mkdir(t))
|
||||||
assert(helpers.mkdir(t .. '/%'))
|
assert(helpers.mkdir(t .. '/%'))
|
||||||
return t .. '/%/x', t .. '/%%x'
|
local tmp1 = t .. '/%/x'
|
||||||
end)(helpers.tmpname())
|
local tmp2 = t .. '/%%x'
|
||||||
|
|
||||||
helpers.write_file(tmp1, 'return 1', true)
|
helpers.write_file(tmp1, 'return 1', true)
|
||||||
helpers.write_file(tmp2, 'return 2', true)
|
helpers.write_file(tmp2, 'return 2', true)
|
||||||
|
@ -195,7 +195,7 @@ describe('print', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('debug.debug', function()
|
describe('debug.debug', function()
|
||||||
local screen
|
local screen --- @type test.functional.ui.screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
screen = Screen.new()
|
screen = Screen.new()
|
||||||
|
@ -11,8 +11,10 @@ local exec_lua = helpers.exec_lua
|
|||||||
local feed_command = helpers.feed_command
|
local feed_command = helpers.feed_command
|
||||||
local feed = helpers.feed
|
local feed = helpers.feed
|
||||||
local fn = helpers.fn
|
local fn = helpers.fn
|
||||||
|
local stdpath = fn.stdpath
|
||||||
local pcall_err = helpers.pcall_err
|
local pcall_err = helpers.pcall_err
|
||||||
local matches = helpers.matches
|
local matches = helpers.matches
|
||||||
|
local read_file = helpers.read_file
|
||||||
|
|
||||||
describe('vim.secure', function()
|
describe('vim.secure', function()
|
||||||
describe('read()', function()
|
describe('read()', function()
|
||||||
@ -71,11 +73,11 @@ describe('vim.secure', function()
|
|||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
|
|
||||||
local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
local trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('! %s', cwd .. pathsep .. 'Xfile'), vim.trim(trust))
|
eq(string.format('! %s', cwd .. pathsep .. 'Xfile'), vim.trim(trust))
|
||||||
eq(vim.NIL, exec_lua([[return vim.secure.read('Xfile')]]))
|
eq(vim.NIL, exec_lua([[return vim.secure.read('Xfile')]]))
|
||||||
|
|
||||||
os.remove(fn.stdpath('state') .. pathsep .. 'trust')
|
os.remove(stdpath('state') .. pathsep .. 'trust')
|
||||||
|
|
||||||
feed_command([[lua vim.secure.read('Xfile')]])
|
feed_command([[lua vim.secure.read('Xfile')]])
|
||||||
screen:expect {
|
screen:expect {
|
||||||
@ -100,12 +102,12 @@ describe('vim.secure', function()
|
|||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
|
|
||||||
local hash = fn.sha256(helpers.read_file('Xfile'))
|
local hash = fn.sha256(read_file('Xfile'))
|
||||||
trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('%s %s', hash, cwd .. pathsep .. 'Xfile'), vim.trim(trust))
|
eq(string.format('%s %s', hash, cwd .. pathsep .. 'Xfile'), vim.trim(trust))
|
||||||
eq(vim.NIL, exec_lua([[vim.secure.read('Xfile')]]))
|
eq(vim.NIL, exec_lua([[vim.secure.read('Xfile')]]))
|
||||||
|
|
||||||
os.remove(fn.stdpath('state') .. pathsep .. 'trust')
|
os.remove(stdpath('state') .. pathsep .. 'trust')
|
||||||
|
|
||||||
feed_command([[lua vim.secure.read('Xfile')]])
|
feed_command([[lua vim.secure.read('Xfile')]])
|
||||||
screen:expect {
|
screen:expect {
|
||||||
@ -131,7 +133,7 @@ describe('vim.secure', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Trust database is not updated
|
-- Trust database is not updated
|
||||||
trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(nil, trust)
|
eq(nil, trust)
|
||||||
|
|
||||||
feed_command([[lua vim.secure.read('Xfile')]])
|
feed_command([[lua vim.secure.read('Xfile')]])
|
||||||
@ -165,7 +167,7 @@ describe('vim.secure', function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Trust database is not updated
|
-- Trust database is not updated
|
||||||
trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(nil, trust)
|
eq(nil, trust)
|
||||||
|
|
||||||
-- Cannot write file
|
-- Cannot write file
|
||||||
@ -210,70 +212,70 @@ describe('vim.secure', function()
|
|||||||
|
|
||||||
it('trust then deny then remove a file using bufnr', function()
|
it('trust then deny then remove a file using bufnr', function()
|
||||||
local cwd = fn.getcwd()
|
local cwd = fn.getcwd()
|
||||||
local hash = fn.sha256(helpers.read_file('test_file'))
|
local hash = fn.sha256(read_file('test_file'))
|
||||||
local full_path = cwd .. pathsep .. 'test_file'
|
local full_path = cwd .. pathsep .. 'test_file'
|
||||||
|
|
||||||
command('edit test_file')
|
command('edit test_file')
|
||||||
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
|
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
|
||||||
local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
local trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
|
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
|
||||||
|
|
||||||
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='deny', bufnr=0})}]]))
|
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='deny', bufnr=0})}]]))
|
||||||
trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('! %s', full_path), vim.trim(trust))
|
eq(string.format('! %s', full_path), vim.trim(trust))
|
||||||
|
|
||||||
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='remove', bufnr=0})}]]))
|
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='remove', bufnr=0})}]]))
|
||||||
trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq('', vim.trim(trust))
|
eq('', vim.trim(trust))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('deny then trust then remove a file using bufnr', function()
|
it('deny then trust then remove a file using bufnr', function()
|
||||||
local cwd = fn.getcwd()
|
local cwd = fn.getcwd()
|
||||||
local hash = fn.sha256(helpers.read_file('test_file'))
|
local hash = fn.sha256(read_file('test_file'))
|
||||||
local full_path = cwd .. pathsep .. 'test_file'
|
local full_path = cwd .. pathsep .. 'test_file'
|
||||||
|
|
||||||
command('edit test_file')
|
command('edit test_file')
|
||||||
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='deny', bufnr=0})}]]))
|
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='deny', bufnr=0})}]]))
|
||||||
local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
local trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('! %s', full_path), vim.trim(trust))
|
eq(string.format('! %s', full_path), vim.trim(trust))
|
||||||
|
|
||||||
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
|
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
|
||||||
trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
|
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
|
||||||
|
|
||||||
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='remove', bufnr=0})}]]))
|
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='remove', bufnr=0})}]]))
|
||||||
trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq('', vim.trim(trust))
|
eq('', vim.trim(trust))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('trust using bufnr then deny then remove a file using path', function()
|
it('trust using bufnr then deny then remove a file using path', function()
|
||||||
local cwd = fn.getcwd()
|
local cwd = fn.getcwd()
|
||||||
local hash = fn.sha256(helpers.read_file('test_file'))
|
local hash = fn.sha256(read_file('test_file'))
|
||||||
local full_path = cwd .. pathsep .. 'test_file'
|
local full_path = cwd .. pathsep .. 'test_file'
|
||||||
|
|
||||||
command('edit test_file')
|
command('edit test_file')
|
||||||
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
|
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
|
||||||
local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
local trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
|
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
|
||||||
|
|
||||||
eq(
|
eq(
|
||||||
{ true, full_path },
|
{ true, full_path },
|
||||||
exec_lua([[return {vim.secure.trust({action='deny', path='test_file'})}]])
|
exec_lua([[return {vim.secure.trust({action='deny', path='test_file'})}]])
|
||||||
)
|
)
|
||||||
trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('! %s', full_path), vim.trim(trust))
|
eq(string.format('! %s', full_path), vim.trim(trust))
|
||||||
|
|
||||||
eq(
|
eq(
|
||||||
{ true, full_path },
|
{ true, full_path },
|
||||||
exec_lua([[return {vim.secure.trust({action='remove', path='test_file'})}]])
|
exec_lua([[return {vim.secure.trust({action='remove', path='test_file'})}]])
|
||||||
)
|
)
|
||||||
trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq('', vim.trim(trust))
|
eq('', vim.trim(trust))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('deny then trust then remove a file using bufnr', function()
|
it('deny then trust then remove a file using bufnr', function()
|
||||||
local cwd = fn.getcwd()
|
local cwd = fn.getcwd()
|
||||||
local hash = fn.sha256(helpers.read_file('test_file'))
|
local hash = fn.sha256(read_file('test_file'))
|
||||||
local full_path = cwd .. pathsep .. 'test_file'
|
local full_path = cwd .. pathsep .. 'test_file'
|
||||||
|
|
||||||
command('edit test_file')
|
command('edit test_file')
|
||||||
@ -281,18 +283,18 @@ describe('vim.secure', function()
|
|||||||
{ true, full_path },
|
{ true, full_path },
|
||||||
exec_lua([[return {vim.secure.trust({action='deny', path='test_file'})}]])
|
exec_lua([[return {vim.secure.trust({action='deny', path='test_file'})}]])
|
||||||
)
|
)
|
||||||
local trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
local trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('! %s', full_path), vim.trim(trust))
|
eq(string.format('! %s', full_path), vim.trim(trust))
|
||||||
|
|
||||||
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
|
eq({ true, full_path }, exec_lua([[return {vim.secure.trust({action='allow', bufnr=0})}]]))
|
||||||
trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
|
eq(string.format('%s %s', hash, full_path), vim.trim(trust))
|
||||||
|
|
||||||
eq(
|
eq(
|
||||||
{ true, full_path },
|
{ true, full_path },
|
||||||
exec_lua([[return {vim.secure.trust({action='remove', path='test_file'})}]])
|
exec_lua([[return {vim.secure.trust({action='remove', path='test_file'})}]])
|
||||||
)
|
)
|
||||||
trust = helpers.read_file(fn.stdpath('state') .. pathsep .. 'trust')
|
trust = read_file(stdpath('state') .. pathsep .. 'trust')
|
||||||
eq('', vim.trim(trust))
|
eq('', vim.trim(trust))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ local exec_lua = helpers.exec_lua
|
|||||||
|
|
||||||
local testdir = 'Xtest-editorconfig'
|
local testdir = 'Xtest-editorconfig'
|
||||||
|
|
||||||
|
--- @param name string
|
||||||
|
--- @param expected table<string,any>
|
||||||
local function test_case(name, expected)
|
local function test_case(name, expected)
|
||||||
local filename = testdir .. pathsep .. name
|
local filename = testdir .. pathsep .. name
|
||||||
command('edit ' .. filename)
|
command('edit ' .. filename)
|
||||||
|
@ -128,6 +128,18 @@ local function fake_lsp_server_setup(test_name, timeout_ms, options, settings)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @class test.lsp.Config
|
||||||
|
--- @field test_name string
|
||||||
|
--- @field timeout_ms? integer
|
||||||
|
--- @field options? table
|
||||||
|
--- @field settings? table
|
||||||
|
---
|
||||||
|
--- @field on_setup? fun()
|
||||||
|
--- @field on_init? fun(client: vim.lsp.Client, ...)
|
||||||
|
--- @field on_handler? fun(...)
|
||||||
|
--- @field on_exit? fun(code: integer, signal: integer)
|
||||||
|
|
||||||
|
--- @param config test.lsp.Config
|
||||||
function M.test_rpc_server(config)
|
function M.test_rpc_server(config)
|
||||||
if config.test_name then
|
if config.test_name then
|
||||||
M.clear_notrace()
|
M.clear_notrace()
|
||||||
@ -158,6 +170,7 @@ function M.test_rpc_server(config)
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
--- @type integer, integer
|
||||||
local code, signal
|
local code, signal
|
||||||
local function on_request(method, args)
|
local function on_request(method, args)
|
||||||
if method == 'init' then
|
if method == 'init' then
|
||||||
|
@ -17,8 +17,8 @@ local fn = helpers.fn
|
|||||||
local retry = helpers.retry
|
local retry = helpers.retry
|
||||||
local stop = helpers.stop
|
local stop = helpers.stop
|
||||||
local NIL = vim.NIL
|
local NIL = vim.NIL
|
||||||
local read_file = require('test.helpers').read_file
|
local read_file = helpers.read_file
|
||||||
local write_file = require('test.helpers').write_file
|
local write_file = helpers.write_file
|
||||||
local is_ci = helpers.is_ci
|
local is_ci = helpers.is_ci
|
||||||
local api = helpers.api
|
local api = helpers.api
|
||||||
local is_os = helpers.is_os
|
local is_os = helpers.is_os
|
||||||
@ -279,7 +279,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_finish',
|
test_name = 'basic_finish',
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -310,7 +310,7 @@ describe('LSP', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('should fire autocommands on attach and detach', function()
|
it('should fire autocommands on attach and detach', function()
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_init',
|
test_name = 'basic_init',
|
||||||
on_setup = function()
|
on_setup = function()
|
||||||
@ -347,7 +347,7 @@ describe('LSP', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('should set default options on attach', function()
|
it('should set default options on attach', function()
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'set_defaults_all_capabilities',
|
test_name = 'set_defaults_all_capabilities',
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -395,7 +395,7 @@ describe('LSP', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('should overwrite options set by ftplugins', function()
|
it('should overwrite options set by ftplugins', function()
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'set_defaults_all_capabilities',
|
test_name = 'set_defaults_all_capabilities',
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -435,7 +435,7 @@ describe('LSP', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('should not overwrite user-defined options', function()
|
it('should not overwrite user-defined options', function()
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'set_defaults_all_capabilities',
|
test_name = 'set_defaults_all_capabilities',
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -506,7 +506,7 @@ describe('LSP', function()
|
|||||||
},
|
},
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'check_workspace_configuration',
|
test_name = 'check_workspace_configuration',
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -596,7 +596,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'text_document_sync_save_bool',
|
test_name = 'text_document_sync_save_bool',
|
||||||
on_init = function(c)
|
on_init = function(c)
|
||||||
@ -690,7 +690,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server({
|
test_rpc_server({
|
||||||
test_name = 'text_document_save_did_open',
|
test_name = 'text_document_save_did_open',
|
||||||
on_init = function(c)
|
on_init = function(c)
|
||||||
@ -730,7 +730,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'text_document_sync_save_includeText',
|
test_name = 'text_document_sync_save_includeText',
|
||||||
on_init = function(c)
|
on_init = function(c)
|
||||||
@ -857,7 +857,7 @@ describe('LSP', function()
|
|||||||
local expected_handlers = {
|
local expected_handlers = {
|
||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'check_forward_request_cancelled',
|
test_name = 'check_forward_request_cancelled',
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -883,7 +883,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ { code = -32801 }, NIL, { method = 'error_code_test', bufnr = 1, client_id = 1 } },
|
{ { code = -32801 }, NIL, { method = 'error_code_test', bufnr = 1, client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'check_forward_content_modified',
|
test_name = 'check_forward_content_modified',
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -913,7 +913,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'slow_request', bufnr = 1, client_id = 1 } },
|
{ NIL, {}, { method = 'slow_request', bufnr = 1, client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'check_pending_request_tracked',
|
test_name = 'check_pending_request_tracked',
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -947,7 +947,7 @@ describe('LSP', function()
|
|||||||
local expected_handlers = {
|
local expected_handlers = {
|
||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'check_cancel_request_tracked',
|
test_name = 'check_cancel_request_tracked',
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -980,7 +980,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'slow_request', bufnr = 1, client_id = 1 } },
|
{ NIL, {}, { method = 'slow_request', bufnr = 1, client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'check_tracked_requests_cleared',
|
test_name = 'check_tracked_requests_cleared',
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -1019,7 +1019,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'slow_request', bufnr = 1, client_id = 1 } },
|
{ NIL, {}, { method = 'slow_request', bufnr = 1, client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'check_tracked_requests_cleared',
|
test_name = 'check_tracked_requests_cleared',
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -1055,7 +1055,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_finish',
|
test_name = 'basic_finish',
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -1097,7 +1097,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_check_buffer_open',
|
test_name = 'basic_check_buffer_open',
|
||||||
on_setup = function()
|
on_setup = function()
|
||||||
@ -1143,7 +1143,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_check_buffer_open',
|
test_name = 'basic_check_buffer_open',
|
||||||
on_setup = function()
|
on_setup = function()
|
||||||
@ -1186,7 +1186,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_check_buffer_open_and_change',
|
test_name = 'basic_check_buffer_open_and_change',
|
||||||
on_setup = function()
|
on_setup = function()
|
||||||
@ -1234,7 +1234,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_check_buffer_open_and_change_noeol',
|
test_name = 'basic_check_buffer_open_and_change_noeol',
|
||||||
on_setup = function()
|
on_setup = function()
|
||||||
@ -1301,7 +1301,7 @@ describe('LSP', function()
|
|||||||
},
|
},
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'inlay_hint',
|
test_name = 'inlay_hint',
|
||||||
on_setup = function()
|
on_setup = function()
|
||||||
@ -1348,7 +1348,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_check_buffer_open_and_change_incremental',
|
test_name = 'basic_check_buffer_open_and_change_incremental',
|
||||||
options = {
|
options = {
|
||||||
@ -1399,7 +1399,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_check_buffer_open_and_change_incremental',
|
test_name = 'basic_check_buffer_open_and_change_incremental',
|
||||||
options = {
|
options = {
|
||||||
@ -1453,7 +1453,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_check_buffer_open_and_change_incremental_editing',
|
test_name = 'basic_check_buffer_open_and_change_incremental_editing',
|
||||||
on_setup = function()
|
on_setup = function()
|
||||||
@ -1498,7 +1498,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_check_buffer_open_and_change_multi',
|
test_name = 'basic_check_buffer_open_and_change_multi',
|
||||||
on_setup = function()
|
on_setup = function()
|
||||||
@ -1549,7 +1549,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_check_buffer_open_and_change_multi_and_close',
|
test_name = 'basic_check_buffer_open_and_change_multi_and_close',
|
||||||
on_setup = function()
|
on_setup = function()
|
||||||
@ -1603,7 +1603,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
{ NIL, {}, { method = 'finish', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'invalid_header',
|
test_name = 'invalid_header',
|
||||||
on_setup = function() end,
|
on_setup = function() end,
|
||||||
@ -1636,7 +1636,7 @@ describe('LSP', function()
|
|||||||
},
|
},
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'decode_nil',
|
test_name = 'decode_nil',
|
||||||
on_setup = function()
|
on_setup = function()
|
||||||
@ -1849,7 +1849,7 @@ describe('LSP', function()
|
|||||||
|
|
||||||
describe('cursor position', function()
|
describe('cursor position', function()
|
||||||
it("don't fix the cursor if the range contains the cursor", function()
|
it("don't fix the cursor if the range contains the cursor", function()
|
||||||
fn.nvim_win_set_cursor(0, { 2, 6 })
|
api.nvim_win_set_cursor(0, { 2, 6 })
|
||||||
local edits = {
|
local edits = {
|
||||||
make_edit(1, 0, 1, 19, 'Second line of text'),
|
make_edit(1, 0, 1, 19, 'Second line of text'),
|
||||||
}
|
}
|
||||||
@ -1861,11 +1861,11 @@ describe('LSP', function()
|
|||||||
'Fourth line of text',
|
'Fourth line of text',
|
||||||
'å å ɧ 汉语 ↥ 🤦 🦄',
|
'å å ɧ 汉语 ↥ 🤦 🦄',
|
||||||
}, buf_lines(1))
|
}, buf_lines(1))
|
||||||
eq({ 2, 6 }, fn.nvim_win_get_cursor(0))
|
eq({ 2, 6 }, api.nvim_win_get_cursor(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('fix the cursor to the valid col if the content was removed', function()
|
it('fix the cursor to the valid col if the content was removed', function()
|
||||||
fn.nvim_win_set_cursor(0, { 2, 6 })
|
api.nvim_win_set_cursor(0, { 2, 6 })
|
||||||
local edits = {
|
local edits = {
|
||||||
make_edit(1, 0, 1, 6, ''),
|
make_edit(1, 0, 1, 6, ''),
|
||||||
make_edit(1, 6, 1, 19, ''),
|
make_edit(1, 6, 1, 19, ''),
|
||||||
@ -1878,11 +1878,11 @@ describe('LSP', function()
|
|||||||
'Fourth line of text',
|
'Fourth line of text',
|
||||||
'å å ɧ 汉语 ↥ 🤦 🦄',
|
'å å ɧ 汉语 ↥ 🤦 🦄',
|
||||||
}, buf_lines(1))
|
}, buf_lines(1))
|
||||||
eq({ 2, 0 }, fn.nvim_win_get_cursor(0))
|
eq({ 2, 0 }, api.nvim_win_get_cursor(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('fix the cursor to the valid row if the content was removed', function()
|
it('fix the cursor to the valid row if the content was removed', function()
|
||||||
fn.nvim_win_set_cursor(0, { 2, 6 })
|
api.nvim_win_set_cursor(0, { 2, 6 })
|
||||||
local edits = {
|
local edits = {
|
||||||
make_edit(1, 0, 1, 6, ''),
|
make_edit(1, 0, 1, 6, ''),
|
||||||
make_edit(0, 18, 5, 0, ''),
|
make_edit(0, 18, 5, 0, ''),
|
||||||
@ -1891,11 +1891,11 @@ describe('LSP', function()
|
|||||||
eq({
|
eq({
|
||||||
'First line of text',
|
'First line of text',
|
||||||
}, buf_lines(1))
|
}, buf_lines(1))
|
||||||
eq({ 1, 17 }, fn.nvim_win_get_cursor(0))
|
eq({ 1, 17 }, api.nvim_win_get_cursor(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('fix the cursor row', function()
|
it('fix the cursor row', function()
|
||||||
fn.nvim_win_set_cursor(0, { 3, 0 })
|
api.nvim_win_set_cursor(0, { 3, 0 })
|
||||||
local edits = {
|
local edits = {
|
||||||
make_edit(1, 0, 2, 0, ''),
|
make_edit(1, 0, 2, 0, ''),
|
||||||
}
|
}
|
||||||
@ -1906,14 +1906,14 @@ describe('LSP', function()
|
|||||||
'Fourth line of text',
|
'Fourth line of text',
|
||||||
'å å ɧ 汉语 ↥ 🤦 🦄',
|
'å å ɧ 汉语 ↥ 🤦 🦄',
|
||||||
}, buf_lines(1))
|
}, buf_lines(1))
|
||||||
eq({ 2, 0 }, fn.nvim_win_get_cursor(0))
|
eq({ 2, 0 }, api.nvim_win_get_cursor(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('fix the cursor col', function()
|
it('fix the cursor col', function()
|
||||||
-- append empty last line. See #22636
|
-- append empty last line. See #22636
|
||||||
exec_lua('vim.api.nvim_buf_set_lines(...)', 1, -1, -1, true, { '' })
|
exec_lua('vim.api.nvim_buf_set_lines(...)', 1, -1, -1, true, { '' })
|
||||||
|
|
||||||
fn.nvim_win_set_cursor(0, { 2, 11 })
|
api.nvim_win_set_cursor(0, { 2, 11 })
|
||||||
local edits = {
|
local edits = {
|
||||||
make_edit(1, 7, 1, 11, ''),
|
make_edit(1, 7, 1, 11, ''),
|
||||||
}
|
}
|
||||||
@ -1926,11 +1926,11 @@ describe('LSP', function()
|
|||||||
'å å ɧ 汉语 ↥ 🤦 🦄',
|
'å å ɧ 汉语 ↥ 🤦 🦄',
|
||||||
'',
|
'',
|
||||||
}, buf_lines(1))
|
}, buf_lines(1))
|
||||||
eq({ 2, 7 }, fn.nvim_win_get_cursor(0))
|
eq({ 2, 7 }, api.nvim_win_get_cursor(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('fix the cursor row and col', function()
|
it('fix the cursor row and col', function()
|
||||||
fn.nvim_win_set_cursor(0, { 2, 12 })
|
api.nvim_win_set_cursor(0, { 2, 12 })
|
||||||
local edits = {
|
local edits = {
|
||||||
make_edit(0, 11, 1, 12, ''),
|
make_edit(0, 11, 1, 12, ''),
|
||||||
}
|
}
|
||||||
@ -1941,7 +1941,7 @@ describe('LSP', function()
|
|||||||
'Fourth line of text',
|
'Fourth line of text',
|
||||||
'å å ɧ 汉语 ↥ 🤦 🦄',
|
'å å ɧ 汉语 ↥ 🤦 🦄',
|
||||||
}, buf_lines(1))
|
}, buf_lines(1))
|
||||||
eq({ 1, 11 }, fn.nvim_win_get_cursor(0))
|
eq({ 1, 11 }, api.nvim_win_get_cursor(0))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -2017,7 +2017,7 @@ describe('LSP', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('apply_text_document_edit', function()
|
describe('apply_text_document_edit', function()
|
||||||
local target_bufnr
|
local target_bufnr --- @type integer
|
||||||
local text_document_edit = function(editVersion)
|
local text_document_edit = function(editVersion)
|
||||||
return {
|
return {
|
||||||
edits = {
|
edits = {
|
||||||
@ -2693,6 +2693,7 @@ describe('LSP', function()
|
|||||||
eq(expected, actual)
|
eq(expected, actual)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('lsp.util.symbols_to_items', function()
|
describe('lsp.util.symbols_to_items', function()
|
||||||
describe('convert DocumentSymbol[] to items', function()
|
describe('convert DocumentSymbol[] to items', function()
|
||||||
it('DocumentSymbol has children', function()
|
it('DocumentSymbol has children', function()
|
||||||
@ -2967,7 +2968,7 @@ describe('LSP', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('lsp.util.jump_to_location', function()
|
describe('lsp.util.jump_to_location', function()
|
||||||
local target_bufnr
|
local target_bufnr --- @type integer
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
target_bufnr = exec_lua [[
|
target_bufnr = exec_lua [[
|
||||||
@ -3027,21 +3028,21 @@ describe('LSP', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('adds current position to jumplist before jumping', function()
|
it('adds current position to jumplist before jumping', function()
|
||||||
fn.nvim_win_set_buf(0, target_bufnr)
|
api.nvim_win_set_buf(0, target_bufnr)
|
||||||
local mark = fn.nvim_buf_get_mark(target_bufnr, "'")
|
local mark = api.nvim_buf_get_mark(target_bufnr, "'")
|
||||||
eq({ 1, 0 }, mark)
|
eq({ 1, 0 }, mark)
|
||||||
|
|
||||||
fn.nvim_win_set_cursor(0, { 2, 3 })
|
api.nvim_win_set_cursor(0, { 2, 3 })
|
||||||
jump(location(0, 9, 0, 9))
|
jump(location(0, 9, 0, 9))
|
||||||
|
|
||||||
mark = fn.nvim_buf_get_mark(target_bufnr, "'")
|
mark = api.nvim_buf_get_mark(target_bufnr, "'")
|
||||||
eq({ 2, 3 }, mark)
|
eq({ 2, 3 }, mark)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('lsp.util.show_document', function()
|
describe('lsp.util.show_document', function()
|
||||||
local target_bufnr
|
local target_bufnr --- @type integer
|
||||||
local target_bufnr2
|
local target_bufnr2 --- @type integer
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
target_bufnr = exec_lua([[
|
target_bufnr = exec_lua([[
|
||||||
@ -3128,101 +3129,101 @@ describe('LSP', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not add current position to jumplist if not focus', function()
|
it('does not add current position to jumplist if not focus', function()
|
||||||
fn.nvim_win_set_buf(0, target_bufnr)
|
api.nvim_win_set_buf(0, target_bufnr)
|
||||||
local mark = fn.nvim_buf_get_mark(target_bufnr, "'")
|
local mark = api.nvim_buf_get_mark(target_bufnr, "'")
|
||||||
eq({ 1, 0 }, mark)
|
eq({ 1, 0 }, mark)
|
||||||
|
|
||||||
fn.nvim_win_set_cursor(0, { 2, 3 })
|
api.nvim_win_set_cursor(0, { 2, 3 })
|
||||||
show_document(location(0, 9, 0, 9), false, true)
|
show_document(location(0, 9, 0, 9), false, true)
|
||||||
show_document(location(0, 9, 0, 9, true), false, true)
|
show_document(location(0, 9, 0, 9, true), false, true)
|
||||||
|
|
||||||
mark = fn.nvim_buf_get_mark(target_bufnr, "'")
|
mark = api.nvim_buf_get_mark(target_bufnr, "'")
|
||||||
eq({ 1, 0 }, mark)
|
eq({ 1, 0 }, mark)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not change cursor position if not focus and not reuse_win', function()
|
it('does not change cursor position if not focus and not reuse_win', function()
|
||||||
fn.nvim_win_set_buf(0, target_bufnr)
|
api.nvim_win_set_buf(0, target_bufnr)
|
||||||
local cursor = fn.nvim_win_get_cursor(0)
|
local cursor = api.nvim_win_get_cursor(0)
|
||||||
|
|
||||||
show_document(location(0, 9, 0, 9), false, false)
|
show_document(location(0, 9, 0, 9), false, false)
|
||||||
eq(cursor, fn.nvim_win_get_cursor(0))
|
eq(cursor, api.nvim_win_get_cursor(0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not change window if not focus', function()
|
it('does not change window if not focus', function()
|
||||||
fn.nvim_win_set_buf(0, target_bufnr)
|
api.nvim_win_set_buf(0, target_bufnr)
|
||||||
local win = fn.nvim_get_current_win()
|
local win = api.nvim_get_current_win()
|
||||||
|
|
||||||
-- same document/bufnr
|
-- same document/bufnr
|
||||||
show_document(location(0, 9, 0, 9), false, true)
|
show_document(location(0, 9, 0, 9), false, true)
|
||||||
eq(win, fn.nvim_get_current_win())
|
eq(win, api.nvim_get_current_win())
|
||||||
|
|
||||||
-- different document/bufnr, new window/split
|
-- different document/bufnr, new window/split
|
||||||
show_document(location(0, 9, 0, 9, true), false, true)
|
show_document(location(0, 9, 0, 9, true), false, true)
|
||||||
eq(2, #fn.nvim_list_wins())
|
eq(2, #api.nvim_list_wins())
|
||||||
eq(win, fn.nvim_get_current_win())
|
eq(win, api.nvim_get_current_win())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("respects 'reuse_win' parameter", function()
|
it("respects 'reuse_win' parameter", function()
|
||||||
fn.nvim_win_set_buf(0, target_bufnr)
|
api.nvim_win_set_buf(0, target_bufnr)
|
||||||
|
|
||||||
-- does not create a new window if the buffer is already open
|
-- does not create a new window if the buffer is already open
|
||||||
show_document(location(0, 9, 0, 9), false, true)
|
show_document(location(0, 9, 0, 9), false, true)
|
||||||
eq(1, #fn.nvim_list_wins())
|
eq(1, #api.nvim_list_wins())
|
||||||
|
|
||||||
-- creates a new window even if the buffer is already open
|
-- creates a new window even if the buffer is already open
|
||||||
show_document(location(0, 9, 0, 9), false, false)
|
show_document(location(0, 9, 0, 9), false, false)
|
||||||
eq(2, #fn.nvim_list_wins())
|
eq(2, #api.nvim_list_wins())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('correctly sets the cursor of the split if range is given without focus', function()
|
it('correctly sets the cursor of the split if range is given without focus', function()
|
||||||
fn.nvim_win_set_buf(0, target_bufnr)
|
api.nvim_win_set_buf(0, target_bufnr)
|
||||||
|
|
||||||
show_document(location(0, 9, 0, 9, true), false, true)
|
show_document(location(0, 9, 0, 9, true), false, true)
|
||||||
|
|
||||||
local wins = fn.nvim_list_wins()
|
local wins = api.nvim_list_wins()
|
||||||
eq(2, #wins)
|
eq(2, #wins)
|
||||||
table.sort(wins)
|
table.sort(wins)
|
||||||
|
|
||||||
eq({ 1, 0 }, fn.nvim_win_get_cursor(wins[1]))
|
eq({ 1, 0 }, api.nvim_win_get_cursor(wins[1]))
|
||||||
eq({ 1, 9 }, fn.nvim_win_get_cursor(wins[2]))
|
eq({ 1, 9 }, api.nvim_win_get_cursor(wins[2]))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not change cursor of the split if not range and not focus', function()
|
it('does not change cursor of the split if not range and not focus', function()
|
||||||
fn.nvim_win_set_buf(0, target_bufnr)
|
api.nvim_win_set_buf(0, target_bufnr)
|
||||||
fn.nvim_win_set_cursor(0, { 2, 3 })
|
api.nvim_win_set_cursor(0, { 2, 3 })
|
||||||
|
|
||||||
exec_lua([[vim.cmd.new()]])
|
exec_lua([[vim.cmd.new()]])
|
||||||
fn.nvim_win_set_buf(0, target_bufnr2)
|
api.nvim_win_set_buf(0, target_bufnr2)
|
||||||
fn.nvim_win_set_cursor(0, { 2, 3 })
|
api.nvim_win_set_cursor(0, { 2, 3 })
|
||||||
|
|
||||||
show_document({ uri = 'file:///fake/uri2' }, false, true)
|
show_document({ uri = 'file:///fake/uri2' }, false, true)
|
||||||
|
|
||||||
local wins = fn.nvim_list_wins()
|
local wins = api.nvim_list_wins()
|
||||||
eq(2, #wins)
|
eq(2, #wins)
|
||||||
eq({ 2, 3 }, fn.nvim_win_get_cursor(wins[1]))
|
eq({ 2, 3 }, api.nvim_win_get_cursor(wins[1]))
|
||||||
eq({ 2, 3 }, fn.nvim_win_get_cursor(wins[2]))
|
eq({ 2, 3 }, api.nvim_win_get_cursor(wins[2]))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('respects existing buffers', function()
|
it('respects existing buffers', function()
|
||||||
fn.nvim_win_set_buf(0, target_bufnr)
|
api.nvim_win_set_buf(0, target_bufnr)
|
||||||
local win = fn.nvim_get_current_win()
|
local win = api.nvim_get_current_win()
|
||||||
|
|
||||||
exec_lua([[vim.cmd.new()]])
|
exec_lua([[vim.cmd.new()]])
|
||||||
fn.nvim_win_set_buf(0, target_bufnr2)
|
api.nvim_win_set_buf(0, target_bufnr2)
|
||||||
fn.nvim_win_set_cursor(0, { 2, 3 })
|
api.nvim_win_set_cursor(0, { 2, 3 })
|
||||||
local split = fn.nvim_get_current_win()
|
local split = api.nvim_get_current_win()
|
||||||
|
|
||||||
-- reuse win for open document/bufnr if called from split
|
-- reuse win for open document/bufnr if called from split
|
||||||
show_document(location(0, 9, 0, 9, true), false, true)
|
show_document(location(0, 9, 0, 9, true), false, true)
|
||||||
eq({ 1, 9 }, fn.nvim_win_get_cursor(split))
|
eq({ 1, 9 }, api.nvim_win_get_cursor(split))
|
||||||
eq(2, #fn.nvim_list_wins())
|
eq(2, #api.nvim_list_wins())
|
||||||
|
|
||||||
fn.nvim_set_current_win(win)
|
api.nvim_set_current_win(win)
|
||||||
|
|
||||||
-- reuse win for open document/bufnr if called outside the split
|
-- reuse win for open document/bufnr if called outside the split
|
||||||
show_document(location(0, 9, 0, 9, true), false, true)
|
show_document(location(0, 9, 0, 9, true), false, true)
|
||||||
eq({ 1, 9 }, fn.nvim_win_get_cursor(split))
|
eq({ 1, 9 }, api.nvim_win_get_cursor(split))
|
||||||
eq(2, #fn.nvim_list_wins())
|
eq(2, #api.nvim_list_wins())
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -3500,7 +3501,7 @@ describe('LSP', function()
|
|||||||
},
|
},
|
||||||
}) do
|
}) do
|
||||||
it(test.it, function()
|
it(test.it, function()
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = test.name,
|
test_name = test.name,
|
||||||
on_init = function(_client)
|
on_init = function(_client)
|
||||||
@ -3550,7 +3551,7 @@ describe('LSP', function()
|
|||||||
|
|
||||||
describe('vim.lsp.buf.code_action', function()
|
describe('vim.lsp.buf.code_action', function()
|
||||||
it('Calls client side command if available', function()
|
it('Calls client side command if available', function()
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
local expected_handlers = {
|
local expected_handlers = {
|
||||||
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
@ -3588,7 +3589,7 @@ describe('LSP', function()
|
|||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
it('Calls workspace/executeCommand if no client side command', function()
|
it('Calls workspace/executeCommand if no client side command', function()
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
local expected_handlers = {
|
local expected_handlers = {
|
||||||
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
||||||
{
|
{
|
||||||
@ -3628,7 +3629,7 @@ describe('LSP', function()
|
|||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
it('Filters and automatically applies action if requested', function()
|
it('Filters and automatically applies action if requested', function()
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
local expected_handlers = {
|
local expected_handlers = {
|
||||||
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
@ -3728,6 +3729,7 @@ describe('LSP', function()
|
|||||||
eq('command:1', result[5].params.command)
|
eq('command:1', result[5].params.command)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('vim.lsp.commands', function()
|
describe('vim.lsp.commands', function()
|
||||||
it('Accepts only string keys', function()
|
it('Accepts only string keys', function()
|
||||||
matches(
|
matches(
|
||||||
@ -3742,9 +3744,10 @@ describe('LSP', function()
|
|||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('vim.lsp.codelens', function()
|
describe('vim.lsp.codelens', function()
|
||||||
it('uses client commands', function()
|
it('uses client commands', function()
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
local expected_handlers = {
|
local expected_handlers = {
|
||||||
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
@ -3798,7 +3801,7 @@ describe('LSP', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('releases buffer refresh lock', function()
|
it('releases buffer refresh lock', function()
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
local expected_handlers = {
|
local expected_handlers = {
|
||||||
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
@ -3965,7 +3968,7 @@ describe('LSP', function()
|
|||||||
|
|
||||||
describe('vim.lsp.buf.format', function()
|
describe('vim.lsp.buf.format', function()
|
||||||
it('Aborts with notify if no client matches filter', function()
|
it('Aborts with notify if no client matches filter', function()
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_init',
|
test_name = 'basic_init',
|
||||||
on_init = function(c)
|
on_init = function(c)
|
||||||
@ -3994,7 +3997,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_formatting',
|
test_name = 'basic_formatting',
|
||||||
on_init = function(c)
|
on_init = function(c)
|
||||||
@ -4027,7 +4030,7 @@ describe('LSP', function()
|
|||||||
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
{ NIL, {}, { method = 'shutdown', client_id = 1 } },
|
||||||
{ NIL, {}, { method = 'start', client_id = 1 } },
|
{ NIL, {}, { method = 'start', client_id = 1 } },
|
||||||
}
|
}
|
||||||
local client
|
local client --- @type vim.lsp.Client
|
||||||
test_rpc_server {
|
test_rpc_server {
|
||||||
test_name = 'basic_formatting',
|
test_name = 'basic_formatting',
|
||||||
on_init = function(c)
|
on_init = function(c)
|
||||||
@ -4150,6 +4153,9 @@ describe('LSP', function()
|
|||||||
end
|
end
|
||||||
]])
|
]])
|
||||||
local fail_msg = '[LSP] Format request failed, no matching language servers.'
|
local fail_msg = '[LSP] Format request failed, no matching language servers.'
|
||||||
|
--- @param name string
|
||||||
|
--- @param formatting boolean
|
||||||
|
--- @param range_formatting boolean
|
||||||
local function check_notify(name, formatting, range_formatting)
|
local function check_notify(name, formatting, range_formatting)
|
||||||
local timeout_msg = '[LSP][' .. name .. '] timeout'
|
local timeout_msg = '[LSP][' .. name .. '] timeout'
|
||||||
exec_lua(
|
exec_lua(
|
||||||
@ -4306,7 +4312,7 @@ describe('LSP', function()
|
|||||||
eq('initialize', result.method)
|
eq('initialize', result.method)
|
||||||
end)
|
end)
|
||||||
it('can connect to lsp server via rpc.domain_socket_connect', function()
|
it('can connect to lsp server via rpc.domain_socket_connect', function()
|
||||||
local tmpfile
|
local tmpfile --- @type string
|
||||||
if is_os('win') then
|
if is_os('win') then
|
||||||
tmpfile = '\\\\.\\\\pipe\\pipe.test'
|
tmpfile = '\\\\.\\\\pipe\\pipe.test'
|
||||||
else
|
else
|
||||||
@ -4761,14 +4767,7 @@ describe('LSP', function()
|
|||||||
)
|
)
|
||||||
|
|
||||||
local function watched_uri(fname)
|
local function watched_uri(fname)
|
||||||
return exec_lua(
|
|
||||||
[[
|
|
||||||
local root_dir, fname = ...
|
|
||||||
return vim.uri_from_fname(root_dir .. '/' .. fname)
|
return vim.uri_from_fname(root_dir .. '/' .. fname)
|
||||||
]],
|
|
||||||
root_dir,
|
|
||||||
fname
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
eq(4, #result)
|
eq(4, #result)
|
||||||
@ -4874,13 +4873,7 @@ describe('LSP', function()
|
|||||||
)
|
)
|
||||||
|
|
||||||
local function watched_uri(fname)
|
local function watched_uri(fname)
|
||||||
return exec_lua(
|
|
||||||
[[
|
|
||||||
local fname = ...
|
|
||||||
return vim.uri_from_fname('/dir/' .. fname)
|
return vim.uri_from_fname('/dir/' .. fname)
|
||||||
]],
|
|
||||||
fname
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
eq(3, #result)
|
eq(3, #result)
|
||||||
@ -5005,30 +4998,21 @@ describe('LSP', function()
|
|||||||
root_dir
|
root_dir
|
||||||
)
|
)
|
||||||
|
|
||||||
local function watched_uri(fname)
|
|
||||||
return exec_lua(
|
|
||||||
[[
|
|
||||||
return vim.uri_from_fname(...)
|
|
||||||
]],
|
|
||||||
fname
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
eq(3, #result)
|
eq(3, #result)
|
||||||
eq('workspace/didChangeWatchedFiles', result[3].method)
|
eq('workspace/didChangeWatchedFiles', result[3].method)
|
||||||
eq({
|
eq({
|
||||||
changes = {
|
changes = {
|
||||||
{
|
{
|
||||||
type = exec_lua([[return vim.lsp.protocol.FileChangeType.Created]]),
|
type = exec_lua([[return vim.lsp.protocol.FileChangeType.Created]]),
|
||||||
uri = watched_uri('file1'),
|
uri = vim.uri_from_fname('file1'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = exec_lua([[return vim.lsp.protocol.FileChangeType.Changed]]),
|
type = exec_lua([[return vim.lsp.protocol.FileChangeType.Changed]]),
|
||||||
uri = watched_uri('file1'),
|
uri = vim.uri_from_fname('file1'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = exec_lua([[return vim.lsp.protocol.FileChangeType.Created]]),
|
type = exec_lua([[return vim.lsp.protocol.FileChangeType.Created]]),
|
||||||
uri = watched_uri('file2'),
|
uri = vim.uri_from_fname('file2'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, result[3].params)
|
}, result[3].params)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local command, rawfeed = helpers.command, helpers.rawfeed
|
local command, feed = helpers.command, helpers.feed
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local exec_lua = helpers.exec_lua
|
local exec_lua = helpers.exec_lua
|
||||||
local fn = helpers.fn
|
local fn = helpers.fn
|
||||||
@ -44,7 +44,7 @@ describe(':Man', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('man.lua: highlight_line()', function()
|
describe('man.lua: highlight_line()', function()
|
||||||
local screen
|
local screen --- @type test.functional.ui.screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
command('syntax on')
|
command('syntax on')
|
||||||
@ -64,7 +64,7 @@ describe(':Man', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('clears backspaces from text and adds highlights', function()
|
it('clears backspaces from text and adds highlights', function()
|
||||||
rawfeed(
|
feed(
|
||||||
[[
|
[[
|
||||||
ithis i<C-v><C-h>is<C-v><C-h>s a<C-v><C-h>a test
|
ithis i<C-v><C-h>is<C-v><C-h>s a<C-v><C-h>a test
|
||||||
with _<C-v><C-h>o_<C-v><C-h>v_<C-v><C-h>e_<C-v><C-h>r_<C-v><C-h>s_<C-v><C-h>t_<C-v><C-h>r_<C-v><C-h>u_<C-v><C-h>c_<C-v><C-h>k text<ESC>]]
|
with _<C-v><C-h>o_<C-v><C-h>v_<C-v><C-h>e_<C-v><C-h>r_<C-v><C-h>s_<C-v><C-h>t_<C-v><C-h>r_<C-v><C-h>u_<C-v><C-h>c_<C-v><C-h>k text<ESC>]]
|
||||||
@ -90,7 +90,7 @@ describe(':Man', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('clears escape sequences from text and adds highlights', function()
|
it('clears escape sequences from text and adds highlights', function()
|
||||||
rawfeed(
|
feed(
|
||||||
[[
|
[[
|
||||||
ithis <C-v><ESC>[1mis <C-v><ESC>[3ma <C-v><ESC>[4mtest<C-v><ESC>[0m
|
ithis <C-v><ESC>[1mis <C-v><ESC>[3ma <C-v><ESC>[4mtest<C-v><ESC>[0m
|
||||||
<C-v><ESC>[4mwith<C-v><ESC>[24m <C-v><ESC>[4mescaped<C-v><ESC>[24m <C-v><ESC>[4mtext<C-v><ESC>[24m<ESC>]]
|
<C-v><ESC>[4mwith<C-v><ESC>[24m <C-v><ESC>[4mescaped<C-v><ESC>[24m <C-v><ESC>[4mtext<C-v><ESC>[24m<ESC>]]
|
||||||
@ -116,7 +116,7 @@ describe(':Man', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('highlights multibyte text', function()
|
it('highlights multibyte text', function()
|
||||||
rawfeed(
|
feed(
|
||||||
[[
|
[[
|
||||||
ithis i<C-v><C-h>is<C-v><C-h>s あ<C-v><C-h>あ test
|
ithis i<C-v><C-h>is<C-v><C-h>s あ<C-v><C-h>あ test
|
||||||
with _<C-v><C-h>ö_<C-v><C-h>v_<C-v><C-h>e_<C-v><C-h>r_<C-v><C-h>s_<C-v><C-h>t_<C-v><C-h>r_<C-v><C-h>u_<C-v><C-h>̃_<C-v><C-h>c_<C-v><C-h>k te<C-v><ESC>[3mxt¶<C-v><ESC>[0m<ESC>]]
|
with _<C-v><C-h>ö_<C-v><C-h>v_<C-v><C-h>e_<C-v><C-h>r_<C-v><C-h>s_<C-v><C-h>t_<C-v><C-h>r_<C-v><C-h>u_<C-v><C-h>̃_<C-v><C-h>c_<C-v><C-h>k te<C-v><ESC>[3mxt¶<C-v><ESC>[0m<ESC>]]
|
||||||
@ -132,7 +132,7 @@ describe(':Man', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('highlights underscores based on context', function()
|
it('highlights underscores based on context', function()
|
||||||
rawfeed(
|
feed(
|
||||||
[[
|
[[
|
||||||
i_<C-v><C-h>_b<C-v><C-h>be<C-v><C-h>eg<C-v><C-h>gi<C-v><C-h>in<C-v><C-h>ns<C-v><C-h>s
|
i_<C-v><C-h>_b<C-v><C-h>be<C-v><C-h>eg<C-v><C-h>gi<C-v><C-h>in<C-v><C-h>ns<C-v><C-h>s
|
||||||
m<C-v><C-h>mi<C-v><C-h>id<C-v><C-h>d_<C-v><C-h>_d<C-v><C-h>dl<C-v><C-h>le<C-v><C-h>e
|
m<C-v><C-h>mi<C-v><C-h>id<C-v><C-h>d_<C-v><C-h>_d<C-v><C-h>dl<C-v><C-h>le<C-v><C-h>e
|
||||||
@ -150,7 +150,7 @@ describe(':Man', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('highlights various bullet formats', function()
|
it('highlights various bullet formats', function()
|
||||||
rawfeed([[
|
feed([[
|
||||||
i· ·<C-v><C-h>·
|
i· ·<C-v><C-h>·
|
||||||
+<C-v><C-h>o
|
+<C-v><C-h>o
|
||||||
+<C-v><C-h>+<C-v><C-h>o<C-v><C-h>o double<ESC>]])
|
+<C-v><C-h>+<C-v><C-h>o<C-v><C-h>o double<ESC>]])
|
||||||
@ -166,7 +166,7 @@ describe(':Man', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('handles : characters in input', function()
|
it('handles : characters in input', function()
|
||||||
rawfeed([[
|
feed([[
|
||||||
i<C-v><C-[>[40m 0 <C-v><C-[>[41m 1 <C-v><C-[>[42m 2 <C-v><C-[>[43m 3
|
i<C-v><C-[>[40m 0 <C-v><C-[>[41m 1 <C-v><C-[>[42m 2 <C-v><C-[>[43m 3
|
||||||
<C-v><C-[>[44m 4 <C-v><C-[>[45m 5 <C-v><C-[>[46m 6 <C-v><C-[>[47m 7 <C-v><C-[>[100m 8 <C-v><C-[>[101m 9
|
<C-v><C-[>[44m 4 <C-v><C-[>[45m 5 <C-v><C-[>[46m 6 <C-v><C-[>[47m 7 <C-v><C-[>[100m 8 <C-v><C-[>[101m 9
|
||||||
<C-v><C-[>[102m 10 <C-v><C-[>[103m 11 <C-v><C-[>[104m 12 <C-v><C-[>[105m 13 <C-v><C-[>[106m 14 <C-v><C-[>[107m 15
|
<C-v><C-[>[102m 10 <C-v><C-[>[103m 11 <C-v><C-[>[104m 12 <C-v><C-[>[105m 13 <C-v><C-[>[106m 14 <C-v><C-[>[107m 15
|
||||||
|
@ -8,7 +8,7 @@ local feed = helpers.feed
|
|||||||
local eq = helpers.eq
|
local eq = helpers.eq
|
||||||
|
|
||||||
describe('matchparen', function()
|
describe('matchparen', function()
|
||||||
local screen
|
local screen --- @type test.functional.ui.screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear { args = { '-u', 'NORC' } }
|
clear { args = { '-u', 'NORC' } }
|
||||||
|
@ -6,7 +6,7 @@ local feed = helpers.feed
|
|||||||
local is_os = helpers.is_os
|
local is_os = helpers.is_os
|
||||||
|
|
||||||
describe(':Tutor', function()
|
describe(':Tutor', function()
|
||||||
local screen
|
local screen --- @type test.functional.ui.screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear({ args = { '--clean' } })
|
clear({ args = { '--clean' } })
|
||||||
|
@ -5,7 +5,7 @@ local exec = helpers.exec
|
|||||||
local api = helpers.api
|
local api = helpers.api
|
||||||
|
|
||||||
describe('Vimscript syntax highlighting', function()
|
describe('Vimscript syntax highlighting', function()
|
||||||
local screen
|
local screen --- @type test.functional.ui.screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
|
@ -271,7 +271,7 @@ end
|
|||||||
--- @field rgb? boolean
|
--- @field rgb? boolean
|
||||||
--- @field _debug_float? boolean
|
--- @field _debug_float? boolean
|
||||||
|
|
||||||
--- @param options test.functional.ui.screen.Opts
|
--- @param options? test.functional.ui.screen.Opts
|
||||||
--- @param session? test.Session
|
--- @param session? test.Session
|
||||||
function Screen:attach(options, session)
|
function Screen:attach(options, session)
|
||||||
session = session or get_session()
|
session = session or get_session()
|
||||||
|
Loading…
Reference in New Issue
Block a user