summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Stankiewicz <sheerun@sher.pl>2015-12-06 11:38:02 +0100
committerAdam Stankiewicz <sheerun@sher.pl>2015-12-06 11:38:02 +0100
commit5658b62b7afb7d4855e2634d8d067cbdf1d332c9 (patch)
tree334b18c006622e75e7f6a3ed89a0091a1c8834e0
parent938a2f1667820c0ac9d5b08d4118aaf53e76a0cb (diff)
downloadvim-polyglot-5658b62b7afb7d4855e2634d8d067cbdf1d332c9.tar.gz
vim-polyglot-5658b62b7afb7d4855e2634d8d067cbdf1d332c9.zip
Add dart language support, closes #93
-rw-r--r--README.md1
-rwxr-xr-xbuild1
-rw-r--r--ftdetect/polyglot.vim4
-rw-r--r--ftplugin/dart.vim31
-rw-r--r--indent/dart.vim13
-rw-r--r--syntax/dart.vim110
6 files changed, 160 insertions, 0 deletions
diff --git a/README.md b/README.md
index bcb935d7..19dc98eb 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,7 @@ Optionally download one of the [releases](https://github.com/sheerun/vim-polyglo
- [coffee-script](https://github.com/kchmck/vim-coffee-script) (syntax, indent, compiler, autoload, ftplugin, ftdetect)
- [css](https://github.com/JulesWang/css.vim) (syntax)
- [cucumber](https://github.com/tpope/vim-cucumber) (syntax, indent, compiler, ftplugin, ftdetect)
+- [dart](https://github.com/dart-lang/dart-vim-plugin) (syntax, indent, ftplugin, ftdetect)
- [dockerfile](https://github.com/honza/dockerfile.vim) (syntax, ftdetect)
- [elixir](https://github.com/elixir-lang/vim-elixir) (syntax, indent, compiler, ftplugin, ftdetect)
- [emberscript](https://github.com/heartsentwined/vim-ember-script) (syntax, indent, ftplugin, ftdetect)
diff --git a/build b/build
index 86040174..6d4cedec 100755
--- a/build
+++ b/build
@@ -105,6 +105,7 @@ PACKS="
coffee-script:kchmck/vim-coffee-script
css:JulesWang/css.vim
cucumber:tpope/vim-cucumber
+ dart:dart-lang/dart-vim-plugin
dockerfile:honza/dockerfile.vim
elixir:elixir-lang/vim-elixir
emberscript:heartsentwined/vim-ember-script
diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim
index 65650431..6869abf5 100644
--- a/ftdetect/polyglot.vim
+++ b/ftdetect/polyglot.vim
@@ -34,6 +34,10 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'cucumber') == -
autocmd BufNewFile,BufReadPost *.feature,*.story set filetype=cucumber
endif
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dart') == -1
+
+autocmd BufRead,BufNewFile *.dart set filetype=dart
+endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dockerfile') == -1
au BufNewFile,BufRead Dockerfile set filetype=dockerfile
diff --git a/ftplugin/dart.vim b/ftplugin/dart.vim
new file mode 100644
index 00000000..9b2e8d32
--- /dev/null
+++ b/ftplugin/dart.vim
@@ -0,0 +1,31 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dart') == -1
+
+if exists('b:did_ftplugin')
+ finish
+endif
+let b:did_ftplugin = 1
+
+" Enable automatic indentation (2 spaces) if variable g:dart_style_guide is set
+if exists('g:dart_style_guide')
+ setlocal expandtab
+ setlocal shiftwidth=2
+ setlocal softtabstop=2
+
+ setlocal formatoptions-=t
+endif
+
+" Set 'comments' to format dashed lists in comments.
+setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,://
+
+setlocal commentstring=//%s
+let s:win_sep = (has('win32') || has('win64')) ? '/' : ''
+let &l:errorformat =
+ \ join([
+ \ ' %#''file://' . s:win_sep . '%f'': %s: line %l pos %c:%m',
+ \ '%m'
+ \ ], ',')
+
+
+let b:undo_ftplugin = 'setl et< fo< sw< sts< com< cms<'
+
+endif
diff --git a/indent/dart.vim b/indent/dart.vim
new file mode 100644
index 00000000..af4cb7df
--- /dev/null
+++ b/indent/dart.vim
@@ -0,0 +1,13 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dart') == -1
+
+if exists('b:did_indent')
+ finish
+endif
+let b:did_indent = 1
+
+setlocal cindent
+setlocal cinoptions+=j1,J1
+
+let b:undo_indent = 'setl cin< cino<'
+
+endif
diff --git a/syntax/dart.vim b/syntax/dart.vim
new file mode 100644
index 00000000..ebfb7abd
--- /dev/null
+++ b/syntax/dart.vim
@@ -0,0 +1,110 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'dart') == -1
+
+" Vim syntax file " Language: Dart
+" Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+" for details. All rights reserved. Use of this source code is governed by a
+" BSD-style license that can be found in the LICENSE file.
+
+if !exists("g:main_syntax")
+ if version < 600
+ syntax clear
+ elseif exists("b:current_syntax")
+ finish
+ endif
+ let g:main_syntax = 'dart'
+ syntax region dartFold start="{" end="}" transparent fold
+endif
+
+" Ensure long multiline strings are highlighted.
+syntax sync fromstart
+
+" keyword definitions
+syntax keyword dartConditional if else switch
+syntax keyword dartRepeat do while for
+syntax keyword dartBoolean true false
+syntax keyword dartConstant null
+syntax keyword dartTypedef this super class typedef
+syntax keyword dartOperator new is as in factory
+syntax match dartOperator "+=\=\|-=\=\|*=\=\|/=\=\|%=\=\|\~/=\=\|<<=\=\|>>=\=\|[<>]=\=\|===\=\|\!==\=\|&=\=\|\^=\=\||=\=\|||\|&&\|\[\]=\=\|=>\|!\|\~\|?\|:"
+syntax keyword dartType void var bool int double num dynamic
+syntax keyword dartStatement return
+syntax keyword dartStorageClass static abstract final const
+syntax keyword dartExceptions throw rethrow try on catch finally
+syntax keyword dartAssert assert
+syntax keyword dartClassDecl extends with implements
+syntax keyword dartBranch break continue nextgroup=dartUserLabelRef skipwhite
+syntax keyword dartKeyword get set operator call external async await yield sync
+syntax match dartUserLabelRef "\k\+" contained
+
+syntax region dartLabelRegion transparent matchgroup=dartLabel start="\<case\>" matchgroup=NONE end=":"
+syntax keyword dartLabel default
+
+syntax match dartLibrary "^\(import\|part of\|part\|export\|library\|show\|hide\)\s"
+
+" Comments
+syntax keyword dartTodo contained TODO FIXME XXX
+syntax region dartComment start="/\*" end="\*/" contains=dartTodo,dartDocLink,@Spell
+syntax match dartLineComment "//.*" contains=dartTodo,@Spell
+syntax match dartLineDocComment "///.*" contains=dartTodo,dartDocLink,@Spell
+syntax region dartDocLink contained start=+\[+ end=+\]+
+
+" Strings
+syntax region dartString start=+\z(["']\)+ end=+\z1+ contains=@Spell,dartInterpolation,dartSpecialChar
+syntax region dartRawString start=+r\z(["']\)+ end=+\z1+ contains=@Spell
+syntax region dartMultilineString start=+\z("\{3\}\|'\{3\}\)+ end=+\z1+ contains=@Spell,dartInterpolation,dartSpecialChar
+syntax region dartRawMultilineString start=+r\z("\{3\}\|'\{3\}\)+ end=+\z1+ contains=@Spell
+syntax match dartInterpolation contained "\$\(\w\+\|{[^}]\+}\)"
+syntax match dartSpecialChar contained "\\\(u\x\{4\}\|u{\x\+}\|x\x\x\|x{\x\+}\|.\)"
+
+" Numbers
+syntax match dartNumber "\<\d\+\(\.\d\+\)\=\>"
+
+" TODO(antonm): consider conditional highlighting of corelib classes.
+syntax keyword dartCoreClasses BidirectionalIterator Comparable DateTime Duration Expando Function Invocation Iterable Iterator List Map Match Object Pattern RegExp RuneIterator Runes Set StackTrace Stopwatch String StringBuffer StringSink Symbol Type
+syntax keyword dartCoreTypedefs Comparator
+syntax keyword dartCoreExceptions AbstractClassInstantiationError ArgumentError AssertionError CastError ConcurrentModificationError Error Exception FallThroughError FormatException IntegerDivisionByZeroException NoSuchMethodError NullThrownError OutOfMemoryError RangeError RuntimeError StackOverflowError StateError TypeError UnimplementedError UnsupportedError
+
+
+" The default highlighting.
+highlight default link dartBranch Conditional
+highlight default link dartUserLabelRef dartUserLabel
+highlight default link dartLabel Label
+highlight default link dartUserLabel Label
+highlight default link dartConditional Conditional
+highlight default link dartRepeat Repeat
+highlight default link dartExceptions Exception
+highlight default link dartAssert Statement
+highlight default link dartStorageClass StorageClass
+highlight default link dartClassDecl dartStorageClass
+highlight default link dartBoolean Boolean
+highlight default link dartString String
+highlight default link dartRawString String
+highlight default link dartMultilineString String
+highlight default link dartRawMultilineString String
+highlight default link dartNumber Number
+highlight default link dartStatement Statement
+highlight default link dartOperator Operator
+highlight default link dartComment Comment
+highlight default link dartLineComment Comment
+highlight default link dartLineDocComment Comment
+highlight default link dartConstant Constant
+highlight default link dartTypedef Typedef
+highlight default link dartTodo Todo
+highlight default link dartKeyword Keyword
+highlight default link dartType Type
+highlight default link dartInterpolation PreProc
+highlight default link dartDocLink SpecialComment
+highlight default link dartSpecialChar SpecialChar
+highlight default link dartLibrary Include
+highlight default link dartCoreClasses Type
+highlight default link dartCoreTypedefs Typedef
+highlight default link dartCoreExceptions Exception
+
+let b:current_syntax = "dart"
+let b:spell_options = "contained"
+
+if g:main_syntax is# 'dart'
+ unlet g:main_syntax
+endif
+
+endif