-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
source.lua
35 lines (29 loc) · 1.11 KB
/
source.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
local _ = require('mason-core.functional')
local Optional = require('mason-core.optional')
local M = {}
---Maps null_ls source name to its corresponding package name.
local null_ls_to_package = {
['cmake_lint'] = 'cmakelint',
['cmake_format'] = 'cmakelang',
['eslint_d'] = 'eslint_d',
['goimports_reviser'] = 'goimports_reviser',
['phpcsfixer'] = 'php-cs-fixer',
['verible_verilog_format'] = 'verible',
['lua_format'] = 'luaformatter',
['ansiblelint'] = 'ansible-lint',
['deno_fmt'] = 'deno',
['ruff_format'] = 'ruff',
['xmlformat'] = 'xmlformatter',
}
local package_to_null_ls = _.invert(null_ls_to_package)
---@param source string: Source Name from NullLs
---@return string: Package Name from Mason
M.getPackageFromNullLs = _.memoize(function(source)
return Optional.of_nilable(null_ls_to_package[source]):or_else_get(_.always(source:gsub('%_', '-')))
end)
---@param package string: Package Name from Mason
---@return string: NullLs Source Name
M.getNullLsFromPackage = _.memoize(function(package)
return Optional.of_nilable(package_to_null_ls[package]):or_else_get(_.always(package:gsub('%-', '_')))
end)
return M