Fixed vim and zsh

This commit is contained in:
2018-04-05 13:06:54 +02:00
parent f9db886bd3
commit 0331f6518a
2009 changed files with 256303 additions and 0 deletions

View File

@ -0,0 +1,22 @@
# kotlin-vim
## Installation
### [Vundle](https://github.com/gmarik/Vundle.vim)
Add `Plugin 'udalov/kotlin-vim'` to your `~/.vimrc` and run `PluginInstall`.
### [Pathogen](https://github.com/tpope/vim-pathogen)
$ git clone https://github.com/udalov/kotlin-vim ~/.vim/bundle/kotlin-vim
### Manual
0. `mkdir -p ~/.vim/{syntax,indent,ftdetect}`
1. `cp syntax/kotlin.vim ~/.vim/syntax/kotlin.vim`
2. `cp indent/kotlin.vim ~/.vim/indent/kotlin.vim`
3. `cp ftdetect/kotlin.vim ~/.vim/ftdetect/kotlin.vim`
4. If you use [Syntastic](https://github.com/scrooloose/syntastic): `cp -r syntax_checkers/kotlin ~/.vim/syntax_checkers/`
5. Restart Vim
##### Enjoy!

View File

@ -0,0 +1,2 @@
autocmd BufNewFile,BufRead *.kt setfiletype kotlin
autocmd BufNewFile,BufRead *.kts setfiletype kotlin

View File

@ -0,0 +1,66 @@
" Vim indent file
" Language: Kotlin
" Maintainer: Alexander Udalov
" Latest Revision: 15 July 2017
if exists("b:did_indent")
finish
endif
let b:did_indent = 1
setlocal cinoptions& cinoptions+=j1,L0
setlocal indentexpr=GetKotlinIndent()
setlocal indentkeys=0},0),!^F,o,O,e,<CR>
setlocal autoindent " TODO ?
" TODO teach it to count bracket balance, etc.
function! GetKotlinIndent()
if v:lnum == 0
return 0
endif
let prev_num = prevnonblank(v:lnum - 1)
let prev = getline(prev_num)
let prev_indent = indent(prev_num)
let cur = getline(v:lnum)
if cur =~ '^\s*\*'
return cindent(v:lnum)
endif
if prev =~ '^\s*\*/'
let st = prev
while st > 1
if getline(st) =~ '^\s*/\*'
break
endif
let st = st - 1
endwhile
return indent(st)
endif
let prev_open_paren = prev =~ '^.*(\s*$'
let cur_close_paren = cur =~ '^\s*).*$'
if prev_open_paren && !cur_close_paren
return prev_indent + 2 * &shiftwidth
endif
if cur_close_paren && !prev_open_paren
return prev_indent - 2 * &shiftwidth
endif
let prev_open_brace = prev =~ '^.*\({\|->\)\s*$'
let cur_close_brace = cur =~ '^\s*}.*$'
if prev_open_brace && !cur_close_brace
return prev_indent + &shiftwidth
endif
if cur_close_brace && !prev_open_brace
return prev_indent - &shiftwidth
endif
return prev_indent
endfunction

View File

@ -0,0 +1,103 @@
" Vim syntax file
" Language: Kotlin
" Maintainer: Alexander Udalov
" Latest Revision: 18 September 2017
if exists("b:current_syntax")
finish
endif
let b:current_syntax = "kotlin"
syn keyword ktStatement break continue return
syn keyword ktConditional if else when
syn keyword ktRepeat do for while
syn keyword ktOperator as in is by
syn keyword ktKeyword get set out super this where
syn keyword ktException try catch finally throw
syn keyword ktInclude import package
syn keyword ktType Any Boolean Byte Char Double Float Int Long Nothing Short Unit
syn keyword ktModifier annotation companion enum inner internal private protected public abstract final open override sealed vararg dynamic header impl expect actual
syn keyword ktStructure class object interface typealias fun val var constructor init
syn keyword ktReservedKeyword typeof
syn keyword ktBoolean true false
syn keyword ktConstant null
syn keyword ktModifier data tailrec lateinit reified external inline noinline crossinline const operator infix suspend
syn keyword ktTodo TODO FIXME XXX contained
syn match ktShebang "\v^#!.*$"
syn match ktLineComment "\v//.*$" contains=ktTodo,@Spell
syn region ktComment matchgroup=ktCommentMatchGroup start="/\*" end="\*/" contains=ktComment,ktTodo,@Spell
syn match ktSpecialCharError "\v\\." contained
syn match ktSpecialChar "\v\\([tbnr'"$\\]|u\x{4})" contained
syn region ktString start='"' skip='\\"' end='"' contains=ktSimpleInterpolation,ktComplexInterpolation,ktSpecialChar,ktSpecialCharError
syn region ktString start='"""' end='"""' contains=ktSimpleInterpolation,ktComplexInterpolation,ktSpecialChar,ktSpecialCharError
syn match ktCharacter "\v'[^']*'" contains=ktSpecialChar,ktSpecialCharError
syn match ktCharacter "\v'\\''" contains=ktSpecialChar
syn match ktCharacter "\v'[^\\]'"
" TODO: highlight label in 'this@Foo'
syn match ktAnnotation "\v(\w)@<!\@[[:alnum:]_.]*(:[[:alnum:]_.]*)?"
syn match ktLabel "\v\w+\@"
syn match ktSimpleInterpolation "\v\$\h\w*" contained
syn region ktComplexInterpolation matchgroup=ktComplexInterpolationBrace start="\v\$\{" end="\v\}" contains=ALLBUT,ktSimpleInterpolation
syn match ktNumber "\v<\d+[_[:digit:]]*[LFf]?"
syn match ktNumber "\v<0[Xx]\x+[_[:xdigit:]]*L?"
syn match ktNumber "\v<0[Bb][01]+[_01]*L?"
syn match ktFloat "\v<\d*(\d[eE][-+]?\d+|\.\d+([eE][-+]?\d+)?)[Ff]?"
syn match ktEscapedName "\v`.*`"
syn match ktExclExcl "!!"
syn match ktArrow "->"
hi link ktStatement Statement
hi link ktConditional Conditional
hi link ktRepeat Repeat
hi link ktOperator Operator
hi link ktKeyword Keyword
hi link ktException Exception
hi link ktReservedKeyword Error
hi link ktInclude Include
hi link ktType Type
hi link ktModifier StorageClass
hi link ktStructure Structure
hi link ktTypedef Typedef
hi link ktBoolean Boolean
hi link ktConstant Constant
hi link ktTodo Todo
hi link ktShebang Comment
hi link ktLineComment Comment
hi link ktComment Comment
hi link ktCommentMatchGroup Comment
hi link ktSpecialChar SpecialChar
hi link ktSpecialCharError Error
hi link ktString String
hi link ktCharacter Character
hi link ktAnnotation Identifier
hi link ktLabel Identifier
hi link ktSimpleInterpolation Identifier
hi link ktComplexInterpolationBrace Identifier
hi link ktNumber Number
hi link ktFloat Float
hi link ktExclExcl Special
hi link ktArrow Structure

