Closed adnanhashmi09 closed 1 year ago
If you add a statement inside the frontmatter (the three dashes), does it work?
Try running :TSUpdate
It does.
:TSUpdate
doesn't help. It says already up to date. My dotfiles if you wanna take a look: https://github.com/adnanhashmi09/nvim
Does it work if you install the html
tree-sitter parser?
No it doesn't work. This is my lua config for treesitter.
local status_ok, configs = pcall(require, "nvim-treesitter.configs")
if not status_ok then
return
end
configs.setup({
ensure_installed = "all", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
sync_install = false, -- install languages synchronously (only applied to `ensure_installed`)
ignore_install = { "" }, -- List of parsers to ignore installing
autopairs = {
enable = true,
},
highlight = {
enable = true, -- false will disable the whole extension
disable = { "" }, -- list of language that will be disabled
additional_vim_regex_highlighting = true,
},
indent = { enable = true, disable = { "yaml" } },
context_commentstring = {
enable = true,
enable_autocmd = false,
},
rainbow = {
enable = true,
-- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for
extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
max_file_lines = nil, -- Do not enable for files with more than n lines, int
-- colors = {}, -- table of hex strings
-- termcolors = {} -- table of colour name strings
},
})
I believe this is an issue with nvim-treesitter. I experience a similar problem with a minimal configuration; even though my tree-sitter parser outputs the correct nodes, the highlighting is still broken. The weird part is that the highlighting actually fixes itself if you inspect nodes with :TSPlaygroundToggle
. I'll report the issue upstream.
As a workaround, just don't use empty frontmatter. Astro files work fine without any frontmatter at all; you only need the frontmatter if you have some serverside JS to execute, in which case the highlighting issue fixes itself anyway.
Hi!
I'm facing a similar issue: treesitter health is ok, all the necessary parsers are present and up-to-date, the file type is perfectly recognized too. I get no syntax highlightling at all on neovim v0.8.2 and a little bit more with a nightly build.
@yamafaktory
I cannot reproduce with a minimal example:
Honestly I think your issue is a colorscheme issue: your colorscheme doesn't appear to have many colors. In fact, you can see that the inline JSX interpolations are in italics, suggesting that they are in fact being detected. Are you sure you're using a tree-sitter enabled colorscheme?
@virchau13 I'm using Tokyo night. I assume it works pretty well with tree sitter.
@yamafaktory
Yes, it should work. Hmm...
What's your :checkhealth
output?
Have you configured nvim-treesitter
to enable highlight
for "astro"
?
Can you send the full file? Maybe there's some invisible characters tripping up the lexer or something.
@virchau13 I'm not in front of my laptop right now but I checked the health output and everything was green. Here's the commit related to my init.lua
changes for Astro https://github.com/yamafaktory/.config/commit/13658c367aa27617df6c99c773ed0f3db477ab82.
Can you install the nvim-treesitter playground plugin and type :TSPlaygroundToggle
while viewing the .astro
file? This should display the treesitter AST.
I've created a new dummy Astro project and opened an .astro
file.
I can walk the AST via the playground node by node and everything seems ok.
crates: require("crates.health").check()
========================================================================
## Checking for required plugins
- OK: plenary.nvim installed
- WARNING: null-ls.nvim not found
## Checking for external dependencies
- OK: curl installed
- OK: xdg-open installed
gitsigns: require("gitsigns.health").check()
========================================================================
- OK: git version 2.39.0
lazy: require("lazy.health").check()
========================================================================
## lazy.nvim
- OK: no existing packages found by other package managers
- OK: packer_compiled.lua not found
man: require("man.health").check()
========================================================================
- OK: plugin/man.vim not in $VIMRUNTIME
- OK: autoload/man.vim not in $VIMRUNTIME
mason: require("mason.health").check()
========================================================================
## mason.nvim report
- OK: neovim version >= 0.7.0
- WARNING: **Go**: not available
- OK: **cargo**: `cargo 1.66.0 (d65d197ad 2022-11-15)`
- WARNING: **luarocks**: not available
- WARNING: **Ruby**: not available
- WARNING: **RubyGem**: not available
- WARNING: **Composer**: not available
- WARNING: **PHP**: not available
- OK: **npm**: `8.19.2`
- OK: **node**: `v19.3.0`
- OK: **python3**: `Python 3.10.9`
- WARNING: **pip3**: not available
- WARNING: **javac**: not available
- WARNING: **java**: not available
- WARNING: **julia**: not available
- OK: **wget**: `GNU Wget 1.21.3 built on linux-gnu.`
- OK: **curl**: `curl 7.87.0 (x86_64-pc-linux-gnu) libcurl/7.87.0 OpenSSL/3.0.7 zlib/1.2.13 brotli/1.0.9 zstd/1.5.2 libidn2/2.3.4 libpsl/0.21.1 (+libidn2/2.3.4) libssh2/1.10.0 nghttp2/1.51.0`
- OK: **gzip**: `gzip 1.12`
- OK: **tar**: `tar (GNU tar) 1.34`
- WARNING: **pwsh**: not available
- OK: **bash**: `GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)`
- OK: **sh**: `Ok`
- OK: GitHub API rate limit. Used: 0. Remaining: 60. Limit: 60. Reset: Sat 31 Dec 2022 11:37:09 AM CET.
nvim: health#nvim#check
========================================================================
## Configuration
- OK: no issues found
## Performance
- OK: Build type: Release
## Remote Plugins
- OK: Up to date
## terminal
- INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
- INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
- INFO: $COLORTERM='truecolor'
nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
- OK: `tree-sitter` found 0.20.7 (parser generator, only needed for :TSInstallFromGrammar)
- OK: `node` found v19.3.0 (only needed for :TSInstallFromGrammar)
- OK: `git` executable found.
- OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: cc (GCC) 12.2.0
- OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.
## OS Info:
{
machine = "x86_64",
release = "6.1.1-arch1-1",
sysname = "Linux",
version = "#1 SMP PREEMPT_DYNAMIC Wed, 21 Dec 2022 22:27:55 +0000"
}
## Parser/Features H L F I J
- astro ✓ ✓ ✓ ✓ ✓
- css ✓ . ✓ ✓ ✓
- html ✓ ✓ ✓ ✓ ✓
Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}
provider: health#provider#check
========================================================================
## Clipboard (optional)
- OK: Clipboard tool found: xclip
## Python 3 provider (optional)
- WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
- WARNING: Could not load Python 3:
/usr/bin/python3 does not have the "neovim" module.
/usr/bin/python3.10 does not have the "neovim" module.
python3.9 not found in search path or not executable.
python3.8 not found in search path or not executable.
python3.7 not found in search path or not executable.
/usr/bin/python does not have the "neovim" module.
- ADVICE:
- See :help |provider-python| for more information.
- You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim
- INFO: Executable: Not found
## Python virtualenv
- OK: no $VIRTUAL_ENV
## Ruby provider (optional)
- WARNING: `ruby` and `gem` must be in $PATH.
- ADVICE:
- Install Ruby and verify that `ruby` and `gem` commands work.
## Node.js provider (optional)
- INFO: Node.js: v19.3.0
- WARNING: Missing "neovim" npm (or yarn, pnpm) package.
- ADVICE:
- Run in shell: npm install -g neovim
- Run in shell (if you use yarn): yarn global add neovim
- Run in shell (if you use pnpm): pnpm install -g neovim
- You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim
## Perl provider (optional)
- WARNING: "Neovim::Ext" cpan module is not installed
- ADVICE:
- See :help |provider-perl| for more information.
- You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim
telescope: require("telescope.health").check()
========================================================================
## Checking for required plugins
- OK: plenary installed.
- OK: nvim-treesitter installed.
## Checking external dependencies
- OK: rg: found ripgrep 13.0.0
- OK: fd: found fd 8.6.0
## ===== Installed extensions =====
## Telescope Extension: `file_browser`
- INFO: No healthcheck provided
## Telescope Extension: `fzf`
- OK: lib working as expected
- OK: file_sorter correctly configured
- OK: generic_sorter correctly configured
vim.lsp: require("vim.lsp.health").check()
========================================================================
- INFO: LSP log level : WARN
- INFO: Log path: /home/yamafaktory/.local/state/nvim/lsp.log
- INFO: Log size: 10982 KB
vim.treesitter: require("vim.treesitter.health").check()
========================================================================
- INFO: Runtime ABI version : 14
- OK: Loaded parser for astro: ABI version 14
- OK: Loaded parser for css: ABI version 13
- OK: Loaded parser for html: ABI version 13
Maybe something is odd with my neovim setup. Thanks for the swift help & feedback! I'd assume that this is on my side since the AST is fine...I'll give it another shot in the near future. Sorry for polluting this issue :).
I don't think this is the correct issue, yeah, but your problem is still worth solving, surely! If only so that I can add the solution to my troubleshooting section in the README :P
There's something extremely suspicious about this:
## Parser/Features H L F I J
- astro ✓ ✓ ✓ ✓ ✓
- css ✓ . ✓ ✓ ✓
- html ✓ ✓ ✓ ✓ ✓
How are there only 3 parsers? Looking at your dotfiles, you have way more than 3 parsers specified under ensure_installed
. I think there might be something wrong with your parser installation; what does :TSInstall
do?
I can't reproduce this anymore on the latest version of Neovim + nvim-treesitter, so I presume it's fixed. Closing for now; feel free to bump if you still encounter this issue.
I have installed all the parsers
tsx
,typescript
andcss
and have included the file detect script. But the highlighting is not working.:checkhealth output