Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enhancement] Add an option to clear screen every time code is sent #25

Closed
jagjordi opened this issue Apr 7, 2020 · 12 comments
Closed
Labels
enhancement New feature or request

Comments

@jagjordi
Copy link

jagjordi commented Apr 7, 2020

Some times you want to run code in a clean terminal, you would do that with clear-screen command in IPython. It would be nice if some sort of setting through a global variable could be enabled so every time you send code from vim :JupyterRunFile the clear-screen command also gets send just before.

Regards.

tinmarino added a commit to tinmarino/jupyter-vim that referenced this issue Apr 7, 2020
Problem: jupyter-vim#25 'How can i send `clear-screen` before each execute_request
(exept itself)
Solution: Add string variable considered at each send request
@tinmarino
Copy link
Collaborator

tinmarino commented Apr 7, 2020

Brief: I've just coded this feature (1939006), jump to 'get-it' if you want to use it.
Reason: That is a pretty good idea. A feature like that can permit many things.
Warning: Your history will be filled of clear-screen command if we don't solve #24 before.

Now: I added 4 variables

  1. b:jupyter_exec_before: Send another command before
  2. b:jupyter_exec_pre: prepend
  3. b:jupyter_exec_post: append
  4. b:jupyter_after_after: Send another command after

Get it:

In you jupyter-vim directory:

git fetch
git check dev

In your vimrc:

autocmd FileType python let b:jupyter_exec_before = 'clear-screen'

Before: (Do not do it)

python3 _jupyter_session.client.send_save = _jupyter_session.client.send
python3 _jupyter_session.client.send = lambda cmd : _jupyter_session.client.send_save('print("pre")') and _jupyter_session.client.send_save(cmd) and _jupyter_session.client.send_save('print("post")')

After: (More implementation independent)

autocmd FileType python let b:jupyter_exec_before = 'clear-screen'

I'll try to solve #24 which will be annoying for (before|after)_each

tinmarino added a commit to tinmarino/jupyter-vim that referenced this issue Apr 7, 2020
Problem: jupyter-vim#25 'How can i send `clear-screen` before each execute_request
(exept itself)
Solution: Add a string variable that is considered at each send request
@tinmarino
Copy link
Collaborator

Tell me if you like this way. Thank you for raising the issue: for the feedback.

tinmarino added a commit that referenced this issue Apr 7, 2020
Problem: #25 'How can i send `clear-screen` before each execute_request
(exept itself)
Solution: Add a string variable that is considered at each send request
@broesler
Copy link
Collaborator

I like this idea... but should these vim variables be buffer-local so the user can set them per language? For example in iPython I use >>> !clear to clear the external shell screen, but that may vary on other interpreters.

@tinmarino
Copy link
Collaborator

tinmarino commented Apr 10, 2020 via email

@tinmarino
Copy link
Collaborator

I changed it, updated the doc and the comment above:

autocmd FileType python let b:jupyter_exec_before = 'clear-screen'

@jagjordi
Copy link
Author

I'm not sure if I am doing something wrong but after running git chechout dev the plugin commands are not recognized in vim

@tinmarino
Copy link
Collaborator

  1. :set filetype returns python ? ?
  2. :JupyterConnect exists ?

@jagjordi
Copy link
Author

jagjordi commented Apr 15, 2020

  1. Yes
  2. No

What type of log shoudl I provide to debug this?
Just to clarify, everything works fine in master branch

@tinmarino
Copy link
Collaborator

What type of log shoudl I provide to debug this?

Very good question, There is no protocol yet. The trust is in the code. You can start with loading order in this wiki or trust my 1,2,3.

1 plugin

1.5: :echo g:loaded_jupyter_vim -> 1 ? I think it's ok for you. If not the plugin is not loaded
1.6: :echo b:jupyter_kernel_type -> python

2 autoload

2.1: :call jupyter#load#MakeStandardCommands() there you should have the command

3 python

3.1/ :python3 print(_jupyter_session) -> something like <jupyter_vim.JupyterVimSession object at 0x7f15cd4e5650>

@tinmarino
Copy link
Collaborator

@jagjordi did you fix it ? How ? I added a troobleshoot wiki

@tinmarino tinmarino added the enhancement New feature or request label Apr 18, 2020
@tinmarino
Copy link
Collaborator

tinmarino commented Apr 18, 2020

The new command is JConnect (d4d85de) nobody likes typing especially vim users (good job @broesler)

@jagjordi
Copy link
Author

Sorry for the late response. Now It works fine, the problem was that I was using JupyterConnect still!!! Thank you! I guess the issue can be closed now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants