Coder Social home page Coder Social logo

dart-vim-plugin's Introduction

Dart Support for Vim

dart-vim-plugin provides filetype detection, syntax highlighting, and indentation for Dart code in Vim.

Looking for auto-complete, diagnostics as you type, jump to definition and other intellisense features? Try a vim plugin for the Language Server Protocol such as vim-lsc configured to start the Dart analysis server with the --lsp flag.

Looking for an IDE experience? See the Dart Tools page.

Commands

:DartFmt

Installation

Install as a typical vim plugin using your favorite approach. If you don't have a preference vim-plug is a good place to start. Below are examples for common choices, be sure to read the docs for each option.

call plug#begin()
"... <snip other plugins>
Plug 'dart-lang/dart-vim-plugin'

call plug#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 line execute pathogen#infect()

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"... <snip other plugins>
Plugin 'dart-lang/dart-vim-plugin'

call vundle#end()

Configuration

Enable HTML syntax highlighting inside Dart strings with let dart_html_in_string=v:true (default false).

Disable highlighting of core library classes with let dart_corelib_highlight=v:false (default true).

Disable highlighting of user defined types (words starting with a capital letter) with let dart_highlight_types=v:false (default true).

Enable Dart style guide syntax (like 2-space indentation) with let dart_style_guide = 2

Enable DartFmt execution on buffer save with let dart_format_on_save = 1

FAQ

Why doesn't the plugin does not indent identically to dartfmt?

The indentation capabilities within vim are limited and it's not easy to fully express the indentation behavior of dartfmt. The major area where this plugin differs from dartfmt is indentation of function arguments when using a trailing comma in the argument list. When using a trailing comma (as is common in flutter widget code) dartfmt uses 2 space indent for argument parameters. In all other indentation following an open parenthesis (argument lists without a trailing comma, multi-line assert statements, etc) dartmft uses 4 space indent. This plugin uses 4 space indent to match the most cases.

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. The server ships with the SDK. Assuming the bin 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. If you'll be opening files outside of the rootUri sent by your LSP client (usually cwd) you may want to pass onlyAnalyzeProjectsWithOpenFiles: true in the initializationOptions. See the documentation for your LSP client for how to configure initialization options. If you are using the vim-lsc plugin there is an additional plugin which can configure everything for you at vim-lsc-dart. A minimal config for a good default experience using vim-plug would look like:

call plug#begin()
Plug 'dart-lang/dart-vim-plugin'
Plug 'natebosch/vim-lsc'
Plug 'natebosch/vim-lsc-dart'
call plug#end()

let g:lsc_auto_map = v:true

dart-vim-plugin's People

Contributors

adrienlemaire avatar aleksa avatar amouravski avatar cbracken avatar colintsteele avatar dbarnett avatar eltoder avatar floitsch avatar har79 avatar jadengis avatar kevmoo avatar ladicek avatar luklanis avatar mit-mit avatar natebosch avatar radimsuckr avatar rbtnn avatar rchavarria avatar sethladd avatar sigmundch avatar yasukotelin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.