0

Just getting started learning Vim/Neovim and am just following along with some tutorials that said to just open up any repo on your system to play around.

I noticed that I don't have syntax highlighting for CSS if its in an HTML file inside of a <style> block, but I do if I'm inside of a .css file.

I'm currently using LazyVim and did use "Mason" to install any language server that looked like it would enable CSS support.

Is this typical, that you'd have to switch the file type using :set filetype=css to get highlighting for the <style> block or is there something I'm not configuring correctly?

The example test html document

<!DOCTYPE html>
<html>
<head>
  <title>Test</title>
  <style>
    div {
      display: none;
      color: #fff;
    }
  </style>
</head>

<body>
  <div class="test">This is a test</div>
</body>

</html>
6
  • It should work. Could you share a short example? Jun 15 at 4:18
  • I suspect that your <style> tag is not positioned correctly into the <html> file structure or that there is something corrupted in your html file. Jun 15 at 9:02
  • 1
    @VivianDeSmedt apparently LazyVim doesn't have css treesitter installed by default, adding "css" to my treesitters ensure_installed fixed it!
    – null
    Jun 16 at 12:11
  • Thanks for the feedback. But I have tested using a bare version of Vim or Neovim and it seems also working fine. I suspect that the bare version is a bit more picky about the syntax. Jun 16 at 12:31
  • 1
    @VivianDeSmedt I updated it with the test html, which has no syntax highlighting at all in LazyVim at least until CSS treesitter was added. It may work in a bare version of nvim but not LazyVim's default config? Everything is highlighted but the CSS
    – null
    Jun 16 at 18:24

1 Answer 1

0

This is what I have with a bar version of gVim:

gVim screenshot

And this what I have with a bar version of Neovim

Neovim screenshot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.