# Neovim treesitter based shell syntax highlighting for command literals

**URL:** https://discourse.julialang.org/t/neovim-treesitter-based-shell-syntax-highlighting-for-command-literals/117379
**Category:** Tooling
**Tags:** neovim
**Created:** [July 23, 2024, 10:24am UTC](https://discourse.julialang.org/t/neovim-treesitter-based-shell-syntax-highlighting-for-command-literals/117379 "2024-07-23T10:24:07Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![kdheepak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdheepak/32/10881_2.png) [@kdheepak](https://discourse.julialang.org/u/kdheepak)
#### Post date: [July 23, 2024, 10:24am UTC](https://discourse.julialang.org/t/neovim-treesitter-based-shell-syntax-highlighting-for-command-literals/117379/1 "2024-07-23T10:24:07Z")

</div>

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):

 ![bash command syntax highlighting](https://global.discourse-cdn.com/julialang/original/3X/b/a/ba09ddadbf559584f6fc0c47aacfb5a31b090761.png)

I’ve added this feature to [`kdheepak/ts-julia-actions`](https://github.com/kdheepak/ts-julia-actions/commit/280900a61d0b2b3377170cdf2a1afd99781b0a45). You can add the same manually to your local configuration or with the `lazy.nvim` package manager you can do the following:

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

```

---

<div class="post-metadata">

### Author: ![caleb-allen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/caleb-allen/32/14054_2.png) [@caleb-allen](https://discourse.julialang.org/u/caleb-allen)
#### Post date: [July 23, 2024, 1:40pm UTC](https://discourse.julialang.org/t/neovim-treesitter-based-shell-syntax-highlighting-for-command-literals/117379/2 "2024-07-23T13:40:25Z")

</div>

This is wonderful!

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

---

<div class="post-metadata">

### Author: ![sbuercklin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sbuercklin/32/15728_2.png) [@sbuercklin](https://discourse.julialang.org/u/sbuercklin)
#### Post date: [July 23, 2024, 3:03pm UTC](https://discourse.julialang.org/t/neovim-treesitter-based-shell-syntax-highlighting-for-command-literals/117379/3 "2024-07-23T15:03:02Z")

</div>

> [@caleb-allen](#):
>
> Is it possible to get syntax highlighting of the markdown in docstrings using this?

I’m pretty sure this already works:

![image](https://global.discourse-cdn.com/julialang/original/3X/4/5/45bb7326b65848e1cc0d5b9bebecf193e83a4f34.png)

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

---

<div class="post-metadata">

### Author: ![kdheepak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdheepak/32/10881_2.png) [@kdheepak](https://discourse.julialang.org/u/kdheepak)
#### Post date: [July 23, 2024, 3:31pm UTC](https://discourse.julialang.org/t/neovim-treesitter-based-shell-syntax-highlighting-for-command-literals/117379/4 "2024-07-23T15:31:12Z")

</div>

It already works!

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/c/9c2f61c4d73cb9e2ded483187de32edadf3ea273.png)

> [@sbuercklin](#):
>
> But I don’t actually know if this is coming from the LSP highlighting, TS definition, or Julia language plugin right now

It comes from treesitter:

> <https://github.com/nvim-treesitter/nvim-treesitter/blob/9d252d00210ed8d43197ef048daa94e6dc821bd6/queries/julia/injections.scm#L1-L14>

---

<div class="post-metadata">

### Author: ![caleb-allen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/caleb-allen/32/14054_2.png) [@caleb-allen](https://discourse.julialang.org/u/caleb-allen)
#### Post date: [July 23, 2024, 5:43pm UTC](https://discourse.julialang.org/t/neovim-treesitter-based-shell-syntax-highlighting-for-command-literals/117379/5 "2024-07-23T17:43:15Z")

</div>

> [@kdheepak](#):
>
> It already works!

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!

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [July 23, 2024, 7:53pm UTC](https://discourse.julialang.org/t/neovim-treesitter-based-shell-syntax-highlighting-for-command-literals/117379/6 "2024-07-23T19:53:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![kdheepak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdheepak/32/10881_2.png) [@kdheepak](https://discourse.julialang.org/u/kdheepak)
#### Post date: [July 24, 2024, 12:19am UTC](https://discourse.julialang.org/t/neovim-treesitter-based-shell-syntax-highlighting-for-command-literals/117379/7 "2024-07-24T00:19:35Z")

</div>

I also added [markdown codeblocks to this package](https://github.com/kdheepak/ts-julia-actions/commit/45d0c88f930e77b25edee918bffe407dee6444ec) (before and after screenshot below):

 ![](https://global.discourse-cdn.com/julialang/original/3X/4/5/45410101c970aef81791f26e66d1771bedf76a1c.png)

I made a PR to upstream these two features:

> <https://github.com/nvim-treesitter/nvim-treesitter/pull/6970>
>
> This PR adds markdown syntax highlighting and bash command line syntax highlight…ing for the appropriate Julia expressions.
> 
> bash syntax highlighting:
> 
> !\[image\](https://github.com/user-attachments/assets/5d7c7037-f67f-4307-91de-ae3b8a1679bc)
> 
> markdown syntax highlighting:
> 
> !\[image\](https://github.com/user-attachments/assets/6558341f-df3e-439c-a245-6676e54e6d7f)
> 
> This PR also adds a comment for each injection.
