-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get_available_servers now accepts a filter (#25)
Co-authored-by: William Boman <william@redwill.se>
- Loading branch information
1 parent
af46a16
commit e48a41e
Showing
3 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
local mason_lspconfig = require "mason-lspconfig" | ||
local _ = require "mason-core.functional" | ||
|
||
describe("mason-lspconfig API", function() | ||
it("should return all available servers", function() | ||
local server_mappings = require "mason-lspconfig.mappings.server" | ||
local available_servers = mason_lspconfig.get_available_servers() | ||
assert.equal(#vim.tbl_keys(server_mappings.package_to_lspconfig), #available_servers) | ||
end) | ||
|
||
it("should return all available servers for given filetype", function() | ||
assert.same( | ||
{ "terraformls", "tflint" }, | ||
_.sort_by( | ||
_.identity, | ||
mason_lspconfig.get_available_servers { | ||
filetype = "terraform", | ||
} | ||
) | ||
) | ||
end) | ||
|
||
it("should return all available servers for given filetypes", function() | ||
assert.same( | ||
{ "lemminx", "taplo" }, | ||
_.sort_by( | ||
_.identity, | ||
mason_lspconfig.get_available_servers { | ||
filetype = { "xml", "xsd", "xsl", "toml" }, | ||
} | ||
) | ||
) | ||
end) | ||
|
||
it("should return no servers if filetype predicate has no matches", function() | ||
assert.same( | ||
{}, | ||
mason_lspconfig.get_available_servers { | ||
filetype = { "thisfiletypesimplydoesntexist" }, | ||
} | ||
) | ||
end) | ||
end) |