Rename Nimrod to Nim
This commit is contained in:
parent
aa586b5397
commit
eecfe9b81f
6 changed files with 67 additions and 67 deletions
|
|
@ -1,25 +1,25 @@
|
||||||
let g:nimrod_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:nimrod_caas_enabled")
|
if !exists("g:nim_caas_enabled")
|
||||||
let g:nimrod_caas_enabled = 1
|
let g:nim_caas_enabled = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !executable('nimrod')
|
if !executable('nim')
|
||||||
echoerr "the nimrod compiler must be in your system's PATH"
|
echoerr "the Nim compiler must be in your system's PATH"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
exe 'pyfile ' . fnameescape(s:plugin_path) . '/nimrod_vim.py'
|
exe 'pyfile ' . fnameescape(s:plugin_path) . '/nim_vim.py'
|
||||||
|
|
||||||
fun! nimrod#init()
|
fun! nim#init()
|
||||||
let cmd = printf("nimrod --dump.format:json --verbosity:0 dump %s", s:CurrentNimrodFile())
|
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
|
if !v:shell_error
|
||||||
let dumpdata = eval(substitute(raw_dumpdata, "\n", "", "g"))
|
let dumpdata = eval(substitute(raw_dumpdata, "\n", "", "g"))
|
||||||
|
|
||||||
let b:nimrod_project_root = dumpdata['project_path']
|
let b:nim_project_root = dumpdata['project_path']
|
||||||
let b:nimrod_defined_symbols = dumpdata['defined_symbols']
|
let b:nim_defined_symbols = dumpdata['defined_symbols']
|
||||||
let b:nimrod_caas_enabled = g:nimrod_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
|
||||||
|
|
@ -27,7 +27,7 @@ fun! nimrod#init()
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
else
|
else
|
||||||
let b:nimrod_caas_enabled = 0
|
let b:nim_caas_enabled = 0
|
||||||
endif
|
endif
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
|
@ -36,31 +36,31 @@ fun! s:UpdateNimLog()
|
||||||
setlocal bufhidden=hide
|
setlocal bufhidden=hide
|
||||||
setlocal noswapfile
|
setlocal noswapfile
|
||||||
|
|
||||||
for entry in g:nimrod_log
|
for entry in g:nim_log
|
||||||
call append(line('$'), split(entry, "\n"))
|
call append(line('$'), split(entry, "\n"))
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
let g:nimrod_log = []
|
let g:nim_log = []
|
||||||
|
|
||||||
match Search /^nimrod\ .*/
|
match Search /^nim\ .*/
|
||||||
endf
|
endf
|
||||||
|
|
||||||
augroup NimrodVim
|
augroup NimVim
|
||||||
au!
|
au!
|
||||||
au BufEnter log://nimrod call s:UpdateNimLog()
|
au BufEnter log://nim call s:UpdateNimLog()
|
||||||
" au QuitPre * :py nimTerminateAll()
|
" au QuitPre * :py nimTerminateAll()
|
||||||
au VimLeavePre * :py nimTerminateAll()
|
au VimLeavePre * :py nimTerminateAll()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
command! NimLog :e log://nimrod
|
command! NimLog :e log://nim
|
||||||
|
|
||||||
command! NimTerminateService
|
command! NimTerminateService
|
||||||
\ :exe printf("py nimTerminateService('%s')", b:nimrod_project_root)
|
\ :exe printf("py nimTerminateService('%s')", b:nim_project_root)
|
||||||
|
|
||||||
command! NimRestartService
|
command! NimRestartService
|
||||||
\ :exe printf("py nimRestartService('%s')", b:nimrod_project_root)
|
\ :exe printf("py nimRestartService('%s')", b:nim_project_root)
|
||||||
|
|
||||||
fun! s:CurrentNimrodFile()
|
fun! s:CurrentNimFile()
|
||||||
let save_cur = getpos('.')
|
let save_cur = getpos('.')
|
||||||
call cursor(0, 0, 0)
|
call cursor(0, 0, 0)
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ fun! s:CurrentNimrodFile()
|
||||||
return l:to_check
|
return l:to_check
|
||||||
endf
|
endf
|
||||||
|
|
||||||
let g:nimrod_symbol_types = {
|
let g:nim_symbol_types = {
|
||||||
\ 'skParam': 'v',
|
\ 'skParam': 'v',
|
||||||
\ 'skVar': 'v',
|
\ 'skVar': 'v',
|
||||||
\ 'skLet': 'v',
|
\ 'skLet': 'v',
|
||||||
|
|
@ -105,20 +105,20 @@ fun! NimExec(op)
|
||||||
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:CurrentNimrodFile())
|
\ 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:CurrentNimrodFile())
|
\ a:op, expand('%:p'), line('.'), col('.')-1, s:CurrentNimFile())
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if b:nimrod_caas_enabled
|
if b:nim_caas_enabled
|
||||||
exe printf("py nimExecCmd('%s', '%s', False)", b:nimrod_project_root, cmd)
|
exe printf("py nimExecCmd('%s', '%s', False)", b:nim_project_root, cmd)
|
||||||
let output = l:py_res
|
let output = l:py_res
|
||||||
else
|
else
|
||||||
let output = system("nimrod " . cmd)
|
let output = system("nim " . cmd)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call add(g:nimrod_log, "nimrod " . cmd . "\n" . output)
|
call add(g:nim_log, "nim " . cmd . "\n" . output)
|
||||||
return output
|
return output
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
|
@ -128,7 +128,7 @@ fun! NimExecAsync(op, Handler)
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fun! NimComplete(findstart, base)
|
fun! NimComplete(findstart, base)
|
||||||
if b:nimrod_caas_enabled == 0
|
if b:nim_caas_enabled == 0
|
||||||
return -1
|
return -1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -143,7 +143,7 @@ fun! NimComplete(findstart, base)
|
||||||
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 kind = get(g:nimrod_symbol_types, lineData[1], '')
|
let kind = get(g:nim_symbol_types, lineData[1], '')
|
||||||
let c = { 'word': lineData[2], 'kind': kind, 'menu': lineData[3], 'dup': 1 }
|
let c = { 'word': lineData[2], 'kind': kind, 'menu': lineData[3], 'dup': 1 }
|
||||||
call add(result, c)
|
call add(result, c)
|
||||||
endif
|
endif
|
||||||
|
|
@ -156,25 +156,25 @@ if !exists("g:neocomplcache_omni_patterns")
|
||||||
let g:neocomplcache_omni_patterns = {}
|
let g:neocomplcache_omni_patterns = {}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*'
|
let g:neocomplcache_omni_patterns['nim'] = '[^. *\t]\.\w*'
|
||||||
let g:nimrod_completion_callbacks = {}
|
let g:nim_completion_callbacks = {}
|
||||||
|
|
||||||
fun! NimrodAsyncCmdComplete(cmd, output)
|
fun! NimAsyncCmdComplete(cmd, output)
|
||||||
call add(g:nimrod_log, a:output)
|
call add(g:nim_log, a:output)
|
||||||
echom g:nimrod_completion_callbacks
|
echom g:nim_completion_callbacks
|
||||||
if has_key(g:nimrod_completion_callbacks, a:cmd)
|
if has_key(g:nim_completion_callbacks, a:cmd)
|
||||||
let Callback = get(g:nimrod_completion_callbacks, a:cmd)
|
let Callback = get(g:nim_completion_callbacks, a:cmd)
|
||||||
call Callback(a:output)
|
call Callback(a:output)
|
||||||
" remove(g:nimrod_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_nimrod_ready(def_output)
|
fun! GotoDefinition_nim_ready(def_output)
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
echo "nimrod 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
|
||||||
|
|
@ -192,37 +192,37 @@ fun! GotoDefinition_nimrod_ready(def_output)
|
||||||
return 1
|
return 1
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fun! GotoDefinition_nimrod()
|
fun! GotoDefinition_nim()
|
||||||
call NimExecAsync("--def", function("GotoDefinition_nimrod_ready"))
|
call NimExecAsync("--def", function("GotoDefinition_nim_ready"))
|
||||||
endf
|
endf
|
||||||
|
|
||||||
fun! FindReferences_nimrod()
|
fun! FindReferences_nim()
|
||||||
setloclist()
|
setloclist()
|
||||||
endf
|
endf
|
||||||
|
|
||||||
" Syntastic syntax checking
|
" Syntastic syntax checking
|
||||||
fun! SyntaxCheckers_nimrod_nimrod_GetLocList()
|
fun! SyntaxCheckers_nim_nim_GetLocList()
|
||||||
let makeprg = 'nimrod check --hints:off ' . s:CurrentNimrodFile()
|
let makeprg = 'nim check --hints:off ' . s:CurrentNimFile()
|
||||||
let errorformat = &errorformat
|
let errorformat = &errorformat
|
||||||
|
|
||||||
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
||||||
endf
|
endf
|
||||||
|
|
||||||
function! SyntaxCheckers_nimrod_nimrod_IsAvailable()
|
function! SyntaxCheckers_nim_nim_IsAvailable()
|
||||||
return executable("nimrod")
|
return executable("nim")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
if exists("g:SyntasticRegistry")
|
if exists("g:SyntasticRegistry")
|
||||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||||
\ 'filetype': 'nimrod',
|
\ 'filetype': 'nim',
|
||||||
\ 'name': 'nimrod'})
|
\ 'name': 'nim'})
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !exists("g:quickrun_config")
|
if !exists("g:quickrun_config")
|
||||||
let g:quickrun_config = {}
|
let g:quickrun_config = {}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !exists("g:quickrun_config.nimrod")
|
if !exists("g:quickrun_config.nim")
|
||||||
let g:quickrun_config.nimrod = { "exec": "nimrod c --run --verbosity:0 %S" }
|
let g:quickrun_config.nim = { "exec": "nim c --run --verbosity:0 %S" }
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@ except ImportError:
|
||||||
|
|
||||||
vim = Vim()
|
vim = Vim()
|
||||||
|
|
||||||
class NimrodThread(threading.Thread):
|
class NimThread(threading.Thread):
|
||||||
def __init__(self, project_path):
|
def __init__(self, project_path):
|
||||||
super(NimrodThread, self).__init__()
|
super(NimThread, self).__init__()
|
||||||
self.tasks = Queue.Queue()
|
self.tasks = Queue.Queue()
|
||||||
self.responses = Queue.Queue()
|
self.responses = Queue.Queue()
|
||||||
self.nim = subprocess.Popen(
|
self.nim = subprocess.Popen(
|
||||||
["nimrod", "serve", "--server.type:stdin", project_path],
|
["nim", "serve", "--server.type:stdin", project_path],
|
||||||
cwd = os.path.dirname(project_path),
|
cwd = os.path.dirname(project_path),
|
||||||
stdin = subprocess.PIPE,
|
stdin = subprocess.PIPE,
|
||||||
stdout = subprocess.PIPE,
|
stdout = subprocess.PIPE,
|
||||||
|
|
@ -53,15 +53,15 @@ class NimrodThread(threading.Thread):
|
||||||
def nimVimEscape(expr):
|
def nimVimEscape(expr):
|
||||||
return expr.replace("\\", "\\\\").replace('"', "\\\"").replace("\n", "\\n")
|
return expr.replace("\\", "\\\\").replace('"', "\\\"").replace("\n", "\\n")
|
||||||
|
|
||||||
class NimrodVimThread(NimrodThread):
|
class NimVimThread(NimThread):
|
||||||
def asyncOpComplete(self, msg, result):
|
def asyncOpComplete(self, msg, result):
|
||||||
cmd = "/usr/local/bin/mvim --remote-expr 'NimrodAsyncCmdComplete(1, \"" + nimVimEscape(result) + "\")'"
|
cmd = "/usr/local/bin/mvim --remote-expr 'NimAsyncCmdComplete(1, \"" + nimVimEscape(result) + "\")'"
|
||||||
os.system (cmd)
|
os.system (cmd)
|
||||||
|
|
||||||
NimProjects = {}
|
NimProjects = {}
|
||||||
|
|
||||||
def nimStartService(project):
|
def nimStartService(project):
|
||||||
target = NimrodVimThread(project)
|
target = NimVimThread(project)
|
||||||
NimProjects[project] = target
|
NimProjects[project] = target
|
||||||
target.start()
|
target.start()
|
||||||
return target
|
return target
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ if exists("current_compiler")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let current_compiler = "nimrod"
|
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>
|
||||||
|
|
@ -11,7 +11,7 @@ endif
|
||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo-=C
|
set cpo-=C
|
||||||
|
|
||||||
CompilerSet makeprg=nimrod\ c\ $*
|
CompilerSet makeprg=nim\ c\ $*
|
||||||
|
|
||||||
CompilerSet errorformat=
|
CompilerSet errorformat=
|
||||||
\%-GHint:\ %m,
|
\%-GHint:\ %m,
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
au BufNewFile,BufRead *.nim set filetype=nimrod
|
au BufNewFile,BufRead *.nim set filetype=nim
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
if exists("b:nimrod_loaded")
|
if exists("b:nim_loaded")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let b:nimrod_loaded = 1
|
let b:nim_loaded = 1
|
||||||
|
|
||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
call nimrod#init()
|
call nim#init()
|
||||||
|
|
||||||
setlocal formatoptions-=t formatoptions+=croql
|
setlocal formatoptions-=t formatoptions+=croql
|
||||||
setlocal comments=:##,:#
|
setlocal comments=:##,:#
|
||||||
|
|
@ -16,7 +16,7 @@ setlocal omnifunc=NimComplete
|
||||||
setlocal suffixesadd=.nim
|
setlocal suffixesadd=.nim
|
||||||
setlocal expandtab "Make sure that only spaces are used
|
setlocal expandtab "Make sure that only spaces are used
|
||||||
|
|
||||||
compiler nimrod
|
compiler nim
|
||||||
|
|
||||||
let &cpo = s:cpo_save
|
let &cpo = s:cpo_save
|
||||||
unlet s:cpo_save
|
unlet s:cpo_save
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@ let b:did_indent = 1
|
||||||
setlocal nolisp " Make sure lisp indenting doesn't supersede us
|
setlocal nolisp " Make sure lisp indenting doesn't supersede us
|
||||||
setlocal autoindent " indentexpr isn't much help otherwise
|
setlocal autoindent " indentexpr isn't much help otherwise
|
||||||
|
|
||||||
setlocal indentexpr=GetNimrodIndent(v:lnum)
|
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("*GetNimrodIndent")
|
if exists("*GetNimIndent")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ function! s:FindStartLine(fromln, pattern)
|
||||||
return indent(lnum)
|
return indent(lnum)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! GetNimrodIndent(lnum)
|
function! GetNimIndent(lnum)
|
||||||
" Search backwards for the previous non-empty line.
|
" Search backwards for the previous non-empty line.
|
||||||
let plnum = prevnonblank(a:lnum - 1)
|
let plnum = prevnonblank(a:lnum - 1)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue