- Notifications
You must be signed in to change notification settings - Fork52
Syntax highlighting for Dart in Vim
License
dart-lang/dart-vim-plugin
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
dart-vim-plugin provides filetype detection, syntax highlighting, andindentation forDart code in Vim.
Looking for auto-complete, diagnostics as you type, jump to definition and otherintellisense features? Try a vim plugin for theLanguage Server Protocol such asvim-lscconfigured to start the Dart analysis server with the--lsp
flag.
Looking for an IDE experience? See theDart Tools page.
Install as a typical vim plugin using your favorite approach. If you don't havea preferencevim-plug is a good place to start. Below are examples forcommon choices, be sure to read the docs for each option.
callplug#begin()"... <snip other plugins>Plug'dart-lang/dart-vim-plugin'callplug#end()
Then invoke:PlugInstall
to install the plugin.
Clone the repository into your pathogen directory.
mkdir -p~/.vim/bundle&&cd~/.vim/bundle&& \git clone https://github.com/dart-lang/dart-vim-plugin
Ensure your.vimrc
contains the lineexecute pathogen#infect()
setrtp+=~/.vim/bundle/Vundle.vimcallvundle#begin()"... <snip other plugins>Plugin'dart-lang/dart-vim-plugin'callvundle#end()
Enable HTML syntax highlighting inside Dart strings withlet g:dart_html_in_string = v:true
(default false).
Highlighting for specific syntax groups can be disabled by defining customhighlight group links. See:help dart-syntax
Enable Dart style guide syntax (like 2-space indentation) withlet g:dart_style_guide = 2
Enable DartFmt execution on buffer save withlet g:dart_format_on_save = v:true
Configure DartFmt options withlet g:dartfmt_options
(discover formatter options withdartfmt -h
)
The indentation capabilities within vim are limited and it's not easy to fullyexpress the indentation behavior ofdart format
. The major area where thisplugin differs fromdart format
is indentation of function arguments whenusing a trailing comma in the argument list. When using a trailing comma (as iscommon in flutter widget code)dart format
uses 2 space indent for argumentparameters. In all other indentation following an open parenthesis (argumentlists without a trailing comma, multi-line assert statements, etc)dart format
uses 4 space indent. This plugin uses 4 space indent indent by default. To use 2space indent by default,let g:dart_trailing_comma_indent = v:true
.
The Dart SDK comes with an analysis server that can be run in LSP mode. Theserver ships with the SDK. Assuming thebin
directory of the SDK is at$DART_SDK
the full command to run the analysis server in LSP mode is$DART_SDK/dart $DART_SDK/snapshots/analysis_server.dart.snapshot --lsp
. Ifyou'll be opening files outside of therootUri
sent by your LSP client(usuallycwd
) you may want to passonlyAnalyzeProjectsWithOpenFiles: true
intheinitializationOptions
. See the documentation for your LSP client for howto configure initialization options. If you are using thevim-lsc pluginthere is an additional plugin which can configure everything for you atvim-lsc-dart. A minimal config for a good default experience usingvim-plug would look like:
callplug#begin()Plug'dart-lang/dart-vim-plugin'Plug'natebosch/vim-lsc'Plug'natebosch/vim-lsc-dart'callplug#end()letg:lsc_auto_map=v:true
About
Syntax highlighting for Dart in Vim
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.