vint: Use single quotes.

This commit is contained in:
Yasuhiro Matsumoto 2020-10-16 11:18:49 +09:00 committed by zah
commit d37b228985
6 changed files with 48 additions and 46 deletions

View file

@ -1,7 +1,7 @@
let g:nim_log = [] let g:nim_log = []
let s:plugin_path = escape(expand('<sfile>:p:h'), '\') let s:plugin_path = escape(expand('<sfile>:p:h'), '\')
if !exists("g:nim_caas_enabled") if !exists('g:nim_caas_enabled')
let g:nim_caas_enabled = 0 let g:nim_caas_enabled = 0
endif endif
@ -14,12 +14,12 @@ if has('pythonx')
endif endif
fun! nim#init() fun! nim#init()
let cmd = printf("nim --dump.format:json --verbosity:0 dump %s", s:CurrentNimFile()) let cmd = printf('nim --dump.format:json --verbosity:0 dump %s', s:CurrentNimFile())
let raw_dumpdata = system(cmd) let raw_dumpdata = system(cmd)
if !v:shell_error && expand("%:e") == "nim" if !v:shell_error && expand('%:e') == 'nim'
let false = 0 " Needed for eval of json let false = 0 " Needed for eval of json
let true = 1 " Needed for eval of json let true = 1 " Needed for eval of json
let dumpdata = eval(substitute(raw_dumpdata, "\n", "", "g")) let dumpdata = eval(substitute(raw_dumpdata, "\n", '', 'g'))
let b:nim_project_root = dumpdata['project_path'] let b:nim_project_root = dumpdata['project_path']
let b:nim_defined_symbols = dumpdata['defined_symbols'] let b:nim_defined_symbols = dumpdata['defined_symbols']
@ -27,7 +27,7 @@ fun! nim#init()
for path in dumpdata['lib_paths'] for path in dumpdata['lib_paths']
if finddir(path) == path if finddir(path) == path
let &l:path = path . "," . &l:path let &l:path = path . ',' . &l:path
endif endif
endfor endfor
else else
@ -52,7 +52,7 @@ endf
augroup NimVim augroup NimVim
au! au!
au BufEnter log://nim call s:UpdateNimLog() au BufEnter log://nim call s:UpdateNimLog()
if has("pythonx") if has('pythonx')
" au QuitPre * :pyx nimTerminateAll() " au QuitPre * :pyx nimTerminateAll()
au VimLeavePre * :pyx nimTerminateAll() au VimLeavePre * :pyx nimTerminateAll()
endif endif
@ -70,14 +70,14 @@ fun! s:CurrentNimFile()
let save_cur = getpos('.') let save_cur = getpos('.')
call cursor(0, 0, 0) call cursor(0, 0, 0)
let PATTERN = "\\v^\\#\\s*included from \\zs.*\\ze" let PATTERN = '\v^\#\s*included from \zs.*\ze'
let l = search(PATTERN, "n") let l = search(PATTERN, 'n')
if l != 0 if l != 0
let f = matchstr(getline(l), PATTERN) let f = matchstr(getline(l), PATTERN)
let l:to_check = expand('%:h') . "/" . f let l:to_check = expand('%:h') . '/' . f
else else
let l:to_check = expand("%") let l:to_check = expand('%')
endif endif
call setpos('.', save_cur) call setpos('.', save_cur)
@ -105,15 +105,15 @@ let g:nim_symbol_types = {
\ } \ }
fun! NimExec(op) fun! NimExec(op)
let isDirty = getbufvar(bufnr('%'), "&modified") let isDirty = getbufvar(bufnr('%'), '&modified')
if isDirty if isDirty
let tmp = tempname() . bufname("%") . "_dirty.nim" let tmp = tempname() . bufname('%') . '_dirty.nim'
silent! exe ":w " . tmp silent! exe ':w ' . tmp
let cmd = printf("idetools %s --trackDirty:\"%s,%s,%d,%d\" \"%s\"", let cmd = printf('idetools %s --trackDirty:"%s,%s,%d,%d" "%s"',
\ a:op, tmp, expand('%:p'), line('.'), col('.')-1, s:CurrentNimFile()) \ a:op, tmp, expand('%:p'), line('.'), col('.')-1, s:CurrentNimFile())
else else
let cmd = printf("idetools %s --track:\"%s,%d,%d\" \"%s\"", let cmd = printf('idetools %s --track:"%s,%d,%d" "%s"',
\ a:op, expand('%:p'), line('.'), col('.')-1, s:CurrentNimFile()) \ a:op, expand('%:p'), line('.'), col('.')-1, s:CurrentNimFile())
endif endif
@ -121,10 +121,10 @@ fun! NimExec(op)
exe printf("pyx nimExecCmd('%s', '%s', False)", b:nim_project_root, cmd) exe printf("pyx nimExecCmd('%s', '%s', False)", b:nim_project_root, cmd)
let output = l:py_res let output = l:py_res
else else
let output = system("nim " . cmd) let output = system('nim ' . cmd)
endif endif
call add(g:nim_log, "nim " . cmd . "\n" . output) call add(g:nim_log, 'nim ' . cmd . "\n" . output)
return output return output
endf endf
@ -139,7 +139,7 @@ fun! NimComplete(findstart, base)
endif endif
if a:findstart if a:findstart
if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment' if synIDattr(synIDtrans(synID(line('.'),col('.'),1)), 'name') == 'Comment'
return -1 return -1
endif endif
let line = getline('.') let line = getline('.')
@ -150,10 +150,10 @@ fun! NimComplete(findstart, base)
return start return start
else else
let result = [] let result = []
let sugOut = NimExec("--suggest") let sugOut = NimExec('--suggest')
for line in split(sugOut, '\n') for line in split(sugOut, '\n')
let lineData = split(line, '\t') let lineData = split(line, '\t')
if len(lineData) > 0 && lineData[0] == "sug" if len(lineData) > 0 && lineData[0] == 'sug'
let word = split(lineData[2], '\.')[-1] let word = split(lineData[2], '\.')[-1]
if a:base ==? '' || word =~# '^' . a:base if a:base ==? '' || word =~# '^' . a:base
let kind = get(g:nim_symbol_types, lineData[1], '') let kind = get(g:nim_symbol_types, lineData[1], '')
@ -166,7 +166,7 @@ fun! NimComplete(findstart, base)
endif endif
endf endf
if !exists("g:neocomplcache_omni_patterns") if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {} let g:neocomplcache_omni_patterns = {}
endif endif
let g:neocomplcache_omni_patterns['nim'] = '[^. *\t]\.\w*' let g:neocomplcache_omni_patterns['nim'] = '[^. *\t]\.\w*'
@ -186,33 +186,33 @@ fun! NimAsyncCmdComplete(cmd, output)
call Callback(a:output) call Callback(a:output)
" remove(g:nim_completion_callbacks, a:cmd) " remove(g:nim_completion_callbacks, a:cmd)
else else
echom "ERROR, Unknown Command: " . a:cmd echom 'ERROR, Unknown Command: ' . a:cmd
endif endif
return 1 return 1
endf endf
fun! GotoDefinition_nim_ready(def_output) fun! GotoDefinition_nim_ready(def_output)
if v:shell_error if v:shell_error
echo "nim was unable to locate the definition. exit code: " . v:shell_error echo 'nim was unable to locate the definition. exit code: ' . v:shell_error
" echoerr a:def_output " echoerr a:def_output
return 0 return 0
endif endif
let rawDef = matchstr(a:def_output, 'def\t\([^\n]*\)') let rawDef = matchstr(a:def_output, 'def\t\([^\n]*\)')
if rawDef == "" if rawDef == ''
echo "the current cursor position does not match any definitions" echo 'the current cursor position does not match any definitions'
return 0 return 0
endif endif
let defBits = split(rawDef, '\t') let defBits = split(rawDef, '\t')
let file = defBits[4] let file = defBits[4]
let line = defBits[5] let line = defBits[5]
exe printf("e +%d %s", line, file) exe printf('e +%d %s', line, file)
return 1 return 1
endf endf
fun! GotoDefinition_nim() fun! GotoDefinition_nim()
call NimExecAsync("--def", function("GotoDefinition_nim_ready")) call NimExecAsync('--def', function('GotoDefinition_nim_ready'))
endf endf
fun! FindReferences_nim() fun! FindReferences_nim()
@ -228,10 +228,10 @@ fun! SyntaxCheckers_nim_nim_GetLocList()
endf endf
function! SyntaxCheckers_nim_nim_IsAvailable() function! SyntaxCheckers_nim_nim_IsAvailable()
return executable("nim") return executable('nim')
endfunction endfunction
if exists("g:SyntasticRegistry") if exists('g:SyntasticRegistry')
call g:SyntasticRegistry.CreateAndRegisterChecker({ call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'nim', \ 'filetype': 'nim',
\ 'name': 'nim'}) \ 'name': 'nim'})

