diff options
| -rw-r--r-- | lua/lvim/core/info.lua | 4 | ||||
| -rw-r--r-- | lua/lvim/lsp/config.lua | 5 | ||||
| -rw-r--r-- | lua/lvim/lsp/manager.lua | 3 | ||||
| -rw-r--r-- | lua/lvim/lsp/utils.lua | 17 | ||||
| -rw-r--r-- | tests/config_loader_spec.lua | 8 | ||||
| -rw-r--r-- | tests/lsp_spec.lua | 36 | ||||
| -rw-r--r-- | utils/bin/test_runner.sh | 10 | 
7 files changed, 44 insertions, 39 deletions
| diff --git a/lua/lvim/core/info.lua b/lua/lvim/core/info.lua index 5707cc30..fc87691e 100644 --- a/lua/lvim/core/info.lua +++ b/lua/lvim/core/info.lua @@ -61,11 +61,13 @@ local function make_client_info(client)    local client_enabled_caps = lsp_utils.get_client_capabilities(client.id)    local name = client.name    local id = client.id +  local filetypes = lsp_utils.get_supported_filetypes(name)    local document_formatting = client.resolved_capabilities.document_formatting    local attached_buffers_list = table.concat(vim.lsp.get_buffers_by_client_id(client.id), ", ")    local client_info = {      fmt("* Name:                      %s", name),      fmt("* Id:                        [%s]", tostring(id)), +    fmt("* filetype(s):               [%s]", table.concat(filetypes, ", ")),      fmt("* Attached buffers:          [%s]", tostring(attached_buffers_list)),      fmt("* Supports formatting:       %s", tostring(document_formatting)),    } @@ -106,7 +108,7 @@ function M.toggle_popup(ft)    local lsp_info = {      "Language Server Protocol (LSP) info", -    fmt "* Associated server(s):", +    fmt "* Active server(s):",    }    for _, client in pairs(clients) do diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index 2d9104ea..ccc524ee 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -46,15 +46,20 @@ return {      "ansiblels",      "denols",      "ember", +    "emmet_ls",      "eslint",      "eslintls", +    "graphql",      "jedi_language_server", +    "ltex", +    "phpactor",      "pylsp",      "rome",      "sqlls",      "sqls",      "stylelint_lsp",      "tailwindcss", +    "tflint",      "volar",    },  } diff --git a/lua/lvim/lsp/manager.lua b/lua/lvim/lsp/manager.lua index 128c7553..dbb7b87f 100644 --- a/lua/lvim/lsp/manager.lua +++ b/lua/lvim/lsp/manager.lua @@ -42,7 +42,7 @@ end  -- manually start the server and don't wait for the usual filetype trigger from lspconfig  local function buf_try_add(server_name, bufnr)    bufnr = bufnr or vim.api.nvim_get_current_buf() -  require("lspconfig")[server_name].manager.try_add(bufnr) +  require("lspconfig")[server_name].manager.try_add_wrapper(bufnr)  end  ---Setup a language server by providing a name @@ -78,7 +78,6 @@ function M.setup(server_name, user_config)        end        install_notification = false        requested_server:setup(config) -      buf_try_add(server_name)      end)    else      -- since it may not be installed, don't attempt to configure the LSP unless there is a custom provider diff --git a/lua/lvim/lsp/utils.lua b/lua/lvim/lsp/utils.lua index a34fbf44..7cc8f54f 100644 --- a/lua/lvim/lsp/utils.lua +++ b/lua/lvim/lsp/utils.lua @@ -49,14 +49,17 @@ function M.get_client_capabilities(client_id)  end  function M.get_supported_filetypes(server_name) -  -- print("got filetypes query request for: " .. server_name) -  local configs = require "lspconfig/configs" -  pcall(require, ("lspconfig/" .. server_name)) -  for _, config in pairs(configs) do -    if config.name == server_name then -      return config.document_config.default_config.filetypes or {} -    end +  -- temporary workaround: https://github.com/neovim/nvim-lspconfig/pull/1358 +  if server_name == "dockerls" then +    return { "dockerfile" } +  end +  local lsp_installer_servers = require "nvim-lsp-installer.servers" +  local server_available, requested_server = lsp_installer_servers.get_server(server_name) +  if not server_available then +    return {}    end + +  return requested_server:get_supported_filetypes()  end  return M diff --git a/tests/config_loader_spec.lua b/tests/config_loader_spec.lua index 8e7ab339..1aef0974 100644 --- a/tests/config_loader_spec.lua +++ b/tests/config_loader_spec.lua @@ -1,5 +1,6 @@  local a = require "plenary.async_lib.tests"  local config = require "lvim.config" +local utils = require "lvim.utils"  a.describe("config-loader", function()    local user_config_path = config:get_user_config_path() @@ -20,18 +21,19 @@ a.describe("config-loader", function()      vim.opt.undodir = "/tmp"      assert.equal(vim.opt.undodir:get()[1], "/tmp")      config:reload() -    assert.equal(vim.opt.undodir:get()[1], get_cache_dir() .. "/undo") +    assert.equal(vim.opt.undodir:get()[1], utils.join_paths(get_cache_dir(), "undo"))    end)    a.it("should not get interrupted by errors in user-config", function()      vim.opt.undodir = "/tmp"      assert.equal(vim.opt.undodir:get()[1], "/tmp") -    os.execute("echo bad_string_test >> " .. user_config_path) +    os.execute(string.format("echo 'bad_string_test' >> %s", user_config_path))      local error_handler = function(msg)        return msg      end      local err = xpcall(config:reload(), error_handler)      assert.falsy(err) -    assert.equal(vim.opt.undodir:get()[1], get_cache_dir() .. "/undo") +    assert.equal(vim.opt.undodir:get()[1], utils.join_paths(get_cache_dir(), "undo")) +    os.execute(string.format("echo '' > %s", user_config_path))    end)  end) diff --git a/tests/lsp_spec.lua b/tests/lsp_spec.lua index 173810e0..b3bb59ab 100644 --- a/tests/lsp_spec.lua +++ b/tests/lsp_spec.lua @@ -44,29 +44,6 @@ a.describe("lsp workflow", function()      end)    end) -  a.it("shoud retrieve supported filetypes correctly", function() -    local ocaml = { -      name = "ocamlls", -      filetypes = { "ocaml", "reason" }, -    } -    local ocaml_fts = require("lvim.lsp.utils").get_supported_filetypes(ocaml.name) -    assert.True(vim.deep_equal(ocaml.filetypes, ocaml_fts)) - -    local tsserver = { -      name = "tsserver", -      filetypes = { -        "javascript", -        "javascriptreact", -        "javascript.jsx", -        "typescript", -        "typescriptreact", -        "typescript.tsx", -      }, -    } -    local tsserver_fts = require("lvim.lsp.utils").get_supported_filetypes(tsserver.name) -    assert.True(vim.deep_equal(tsserver.filetypes, tsserver_fts)) -  end) -    a.it("shoud not include blacklisted servers in the generated templates", function()      assert.True(utils.is_directory(lvim.lsp.templates_dir))      require("lvim.lsp").setup() @@ -77,4 +54,17 @@ a.describe("lsp workflow", function()        end      end    end) + +  a.it("shoud only include one server per generated template", function() +    assert.True(utils.is_directory(lvim.lsp.templates_dir)) +    require("lvim.lsp").setup() + +    for _, file in ipairs(vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)) do +      local count = 0 +      for _ in io.lines(file) do +        count = count + 1 +      end +      assert.equal(count, 1) +    end +  end)  end) diff --git a/utils/bin/test_runner.sh b/utils/bin/test_runner.sh index ee138345..6fc6858b 100644 --- a/utils/bin/test_runner.sh +++ b/utils/bin/test_runner.sh @@ -1,15 +1,17 @@  #!/usr/bin/env bash  set -e -export LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$HOME/.config/lvim"}"  export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$HOME/.local/share/lunarvim"}"  export LVIM_TEST_ENV=true -rm -f "$LUNARVIM_CONFIG_DIR/plugin/packer_compiled.lua" +# we should start with an empty configuration +TEST_BASE_DIR="$(mktemp -d)" + +export LUNARVIM_CONFIG_DIR="$TEST_BASE_DIR" +export LUNARVIM_CACHE_DIR="$TEST_BASE_DIR"  lvim() { -  # TODO: allow running with a minimal_init.lua    nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/tests/minimal_init.lua" --cmd "set runtimepath+=$LUNARVIM_RUNTIME_DIR/lvim" "$@"  } @@ -18,3 +20,5 @@ if [ -n "$1" ]; then  else    lvim --headless -c "PlenaryBustedDirectory tests/ { minimal_init = './tests/minimal_init.lua' }"  fi + +rm -rf "$TEST_BASE_DIR" | 
