diff --git a/README.md b/README.md index 6e8f95d..55e423e 100644 --- a/README.md +++ b/README.md @@ -44,17 +44,20 @@ Nim support for Neovim - [ ] IDE features - [x] Neomake - - [x] Autocompletion with ycm - [ ] Search and view online documentation - [ ] Usages with unite - [ ] Outline with unite - [ ] Outline with a proper tagbar - - [ ] Auto complete modules - [ ] Parse proc parameter types for parameter completion - [ ] Airline integration - [ ] When lines are added or removed use cached highlighter results - [ ] When editing line, remove highlighter results from that line + - [ ] Autocompletion + - [x] Autocompletion with ycm + - [ ] Auto complete modules + - [ ] Snippet/documentation support after complete + - [ ] Debugging - [ ] Commands - [ ] Run file in debug mode diff --git a/autoload/features/debugger.vim b/autoload/features/debugger.vim new file mode 100644 index 0000000..0d476de --- /dev/null +++ b/autoload/features/debugger.vim @@ -0,0 +1,81 @@ +let s:edb_terminal_job = -2 + +let s:NimDebugger = { + \ 'pty': 1, + \ } + +function! s:NimDebugger.on_stdout(job, chunk) + for line in a:chunk + " *** endb| reached edb.nim(4) wat *** + " let matched = matchlist(line, "\\*\\*\\* endb\|\(.*\)$") + let matched = matchlist(line, "") + endfor +endfunction + +function! s:NimDebugger.on_stderr(job, chunk) + " echoerr "Error" . join(a:chunk, "\n") +endfunction + +function! s:NimDebugger.on_exit() + echoerr "Done" + let s:edb_terminal_job = -2 +endfunction + +function! features#debugger#run() + if s:edb_terminal_job > 0 + echo "Debugger already running" + else + " vnew + let s:edb_terminal_job = jobstart(["nim", "c", "--colors:off", "--debugger:on", "-r", "edb.nim"], s:NimDebugger) + " let s:edb_terminal_job = termopen("nim c --debugger:on -r edb.nim") + " wincmd p + endif +endfunction + +function! features#debugger#stop() + if s:edb_terminal_job > 0 + call jobstop([s:edb_terminal_job]) + else + echo "No debugger running" + endif +endfunction + +function! s:SendCommand(cmd) + if s:edb_terminal_job > 0 + call jobsend(s:edb_terminal_job, a:cmd . "\n") + " call jobsend(s:edb_terminal_job, "w\n") + else + echom "Debugger not running" + endif +endfunction + +function! features#debugger#continue() + call s:SendCommand("c") +endfunction + +function! features#debugger#stepinto() + call s:SendCommand("s") +endfunction + +function! features#debugger#stepover() + call s:SendCommand("n") +endfunction + +function! features#debugger#skipcurrent() + call s:SendCommand("f") +endfunction + +function! features#debugger#ignore() + call s:SendCommand("i") +endfunction + +function! features#debugger#togglebp() + call s:SendCommand("s") +endfunction + +autocmd! TermResponse * call s:ParseTerminal() + +function! s:ParseTerminal() + echoerr "WAAAT" + echoerr &t_RV +endfunction diff --git a/autoload/features/info.vim b/autoload/features/info.vim index 46f0ce7..39990ef 100644 --- a/autoload/features/info.vim +++ b/autoload/features/info.vim @@ -38,6 +38,5 @@ endfunction function! features#info#run() - call suggest#New("def", 1, 0, s:InfoImpl) + call suggest#New("def", 0, 0, s:InfoImpl) endfunction - diff --git a/autoload/features/outline.vim b/autoload/features/outline.vim index 54facbf..3815603 100644 --- a/autoload/features/outline.vim +++ b/autoload/features/outline.vim @@ -4,7 +4,10 @@ endif let s:loaded = 1 -let s:OutlineImpl = {} +let s:OutlineImpl = { + \ 'pty': 1, + \ } + function! s:OutlineImpl.run(data) for line in a:data.lines if len(line) == 0 @@ -27,6 +30,6 @@ endfunction function! features#outline#run() cclose call setqflist([]) - call suggest#New("outline", 1, 1, s:OutlineImpl) + call suggest#New("outline", 0, 1, s:OutlineImpl) endfunction diff --git a/autoload/features/rename.vim b/autoload/features/rename.vim index 42758bd..d16a979 100644 --- a/autoload/features/rename.vim +++ b/autoload/features/rename.vim @@ -19,18 +19,19 @@ function! s:RenameImpl.run(data) continue endif - let [_, _, _, _, filename, line, column, _, _] = split(line, " ") - if !s:findInProject && filename != expand("%:p") + + let res = util#ParseV2(line) + if !s:findInProject && res.file != expand("%:p") continue endif - if filename != expand("%:p") + if res.file != expand("%:p") execute ":e " . expand("%:p") endif - let left = getline(line)[0:column - 1] - let right = getline(line)[column + len(oldName):-1] - call setline(line, left . newName . right) + let left = getline(res.line)[0:res.col - 1] + let right = getline(res.line)[res.col + len(oldName):-1] + call setline(res.line, left . newName . right) endfor endfunction diff --git a/autoload/features/usages.vim b/autoload/features/usages.vim index 7224d58..5cf39d1 100644 --- a/autoload/features/usages.vim +++ b/autoload/features/usages.vim @@ -55,6 +55,6 @@ function! features#usages#run(findInProject) cclose call setqflist([]) let s:findInProject = a:findInProject - call suggest#New("def", 1, 0, s:UsagesDefinitionImpl) + call suggest#New("def", 1, 1, s:UsagesDefinitionImpl) endfunction diff --git a/autoload/suggest.vim b/autoload/suggest.vim index 00117b6..cff0d1f 100644 --- a/autoload/suggest.vim +++ b/autoload/suggest.vim @@ -5,7 +5,10 @@ let s:loaded = 1 let s:findInProject = 1 -let s:NimSuggestServer = {} +let s:NimSuggestServer = { + \ 'pty': 1, + \ } + function! s:NimSuggestServer.on_stdout(job, chunk) " echoerr join(a:chunk, "\n") endfunction @@ -19,7 +22,9 @@ endfunction " NimSuggest -let s:NimSuggest = {} +let s:NimSuggest = { + \ 'pty': 1, + \ } function! s:NimSuggest.on_stdout(job, chunk) call extend(self.lines, a:chunk) @@ -29,11 +34,13 @@ function! s:NimSuggest.on_stderr(job, chunk) endfunction function! s:NimSuggest.on_exit() - if self.isAsync - let self.lines = self.lines[5:-1] - else - let self.lines = self.lines[4:-1] - endif + let temparr = [] + for line in self.lines + if len(split(line, " ")) > 6 + call add(temparr, line) + endif + endfor + let self.lines = temparr if len(self.lines) > 0 call self.handler.run(self) diff --git a/autoload/util.vim b/autoload/util.vim index a78774c..2b7cc3e 100644 --- a/autoload/util.vim +++ b/autoload/util.vim @@ -87,7 +87,6 @@ endfunction function! util#ParseV1(line) let res = split(a:line, " ") let path = split(res[2], "\\.") - let result = { \ "ctype": res[0], \ "kind": res[1], @@ -119,7 +118,6 @@ function! util#ParseV2(line) \ "line": res[5], \ "col": res[6], \ "doc": res[7], - \ "quality": res[8], \ "module": s:GetModule(path), \ "location": join(path[0:-2], "."), \ "name": path[-1], @@ -127,6 +125,7 @@ function! util#ParseV2(line) \ "kindstr": s:idtypes[res[1]][1], \ "kindshort": s:idtypes[res[1]][0], \ } + " \ "quality": res[8], return result endfunction diff --git a/ftplugin/nim.vim b/ftplugin/nim.vim index 604be49..b60c26a 100644 --- a/ftplugin/nim.vim +++ b/ftplugin/nim.vim @@ -18,6 +18,16 @@ command! NimRenameSymbolProject :call features#rename#run(1) command! NimDebug :call features#debug#run() command! NimOutline :call features#outline#run() +command! NimEdb :call features#debugger#run() +command! NimEdbStop :call features#debugger#stop() +command! NimEdbContinue :call features#debugger#continue() +command! NimEdbStepInto :call features#debugger#stepinto() +command! NimEdbStepOver :call features#debugger#stepover() +command! NimEdbSkipCurrent :call features#debugger#skipcurrent() +command! NimEdbIgonore :call features#debugger#ignore() +command! NimEdbContinue :call features#debugger#continue() +command! NimEdbToggleBP :call features#debugger#togglebp() + nnoremap :NimDefinition nnoremap gd :NimDefinition nnoremap gt :NimInfo diff --git a/other/tests/suggestions.nim b/other/tests/nimsuggest/suggestions.nim similarity index 100% rename from other/tests/suggestions.nim rename to other/tests/nimsuggest/suggestions.nim diff --git a/other/tests/tmodule.nim b/other/tests/nimsuggest/tmodule.nim similarity index 100% rename from other/tests/tmodule.nim rename to other/tests/nimsuggest/tmodule.nim diff --git a/other/tests/tother.nim b/other/tests/nimsuggest/tother.nim similarity index 100% rename from other/tests/tother.nim rename to other/tests/nimsuggest/tother.nim diff --git a/other/tests/util.nim b/other/tests/nimsuggest/util.nim similarity index 100% rename from other/tests/util.nim rename to other/tests/nimsuggest/util.nim diff --git a/other/travis.sh b/other/travis.sh index 055655c..1193cb0 100755 --- a/other/travis.sh +++ b/other/travis.sh @@ -58,4 +58,5 @@ echo "========================================================================== echo "Run tests in $PWD" cd $current/other -nim c tests/suggestions.nim +nim c tests/nimsuggest/suggestions.nim +nim c tests/edb/edb.nim