diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2024-01-03 02:09:18 +0100 |
|---|---|---|
| committer | Justin M. Keyes <justinkz@gmail.com> | 2024-01-03 02:09:29 +0100 |
| commit | 04f2f864e270e772c6326cefdf24947f0130e492 (patch) | |
| tree | 46f83f909b888a66c741032ab955afc6eab84292 /test/functional/plugin | |
| parent | 59d117ec99b6037cb9fad5bbfb6d0b18f5012927 (diff) | |
| download | rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.gz rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.bz2 rneovim-04f2f864e270e772c6326cefdf24947f0130e492.zip | |
refactor: format test/*
Diffstat (limited to 'test/functional/plugin')
| -rw-r--r-- | test/functional/plugin/editorconfig_spec.lua | 2 | ||||
| -rw-r--r-- | test/functional/plugin/health_spec.lua | 124 | ||||
| -rw-r--r-- | test/functional/plugin/lsp/codelens_spec.lua | 43 | ||||
| -rw-r--r-- | test/functional/plugin/lsp/completion_spec.lua | 90 | ||||
| -rw-r--r-- | test/functional/plugin/lsp/diagnostic_spec.lua | 59 | ||||
| -rw-r--r-- | test/functional/plugin/lsp/handler_spec.lua | 19 | ||||
| -rw-r--r-- | test/functional/plugin/lsp/helpers.lua | 43 | ||||
| -rw-r--r-- | test/functional/plugin/lsp/incremental_sync_spec.lua | 426 | ||||
| -rw-r--r-- | test/functional/plugin/lsp/inlay_hint_spec.lua | 16 | ||||
| -rw-r--r-- | test/functional/plugin/lsp/semantic_tokens_spec.lua | 251 | ||||
| -rw-r--r-- | test/functional/plugin/lsp/utils_spec.lua | 117 | ||||
| -rw-r--r-- | test/functional/plugin/lsp_spec.lua | 2215 | ||||
| -rw-r--r-- | test/functional/plugin/man_spec.lua | 115 | ||||
| -rw-r--r-- | test/functional/plugin/matchparen_spec.lua | 13 | ||||
| -rw-r--r-- | test/functional/plugin/msgpack_spec.lua | 497 | ||||
| -rw-r--r-- | test/functional/plugin/shada_spec.lua | 3578 | ||||
| -rw-r--r-- | test/functional/plugin/tutor_spec.lua | 6 |
17 files changed, 4378 insertions, 3236 deletions
diff --git a/test/functional/plugin/editorconfig_spec.lua b/test/functional/plugin/editorconfig_spec.lua index ac78003a8c..2c9ce7ae1a 100644 --- a/test/functional/plugin/editorconfig_spec.lua +++ b/test/functional/plugin/editorconfig_spec.lua @@ -13,7 +13,7 @@ local function test_case(name, expected) local filename = testdir .. pathsep .. name command('edit ' .. filename) for opt, val in pairs(expected) do - eq(val, meths.get_option_value(opt, {buf=0}), name) + eq(val, meths.get_option_value(opt, { buf = 0 }), name) end end diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index 5d32768260..f08f207d39 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -11,9 +11,9 @@ local source = helpers.source local exec_lua = helpers.exec_lua describe(':checkhealth', function() - it("detects invalid $VIMRUNTIME", function() + it('detects invalid $VIMRUNTIME', function() clear({ - env={ VIMRUNTIME='bogus', }, + env = { VIMRUNTIME = 'bogus' }, }) local status, err = pcall(command, 'checkhealth') eq(false, status) @@ -26,11 +26,11 @@ describe(':checkhealth', function() eq(false, status) eq("Invalid 'runtimepath'", string.match(err, 'Invalid.*')) end) - it("detects invalid $VIM", function() + it('detects invalid $VIM', function() clear() -- Do this after startup, otherwise it just breaks $VIMRUNTIME. command("let $VIM='zub'") - command("checkhealth nvim") + command('checkhealth nvim') matches('ERROR $VIM .* zub', curbuf_contents()) end) it('completions can be listed via getcompletion()', function() @@ -38,20 +38,20 @@ describe(':checkhealth', function() eq('nvim', getcompletion('nvim', 'checkhealth')[1]) eq('provider.clipboard', getcompletion('prov', 'checkhealth')[1]) eq('vim.lsp', getcompletion('vim.ls', 'checkhealth')[1]) - neq('vim', getcompletion('^vim', 'checkhealth')[1]) -- should not complete vim.health + neq('vim', getcompletion('^vim', 'checkhealth')[1]) -- should not complete vim.health end) end) describe('health.vim', function() before_each(function() - clear{args={'-u', 'NORC'}} + clear { args = { '-u', 'NORC' } } -- Provides healthcheck functions - command("set runtimepath+=test/functional/fixtures") + command('set runtimepath+=test/functional/fixtures') end) - describe(":checkhealth", function() - it("functions report_*() render correctly", function() - command("checkhealth full_render") + describe(':checkhealth', function() + it('functions report_*() render correctly', function() + command('checkhealth full_render') helpers.expect([[ ============================================================================== @@ -73,8 +73,8 @@ describe('health.vim', function() ]]) end) - it("concatenates multiple reports", function() - command("checkhealth success1 success2 test_plug") + it('concatenates multiple reports', function() + command('checkhealth success1 success2 test_plug') helpers.expect([[ ============================================================================== @@ -103,8 +103,8 @@ describe('health.vim', function() ]]) end) - it("lua plugins submodules", function() - command("checkhealth test_plug.submodule") + it('lua plugins submodules', function() + command('checkhealth test_plug.submodule') helpers.expect([[ ============================================================================== @@ -118,8 +118,8 @@ describe('health.vim', function() ]]) end) - it("... including empty reports", function() - command("checkhealth test_plug.submodule_empty") + it('... including empty reports', function() + command('checkhealth test_plug.submodule_empty') helpers.expect([[ ============================================================================== @@ -129,7 +129,7 @@ describe('health.vim', function() ]]) end) - it("highlights OK, ERROR", function() + it('highlights OK, ERROR', function() local screen = Screen.new(50, 12) screen:attach() screen:set_default_attr_ids({ @@ -138,9 +138,10 @@ describe('health.vim', function() Heading = { foreground = tonumber('0x6a0dad') }, Bar = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGrey }, }) - command("checkhealth foo success1") - command("set nofoldenable nowrap laststatus=0") - screen:expect{grid=[[ + command('checkhealth foo success1') + command('set nofoldenable nowrap laststatus=0') + screen:expect { + grid = [[ ^ | {Bar:──────────────────────────────────────────────────}| {Heading:foo: } | @@ -153,15 +154,17 @@ describe('health.vim', function() {Heading:report 1} | - {Ok:OK} everything is fine | | - ]]} + ]], + } end) - it("fold healthchecks", function() + it('fold healthchecks', function() local screen = Screen.new(50, 7) screen:attach() - command("checkhealth foo success1") - command("set nowrap laststatus=0") - screen:expect{grid=[[ + command('checkhealth foo success1') + command('set nowrap laststatus=0') + screen:expect { + grid = [[ ^ | ──────────────────────────────────────────────────| +WE 4 lines: foo: ·······························| @@ -169,11 +172,12 @@ describe('health.vim', function() +-- 8 lines: test_plug.success1: require("test_pl| ~ | | - ]]} + ]], + } end) - it("gracefully handles invalid healthcheck", function() - command("checkhealth non_existent_healthcheck") + it('gracefully handles invalid healthcheck', function() + command('checkhealth non_existent_healthcheck') -- luacheck: ignore 613 helpers.expect([[ @@ -184,9 +188,9 @@ describe('health.vim', function() ]]) end) - it("does not use vim.health as a healtcheck", function() + it('does not use vim.health as a healtcheck', function() -- vim.health is not a healthcheck - command("checkhealth vim") + command('checkhealth vim') helpers.expect([[ ERROR: No healthchecks found.]]) end) @@ -206,17 +210,18 @@ end) describe(':checkhealth window', function() before_each(function() - clear{args={'-u', 'NORC'}} + clear { args = { '-u', 'NORC' } } -- Provides healthcheck functions - command("set runtimepath+=test/functional/fixtures") - command("set nofoldenable nowrap laststatus=0") + command('set runtimepath+=test/functional/fixtures') + command('set nofoldenable nowrap laststatus=0') end) - it("opens directly if no buffer created", function() + it('opens directly if no buffer created', function() local screen = Screen.new(50, 12) - screen:attach({ext_multigrid=true}) - command("checkhealth success1") - screen:expect{grid=[[ + screen:attach({ ext_multigrid = true }) + command('checkhealth success1') + screen:expect { + grid = [[ ## grid 1 [2:--------------------------------------------------]|*11 [3:--------------------------------------------------]| @@ -234,17 +239,19 @@ describe(':checkhealth window', function() - OK nothing to see here | ## grid 3 | - ]]} + ]], + } end) local function test_health_vsplit(left, emptybuf, mods) local screen = Screen.new(50, 20) - screen:attach({ext_multigrid=true}) + screen:attach({ ext_multigrid = true }) if not emptybuf then insert('hello') end command(mods .. ' checkhealth success1') - screen:expect(([[ + screen:expect( + ([[ ## grid 1 %s [3:--------------------------------------------------]| @@ -268,10 +275,11 @@ describe(':checkhealth window', function() - OK nothing to see here | | ~ |*4 - ]]):format(left - and '[4:-------------------------]│[2:------------------------]|*19' - or '[2:------------------------]│[4:-------------------------]|*19', - emptybuf and ' ' or 'hello') + ]]):format( + left and '[4:-------------------------]│[2:------------------------]|*19' + or '[2:------------------------]│[4:-------------------------]|*19', + emptybuf and ' ' or 'hello' + ) ) end @@ -295,12 +303,13 @@ describe(':checkhealth window', function() local function test_health_split(top, emptybuf, mods) local screen = Screen.new(50, 25) - screen:attach({ext_multigrid=true}) + screen:attach({ ext_multigrid = true }) if not emptybuf then insert('hello') end command(mods .. ' checkhealth success1') - screen:expect(([[ + screen:expect( + ([[ ## grid 1 %s [3:--------------------------------------------------]| @@ -322,17 +331,20 @@ describe(':checkhealth window', function() report 2 | - OK nothing to see here | | - ]]):format(top - and [[ + ]]):format( + top + and [[ [4:--------------------------------------------------]|*12 health:// | [2:--------------------------------------------------]|*11]] - or ([[ + or ([[ [2:--------------------------------------------------]|*11 [No Name] %s | - [4:--------------------------------------------------]|*12]] - ):format(emptybuf and ' ' or '[+]'), - emptybuf and ' ' or 'hello') + [4:--------------------------------------------------]|*12]]):format( + emptybuf and ' ' or '[+]' + ), + emptybuf and ' ' or 'hello' + ) ) end @@ -354,11 +366,11 @@ describe(':checkhealth window', function() end) end - it("opens in tab", function() + it('opens in tab', function() -- create an empty buffer called "my_buff" exec_lua 'vim.api.nvim_create_buf(false, true)' command('file my_buff') - command("checkhealth success1") + command('checkhealth success1') -- define a function that collects all buffers in each tab -- returns a dictionary like {tab1 = ["buf1", "buf2"], tab2 = ["buf3"]} source([[ @@ -375,7 +387,7 @@ describe(':checkhealth window', function() return buffs endfunction ]]) - local buffers_per_tab = exec_lua("return vim.fn.CollectBuffersPerTab()") - eq(buffers_per_tab, {tab1 = { "my_buff" }, tab2 = {"health://"}}) + local buffers_per_tab = exec_lua('return vim.fn.CollectBuffersPerTab()') + eq(buffers_per_tab, { tab1 = { 'my_buff' }, tab2 = { 'health://' } }) end) end) diff --git a/test/functional/plugin/lsp/codelens_spec.lua b/test/functional/plugin/lsp/codelens_spec.lua index 3d7a15a191..29daf7a066 100644 --- a/test/functional/plugin/lsp/codelens_spec.lua +++ b/test/functional/plugin/lsp/codelens_spec.lua @@ -11,17 +11,21 @@ describe('vim.lsp.codelens', function() after_each(helpers.clear) it('on_codelens_stores_and_displays_lenses', function() - local fake_uri = "file:///fake/uri" - local bufnr = exec_lua([[ + local fake_uri = 'file:///fake/uri' + local bufnr = exec_lua( + [[ fake_uri = ... local bufnr = vim.uri_to_bufnr(fake_uri) local lines = {'So', 'many', 'lines'} vim.fn.bufload(bufnr) vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines) return bufnr - ]], fake_uri) + ]], + fake_uri + ) - exec_lua([[ + exec_lua( + [[ local bufnr = ... local lenses = { { @@ -33,14 +37,16 @@ describe('vim.lsp.codelens', function() }, } vim.lsp.codelens.on_codelens(nil, lenses, {method='textDocument/codeLens', client_id=1, bufnr=bufnr}) - ]], bufnr) + ]], + bufnr + ) local stored_lenses = exec_lua('return vim.lsp.codelens.get(...)', bufnr) local expected = { { range = { start = { line = 0, character = 0 }, - ['end'] = { line = 0, character = 0 } + ['end'] = { line = 0, character = 0 }, }, command = { title = 'Lens1', @@ -50,28 +56,35 @@ describe('vim.lsp.codelens', function() } eq(expected, stored_lenses) - local virtual_text_chunks = exec_lua([[ + local virtual_text_chunks = exec_lua( + [[ local bufnr = ... local ns = vim.lsp.codelens.__namespaces[1] local extmarks = vim.api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, {}) return vim.api.nvim_buf_get_extmark_by_id(bufnr, ns, extmarks[1][1], { details = true })[3].virt_text - ]], bufnr) + ]], + bufnr + ) - eq({[1] = {'Lens1', 'LspCodeLens'}}, virtual_text_chunks) + eq({ [1] = { 'Lens1', 'LspCodeLens' } }, virtual_text_chunks) end) it('can clear all lens', function() - local fake_uri = "file:///fake/uri" - local bufnr = exec_lua([[ + local fake_uri = 'file:///fake/uri' + local bufnr = exec_lua( + [[ fake_uri = ... local bufnr = vim.uri_to_bufnr(fake_uri) local lines = {'So', 'many', 'lines'} vim.fn.bufload(bufnr) vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines) return bufnr - ]], fake_uri) + ]], + fake_uri + ) - exec_lua([[ + exec_lua( + [[ local bufnr = ... local lenses = { { @@ -83,7 +96,9 @@ describe('vim.lsp.codelens', function() }, } vim.lsp.codelens.on_codelens(nil, lenses, {method='textDocument/codeLens', client_id=1, bufnr=bufnr}) - ]], bufnr) + ]], + bufnr + ) local stored_lenses = exec_lua('return vim.lsp.codelens.get(...)', bufnr) eq(1, #stored_lenses) diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua index 9354654afe..b49f970385 100644 --- a/test/functional/plugin/lsp/completion_spec.lua +++ b/test/functional/plugin/lsp/completion_spec.lua @@ -3,7 +3,6 @@ local helpers = require('test.functional.helpers')(after_each) local eq = helpers.eq local exec_lua = helpers.exec_lua - --- Convert completion results. --- ---@param line string line contents. Mark cursor position with `|` @@ -13,9 +12,10 @@ local exec_lua = helpers.exec_lua local function complete(line, candidates, lnum) lnum = lnum or 0 -- nvim_win_get_cursor returns 0 based column, line:find returns 1 based - local cursor_col = line:find("|") - 1 - line = line:gsub("|", "") - return exec_lua([[ + local cursor_col = line:find('|') - 1 + line = line:gsub('|', '') + return exec_lua( + [[ local line, cursor_col, lnum, result = ... local line_to_cursor = line:sub(1, cursor_col) local client_start_boundary = vim.fn.match(line_to_cursor, '\\k*$') @@ -32,18 +32,22 @@ local function complete(line, candidates, lnum) items = items, server_start_boundary = server_start_boundary } - ]], line, cursor_col, lnum, candidates) + ]], + line, + cursor_col, + lnum, + candidates + ) end - -describe("vim.lsp._completion", function() +describe('vim.lsp._completion', function() before_each(helpers.clear) -- https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion it('prefers textEdit over label as word', function() local range0 = { start = { line = 0, character = 0 }, - ["end"] = { line = 0, character = 0 }, + ['end'] = { line = 0, character = 0 }, } local completion_list = { -- resolves into label @@ -57,7 +61,12 @@ describe("vim.lsp._completion", function() { label = 'foocar', sortText = 'c', insertText = 'foobar' }, { label = 'foocar', sortText = 'd', insertText = 'foobar' }, -- resolves into textEdit.newText - { label = 'foocar', sortText = 'e', insertText = 'foodar', textEdit = { newText = 'foobar', range = range0 } }, + { + label = 'foocar', + sortText = 'e', + insertText = 'foodar', + textEdit = { newText = 'foobar', range = range0 }, + }, { label = 'foocar', sortText = 'f', textEdit = { newText = 'foobar', range = range0 } }, -- real-world snippet text { @@ -65,7 +74,10 @@ describe("vim.lsp._completion", function() sortText = 'g', insertText = 'foodar', insertTextFormat = 2, - textEdit = { newText = 'foobar(${1:place holder}, ${2:more ...holder{\\}})', range = range0 }, + textEdit = { + newText = 'foobar(${1:place holder}, ${2:more ...holder{\\}})', + range = range0, + }, }, { label = 'foocar', @@ -81,7 +93,7 @@ describe("vim.lsp._completion", function() insertTextFormat = 2, }, -- braced tabstop - { label = 'foocar', sortText = 'j', insertText = 'foodar()${0}', insertTextFormat = 2}, + { label = 'foocar', sortText = 'j', insertText = 'foodar()${0}', insertTextFormat = 2 }, -- plain text { label = 'foocar', @@ -140,32 +152,32 @@ describe("vim.lsp._completion", function() result = vim.tbl_map(function(x) return { abbr = x.abbr, - word = x.word + word = x.word, } end, result.items) eq(expected, result) end) - it("uses correct start boundary", function() + it('uses correct start boundary', function() local completion_list = { isIncomplete = false, items = { { - filterText = "this_thread", - insertText = "this_thread", + filterText = 'this_thread', + insertText = 'this_thread', insertTextFormat = 1, kind = 9, - label = " this_thread", + label = ' this_thread', score = 1.3205767869949, - sortText = "4056f757this_thread", + sortText = '4056f757this_thread', textEdit = { - newText = "this_thread", + newText = 'this_thread', range = { start = { line = 0, character = 7 }, - ["end"] = { line = 0, character = 11 }, + ['end'] = { line = 0, character = 11 }, }, - } + }, }, - } + }, } local expected = { abbr = ' this_thread', @@ -176,50 +188,50 @@ describe("vim.lsp._completion", function() menu = '', word = 'this_thread', } - local result = complete(" std::this|", completion_list) + local result = complete(' std::this|', completion_list) eq(7, result.server_start_boundary) local item = result.items[1] item.user_data = nil eq(expected, item) end) - it("should search from start boundary to cursor position", function() + it('should search from start boundary to cursor position', function() local completion_list = { isIncomplete = false, items = { { - filterText = "this_thread", - insertText = "this_thread", + filterText = 'this_thread', + insertText = 'this_thread', insertTextFormat = 1, kind = 9, - label = " this_thread", + label = ' this_thread', score = 1.3205767869949, - sortText = "4056f757this_thread", + sortText = '4056f757this_thread', textEdit = { - newText = "this_thread", + newText = 'this_thread', range = { start = { line = 0, character = 7 }, - ["end"] = { line = 0, character = 11 }, + ['end'] = { line = 0, character = 11 }, }, - } + }, }, { - filterText = "notthis_thread", - insertText = "notthis_thread", + filterText = 'notthis_thread', + insertText = 'notthis_thread', insertTextFormat = 1, kind = 9, - label = " notthis_thread", + label = ' notthis_thread', score = 1.3205767869949, - sortText = "4056f757this_thread", + sortText = '4056f757this_thread', textEdit = { - newText = "notthis_thread", + newText = 'notthis_thread', range = { start = { line = 0, character = 7 }, - ["end"] = { line = 0, character = 11 }, + ['end'] = { line = 0, character = 11 }, }, - } + }, }, - } + }, } local expected = { abbr = ' this_thread', @@ -230,7 +242,7 @@ describe("vim.lsp._completion", function() menu = '', word = 'this_thread', } - local result = complete(" std::this|is", completion_list) + local result = complete(' std::this|is', completion_list) eq(1, #result.items) local item = result.items[1] item.user_data = nil diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua index 1da0222114..ee8dfc7a60 100644 --- a/test/functional/plugin/lsp/diagnostic_spec.lua +++ b/test/functional/plugin/lsp/diagnostic_spec.lua @@ -12,10 +12,10 @@ describe('vim.lsp.diagnostic', function() local fake_uri before_each(function() - clear {env={ - NVIM_LUA_NOTRACK="1"; - VIMRUNTIME=os.getenv"VIMRUNTIME"; - }} + clear { env = { + NVIM_LUA_NOTRACK = '1', + VIMRUNTIME = os.getenv 'VIMRUNTIME', + } } exec_lua [[ require('vim.lsp') @@ -76,9 +76,10 @@ describe('vim.lsp.diagnostic', function() } ]] - fake_uri = "file:///fake/uri" + fake_uri = 'file:///fake/uri' - exec_lua([[ + exec_lua( + [[ fake_uri = ... diagnostic_bufnr = vim.uri_to_bufnr(fake_uri) local lines = {"1st line of text", "2nd line of text", "wow", "cool", "more", "lines"} @@ -86,7 +87,9 @@ describe('vim.lsp.diagnostic', function() vim.api.nvim_buf_set_lines(diagnostic_bufnr, 0, 1, false, lines) vim.api.nvim_win_set_buf(0, diagnostic_bufnr) return diagnostic_bufnr - ]], fake_uri) + ]], + fake_uri + ) end) after_each(function() @@ -113,17 +116,18 @@ describe('vim.lsp.diagnostic', function() vim.lsp.diagnostic.get_line_diagnostics(diagnostic_bufnr, 1)[1], } ]] - eq({code = 42, data = "Hello world"}, result[1].user_data.lsp) + eq({ code = 42, data = 'Hello world' }, result[1].user_data.lsp) eq(42, result[1].code) eq(42, result[2].code) - eq("Hello world", result[2].data) + eq('Hello world', result[2].data) end) end) - describe("vim.lsp.diagnostic.on_publish_diagnostics", function() + 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([[ + local extmarks = exec_lua( + [[ PublishDiagnostics = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = { spacing = ..., @@ -139,7 +143,9 @@ describe('vim.lsp.diagnostic', function() ) return get_extmarks(diagnostic_bufnr, client_id) - ]], expected_spacing) + ]], + expected_spacing + ) local virt_text = extmarks[1][4].virt_text local spacing = virt_text[1][1] @@ -149,7 +155,8 @@ describe('vim.lsp.diagnostic', function() it('allows configuring the virtual text via vim.lsp.with using a function', function() local expected_spacing = 10 - local extmarks = exec_lua([[ + local extmarks = exec_lua( + [[ spacing = ... PublishDiagnostics = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { @@ -169,7 +176,9 @@ describe('vim.lsp.diagnostic', function() ) return get_extmarks(diagnostic_bufnr, client_id) - ]], expected_spacing) + ]], + expected_spacing + ) local virt_text = extmarks[1][4].virt_text local spacing = virt_text[1][1] @@ -179,7 +188,8 @@ describe('vim.lsp.diagnostic', function() it('allows filtering via severity limit', function() local get_extmark_count_with_severity = function(severity_limit) - return exec_lua([[ + return exec_lua( + [[ PublishDiagnostics = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { underline = false, virtual_text = { @@ -196,20 +206,23 @@ describe('vim.lsp.diagnostic', function() ) return #get_extmarks(diagnostic_bufnr, client_id) - ]], severity_limit) + ]], + severity_limit + ) end -- No messages with Error or higher - eq(0, get_extmark_count_with_severity("Error")) + eq(0, get_extmark_count_with_severity('Error')) -- But now we don't filter it - eq(1, get_extmark_count_with_severity("Warning")) - eq(1, get_extmark_count_with_severity("Hint")) + eq(1, get_extmark_count_with_severity('Warning')) + 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([[ + local line = 'All 💼 and no 🎉 makes Jack a dull 👦' + local result = exec_lua( + [[ local line = ... vim.api.nvim_buf_set_lines(diagnostic_bufnr, 0, -1, false, {line}) @@ -225,7 +238,9 @@ describe('vim.lsp.diagnostic', function() vim.lsp.stop_client(client_id) vim.api.nvim_exec_autocmds('VimLeavePre', { modeline = false }) return diags - ]], line) + ]], + line + ) eq(1, #result) eq(exec_lua([[return vim.str_byteindex(..., 7, true)]], line), result[1].col) eq(exec_lua([[return vim.str_byteindex(..., 8, true)]], line), result[1].end_col) diff --git a/test/functional/plugin/lsp/handler_spec.lua b/test/functional/plugin/lsp/handler_spec.lua index 3086c23fe8..56e29e7337 100644 --- a/test/functional/plugin/lsp/handler_spec.lua +++ b/test/functional/plugin/lsp/handler_spec.lua @@ -8,21 +8,30 @@ local matches = helpers.matches describe('lsp-handlers', function() describe('vim.lsp._with_extend', function() it('should return a table with the default keys', function() - eq({hello = 'world' }, exec_lua [[ + eq( + { hello = 'world' }, + exec_lua [[ return vim.lsp._with_extend('test', { hello = 'world' }) - ]]) + ]] + ) end) it('should override with config keys', function() - eq({hello = 'universe', other = true}, exec_lua [[ + eq( + { hello = 'universe', other = true }, + exec_lua [[ return vim.lsp._with_extend('test', { other = true, hello = 'world' }, { hello = 'universe' }) - ]]) + ]] + ) end) it('should not allow invalid keys', function() matches( '.*Invalid option for `test`.*', - pcall_err(exec_lua, "return vim.lsp._with_extend('test', { hello = 'world' }, { invalid = true })") + pcall_err( + exec_lua, + "return vim.lsp._with_extend('test', { hello = 'world' }, { invalid = true })" + ) ) end) end) diff --git a/test/functional/plugin/lsp/helpers.lua b/test/functional/plugin/lsp/helpers.lua index 15e6a62781..f641b42727 100644 --- a/test/functional/plugin/lsp/helpers.lua +++ b/test/functional/plugin/lsp/helpers.lua @@ -11,11 +11,13 @@ local M = {} function M.clear_notrace() -- problem: here be dragons -- solution: don't look too closely for dragons - clear {env={ - NVIM_LUA_NOTRACK="1"; - NVIM_APPNAME="nvim_lsp_test"; - VIMRUNTIME=os.getenv"VIMRUNTIME"; - }} + clear { + env = { + NVIM_LUA_NOTRACK = '1', + NVIM_APPNAME = 'nvim_lsp_test', + VIMRUNTIME = os.getenv 'VIMRUNTIME', + }, + } end M.create_server_definition = [[ @@ -79,7 +81,8 @@ M.fake_lsp_code = 'test/functional/fixtures/fake-lsp-server.lua' M.fake_lsp_logfile = 'Xtest-fake-lsp.log' local function fake_lsp_server_setup(test_name, timeout_ms, options, settings) - exec_lua([=[ + exec_lua( + [=[ lsp = require('vim.lsp') local test_name, fake_lsp_code, fake_lsp_logfile, timeout, options, settings = ... TEST_RPC_CLIENT_ID = lsp.start_client { @@ -115,33 +118,49 @@ local function fake_lsp_server_setup(test_name, timeout_ms, options, settings) vim.rpcnotify(1, "exit", ...) end; } - ]=], test_name, M.fake_lsp_code, M.fake_lsp_logfile, timeout_ms or 1e3, options or {}, settings or {}) + ]=], + test_name, + M.fake_lsp_code, + M.fake_lsp_logfile, + timeout_ms or 1e3, + options or {}, + settings or {} + ) end function M.test_rpc_server(config) if config.test_name then M.clear_notrace() - fake_lsp_ser |