Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Syntax highlighting for Dart in Vim

License

NotificationsYou must be signed in to change notification settings

dart-lang/dart-vim-plugin

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.

Commands

:DartFmt

Installation

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()

Configuration

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)

FAQ

Why doesn't the plugin indent identically todart format?

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 formatuses 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.

How do I configure an LSP plugin to start the analysis server?

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

Stars

Watchers

Forks

Packages

No packages published

Contributors29


[8]ページ先頭

©2009-2025 Movatter.jp