diff --git a/autoload/features/debugger.vim b/autoload/features/debugger.vim index 6a19ecb..9908044 100644 --- a/autoload/features/debugger.vim +++ b/autoload/features/debugger.vim @@ -12,7 +12,6 @@ let s:NimDebugger = { function! s:NimDebugger.on_stdout(job, chunk) for line in a:chunk - echom line " *** endb| reached edb.nim(4) wat *** " let matched = matchlist(line, "\\*\\*\\* endb\|\(.*\)$") let matched = matchlist(line, "") diff --git a/autoload/features/definition.vim b/autoload/features/definition.vim index c7a36d2..8b98775 100644 --- a/autoload/features/definition.vim +++ b/autoload/features/definition.vim @@ -14,7 +14,7 @@ endfunction function! features#definition#run() - call suggest#New("def", 0, 0, s:DefinitionImpl) + call suggest#New("def", !g:nvim_nim_enable_async, 0, s:DefinitionImpl) endfunction diff --git a/autoload/features/info.vim b/autoload/features/info.vim index 9bea09a..f042543 100644 --- a/autoload/features/info.vim +++ b/autoload/features/info.vim @@ -53,13 +53,13 @@ function! features#info#web() if modules#isGlobalImport(current_word) call util#open_module_doc(current_word, "") else - call suggest#New("def", 0, 0, s:New(1)) + call suggest#New("def", !g:nvim_nim_enable_async, 0, s:New(1)) endif endfunction function! features#info#run() - call suggest#New("def", 0, 0, s:New(0)) + call suggest#New("def", !g:nvim_nim_enable_async, 0, s:New(0)) endfunction diff --git a/autoload/features/outline.vim b/autoload/features/outline.vim index af1fbf6..1df82e0 100644 --- a/autoload/features/outline.vim +++ b/autoload/features/outline.vim @@ -250,7 +250,7 @@ function! features#outline#run(isUpdating) if !a:isUpdating || s:IsOpen() " if s:BufferModified() let s:current_buffer = winnr() - call suggest#New("outline", 0, 1, s:OutlineImpl) + call suggest#New("outline", !g:nvim_nim_enable_async, 1, s:OutlineImpl) " else " call s:OutlineImpl.run(s:OutlineImpl.cache) " endif diff --git a/autoload/features/rename.vim b/autoload/features/rename.vim index 39d857f..ab94a8f 100644 --- a/autoload/features/rename.vim +++ b/autoload/features/rename.vim @@ -34,7 +34,7 @@ endfunction function! features#rename#run(inProject) let s:findInProject = a:inProject - call suggest#New("use", 0, 1, s:RenameImpl) + call suggest#New("use", !g:nvim_nim_enable_async, 1, s:RenameImpl) endfunction diff --git a/autoload/features/usages.vim b/autoload/features/usages.vim index 4278b78..65768e8 100644 --- a/autoload/features/usages.vim +++ b/autoload/features/usages.vim @@ -46,14 +46,14 @@ endfunction let s:UsagesDefinitionImpl = {} function! s:UsagesDefinitionImpl.run(data) - call suggest#NewKnown("use", 0, 1, a:data.file, a:data.line, a:data.col, s:UsagesImpl) + call suggest#NewKnown("use", !g:nvim_nim_enable_async, 1, a:data.file, a:data.line, a:data.col, s:UsagesImpl) endfunction function! features#usages#run(findInProject) cclose call setqflist([]) let s:findInProject = a:findInProject - call suggest#New("def", 0, 1, s:UsagesDefinitionImpl) + call suggest#New("def", !g:nvim_nim_enable_async, 1, s:UsagesDefinitionImpl) endfunction diff --git a/autoload/highlighter.vim b/autoload/highlighter.vim index 2e83fc5..7083481 100644 --- a/autoload/highlighter.vim +++ b/autoload/highlighter.vim @@ -111,8 +111,8 @@ function highlighter#New() let result.file = expand("%:p") let result.tempfile = util#WriteMemfile() let result.job = jobstart([g:nvim_nim_exec_nimsuggest, '--v2', '--stdin', result.file], result) - - call jobsend(result.job, "highlight " . result.file . ";" . result.tempfile . ":1:1\nquit\n") + let cmd = "highlight " . result.file . ";" . result.tempfile . ":1:1\nquit\n" + call jobsend(result.job, cmd) if !exists("b:highlights") let b:highlights = [] diff --git a/autoload/omni.vim b/autoload/omni.vim index c4484b6..ed8a75f 100644 --- a/autoload/omni.vim +++ b/autoload/omni.vim @@ -23,13 +23,14 @@ function! omni#item_module(name, file, type) \ } endfunction +" TODO: Refactor combine (1) function! omni#nimsuggest(file, l, c) let completions = [] let tempfile = util#WriteMemfile() let query = "sug " . a:file . ";" . tempfile . ":" . a:l . ":" . a:c let jobcmdstr = g:nvim_nim_exec_nimsuggest . " --threads:on --colors:off --compileOnly --experimental --v2 --stdin " . a:file - let fullcmd = 'echo -e ' . shellescape(query, 1) . '|' . jobcmdstr + let fullcmd = 'echo -e "' . query . '"|' . jobcmdstr let completions_raw = util#FilterCompletions(split(system(fullcmd), "\n")) for line in completions_raw diff --git a/autoload/suggest.vim b/autoload/suggest.vim index 6dd97c7..c1e6e6c 100644 --- a/autoload/suggest.vim +++ b/autoload/suggest.vim @@ -36,6 +36,7 @@ function! suggest#CreateJob(useV2, file, callbacks) endfunction +" TODO: Refactor combine (1) function! suggest#NewKnown(command, sync, useV2, file, line, col, handler) let result = copy(s:NimSuggest) let result.lines = [] @@ -49,7 +50,7 @@ function! suggest#NewKnown(command, sync, useV2, file, line, col, handler) if !result.isAsync let jobcmdstr = g:nvim_nim_exec_nimsuggest . " " . (a:useV2 ? '--v2' : '') . " " . '--stdin' . " " . result.file - let fullcmd = 'echo -e ' . shellescape(query, 1) . '|' . jobcmdstr + let fullcmd = 'echo -e "' . query . '"|' . jobcmdstr let result.lines = util#FilterCompletions(split(system(fullcmd), "\n")) if len(result.lines) > 0 call a:handler.run(result) diff --git a/autoload/util.vim b/autoload/util.vim index a44445e..f9bbdd7 100644 --- a/autoload/util.vim +++ b/autoload/util.vim @@ -75,7 +75,7 @@ endfunction function! util#JumpToLocation(file, line, col) if expand("%:p") != a:file - execute ":e " . a:file + execute ":e! " . a:file endif execute ":" . a:line execute ":norm " . (a:col) . "|" @@ -298,7 +298,6 @@ try let start_line = start[1] let stop_line = stop[1] let str = join(getline(start_line, stop_line), "\n") - echom str call features#repl#send(str) endfunction catch diff --git a/other/rc.vim b/other/rc.vim index cfd44f4..dac6f32 100644 --- a/other/rc.vim +++ b/other/rc.vim @@ -5,3 +5,5 @@ filetype plugin indent on syntax enable set ts=4 sts=4 sw=4 + +let g:nvim_nim_enable_async = 0 diff --git a/other/tests/vim/definition.vader b/other/tests/vim/definition.vader new file mode 100644 index 0000000..dea5317 --- /dev/null +++ b/other/tests/vim/definition.vader @@ -0,0 +1,15 @@ +Given nim: + proc other = "foobar".echo + proc hello = "hello".echo + + hello() + +Execute: + set buftype="" + saveas! vader_workbench.nim + w! + norm G^ + NimDefinition + +Then: + AssertEqual 2, line(".") diff --git a/other/tests/vim/smoke.vader b/other/tests/vim/smoke.vader index 01ade70..2013f4e 100644 --- a/other/tests/vim/smoke.vader +++ b/other/tests/vim/smoke.vader @@ -18,14 +18,6 @@ Then: Assert exists(":NimOutline") > 0 Assert exists(":NimOutlineUpdate") > 0 -Execute: - NimInfo - NimDebug - NimDefinition - NimUsages - NimUsagesProject - NimOutline - Given cpp: std::cout << "hello world" << std::endl; diff --git a/plugin/nim.vim b/plugin/nim.vim index d7451cd..9c4bb68 100644 --- a/plugin/nim.vim +++ b/plugin/nim.vim @@ -33,30 +33,78 @@ if exists("g:ycm_semantic_triggers") let g:ycm_semantic_triggers["nim"] = ['.'] endif -let g:nvim_nim_enable_async = has("nvim") +if !exists("g:nvim_nim_enable_async") + let g:nvim_nim_enable_async = has("nvim") +endif -let g:nvim_nim_exec_nim = CheckDependency("nim") -let g:nvim_nim_exec_nimble = CheckDependency("nimble") -let g:nvim_nim_exec_nimsuggest = CheckDependency("nimsuggest") -let g:nvim_nim_exec_bash = CheckDependency("bash") -let g:nvim_nim_deps_nim = FindNimModulesPath() -let g:nvim_nim_deps_nimble = FindNimbleModulesPath() +if !exists("g:nvim_nim_exec_nim") + let g:nvim_nim_exec_nim = CheckDependency("nim") +endif -let g:nvim_nim_outline_track_symbol = 1 -let g:nvim_nim_highlighter_enable = 0 -let g:nvim_nim_highlight_builtin = 1 +if !exists("g:nvim_nim_exec_nimble") + let g:nvim_nim_exec_nimble = CheckDependency("nimble") +endif -let g:nvim_nim_outline_buffer = 1 -let g:nvim_nim_outline_buffer_width = 30 +if !exists("g:nvim_nim_exec_nimsuggest") + let g:nvim_nim_exec_nimsuggest = CheckDependency("nimsuggest") +endif -let g:nvim_nim_repl_height = 14 -let g:nvim_nim_repl_vsplit = 0 +if !exists("g:nvim_nim_exec_bash") + let g:nvim_nim_exec_bash = CheckDependency("bash") +endif -let g:nvim_nim_enable_default_binds = 1 -let g:nvim_nim_enable_custom_textobjects = 1 +if !exists("g:nvim_nim_deps_nim") + let g:nvim_nim_deps_nim = FindNimModulesPath() +endif + +if !exists("g:nvim_nim_deps_nimble") + let g:nvim_nim_deps_nimble = FindNimbleModulesPath() +endif + +if !exists("g:nvim_nim_outline_track_symbol") + let g:nvim_nim_outline_track_symbol = 1 +endif + +if !exists("g:nvim_nim_highlighter_enable") + let g:nvim_nim_highlighter_enable = 0 +endif + +if !exists("g:nvim_nim_highlight_builtin") + let g:nvim_nim_highlight_builtin = 1 +endif + +if !exists("g:nvim_nim_outline_buffer") + let g:nvim_nim_outline_buffer = 1 +endif + +if !exists("g:nvim_nim_outline_buffer_width") + let g:nvim_nim_outline_buffer_width = 30 +endif + +if !exists("g:nvim_nim_repl_height") + let g:nvim_nim_repl_height = 14 +endif + +if !exists("g:nvim_nim_repl_vsplit") + let g:nvim_nim_repl_vsplit = 0 +endif + +if !exists("g:nvim_nim_enable_default_binds") + let g:nvim_nim_enable_default_binds = 1 +endif + +if !exists("g:nvim_nim_enable_custom_textobjects") + let g:nvim_nim_enable_custom_textobjects = 1 +endif + +if !exists("g:nvim_nim_highlighter_enable") + let g:nvim_nim_highlighter_enable = 0 +endif + +if !exists("g:nvim_nim_highlight_builtin") + let g:nvim_nim_highlight_builtin = 1 +endif -let g:nvim_nim_highlighter_enable = 0 -let g:nvim_nim_highlight_builtin = 1 " let g:nvim_nim_highlighter_semantics = ["skConst", "skForVar", "skGlobalVar", "skGlobalLet", "skLet", "skModule", "skParam", "skTemp", "skVar"] let g:nvim_nim_highlighter_semantics = []