This commit is contained in:
baabelfish 2016-02-03 18:46:00 +02:00
commit 161cdef318
14 changed files with 127 additions and 23 deletions

View file

@ -44,17 +44,20 @@ Nim support for Neovim
- [ ] IDE features - [ ] IDE features
- [x] Neomake - [x] Neomake
- [x] Autocompletion with ycm
- [ ] Search and view online documentation - [ ] Search and view online documentation
- [ ] Usages with unite - [ ] Usages with unite
- [ ] Outline with unite - [ ] Outline with unite
- [ ] Outline with a proper tagbar - [ ] Outline with a proper tagbar
- [ ] Auto complete modules
- [ ] Parse proc parameter types for parameter completion - [ ] Parse proc parameter types for parameter completion
- [ ] Airline integration - [ ] Airline integration
- [ ] When lines are added or removed use cached highlighter results - [ ] When lines are added or removed use cached highlighter results
- [ ] When editing line, remove highlighter results from that line - [ ] When editing line, remove highlighter results from that line
- [ ] Autocompletion
- [x] Autocompletion with ycm
- [ ] Auto complete modules
- [ ] Snippet/documentation support after complete
- [ ] Debugging - [ ] Debugging
- [ ] Commands - [ ] Commands
- [ ] Run file in debug mode - [ ] Run file in debug mode

View file

@ -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

View file

@ -38,6 +38,5 @@ endfunction
function! features#info#run() function! features#info#run()
call suggest#New("def", 1, 0, s:InfoImpl) call suggest#New("def", 0, 0, s:InfoImpl)
endfunction endfunction

View file

@ -4,7 +4,10 @@ endif
let s:loaded = 1 let s:loaded = 1
let s:OutlineImpl = {} let s:OutlineImpl = {
\ 'pty': 1,
\ }
function! s:OutlineImpl.run(data) function! s:OutlineImpl.run(data)
for line in a:data.lines for line in a:data.lines
if len(line) == 0 if len(line) == 0
@ -27,6 +30,6 @@ endfunction
function! features#outline#run() function! features#outline#run()
cclose cclose
call setqflist([]) call setqflist([])
call suggest#New("outline", 1, 1, s:OutlineImpl) call suggest#New("outline", 0, 1, s:OutlineImpl)
endfunction endfunction

View file

@ -19,18 +19,19 @@ function! s:RenameImpl.run(data)
continue continue
endif 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 continue
endif endif
if filename != expand("%:p") if res.file != expand("%:p")
execute ":e " . expand("%:p") execute ":e " . expand("%:p")
endif endif
let left = getline(line)[0:column - 1] let left = getline(res.line)[0:res.col - 1]
let right = getline(line)[column + len(oldName):-1] let right = getline(res.line)[res.col + len(oldName):-1]
call setline(line, left . newName . right) call setline(res.line, left . newName . right)
endfor endfor
endfunction endfunction

View file

@ -55,6 +55,6 @@ function! features#usages#run(findInProject)
cclose cclose
call setqflist([]) call setqflist([])
let s:findInProject = a:findInProject let s:findInProject = a:findInProject
call suggest#New("def", 1, 0, s:UsagesDefinitionImpl) call suggest#New("def", 1, 1, s:UsagesDefinitionImpl)
endfunction endfunction

View file

@ -5,7 +5,10 @@ let s:loaded = 1
let s:findInProject = 1 let s:findInProject = 1
let s:NimSuggestServer = {} let s:NimSuggestServer = {
\ 'pty': 1,
\ }
function! s:NimSuggestServer.on_stdout(job, chunk) function! s:NimSuggestServer.on_stdout(job, chunk)
" echoerr join(a:chunk, "\n") " echoerr join(a:chunk, "\n")
endfunction endfunction
@ -19,7 +22,9 @@ endfunction
" NimSuggest " NimSuggest
let s:NimSuggest = {} let s:NimSuggest = {
\ 'pty': 1,
\ }
function! s:NimSuggest.on_stdout(job, chunk) function! s:NimSuggest.on_stdout(job, chunk)
call extend(self.lines, a:chunk) call extend(self.lines, a:chunk)
@ -29,11 +34,13 @@ function! s:NimSuggest.on_stderr(job, chunk)
endfunction endfunction
function! s:NimSuggest.on_exit() function! s:NimSuggest.on_exit()
if self.isAsync let temparr = []
let self.lines = self.lines[5:-1] for line in self.lines
else if len(split(line, " ")) > 6
let self.lines = self.lines[4:-1] call add(temparr, line)
endif endif
endfor
let self.lines = temparr
if len(self.lines) > 0 if len(self.lines) > 0
call self.handler.run(self) call self.handler.run(self)

View file

@ -87,7 +87,6 @@ endfunction
function! util#ParseV1(line) function! util#ParseV1(line)
let res = split(a:line, " ") let res = split(a:line, " ")
let path = split(res[2], "\\.") let path = split(res[2], "\\.")
let result = { let result = {
\ "ctype": res[0], \ "ctype": res[0],
\ "kind": res[1], \ "kind": res[1],
@ -119,7 +118,6 @@ function! util#ParseV2(line)
\ "line": res[5], \ "line": res[5],
\ "col": res[6], \ "col": res[6],
\ "doc": res[7], \ "doc": res[7],
\ "quality": res[8],
\ "module": s:GetModule(path), \ "module": s:GetModule(path),
\ "location": join(path[0:-2], "."), \ "location": join(path[0:-2], "."),
\ "name": path[-1], \ "name": path[-1],
@ -127,6 +125,7 @@ function! util#ParseV2(line)
\ "kindstr": s:idtypes[res[1]][1], \ "kindstr": s:idtypes[res[1]][1],
\ "kindshort": s:idtypes[res[1]][0], \ "kindshort": s:idtypes[res[1]][0],
\ } \ }
" \ "quality": res[8],
return result return result
endfunction endfunction

View file

@ -18,6 +18,16 @@ command! NimRenameSymbolProject :call features#rename#run(1)
command! NimDebug :call features#debug#run() command! NimDebug :call features#debug#run()
command! NimOutline :call features#outline#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 <buffer> <c-]> :NimDefinition<cr> nnoremap <buffer> <c-]> :NimDefinition<cr>
nnoremap <buffer> gd :NimDefinition<cr> nnoremap <buffer> gd :NimDefinition<cr>
nnoremap <buffer> gt :NimInfo<cr> nnoremap <buffer> gt :NimInfo<cr>

View file

@ -58,4 +58,5 @@ echo "==========================================================================
echo "Run tests in $PWD" echo "Run tests in $PWD"
cd $current/other cd $current/other
nim c tests/suggestions.nim nim c tests/nimsuggest/suggestions.nim
nim c tests/edb/edb.nim