Skip to content

Commit 692f92d

Browse files
authored
feat: mpls #4341
1 parent d8bf4c4 commit 692f92d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

lsp/mpls.lua

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---@brief
2+
---
3+
--- https://github.com/mhersson/mpls
4+
---
5+
--- Markdown Preview Language Server
6+
7+
---@type vim.lsp.Config
8+
return {
9+
cmd = {
10+
'mpls',
11+
'--theme',
12+
'dark',
13+
'--enable-emoji',
14+
'--enable-footnotes',
15+
'--no-auto',
16+
},
17+
root_markers = { '.marksman.toml', '.git' },
18+
filetypes = { 'markdown' },
19+
on_attach = function(client, bufnr)
20+
vim.api.nvim_create_autocmd('BufEnter', {
21+
pattern = { '*.md' },
22+
group = vim.api.nvim_create_augroup('lspconfig.mpls.focus', { clear = true }),
23+
callback = function(ctx)
24+
---@diagnostic disable-next-line:param-type-mismatch
25+
client:notify('mpls/editorDidChangeFocus', { uri = ctx.match })
26+
end,
27+
desc = 'mpls: notify buffer focus changed',
28+
})
29+
vim.api.nvim_buf_create_user_command(bufnr, 'LspMplsOpenPreview', function()
30+
client:exec_cmd({
31+
title = 'Preview markdown with mpls',
32+
command = 'open-preview',
33+
})
34+
end, { desc = 'Preview markdown with mpls' })
35+
end,
36+
}

0 commit comments

Comments
 (0)