How to make ltex-ls (LanguageTools) grammar checking work properly with mdx files.

Need Help

Recently I've been writing tech content on mdx files in Neovim. But i wasn't satisfied with Neovim's default grammar-checking experience. So i decided to look for good alternatives.

I tried a bunch of them, but i settled on ts-ls.

A LaTeX LSP that provides offline grammar checking of many various markup languages using LanguageTools.

This is my lspconfig, for reference and in case you want to use it in your custom config.

```

{ path = "${3rd}/luv/library", words = { "vim%.uv" } },

},

},

},

},

config = function()

-- Get capabilities from blink.cmp

local capabilities = require("blink.cmp").get_lsp_capabilities()

local on_attach = function(client, bufnr)

vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, { desc = "Code Action", buffer = bufnr })

vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = "Hover Documentation", buffer = bufnr })

end

-- LanguageTool (ltex) configuration: brew install ltex-ls

vim.lsp.config('ltex', {

on_attach = on_attach,

cmd = { "ltex-ls" },

-- 1. Add 'mdx' to the filetypes list so Neovim attaches the LSP to these files

filetypes = { "markdown", "text", "mdx", "gitcommit" },

-- init_options can sometimes force settings in early

init_options = {

userConfiguration = true,

},

root_markers = { '.git' },

settings = {

ltex = {

language = "en-US",

-- 2. Explicitly enable 'mdx' in the server settings

-- Some versions of ltex-ls require this to actually produce diagnostics

enabled = { "markdown", "text", "mdx" },

markdown = {

nodes = {

["CodeBlock"] = "ignore",

["FencedCodeBlock"] = "ignore",

["InlineCode"] = "ignore",

-- MDX Specific nodes that often trigger false positives

["MdxJsxFlowElement"] = "ignore",

["MdxJsxTextElement"] = "ignore",

["MdxjsEsm"] = "ignore",

},

},

},

},

})

-- -- Enable the LSP servers

vim.lsp.enable('ltex')

end

}

}

```

Everything works fine on markdown files, especially now that i configured it to ignore code blocks.

But on MDX files—Astro—I'm getting these annoying diagnostics on code blocks.

https://preview.redd.it/t4djwyv3p6lg1.png?width=903&format=png&auto=webp&s=88bc4f6ec858dd64d9abb9bf11c45dc5ff16b3de

So i was wondering if any of you guys have any idea about a good way to get rid of these types of diagnostics.

Posted Feb 23, 2026, 5:59 AM UTC

10
Loading comments…