View file

@ -1,10 +1,10 @@
if exists("current_compiler") if exists('current_compiler')
finish finish
endif endif
let current_compiler = "nim" let current_compiler = 'nim'
if exists(":CompilerSet") != 2 " older Vim always used :setlocal if exists(':CompilerSet') != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal <args> command -nargs=* CompilerSet setlocal <args>
endif endif

View file

@ -1,2 +1,4 @@
au BufNewFile,BufRead *.nim,*.nims,*.nimble set filetype=nim augroup nim_vim
au BufNewFile,BufRead *.nim,*.nims,*.nimble set filetype=nim
augroup END

View file

@ -1,4 +1,4 @@
if exists("b:nim_loaded") if exists('b:nim_loaded')
finish finish
endif endif

View file

@ -1,5 +1,5 @@
" Only load this indent file when no other was loaded. " Only load this indent file when no other was loaded.
if exists("b:did_indent") if exists('b:did_indent')
finish finish
endif endif
let b:did_indent = 1 let b:did_indent = 1
@ -12,7 +12,7 @@ setlocal indentexpr=GetNimIndent(v:lnum)
setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif
" Only define the function once. " Only define the function once.
if exists("*GetNimIndent") if exists('*GetNimIndent')
finish finish
endif endif
@ -38,7 +38,7 @@ function! GetNimIndent(lnum)
endif endif
" If the start of the line is in a string don't change the indent. " If the start of the line is in a string don't change the indent.
if has('syntax_items') && synIDattr(synID(a:lnum, 1, 1), "name") =~ "String$" if has('syntax_items') && synIDattr(synID(a:lnum, 1, 1), 'name') =~ 'String$'
return -1 return -1
endif endif
@ -54,12 +54,12 @@ function! GetNimIndent(lnum)
" If the last character in the line is a comment, do a binary search for " If the last character in the line is a comment, do a binary search for
" the start of the comment. synID() is slow, a linear search would take " the start of the comment. synID() is slow, a linear search would take
" too long on a long line. " too long on a long line.
if synIDattr(synID(plnum, pline_len, 1), "name") =~ "Comment$" if synIDattr(synID(plnum, pline_len, 1), 'name') =~ 'Comment$'
let min = 1 let min = 1
let max = pline_len let max = pline_len
while min < max while min < max
let col = (min + max) / 2 let col = (min + max) / 2
if synIDattr(synID(plnum, col, 1), "name") =~ "Comment$" if synIDattr(synID(plnum, col, 1), 'name') =~ 'Comment$'
let max = col let max = col
else else
let min = col + 1 let min = col + 1

