Giter Site home page Giter Site logo

vim-julia-cell's Introduction

julia-cell

Cell support for Julia in Vim.

Demo animation

Requirements

This plugin requires Vim/Neovim with Python 2 or Python 3 support (+python or +python3 when running vim --version).

julia-cell uses vim-slime to send code to the Julia REPL.

The cell execution feature requires a clipboard program to be installed. xclip and xsel are supported on Linux, and pbcopy on macOS. Windows is not supported.

If vim-highlightedyank is installed, code sent to the REPL is highlighted.

Installation

Install vim-slime and julia-cell using your favorite package manager:

Using vim-plug

Plug 'jpalardy/vim-slime'
Plug 'mroavi/vim-julia-cell', { 'for': 'julia' }

Using Vundle

Plugin 'jpalardy/vim-slime'
Plugin 'mroavi/vim-julia-cell'

Usage

julia-cell sends code from Vim to a Julia REPL using vim-slime. This means that Julia has to be running in a terminal multiplexer like GNU Screen or tmux, or in a Vim/Neovim terminal.

Code cells are defined by either Vim marks or tags in the code, depending on the value of g:julia_cell_delimit_cells_by.

This plugin does not define any key mappings by default. See the Example Vim Configuration section below for examples of how to set them to the available commands.

Note that the cell execution feature copies your code to the system clipboard, which may be undesirable if your code contains sensitive data.

Commands

Command Description
:JuliaCellExecuteCell Execute the current code cell.
:JuliaCellExecuteCellJump Execute the current code cell and jump to the next cell.
:JuliaCellRun Run the entire file.
:JuliaCellClear Clear the REPL.
:JuliaCellPrevCell Jump to the previous cell header.
:JuliaCellNextCell Jump to the next cell header.

Configuration

Option Description Default
g:julia_cell_delimit_cells_by Specifies if cells are delimited by 'marks' or 'tags'. 'marks'
g:julia_cell_tag Specifies the tag format. '##'

Example

Example of how to configure julia-cell in your .vimrc.

" Load plugins using vim-plug
call plug#begin('~/.vim/plugged')
Plug 'jpalardy/vim-slime'
Plug 'mroavi/vim-julia-cell', { 'for': 'julia' }
call plug#end()

"------------------------------------------------------------------------------
" slime configuration 
"------------------------------------------------------------------------------
let g:slime_target = 'tmux'
let g:slime_default_config = {"socket_name": "default", "target_pane": "{right-of}"}
let g:slime_dont_ask_default = 1

"------------------------------------------------------------------------------
" julia-cell configuration
"------------------------------------------------------------------------------
" Use '##' tags to define cells
let g:julia_cell_delimit_cells_by = 'tags'

" map <Leader>jr to run entire file
nnoremap <Leader>jr :JuliaCellRun<CR>

" map <Leader>jc to execute the current cell
nnoremap <Leader>jc :JuliaCellExecuteCell<CR>

" map <Leader>jC to execute the current cell and jump to the next cell
nnoremap <Leader>jC :JuliaCellExecuteCellJump<CR>

" map <Leader>jl to clear Julia screen
nnoremap <Leader>jl :JuliaCellClear<CR>

" map <Leader>jp and <Leader>jn to jump to the previous and next cell header
nnoremap <Leader>jp :JuliaCellPrevCell<CR>
nnoremap <Leader>jn :JuliaCellNextCell<CR>

" map <Leader>je to execute the current line or current selection
nmap <Leader>je <Plug>SlimeLineSend
xmap <Leader>je <Plug>SlimeRegionSend

In case you want to save before running the entire file:

" map <F5> to save and run script
nnoremap <F5> :w<CR>:JuliaCellRun<CR>

Credits

  • julia-cell is and adaptation of hanschen/vim-ipython-cell.
  • This plugin uses vim-slime under the hood to communicate with the Julia REPL.
  • @FirstnameLastname came up with an initial implementation.

vim-julia-cell's People

Contributors

mroavi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vim-julia-cell's Issues

Clipboard is not updated when executing cell

I'm trying to use the plugin with tmux in macOS Catalina 10.15.4 but somehow the clipboard is not updated when I execute a cell. vim-slime is working as running :SlimeSendCurrentLine works as expected.

In the attached image you can see that clipboard() returns "last copy" which was the last thing I copied with cmd+c and it is send to Julia when I run :JuliaCellExecuteCell.

Is there something I'm doing wrong? I can provide more information if needed, thanks in advance.

Captura de Pantalla 2020-06-13 a la(s) 20 42 08

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.