parent
76e54f8ad5
commit
fd587228d0
5 changed files with 90 additions and 1 deletions
|
|
@ -23,12 +23,15 @@ DON'T INSTALL YET, STILL UNDER VERY HEAVY DEVELOPMENT.
|
||||||
- Jump to documentation in web
|
- Jump to documentation in web
|
||||||
- Refactoring
|
- Refactoring
|
||||||
- Rename symbol in file or project
|
- Rename symbol in file or project
|
||||||
|
- REPL
|
||||||
|
- Open repl
|
||||||
|
- Send current buffer
|
||||||
|
- Send selection
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
## Planned features
|
## Planned features
|
||||||
- REPL support
|
|
||||||
- Debugger support
|
- Debugger support
|
||||||
- Autocomplete modules
|
- Autocomplete modules
|
||||||
- All features will work asynchronously
|
- All features will work asynchronously
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
if exists("s:loaded")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let s:loaded = 1
|
||||||
|
|
||||||
|
let s:repl_pid = -1
|
||||||
|
let s:repl_window = -1
|
||||||
|
|
||||||
|
function! s:Window()
|
||||||
|
return winbufnr(s:repl_window)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:IsOpen()
|
||||||
|
return winbufnr(s:Window()) > 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:Focus()
|
||||||
|
if s:IsOpen()
|
||||||
|
exec ":" . s:Window() . "wincmd w"
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! features#repl#start()
|
||||||
|
if s:IsOpen()
|
||||||
|
call s:Focus()
|
||||||
|
else
|
||||||
|
if g:nvim_nim_repl_vsplit
|
||||||
|
vnew
|
||||||
|
wincmd L
|
||||||
|
wincmd L
|
||||||
|
wincmd L
|
||||||
|
else
|
||||||
|
new
|
||||||
|
wincmd J
|
||||||
|
wincmd J
|
||||||
|
wincmd J
|
||||||
|
endif
|
||||||
|
|
||||||
|
let s:repl_window = winnr()
|
||||||
|
let s:repl_pid = termopen("sh -c \"nim secret\"")
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! features#repl#send(lines)
|
||||||
|
if !s:IsOpen()
|
||||||
|
call features#repl#start()
|
||||||
|
sleep 100m
|
||||||
|
endif
|
||||||
|
|
||||||
|
for line in a:lines
|
||||||
|
call jobsend(s:repl_pid, line . "\r")
|
||||||
|
sleep 20m
|
||||||
|
endfor
|
||||||
|
call jobsend(s:repl_pid, "\r")
|
||||||
|
sleep 20m
|
||||||
|
norm! i
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! features#repl#stop()
|
||||||
|
if s:repl_pid > 0
|
||||||
|
call jobstop(s:repl_pid)
|
||||||
|
call s:Focus()
|
||||||
|
exec ":bd!"
|
||||||
|
else
|
||||||
|
echom "No REPL running"
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
@ -262,3 +262,15 @@ function! util#SelectNimProc(inner)
|
||||||
normal! h
|
normal! h
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
call operator#user#define('nimrepl_send', 'NimReplSend')
|
||||||
|
function! NimReplSend(motion_wiseness)
|
||||||
|
let start = getpos("'[")
|
||||||
|
let stop = getpos("']")
|
||||||
|
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
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ command! NimEdbIgonore :call features#debugger#ignore()
|
||||||
command! NimEdbContinue :call features#debugger#continue()
|
command! NimEdbContinue :call features#debugger#continue()
|
||||||
command! NimEdbToggleBP :call features#debugger#togglebp()
|
command! NimEdbToggleBP :call features#debugger#togglebp()
|
||||||
|
|
||||||
|
command! NimREPL :call features#repl#start()
|
||||||
|
command! NimREPLEvalFile :call features#repl#send(getline(0, line("$")))
|
||||||
|
command! -range NimREPLEval :call features#repl#send(getline(getpos("'<")[1], getpos("'>")[1]))
|
||||||
|
|
||||||
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>
|
||||||
|
|
|
||||||
|
|
@ -44,4 +44,7 @@ let g:nvim_nim_highlight_use_unite = 0
|
||||||
let g:nvim_nim_outline_buffer = 1
|
let g:nvim_nim_outline_buffer = 1
|
||||||
let g:nvim_nim_outline_buffer_width = 30
|
let g:nvim_nim_outline_buffer_width = 30
|
||||||
|
|
||||||
|
let g:nvim_nim_repl_height = 14
|
||||||
|
let g:nvim_nim_repl_vsplit = 0
|
||||||
|
|
||||||
let g:nvim_nim_highlighter_semantics = ["skConst", "skForVar", "skGlobalVar", "skGlobalLet", "skLet", "skModule", "skParam", "skTemp", "skVar"]
|
let g:nvim_nim_highlighter_semantics = ["skConst", "skForVar", "skGlobalVar", "skGlobalLet", "skLet", "skModule", "skParam", "skTemp", "skVar"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue