mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-09 20:13:51 -05:00
Make sure custom scripts.vim are respected as well
This commit is contained in:
@@ -578,6 +578,10 @@ function! go#config#DiagnosticsEnabled() abort
|
|||||||
return get(g:, 'go_diagnostics_enabled', 0)
|
return get(g:, 'go_diagnostics_enabled', 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! go#config#DiagnosticsIgnoreWarnings() abort
|
||||||
|
return get(g:, 'go_diagnostics_ignore_warnings', 0)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! go#config#GoplsOptions() abort
|
function! go#config#GoplsOptions() abort
|
||||||
return get(g:, 'go_gopls_options', ['-remote=auto'])
|
return get(g:, 'go_gopls_options', ['-remote=auto'])
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
106
autoload/nim.vim
106
autoload/nim.vim
@@ -3,7 +3,7 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nim') == -1
|
|||||||
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
|
||||||
|
|
||||||
@@ -11,27 +11,25 @@ if !executable('nim')
|
|||||||
echoerr "the Nim compiler must be in your system's PATH"
|
echoerr "the Nim compiler must be in your system's PATH"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has("python3")
|
if has('pythonx')
|
||||||
exe 'py3file ' . fnameescape(s:plugin_path) . '/nim_vim.py'
|
exe 'pyxfile ' . fnameescape(s:plugin_path) . '/nim_vim.py'
|
||||||
elseif has("python")
|
|
||||||
exe 'pyfile ' . fnameescape(s:plugin_path) . '/nim_vim.py'
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
fun! nim#init()
|
fun! nim#init() abort
|
||||||
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']
|
||||||
let b:nim_caas_enabled = g:nim_caas_enabled || index(dumpdata['defined_symbols'], 'forcecaas') != -1
|
let b:nim_caas_enabled = g:nim_caas_enabled || index(dumpdata['defined_symbols'], 'forcecaas') != -1
|
||||||
|
|
||||||
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
|
||||||
@@ -39,7 +37,7 @@ fun! nim#init()
|
|||||||
endif
|
endif
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fun! s:UpdateNimLog()
|
fun! s:UpdateNimLog() abort
|
||||||
setlocal buftype=nofile
|
setlocal buftype=nofile
|
||||||
setlocal bufhidden=hide
|
setlocal bufhidden=hide
|
||||||
setlocal noswapfile
|
setlocal noswapfile
|
||||||
@@ -56,32 +54,32 @@ endf
|
|||||||
augroup NimVim
|
augroup NimVim
|
||||||
au!
|
au!
|
||||||
au BufEnter log://nim call s:UpdateNimLog()
|
au BufEnter log://nim call s:UpdateNimLog()
|
||||||
if has("python3") || has("python")
|
if has('pythonx')
|
||||||
" au QuitPre * :py nimTerminateAll()
|
" au QuitPre * :pyx nimTerminateAll()
|
||||||
au VimLeavePre * :py nimTerminateAll()
|
au VimLeavePre * :pyx nimTerminateAll()
|
||||||
endif
|
endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
command! NimLog :e log://nim
|
command! NimLog :e log://nim
|
||||||
|
|
||||||
command! NimTerminateService
|
command! NimTerminateService
|
||||||
\ :exe printf("py nimTerminateService('%s')", b:nim_project_root)
|
\ :exe printf("pyx nimTerminateService('%s')", b:nim_project_root)
|
||||||
|
|
||||||
command! NimRestartService
|
command! NimRestartService
|
||||||
\ :exe printf("py nimRestartService('%s')", b:nim_project_root)
|
\ :exe printf("pyx nimRestartService('%s')", b:nim_project_root)
|
||||||
|
|
||||||
fun! s:CurrentNimFile()
|
fun! s:CurrentNimFile() abort
|
||||||
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)
|
||||||
@@ -108,42 +106,42 @@ let g:nim_symbol_types = {
|
|||||||
\ 'skEnumField': 'v',
|
\ 'skEnumField': 'v',
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
fun! NimExec(op)
|
fun! NimExec(op) abort
|
||||||
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
|
||||||
|
|
||||||
if b:nim_caas_enabled
|
if b:nim_caas_enabled
|
||||||
exe printf("py 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 = get(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
|
||||||
|
|
||||||
fun! NimExecAsync(op, Handler)
|
fun! NimExecAsync(op, Handler) abort
|
||||||
let result = NimExec(a:op)
|
let result = NimExec(a:op)
|
||||||
call a:Handler(result)
|
call a:Handler(result)
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fun! NimComplete(findstart, base)
|
fun! NimComplete(findstart, base) abort
|
||||||
if b:nim_caas_enabled == 0
|
if b:nim_caas_enabled ==# 0
|
||||||
return -1
|
return -1
|
||||||
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('.')
|
||||||
@@ -154,10 +152,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], '')
|
||||||
@@ -170,7 +168,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*'
|
||||||
@@ -182,7 +180,7 @@ let g:neocomplete#sources#omni#input_patterns['nim'] = '[^. *\t]\.\w*'
|
|||||||
|
|
||||||
let g:nim_completion_callbacks = {}
|
let g:nim_completion_callbacks = {}
|
||||||
|
|
||||||
fun! NimAsyncCmdComplete(cmd, output)
|
fun! NimAsyncCmdComplete(cmd, output) abort
|
||||||
call add(g:nim_log, a:output)
|
call add(g:nim_log, a:output)
|
||||||
echom g:nim_completion_callbacks
|
echom g:nim_completion_callbacks
|
||||||
if has_key(g:nim_completion_callbacks, a:cmd)
|
if has_key(g:nim_completion_callbacks, a:cmd)
|
||||||
@@ -190,52 +188,52 @@ 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) abort
|
||||||
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() abort
|
||||||
call NimExecAsync("--def", function("GotoDefinition_nim_ready"))
|
call NimExecAsync('--def', function('GotoDefinition_nim_ready'))
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fun! FindReferences_nim()
|
fun! FindReferences_nim() abort
|
||||||
setloclist()
|
"setloclist()
|
||||||
endf
|
endf
|
||||||
|
|
||||||
" Syntastic syntax checking
|
" Syntastic syntax checking
|
||||||
fun! SyntaxCheckers_nim_nim_GetLocList()
|
fun! SyntaxCheckers_nim_nim_GetLocList() abort
|
||||||
let makeprg = 'nim check --hints:off --listfullpaths ' . s:CurrentNimFile()
|
let makeprg = 'nim check --hints:off --listfullpaths ' . s:CurrentNimFile()
|
||||||
let errorformat = &errorformat
|
let errorformat = &errorformat
|
||||||
|
|
||||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||||
endf
|
endf
|
||||||
|
|
||||||
function! SyntaxCheckers_nim_nim_IsAvailable()
|
function! SyntaxCheckers_nim_nim_IsAvailable() abort
|
||||||
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'})
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nim') == -1
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nim') == -1
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
@@ -1941,6 +1941,14 @@ By default it is disabled.
|
|||||||
>
|
>
|
||||||
let g:go_diagnostics_enabled = 0
|
let g:go_diagnostics_enabled = 0
|
||||||
<
|
<
|
||||||
|
*'g:go_diagnostics_ignore_warnings'*
|
||||||
|
|
||||||
|
Specifies whether warnings from `gopls` diagnostics are ignored.
|
||||||
|
|
||||||
|
By default it is disabled.
|
||||||
|
>
|
||||||
|
let g:go_diagnostics_ignore_warnings = 0
|
||||||
|
<
|
||||||
|
|
||||||
*'g:go_template_autocreate'*
|
*'g:go_template_autocreate'*
|
||||||
|
|
||||||
|
|||||||
2257
extras/filetype.vim
Normal file
2257
extras/filetype.vim
Normal file
File diff suppressed because it is too large
Load Diff
1
filetype.vim
Normal file
1
filetype.vim
Normal file
@@ -0,0 +1 @@
|
|||||||
|
runtime! ftdetect/polyglot.vim
|
||||||
@@ -3431,7 +3431,7 @@ augroup END
|
|||||||
" detected filetypes.
|
" detected filetypes.
|
||||||
if exists("did_load_filetypes") && exists("g:polyglot_disabled")
|
if exists("did_load_filetypes") && exists("g:polyglot_disabled")
|
||||||
unlet did_load_filetypes
|
unlet did_load_filetypes
|
||||||
runtime! $VIMRUNTIME/filetype.vim
|
runtime! extras/filetype.vim
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Restore 'cpoptions'
|
" Restore 'cpoptions'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nim') == -1
|
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nim') == -1
|
||||||
|
|
||||||
" 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
|
||||||
@@ -14,7 +14,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
|
||||||
|
|
||||||
@@ -40,7 +40,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
|
||||||
|
|
||||||
@@ -56,12 +56,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
|
||||||
@@ -80,16 +80,16 @@ function! GetNimIndent(lnum)
|
|||||||
endwhile
|
endwhile
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if cline =~ '^\s*\(if\|when\|for\|while\|case\|of\|try\)\>'
|
if cline =~# '^\s*\(if\|when\|for\|while\|case\|of\|try\)\>'
|
||||||
" This is a benign line, do nothing
|
" This is a benign line, do nothing
|
||||||
return -1
|
return -1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" If the current line begins with a keyword that lines up with "try"
|
" If the current line begins with a keyword that lines up with "try"
|
||||||
if cline =~ '^\s*\(except\|finally\)\>'
|
if cline =~# '^\s*\(except\|finally\)\>'
|
||||||
let lnum = a:lnum - 1
|
let lnum = a:lnum - 1
|
||||||
while lnum >= 1
|
while lnum >= 1
|
||||||
if getline(lnum) =~ '^\s*\(try\|except\)\>'
|
if getline(lnum) =~# '^\s*\(try\|except\)\>'
|
||||||
let ind = indent(lnum)
|
let ind = indent(lnum)
|
||||||
if ind >= clindent
|
if ind >= clindent
|
||||||
return -1 " indent is already less than this
|
return -1 " indent is already less than this
|
||||||
@@ -102,31 +102,31 @@ function! GetNimIndent(lnum)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" If the current line begins with a header keyword, dedent
|
" If the current line begins with a header keyword, dedent
|
||||||
if cline =~ '^\s*\(elif\|else\)\>'
|
if cline =~# '^\s*\(elif\|else\)\>'
|
||||||
return s:FindStartLine(a:lnum, '^\s*\(if\|when\|elif\|of\)')
|
return s:FindStartLine(a:lnum, '^\s*\(if\|when\|elif\|of\)')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if pline =~ ':\s*$'
|
if pline =~# ':\s*$'
|
||||||
"return s:FindStartLine(plnum, '(^\s*\(if\|when\|else\|elif\|case\|of\|try\|except\|finally\)\>)\|\<do\>') + &sw
|
"return s:FindStartLine(plnum, '(^\s*\(if\|when\|else\|elif\|case\|of\|try\|except\|finally\)\>)\|\<do\>') + &sw
|
||||||
return s:FindStartLine(plnum, '^\s*\(if\|when\|else\|elif\|for\|while\|case\|of\|try\|except\|finally\)\>') + &sw
|
return s:FindStartLine(plnum, '^\s*\(if\|when\|else\|elif\|for\|while\|case\|of\|try\|except\|finally\)\>') + &sw
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if pline =~ '=\s*$'
|
if pline =~# '=\s*$'
|
||||||
return s:FindStartLine(plnum, '^\s*\(proc\|template\|macro\|iterator\)\>') + &sw
|
return s:FindStartLine(plnum, '^\s*\(proc\|template\|macro\|iterator\)\>') + &sw
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" if we got here, this should be the begging of a multi-line if expression for example
|
" if we got here, this should be the begging of a multi-line if expression for example
|
||||||
if pline =~ '^\s*\(if\|when\|proc\|iterator\|macro\|template\|for\|while\)[^:]*$'
|
if pline =~# '^\s*\(if\|when\|proc\|iterator\|macro\|template\|for\|while\)[^:]*$'
|
||||||
return plindent + &sw
|
return plindent + &sw
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if pline =~ '\(type\|import\|const\|var\|let\)\s*$'
|
if pline =~# '\(type\|import\|const\|var\|let\)\s*$'
|
||||||
\ || pline =~ '=\s*\(object\|enum\|tuple\|concept\)'
|
\ || pline =~# '=\s*\(object\|enum\|tuple\|concept\)'
|
||||||
return plindent + &sw
|
return plindent + &sw
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" If the previous line was a stop-execution statement...
|
" If the previous line was a stop-execution statement...
|
||||||
if pline =~ '^\s*\(break\|continue\|raise\|return\)\>'
|
if pline =~# '^\s*\(break\|continue\|raise\|return\)\>'
|
||||||
" See if the user has already dedented
|
" See if the user has already dedented
|
||||||
if indent(a:lnum) > plindent - &sw
|
if indent(a:lnum) > plindent - &sw
|
||||||
" If not, recommend one dedent
|
" If not, recommend one dedent
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
if !exists("did_load_polyglot")
|
" Turn on filetype plugins (:help filetype-plugin).
|
||||||
|
if has('autocmd') && !(exists("did_load_filetypes") && exists("did_indent_on"))
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Enable syntax highlighting.
|
||||||
|
if has('syntax') && !exists('g:syntax_on')
|
||||||
|
syntax enable
|
||||||
|
endif
|
||||||
|
|||||||
@@ -257,9 +257,8 @@ def parse_remote(remote)
|
|||||||
[match[:repo], match[:branch] || "master", match[:path], dir]
|
[match[:repo], match[:branch] || "master", match[:path], dir]
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_file(package, src, dest)
|
def copy_file(name, src, dest)
|
||||||
FileUtils.mkdir_p(File.dirname(dest))
|
FileUtils.mkdir_p(File.dirname(dest))
|
||||||
name = package.fetch("name")
|
|
||||||
|
|
||||||
if dest.end_with?(".vim")
|
if dest.end_with?(".vim")
|
||||||
header = '" Polyglot metafile'
|
header = '" Polyglot metafile'
|
||||||
@@ -509,11 +508,11 @@ def extract(packages)
|
|||||||
globs.each do |glob|
|
globs.each do |glob|
|
||||||
Dir.glob("#{subdir}/#{glob}", base: subtree).each do |p|
|
Dir.glob("#{subdir}/#{glob}", base: subtree).each do |p|
|
||||||
next unless File.file?("#{subtree}#{p}")
|
next unless File.file?("#{subtree}#{p}")
|
||||||
copy_file(package, "#{subtree}#{p}", p)
|
copy_file(package["name"], "#{subtree}#{p}", p)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elsif File.exist?(subpath)
|
elsif File.exist?(subpath)
|
||||||
copy_file(package, subpath, subdir)
|
copy_file(package["name"], subpath, subdir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -889,6 +888,19 @@ def show_warnings(all_filetypes, expected_filetypes)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def generate_fallback
|
||||||
|
filetype_content = File.read('tmp/vim/vim/runtime/filetype.vim')
|
||||||
|
filetype_content.gsub!('runtime! ftdetect/*.vim', '')
|
||||||
|
filetype_content.gsub!(/^au BufNewFile,BufRead \*\n.+?runtime!.+?endif/m) {}
|
||||||
|
filetype_content.gsub!(/^au StdinReadPost \* .+?runtime!.+?endif/m) {}
|
||||||
|
filetype_content.gsub!(/^au filetypedetect BufNewFile,BufRead,StdinReadPost \*\n.+?endif/m) {}
|
||||||
|
File.write('extras/filetype.vim', filetype_content)
|
||||||
|
|
||||||
|
autoload_content = File.read('tmp/vim/vim/runtime/autoload/dist/ft.vim')
|
||||||
|
autoload_content.gsub!('dist#ft#', 'polyglot#ft#')
|
||||||
|
File.write('autoload/polyglot/ft.vim', autoload_content)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
if __FILE__ == $0
|
if __FILE__ == $0
|
||||||
if !ENV["DEV"]
|
if !ENV["DEV"]
|
||||||
@@ -900,6 +912,7 @@ if __FILE__ == $0
|
|||||||
packages, heuristics = load_data()
|
packages, heuristics = load_data()
|
||||||
download(packages)
|
download(packages)
|
||||||
extract(packages)
|
extract(packages)
|
||||||
|
generate_fallback()
|
||||||
generate_ftdetect(packages, heuristics)
|
generate_ftdetect(packages, heuristics)
|
||||||
generate_plugins(packages)
|
generate_plugins(packages)
|
||||||
generate_tests(packages)
|
generate_tests(packages)
|
||||||
|
|||||||
@@ -2,30 +2,30 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'nim') == -1
|
|||||||
|
|
||||||
" For version 5.x: Clear all syntax items
|
" For version 5.x: Clear all syntax items
|
||||||
" 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 v: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
|
||||||
@@ -158,8 +158,8 @@ syn sync match nimSync grouphere NONE "):$"
|
|||||||
syn sync maxlines=200
|
syn sync maxlines=200
|
||||||
syn sync minlines=2000
|
syn sync minlines=2000
|
||||||
|
|
||||||
if version >= 508 || !exists("did_nim_syn_inits")
|
if v:version >= 508 || !exists('did_nim_syn_inits')
|
||||||
if version <= 508
|
if v:version <= 508
|
||||||
let did_nim_syn_inits = 1
|
let did_nim_syn_inits = 1
|
||||||
command -nargs=+ HiLink hi link <args>
|
command -nargs=+ HiLink hi link <args>
|
||||||
else
|
else
|
||||||
@@ -202,7 +202,7 @@ if version >= 508 || !exists("did_nim_syn_inits")
|
|||||||
delcommand HiLink
|
delcommand HiLink
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let b:current_syntax = "nim"
|
let b:current_syntax = 'nim'
|
||||||
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user