jalvesaq / vimcmdline Goto Github PK
View Code? Open in Web Editor NEWSend code to command line interpreter
License: GNU General Public License v2.0
Send code to command line interpreter
License: GNU General Public License v2.0
Hi there, I'm having a small problem with using vimcmdline with Julia. I'm currently on an UbuntuMATE 18.04 system which is currently fully updated. Running NVIM v0.3.0-dev in MATE Terminal 1.20. With a blank .vimrc file and only the vimcmdline and julia-vim plugin's installed, using space to send a line to the REPL results in what looks like two newlines being sent.
This is the result of pressing the spacebar twice:
I can't remove julia-vim plugin because nvim doesn't seem to recognise the .jl as a julia file, which stops me opening the REPL.
Happy to provide / do further info or tests to try to pin this down. I've only discovered this plugin today and enjoying it so far (the extra newline doesn't seem to cause too many problems). TIA.
After sending a js file with several vars and functions defined in that file, I see those vars and functions undefined in node repl.
Sending lines using space works though.
For some reason VimCmdLineSendLine() works but VimCmdLineSendSelection() and b:cmdline_source_fun(...) actually put
delete require.cache[require.resolve('/tmp/cmdline_1586888699_${user}/lines.js')]; require('/tmp/cmdline_1586888699_${user}/lines.js')
into the console and doesn't run the code in selection. I'm using nvim 0.4.3 with node 10.19.0 in debian testing.
I am a huge fan of docker, and I'd like to use vimcmdline to debug my scripts that are running inside a container.
It is actually simple to change init.vim to make it work:
let cmdline_app["python"] = "docker exec -it container /usr/python3"
But I don't want to have to edit my config file every time I want to attach to a different container. What would you suggest? I am willing to do a pull request.
Could we imagine a new shortcut? That would query the user for a custom command line?
Is it possible to convert this plugin to work with vim 8 like NvimR does?
This is a great project! I love it!
I just have a minor usability issue:
I was wondering if there's a way to toggle the interpreter?
Because when I start a session after having a session already open, it starts a second session, then when I close it, I can't close the first session.
Another way would be that when I start a session, to try and close a previous session
I did a 'apt upgrade' and both my ubuntu 18.04 machine stop to work.
Showing error:
"Error detected while processing fuction RonJobStout[7].. SetNvimcomInfo[77]..JobStdin: line 1:
unknown function: chansend"
I installed vimcmdline using Plug by placing the following line into my ~/.config/nvim/init.vim
:
call plug#begin('~/.config/nvim/plugged')
Plug 'jalvesaq/vimcmdline'
call plug#end()
I was able to install the plugin. Loading up a test.sh
file and then pressing <LocalLeader>s
starts up my interpreter. But if add the following mapping:
call plug#begin('~/.config/nvim/plugged')
Plug 'jalvesaq/vimcmdline'
call plug#end()
" Swap ; and :
" Avoid needing to use <SHIFT> for Ex commands
" Only applies in 'normal' mode
" E.g. ;w! - Will save the file
nnoremap ; :
nnoremap : ;
The interpreter no longer starts. Clearly, the mapping of the colon to semicolon is having an adverse effect on starting the interpreter and other vimcmdline arguments. Is there a way to get around this? Interestingly, when I use Nvim-R I don't have this problem.
When I send multiple lines of Python (e.g. a paragraph or function) to IPython running in a Neovim terminal buffer, "%cpaste -q" appears at the console and nothing happens. If I then switch to the console and hit CTRL-C I get a long traceback related to the keyboard interrupt and then one by one the sent lines are evaluated at the normal IPython prompt (not the one expected to be invoked by %cpaste) and also "--" is evaluated raising an error.
This happens most of the time but not always. The expected behaviour also occurs.
How can I fix this?
I'm using NVIM v0.2.2, Python 3.6.8 and IPython 7.8.0 all running in tmux in Windows Subsystem for Linux with Ubuntu 18.04.
I added kdb support and realize that sending the line "-1" (just the number)
-1
would break the VimCmdLineSendLine function in any filetype
This issue occurs only with ipython.
When I select multiple lines with shift + v and send them to the Terminal with < space >, only the first line is pasted and executed.
is it possible to have localleader+p+p to print out the value of a python object?
Hi,
Would it be possible to direct the output into the buffer it was called from instead of the terminal?
This would be similar to Nvim-R o as below:
https://github.com/jalvesaq/Nvim-R/blob/100ba75258cf7f5d0033a8b3c2aabbb999bb162f/doc/Nvim-R.txt#L480
Anyway, fantastic work! Really appreciate this plugin on a daily basis.
Hi!
It would be nice to automatically consult the current file in the prolog REPL for testing the written code. You have to type consult('file.pl').
now everytime you want to open the repl for testing.
This option would be nice for every language, by the way.
Sorry to nitpick, but the map to start vimcmdline is not configurable, but the one to quit is.
Hi Jakson,
First of all, I would like to thank you for this great Plugin.
The suggestion is when you are working on a large projects it would be very stressful and confused to leave the workspace and open a new Terminal to do some related work like updating or installing a some components etc. In most popular IDEs like Atom and VSCode you can open a Terminal in the workspace to accomplish these tasks without leaving the workspace. So I think it would be a great addition to this Plugin if it was applied. For example when working on a Django project, what I suggest is something like that:
When I send a line to the Python REPL (either plain python or ipython), the contents of the line is entered in the REPL, but they are not evaluated. In order to execute the command I have to go to the REPL and hit Enter.
This issue does not arise with the Julia REPL, which works as expected.
I'm using Neovim 0.3 on Windows 10.
I am using vim 8.1
and tmux 2.3
on debian 9.8
, my vimcmdline
configuration is as follows:
" vimcmdline mappings
let cmdline_map_start = '\s'
let cmdline_map_send_and_stay = '\l'
" Send file
let cmdline_map_source_fun = '\f'
let cmdline_map_send_paragraph = '\p'
let cmdline_map_send_block = '\b'
let cmdline_map_quit = '\q'
" vimcmdline options
let cmdline_vsplit = 1 " Split the window vertically
let cmdline_in_buffer = 0 " Start the interpreter in tmux since vimcmdline doesn't support vim term
I also use pylint
through pymode
which strip all trailing space, including the empty lines inside functions.
And when I was sending split.py
that have functions with blank lines inside:
# split.py
def find(s, start, predictor):
for i in range(start, len(s)):
if predictor(s[i]):
return i
return -1
def find_all(s, sep=" \t\n"):
beg_of_nonsep = 0
while beg_of_nonsep < len(s):
beg_of_nonsep = find(s, beg_of_nonsep, lambda ch, sep_chs=sep: ch not in sep_chs)
if beg_of_nonsep == -1:
break
end_of_nonsep = find(s, beg_of_nonsep + 1, lambda ch, sep_chs=sep: ch in sep_chs)
if end_of_nonsep == -1:
end_of_nonsep = len(s)
yield (beg_of_nonsep, end_of_nonsep)
beg_of_nonsep = end_of_nonsep + 1
split = lambda s: [s[beg: end] for (beg, end) in find_all(s)]
print(split(""))
print(split(" \t\n"))
print(split(" \tssss\n"))
it did not work:
Type "help", "copyright", "credits" or "license" for more information.
>>> def find(s, start, predictor):
... for i in range(start, len(s)):
... if predictor(s[i]):
... return i
... return -1
...
>>> def find_all(s, sep=" \t\n"):
... beg_of_nonsep = 0
... while beg_of_nonsep < len(s):
... beg_of_nonsep = find(s, beg_of_nonsep, lambda ch, sep_chs=sep: ch not in sep_chs)
... if beg_of_nonsep == -1:
... break
...
>>> end_of_nonsep = find(s, beg_of_nonsep + 1, lambda ch, sep_chs=sep: ch in sep_chs)
File "<stdin>", line 1
end_of_nonsep = find(s, beg_of_nonsep + 1, lambda ch, sep_chs=sep: ch in sep_chs)
^
IndentationError: unexpected indent
>>> if end_of_nonsep == -1:
File "<stdin>", line 1
if end_of_nonsep == -1:
^
IndentationError: unexpected indent
>>> end_of_nonsep = len(s)
File "<stdin>", line 1
end_of_nonsep = len(s)
^
IndentationError: unexpected indent
>>>
>>> yield (beg_of_nonsep, end_of_nonsep)
File "<stdin>", line 1
yield (beg_of_nonsep, end_of_nonsep)
^
IndentationError: unexpected indent
>>>
>>> beg_of_nonsep = end_of_nonsep + 1
File "<stdin>", line 1
beg_of_nonsep = end_of_nonsep + 1
^
IndentationError: unexpected indent
>>>
>>> split = lambda s: [s[beg: end] for (beg, end) in find_all(s)]
>>>
>>> print(split(""))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <lambda>
TypeError: 'NoneType' object is not iterable
>>> print(split(" \t\n"))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <lambda>
TypeError: 'NoneType' object is not iterable
>>> print(split(" \tssss\n"))
It ignores much of the function find_all
, so the code is completely broken. (The third print
actually never returned until I killed it with <ctrl + c>
.
However, when I use python3 ./split.py
to run the code, nothing went wrong:
[]
[]
['ssss']
It gave me exactly what I want.
Jakson, your Nvim-R and Colorout repos have been so valuable to me: thank you! Have been using both for a year+. I literally use both for 12+ hours a day. thank you
I was just poking around in the interior of colorout: wow, I had no idea how tricky that probably was...then I noticed this new repo....
My question is this: are you going to merge the Nvim-R behavior into vimcmdline
in order to unify this neovim + terminal + REPL "pattern"? Just wondering if I should keep an eye on this, and also test it.
I use both vimcmdline and nvim-R, in nvim-R i could swich between different tabs in vim-nerdtree and send lines to the same R console, but in vimcmdline, when i switch tabs, the python console also disappears.
if I use space to excute a line like "import bla", then there will be long stacktraces like below, although in fact the import actually works.
this is not an urgent issue since it indeed sucessfully completed the import and everything else works just seemingly something is wrong:
Python 3.7.1 (default, Dec 14 2018, 19:28:38)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from main import embed_cluster
Exception in default exception handler
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.7/site-packages/prompt_toolkit/eventloop/posix.py", line 154, in _run_task
t()
File "/home/user/anaconda3/lib/python3.7/site-packages/prompt_toolkit/eventloop/context.py", line 115, in new_func
return func(*a, **kw)
File "/home/user/anaconda3/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 716, in cpr_not_supported_callback
run_in_terminal(in_terminal)
File "/home/user/anaconda3/lib/python3.7/site-packages/prompt_toolkit/application/run_in_terminal.py", line 41, in run_in_terminal
return run_coroutine_in_terminal(async_func, render_cli_done=render_cli_done)
File "/home/user/anaconda3/lib/python3.7/site-packages/prompt_toolkit/application/run_in_terminal.py", line 62, in run_coroutine_in_terminal
assert app._is_running
AssertionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.7/site-packages/prompt_toolkit/eventloop/base.py", line 129, in call_exception_handler
self._exception_handler(context)
File "/home/user/anaconda3/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 692, in handle_exception
run_coroutine_in_terminal(print_exception)
File "/home/user/anaconda3/lib/python3.7/site-packages/prompt_toolkit/application/run_in_terminal.py", line 62, in run_coroutine_in_terminal
assert app._is_running
AssertionError
from main import embed_cluster
In [2]: from main import embed_cluster
In [3]:
This way, users can set their own maps and not worry about the plugin clobbering existing mappings (for example, <space>
is my leader and it gets remapped by starting vimcmdline
).
Could we get the same feature that we get in vim-r-plugin: an option to open an external terminal instead of a tmux pane ?
$ vim foo.js
"foo.js" [New File]
Error detected while processing function VimCmdLineSetApp:
line 8:
E716: Key not present in Dictionary: javascript.jsx
E15: Invalid expression: g:cmdline_job[&filetype] || g:cmdline_tmuxsname[&filetype] != "" || s:cmdline_app_pane != ''
I believe that comes from https://github.com/mxw/vim-jsx/blob/master/ftdetect/javascript.vim#L34
It seems like vimcmdline
should just ignore unknown filetypes?
for some debug, this can be particular useful.
Hi, what should I do if I do not want to use space to execute each line of a python class but instead the whole class?
Hello, would that be easy to add multiple buffer support like for vim-r-plugin ?
When I open anyfile in tmux, then get a terminal then open another buffer the second buffer cannot send lines to the console (we can do that in vim-r-plugin)
I'm using the following command in .vimrc to run a terminal in tmux pane:
let cmdline_external_term_cmd = "tmux split-window '%s'"
Is it possible to colorize for example python output (using vimcmdline
) in a tmux pane similar to nvim-R tmux pane ?
this seems to work
function StataSourceLines(lines)
call writefile(a:lines, g:cmdline_tmp_dir . "/lines.do")
call VimCmdLineSendCmd('do ' . g:cmdline_tmp_dir . '/lines.do')
endfunction
let b:cmdline_nl = "\r\n"
let b:cmdline_app = "stata"
let b:cmdline_quit_cmd = "exit"
let b:cmdline_source_fun = function("StataSourceLines")
let b:cmdline_send_empty = 0
nmap s :call VimCmdLineStartApp()
exe 'autocmd VimLeave * call delete(g:cmdline_tmp_dir . "/lines.do")'
I use kitty as my terminal emulator, with Neovim as my editor. I typically use NVim-R
for R code, which works perfectly. I just tried to get vimcmdline
working to let me have a similar setup to play with Julia, but I'm running into errors.
vimcmdline
works fine if I set my terminal to, say, xterm, but for some reason I'm getting errors (apparently related to the tmux configuration file) when I try the same in ktty.
With let cmdline_external_term_cmd = "kitty '%s' &"
I get:
Failed to launch child: tmux -2 -f "/tmp/cmdline_1573890709_joss/tmux.conf" -L VimCmdLine new-session -s vcl1573890710 julia
With error: No such file or directory
Press Enter to exit.
For convenience, I often use a wrapper command terminal
to run kitty, which just contains kitty $*
at the moment. When I set let cmdline_external_term_cmd = "terminal '%s' &"
I instead get:
"/tmp/cmdline_1573890503_joss/tmux.conf": No such file or directory
In the second case, the REPL does then appear, and I can send code to it from Neovim, but the tmux configuration file is clearly not being read, and causes an error. I've checked, and the tmux configuration file is being created.
Thinking it might be some kind of timing issue, I changed my terminal
command to sleep 1; kitty $*
, but that had no effect.
On that note, under NVim-R I much prefer to use my own .tmux.conf, and so have the let R_notmuxconf = 1
option set. Is there something similar available for vimcmdline
? If not, would it be possible to have it?
Thank you.
Having a comprehensive help pages seems to be VIM/NVIM standard for VIM plugins.
It is also very convenient to have all help in one place and not to switch to browser when you need some information about some particular features.
Please, add VIM help pages.
Feel free to close this/move to a more appropriate section, but I figured this would be the best place to discuss the commit to allow different REPLs.
It works for haskell, but (i)python support is broken. I suspect you will have to use paste mode (%cpaste), and you may want to see how vim-slime does it.
They have good handling for python but don't open the repl for you.
I tried to use vimcmdline
with conda
, however it doesn't work due to the fact that the newly created python
interpreter does not inherit the environment variable PATH
from vim
.
It works by appending /shared/conda/envs/environ_name
to environment variable PATH
.
So adding 'env PATH=' . $PATH
when launching python
through tmux
should work.
Hello this is more a question
On some ft
I'd like to be able to start different interpreters, would that be able to do ?
I was thinking about something like
let cmdline_ft['python-2'] = 'python' " python-2 will use everything python uses
let cmdline_app = {}
let cmdline_app['python'] = 'ptipython3'
let cmdline_app['python-2'] = 'somestuff'
Kind regards
I just posted the follow feature request to vimpyter
(szymonmaszke/vimpyter#17 (comment)) which I thought might also interest you. I'm primarily an R user and just found Nvim-R (and spacevim) and am very excited about both! However, I'm also using more python these days and having access to jupyter kernels (in docker containers) is super useful for reproducible research and a consistent computing environment. In case you are interested, below a link to install instructions to a docker container I use with my students.
https://github.com/radiant-rstats/docker/tree/master/install
===========================================================
Copied the issue posted to vimpyter
below for your convenience:
You may be interested in "https://github.com/mwouts/jupytext" which makes it possible to "link", e.g., a python or R(markdown) script to a jypyter notebook. You can edit the notebook and the linked file will be auto-updated. You can also edit the linked file, e.g., in (space)vim, and the notebook will be updated as well. Very nice!
I also saw the follow issue posted on 'spacevim' (SpaceVim/SpaceVim#1854) but I don't think this has happened yet but it is listed as a "milestone".
One thing that would be fantastic in vimpyter (and spacevim) would be to send Python (or R) code to a running jupyter kernel. This is something that atom + hydrogen currently does a fantastic job at. See link below
https://nteract.gitbooks.io/hydrogen/docs/Usage/GettingStarted.html
You can even connect to jupyter kernels (e.g., R and Python) running in local or remote docker containers which is something I use all the time. Works really great ... from atom ... but I would love to have this work form (space)vim.
https://github.com/nteract/hydrogen/blob/master/docs/Usage/RemoteKernelConnection.md
call VimCmdLineSendCmd('source ("' . g:cmdline_tmp_dir . '/lines.m");')
I think source is an Octave only function. The equivalent Matlab function is run.
Changing source to run allows sending multiple lines in Matlab. Without this change it does not work for me.
In Vim, when starting a session I get the error:
"Cannot start interpreter because not inside a Tmux session."
Is Tmux required for this plugin?
I am running a similar functionality that I mostly derived from your notes in vim-r-plugin. With the help of tmux/screen I send selection from my vim buffer to another tmux/screen session. This looks very similar to what your plugin seems to be doing.
Is there a possibility for the user to specify any program (would be q for me) and leverage on your plugin ?
when a selection is made in visual mode and sent by space, the whole line is sent instead of only the selection.
I tried this command.
let cmdline_app = {}
let cmdline_app['python'] = 'ssh [[email protected]](mailto:[email protected]) python'
This command run well.
As image tells us, VCL could connect external session ( ssh )
but if ssh needs password to enter, vimcmdline seems not to allow me enter it
VCM allows me to do these?
1, to use ssh public key connection? if ok, we don't need password
2, to enter password to .vimrc or init.vim? if ok, we don't have to enter it manually, but danger to security
3, to prepare making neovim's terminal mode be logged in already? as write next, I tried preparing neovim's terminal logged in before start vimcmdline, but it seems to be not good
What I want is to connect ssh session because ssh session has good machine resource.
But I don't want to run NeoVim in ssh because of overhead.
I want to run neovim ( session A, I'm here ) and want only to send code to ssh ( external session B ) for talking with interpreter .
So, I'm happy if VCL can send codes unit|block to external session like ssh.
As you know, I've been trying to figure out how to get line endings to work correctly on Windows. To experiment with this, I can set cmdline_nl to different values in Neovim interactively. But whenever I try to change this setting in my settings files, it seems to get overridden by the plugin settings.
Would it be possible to expose per-filetype line ending settings to the user in a similar way as with the cmdline_app option? This would make it easier to customize my setup.
While adding new supported languages/REPLs is known not to be a priority, are there any chances you could add support for the Scala REPL? (scala
or amm
)
The Scala REPLs have multi-line output, which is not handled that great by similar vim/nvim plug-ins, but as vimcmdline already supports Shells, it might be easier to add here?
Hi, I'm using Vim 8.1 with tmux. I have been using Nvim-R for a long while and found it very useful. Now hoping to make it work for Python, I installed and set up vimcmdline as instructed, by adding this line to my .vimrc:
let cmdline_external_term_cmd = "xterm -e '%s' &"
Then I opened an example.py file and pressed s (in my case it's \s), but there's no reaction and an external terminal was not opened.
:echo cmdline_tmuxsname
has some value of 'vcl' plus a string of numbers assigned to 'python'; :echo cmdline_job
has everything with 0 value. I'm not sure how to further debug this.
Could you please help with this? Thanks in advance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.