Search code examples
dartflutter

How to let vim do syntax highlight right for Flutter?


Some background: I am using VSCode for coding in Flutter. But when I open many workspaces, it ate all my free RAM quickly (MacBook Pro 8GB). (IntelliJ is even worse.) Sometimes, I just need to check other workspaces' Code etc.. So The best option is to use vim for this purpose.

I have installed dart-vim-plugin, but the syntax highlighting is not really correct for Flutter, for example, BuildContext, Scaffold, AppBar etc. all the class types are pure white color. To minimize the RAM usage, I just don't want any analysis server, auto completion etc. I just want the editor has a correct syntax highlighting so that I can easily check the code. Is that doable?

PS: I just want to use an editor which only does syntax highlight. I really don't have much free RAM. Normally, there are only 600MB left and I don't want to use them all.


Solution

  • Even if I am new to vim syntax highlight, since nobody provides an answer, I have to study how to do this by myself. I have created my own dart.vim and put it at ~/.vim/after/syntax/dart.vim. Note this is just an add-on for dart-vim-plugin, you still need to install it. Hopefully, this will help somebody some day.