README.adoc

May 21, 2021 ยท View on GitHub

= vim-iced-multi-session

image:https://img.shields.io/badge/iced-plugin-blue.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgICAgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiCiAgICAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiCiAgICAgdmlld0JveD0iMTAsMTAsODAsODAiPgogIDxwb2x5Z29uIGZpbGw9IiNCM0U1RkMiIHBvaW50cz0iNTAsMTAgMTAsNTAgMzAsNzAgMjAsNTAiLz4KICA8cG9seWdvbiBmaWxsPSIjOTBDQUY5IiBwb2ludHM9IjUwLDEwIDMwLDUwIDMwLDcwIDU1LDUwIi8+CiAgPHBvbHlnb24gZmlsbD0iIzgxRDRGQSIgcG9pbnRzPSI1MCwxMCA3MCw3MCA5MCw1MCIvPgogIDxwb2x5Z29uIGZpbGw9IiM2NEI1RjYiIHBvaW50cz0iNjAsNjAgMzAsNzAgNTAsOTAgNzAsNzAiLz4KPC9zdmc+Cg==["vim-iced plugin", link="https://github.com/liquidz/vim-iced"]

https://github.com/liquidz/vim-iced[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 https://liquidz.github.io/vim-iced/#command_palette[command palette] automatically.

[cols="1,3"] |=== |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

[cols="2,1,4a"] |=== | 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 https://github.com/thinca/vim-localrc[vim-localrc].

./path/to/your/project/root/.local.vimrc [source,vim]

let g:iced_multi_session#definitions = [ \ {'port_file': printf('%s/.nrepl-port', expand(':p:h')), \ 'path': 'src/', \ 'name': 'web'}, \ {'port_file': printf('%s/.shadow-cljs/nrepl.port', expand(':p:h')), \ 'path': 'src-cljs/', \ 'name': 'cljs'}, \ ]

|===

=== Functions

[cols="2,5a"] |=== | 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 https://github.com/itchyny/lightline.vim[lightline.vim]. [source,vim]

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

|===

== Requirements

== Installation

=== vim-plug

[source,vim]

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 http://twitter.com/uochan[Masashi Iizuka]

Distributed under the MIT License.