aboutsummaryrefslogtreecommitdiffstats
path: root/lsp/mpls.lua
blob: 227342b795da216687894638ad9f4d485174dd36 (plain) (blame)
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
36
---@brief
---
--- https://github.com/mhersson/mpls
---
--- Markdown Preview Language Server

---@type vim.lsp.Config
return {
  cmd = {
    'mpls',
    '--theme',
    'dark',
    '--enable-emoji',
    '--enable-footnotes',
    '--no-auto',
  },
  root_markers = { '.marksman.toml', '.git' },
  filetypes = { 'markdown' },
  on_attach = function(client, bufnr)
    vim.api.nvim_create_autocmd('BufEnter', {
      pattern = { '*.md' },
      group = vim.api.nvim_create_augroup('lspconfig.mpls.focus', { clear = true }),
      callback = function(ctx)
        ---@diagnostic disable-next-line:param-type-mismatch
        client:notify('mpls/editorDidChangeFocus', { uri = ctx.match })
      end,
      desc = 'mpls: notify buffer focus changed',
    })
    vim.api.nvim_buf_create_user_command(bufnr, 'LspMplsOpenPreview', function()
      client:exec_cmd({
        title = 'Preview markdown with mpls',
        command = 'open-preview',
      })
    end, { desc = 'Preview markdown with mpls' })
  end,
}