Async fixes
This commit is contained in:
parent
04ac2060e9
commit
02862ee691
11 changed files with 37 additions and 61 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
# nvim-nim [](https://travis-ci.org/baabelfish/nvim-nim)
|
# nvim-nim [](https://travis-ci.org/baabelfish/nvim-nim)
|
||||||
Nim support for vim and advanced support for neovim.
|
Nim support for vim and advanced support for neovim. Still in heavy development.
|
||||||
|
|
||||||
DON'T INSTALL YET, STILL UNDER VERY HEAVY DEVELOPMENT.
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
- Asynchronous
|
||||||
- Syntax highlighting
|
- Syntax highlighting
|
||||||
- Normal vim highlight
|
- Normal vim highlight
|
||||||
- More intelligent highlight with nimsuggest
|
- More intelligent highlight with nimsuggest
|
||||||
|
|
@ -17,7 +17,7 @@ DON'T INSTALL YET, STILL UNDER VERY HEAVY DEVELOPMENT.
|
||||||
- Get symbol information (type, module, file, signature, etc...)
|
- Get symbol information (type, module, file, signature, etc...)
|
||||||
- Find usages (file and/or project)
|
- Find usages (file and/or project)
|
||||||
- Autocompletion
|
- Autocompletion
|
||||||
- Nimsuggest autocompletion
|
- Nimsuggest omnicompletion
|
||||||
- Autocomplete module names
|
- Autocomplete module names
|
||||||
- IDE like stuff
|
- IDE like stuff
|
||||||
- Outline listing all symbols in the module (like tagbar)
|
- Outline listing all symbols in the module (like tagbar)
|
||||||
|
|
@ -29,9 +29,10 @@ DON'T INSTALL YET, STILL UNDER VERY HEAVY DEVELOPMENT.
|
||||||
- Send current buffer
|
- Send current buffer
|
||||||
- Send selection
|
- Send selection
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
## Planned features
|
## Planned features
|
||||||
- Debugger support
|
- Debugger support
|
||||||
- All features will work asynchronously
|
- Async autocomplete with deoplete (maybe a seperate plugin)
|
||||||
|
|
|
||||||
|
|
@ -8,17 +8,11 @@ let s:DefinitionImpl = {}
|
||||||
|
|
||||||
|
|
||||||
function! s:DefinitionImpl.run(data)
|
function! s:DefinitionImpl.run(data)
|
||||||
if len(a:data.lines) > 0
|
let res = util#ParseV1(a:data.lines[0])
|
||||||
let res = util#ParseV1(a:data.lines[0])
|
call util#JumpToLocation(res.file, res.line, res.col + 1)
|
||||||
call util#JumpToLocation(res.file, res.line, res.col + 1)
|
|
||||||
else
|
|
||||||
echohl Comment | echo "Not found"
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! features#definition#run()
|
function! features#definition#run()
|
||||||
call suggest#New("def", 1, 0, s:DefinitionImpl)
|
call suggest#New("def", 0, 0, s:DefinitionImpl)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,10 @@ endfunction
|
||||||
|
|
||||||
|
|
||||||
function! features#info#web()
|
function! features#info#web()
|
||||||
call suggest#New("def", 1, 0, s:New(1))
|
call suggest#New("def", 0, 0, s:New(1))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! features#info#run()
|
function! features#info#run()
|
||||||
call suggest#New("def", 1, 0, s:New(0))
|
call suggest#New("def", 0, 0, s:New(0))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ endfunction
|
||||||
|
|
||||||
function! features#outline#run(isUpdating)
|
function! features#outline#run(isUpdating)
|
||||||
if !a:isUpdating || s:IsOpen()
|
if !a:isUpdating || s:IsOpen()
|
||||||
call suggest#New("outline", 1, 1, s:OutlineImpl)
|
call suggest#New("outline", 0, 1, s:OutlineImpl)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,19 +7,10 @@ let s:RenameImpl = {}
|
||||||
|
|
||||||
|
|
||||||
function! s:RenameImpl.run(data)
|
function! s:RenameImpl.run(data)
|
||||||
if len(a:data.lines) == 1
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let oldName = split(split(util#FirstNonEmpty(a:data.lines), " ")[2], "\\.")[-1]
|
let oldName = split(split(util#FirstNonEmpty(a:data.lines), " ")[2], "\\.")[-1]
|
||||||
let newName = input("Rename symbol: ", oldName)
|
let newName = input("Rename symbol: ", oldName)
|
||||||
|
|
||||||
for line in a:data.lines
|
for line in a:data.lines
|
||||||
if len(line) == 0
|
|
||||||
continue
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
let res = util#ParseV2(line)
|
let res = util#ParseV2(line)
|
||||||
if !s:findInProject && res.file != expand("%:p")
|
if !s:findInProject && res.file != expand("%:p")
|
||||||
continue
|
continue
|
||||||
|
|
@ -42,6 +33,6 @@ endfunction
|
||||||
|
|
||||||
function! features#rename#run(inProject)
|
function! features#rename#run(inProject)
|
||||||
let s:findInProject = a:inProject
|
let s:findInProject = a:inProject
|
||||||
call suggest#New("use", 1, 1, s:RenameImpl)
|
call suggest#New("use", 0, 1, s:RenameImpl)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,15 +46,13 @@ endfunction
|
||||||
|
|
||||||
let s:UsagesDefinitionImpl = {}
|
let s:UsagesDefinitionImpl = {}
|
||||||
function! s:UsagesDefinitionImpl.run(data)
|
function! s:UsagesDefinitionImpl.run(data)
|
||||||
" let res = util#ParseV1(a:data.lines[0])
|
call suggest#NewKnown("use", 0, 1, a:data.file, a:data.line, a:data.col, s:UsagesImpl)
|
||||||
" call suggest#NewKnown("use", 1, res.file, res.line, res.col + 1, s:UsagesImpl)
|
|
||||||
call suggest#New("use", 1, 1, s:UsagesImpl)
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! features#usages#run(findInProject)
|
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, 1, s:UsagesDefinitionImpl)
|
call suggest#New("def", 0, 1, s:UsagesDefinitionImpl)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,11 +97,12 @@ endfunction
|
||||||
function highlighter#New()
|
function highlighter#New()
|
||||||
let result = copy(s:NimHighlighter)
|
let result = copy(s:NimHighlighter)
|
||||||
let result.lines = []
|
let result.lines = []
|
||||||
let result.job = jobstart([g:nvim_nim_exec_nimsuggest, '--v2', '--stdin', expand("%:p")], result)
|
|
||||||
let result.file = expand("%:p")
|
let result.file = expand("%:p")
|
||||||
let result.tempfile = util#WriteMemfile()
|
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")
|
call jobsend(result.job, "highlight " . result.file . ";" . result.tempfile . ":1:1\nquit\n")
|
||||||
|
|
||||||
if !exists("b:highlights")
|
if !exists("b:highlights")
|
||||||
let b:highlights = []
|
let b:highlights = []
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
|
|
@ -5,25 +5,8 @@ let s:loaded = 1
|
||||||
|
|
||||||
|
|
||||||
let s:findInProject = 1
|
let s:findInProject = 1
|
||||||
let s:NimSuggestServer = {
|
|
||||||
\ 'pty': 1,
|
|
||||||
\ }
|
|
||||||
|
|
||||||
function! s:NimSuggestServer.on_stdout(job, chunk)
|
|
||||||
" echoerr join(a:chunk, "\n")
|
|
||||||
endfunction
|
|
||||||
function! s:NimSuggestServer.on_stderr(job, chunk)
|
|
||||||
" echoerr join(a:chunk, "\n")
|
|
||||||
endfunction
|
|
||||||
function! s:NimSuggestServer.on_exit()
|
|
||||||
" call jobstop(self.job_server)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
" NimSuggest
|
|
||||||
let s:NimSuggest = {
|
let s:NimSuggest = {
|
||||||
\ 'pty': 1,
|
\ 'pty': 0,
|
||||||
\ }
|
\ }
|
||||||
|
|
||||||
function! s:NimSuggest.on_stdout(job, chunk)
|
function! s:NimSuggest.on_stdout(job, chunk)
|
||||||
|
|
@ -33,15 +16,23 @@ endfunction
|
||||||
function! s:NimSuggest.on_stderr(job, chunk)
|
function! s:NimSuggest.on_stderr(job, chunk)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:NimSuggest.on_exit()
|
function! s:NimSuggest.on_exit()
|
||||||
|
echo ""
|
||||||
let self.lines = util#FilterCompletions(self.lines)
|
let self.lines = util#FilterCompletions(self.lines)
|
||||||
if len(self.lines) > 0
|
if len(self.lines) > 0
|
||||||
call self.handler.run(self)
|
call self.handler.run(self)
|
||||||
else
|
else
|
||||||
echo ""
|
echohl Comment | echo "Got nothing" | echohl Normal
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! suggest#CreateJob(useV2, file, callbacks)
|
||||||
|
return jobstart([g:nvim_nim_exec_nimsuggest, '--stdin', (a:useV2 ? '--v2' : ''), a:file], a:callbacks)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! suggest#NewKnown(command, sync, useV2, file, line, col, handler)
|
function! suggest#NewKnown(command, sync, useV2, file, line, col, handler)
|
||||||
let result = copy(s:NimSuggest)
|
let result = copy(s:NimSuggest)
|
||||||
let result.lines = []
|
let result.lines = []
|
||||||
|
|
@ -59,16 +50,16 @@ function! suggest#NewKnown(command, sync, useV2, file, line, col, handler)
|
||||||
let result.lines = util#FilterCompletions(split(system(fullcmd), "\n"))
|
let result.lines = util#FilterCompletions(split(system(fullcmd), "\n"))
|
||||||
if len(result.lines) > 0
|
if len(result.lines) > 0
|
||||||
call a:handler.run(result)
|
call a:handler.run(result)
|
||||||
|
else
|
||||||
|
echohl Comment | echo "Got nothing" | echohl Normal
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call util#StartQuery()
|
call util#StartQuery()
|
||||||
let result.job_server = jobstart([g:nvim_nim_exec_nimsuggest, '--port:5999', '--address:localhost', (a:useV2 ? '--v2' : ''), result.file], s:NimSuggestServer)
|
let result.job = suggest#CreateJob(a:useV2, result.file, result)
|
||||||
if result.job_server < 1
|
if result.job > 0
|
||||||
echoerr "Unable to start server"
|
call jobsend(result.job, query . "\nquit\n")
|
||||||
else
|
else
|
||||||
" FIXME: Telnet is not possibly the best way to communicate :S
|
echoerr "Unable to start server"
|
||||||
let result.job_suggest = jobstart(['telnet', 'localhost', '5999'], result)
|
|
||||||
call jobsend(result.job_suggest, query . "\n")
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
if exists("s:loaded")
|
if exists("g:nvim_nim_ftdetect_loaded")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let s:loaded = 1
|
let g:nvim_nim_ftdetect_loaded = 1
|
||||||
|
|
||||||
au BufNewFile,BufRead *.nim setlocal filetype=nim
|
au BufNewFile,BufRead *.nim setlocal filetype=nim
|
||||||
au BufNewFile,BufRead *.nims setlocal filetype=nims
|
au BufNewFile,BufRead *.nims setlocal filetype=nims
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,6 @@ vnoremap <silent>af :<C-U>call util#SelectNimProc(0)<CR><Esc>gv
|
||||||
vnoremap <silent>if :<C-U>call util#SelectNimProc(1)<CR><Esc>gv
|
vnoremap <silent>if :<C-U>call util#SelectNimProc(1)<CR><Esc>gv
|
||||||
|
|
||||||
autocmd! BufReadPost,BufWritePost,CursorHold,InsertLeave,TextChanged,InsertEnter *.nim call highlighter#guard()
|
autocmd! BufReadPost,BufWritePost,CursorHold,InsertLeave,TextChanged,InsertEnter *.nim call highlighter#guard()
|
||||||
autocmd! BufWinEnter,BufWritePost,FileWritePost *.nim call features#outline#run(1)
|
autocmd! CursorHold,BufWritePost,FileWritePost *.nim call features#outline#run(1)
|
||||||
autocmd! VimResized,WinEnter * call features#outline#render()
|
autocmd! VimResized,WinEnter * call features#outline#render()
|
||||||
call highlighter#guard()
|
call highlighter#guard()
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
if exists("s:loaded")
|
if exists("g:nvim_nim_loaded")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let s:loaded = 1
|
let g:nvim_nim_loaded = 1
|
||||||
|
|
||||||
|
|
||||||
function! CheckDependency(command)
|
function! CheckDependency(command)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue