Skip to content

habamax/vim-ii

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim-ii: suckless ii (irc) and vim

WIP

Thin integration layer over Irc it (ii) to do irc in vim.

https://github.com/habamax/vim-ii/assets/234774/e76452f6-85ea-4a19-9530-cc8400fdb58e

Quickstart

Prerequisites:

  • GNU/Linux -- I doubt it would work on Windows, haven't tested OSX.
  • ii suckless irc client
  • tail command
  • vim9 compiled as huge

Install ii

$ git clone https://git.suckless.org/ii

Edit Makefile if you want to have a different PREFIX (I have PREFIX=$(HOME)/.local).

$ cd ii
$ make
$ make install

ii should be installed into PREFIX dir. Make sure it is in PATH.

Run ii

$ ii -s irc.libera.chat -p 6667 -n mynickname &
$ cd ~/irc/irc.libera.chat
$ echo "/j nickserv identify mynickname password" > in

Change mynickname and password to your own.

The ~/irc/irc.libera.chat directories will be created by ii automatically.

Vim

Now when ii is up and running, connected to libera.chat, in vim do:

:IIJoin irc.libera.chat #vim

to join #vim channel.

Now you are able to send and recieve messages.

Treat the windows as you normally do in Vim.

For example C-w H to make the current window split, a vertical split.

See :h windows for more information.

Quickstart 2

Shell script to connect/reconnect libera

#!/usr/bin/env sh

# https://github.com/c00kiemon5ter/iii/blob/master/connect.sh

: "${ircdir:=$HOME/irc}"
: "${nick:=$USER}"

# server info functions
libera() {
    server='irc.libera.chat'
    channels="#vim #emacs #perl #python"
}

# these match the functions above
networks="libera"

for network in $networks; do
    unset server channels port
    "$network" # set the appropriate vars

    while true; do
        # cleanup
        rm -f "$ircdir/$server/in"
        # connect to network -- password is set through the env var synonym to the network name
        ii -i "$ircdir" -n "$nick" -k "$network" -s "$server" -p "${port:-6667}" &
        pid="$!"

        # wait for the connection
        while ! test -p "$ircdir/$server/in"; do sleep .3; done

        # auth to services either using plain password stored in ident file
        # or using pass
        if [ -e "$ircdir/$server/ident" ]
            then printf "/j nickserv identify %s\n" "$(cat "$ircdir/$server/ident")" > "$ircdir/$server/in"
        else
            printf "/j nickserv identify %s\n" "$(pass libera)" > "$ircdir/$server/in"
        fi && rm -f "$ircdir/$server/nickserv/out" # clean that up - ident passwd is in there

        # join channels
        printf "/j %s\n" $channels > "$ircdir/$server/in"

        # if connection is lost reconnect
        wait "$pid"
    done &
done

vim command to open windows with 4 channels

vim9script

def Irc()
    exe "IIJoin irc.libera.chat #vim"
    wincmd o
    exe "IIJoin irc.libera.chat #python"
    wincmd L
    exe "IIJoin irc.libera.chat #perl"
    wincmd h
    exe "IIJoin irc.libera.chat #emacs"
enddef
command! Irc Irc()

About

IRC with suckless Irc it (ii) and vim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published