markdown · 1681 bytes Raw Blame History

Use DLM in Neovim

The dlm-lsp language server attaches to Neovim through nvim-lspconfig.

Install

pip install dlm-lsp
which dlm-lsp   # confirm it's on PATH

Configure

Add to your Neovim config (Lua, e.g. ~/.config/nvim/lua/plugins/dlm.lua or anywhere in your init.lua):

-- Recognize .dlm files
vim.filetype.add({ extension = { dlm = "dlm" } })

-- Register the LSP
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")

if not configs.dlm_lsp then
  configs.dlm_lsp = {
    default_config = {
      cmd = { "dlm-lsp" },
      filetypes = { "dlm" },
      root_dir = lspconfig.util.find_git_ancestor,
      single_file_support = true,
      settings = {},
    },
  }
end

lspconfig.dlm_lsp.setup({})

If dlm-lsp isn't on your PATH (e.g. installed inside a venv), pass the absolute path:

cmd = { "/Users/you/.venvs/dlm/bin/dlm-lsp" },

Verify

Open a .dlm file. Run :LspInfo and confirm dlm_lsp is attached. If not, :LspLog shows the spawn error.

You'll get:

  • Diagnostics through the standard Neovim diagnostic interface
  • Hover (K) on base_model: keys and section fences
  • Completion through your usual completion plugin (nvim-cmp, coq_nvim, the built-in Ctrl-x Ctrl-o, etc.)
  • Code actions through vim.lsp.buf.code_action()

Optional: Tree-sitter highlighting

Neovim uses Tree-sitter for highlighting. There is no tree-sitter-dlm parser yet; if you want richer highlighting before that lands, set the filetype to markdown for the body region and rely on LSP semantic tokens for the frontmatter and fence accents.

View source
1 # Use DLM in Neovim
2
3 The `dlm-lsp` language server attaches to Neovim through
4 [`nvim-lspconfig`](https://github.com/neovim/nvim-lspconfig).
5
6 ## Install
7
8 ```bash
9 pip install dlm-lsp
10 which dlm-lsp # confirm it's on PATH
11 ```
12
13 ## Configure
14
15 Add to your Neovim config (Lua, e.g. `~/.config/nvim/lua/plugins/dlm.lua`
16 or anywhere in your `init.lua`):
17
18 ```lua
19 -- Recognize .dlm files
20 vim.filetype.add({ extension = { dlm = "dlm" } })
21
22 -- Register the LSP
23 local lspconfig = require("lspconfig")
24 local configs = require("lspconfig.configs")
25
26 if not configs.dlm_lsp then
27 configs.dlm_lsp = {
28 default_config = {
29 cmd = { "dlm-lsp" },
30 filetypes = { "dlm" },
31 root_dir = lspconfig.util.find_git_ancestor,
32 single_file_support = true,
33 settings = {},
34 },
35 }
36 end
37
38 lspconfig.dlm_lsp.setup({})
39 ```
40
41 If `dlm-lsp` isn't on your PATH (e.g. installed inside a venv), pass the
42 absolute path:
43
44 ```lua
45 cmd = { "/Users/you/.venvs/dlm/bin/dlm-lsp" },
46 ```
47
48 ## Verify
49
50 Open a `.dlm` file. Run `:LspInfo` and confirm `dlm_lsp` is attached. If
51 not, `:LspLog` shows the spawn error.
52
53 You'll get:
54
55 - Diagnostics through the standard Neovim diagnostic interface
56 - Hover (`K`) on `base_model:` keys and section fences
57 - Completion through your usual completion plugin
58 (`nvim-cmp`, `coq_nvim`, the built-in `Ctrl-x Ctrl-o`, etc.)
59 - Code actions through `vim.lsp.buf.code_action()`
60
61 ## Optional: Tree-sitter highlighting
62
63 Neovim uses Tree-sitter for highlighting. There is no `tree-sitter-dlm`
64 parser yet; if you want richer highlighting before that lands, set the
65 filetype to `markdown` for the body region and rely on LSP semantic
66 tokens for the frontmatter and fence accents.