View File

@ -0,0 +1,105 @@
" Vim syntastic plugin
" Language: Kotlin
if exists('g:loaded_syntastic_kotlin_kotlinc_checker')
finish
endif
let g:loaded_syntastic_kotlin_kotlinc_checker = 1
let s:save_cpo = &cpo
set cpo&vim
if !exists("g:syntastic_kotlin_kotlinc_options")
let g:syntastic_kotlin_kotlinc_options = ""
endif
if !exists("g:syntastic_kotlin_kotlinc_delete_output")
let g:syntastic_kotlin_kotlinc_delete_output = 1
endif
if !exists("g:syntastic_kotlin_kotlinc_config_file_enabled")
let g:syntastic_kotlin_kotlinc_config_file_enabled = 0
endif
if !exists("g:syntastic_kotlin_kotlinc_config_file")
let g:syntastic_kotlin_kotlinc_config_file = ".syntastic_kotlinc_config"
endif
if !exists("g:syntastic_kotlin_kotlinc_classpath")
let g:syntastic_kotlin_kotlinc_classpath = ""
endif
if !exists("g:syntastic_kotlin_kotlinc_sourcepath")
let g:syntastic_kotlin_kotlinc_sourcepath = ""
endif
function! SyntaxCheckers_kotlin_kotlinc_GetLocList() dict
let kotlinc_opts = g:syntastic_kotlin_kotlinc_options
if g:syntastic_kotlin_kotlinc_config_file_enabled
if filereadable(expand(g:syntastic_kotlin_kotlinc_config_file, 1))
execute "source " . fnameescape(expand(g:syntastic_kotlin_kotlinc_config_file, 1))
endif
endif
if g:syntastic_kotlin_kotlinc_classpath !=# ""
let kotlinc_opts .= " -cp " . g:syntastic_kotlin_kotlinc_classpath
endif
let fname = ""
if g:syntastic_kotlin_kotlinc_sourcepath !=# ""
let fname .= expand(g:syntastic_kotlin_kotlinc_sourcepath, 1) . " "
endif
let fname .= shellescape(expand("%", 1))
let output_dir = ""
if g:syntastic_kotlin_kotlinc_delete_output
let output_dir = syntastic#util#tmpdir()
let kotlinc_opts .= " -d " . syntastic#util#shescape(output_dir)
endif
let makeprg = self.makeprgBuild({
\ "exe": "kotlinc",
\ "args": kotlinc_opts,
\ "fname": fname })
let errorformat =
\ "%E%f:%l:%c: error: %m," .
\ "%W%f:%l:%c: warning: %m," .
\ "%Eerror: %m," .
\ "%Wwarning: %m," .
\ "%Iinfo: %m,"
if output_dir !=# ''
silent! call mkdir(output_dir, 'p')
endif
let errors = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat, })
if output_dir !=# ''
call syntastic#util#rmrf(output_dir)
endif
let currbufnr = bufnr("%")
let relevant_errors = []
for error in errors
" Only get messages bounded to this buffer or are 'bufferless'
if (error.bufnr == currbufnr) || (error.bufnr == 0)
let relevant_errors = add(relevant_errors, error)
endif
endfor
return relevant_errors
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'kotlin',
\ 'name': 'kotlinc',
\ 'exec': 'kotlinc' })
let &cpo = s:save_cpo
unlet s:save_cpo