Skip to content

Commit

Permalink
daily commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchee committed Dec 29, 2017
1 parent d20ae6e commit ee86160
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 4 deletions.
10 changes: 6 additions & 4 deletions _vimrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" ----------------- Author: Ruchee
" ----------------- Email: [email protected]
" ----------------- Date: 2017-11-03 17:33:51
" ----------------- Date: 2017-12-29 15:26:10
" ----------------- https://github.com/ruchee/vimrc


Expand Down Expand Up @@ -736,7 +736,7 @@ else
endif
let g:syntastic_c_compiler_options = '-Wall -std=c11'
let g:syntastic_cpp_compiler_options = '-Wall -std=c++14'
let g:syntastic_swift_checkers = ['swiftpm', 'swiftlint']
let g:syntastic_swift_checkers = ['swift', 'swiftpm', 'swiftlint']
let g:syntastic_rust_checkers = ['rustc']
let g:syntastic_nim_checkers = ['nim']
let g:syntastic_enable_nim_checker = 1
Expand Down Expand Up @@ -966,8 +966,10 @@ func! Compile_Run_Code()
exec '!clang -fobjc-arc -framework Foundation %:t -o %:r && ./%:r'
endif
elseif &filetype == 'swift'
if g:isMAC
exec '!swift %:t'
if g:isWIN
exec '!swiftc %:t && %:r.exe'
else
exec '!swiftc %:t && ./%:r'
endif
elseif &filetype == 'd'
if g:isWIN
Expand Down
52 changes: 52 additions & 0 deletions vimfiles/bundle/vim-swift/syntax_checkers/swift/swift.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
if exists('g:loaded_syntastic_swift_swift_checker')
finish
endif
let g:loaded_syntastic_swift_swift_checker = 1

if !exists('g:syntastic_swift_swift_executable')
let g:syntastic_swift_swift_executable = 'swift'
endif

if !exists('g:syntastic_swift_swift_arguments')
let g:syntastic_swift_swift_arguments = expand('%:p')
endif
let s:save_cpo = &cpo

set cpo&vim

function! SyntaxCheckers_swift_swift_IsAvailable() dict
if !executable(self.getExec())
return 0
endif
return 1
endfunction

function! SyntaxCheckers_swift_swift_GetLocList() dict
let makeprg = self.makeprgBuild({
\ 'args': g:syntastic_swift_swift_arguments,
\ 'fname': '' })

let errorformat =
\ '%f:%l:%c: %trror: %m,' .
\ '%f:%l:%c: %tarning: %m,' .
\ '%f:%l: %trror: %m,' .
\ '%f:%l: %tarning: %m'

let env = {
\ 'SCRIPT_INPUT_FILE_COUNT': 1,
\ 'SCRIPT_INPUT_FILE_0': expand('%:p'),
\ }

return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'env': env })
endfunction

call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'swift',
\ 'exec': g:syntastic_swift_swift_executable,
\ 'name': 'swift' })

let &cpo = s:save_cpo
unlet s:save_cpo
18 changes: 18 additions & 0 deletions vimfiles/snippets/swift.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ snippet if if
if ${1} {
${0}
}
snippet ifc if case
if case ${1} {
${0}
}
snippet ifl if let
if let ${1} {
${0}
}
snippet elif else if
else if ${1} {
${0}
Expand Down Expand Up @@ -105,6 +113,8 @@ snippet cs case
snippet def default
default:
${0}
snippet fa 继续匹配
fallthrough${0}
# 异常处理
snippet thr 抛出异常
throw ${0}
Expand Down Expand Up @@ -133,8 +143,14 @@ snippet v 定义变量
var ${0}
snippet l 定义常量
let ${0}
snippet w 条件匹配
where ${0}
snippet re 返回
return ${0}
snippet co 继续
continue${0}
snippet br 中断
break${0}
snippet su 调用父类的方法
super${0}
snippet sui 调用父类的构造方法
Expand Down Expand Up @@ -173,6 +189,8 @@ snippet _f Float
Float${0}
snippet _d Double
Double${0}
snippet _c Character
Character${0}
snippet _s String
String${0}
snippet _b Bool
Expand Down

0 comments on commit ee86160

Please sign in to comment.