Grammar/style check and markdown linter for code documentation in Neovim

Another cool plugin for Neovim, GitHub - jmbuhr/otter.nvim: Just ask an otter! 🦦 makes it possible to run linters for embedded code, like Markdown in code documentation:

In order to make it happen, you need to install otter (example for lazy.vim):

{
    "jmbuhr/otter.nvim",
    dependencies = {
      "hrsh7th/nvim-cmp",
      "neovim/nvim-lspconfig",
      "nvim-treesitter/nvim-treesitter",
    },
    opts = {
      buffers = {
        set_filetype = true,
      },
    },
  }

You also need to activate Otter in Elixir files:

local group = vim.api.nvim_create_augroup("Elixir", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
  pattern = "*.ex,*.exs",
  group = group,
  callback = function()
    local ok, otter = pcall(require, "otter")
    if ok then
      otter.activate({ "markdown" })
    end
  end,
})

Then I installed ltex-ls and vale-ls via :Mason.

Vale also needs a config in the project or in ~/.vale.ini:

StylesPath = styles

MinAlertLevel = suggestion

Packages = proselint, write-good, alex, Joblint

[*]
BasedOnStyles = Vale, proselint, write-good, alex, Joblint

Then vale sync and you’re ready to go.

Now your Neovim will be able to help with grammar and style guide for English not only in Markdown files, but also in Markdown embedded into Elixir files.

5 Likes

I forgot to mention that using ltex-ls means we’re using the awesome toolkit from https://languagetool.org/

1 Like