Giter Site home page Giter Site logo

vim-slime-cells's Introduction

vim-slime-cells

A plugin on top of vim-slime to enhance its cell feature. It adds the possibility to jump between cells and to send the current cell then jump to the next one.

There is also a nice syntax-highlighting feature for cell boundaries.

Preview

asciicast

Installation

You need vim-slime installed.

You can use Vim-Plug:

Plug 'klafyvel/vim-slime-cells'

Or with packer (example configuration for Julia):

use {
  'klafyvel/vim-slime-cells',
  requires = {{'jpalardy/vim-slime', opt=true}},
  ft = {'julia'},
  config=function ()
    vim.g.slime_target = "tmux"
    vim.g.slime_cell_delimiter = "^\\s*##"
    vim.g.slime_default_config = {socket_name="default", target_pane="0"}
    vim.g.slime_dont_ask_default = 1
    vim.g.slime_bracketed_paste = 1
    vim.g.slime_no_mappings = 1
    vim.cmd([[
    nmap <leader>cv <Plug>SlimeConfig
    nmap <leader>cc <Plug>SlimeCellsSendAndGoToNext
    nmap <leader>cj <Plug>SlimeCellsNext
    nmap <leader>ck <Plug>SlimeCellsPrev
    ]])
  end
}

Configuration

Here is an example of how you can configure vim-slime and vim-slime-cells to work together. Those settings are used in the preview.

" vim-slime
let g:slime_target = "tmux"
let g:slime_cell_delimiter = "^\\s*##"
let g:slime_default_config = {"socket_name": get(split($TMUX, ","), 0), "target_pane": ":.1"}
let g:slime_dont_ask_default = 1
let g:slime_bracketed_paste = 1
let g:slime_no_mappings = 1
nmap <c-c>v <Plug>SlimeConfig

" vim-slime-cells
nmap <c-c><c-c> <Plug>SlimeCellsSendAndGoToNext
nmap <c-c><c-Down> <Plug>SlimeCellsNext
nmap <c-c><c-Up> <Plug>SlimeCellsPrev

Documentation

See :help slime-cells.

Credits

vim-slime is a very nice plugin developped by Jonathan Palardy.

The original idea that makes the syntax-highlighting feature in vim-slime-cells work is from @bensmrs, and the macro he came up with deserves a place here for posterity.

hi Match ctermbg=162
sig define highlightline linehl=Match
au TextChanged,TextChangedI,TextChangedP,BufWinEnter,BufWritePost,FileWritePost * if expand("%:p") != "" | exe("call map(range(1,1000), {i->execute('sig unplace 999 file='.expand('%:p'))})") | call map(getline(1, '$'), {idx, val -> execute('if val =~ "^\\s*##" | exe "sig place 999 line=".expand(idx+1)." name=highlightline file=".expand("%:p") | endif')}) | endif

vim-slime-cells's People

Contributors

klafyvel 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  avatar  avatar

vim-slime-cells's Issues

b:slime_cell_delimeter is not defined

Hi! Just want to report this error I got after adding the plugin with vim-plug.
I'm using neovim v0.8.2. OS is ubuntu 22.10. I have 'jpalardy/vim-slime' installed and is working fine. I also have 'matschaffer/vim-islime2' installed which is for when I use MacOS.

Error detected while processing function 206[2]..207[11]..217[20]..nerdtree#exec[9]..function 206[2]..207[11]..217[20]..nerdtree#exec[6]..BufEnter Autocommands for "*"..function slime_cells#sign_on_cell_boundaries
[2]..slime_cells#get_delimiter:                                                                                                                                                                                      
line    6:                                                                                                                                                                                                           
b:slime_cell_delimeter is not defined                                                                                                                                                                                
Error detected while processing function 206[2]..207[11]..217:                                                                                                                                                       
line   20:                                                                                                                                                                                                           
E171: Missing :endif                                                                                                                                                                                                 
Error detected while processing function 206[2]..207:                                                                                                                                                                
line   11:                                                                                                                                                                                                           
E171: Missing :endif    

Color issue again.

Hi

I am trying the last version of slime and cell slime and getting color issue as descrivef in #1

Error detected while processing /home/petro/.vim/bundle/vim-slime-cells/plugin/slime_cells.vim:
line 51:
E254: Cannot allocate color ctermbg=
Press ENTER or type command to continue

The outputs from below commands are:
:echo synIDattr(synIDtrans(hlID(g:slime_cells_highlight_from)), "fg", "GUI")
StateBlue
:echo synIDattr(synIDtrans(hlID(g:slime_cells_highlight_from)), "fg", "cterm")
5
:echo synIDattr(synIDtrans(hlID(g:slime_cells_highlight_from)), "bg", "GUI")
nothing
:echo synIDattr(synIDtrans(hlID(g:slime_cells_highlight_from)), "bg", "cterm")
nothing.
Any Idea what it can be.