View file

@ -2,28 +2,28 @@
" For version 6.x: Quit when a syntax file was already loaded " For version 6.x: Quit when a syntax file was already loaded
if version < 600 if version < 600
syntax clear syntax clear
elseif exists("b:current_syntax") elseif exists('b:current_syntax')
finish finish
endif endif
" Keep user-supplied options " Keep user-supplied options
if !exists("nim_highlight_numbers") if !exists('nim_highlight_numbers')
let nim_highlight_numbers = 1 let nim_highlight_numbers = 1
endif endif
if !exists("nim_highlight_builtins") if !exists('nim_highlight_builtins')
let nim_highlight_builtins = 1 let nim_highlight_builtins = 1
endif endif
if !exists("nim_highlight_exceptions") if !exists('nim_highlight_exceptions')
let nim_highlight_exceptions = 1 let nim_highlight_exceptions = 1
endif endif
if !exists("nim_highlight_space_errors") if !exists('nim_highlight_space_errors')
let nim_highlight_space_errors = 1 let nim_highlight_space_errors = 1
endif endif
if !exists("nim_highlight_special_vars") if !exists('nim_highlight_special_vars')
let nim_highlight_special_vars = 1 let nim_highlight_special_vars = 1
endif endif
if exists("nim_highlight_all") if exists('nim_highlight_all')
let nim_highlight_numbers = 1 let nim_highlight_numbers = 1
let nim_highlight_builtins = 1 let nim_highlight_builtins = 1
let nim_highlight_exceptions = 1 let nim_highlight_exceptions = 1