Skip to content

Commit e457eac

Browse files
authored
feat(pack): add Moonbit language support (#1224)
1 parent c2d1a80 commit e457eac

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Moonbit Language Pack
2+
3+
Requires:
4+
5+
- [Moonbit CLI tools](https://www.moonbitlang.com/download/#moonbit-cli-tools)
6+
- [moonbit-lsp](https://www.npmjs.com/package/@moonbit/moonbit-lsp)
7+
8+
This plugin pack does the following:
9+
10+
- Adds [`moonbit.nvim`](https://github.com/tonyfettes/moonbit.nvim) plugin which adds
11+
- Adds `moonbit` Treesitter parser
12+
- Adds `moonbit-lsp` language server
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
return {
2+
{
3+
"tonyfettes/moonbit.nvim",
4+
ft = "moonbit",
5+
-- uncomment when mason support added to make sure command is available
6+
-- dependencies = {
7+
-- { "williamboman/mason.nvim", optional = true },
8+
-- },
9+
opts = function(_, opts)
10+
-- only enable treesitter if the plugin is available
11+
if not require("astrocore").is_available "nvim-treesitter" then opts.treesitter = { enabled = false } end
12+
-- only enable the LSP if the lsp command is executable
13+
if vim.fn.executable "moonbit-lsp" == 1 then
14+
local astrolsp_avail, astrolsp = pcall(require, "astrolsp")
15+
if astrolsp_avail then opts.lsp = astrolsp.lsp_opts "moonbit" end
16+
else
17+
opts.lsp = false
18+
end
19+
end,
20+
},
21+
-- uncomment if/when moonbit-lsp is added to lspconfig and mason-lspconfig
22+
-- {
23+
-- "williamboman/mason-lspconfig.nvim",
24+
-- opts = function(_, opts)
25+
-- opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "harper-ls" })
26+
-- end,
27+
-- },
28+
-- uncomment when merged upstream: https://github.com/mason-org/mason-registry/pull/7350
29+
-- {
30+
-- "WhoIsSethDaniel/mason-tool-installer.nvim",
31+
-- optional = true,
32+
-- opts = function(_, opts)
33+
-- opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "moonbit-lsp" })
34+
-- end,
35+
-- },
36+
}

0 commit comments

Comments
 (0)