diff options
Diffstat (limited to 'test/functional/plugin')
-rw-r--r-- | test/functional/plugin/health_spec.lua | 56 | ||||
-rw-r--r-- | test/functional/plugin/lsp/inlay_hint_spec.lua | 44 | ||||
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 35 |
3 files changed, 108 insertions, 27 deletions
diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index 3632774bff..58634460c8 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -86,7 +86,7 @@ describe('vim.health', function() end) describe(':checkhealth', function() - it('functions report_*() render correctly', function() + it('report_xx() renders correctly', function() command('checkhealth full_render') n.expect([[ @@ -94,15 +94,15 @@ describe('vim.health', function() test_plug.full_render: require("test_plug.full_render.health").check() report 1 ~ - - OK life is fine - - WARNING no what installed + - ✅ OK life is fine + - ⚠️ WARNING no what installed - ADVICE: - pip what - make what report 2 ~ - stuff is stable - - ERROR why no hardcopy + - ❌ ERROR why no hardcopy - ADVICE: - :help |:hardcopy| - :help |:TOhtml| @@ -117,25 +117,25 @@ describe('vim.health', function() test_plug: require("test_plug.health").check() report 1 ~ - - OK everything is fine + - ✅ OK everything is fine report 2 ~ - - OK nothing to see here + - ✅ OK nothing to see here ============================================================================== test_plug.success1: require("test_plug.success1.health").check() report 1 ~ - - OK everything is fine + - ✅ OK everything is fine report 2 ~ - - OK nothing to see here + - ✅ OK nothing to see here ============================================================================== test_plug.success2: require("test_plug.success2.health").check() another 1 ~ - - OK ok + - ✅ OK ok ]]) end) @@ -147,10 +147,10 @@ describe('vim.health', function() test_plug.submodule: require("test_plug.submodule.health").check() report 1 ~ - - OK everything is fine + - ✅ OK everything is fine report 2 ~ - - OK nothing to see here + - ✅ OK nothing to see here ]]) end) @@ -161,7 +161,7 @@ describe('vim.health', function() ============================================================================== test_plug.submodule_empty: require("test_plug.submodule_empty.health").check() - - ERROR The healthcheck report for "test_plug.submodule_empty" plugin is empty. + - ❌ ERROR The healthcheck report for "test_plug.submodule_empty" plugin is empty. ]]) end) @@ -182,13 +182,13 @@ describe('vim.health', function() {Bar: }| {h1:foo: }| | - - {Error:ERROR} No healthcheck found for "foo" plugin. | + - ❌ {Error:ERROR} No healthcheck found for "foo" plugin. | | {Bar: }| {h1:test_plug.success1: require("test_pl}| | {h2:report 1} | - - {Ok:OK} everything is fine | + - ✅ {Ok:OK} everything is fine | | ]], } @@ -202,11 +202,11 @@ describe('vim.health', function() ============================================================================== non_existent_healthcheck: - - ERROR No healthcheck found for "non_existent_healthcheck" plugin. + - ❌ ERROR No healthcheck found for "non_existent_healthcheck" plugin. ]]) end) - it('does not use vim.health as a healtcheck', function() + it('does not use vim.health as a healthcheck', function() -- vim.health is not a healthcheck command('checkhealth vim') n.expect([[ @@ -221,7 +221,7 @@ describe('vim.health', function() test_plug.lua: require("test_plug.lua.health").check() nested lua/ directory ~ - - OK everything is ok + - ✅ OK everything is ok ]]) end) @@ -239,19 +239,19 @@ describe('vim.health', function() nest: require("nest.health").check() healthy pack ~ - - OK healthy ok + - ✅ OK healthy ok ]]) end) end) end) -describe(':checkhealth provider', function() +describe(':checkhealth vim.provider', function() it("works correctly with a wrongly configured 'shell'", function() clear() command([[set shell=echo\ WRONG!!!]]) command('let g:loaded_perl_provider = 0') command('let g:loaded_python3_provider = 0') - command('checkhealth provider') + command('checkhealth vim.provider') eq(nil, string.match(curbuf_contents(), 'WRONG!!!')) end) end) @@ -285,10 +285,10 @@ describe(':checkhealth window', function() {h1:require("test_plug.success1.health").check()} | | {h2:report 1} | - - {32:OK} everything is fine | + - ✅ {32:OK} everything is fine | | {h2:report 2} | - - {32:OK} nothing to see here | + - ✅ {32:OK} nothing to see here | ## grid 3 | ]], @@ -328,12 +328,14 @@ describe(':checkhealth window', function() {h1:success1.health").check()}| | {h2:report 1} | - - {32:OK} everything is fine | + - ✅ {32:OK} everything is | + fine | | {h2:report 2} | - - {32:OK} nothing to see here | + - ✅ {32:OK} nothing to see | + here | | - {1:~ }|*3 + {1:~ }| ]]):format( left and '[4:-------------------------]│[2:------------------------]|*19' or '[2:------------------------]│[4:-------------------------]|*19', @@ -385,10 +387,10 @@ describe(':checkhealth window', function() require("test_plug.success1.health").check() | | report 1 | - - OK everything is fine | + - ✅ OK everything is fine | | report 2 | - - OK nothing to see here | + - ✅ OK nothing to see here | | ]]):format( top diff --git a/test/functional/plugin/lsp/inlay_hint_spec.lua b/test/functional/plugin/lsp/inlay_hint_spec.lua index e410a54c31..3ff190fb55 100644 --- a/test/functional/plugin/lsp/inlay_hint_spec.lua +++ b/test/functional/plugin/lsp/inlay_hint_spec.lua @@ -297,6 +297,50 @@ int main() { end) ) end) + + it('does not request hints from lsp when disabled', function() + exec_lua(function() + _G.server2 = _G._create_server({ + capabilities = { + inlayHintProvider = true, + }, + handlers = { + ['textDocument/inlayHint'] = function(_, _, callback) + _G.got_inlay_hint_request = true + callback(nil, {}) + end, + }, + }) + _G.client2 = vim.lsp.start({ name = 'dummy2', cmd = _G.server2.cmd }) + end) + + local function was_request_sent() + return exec_lua(function() + return _G.got_inlay_hint_request == true + end) + end + + eq(false, was_request_sent()) + + exec_lua(function() + vim.lsp.inlay_hint.get() + end) + + eq(false, was_request_sent()) + + exec_lua(function() + vim.lsp.inlay_hint.enable(false, { bufnr = bufnr }) + vim.lsp.inlay_hint.get() + end) + + eq(false, was_request_sent()) + + exec_lua(function() + vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) + end) + + eq(true, was_request_sent()) + end) end) end) diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 614c49a41f..856c086add 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -6414,5 +6414,40 @@ describe('LSP', function() filetypes = true, }, 'cannot start foo due to config error: .* filetypes: expected table, got boolean') end) + + it('does not start without workspace if workspace_required=true', function() + exec_lua(create_server_definition) + + local tmp1 = t.tmpname(true) + + eq( + { workspace_required = false }, + exec_lua(function() + local server = _G._create_server({ + handlers = { + initialize = function(_, _, callback) + callback(nil, { capabilities = {} }) + end, + }, + }) + + local ws_required = { cmd = server.cmd, workspace_required = true, filetypes = { 'foo' } } + local ws_not_required = vim.deepcopy(ws_required) + ws_not_required.workspace_required = false + + vim.lsp.config('ws_required', ws_required) + vim.lsp.config('ws_not_required', ws_not_required) + vim.lsp.enable('ws_required') + vim.lsp.enable('ws_not_required') + + vim.cmd.edit(assert(tmp1)) + vim.bo.filetype = 'foo' + + local clients = vim.lsp.get_clients({ bufnr = vim.api.nvim_get_current_buf() }) + assert(1 == #clients) + return { workspace_required = clients[1].config.workspace_required } + end) + ) + end) end) end) |