Neovim treesitter based shell syntax highlighting for command literals

With neovim and treesitter installed, you can set the syntax highlighting for a language inside another language.

For example, for command_literals, you can make the language "bash" and you’ll get syntax highlighting (before and after screenshots below):

I’ve added this feature to kdheepak/ts-julia-actions. You can add the same manually to your local configuration or with the lazy.nvim package manager you can do the following:

return {
  "kdheepak/ts-julia-actions",
  dependencies = {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    config = function()
      require'nvim-treesitter.configs'.setup {
        ensure_installed = { "julia" },
      }
    end,
  },
}
7 Likes

This is wonderful!

Is it possible to get syntax highlighting of the markdown in docstrings using this?

1 Like

I’m pretty sure this already works:

image

But I don’t actually know if this is coming from the LSP highlighting, TS definition, or Julia language plugin right now

1 Like

It already works!

It comes from treesitter:

1 Like

Oh, fantastic! I clearly need to revisit my nvim treesitter configuration, haven’t used it in well over a year. Thank you for your great work on this @kdheepak!

1 Like

I asked the same thing on slack and in my case I just had to make sure the markdown parser was installed too.

2 Likes

I also added markdown codeblocks to this package (before and after screenshot below):

I made a PR to upstream these two features:

2 Likes