Skip to content

Commit

Permalink
feat: add cbfmt (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamboman authored Aug 21, 2022
1 parent 13299c4 commit 1355e3a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
56 changes: 56 additions & 0 deletions lua/mason-registry/cbfmt/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
local Pkg = require "mason-core.package"
local platform = require "mason-core.platform"
local _ = require "mason-core.functional"
local github = require "mason-core.managers.github"
local path = require "mason-core.path"

local coalesce, when = _.coalesce, _.when

return Pkg.new {
name = "cbfmt",
desc = _.dedent [[
A tool to format codeblocks inside markdown and org documents. It iterates over all codeblocks, and formats them
with the tool(s) specified for the language of the block.
]],
homepage = "https://github.com/lukas-reineke/cbfmt",
languages = { Pkg.Lang.Markdown },
categories = { Pkg.Cat.Formatter },
---@async
---@param ctx InstallContext
install = function(ctx)
local libc = platform.get_libc()

local asset_file = coalesce(
when(platform.is.mac, "cbfmt_macos-x86_64_%s.tar.gz"),
when(
platform.is.linux_x64,
coalesce(
when(libc == "glibc", "cbfmt_linux-x86_64_%s.tar.gz"),
when(libc == "musl", "cbfmt_linux-x86_64-musl_%s.tar.gz")
)
),
when(platform.is.win_x64, "cbfmt_windows-x86_64-msvc_%s.zip")
)

local source = platform.when {
unix = function()
return github.untargz_release_file {
repo = "lukas-reineke/cbfmt",
asset_file = _.format(asset_file),
}
end,
win = function()
return github.unzip_release_file {
repo = "lukas-reineke/cbfmt",
asset_file = _.format(asset_file),
}
end,
}
source.with_receipt()
local strip_extension = _.compose(_.gsub("%.zip$", ""), _.gsub("%.tar%.gz$", ""))
ctx:link_bin(
"cbfmt",
path.concat { strip_extension(source.asset_file), platform.is.win and "cbfmt.exe" or "cbfmt" }
)
end,
}
1 change: 1 addition & 0 deletions lua/mason-registry/index.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ return {
["bsl-language-server"] = "mason-registry.bsl-language-server",
buf = "mason-registry.buf",
buildifier = "mason-registry.buildifier",
cbfmt = "mason-registry.cbfmt",
["cfn-lint"] = "mason-registry.cfn-lint",
["chrome-debug-adapter"] = "mason-registry.chrome-debug-adapter",
["clang-format"] = "mason-registry.clang-format",
Expand Down
2 changes: 1 addition & 1 deletion lua/mason/mappings/language.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ return {
less = { "css-lsp", "prettier", "prettierd" },
liquid = { "curlylint", "shopify-theme-check" },
lua = { "lemmy-help", "lua-language-server", "luacheck", "luaformatter", "selene", "stylua" },
markdown = { "alex", "grammarly-languageserver", "ltex-ls", "markdownlint", "marksman", "prettier", "prettierd", "proselint", "prosemd-lsp", "remark-language-server", "textlint", "vale", "write-good", "zk" },
markdown = { "alex", "cbfmt", "grammarly-languageserver", "ltex-ls", "markdownlint", "marksman", "prettier", "prettierd", "proselint", "prosemd-lsp", "remark-language-server", "textlint", "vale", "write-good", "zk" },
["metamath zero"] = { "metamath-zero-lsp" },
mksh = { "shfmt" },
mustache = { "djlint" },
Expand Down

0 comments on commit 1355e3a

Please sign in to comment.