Correct delimiter regex for quarto

(this is somewhat related to #8)

quarto qmd files use cell delimiters that look something like:

```python

or

```{python}

I'm trying to use a delimiter regex to catch both; I currently have the following but doesnt seem to be working:
vim.g.slime_cell_delimiter = "^```{?%a+}?$"

any thoughts on why that pattern doesnt seem to be matching either? does the plugin use standard regex or lua match patterns?

remove <cr>

in lines 6 through 9 in plugin/slime_cells.vim

noremap <unique> <script> <silent> <Plug>SlimeCellsNext :<c-u>call slime_cells#go_to_next_cell()<cr>
noremap <unique> <script> <silent> <Plug>SlimeCellsPrev :<c-u>call slime_cells#go_to_previous_cell()<cr>
noremap <unique> <script> <silent> <Plug>SlimeCellsSendAndGoToNext :<c-u>call slime_cells#send_cell_and_go_to_next()<cr>
noremap <unique> <script> <silent> <Plug>SlimeCellsSendAndGoToNext :<c-u>call slime_cells#send_cell_and_go_to_next()<cr>

the additional <cr> causes the cursor to go to a new line after the text is sent ,

this destorys the purpose of slime_preserve_curpos in vim-slime

Error when loading the plugin in Neovim

I'm trying to use the script in Neovim v0.4.3, but when doing so I get this error (sorry, in Spanish):

Se ha detectado un error al procesar /home/user/.vim/bundle/vim-slime-cells/autoload/slime_cells.vim:
línea   13
E475: El argumento no es válido: include_header=0) abort
línea   16
E133: ":return" no está dentro de una función
línea   39
E193: ¡":endfunction" no está dentro de una función!
The problem seems to be in the following function:

function! slime_cells#select_current_cell(include_header=0) abort
  let cell_delimiter = slime_cells#get_delimiter()
  if cell_delimiter == ""
      return
  endif

  let [line_ini, col_ini] = searchpos(cell_delimiter, 'bcnW')
  let line_end = search(cell_delimiter, 'nW')

  if !line_ini
    let line_ini = 1 
  elseif !a:include_header
    let line_ini = line_ini + 1 
    let col_ini = 1 
  end 
  " line before delimiter or bottom of file
  let line_end = line_end ? line_end - 1 : line("$")
  let col_end = strlen(getline(line_end))

  call setpos("'<", [0, line_ini, col_ini, 0]) 
  call setpos("'>", [0, line_end, col_end, 0]) 
  normal! gv
  let current_mode = mode()
  if current_mode != "V" 
    normal! V
  endif
endfunction```

This error does not happen in Vim 8.1 with the same .vim files.

feature request : fenced-block cells

Hi, thanks for the useful plugin.

I am using quarto file format where cells are similar to markdown fenced-block starting and ending with ```.

I think it would be useful (to me at least ;) ) to add support for such cells that have opening and closing delimiters.

The difference in behavior that it would introduce and that I noticed so far :

  • SlimeCells{Next,Prev} would skip closing delimiters
  • ac textobject would include the closing delimiter as well (ic is already working properly).
  • (optionnaly) the closing delimiter may be highlighted differently (for instance with an horizontal rule above instead of below the closing delimiter)

SlimeCellsSendAndGoToNext and Julia multiline comments

Currently SlimeCellsSendAndGoToNext does not handle properly julia multiline comments with two or more empty lines

MWE:

##
# Normal cell, should be executed
a = 1
##
# Commented out cell using multiline comments, should not be executed
#=


a = 2
=#
##
# test cell, should return 1, not 2
a
##

Expected output (using 3x SlimeCellsSendAndGoToNext)

julia> a
1

Actual output

ERROR: syntax: incomplete: unterminated multi-line comment #= ... =#
Stacktrace:
 [1] top-level scope
   @ none:1

julia> a = 2
2

julia> =#
ERROR: syntax: unexpected "="

Note :

Removing one of the two blank lines in the commented out cell fixes the problem.
Hope it helps improving vim-slime,

FoFuSa

Color Issue

Hi,

I am using the example installation via packer you provided on the README. Everything installs, but when I start neovim I am getting the message below.

Error detected while processing /home/username/.local/share/nvim/site/pack/packer/start/vim-slime-cells/plugin/slime_cells.vim:
line 24:
E421: Color name or number not recognized: ctermfg= guibg= ctermbg=

Thank you for the plug-in and your help.

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.