akinsho / flutter-tools.nvim

Tools to help create flutter apps in neovim using the native lsp
MIT License
932 stars 75 forks source link

[BUG] Syntax highlighting not working immediately #310

Closed paulkre closed 7 months ago

paulkre commented 7 months ago

Is there an existing issue for this?

Current Behavior

When opening the first Dart file after starting Neovim, the code is not highlighted correctly. After making any change to the code (like inserting a new line) the syntax highlighting updates and works correctly.

This is how the code looks on first startup: Screenshot 2023-11-18 at 12 16 56

And this is how the code looks after any change: Screenshot 2023-11-18 at 12 17 06

Expected Behavior

The colors of the syntax highlighting should be correct immediately.

Steps To Reproduce

  1. Create a new project with flutter create my_app
  2. Open main.dart

Environment

- OS: macOS 14.0
- Flutter version: 3.13.9
- Is flutter in $PATH: yes
- neovim version: 0.9.2

Anything else?

No response

akinsho commented 7 months ago

This plugin has no relationship to syntax highlighting. It doesn't add any. This is all handled by either neovim's syntax functionality or semantic highlighting from the lsp but neither of these things are configured or handled here

paulkre commented 7 months ago

Do you by chance know a function to make neovim rerender the buffer after the LSP has been initialized? Then I could maybe call it in on_attach.

akinsho commented 7 months ago

You can use vim.cmd(':e') otherwise check reddit as I believe doing this will definitely have been discussed there

hauserx commented 3 weeks ago

Noticed same issue. After enabling debug for lsp server with:

vim.lsp.set_log_level('debug')

Noticed that LSP server sends empty response on first try, nothing in logs of LSP server though:

"rpc.send"  {  id = 2,  jsonrpc = "2.0",  method = "textDocument/semanticTokens/full",  params = {    textDocument = {      uri = "file:///..../main.dart"    }  }}

"rpc.receive"   {  id = 2,  jsonrpc = "2.0",  result = {    data = {}  }}