sillybun / vim-repl

Best REPL environment for Vim
GNU General Public License v2.0
446 stars 39 forks source link

support for neovim #3

Open tgzhou98 opened 6 years ago

tgzhou98 commented 6 years ago

I'm not sure how much the work is. It just a feature request.

When I use <leader>r to open terminal program, neovim shows the following error.

image

sillybun commented 6 years ago

I have to admit that currently, I cannot provide support for neovim because that I'm not a neovim user. I tried to install neovim and something went wrong with my vimrc.

DavidEGx commented 5 years ago

Looks like all the terminal related stuff works differently in vim and neovim. So it's probably a bit of a pain.

This quick & dirty hack could be a start:

diff --git a/autoload/repl.vim b/autoload/repl.vim
index 0c43602..a4a56b5 100644
--- a/autoload/repl.vim
+++ b/autoload/repl.vim
@@ -96,7 +96,7 @@ endfunction
 function! repl#REPLClose()
        if repl#REPLIsVisible()
         if index(split(repl#REPLGetName(), ' '), 'ipdb') != -1 || index(split(repl#REPLGetName(), ' '), 'pdb') != -1
-            call term_sendkeys('ZYTREPL', "\<C-W>\<C-C>")
+            call jobsend(g:term_job_id, "\<C-W>\<C-C>")
             call repl#Sends(['quit()'], ['ipdb>', 'pdb>'])
         else
             exe "call term_sendkeys('" . 'ZYTREPL' . ''', "\<C-W>\<C-C>")'
@@ -151,7 +151,9 @@ function! repl#REPLOpen(...)
                if exists('g:repl_height')
                        exe 'bo term ++close ++rows=' . float2nr(g:repl_height) . ' ' . repl#REPLGetName()
                else
-                       exe 'bo term ++close ' . repl#REPLGetName()
+                       exe 'bo vsplit | enew'
+      let g:term_job_id = termopen(repl#REPLGetName())
+                       exe 'startinsert'
                endif
        elseif g:repl_position == 1
                if exists('g:repl_height')
@@ -265,7 +267,7 @@ function! repl#REPLSaveCheckPoint() abort
         endif
         let l:checkid = repl#REPLGetCheckID(getline('.'))
         if repl#REPLIsVisible()
-            call term_sendkeys('ZYTREPL', '__import__("dill").dump_session("CHECKPOINT_' . l:checkid .  '.data")' . "\<Cr>")
+            call jobsend(g:term_job_id, '__import__("dill").dump_session("CHECKPOINT_' . l:checkid .  '.data")' . "\<Cr>")
             if matchstr(getline(line('.') + 1), '# \d\d\d\d-\d\d\?-\d\d?') !=# ''
                 call setline(line('.') + 1, '# ' . strftime('%Y-%m-%d'))
             else
@@ -282,7 +284,7 @@ function! repl#REPLLoadCheckPoint() abort
     endif
     let l:checkid = repl#REPLGetCheckID(getline('.'))
     if repl#REPLIsVisible()
-        call term_sendkeys('ZYTREPL', '__import__("dill").load_session("CHECKPOINT_' . l:checkid .  '.data")' . "\<Cr>")
+        call jobsend(g:term_job_id, '__import__("dill").load_session("CHECKPOINT_' . l:checkid .  '.data")' . "\<Cr>")
     endif
 endfunction

@@ -302,8 +304,7 @@ function! repl#SendCurrentLine() abort
                 return
             endif
         endif
-               exe "call term_sendkeys('" . 'ZYTREPL' . ''', getline(".") . "\<Cr>")'
-               exe "call term_wait('" . 'ZYTREPL' . ''',  50)'
+               call jobsend(g:term_job_id, getline(".") . "\<Cr>")
        endif
 endfunction

@@ -654,7 +655,7 @@ function! repl#Sends(tasks, symbols)
         let g:currentlinenumber = -1
         let g:currentrepltype = repl#REPLGetShortName()
         " echom len(g:tasks)
-        let g:term_send_task_codes = ['LABEL Start', 'wait repl#CheckInputState()', 'call term_sendkeys("ZYTREPL", g:tasks[g:taskprocess] . "\<Cr>")', 'let g:taskprocess = g:taskprocess + 1', 'if g:taskprocess == len(g:tasks)', 'return', 'endif', 'GOTO Start']
+        let g:term_send_task_codes = ['LABEL Start', 'wait repl#CheckInputState()', 'call jobsend(' . g:term_job_id . ', g:tasks[g:taskprocess] . "\<Cr>")', 'let g:taskprocess = g:taskprocess + 1', 'if g:taskprocess == len(g:tasks)', 'return', 'endif', 'GOTO Start']
         " let g:term_send_task_index = 0
         " call job_start("echo 'g:term_send_task'", {'close_cb': 'AsyncFuncRun'})
         call AsyncCodeRun(g:term_send_task_codes, "term_send_task")
@@ -711,10 +712,9 @@ function! repl#SendLines(first, last) abort
             endwhile
             for line in getline(l:firstline, a:last)
                 let l:deletespaceline = line[l:i:]
-                exe "call term_sendkeys('" . 'ZYTREPL' . ''', l:deletespaceline . "\<Cr>")'
-                exe 'call term_wait("ZYTREPL", 50)'
+                exe "call jobsend(" . g:term_job_id . ', l:deletespaceline . "\<Cr>")'
             endfor
