diff --git a/lua/metals.lua b/lua/metals.lua index b381daa..b4ec2a9 100644 --- a/lua/metals.lua +++ b/lua/metals.lua @@ -508,11 +508,21 @@ M.toggle_setting = function(setting) end M.select_test_suite = function() - test_explorer.dap_select_test_suite() + local config = conf.get_config_cache() + if config and config.settings.metals.testUserInterface == "Test Explorer" then + test_explorer.dap_select_test_suite() + else + log.error_and_show(messages.enable_test_explorer) + end end M.select_test_case = function() - test_explorer.dap_select_test_case() + local config = conf.get_config_cache() + if config and config.settings.metals.testUserInterface == "Test Explorer" then + test_explorer.dap_select_test_case() + else + log.error_and_show(messages.enable_test_explorer) + end end M.open_new_github_issue = function() diff --git a/lua/metals/messages.lua b/lua/metals/messages.lua index 300acc8..b0f1224 100644 --- a/lua/metals/messages.lua +++ b/lua/metals/messages.lua @@ -63,4 +63,7 @@ You recieved a null response for the tree view. If you're using Scala 3, this is expected as it's not support yet. If you're using Scala 2, please create an issue for this in nvim-metals.]] +M.enable_test_explorer = [[ +You can't use this command unless you have "Test Explorer" set as the value of testUserInterface in your config. +You can read more about this in :h metals-nvim-dap.]] return M