Skip to content

liquidz/vim-iced-multi-session

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim-iced-multi-session

vim-iced plugin

vim-iced plugin to add support for multi session.

vim-iced basically only supports connections to a single nREPL server. But if you use shadow-cljs, for example, to run backend and frontend nREPL server separately in the same project, you’ll need to launch 2 vim/nvim to connect them. It’s pain.

This plugin supports multiple nREPL connections from a single vim/nvim by allowing you to store and switch between multiple nREPL sessions.

Usage

Basically, only you should do is executing IcedConnect command as before.

vim-iced can select a REPL port to connect when Clojure project and ClojureScript project(e.g. shadow-cljs) REPLs are up. This plugin hooks the connection process, and manages multiple REPL connections.

This plugin primarily targets connecting to 2 REPLs: Clojure and ClojureScript projects. With g:iced_multi_session#does_switch_session option, this plugin automatically switches the connecting REPL when the connecting REPL is not matched to the file extension on current buffer.

If you’d like to connect to 3 or more REPLs or switch the REPL more strictly, g:iced_multi_session#definitions option is recommended.

Commands

This plugin provides following commands, and these are added to the command palette automatically.

Command Note

:IcedMultiSessionNew

Create a new session.

:IcedMultiSessionNext

Switch to the next session. If the current session is the last, switch to first one.

:IcedMultiSessionList

Display all session names.

:IcedMultiSessionSwitch

Swith to the selected session.

:IcedMultiSessionRename

Rename the current session name.

Options

Option Default Note

g:iced_multi_session#does_switch_session

v:false

If v:true, execute :IcedMultiSessionNext when expected session is different from the current file extension.

g:iced_multi_session#name_prefix

'new'

The prefix string for new session name.

g:iced_multi_session#definitions

[]

Session definitions in current project.
This option should be defined with vim-localrc.

/path/to/your/project/root/.local.vimrc
let g:iced_multi_session#definitions = [
    \ {'port_file': printf('%s/.nrepl-port', expand('<sfile>:p:h')),
    \  'path': 'src/',
    \  'name': 'web'},
    \ {'port_file': printf('%s/.shadow-cljs/nrepl.port', expand('<sfile>:p:h')),
    \  'path': 'src-cljs/',
    \  'name': 'cljs'},
    \ ]

Functions

Function Note

iced_multi_session#current

Returns a string which describe current session status. e.g. 'NREPL(shadow-cljs)'

This function can be used for showing session status on statusline. The following is a example configuration for lightline.vim.

let g:lightline = {
    \   'active': {
    \     'left': [ ... ],
    \     'right': [ ... ['iced_multi_session'], ... ]
    \   },
    \   'component_function': {
    \     'iced_multi_session': 'iced_multi_session#current',
    \   },
    \ }

Requirements

Installation

vim-plug

Plug 'liquidz/vim-iced', {'for': 'clojure'}
Plug 'liquidz/vim-iced-multi-session', {'for': 'clojure'}

Execute :PlugInstall to install above plugins.

License

Copyright (c) 2020-2021 Masashi Iizuka

Distributed under the MIT License.