summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rwxr-xr-xbuild1
-rw-r--r--ftdetect/polyglot.vim8
-rw-r--r--ftplugin/vlang.vim6
-rw-r--r--indent/vlang.vim69
-rw-r--r--syntax/vlang.vim268
6 files changed, 354 insertions, 1 deletions
diff --git a/README.md b/README.md
index 42340c21..52e2776b 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ A collection of language packs for Vim.
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
-- It **installs and updates 120+ times faster** than the <!--Package Count-->146<!--/Package Count--> packages it consists of.
+- It **installs and updates 120+ times faster** than the <!--Package Count-->147<!--/Package Count--> packages it consists of.
- Solid syntax and indentation support (other features skipped). Only the best language packs.
- All unnecessary files are ignored (like enormous documentation from php support).
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
@@ -178,6 +178,7 @@ If you need full functionality of any plugin, please use it directly with your p
- [tptp](https://github.com/c-cube/vim-tptp) (syntax)
- [twig](https://github.com/lumiliet/vim-twig) (syntax, indent, ftplugin)
- [typescript](https://github.com/HerringtonDarkholme/yats.vim) (syntax, indent, compiler, ftplugin)
+- [v](https://github.com/ollykel/v-vim) (syntax, indent, ftplugin)
- [vala](https://github.com/arrufat/vala.vim) (syntax, indent, ftplugin)
- [vbnet](https://github.com/vim-scripts/vbnet.vim) (syntax)
- [vcl](https://github.com/smerrill/vcl-vim-plugin) (syntax)
diff --git a/build b/build
index 72a089f8..7e4b5221 100755
--- a/build
+++ b/build
@@ -292,6 +292,7 @@ PACKS="
tptp:c-cube/vim-tptp
twig:lumiliet/vim-twig
typescript:HerringtonDarkholme/yats.vim
+ v:ollykel/v-vim
vala:arrufat/vala.vim
vbnet:vim-scripts/vbnet.vim
vcl:smerrill/vcl-vim-plugin
diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim
index 128d60c3..5ab23e80 100644
--- a/ftdetect/polyglot.vim
+++ b/ftdetect/polyglot.vim
@@ -1473,6 +1473,14 @@ autocmd BufNewFile,BufRead *.tsx setlocal filetype=typescriptreact
augroup end
endif
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'v') == -1
+ augroup filetypedetect
+ " v, from vlang.vim in ollykel/v-vim
+au BufNewFile,BufRead *.v set filetype=vlang
+au BufNewFile,BufRead *.v set syntax=vlang
+ augroup end
+endif
+
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vala') == -1
augroup filetypedetect
" vala, from vala.vim in arrufat/vala.vim
diff --git a/ftplugin/vlang.vim b/ftplugin/vlang.vim
new file mode 100644
index 00000000..0aafeac5
--- /dev/null
+++ b/ftplugin/vlang.vim
@@ -0,0 +1,6 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'v') == -1
+
+setlocal commentstring=//\ %s
+setlocal makeprg=v\ %
+
+endif
diff --git a/indent/vlang.vim b/indent/vlang.vim
new file mode 100644
index 00000000..58b441f9
--- /dev/null
+++ b/indent/vlang.vim
@@ -0,0 +1,69 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'v') == -1
+
+" Based on the Go identation file.
+"
+" Copyright 2011 The Go Authors. 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("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal nolisp
+setlocal autoindent
+setlocal indentexpr=VlangIndent(v:lnum)
+setlocal indentkeys+=<:>,0=},0=)
+
+if exists("*VlangIndent")
+ finish
+endif
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+function! VlangIndent(lnum) abort
+ let prevlnum = prevnonblank(a:lnum-1)
+ if prevlnum == 0
+ return 0
+ endif
+
+ let prevl = substitute(getline(prevlnum), '//.*$', '', '')
+ let thisl = substitute(getline(a:lnum), '//.*$', '', '')
+ let previ = indent(prevlnum)
+
+ let ind = previ
+
+ if prevl =~ '[({]\s*$'
+ " previous line opened a block
+ let ind += shiftwidth()
+ endif
+ if prevl =~# '^\s*\(case .*\|default\):$'
+ " previous line is part of a switch statement
+ let ind += shiftwidth()
+ endif
+
+ if thisl =~ '^\s*[)}]'
+ " this line closed a block
+ let ind -= shiftwidth()
+ endif
+
+ " Colons are tricky.
+ " We want to outdent if it's part of a switch ("case foo:" or "default:").
+ " We ignore trying to deal with jump labels because (a) they're rare, and
+ " (b) they're hard to disambiguate from a composite literal key.
+ if thisl =~# '^\s*\(case .*\|default\):$'
+ let ind -= shiftwidth()
+ endif
+
+ return ind
+endfunction
+
+" restore Vi compatibility settings
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
+" vim: sw=2 ts=2 et
+
+endif
diff --git a/syntax/vlang.vim b/syntax/vlang.vim
new file mode 100644
index 00000000..9d802f00
--- /dev/null
+++ b/syntax/vlang.vim
@@ -0,0 +1,268 @@
+if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'v') == -1
+
+" Vim syntax file
+" Language: V
+" Maintainer: Oliver Kelton (https://github.com/ollykel)
+" Last Change: 2019 Jun 13
+" NOTE: largely based on go.vim, maintained by David Barnett
+" see David Barnett (https://github.com/google/vim-ft-go)
+" Options:
+" There are some options for customizing the highlighting; the recommended
+" settings are the default values, but you can write:
+" let OPTION_NAME = 0
+" in your ~/.vimrc file to disable particular options. You can also write:
+" let OPTION_NAME = 1
+" to enable particular options. At present, all options default to on.
+"
+" - g:v_highlight_array_whitespace_error
+" Highlights white space after "[]".
+" - g:v_highlight_chan_whitespace_error
+" Highlights white space around the communications operator that don't
+" follow the standard style.
+" Highlights commonly used library types (io.Reader, etc.).
+" - g:v_highlight_space_tab_error
+" Highlights instances of tabs following spaces.
+" - g:v_highlight_trailing_whitespace_error
+" Highlights trailing white space.
+
+" Quit when a (custom) syntax file was already loaded
+if exists('b:current_syntax')
+ finish
+endif
+
+if !exists('g:v_highlight_array_whitespace_error')
+ let g:v_highlight_array_whitespace_error = 1
+endif
+if !exists('g:v_highlight_chan_whitespace_error')
+ let g:v_highlight_chan_whitespace_error = 1
+endif
+if !exists('g:v_highlight_space_tab_error')
+ let g:v_highlight_space_tab_error = 1
+endif
+if !exists('g:v_highlight_trailing_whitespace_error')
+ let g:v_highlight_trailing_whitespace_error = 1
+endif
+if !exists('g:v_highlight_function_calls')
+ let g:v_highlight_function_calls = 1
+endif
+if !exists('g:v_highlight_fields')
+ let g:v_highlight_fields = 1
+endif
+
+syn case match
+
+syn match vDeclType "\<\(struct\|interface\)\>"
+
+syn keyword vDirective module import
+syn keyword vDeclaration pub mut const type enum
+syn region vIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
+syn match vIncluded display contained "<[^>]*>"
+syn match vFlagDefinition display contained "\s\i[^\n]*"
+syn match vInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=vIncluded
+syn match vFlag display "^\s*\zs\(%:\|#\)\s*flag\>\s*[^\n]*" contains=vFlagDefinition
+syn region vShebang display start=/^#!/ end=/$/
+
+hi def link vDirective Statement
+hi def link vDeclaration Keyword
+hi def link vDeclType Keyword
+hi def link vInclude Include
+hi def link vFlag Include
+hi def link vIncluded vString
+hi def link vFlagDefinition vString
+hi def link vShebang Include
+
+" Keywords within functions
+syn keyword vStatement defer go goto return break continue fallthrough
+syn keyword vConditional if else switch match or
+syn keyword vLabel case default
+syn keyword vRepeat for in
+syn match vCodeGen /$if\>/
+syn match vCodeGen /\.fields\>/
+syn match vCodeGen /\.$\i*\>/
+
+hi def link vStatement Statement
+hi def link vConditional Conditional
+hi def link vLabel Label
+hi def link vRepeat Repeat
+hi def link vCodeGen Identifier
+
+" Predefined types
+syn keyword vType chan map bool string error voidptr
+syn keyword vSignedInts int i8 i16 i32 i64 rune intptr
+syn keyword vUnsignedInts byte uint u8 u16 u32 u64 byteptr
+syn keyword vFloats f32 f64 floatptr
+syn keyword vComplexes complex64 complex128
+
+hi def link vType Type
+hi def link vSignedInts Type
+hi def link vUnsignedInts Type
+hi def link vFloats Type
+hi def link vComplexes Type
+
+" Treat fn specially: it's a declaration at the start of a line, but a type
+" elsewhere. Order matters here.
+" syn match vType /\<fn\>/
+syn match vDeclaration /\<fn\>/
+syn match vDeclaration contained /\<fn\>/
+
+" Predefined functions and values
+syn keyword vBuiltins assert C cap complex copy delete exit imag
+syn keyword vBuiltins print println eprint eprintln print_backtrace
+syn keyword vBuiltins float_calloc ok memdup range_int real recover
+syn keyword vBuiltins malloc byte_calloc float_calloc
+syn keyword vBuiltins isok isnil panic on_panic
+syn keyword vConstants iota true false
+syn match vBuiltins /\<json\.\(encode\|decode\)\>/
+
+hi def link vBuiltins Keyword
+hi def link vConstants Keyword
+
+" Comments; their contents
+syn keyword vTodo contained TODO FIXME XXX BUG
+syn cluster vCommentGroup contains=vTodo
+syn region vComment start="/\*" end="\*/" contains=@vCommentGroup,@Spell
+syn region vComment start="//" end="$" contains=@vCommentGroup,@Spell
+
+hi def link vComment Comment
+hi def link vTodo Todo
+
+" Go escapes
+syn match vEscapeOctal display contained "\\[0-7]\{3}"
+syn match vEscapeVar display contained "\$[0-9A-Za-z\.]*"
+syn match vEscapeVar display contained "\${[^}]*}"
+syn match vEscapeC display contained +\\[abfnrtv\\'"]+
+syn match vEscapeX display contained "\\x\x\{2}"
+syn match vEscapeU display contained "\\u\x\{4}"
+syn match vEscapeBigU display contained "\\U\x\{8}"
+syn match vEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+
+
+hi def link vEscapeOctal vSpecialString
+hi def link vEscapeVar vSpecialString
+hi def link vEscapeC vSpecialString
+hi def link vEscapeX vSpecialString
+hi def link vEscapeU vSpecialString
+hi def link vEscapeBigU vSpecialString
+hi def link vSpecialString Special
+hi def link vEscapeError Error
+
+" Strings and their contents
+syn cluster vStringGroup contains=vEscapeOctal,vEscapeVar,vEscapeC,vEscapeX,vEscapeU,vEscapeBigU,vEscapeError
+syn region vString start=+"+ skip=+\\\\\|\\'+ end=+"+ contains=@vStringGroup
+syn region vRawString start=+`+ end=+`+
+
+hi def link vString String
+hi def link vRawString String
+
+" Characters; their contents
+syn cluster vCharacterGroup contains=vEscapeOctal,vEscapeC,vEscapeVar,vEscapeX,vEscapeU,vEscapeBigU
+syn region vCharacter start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@vCharacterGroup
+
+hi def link vCharacter Character
+
+" Regions
+syn region vBlock start="{" end="}" transparent fold
+syn region vParen start='(' end=')' transparent
+
+" Integers
+syn match vDecimalInt "\<\d\+\([Ee]\d\+\)\?\>"
+syn match vHexadecimalInt "\<0x\x\+\>"
+syn match vOctalInt "\<0\o\+\>"
+syn match vOctalError "\<0\o*[89]\d*\>"
+
+hi def link vDecimalInt Integer
+hi def link vHexadecimalInt Integer
+hi def link vOctalInt Integer
+hi def link Integer Number
+
+" Floating point
+syn match vFloat "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>"
+syn match vFloat "\<\.\d\+\([Ee][-+]\d\+\)\?\>"
+syn match vFloat "\<\d\+[Ee][-+]\d\+\>"
+
+hi def link vFloat Float
+
+" Imaginary literals
+syn match vImaginary "\<\d\+i\>"
+syn match vImaginary "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>"
+syn match vImaginary "\<\.\d\+\([Ee][-+]\d\+\)\?i\>"
+syn match vImaginary "\<\d\+[Ee][-+]\d\+i\>"
+
+hi def link vImaginary Number
+
+" Generics
+syn match vGenericBrackets display contained "[<>]"
+syn match vInterfaceDeclaration display "\s*\zsinterface\s*\i*\s*<[^>]*>" contains=vDeclType,vGenericBrackets
+syn match vStructDeclaration display "\s*\zsstruct\s*\i*\s*<[^>]*>" contains=vDeclType,vGenericBrackets
+" vFunctionName only appears when v_highlight_function_calls set
+syn match vFuncDeclaration display "\s*\zsfn\s*\i*\s*<[^>]*>" contains=vFunctionName,vDeclaration,vGenericBrackets
+
+hi def link vGenericBrackets Identifier
+
+" Spaces after "[]"
+if v_highlight_array_whitespace_error != 0
+ syn match vSpaceError display "\(\[\]\)\@<=\s\+"
+endif
+
+" Spacing errors around the 'chan' keyword
+if v_highlight_chan_whitespace_error != 0
+ " receive-only annotation on chan type
+ syn match vSpaceError display "\(<-\)\@<=\s\+\(chan\>\)\@="
+ " send-only annotation on chan type
+ syn match vSpaceError display "\(\<chan\)\@<=\s\+\(<-\)\@="
+ " value-ignoring receives in a few contexts
+ syn match vSpaceError display "\(\(^\|[={(,;]\)\s*<-\)\@<=\s\+"
+endif
+
+" Space-tab error
+if v_highlight_space_tab_error != 0
+ syn match vSpaceError display " \+\t"me=e-1
+endif
+
+" Trailing white space error
+if v_highlight_trailing_whitespace_error != 0
+ syn match vSpaceError display excludenl "\s\+$"
+endif
+
+hi def link vSpaceError Error
+
+" Function calls and Fields are from: https://github.com/fatih/vim-go/blob/master/syntax/go.vim
+" Function calls;
+if v_highlight_function_calls
+ syn match vFunctionCall /\w\+\ze\s*(/ contains=vBuiltins,vDeclaration
+ syn match vFunctionName display contained /\s\w\+/
+ hi def link vFunctionName Special
+endif
+
+hi def link vFunctionCall Special
+
+" Fields;
+if v_highlight_fields
+ " 1. Match a sequence of word characters coming after a '.'
+ " 2. Require the following but dont match it: ( \@= see :h E59)
+ " - The symbols: / - + * % OR
+ " - The symbols: [] {} <> ) OR
+ " - The symbols: \n \r space OR
+ " - The symbols: , : .
+ " 3. Have the start of highlight (hs) be the start of matched
+ " pattern (s) offsetted one to the right (+1) (see :h E401)
+ syn match vField /\.\w\+\
+ \%(\%([\/\-\+*%]\)\|\
+ \%([\[\]{}<\>\)]\)\|\
+ \%([\!=\^|&]\)\|\
+ \%([\n\r\ ]\)\|\
+ \%([,\:.]\)\)\@=/hs=s+1
+endif
+hi def link vField Identifier
+
+" Search backwards for a global declaration to start processing the syntax.
+"syn sync match vSync grouphere NONE /^\(const\|var\|type\|func\)\>/
+
+" There's a bug in the implementation of grouphere. For now, use the
+" following as a more expensive/less precise workaround.
+syn sync minlines=500
+
+let b:current_syntax = 'vlang'
+
+" vim: sw=2 sts=2 et
+
+endif