aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/plugin')
-rw-r--r--test/functional/plugin/health_spec.lua10
-rw-r--r--test/functional/plugin/lsp/completion_spec.lua397
-rw-r--r--test/functional/plugin/lsp/diagnostic_spec.lua111
-rw-r--r--test/functional/plugin/lsp/inlay_hint_spec.lua2
-rw-r--r--test/functional/plugin/lsp/semantic_tokens_spec.lua1
-rw-r--r--test/functional/plugin/lsp/utils_spec.lua4
-rw-r--r--test/functional/plugin/lsp_spec.lua149
-rw-r--r--test/functional/plugin/man_spec.lua1
-rw-r--r--test/functional/plugin/matchparen_spec.lua1
-rw-r--r--test/functional/plugin/shada_spec.lua1
-rw-r--r--test/functional/plugin/tohtml_spec.lua3
-rw-r--r--test/functional/plugin/tutor_spec.lua1
-rw-r--r--test/functional/plugin/vim_syntax_spec.lua1
13 files changed, 473 insertions, 209 deletions
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua
index 7089313303..753da64522 100644
--- a/test/functional/plugin/health_spec.lua
+++ b/test/functional/plugin/health_spec.lua
@@ -155,7 +155,6 @@ describe('vim.health', function()
it('highlights OK, ERROR', function()
local screen = Screen.new(50, 12)
- screen:attach()
screen:set_default_attr_ids({
h1 = { reverse = true },
h2 = { foreground = tonumber('0x6a0dad') },
@@ -222,7 +221,7 @@ describe(':checkhealth window', function()
end)
it('opens directly if no buffer created', function()
- local screen = Screen.new(50, 12)
+ local screen = Screen.new(50, 12, { ext_multigrid = true })
screen:set_default_attr_ids {
h1 = { reverse = true },
h2 = { foreground = tonumber('0x6a0dad') },
@@ -230,7 +229,6 @@ describe(':checkhealth window', function()
[14] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray },
[32] = { foreground = Screen.colors.PaleGreen2 },
}
- screen:attach({ ext_multigrid = true })
command('checkhealth success1')
screen:expect {
grid = [[
@@ -256,7 +254,7 @@ describe(':checkhealth window', function()
end)
local function test_health_vsplit(left, emptybuf, mods)
- local screen = Screen.new(50, 20)
+ local screen = Screen.new(50, 20, { ext_multigrid = true })
screen:set_default_attr_ids {
h1 = { reverse = true },
h2 = { foreground = tonumber('0x6a0dad') },
@@ -264,7 +262,6 @@ describe(':checkhealth window', function()
[14] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray },
[32] = { foreground = Screen.colors.PaleGreen2 },
}
- screen:attach({ ext_multigrid = true })
if not emptybuf then
insert('hello')
end
@@ -322,8 +319,7 @@ describe(':checkhealth window', function()
end
local function test_health_split(top, emptybuf, mods)
- local screen = Screen.new(50, 25)
- screen:attach({ ext_multigrid = true })
+ local screen = Screen.new(50, 25, { ext_multigrid = true })
screen._default_attr_ids = nil
if not emptybuf then
insert('hello')
diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua
index 4df8d77d44..39b6ddc105 100644
--- a/test/functional/plugin/lsp/completion_spec.lua
+++ b/test/functional/plugin/lsp/completion_spec.lua
@@ -134,10 +134,14 @@ describe('vim.lsp.completion: item conversion', function()
eq(expected, result)
end)
- it('filters on label if filterText is missing', function()
+ it('does not filter if there is a textEdit', function()
+ local range0 = {
+ start = { line = 0, character = 0 },
+ ['end'] = { line = 0, character = 0 },
+ }
local completion_list = {
- { label = 'foo' },
- { label = 'bar' },
+ { label = 'foo', textEdit = { newText = 'foo', range = range0 } },
+ { label = 'bar', textEdit = { newText = 'bar', range = range0 } },
}
local result = complete('fo|', completion_list)
local expected = {
@@ -145,6 +149,10 @@ describe('vim.lsp.completion: item conversion', function()
abbr = 'foo',
word = 'foo',
},
+ {
+ abbr = 'bar',
+ word = 'bar',
+ },
}
result = vim.tbl_map(function(x)
return {
@@ -152,7 +160,259 @@ describe('vim.lsp.completion: item conversion', function()
word = x.word,
}
end, result.items)
+ local sorter = function(a, b)
+ return a.word > b.word
+ end
+ table.sort(expected, sorter)
+ table.sort(result, sorter)
+ eq(expected, result)
+ end)
+
+ ---@param prefix string
+ ---@param items lsp.CompletionItem[]
+ ---@param expected table[]
+ local assert_completion_matches = function(prefix, items, expected)
+ local result = complete(prefix .. '|', items)
+ result = vim.tbl_map(function(x)
+ return {
+ abbr = x.abbr,
+ word = x.word,
+ }
+ end, result.items)
+ local sorter = function(a, b)
+ return a.word > b.word
+ end
+ table.sort(expected, sorter)
+ table.sort(result, sorter)
eq(expected, result)
+ end
+
+ describe('when completeopt has fuzzy matching enabled', function()
+ before_each(function()
+ exec_lua(function()
+ vim.opt.completeopt:append('fuzzy')
+ end)
+ end)
+ after_each(function()
+ exec_lua(function()
+ vim.opt.completeopt:remove('fuzzy')
+ end)
+ end)
+
+ it('fuzzy matches on filterText', function()
+ assert_completion_matches('fo', {
+ { label = '?.foo', filterText = 'foo' },
+ { label = 'faz other', filterText = 'faz other' },
+ { label = 'bar', filterText = 'bar' },
+ }, {
+ {
+ abbr = 'faz other',
+ word = 'faz other',
+ },
+ {
+ abbr = '?.foo',
+ word = '?.foo',
+ },
+ })
+ end)
+
+ it('fuzzy matches on label when filterText is missing', function()
+ assert_completion_matches('fo', {
+ { label = 'foo' },
+ { label = 'faz other' },
+ { label = 'bar' },
+ }, {
+ {
+ abbr = 'faz other',
+ word = 'faz other',
+ },
+ {
+ abbr = 'foo',
+ word = 'foo',
+ },
+ })
+ end)
+ end)
+
+ describe('when smartcase is enabled', function()
+ before_each(function()
+ exec_lua(function()
+ vim.opt.smartcase = true
+ end)
+ end)
+ after_each(function()
+ exec_lua(function()
+ vim.opt.smartcase = false
+ end)
+ end)
+
+ it('matches filterText case sensitively', function()
+ assert_completion_matches('Fo', {
+ { label = 'foo', filterText = 'foo' },
+ { label = '?.Foo', filterText = 'Foo' },
+ { label = 'Faz other', filterText = 'Faz other' },
+ { label = 'faz other', filterText = 'faz other' },
+ { label = 'bar', filterText = 'bar' },
+ }, {
+ {
+ abbr = '?.Foo',
+ word = '?.Foo',
+ },
+ })
+ end)
+
+ it('matches label case sensitively when filterText is missing', function()
+ assert_completion_matches('Fo', {
+ { label = 'foo' },
+ { label = 'Foo' },
+ { label = 'Faz other' },
+ { label = 'faz other' },
+ { label = 'bar' },
+ }, {
+ {
+ abbr = 'Foo',
+ word = 'Foo',
+ },
+ })
+ end)
+
+ describe('when ignorecase is enabled', function()
+ before_each(function()
+ exec_lua(function()
+ vim.opt.ignorecase = true
+ end)
+ end)
+ after_each(function()
+ exec_lua(function()
+ vim.opt.ignorecase = false
+ end)
+ end)
+
+ it('matches filterText case insensitively if prefix is lowercase', function()
+ assert_completion_matches('fo', {
+ { label = '?.foo', filterText = 'foo' },
+ { label = '?.Foo', filterText = 'Foo' },
+ { label = 'Faz other', filterText = 'Faz other' },
+ { label = 'faz other', filterText = 'faz other' },
+ { label = 'bar', filterText = 'bar' },
+ }, {
+ {
+ abbr = '?.Foo',
+ word = '?.Foo',
+ },
+ {
+ abbr = '?.foo',
+ word = '?.foo',
+ },
+ })
+ end)
+
+ it(
+ 'matches label case insensitively if prefix is lowercase and filterText is missing',
+ function()
+ assert_completion_matches('fo', {
+ { label = 'foo' },
+ { label = 'Foo' },
+ { label = 'Faz other' },
+ { label = 'faz other' },
+ { label = 'bar' },
+ }, {
+ {
+ abbr = 'Foo',
+ word = 'Foo',
+ },
+ {
+ abbr = 'foo',
+ word = 'foo',
+ },
+ })
+ end
+ )
+
+ it('matches filterText case sensitively if prefix has uppercase letters', function()
+ assert_completion_matches('Fo', {
+ { label = 'foo', filterText = 'foo' },
+ { label = '?.Foo', filterText = 'Foo' },
+ { label = 'Faz other', filterText = 'Faz other' },
+ { label = 'faz other', filterText = 'faz other' },
+ { label = 'bar', filterText = 'bar' },
+ }, {
+ {
+ abbr = '?.Foo',
+ word = '?.Foo',
+ },
+ })
+ end)
+
+ it(
+ 'matches label case sensitively if prefix has uppercase letters and filterText is missing',
+ function()
+ assert_completion_matches('Fo', {
+ { label = 'foo' },
+ { label = 'Foo' },
+ { label = 'Faz other' },
+ { label = 'faz other' },
+ { label = 'bar' },
+ }, {
+ {
+ abbr = 'Foo',
+ word = 'Foo',
+ },
+ })
+ end
+ )
+ end)
+ end)
+
+ describe('when ignorecase is enabled', function()
+ before_each(function()
+ exec_lua(function()
+ vim.opt.ignorecase = true
+ end)
+ end)
+ after_each(function()
+ exec_lua(function()
+ vim.opt.ignorecase = false
+ end)
+ end)
+
+ it('matches filterText case insensitively', function()
+ assert_completion_matches('Fo', {
+ { label = '?.foo', filterText = 'foo' },
+ { label = '?.Foo', filterText = 'Foo' },
+ { label = 'Faz other', filterText = 'Faz other' },
+ { label = 'faz other', filterText = 'faz other' },
+ { label = 'bar', filterText = 'bar' },
+ }, {
+ {
+ abbr = '?.Foo',
+ word = '?.Foo',
+ },
+ {
+ abbr = '?.foo',
+ word = '?.foo',
+ },
+ })
+ end)
+
+ it('matches label case insensitively when filterText is missing', function()
+ assert_completion_matches('Fo', {
+ { label = 'foo' },
+ { label = 'Foo' },
+ { label = 'Faz other' },
+ { label = 'faz other' },
+ { label = 'bar' },
+ }, {
+ {
+ abbr = 'Foo',
+ word = 'Foo',
+ },
+ {
+ abbr = 'foo',
+ word = 'foo',
+ },
+ })
+ end)
end)
it('works on non word prefix', function()
@@ -320,7 +580,7 @@ describe('vim.lsp.completion: item conversion', function()
info = '',
kind = 'Module',
menu = '',
- hl_group = '',
+ abbr_hlgroup = '',
word = 'this_thread',
}
local result = complete(' std::this|', completion_list)
@@ -376,7 +636,7 @@ describe('vim.lsp.completion: item conversion', function()
info = '',
kind = 'Module',
menu = '',
- hl_group = '',
+ abbr_hlgroup = '',
word = 'this_thread',
}
local result = complete(' std::this|is', completion_list)
@@ -471,6 +731,39 @@ describe('vim.lsp.completion: item conversion', function()
)
end)
+--- @param completion_result lsp.CompletionList
+--- @return integer
+local function create_server(completion_result)
+ return exec_lua(function()
+ local server = _G._create_server({
+ capabilities = {
+ completionProvider = {
+ triggerCharacters = { '.' },
+ },
+ },
+ handlers = {
+ ['textDocument/completion'] = function(_, _, callback)
+ callback(nil, completion_result)
+ end,
+ },
+ })
+
+ local bufnr = vim.api.nvim_get_current_buf()
+ vim.api.nvim_win_set_buf(0, bufnr)
+ return vim.lsp.start({
+ name = 'dummy',
+ cmd = server.cmd,
+ on_attach = function(client, bufnr0)
+ vim.lsp.completion.enable(true, client.id, bufnr0, {
+ convert = function(item)
+ return { abbr = item.label:gsub('%b()', '') }
+ end,
+ })
+ end,
+ })
+ end)
+end
+
describe('vim.lsp.completion: protocol', function()
before_each(function()
clear()
@@ -487,39 +780,6 @@ describe('vim.lsp.completion: protocol', function()
after_each(clear)
- --- @param completion_result lsp.CompletionList
- --- @return integer
- local function create_server(completion_result)
- return exec_lua(function()
- local server = _G._create_server({
- capabilities = {
- completionProvider = {
- triggerCharacters = { '.' },
- },
- },
- handlers = {
- ['textDocument/completion'] = function(_, _, callback)
- callback(nil, completion_result)
- end,
- },
- })
-
- local bufnr = vim.api.nvim_get_current_buf()
- vim.api.nvim_win_set_buf(0, bufnr)
- return vim.lsp.start({
- name = 'dummy',
- cmd = server.cmd,
- on_attach = function(client, bufnr0)
- vim.lsp.completion.enable(true, client.id, bufnr0, {
- convert = function(item)
- return { abbr = item.label:gsub('%b()', '') }
- end,
- })
- end,
- })
- end)
- end
-
local function assert_matches(fn)
retry(nil, nil, function()
fn(exec_lua('return _G.capture.matches'))
@@ -570,7 +830,7 @@ describe('vim.lsp.completion: protocol', function()
info = '',
kind = 'Unknown',
menu = '',
- hl_group = '',
+ abbr_hlgroup = '',
user_data = {
nvim = {
lsp = {
@@ -591,7 +851,7 @@ describe('vim.lsp.completion: protocol', function()
info = '',
kind = 'Unknown',
menu = '',
- hl_group = 'DiagnosticDeprecated',
+ abbr_hlgroup = 'DiagnosticDeprecated',
user_data = {
nvim = {
lsp = {
@@ -613,7 +873,7 @@ describe('vim.lsp.completion: protocol', function()
info = '',
kind = 'Unknown',
menu = '',
- hl_group = 'DiagnosticDeprecated',
+ abbr_hlgroup = 'DiagnosticDeprecated',
user_data = {
nvim = {
lsp = {
@@ -726,3 +986,58 @@ describe('vim.lsp.completion: protocol', function()
end)
end)
end)
+
+describe('vim.lsp.completion: integration', function()
+ before_each(function()
+ clear()
+ exec_lua(create_server_definition)
+ exec_lua(function()
+ vim.fn.complete = vim.schedule_wrap(vim.fn.complete)
+ end)
+ end)
+
+ after_each(clear)
+
+ it('puts cursor at the end of completed word', function()
+ local completion_list = {
+ isIncomplete = false,
+ items = {
+ {
+ label = 'hello',
+ insertText = '${1:hello} friends',
+ insertTextFormat = 2,
+ },
+ },
+ }
+ exec_lua(function()
+ vim.o.completeopt = 'menuone,noselect'
+ end)
+ create_server(completion_list)
+ feed('i world<esc>0ih<c-x><c-o>')
+ retry(nil, nil, function()
+ eq(
+ 1,
+ exec_lua(function()
+ return vim.fn.pumvisible()
+ end)
+ )
+ end)
+ feed('<C-n><C-y>')
+ eq(
+ { true, { 'hello friends world' } },
+ exec_lua(function()
+ return {
+ vim.snippet.active({ direction = 1 }),
+ vim.api.nvim_buf_get_lines(0, 0, -1, true),
+ }
+ end)
+ )
+ feed('<tab>')
+ eq(
+ #'hello friends',
+ exec_lua(function()
+ return vim.api.nvim_win_get_cursor(0)[2]
+ end)
+ )
+ end)
+end)
diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua
index 78c684083b..5afbe22793 100644
--- a/test/functional/plugin/lsp/diagnostic_spec.lua
+++ b/test/functional/plugin/lsp/diagnostic_spec.lua
@@ -120,85 +120,6 @@ describe('vim.lsp.diagnostic', function()
end)
describe('vim.lsp.diagnostic.on_publish_diagnostics', function()
- it('allows configuring the virtual text via vim.lsp.with', function()
- local expected_spacing = 10
- local extmarks = exec_lua(function()
- _G.PublishDiagnostics = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
- virtual_text = {
- spacing = expected_spacing,
- },
- })
-
- _G.PublishDiagnostics(nil, {
- uri = fake_uri,
- diagnostics = {
- _G.make_error('Delayed Diagnostic', 4, 4, 4, 4),
- },
- }, { client_id = client_id })
-
- return _G.get_extmarks(diagnostic_bufnr, client_id)
- end)
-
- local spacing = extmarks[1][4].virt_text[1][1]
-
- eq(expected_spacing, #spacing)
- end)
-
- it('allows configuring the virtual text via vim.lsp.with using a function', function()
- local expected_spacing = 10
- local extmarks = exec_lua(function()
- _G.PublishDiagnostics = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
- virtual_text = function()
- return {
- spacing = expected_spacing,
- }
- end,
- })
-
- _G.PublishDiagnostics(nil, {
- uri = fake_uri,
- diagnostics = {
- _G.make_error('Delayed Diagnostic', 4, 4, 4, 4),
- },
- }, { client_id = client_id })
-
- return _G.get_extmarks(diagnostic_bufnr, client_id)
- end)
-
- local spacing = extmarks[1][4].virt_text[1][1]
-
- eq(expected_spacing, #spacing)
- end)
-
- it('allows filtering via severity limit', function()
- local get_extmark_count_with_severity = function(severity_limit)
- return exec_lua(function()
- _G.PublishDiagnostics = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
- underline = false,
- virtual_text = {
- severity = { min = severity_limit },
- },
- })
-
- _G.PublishDiagnostics(nil, {
- uri = fake_uri,
- diagnostics = {
- _G.make_warning('Delayed Diagnostic', 4, 4, 4, 4),
- },
- }, { client_id = client_id })
-
- return #_G.get_extmarks(diagnostic_bufnr, client_id)
- end, client_id, fake_uri, severity_limit)
- end
-
- -- No messages with Error or higher
- eq(0, get_extmark_count_with_severity('ERROR'))
-
- -- But now we don't filter it
- eq(1, get_extmark_count_with_severity('WARN'))
- eq(1, get_extmark_count_with_severity('HINT'))
- end)
-
it('correctly handles UTF-16 offsets', function()
local line = 'All 💼 and no 🎉 makes Jack a dull 👦'
local result = exec_lua(function()
@@ -219,13 +140,13 @@ describe('vim.lsp.diagnostic', function()
eq(1, #result)
eq(
exec_lua(function()
- return vim.str_byteindex(line, 7, true)
+ return vim.str_byteindex(line, 'utf-16', 7)
end),
result[1].col
)
eq(
exec_lua(function()
- return vim.str_byteindex(line, 8, true)
+ return vim.str_byteindex(line, 'utf-16', 8)
end),
result[1].end_col
)
@@ -380,34 +301,6 @@ describe('vim.lsp.diagnostic', function()
eq(1, diagnostics[1].severity)
end)
- it('allows configuring the virtual text via vim.lsp.with', function()
- local expected_spacing = 10
- local extmarks = exec_lua(function()
- _G.Diagnostic = vim.lsp.with(vim.lsp.diagnostic.on_diagnostic, {
- virtual_text = {
- spacing = expected_spacing,
- },
- })
-
- _G.Diagnostic(nil, {
- kind = 'full',
- items = {
- _G.make_error('Pull Diagnostic', 4, 4, 4, 4),
- },
- }, {
- params = {
- textDocument = { uri = fake_uri },
- },
- uri = fake_uri,
- client_id = client_id,
- }, {})
-
- return _G.get_extmarks(diagnostic_bufnr, client_id)
- end)
- eq(2, #extmarks)
- eq(expected_spacing, #extmarks[1][4].virt_text[1][1])
- end)
-
it('clears diagnostics when client detaches', function()
exec_lua(function()
vim.lsp.diagnostic.on_diagnostic(nil, {
diff --git a/test/functional/plugin/lsp/inlay_hint_spec.lua b/test/functional/plugin/lsp/inlay_hint_spec.lua
index 471f2cc3e8..fc6c3f46f7 100644
--- a/test/functional/plugin/lsp/inlay_hint_spec.lua
+++ b/test/functional/plugin/lsp/inlay_hint_spec.lua
@@ -67,7 +67,6 @@ int main() {
before_each(function()
clear_notrace()
screen = Screen.new(50, 9)
- screen:attach()
bufnr = n.api.nvim_get_current_buf()
exec_lua(create_server_definition)
@@ -339,7 +338,6 @@ test text
before_each(function()
clear_notrace()
screen = Screen.new(50, 3)
- screen:attach()
exec_lua(create_server_definition)
bufnr = n.api.nvim_get_current_buf()
diff --git a/test/functional/plugin/lsp/semantic_tokens_spec.lua b/test/functional/plugin/lsp/semantic_tokens_spec.lua
index f72aab7e0b..280bd27207 100644
--- a/test/functional/plugin/lsp/semantic_tokens_spec.lua
+++ b/test/functional/plugin/lsp/semantic_tokens_spec.lua
@@ -28,7 +28,6 @@ describe('semantic token highlighting', function()
local screen --- @type test.functional.ui.screen
before_each(function()
screen = Screen.new(40, 16)
- screen:attach()
screen:set_default_attr_ids {
[1] = { bold = true, foreground = Screen.colors.Blue1 },
[2] = { foreground = Screen.colors.DarkCyan },
diff --git a/test/functional/plugin/lsp/utils_spec.lua b/test/functional/plugin/lsp/utils_spec.lua
index 64d58eeffd..813b8de812 100644
--- a/test/functional/plugin/lsp/utils_spec.lua
+++ b/test/functional/plugin/lsp/utils_spec.lua
@@ -181,11 +181,9 @@ describe('vim.lsp.util', function()
eq(expected_anchor, string.sub(opts.anchor, 1, 1))
end
- local screen --- @type test.functional.ui.screen
before_each(function()
n.clear()
- screen = Screen.new(80, 80)
- screen:attach()
+ local _ = Screen.new(80, 80)
feed('79i<CR><Esc>') -- fill screen with empty lines
end)
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 9956fdf628..5222216faf 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -2586,7 +2586,7 @@ describe('LSP', function()
},
},
}
- eq(false, pcall(exec_lua, 'vim.lsp.util.apply_workspace_edit(...)', edit))
+ eq(false, pcall(exec_lua, 'vim.lsp.util.apply_workspace_edit(...)', edit, 'utf-16'))
eq(false, vim.uv.fs_stat(tmpfile) ~= nil)
end)
end)
@@ -3134,44 +3134,6 @@ describe('LSP', function()
end)
end)
- describe('lsp.util._get_symbol_kind_name', function()
- it('returns the name specified by protocol', function()
- eq(
- 'File',
- exec_lua(function()
- return vim.lsp.util._get_symbol_kind_name(1)
- end)
- )
- eq(
- 'TypeParameter',
- exec_lua(function()
- return vim.lsp.util._get_symbol_kind_name(26)
- end)
- )
- end)
-
- it('returns the name not specified by protocol', function()
- eq(
- 'Unknown',
- exec_lua(function()
- return vim.lsp.util._get_symbol_kind_name(nil)
- end)
- )
- eq(
- 'Unknown',
- exec_lua(function()
- return vim.lsp.util._get_symbol_kind_name(vim.NIL)
- end)
- )
- eq(
- 'Unknown',
- exec_lua(function()
- return vim.lsp.util._get_symbol_kind_name(1000)
- end)
- )
- end)
- end)
-
describe('lsp.util.jump_to_location', function()
local target_bufnr --- @type integer
@@ -3519,6 +3481,30 @@ describe('LSP', function()
local expected = { '```cs', 'TestEntity.TestEntity()', '```', 'some doc' }
eq(expected, result)
end)
+
+ it('highlights active parameters in multiline signature labels', function()
+ local _, hl = exec_lua(function()
+ local signature_help = {
+ activeSignature = 0,
+ signatures = {
+ {
+ activeParameter = 1,
+ label = 'fn bar(\n _: void,\n _: void,\n) void',
+ parameters = {
+ { label = '_: void' },
+ { label = '_: void' },
+ },
+ },
+ },
+ }
+ return vim.lsp.util.convert_signature_help_to_markdown_lines(signature_help, 'zig', { '(' })
+ end)
+ -- Note that although the higlight positions below are 0-indexed, the 2nd parameter
+ -- corresponds to the 3rd line because the first line is the ``` from the
+ -- Markdown block.
+ local expected = { 3, 4, 3, 11 }
+ eq(expected, hl)
+ end)
end)
describe('lsp.util.get_effective_tabstop', function()
@@ -5090,6 +5076,91 @@ describe('LSP', function()
end)
end)
+ describe('lsp.buf.definition', function()
+ it('jumps to single location', function()
+ exec_lua(create_server_definition)
+ local result = exec_lua(function()
+ local bufnr = vim.api.nvim_get_current_buf()
+ local server = _G._create_server({
+ capabilities = {
+ definitionProvider = true,
+ },
+ handlers = {
+ ['textDocument/definition'] = function(_, _, callback)
+ local location = {
+ range = {
+ start = { line = 0, character = 0 },
+ ['end'] = { line = 0, character = 0 },
+ },
+ uri = vim.uri_from_bufnr(bufnr),
+ }
+ callback(nil, location)
+ end,
+ },
+ })
+ local win = vim.api.nvim_get_current_win()
+ vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, { 'local x = 10', '', 'print(x)' })
+ vim.api.nvim_win_set_cursor(win, { 3, 6 })
+ local client_id = assert(vim.lsp.start({ name = 'dummy', cmd = server.cmd }))
+ vim.lsp.buf.definition()
+ vim.lsp.stop_client(client_id)
+ return {
+ cursor = vim.api.nvim_win_get_cursor(win),
+ messages = server.messages,
+ tagstack = vim.fn.gettagstack(win),
+ }
+ end)
+ eq('textDocument/definition', result.messages[3].method)
+ eq({ 1, 0 }, result.cursor)
+ eq(1, #result.tagstack.items)
+ eq('x', result.tagstack.items[1].tagname)
+ eq(3, result.tagstack.items[1].from[2])
+ eq(7, result.tagstack.items[1].from[3])
+ end)
+ it('merges results from multiple servers', function()
+ exec_lua(create_server_definition)
+ local result = exec_lua(function()
+ local bufnr = vim.api.nvim_get_current_buf()
+ local function serveropts(character)
+ return {
+ capabilities = {
+ definitionProvider = true,
+ },
+ handlers = {
+ ['textDocument/definition'] = function(_, _, callback)
+ local location = {
+ range = {
+ start = { line = 0, character = character },
+ ['end'] = { line = 0, character = character },
+ },
+ uri = vim.uri_from_bufnr(bufnr),
+ }
+ callback(nil, location)
+ end,
+ },
+ }
+ end
+ local server1 = _G._create_server(serveropts(0))
+ local server2 = _G._create_server(serveropts(7))
+ local win = vim.api.nvim_get_current_win()
+ vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, { 'local x = 10', '', 'print(x)' })
+ vim.api.nvim_win_set_cursor(win, { 3, 6 })
+ local client_id1 = assert(vim.lsp.start({ name = 'dummy', cmd = server1.cmd }))
+ local client_id2 = assert(vim.lsp.start({ name = 'dummy', cmd = server2.cmd }))
+ local response
+ vim.lsp.buf.definition({
+ on_list = function(r)
+ response = r
+ end,
+ })
+ vim.lsp.stop_client(client_id1)
+ vim.lsp.stop_client(client_id2)
+ return response
+ end)
+ eq(2, #result.items)
+ end)
+ end)
+
describe('vim.lsp.tagfunc', function()
before_each(function()
clear()
diff --git a/test/functional/plugin/man_spec.lua b/test/functional/plugin/man_spec.lua
index 6f0eeff748..8906e60dce 100644
--- a/test/functional/plugin/man_spec.lua
+++ b/test/functional/plugin/man_spec.lua
@@ -60,7 +60,6 @@ describe(':Man', function()
c = { foreground = Screen.colors.Blue }, -- control chars
eob = { bold = true, foreground = Screen.colors.Blue }, -- empty line '~'s
})
- screen:attach()
end)
it('clears backspaces from text and adds highlights', function()
diff --git a/test/functional/plugin/matchparen_spec.lua b/test/functional/plugin/matchparen_spec.lua
index ae718ac1bd..b2bbdb2ef6 100644
--- a/test/functional/plugin/matchparen_spec.lua
+++ b/test/functional/plugin/matchparen_spec.lua
@@ -14,7 +14,6 @@ describe('matchparen', function()
before_each(function()
clear { args = { '-u', 'NORC' } }
screen = Screen.new(20, 5)
- screen:attach()
screen:set_default_attr_ids({
[0] = { bold = true, foreground = 255 },
[1] = { bold = true },
diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua
index c9d49f7d01..f33819f364 100644
--- a/test/functional/plugin/shada_spec.lua
+++ b/test/functional/plugin/shada_spec.lua
@@ -3053,7 +3053,6 @@ describe('syntax/shada.vim', function()
[7] = { bold = true, reverse = true },
[8] = { bold = true, foreground = Screen.colors.Blue },
}
- screen:attach()
api.nvim_buf_set_lines(0, 0, 1, true, {
'Header with timestamp ' .. epoch .. ':',
diff --git a/test/functional/plugin/tohtml_spec.lua b/test/functional/plugin/tohtml_spec.lua
index 1d05f4d6b4..afd4169006 100644
--- a/test/functional/plugin/tohtml_spec.lua
+++ b/test/functional/plugin/tohtml_spec.lua
@@ -185,8 +185,7 @@ describe(':TOhtml', function()
local screen
before_each(function()
clear({ args = { '--clean' } })
- screen = Screen.new(80, 80)
- screen:attach({ term_name = 'xterm' })
+ screen = Screen.new(80, 80, { term_name = 'xterm' })
exec('colorscheme default')
end)
diff --git a/test/functional/plugin/tutor_spec.lua b/test/functional/plugin/tutor_spec.lua
index 9f381d45db..09cd22ab6c 100644
--- a/test/functional/plugin/tutor_spec.lua
+++ b/test/functional/plugin/tutor_spec.lua
@@ -24,7 +24,6 @@ describe(':Tutor', function()
[5] = { bold = true, foreground = Screen.colors.Magenta1 },
[6] = { italic = true },
})
- screen:attach()
end)
it('applies {unix:…,win:…} transform', function()
diff --git a/test/functional/plugin/vim_syntax_spec.lua b/test/functional/plugin/vim_syntax_spec.lua
index d99a69eab9..bdb4534cba 100644
--- a/test/functional/plugin/vim_syntax_spec.lua
+++ b/test/functional/plugin/vim_syntax_spec.lua
@@ -21,7 +21,6 @@ describe('Vimscript syntax highlighting', function()
[1] = { foreground = Screen.colors.Brown, bold = true },
[2] = { foreground = tonumber('0x6a0dad') },
})
- screen:attach()
end)
it('prefixed boolean options are highlighted properly', function()