Where can I see a list of all recognized languages for code blocks inside Markdown? Alternatively, how can I enabled nix
to be highlighted too?
I am editing a Markdown file and noticed that code in some blocks get highlighted, while in some isn’t.
For example, I can see a code highlighted in a block containing shell script (and denoted using sh
), but not highlighted in a block denoted by nix
. I assume sh
is a recognized code format, while nix
isn’t. Among others, I could see that elixir
is a recognized format too.
I use neovim 0.10. Not sure if relevant, but the list of plugins I use is here:
catppuccin
lazy.nvim
mason-lspconfig.nvim
mason.nvim
nvim-lspconfig
nvim-tree.lua
nvim-treesitter
nvim-web-devicons
plenary.nvim
telescope.nvim
vim-fugitive
vim-rhubarb
Figured this out. This was not related to neovim itself, but rather coming from nvim-treesitter
plugin.
Comments to this reddit post helped me realize this is enabled by tree-sitter, which made me review my nvim configs and remember that I maintain a list of languages for tree-sitter must recognize.
Here’s the nvim-treesitter
config I needed to edit (I use lazy.nvim
to maintain neovim plugins):
local M = {
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = {
"bash",
"fish",
-- ...
"nix" -- <- added this line
},
highlight = {
enable = true
}
})
end
}
return { M }
Here’s the end result:
I find this somewhat interesting since code in regular .nix files was highlighted just fine, but code in .md blocks written in nix wasn’t. Aren’t both use the same underlying highlighting mechanism these days?