### Install vim-slime using Vim's built-in package support Source: https://github.com/jpalardy/vim-slime/blob/main/README.md Clone the vim-slime repository into the start directory of Vim's package management system. ```bash mkdir -p ~/.vim/pack/plugins/start cd ~/.vim/pack/plugins/start git clone https://github.com/jpalardy/vim-slime.git ``` -------------------------------- ### Neovim Installation and Configuration with lazy.nvim Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md Install vim-slime using lazy.nvim and configure essential options like target, input method, and default suggestions. Sets up key mappings for sending code. ```lua { "jpalardy/vim-slime", init = function() -- these two should be set before the plugin loads vim.g.slime_target = "neovim" vim.g.slime_no_mappings = true end, config = function() vim.g.slime_input_pid = false vim.g.slime_suggest_default = true vim.g.slime_menu_config = false vim.g.slime_neovim_ignore_unlisted = false -- options not set here are g:slime_neovim_menu_order, g:slime_neovim_menu_delimiter, and g:slime_get_jobid -- see the documentation above to learn about those options -- called MotionSend but works with textobjects as well vim.keymap.set("n", "gz", "SlimeMotionSend", { remap = true, silent = false }) vim.keymap.set("n", "gzz", "SlimeLineSend", { remap = true, silent = false }) vim.keymap.set("x", "gz", "SlimeRegionSend", { remap = true, silent = false }) vim.keymap.set("n", "gzc", "SlimeConfig", { remap = true, silent = false }) end, } ``` -------------------------------- ### Start Kitty with Remote Control Enabled Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/kitty.md Ensure Kitty is started with remote control enabled and specifies a listen address. This command-line option can also be added to your kitty.conf. ```sh kitty -o allow_remote_control=yes --listen-on unix:/tmp/mykitty ``` -------------------------------- ### Custom Vim-Style Mappings for Vim-Slime Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md Example of how to set custom vim-style mappings for sending code. This includes disabling default mappings and defining shortcuts for sending visual selections, motions, lines, and the entire file. ```vim " disables default bindings let g:slime_no_mappings = 1 " send visual selection xmap s SlimeRegionSend " send based on motion or text object nmap s SlimeMotionSend " send line nmap ss SlimeLineSend " send the whole file nmap sf :%SlimeSend ``` -------------------------------- ### Configure Default Tmux Socket and Target Pane Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/tmux.md Set default configuration for vim-slime when using tmux. This example uses the current tmux socket and targets the second pane of the current window. ```vim let g:slime_default_config = {"socket_name": get(split($TMUX, ","), 0), "target_pane": ":.2"} ``` -------------------------------- ### List Tmux Panes Source: https://github.com/jpalardy/vim-slime/blob/main/doc/vim-slime.txt Execute this command in your terminal to get a list of all available tmux panes, which can be useful for targeting specific panes with vim-slime. ```bash tmux list-panes -a ``` -------------------------------- ### Set Wezterm as Slime Target Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/wezterm.md Configure vim-slime to use Wezterm as the default terminal target. This is the initial setup required to enable Wezterm integration. ```vim let g:slime_target = "wezterm" ``` -------------------------------- ### Override Default Vim-Slime Mappings Source: https://github.com/jpalardy/vim-slime/blob/main/doc/vim-slime.txt Customize vim-slime's default key mappings by defining your own in your .vimrc. This example shows how to map leader+s for region and paragraph sending. ```vim xmap s SlimeRegionSend nmap s SlimeParagraphSend ``` -------------------------------- ### Get Terminal Job PID in Lua Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md A Lua function to retrieve the process ID (PID) of a terminal job in Neovim. It executes Vimscript to get the PID and handles potential errors. ```lua local function get_chan_jobpid() local out = vim.api.nvim_exec2([[ let pid_out = "" try let pid_out = string(jobpid(&channel)) " in case an external process kills the terminal's shell; jobpid will error catch /^Vim\%((\a\+)\)\,:E900/ endtry echo pid_out ]], {output = true}) return out["output"] --returns as string end ``` -------------------------------- ### Get Terminal Channel ID Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md Use this Vimscript command to display the current terminal's channel ID. ```vim :echo &channel ``` -------------------------------- ### Get Terminal Job PID Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md Use this Vimscript command to display the process ID (PID) of the current terminal job. ```vim :echo jobpid(&channel) ``` -------------------------------- ### Get Terminal Job ID in Lua Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md A Lua function to retrieve the job ID of a terminal in Neovim. It evaluates the '&channel' option. ```lua local function get_chan_jobid() return vim.api.nvim_eval('&channel > 0 ? &channel : ""') end ``` -------------------------------- ### Safely Get Terminal Job PID Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md A Vimscript function to safely retrieve the terminal job PID, handling cases where the channel might no longer exist. ```vim function! Safe_jobpid(channel_in) let pid_out = "" " in case an external process kills the terminal's shell; jobpid will error try let pid_out = string(jobpid(a:channel_in)) catch /^Vim\%((\a\+)\)\,:E900/ endtry return pid_out endfunction autocmd TermOpen * setlocal statusline=%{bufname()}%=id:\ %{&channel}\ pid:\ %{Safe_jobpid(&channel)} ``` -------------------------------- ### Set Custom Default Configuration for Screen Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md Configure vim-slime to prefill prompt answers with a default session and window name for screen sessions. ```vim " screen: let g:slime_default_config = {"sessionname": "xxx", "windowname": "0"} ``` -------------------------------- ### Send Entire File to REPL Source: https://github.com/jpalardy/vim-slime/blob/main/doc/vim-slime.txt Use the :%SlimeSend command to send all lines of the current file to the configured REPL session. ```vim :%SlimeSend. ``` -------------------------------- ### Vim Terminal Configuration Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/vimterminal.md Set custom options for the Vim terminal configuration. Refer to :help term_start() for available options. ```vim let g:slime_vimterminal_config = {options} ``` -------------------------------- ### Configure Kitty Remote Control in kitty.conf Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/kitty.md Alternatively, configure Kitty's remote control settings directly in your kitty.conf file. ```ini allow_remote_control yes listen_on unix:/tmp/mykitty ``` -------------------------------- ### Override Configuration Loading Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md Define `SlimeOverrideConfig` to programmatically set `b:slime_config` with custom configuration values, potentially using user input. ```vim function SlimeOverrideConfig() let b:slime_config = {} let b:slime_config["key"] = input("key: ", "default value") endfunction ``` -------------------------------- ### Load vim-slime with lazy.nvim Source: https://github.com/jpalardy/vim-slime/wiki/Example-configurations Load the vim-slime plugin using the lazy.nvim package manager and disable default mappings. ```lua { "jpalardy/vim-slime", lazy = false, init = function() vim.g.slime_no_mappings = 1 end }, ``` -------------------------------- ### Set Custom Default Configuration for Tmux Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md Configure vim-slime to prefill prompt answers with a default socket name and target pane for tmux sessions. ```vim " tmux: let g:slime_default_config = {"socket_name": "default", "target_pane": "1"} ``` -------------------------------- ### Enable Menu Prompt for Terminal Configuration Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md Enable a numbered menu that prompts the user to select an available terminal. This takes precedence over using the terminal's PID. ```vim let g:slime_menu_config=1 ``` -------------------------------- ### Configure R filetype mappings for vim-slime Source: https://github.com/jpalardy/vim-slime/wiki/Example-configurations Define custom key mappings for the R file type, including setting a cell delimiter and sending lines, regions, or cells. ```lua vim.g.slime_cell_delimiter = "# %%" vim.api.nvim_set_keymap("n", "a", ':execute "normal \SlimeLineSend"j', {noremap = true}) vim.api.nvim_set_keymap("v", "s", "SlimeRegionSend", {noremap = true}) vim.api.nvim_set_keymap( "n", "s", ':execute "normal \SlimeSendCell"/' .. vim.g.slime_cell_delimiter .. ":nohlsearch", {noremap = true} ) ``` -------------------------------- ### Reconfigure vim-slime target Source: https://github.com/jpalardy/vim-slime/blob/main/README.md Access the configuration prompt for vim-slime by typing Ctrl-C followed by 'v', or by executing the :SlimeConfig command. ```vim ctrl-c v _--- mnemonic: "variables" ``` ```vim :SlimeConfig ``` -------------------------------- ### Configure Vim-Slime to Use dtach Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/dtach.md Add this line to your .vimrc file to enable dtach as the target for vim-slime. You will be prompted for further configuration on first use. ```vim let g:slime_target = "dtach" ``` -------------------------------- ### Configure Vim-Slime for ConEmu Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/conemu.md Add this line to your `.vimrc` file to set ConEmu as the target for Vim-Slime. You will be prompted for further configuration the first time you use Vim-Slime after adding this setting. ```vim let g:slime_target = "conemu" ``` -------------------------------- ### Configure Vim-Slime Target to Whimrepl Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/whimrepl.md Set this option in your .vimrc to enable whimrepl as the target for Vim-Slime. You will be prompted for server configuration on first use. ```vim let g:slime_target = "whimrepl" ``` -------------------------------- ### Configure Vim-Slime with Custom Mappings Source: https://github.com/jpalardy/vim-slime/blob/main/doc/vim-slime.txt Configure vim-slime to use Vim-like mappings instead of Emacs keybindings by setting g:slime_no_mappings and defining custom mappings for line and motion sending. ```vim let g:slime_no_mappings = 1 xmap s SlimeRegionSend nmap s SlimeMotionSend nmap ss SlimeLineSend ``` -------------------------------- ### Send Single Line with Carriage Return Source: https://github.com/jpalardy/vim-slime/blob/main/doc/vim-slime.txt Use the :SlimeSend1 command followed by text to send a single line to the REPL, automatically appending a carriage return. ```vim :SlimeSend1 {text} ``` -------------------------------- ### Bypass Prompt with Default Configuration Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md Set this option to 1 to make vim-slime bypass the prompt and use the specified default configuration options directly. ```vim let g:slime_dont_ask_default = 1 ``` -------------------------------- ### Set Kitty Target for Vim-Slime Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/kitty.md Configure Vim-Slime to use Kitty as the target. This setting should be added to your .vimrc file. ```vim let g:slime_target = "kitty" ``` -------------------------------- ### Configure Default Wezterm Pane Direction Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/wezterm.md Set a default configuration for Wezterm pane direction, useful when you typically run vim in a split window with a REPL to the right. ```vim let g:slime_default_config = {"pane_direction": "right"} ``` -------------------------------- ### Configure Vim-Slime for X11 Target Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/x11.md Add this line to your `.vimrc` file to set X11 as the default target for Vim-Slime. This configuration is required before the first invocation of `vim-slime` when using X11. ```vim let g:slime_target = "x11" ``` -------------------------------- ### Configure Vim-Slime Target to Zellij Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/zellij.md Set the target for vim-slime to Zellij. This is required to enable Zellij integration. ```vim let g:slime_target = "zellij" ``` -------------------------------- ### Override Text Sending Logic Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md Implement `SlimeOverrideSend` to control how the transformed text and configuration are sent to the target, often by calling external commands. ```vim function SlimeOverrideSend(config, text) echom a:config call system("send-to-target --key " . a:config["key"], a:text) endfunction ``` -------------------------------- ### Default Vim-Slime Mappings Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md These are the default key mappings provided by vim-slime for sending code regions, paragraphs, and configuring the plugin. ```vim xmap SlimeRegionSend nmap SlimeParagraphSend nmap v SlimeConfig ``` -------------------------------- ### Enable Ammonite REPL for Scala with Vim-Slime Source: https://github.com/jpalardy/vim-slime/blob/main/ftplugin/scala/README.md Set this variable in your .vimrc to enable vim-slime integration with the Ammonite REPL. This is a global setting. ```vimscript let g:slime_scala_ammonite = 1 ``` -------------------------------- ### Customize NeoVim Terminal Menu Order and Labels Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md Define the order and labels for fields displayed in the NeoVim terminal selection menu. This uses an array of dictionaries, where keys are field names and values are the desired labels. ```vim let g:slime_neovim_menu_order = [{'name': 'buffer name: '}, {'pid': 'shell process identifier: '}, {'jobid': 'neovim internal job identifier: '}, {'term_title': 'process or pwd: '}] ``` -------------------------------- ### Enable IPython %cpaste for Python Source: https://github.com/jpalardy/vim-slime/blob/main/ftplugin/python/README.md Set this variable in your .vimrc to use IPython's %cpaste magic function for error-free code pasting into Python sessions. This is particularly important for IPython 5 and later. ```vim let g:slime_python_ipython = 1 ``` -------------------------------- ### Enable Bracketed Paste Mode Source: https://github.com/jpalardy/vim-slime/blob/main/doc/vim-slime.txt Use either the global 'g:slime_bracketed_paste' or buffer-local 'b:slime_bracketed_paste' variable to enable bracketed-paste mode. The buffer-local variable takes precedence. ```vim g:slime_bracketed_paste ``` ```vim b:slime_bracketed_paste ``` -------------------------------- ### Configure Screen Paste File Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/screen.md Configure the file used to pipe data between Vim and Screen. This file is not erased by the plugin and contains the last sent data. You can set it to a specific path or use a temporary file. ```vim let g:slime_paste_file = expand("$HOME/.slime_paste") ``` ```vim let g:slime_paste_file = tempname() ``` -------------------------------- ### Send Single Line without Carriage Return Source: https://github.com/jpalardy/vim-slime/blob/main/doc/vim-slime.txt Use the :SlimeSend0 command followed by text to send a single line to the REPL without automatically appending a carriage return. ```vim :SlimeSend0 {text} ``` -------------------------------- ### Configure Default Zellij Session and Pane Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/zellij.md Set default configuration for Zellij session ID and relative pane. This is useful for common layouts, like having a REPL to the right of your Vim pane. ```vim let g:slime_default_config = {"session_id": "current", "relative_pane": "right"} ``` -------------------------------- ### Configure Cell Delimiters for Code Blocks Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md Define a cell delimiter using `g:slime_cell_delimiter` and map `SlimeSendCell` to send code blocks as cells, similar to REPL environments. Recommended to use `b:slime_cell_delimiter` in `ftplugin`. ```vim let g:slime_cell_delimiter = "#%% " nmap sc SlimeSendCell ``` -------------------------------- ### Configure Tmux Target Pane with Special Token Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/tmux.md Configure default settings for vim-slime with tmux, using the special token '{last}' to target the most recently active pane. This provides a more dynamic pane selection. ```vim let g:slime_default_config = {"socket_name": "default", "target_pane": "{last}"} ``` -------------------------------- ### Configure Default Target in Vim Source: https://github.com/jpalardy/vim-slime/blob/main/README.md Set the default target for vim-slime to use for all buffers. If not explicitly configured, it defaults to 'screen'. ```vim " for all buffers let g:slime_target = "tmux" " and/or as a buffer-level override let b:slime_target = "wezterm" " if not explicitly configured, it defaults to `screen` ``` -------------------------------- ### Set Vim Terminal as Target Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/vimterminal.md Specify Vim terminal as the target for Vim-Slime. This is the initial step to enable terminal integration. ```vim let g:slime_target = "vimterminal" ``` -------------------------------- ### Configure Haskell Script Filetype in Vim Source: https://github.com/jpalardy/vim-slime/blob/main/ftplugin/haskell/README.md To enable the special GHCi script handler, set the filetype to `haskell.script`. This can be done manually or automatically using an autocommand in your Vim configuration. ```vim au BufRead,BufNewFile,BufNew *.hss setl ft=haskell.script ``` -------------------------------- ### Trigger vim-slime to send text Source: https://github.com/jpalardy/vim-slime/blob/main/README.md Use the key combination Ctrl-C twice to send the current paragraph (or selected text) to the configured REPL target. ```vim ctrl-c ctrl-c _--- the same as slime_ ``` -------------------------------- ### Disable Default Mappings with lazy.nvim Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md For users of lazy.nvim, disable default mappings within the plugin's configuration block using the `init` function. ```lua { "jpalardy/vim-slime", init = function() vim.g.slime_no_mappings = 1 end } ``` -------------------------------- ### Sending GHCi Scripts with Vim-Slime Source: https://github.com/jpalardy/vim-slime/blob/main/ftplugin/haskell/README.md For GHCi script files (filetype `haskell.script`), Vim-Slime uses a handler that avoids syntax translation, allowing direct execution of GHCi commands and expressions as written. This is useful for testing workflows. ```haskell (++) "This is a: " "TEST" :type (++) ``` ```haskell :{ let (++) "This is a: " "TEST" :type (++) :} ``` -------------------------------- ### Use Terminal PID for Input Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md Configure vim-slime to use the terminal's Process ID (PID) instead of NeoVim's internal job ID. This is useful when the PID is visible in the terminal buffer's name. ```vim let g:slime_input_pid=1 ``` -------------------------------- ### Set Tmux Target for Vim-Slime Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/tmux.md Configure vim-slime to use tmux as the target for sending code. This is the initial step to enable tmux integration. ```vim let g:slime_target = "tmux" ``` -------------------------------- ### Transform Haskell Code for GHCi Source: https://github.com/jpalardy/vim-slime/blob/main/ftplugin/haskell/README.md When sending normal Haskell code, Vim-Slime automatically transforms top-level bindings into a `let` binding to comply with GHCi's interactive syntax rules. This transformation requires GHC 8.0.1 or later. ```haskell -- make in triplicate f :: a -> [a] f = replicate 3 ``` ```haskell :{ let f :: a -> [a] f = replicate 3 :} ``` -------------------------------- ### Lua Function for Slime PID Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md A Lua function to retrieve the slime PID from the buffer-local variable b:slime_config. Designed for use with Neovim status line plugins. ```lua local function get_slime_pid() if vim.b.slime_config and vim.b.slime_config.pid then return vim.b.slime_config.pid else return "" end end ``` -------------------------------- ### Directional Sending with TMUX (Visual Mode) Source: https://github.com/jpalardy/vim-slime/wiki/Example-configurations Configure visual mode mappings to send regions to tmux panes relative to the current pane. ```vim xmap :exec 'let g:slime_default_config.target_pane = "{left-of}"'SlimeRegionSend xmap :exec 'let g:slime_default_config.target_pane = "{down-of}"'SlimeRegionSend xmap :exec 'let g:slime_default_config.target_pane = "{up-of}"'SlimeRegionSend xmap :exec 'let g:slime_default_config.target_pane = "{right-of}"'SlimeRegionSend ``` -------------------------------- ### Enable Bracketed Paste for Kitty in Vim-Slime Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/kitty.md Enable bracketed paste mode for Vim-Slime when using Kitty. This can be set globally in .vimrc or per-buffer in b:slime_bracketed_paste. ```vim let g:slime_bracketed_paste = 1 ``` ```vim " or let b:slime_bracketed_paste = 1 ``` -------------------------------- ### Enable Bracketed Paste for Python Source: https://github.com/jpalardy/vim-slime/blob/main/ftplugin/python/README.md Configure Vim-Slime to use bracketed paste mode for Python buffers, which is a more robust method for handling indentation than %cpaste. This can be set globally in .vimrc or per-filetype in ftplugin/python.vim. ```vim " in .vimrc let g:slime_bracketed_paste = 1 ``` ```vim " or, in ftplugin/python.vim let b:slime_bracketed_paste = 1 ``` -------------------------------- ### Override Language Text Transformations Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md Implement `SlimeOverride_EscapeText_#{language}` to customize how selected text is transformed before sending, by delegating to external scripts. ```vim function SlimeOverride_EscapeText_python(text) return system("some-command-line-script", a:text) endfunction ``` -------------------------------- ### Configure IPython Newline Separator Source: https://github.com/jpalardy/vim-slime/wiki/REPL Set the InteractiveShell.separate_in option to an empty string to remove unwanted newlines inserted by IPython between commands when using vim-slime. ```python c.InteractiveShell.separate_in = '' ``` -------------------------------- ### Set Node as Terminal Command Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/vimterminal.md Configure the Vim terminal to use 'node' as the command, typically for executing Node.js scripts. ```vim let g:slime_vimterminal_cmd = "node" ``` -------------------------------- ### Directional Sending with TMUX (Normal Mode) Source: https://github.com/jpalardy/vim-slime/wiki/Example-configurations Configure normal mode mappings to send paragraphs to tmux panes relative to the current pane. ```vim nmap :exec 'let g:slime_default_config.target_pane = "{left-of}"'SlimeParagraphSend nmap :exec 'let g:slime_default_config.target_pane = "{down-of}"'SlimeParagraphSend nmap :exec 'let g:slime_default_config.target_pane = "{up-of}"'SlimeParagraphSend nmap :exec 'let g:slime_default_config.target_pane = "{right-of}"'SlimeParagraphSend ``` -------------------------------- ### Configure vim-slime to use Wezterm Source: https://github.com/jpalardy/vim-slime/blob/main/doc/vim-slime.txt Set the 'g:slime_target' variable in your .vimrc to 'wezterm' to use Wezterm as the terminal target. You can also configure default pane direction. ```vim let g:slime_target = "wezterm" ``` ```vim let g:slime_default_config = {"pane_direction": "right"} ``` -------------------------------- ### Vimscript Functions for Slime Job ID and PID Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md These Vimscript functions safely retrieve the job ID and PID from the b:slime_config dictionary. They are intended for use in status line configurations. ```vimscript " Function to safely check for b:slime_config and return the job ID function! GetSlimeJobId() if exists("b:slime_config") && type(b:slime_config) == v:t_dict && has_key(b:slime_config, 'jobid') && !empty(b:slime_config['jobid']) " vertical bar appended to left as a separator return ' | jobid: ' . b:slime_config['jobid'] . ' ' endif return '' endfunction " Function to safely check for b:slime_config and return the pid function! GetSlimePid() if exists("b:slime_config") && type(b:slime_config) == v:t_dict && has_key(b:slime_config, 'pid') && !empty(b:slime_config['pid']) return 'pid: ' . b:slime_config['pid'] endif return '' endfunction "default statusline with :set ruler set statusline=%<%f %h%m%r%=%-14.(%l,%c%V%) %P " Append the custom function outputs to the right side of the status line set statusline+=%{GetSlimeJobId()} %{GetSlimePid()} ``` -------------------------------- ### Disable Default Vim-Slime Mappings Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md Set this variable before the plugin loads to disable all default key mappings. This is useful if you prefer to define your own custom mappings. ```vim let g:slime_no_mappings = 1 ``` -------------------------------- ### Automatic Job ID Configuration in Neovim Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md Define a Lua function to automatically find and return the job ID of the first terminal buffer. This avoids manual input when vim-slime connects. ```lua vim.g.slime_get_jobid = function() -- iterate over all buffers to find the first terminal with a valid job for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do if vim.api.nvim_get_option_value('buftype',{buf = bufnr}) == "terminal" then local chan = vim.api.nvim_get_option_value( "channel",{buf = bufnr,}) if chan and chan > 0 then return chan end end end return nil end ``` -------------------------------- ### Set Vim-Slime Target to Screen Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/screen.md Explicitly set the vim-slime target to 'screen' in your .vimrc. This ensures that vim-slime uses the screen integration method. ```vim let g:slime_target = "screen" ``` -------------------------------- ### Configure vim-slime to use Neovim Source: https://github.com/jpalardy/vim-slime/blob/main/doc/vim-slime.txt Set the 'g:slime_target' variable in your .vimrc to 'neovim' to use Neovim's terminal support. You may need to find the job_id of the Neovim terminal buffer. ```vim let g:slime_target = "neovim" ``` -------------------------------- ### Specify Frequently Used Command Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/vimterminal.md Define a frequently used command for the Vim terminal. This can be a specific program or script. ```vim let g:slime_vimterminal_cmd = "command" ``` -------------------------------- ### Set Custom Delimiter for Terminal Menu Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md Specify a custom delimiter string to separate fields in the NeoVim terminal selection menu. The default is ', '. ```vim let g:slime_neovim_menu_delimiter = ' | ' ``` -------------------------------- ### Configure vim-slime to use Vim :terminal Source: https://github.com/jpalardy/vim-slime/blob/main/doc/vim-slime.txt Set the 'g:slime_target' variable in your .vimrc to 'vimterminal' to use Vim's built-in terminal. You can configure options and specify default commands. ```vim let g:slime_target = "vimterminal" ``` ```vim let g:slime_vimterminal_config = {options} ``` ```vim let b:slime_vimterminal_cmd = "command" ``` ```vim let g:slime_vimterminal_cmd = "command" ``` ```vim autocmd FileType python let b:slime_vimterminal_cmd='python3' ``` -------------------------------- ### Disable Default Vim-Slime Mappings Source: https://github.com/jpalardy/vim-slime/blob/main/doc/vim-slime.txt Disable default vim-slime mappings by creating a mapping that does not exist. This is useful if you want to completely reconfigure the keybindings. ```vim nmap NoSlimeParagraphSend SlimeParagraphSend ``` -------------------------------- ### Lua Function for Slime Job ID Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/neovim.md A Lua function to retrieve the slime job ID from the buffer-local variable b:slime_config. Useful for status line plugins in Neovim. ```lua local function get_slime_jobid() if vim.b.slime_config and vim.b.slime_config.jobid then return vim.b.slime_config.jobid else return "" end end ``` -------------------------------- ### Auto-Close Vim Terminal Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/vimterminal.md Configure the Vim terminal to automatically close after the command finishes execution. Use 'close' for the term_finish option. ```vim let g:slime_vimterminal_config = {"term_finish": "close"} ``` -------------------------------- ### Disable Auto-indent in IPython Source: https://github.com/jpalardy/vim-slime/wiki/REPL Set this IPython option to False to prevent duplicate indentation when sending Python code from vim-slime, avoiding IndentationError. ```python c.InteractiveShell.autoindent = False ``` -------------------------------- ### Disable Cursor Position Restoration Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/advanced.md Set `g:slime_preserve_curpos` to 0 to prevent vim-slime from restoring the cursor position after execution. ```vim let g:slime_preserve_curpos = 0 ``` -------------------------------- ### Disable Auto-Matching in Radian Source: https://github.com/jpalardy/vim-slime/wiki/REPL Place this option in your radian profile to prevent auto-closing parentheses, which can cause errors when sending code from vim-slime. ```r options(radian.auto_match = FALSE) ``` -------------------------------- ### Enable Bracketed Paste Mode for Tmux Source: https://github.com/jpalardy/vim-slime/blob/main/assets/doc/targets/tmux.md Enable bracketed paste mode in vim-slime when using tmux. This can prevent issues with certain REPLs that interfere with text pasting. It can be set globally or per buffer. ```vim let g:slime_bracketed_paste = 1 ``` ```vim let b:slime_bracketed_paste = 1 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.