Add vim-slime and vim-ipython-cell
Added interactive python repl commands with two plugins: Sending repl snippets over with vim-slime and interacting with python (notebook-like) snippets in the editor with vim-ipython-cell. Cells are simply demarcated by `## ` at the beginning of a line, though they can have other syntaxes as well, e.g. `# %% `. By default slime sends its commands over to the last used tmux pane so it is easy to set up a split coding/repl-ing session. Interaction mappings all center around <leader>c + another key. You can send a simple cell with `<leader>cc` or `<leader>C`, single lines or selections with `<leader>cs`. You can switch between cells with `]c` `[c` and insert new ones below/above existing ones with `<leader>co` `<leader>cO` respectively.
This commit is contained in:
parent
e64df2ec3d
commit
981c4cbf10
2 changed files with 48 additions and 7 deletions
|
@ -71,16 +71,14 @@ map.n.nore[']a'] = ':next<cr>'
|
||||||
map.n.nore['[b'] = ':bprevious<cr>'
|
map.n.nore['[b'] = ':bprevious<cr>'
|
||||||
map.n.nore[']b'] = ':bnext<cr>'
|
map.n.nore[']b'] = ':bnext<cr>'
|
||||||
-- Quickfix list
|
-- Quickfix list
|
||||||
map.n.nore['[c'] = ':cprevious<cr>'
|
map.n.nore['[q'] = ':cprevious<cr>'
|
||||||
map.n.nore[']c'] = ':cnext<cr>'
|
map.n.nore[']q'] = ':cnext<cr>'
|
||||||
-- Location list
|
-- Location list
|
||||||
map.n.nore['[l'] = ':lprevious<cr>'
|
map.n.nore['[l'] = ':lprevious<cr>'
|
||||||
map.n.nore[']l'] = ':lnext<cr>'
|
map.n.nore[']l'] = ':lnext<cr>'
|
||||||
-- Hunks (from gitsigns)
|
-- Hunks (from gitsigns)
|
||||||
map.n.nore.expr['[h'] =
|
map.n.nore.expr['[h'] = [[&diff ? ']c' : '<cmd>Gitsigns prev_hunk<CR>']]
|
||||||
[[&diff ? ']c' : '<cmd>lua require("gitsigns.actions").prev_hunk()<CR>']]
|
map.n.nore.expr[']h'] = [[&diff ? '[c' : '<cmd>Gitsigns next_hunk<CR>']]
|
||||||
map.n.nore.expr[']h'] =
|
|
||||||
[[&diff ? '[c' : '<cmd>lua require("gitsigns.actions").next_hunk()<CR>']]
|
|
||||||
|
|
||||||
-- set our leader key to space since with hjkl, space is largely useless
|
-- set our leader key to space since with hjkl, space is largely useless
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
|
@ -257,3 +255,22 @@ map.n.nore['<leader>ww'] = [[:lua require 'zettelkasten'.open_index()<cr> ]]
|
||||||
-- PLUGIN: toggleterm.nvim
|
-- PLUGIN: toggleterm.nvim
|
||||||
-- create a lazygit window, set up in toggleterm settings
|
-- create a lazygit window, set up in toggleterm settings
|
||||||
map.n.nore['<leader>G'] = ':Lazygit<cr>'
|
map.n.nore['<leader>G'] = ':Lazygit<cr>'
|
||||||
|
|
||||||
|
-- PLUGIN: slime and ipython-cell
|
||||||
|
-- send line / region, not adhering to cells
|
||||||
|
map.n['<leader>cs'] = '<Plug>SlimeLineSend'
|
||||||
|
map.x['<leader>cs'] = '<Plug>SlimeRegionSend'
|
||||||
|
-- send complete script to repl / benchmark execution
|
||||||
|
map.n.nore['<leader>cr'] = ':IPythonCellRun<cr>'
|
||||||
|
map.n.nore['<leader>cR'] = ':IPythonCellRunTime<cr>'
|
||||||
|
-- send current cell / send and go to next
|
||||||
|
map.n.nore['<leader>cc'] = ':IPythonCellExecuteCellVerbose<cr>'
|
||||||
|
map.n.nore['<leader>C'] = ':IPythonCellExecuteCellVerboseJump<cr>'
|
||||||
|
-- clear ipython repl
|
||||||
|
map.n.nore['<leader>cl'] = ':IPythonCellClear<cr>'
|
||||||
|
-- jump to previous/ next cell
|
||||||
|
map.n.nore[']c'] = ':IPythonCellNextCell<cr>'
|
||||||
|
map.n.nore['[c'] = ':IPythonCellPrevCell<cr>'
|
||||||
|
-- insert cell header above/below
|
||||||
|
map.n.nore['<leader>cO'] = ':IPythonCellInsertAbove<cr>a'
|
||||||
|
map.n.nore['<leader>co'] = ':IPythonCellInsertBelow<cr>a'
|
||||||
|
|
|
@ -36,7 +36,12 @@ require("packer").startup(function()
|
||||||
'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter
|
'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter
|
||||||
requires = {'nvim-lua/plenary.nvim'},
|
requires = {'nvim-lua/plenary.nvim'},
|
||||||
tag = 'release',
|
tag = 'release',
|
||||||
config = function() require('gitsigns').setup() end,
|
config = function() require('gitsigns').setup{
|
||||||
|
keymaps = {
|
||||||
|
['n ]c'] = nil,
|
||||||
|
['n [c'] = nil,
|
||||||
|
}
|
||||||
|
} end,
|
||||||
event = "BufRead"
|
event = "BufRead"
|
||||||
}
|
}
|
||||||
use {
|
use {
|
||||||
|
@ -124,6 +129,25 @@ require("packer").startup(function()
|
||||||
-- languages
|
-- languages
|
||||||
use {'euclidianAce/BetterLua.vim', ft = 'lua'} -- better syntax highlighting for lua
|
use {'euclidianAce/BetterLua.vim', ft = 'lua'} -- better syntax highlighting for lua
|
||||||
|
|
||||||
|
-- REPL work
|
||||||
|
use {
|
||||||
|
'jpalardy/vim-slime', -- send arbitrary code chunks to REPLs
|
||||||
|
ft = "python",
|
||||||
|
config = function()
|
||||||
|
vim.g.slime_target = 'tmux'
|
||||||
|
vim.g.slime_default_config = {socket_name = "default", target_pane = "{last}"}
|
||||||
|
vim.g.slime_python_ipython = 1
|
||||||
|
vim.g.slime_no_mappings = 1
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
use { 'hanschen/vim-ipython-cell', -- send code 'cells' to REPL
|
||||||
|
ft = "python",
|
||||||
|
config = function()
|
||||||
|
vim.g.ipython_cell_highlight_cells_ft = {'python'}
|
||||||
|
vim.g.ipython_cell_insert_tag = "## Cell"
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
--
|
--
|
||||||
-- nvim plugs
|
-- nvim plugs
|
||||||
use 'Iron-E/nvim-cartographer' -- makes it easier to set mappings through lua
|
use 'Iron-E/nvim-cartographer' -- makes it easier to set mappings through lua
|
||||||
|
|
Loading…
Reference in a new issue