Repository navigation
nvim: lint and format Markdown with rumdl, support SystemVerilog, and tidy the config - #9
Conversation
patrick-5546
left a comment
There was a problem hiding this comment.
I am wondering if this can be addressed more generically. What is installed by mason in my setup, and from where? Can the markdown lazyextra be overrided to use rumdl instead or not be used at all and instead my custom config? In general I want to use mason and not the locally or .venv installed packages. But it would still read the config that's in the repo if nvim is opened in the project root right? Can a 7 day cooldown be added for updates? Another idea is making the rumdl config compatibile with markdownlint-cli2 so that it can still be used in the project if that's all is available. But not ideal, would rather use rumdl and rumdl would work with markdownlint-cli2 config right (the other way around). if there's no config does rumdl work in a similar way to markdownlint-cli2 and have the same defaults? I also want to add to my setup that verible is installed with mason by default, so that would go in the mason config right
bc3199a to
3b0eda1
Compare
|
Reworked the PR to be generic and Mason-only, with its commits rewritten as if it started that way. Answers to each question: What does Mason install, and from where? Everything goes in
Mason no longer installs markdownlint-cli2 (npm), which the markdown extra asked for; an existing copy stays until it's removed in Can the markdown extra be overridden? Yes, and that's what the PR now does, keeping the extra's marksman, preview, render-markdown and markdown-toc. Mason only, still reading the repo's config? Yes, and not only from the project root. rumdl finds the settings from the file's folder upward. I tested rumdl 0.3.10 from another folder, and Mason's rumdl on notes in Neovim, where it reported the repo's MD004 dash style. So the A 7-day cooldown? There's no built-in option. lazy.nvim has none for plugins ( Making the rumdl config work with markdownlint-cli2? It only works one way. rumdl reads Without a config, does rumdl behave like markdownlint-cli2? Mostly. I ran both with no config on 39 Markdown files from notes, dotfiles, rtl-project-template and md-doc-converter. Most rules match: MD007 152 for both, MD046 10 for both, MD033 2 against 3, and MD040 19 against 16. The differences:
Verible with Mason? Yes, in |
LazyVim's markdown extra lints Markdown with markdownlint-cli2, and fixes what it reports when formatting. It ignores a project's .rumdl.toml or [tool.rumdl] settings, so on a MkDocs or Zensical site it reports the four-space indentation that Python Markdown nests lists, admonitions and content tabs by, and its fixes would change it. Mason installs rumdl instead, whose language server lints as you type. It starts by itself, as mason-lspconfig starts every server that Mason installs. conform formats Markdown with rumdl, then markdown-toc, in place of markdownlint-cli2 and the extra's Prettier, which nothing installs. rumdl finds each project's settings from the file's folder, wherever Neovim starts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Its language server starts by itself, as mason-lspconfig starts every server that Mason installs. It lints SystemVerilog and Verilog as you type, with a project's .rules.verible_lint if it has one, and formats them, as conform falls back to the language server for a file with no formatter of its own. Verible publishes its diagnostics, and also answers requests for them, which Neovim 0.12 makes too, so it would show each problem twice. Neovim only requests them from a server that says it answers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Some other things I noticed while reviewing the nvim files:
- Should example.lua and README.md and LICENSE and any other files be deleted from the starter template? Or updated?
- What do you think about nvim-treesitter.lua? Should verilog treesitter be installed here? Will it automatically download even if not if you open such a file? does this work with systemverilog as well?
- What do you think about the naming conventions for the plugins? Do they follow the same conventions? Is it what is most commonly used?
- Will all of these changes work with Windows nvim? Will it break anything?
- Should check-nvim.lua be updated?
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
LazyVim only installs the parsers on its list, and opening a file doesn't install one, so SystemVerilog and Verilog files had Vim's regex highlighting. nvim-treesitter's systemverilog parser is for both, and also folds them. Like the other parsers, it's compiled once on each machine. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
LazyVim starts installing its tools once Mason's registry is up to date. When the registry first needs an update, as it does once it's a day old, that's after startup, so the check could stop waiting before an install started, and report that Mason didn't start it. On CI's new machines, the update usually finishes while lazy.nvim installs the plugins, so it hasn't failed there. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The check now opens a Markdown and a SystemVerilog file, and checks that their language servers start: marksman and rumdl, and Verible. Then it formats the Markdown file with conform, which shows that rumdl formats it on each OS, including through Mason's .cmd wrapper on Windows. It doesn't fall back to rumdl's language server, which would hide a problem. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The starter's examples in lua/plugins/example.lua return before they load, and use plugins that LazyVim has since replaced. .neoconf.json configures neoconf.nvim and neodev, which aren't installed. Neovim's own Verilog and SystemVerilog ftplugins have set the comment format since 2024. .chezmoiremove removes them from machines that already have them. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
They came from LazyVim's starter before March 2024. Since then, the starter's lazy.lua reports a failed lazy.nvim clone, instead of failing to load lazy.nvim, uses vim.uv, as vim.loop is deprecated, and no longer reads a LAZY variable or lists commented-out extras. Its autocmds.lua explains how to add and remove autocmds. The error waits for a key, except without a UI: headless, as in CI, getchar() would wait forever. netrw stays disabled, and the update check still notifies. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
It was the starter's, which GitHub shows on the dot_config/nvim page, which the root README and the notes site both link to. It now describes the config's layout and naming, the tools it adds to LazyVim's, and its CI check. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Most specs started with their plugin's URL. Now they all do, and Mason's is its current one. persistence.lua's spec was nested in an extra table, and repeated LazyVim's event. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3b0eda1 to
6a991c8
Compare
The check waited until each parser's file existed, then loaded them all. nvim-treesitter copies a parser into place once it's compiled, and on Linux, the file exists while it's copied, so the check could load half of one. That crashed Neovim with a bus error on Ubuntu 22.04, with the systemverilog parser, which is about 25 MB. LazyVim updates its list of installed parsers once they've all installed, which is also when it starts using them, so the check waits for that list instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
marksman is a .NET program, which needs ICU, and minimal Ubuntu installs, such as CI's Ubuntu 22.04 container, don't have it, so marksman crashed there. That's true whether or not this config checks it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
An install that failed while Neovim started, before the check could watch it, was reported as one that didn't start. Mason's log has its error, which the check now reports. On CI's Ubuntu 22.04 container, rumdl once didn't install, most likely because its download failed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed in new commits on top of a rebase onto main (ae4e011), so a local branch at that rebase can fast-forward. Answers to each question: Inline comment on Starter files: delete or update? Compared with the current LazyVim/starter, which hasn't changed since December 2024:
nvim-treesitter: install the Verilog parser? Is it automatic? Does it work with SystemVerilog?
Plugin file naming
Windows
check-nvim.lua Updated in five commits:
|
Their files were named after the plugin's repository without .nvim, so some kept an nvim- or vim- prefix. Most configs drop both, as kickstart and LazyVim's extras do: treesitter.lua, lspconfig.lua and lint.lua. .chezmoiremove removes the old files. lazy.nvim loads every file in lua/plugins, so it would load them as well as the renamed ones. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
One line for each change, grouped by file, which also lays out the config. The README's layout list and its paragraphs about Mason, formatting and CI are gone, as they repeated the code's comments, LazyVim's defaults and the root README. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
It made the pickers show paths of up to 60 characters, instead of 40. Since snacks 2.24.0, paths fill the picker's width, of at least 40 characters, and truncate only chooses which part of a path to cut, "left", "center" or "right", so snacks used its default, "center", for 60. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
It let the terminal's background show through, but Ghostty is opaque, and its TokyoNight Night theme has the same background as the editor, so that looks the same. Floating windows and sidebars, such as the pickers and the explorer, now have the theme's darker background, like tmux's status bar and popups. Neovim also no longer takes on a terminal's own background, such as Windows Terminal's Campbell. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Only <C-H> was mapped, which is how Ctrl+Backspace arrives in tmux. Directly in Ghostty, Neovim turns on the kitty keyboard protocol, so Ctrl+Backspace arrives as <C-BS>, which deleted only one character. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The README lists what each file changes, which comments also said, such as "Disable autoformat" above vim.g.autoformat = false. Those comments are gone, or now only give a reason or explain the code, such as why the swap file is off, or how ygv<Esc> keeps the cursor. The README no longer repeats the reasons that comments give. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Lints and formats Markdown with rumdl, and supports SystemVerilog with Verible and nvim-treesitter's parser, leaving every tool to Mason. It also tidies what's left of LazyVim's starter, and CI now checks the new tools on all four platforms. Companion to patrick-5546/notes#34, which checks the notes site's Markdown with rumdl.
Why
LazyVim's markdown extra lints with markdownlint-cli2, and its formatter fixes what markdownlint-cli2 reports. markdownlint-cli2 ignores a project's
.rumdl.tomlor[tool.rumdl]settings, so on a MkDocs or Zensical site it reports the four-space indentation that Python Markdown nests lists, admonitions and content tabs by. Its fixes would change that indentation too. The extra also lists Prettier, but nothing installs it, so it never ran.Changes
Markdown and SystemVerilog
The plugin stubs are filled in. The markdown extra stays (marksman, the preview, render-markdown, markdown-toc), overridden where needed:
mason.lua: installsrumdlandverible, and no longermarkdownlint-cli2. mason-lspconfig starts every language server that Mason installs, so both servers start by themselves.conform.lua: formats Markdown withrumdl, thenmarkdown-toc.lint.lua: no Markdown linters. rumdl's language server lints as you type, so nvim-lint's own rumdl linter would show each problem twice.lspconfig.lua: Verible both publishes its diagnostics and answers Neovim 0.12's requests for them, so each problem showed twice. Neovim only requests diagnostics from servers that say they answer, so this hides that capability.treesitter.lua: installs thesystemverilogparser, which is also Verilog's, along with LazyVim's other parsers.rumdl finds each project's settings from the file's folder, wherever Neovim starts, and falls back to its defaults outside a project. SystemVerilog needs no formatter in conform:
<leader>cffalls back to Verible's language server.Tidying
lua/plugins/example.lua, the starter's examples. They never loaded and used plugins that LazyVim has replaced..neoconf.json, which configures neoconf.nvim and neodev. Neither is installed.after/ftplugin/{verilog,systemverilog}.lua. Neovim's runtime has set// %sas the comment format since 2024..chezmoiremoveremoves them from machines that already have them.lazy.luaandautocmds.luanow match the current LazyVim starter.lazy.lua: error handling for a failed lazy.nvim clone,vim.uv, and noLAZYvariable or commented-out extras. The error skips the starter's keypress wait when there's no UI, sincegetchar()blocks forever in headless Neovim, including CI.sitefolder workaround, and update notifications.dot_config/nvimpage, which the root README and the notes site link to. The starter's Apache 2.0 LICENSE stays.#1a1b26, so the editor looks the same.#16161e, like tmux's status bar and popups.<C-BS>. Directly in Ghostty, Neovim turns on the kitty keyboard protocol, so Ctrl+Backspace arrives as<C-BS>and deleted only one character.<C-H>covered only tmux.nvim-,vim-or.nvim, as most configs, kickstart and LazyVim's extras name them.nvim-lint.lua,nvim-lspconfig.lua,nvim-treesitter.luaandvim-tmux-navigator.luabecamelint.lua,lspconfig.lua,treesitter.luaandtmux-navigator.lua..chezmoiremoveremoves the old files, which lazy.nvim would otherwise load as well as the new ones.mason.lua's was the old williamboman one.persistence.lualoses an extra level of nesting and a repeat of LazyVim's event.snacks.lualosesformatters.file.truncate = 60. Since snacks 2.24.0,truncateonly picks which part of a path to cut, and paths fill the picker's width, so snacks used its default for60.CI:
check-nvim.lua.cmdwrapper.Verification
Unless noted, these ran in an isolated Neovim:
XDG_*folders in a temporary directory, with a copy of my plugins and Mason packages.rtl/top.sv.systemverilog.sowhen only 12.9 of its 25.2 MB had been copied.*items. No other linter ran.<leader>cfrewrote them as-items.rtl/top.sv: Mason'sverible-verilog-lsattached, rooted at the repo, and reported trailing spaces once.<leader>cfformatted the module with Verible.systemverilogand<C-h>appeared twice.truncate: snacks cut 15 combinations of path and width identically for60and"center".#1a1b26, Ghostty's background, and the explorer's and picker's windows are#16161e.<C-H>and<C-BS>both delete the previous word. Before,<C-BS>deleted one character. Plain Backspace is unchanged.applyinto a scratch home folder deleted exactly the removed files and the four old names..github/lint.shand stylua pass.On a real machine (macOS): the local branch, fast-forwarded and applied, changed only
~/.config/nvim. It removed the old files, andchezmoi statuswas then empty.check-nvim.luapassed with the real config and data. Only the state and cache folders were isolated, so it left no sessions or logs, and LazyVim compiled the systemverilog parser into the real data folder.docs/index.mdgot rumdl and marksman, and rtl-project-template'srtl/top.svgot Verible, both with tree-sitter highlighting. Neither repo changed.CI passes on all four platforms. On each one:
.cmdwrapper on Windows.