-            exe "call term_sendkeys('" . 'ZYTREPL' . ''', "\<Cr>")'
+            exe "call jobsend(" . g:term_job_id . ', "\<Cr>")'
         endif
        endif
 endfunction
diff --git a/plugin/default.vim b/plugin/default.vim
index 8125af8..0a1725b 100644
--- a/plugin/default.vim
+++ b/plugin/default.vim
@@ -4,7 +4,7 @@ let g:REPLVIM_PATH = g:REPLVIM_PATH[:strridx(g:REPLVIM_PATH, "plugin") - 1]
 if !exists("g:repl_program")
        let g:repl_program = {
                                \       "python": "python",
-                               \       "default": "bash"
+                               \       "default": "python"
                                \       }
 endif

Very basic \w command working, a lot of things would still crash.

Not a neovim user myself... I was just curious :)

baogorek commented 4 years ago

On Windows the Neovim install seems to go fine. When I run :REPLToggle I get this:

'++close' is not recognized as an internal or external command, operable program or batch file. [Process exited 1]'

Would be really cool to have this in Neovim!

huyiqun commented 4 years ago

+1 Really hoping to get this in Neovim!

Phantas0s commented 4 years ago

It would be great indeed. What about adding that Neovim is not supported at the beginning of the README?

yelled1 commented 4 years ago

Guys you can try: https://github.com/hkupty/iron.nvim It's pretty good, but has its quirks. It is NOT refined as this is for multiple languages. So, it can't discern if you have an empty line with in a function. So, u have to stick a tab or something. Also, I am using sillybun's solution for gluepython3 development. And, I could not change the repl. If anyone makes iron.nvim work for AWS gluepython3 , then pls let me know by responding to: https://github.com/hkupty/iron.nvim/issues/157 Still, I am reasonably happy with just vim.

baogorek commented 4 years ago

Good call, @yelled1, and while you're there, pick up hkupty/nvimux as well. It simulates tmux and gives you the ability to use CTRL-B O to jump between REPL and code. Here's my init.vim and plugins.lua.

yelled1 commented 4 years ago

Good call, @yelled1, and while you're there, pick up hkupty/nvimux as well. It simulates tmux and gives you the ability to use CTRL-B O to jump between REPL and code. Here's my init.vim and plugins.lua.

Thank you will try.

drskoolie commented 4 years ago

Would've really appreciated neovim support. I'm also getting the ++close

ccaprani commented 4 years ago

Another vote for neovim. Sorry I don't know enough to contribute.

shkronjax commented 4 years ago

neovim vote

sillybun commented 4 years ago

who can help to tell me how to use neovim and vim simutaneously on macOS? I have never used neovim yet/

shkronjax commented 4 years ago

who can help to tell me how to use neovim and vim simutaneously on macOS? I have never used neovim yet/

https://github.com/neovim/neovim/releases/ macOS Download nvim-macos.tar.gz Extract: tar xzvf nvim-macos.tar.gz Run ./nvim-osx64/bin/nvim neovim has its own vimrc file...on Ubuntu its under ~/.config/nvim/init.vim...probably same location on macOS as well(create file if not there after install). You just copy paste your configuration from your vimrc to init.vim or make a symlink. I keep neovims configs separate. On vim I use Conquer of Completion for IDE like features and on nvim LSP protocol and language servers. I suggest u keep vimrc and ~/.config/nvim/init.vim separate.

another option seems to be brew install neovim I hang out at engineermans discord often(google search it and join discord). If u want to keep chatting about vim. Also love your plugin on vim works very nicely.

ECon87 commented 3 years ago

Any updates? My error message reads:

Error detected while processing function repl#REPLToggle[10]..repl#REPLOpen

E117: Unknown function: term_sendkeys

yelled1 commented 3 years ago

Any updates? My error message reads:

Error detected while processing function repl#REPLToggle[10]..repl#REPLOpen

E117: Unknown function: term_sendkeys

Actually, if ur dying to use it on neovim, then coc-python will work now. You just do need to remap the keys to Sillybun's. I use both.

ECon87 commented 3 years ago

Any updates? My error message reads: Error detected while processing function repl#REPLToggle[10]..repl#REPLOpen E117: Unknown function: term_sendkeys

Actually, if ur dying to use it on neovim, then coc-python will work now. You just do need to remap the keys to Sillybun's. I use both.

Thank you. I tried devising my own function but it took forever. coc-python works.

Can you choose the placement of the terminal?

yelled1 commented 3 years ago

Have not tried. GitHub - hkupty/iron.nvim: Interactive Repl Over Neovim is pretty good & let u choose the terminal position, but not as mature as vim-repl. You will hit some prb. Also, https://github.com/kassio/neoterm is another option.

On Sat, Dec 12, 2020 at 4:22 PM Evangelos Constantinou < notifications@github.com> wrote:

Any updates? My error message reads: Error detected while processing function repl#REPLToggle[10]..repl#REPLOpen E117: Unknown function: term_sendkeys

Actually, if ur dying to use it on neovim, then coc-python https://github.com/neoclide/coc-pythonwill work now. You just do need to remap the keys to Sillybun's. I use both.

Thank you. I tried devising my own function but it took forever. coc-python works.

Can you choose the placement of the terminal?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sillybun/vim-repl/issues/3#issuecomment-743889375, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARVDVXWP7K33MC5CJA7URLSUPNLFANCNFSM4FI2X6NA .

ECon87 commented 3 years ago

Have not tried. GitHub - hkupty/iron.nvim: Interactive Repl Over Neovim is pretty good & let u choose the terminal position, but not as mature as vim-repl. You will hit some prb. Also, https://github.com/kassio/neoterm is another option. On Sat, Dec 12, 2020 at 4:22 PM Evangelos Constantinou < @.***> wrote: Any updates? My error message reads: Error detected while processing function repl#REPLToggle[10]..repl#REPLOpen E117: Unknown function: term_sendkeys Actually, if ur dying to use it on neovim, then coc-python https://github.com/neoclide/coc-pythonwill work now. You just do need to remap the keys to Sillybun's. I use both. Thank you. I tried devising my own function but it took forever. coc-python works. Can you choose the placement of the terminal? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#3 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARVDVXWP7K33MC5CJA7URLSUPNLFANCNFSM4FI2X6NA .

Thanks. I figured it out with coc-python (well kind of) for any one who is interested. After sending your selection to the terminal, the position can be re-adjusted with the usual window adjustment keybindings (i.e., ctrl-w-H).

One drawback of using coc-python relative to vim-repl is that the latter automatically moves to the end of the selection after the code is sent.

yelled1 commented 3 years ago

Just use below with caveat that u might want to change \ to something that you would use & You will not be able to use "mY" & you might want to change to something else. When not available then hack'em => why we use (neo)vim.

autocmd FileType python nnoremap l :CocCommand python.upgradePythonLanguageServer autocmd FileType python nnoremap r :CocCommand python.startREPL autocmd FileType python vmap * mY:CocCommand python.execSelectionInTerminal'Yj autocmd Filetype python imap \ 0v$:CocCommand python.execSelectionInTerminalj autocmd Filetype python nmap * 0v$:CocCommand python.execSelectionInTerminalj

On Sun, Dec 13, 2020 at 12:18 PM Evangelos Constantinou < notifications@github.com> wrote:

Have not tried. GitHub - hkupty/iron.nvim: Interactive Repl Over Neovim is pretty good & let u choose the terminal position, but not as mature as vim-repl. You will hit some prb. Also, https://github.com/kassio/neoterm is another option. … <#m3697932679282546535> On Sat, Dec 12, 2020 at 4:22 PM Evangelos Constantinou < @.***> wrote: Any updates? My error message reads: Error detected while processing function repl#REPLToggle[10]..repl#REPLOpen E117: Unknown function: term_sendkeys Actually, if ur dying to use it on neovim, then coc-python https://github.com/neoclide/coc-pythonwill work now. You just do need to remap the keys to Sillybun's. I use both. Thank you. I tried devising my own function but it took forever. coc-python works. Can you choose the placement of the terminal? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#3 (comment) https://github.com/sillybun/vim-repl/issues/3#issuecomment-743889375>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARVDVXWP7K33MC5CJA7URLSUPNLFANCNFSM4FI2X6NA .

Thanks. I figured it out with coc-python (well kind of) for any one who is interested. After sending your selection to the terminal, the position can be re-adjusted with the usual window adjustment keybindings (i.e., ctrl-w-H).

One drawback of using coc-python relative to vim-repl is that the latter automatically moves to the end of the selection after the code is sent.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sillybun/vim-repl/issues/3#issuecomment-744039139, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARVDVVZOHPWT77QIBEFI5DSUTZPTANCNFSM4FI2X6NA .

ECon87 commented 3 years ago

Just use below with caveat that u might want to change * to something that you would use & You will not be able to use "mY" & you might want to change to something else. When not available then hack'em => why we use (neo)vim. autocmd FileType python nnoremap l :CocCommand python.upgradePythonLanguageServer autocmd FileType python nnoremap r :CocCommand python.startREPL autocmd FileType python vmap * mY:CocCommand python.execSelectionInTerminal'Yj autocmd Filetype python imap \ 0v$:CocCommand python.execSelectionInTerminalj autocmd Filetype python nmap * 0v$:CocCommand python.execSelectionInTerminalj On Sun, Dec 13, 2020 at 12:18 PM Evangelos Constantinou < notifications@github.com> wrote: Have not tried. GitHub - hkupty/iron.nvim: Interactive Repl Over Neovim is pretty good & let u choose the terminal position, but not as mature as vim-repl. You will hit some prb. Also, https://github.com/kassio/neoterm is another option. … <#m3697932679282546535> On Sat, Dec 12, 2020 at 4:22 PM Evangelos Constantinou < @*.***> wrote: Any updates? My error message reads: Error detected while processing function repl#REPLToggle[10]..repl#REPLOpen E117: Unknown function: term_sendkeys Actually, if ur dying to use it on neovim, then coc-python https://github.com/neoclide/coc-pythonwill work now. You just do need to remap the keys to Sillybun's. I use both. Thank you. I tried devising my own function but it took forever. coc-python works. Can you choose the placement of the terminal? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#3 (comment) <#3 (comment)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARVDVXWP7K33MC5CJA7URLSUPNLFANCNFSM4FI2X6NA . Thanks. I figured it out with coc-python (well kind of) for any one who is interested. After sending your selection to the terminal, the position can be re-adjusted with the usual window adjustment keybindings (i.e., ctrl-w-H). One drawback of using coc-python relative to vim-repl is that the latter automatically moves to the end of the selection after the code is sent. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#3 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARVDVVZOHPWT77QIBEFI5DSUTZPTANCNFSM4FI2X6NA .

Thank you

yelled1 commented 3 years ago

Ur welcome & @ECon87 You might want to close this issue.

ECon87 commented 3 years ago

It's not my issue. I don't think I can close it

EPC204 commented 3 years ago

neovim vote! Really love this plugin!

lrittel commented 2 years ago

This plugin looks awesome, so I've started working on adding neovim support over on my fork . @DavidEGx’s code was a good starting point :+1: Opening a REPL and sending (pytho) code to it already works, but there still are some things to be done. I'll create a PR if @sillybun is interested in including the feature.

On a side note: I only found out about the missing neovim support after getting the errors described in this issue, a small note in the README would be nice untile neovim support is available :) .

I’m pretty bad at vimscript, though ^^

sillybun commented 2 years ago

@rittelle that will be awesome