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:
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
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 !
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:
nvim-treesitter:master
← kdheepak:kd/julia
opened 12:30AM - 24 Jul 24 UTC
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.
2 Likes