Coder Social home page Coder Social logo

vlime's Introduction

Intro

Vlime is a Common Lisp dev environment for Vim (and Neovim), similar to SLIME for Emacs and SLIMV for Vim.

It provides REPL integration, as well as omni-completions, cross reference utilities, a nice inspector, debugger support, and many other great facilities to aid you in your glorious Common Lisp hacking quest.

To get your feet wet: Quickstart

Short demo:

asciicast

Why?

  • There was no choice other than SLIMV.
  • SLIMV was written in Python on the Vim side, but I think a Lisp-and-Vimscript implementation would be awesome.
  • Vim 8 has these nice channel APIs, why not try them out?

How Does It Work?

Vlime consists of a server written in Common Lisp, and a client written in Vimscript.

The server is basically a wrapped Swank server. The extra wrapper code translates the messages from JSON to Swank commands, and vise versa.

The client handles user input, emits JSON messages, and communicates with the server via Vim channels, or Neovim Jobs.

Current State

Vlime is currently in beta state. Please beware of bugs, and file an issue if you find anything weird/unexpected (see the Contributing section below).

Dependencies

Must-have:

  • Vim 8.0.0312+ with +channel, or Neovim 0.2.2+
  • ASDF
  • Quicklisp
  • An Internet connection to install other dependencies from Quicklisp

Note that there was a bug in the channel implementation of Vim, which may cause large messages to be dropped incorrectly. This was fixed in 8.0.0312. Details.

Currently Vlime can only detect s-expressions inside parentheses. To make your life easier, use parinfer or paredit.

Supported CL Implementations

The CL implementations listed below are supported. If you tried out Vlime with an implementation not listed here, please let me know (see the Contributing section below for contact info).

Implementation  Version  Notes
-----------------------------------------------------
ABCL            1.4.0    Supported by the vlime-patched backend
Allegro CL      10.0     Tested with the Express Edition
CLISP           2.49+    No multithreading support
ECL             16.1.3   No SLDB support
CCL             1.11     
SBCL            2.1.19   
LispWorks       6.1      Tested with the Personal Edition

Quickstart

Before proceeding with the instructions shown below, please make sure Quicklisp is properly installed.

Installing using Vundle:

  1. Add Plugin 'vlime/vlime', {'rtp': 'vim/'} to your vimrc, then run :PluginInstall in Vim.
  2. Run the server: sbcl --load <your bundle dir>/vlime/lisp/start-vlime.lisp

Installing using Vim-Plug

  1. Add Plug 'vlime/vlime', {'rtp': 'vim/'} to your vimrc, then run :PlugInstall in Vim.
  2. Run the server: sbcl --load <your bundle dir>/vlime/lisp/start-vlime.lisp

Installing using dein.vim:

  1. Add call dein#add('vlime/vlime', {'rtp': 'vim/'}) to your vimrc, then run :call dein#install(['vlime']) in Vim.
  2. Run the server: sbcl --load <your bundle dir>/repos/github.com/vlime/vlime/lisp/start-vlime.lisp

Installing manually:

  1. Clone this repo.
  2. Make sure the <vlime repo>/vim/ directory is in your runtimepath (see :help rtp). You may use symlinks to point to this directory, but please don't move it from the Vlime source tree, or Vlime may not be able to automatically locate the server entry point.
  3. Run the server: sbcl --load <vlime repo>/lisp/start-vlime.lisp

If it's your first time running the server, Vlime will try to install it's dependencies via Quicklisp.

When the server is up and running, use Vim to start editing a CL source file, and type "\cc" (without the quote marks) in normal mode to connect to the server.

You can also let Vim start the server for you. See :help vlime-start-up.

See :help vlime-tutor for a tutorial on how to use the main features, and :help vlime for the full documentation.

License

MIT. See LICENSE.txt.

Contributing

The source repo for Vlime is hosted on GitHub:

https://github.com/vlime/vlime

Issues and pull requests are welcome. Please feel free to contact me at l04m33(at)gmail.com if you have any suggestions for improving Vlime.

See :help vlime-tests for a how-to on setting up and running the tests for development.

Sponsor

Sponsor

vlime's People

Contributors

aakropotkin avatar ab-10 avatar charje avatar equwal avatar fukamachi avatar hiphish avatar iamfirecracker avatar l04m33 avatar maxgyver83 avatar mpcjanssen avatar mwgkgk avatar phmarek avatar presuku avatar sjl avatar uki00a avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vlime's Issues

Vim-airline support

It should be more convenient to have these extra info in the status line:

  • The package bound to the current buffer
  • The top-level definition (function/macro/variable etc.) enclosing the cursor

One-off calls

Often I want to look up documentation, jump to definition, etc of something that's not currently written in my Lisp file. Is there a way I can look up the definition of (or jump to, etc etc) an arbitrary string without typing it into my lisp buffer, running the key mapping, then undoing the typing?

Ideally I'd be able to make a mapping like nnoremap <localleader>dd? :call VlimeDocumentationForSymbol(input("Symbol Name? "))<cr>. I looked in the Vlime source and it seems like VlimeDocumentationForSymbol() just expects one of the two magic strings "atom" or "operator"... any change we could get a separate function that could take the symbol name itself?

Cross-platform support for the vlime-sbcl backend

Currently the vlime-sbcl backend only works on Linux, due to some hard-coded platform-dependent info. For one thing, the errnos it checked are Linux-specific (Thanks Andreas!).

SBCL versions/distributions without threading support are all affected.

Maybe a compatibility layer is needed.

Help commands are not working (E149)

After a fresh installation of vlime on neovim 0.2.0-2 (on an up-to-date Arch machine) I can't open the help commands for vlime.
For example, typing :help vlime yields the following output:

E149: Sorry, no help for vlime

Vlime seems to be installed because after manually launching the sbcl server I can connect to it by typing \cc on nvim while editing a lisp file.

Sized vertical repl does not work in neovim

The following configuration works as expected.

let g:vlime_window_settings = {                                                 
        \ "repl": {                                                             
            \ "pos": "botright",                                                
            \ "vertical": v:true                                                
        \ }                                                                     
    \ }   

But, if I add a size parameter such as 80, neovim complains
E481: No range allowed: botright 80vertical split #3

I tried for about 10 minutes to make a patch for this, but I just don't know enough about vimscript.

Skip shebang line when loading file with <localleader>l

Hi, is it possible to skip the shebang line (if present) when loading the currently open file with <localleader>l?

If it's any help, slimv seems to do it like this: kovisoft/slimv@e7e4ceb

Some more details:

I have the following file:

#! /usr/bin/sbcl --script

(print (subseq sb-ext:*posix-argv* 1))

So if I run ./script.lisp hello world, the script will print ("hello" "world") to stdout.

That works, but now the shebang line (#! /usr/bin/sbcl --script) gets in the way when I use <localleader>l in vlime.

Installation issues on MacOS with Pathogen

Issue

Running sbcl --script ~/.vim/bundle/vlime/lisp/start-vlime.lisp produces the following error:

While evaluating the form starting at line 29, column 0
  of #P"/Users/seneca/.vim/bundle/vlime/lisp/load-vlime.lisp":
Unhandled VLIME::QUICKLISP-NOT-FOUND-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING
                                                        {1004A88203}>:
  Quicklisp not found. Please set up Quicklisp or install the dependencies for VLIME manually.

Full error backtrace

System

Vim 8.2 (w/ +channel)

ASDF 3.3.1

Quickstart latest version (I've verified installation by running (ql:quickload "vecto") in a fresh SBCL REPL).

SBCL 2.1.9

Running Vlime server automatically (\rr command) with CLISP fails with illegal socket-status error

Setup Steps

All steps mentioned in this issue were run on a Debian GNU/Linux 10.1 (buster).

  1. Install Vlime and Paredit.

    git clone https://github.com/l04m33/vlime.git ~/.vim/bundle/vlime
    echo 'set runtimepath^=~/.vim/bundle/vlime/vim' >> ~/.vimrc
    
    git clone https://github.com/kovisoft/paredit ~/.vim/bundle/paredit
    echo 'set runtimepath^=~/.vim/bundle/paredit' >> ~/.vimrc
    
    vim +'helptags ~/.vim/bundle/vlime/vim/doc' +'helptags ~/.vim/bundle/paredit/doc' +q
  2. Install CLISP.

    sudo apt-get update
    sudo apt-get install clisp
  3. Install Quicklisp.

    curl -O https://beta.quicklisp.org/quicklisp.lisp
    clisp -i quicklisp.lisp -x '(quicklisp-quickstart:install)'

Running Vlime Server Manually Works Fine

Running CLISP manually and then connecting to it from Vlime works fine. Here are the steps that work fine:

  1. Start Vlime server with CLISP manually.

    clisp -i ~/quicklisp/setup.lisp -i ~/.vim/bundle/vlime/lisp/start-vlime.lisp
  2. Create a new Lisp source code file with Vim.

    vim foo.lisp
  3. Connect to Vlime server from Vlime by pressing \cc. Vlime connects to Swank server successfully. The following message appears at the bottom:

    Vim Connection 1 established.
    

Running Vlime Server Automatically Fails

  1. Add the following code to ~/.vimrc:

    let g:vlime_cl_impl = "clisp"
    function! VlimeBuildServerCommandFor_clisp(vlime_loader, vlime_eval)
        return ["clisp", "-i", "~/quicklisp/setup.lisp",
                       \ "-i", a:vlime_loader,
                       \ "-x", a:vlime_eval]
    endfunction
  2. Create a new Lisp source code file with Vim.

    vim foo.lisp
  3. Run a new Vlime server and connect to it by pressing \rr. The following error appears in the split window for Vlime server's console output:

    ...
    ;;  Loading file /home/susam/.cache/common-lisp/clisp-2.49.92-unix-x64/home/susam/.vim/bundle/vlime/lisp/src/vlime-protocol.fas ...
    ;;  Loaded file /home/susam/.cache/common-lisp/clisp-2.49.92-unix-x64/home/susam/.vim/bundle/vlime/lisp/src/vlime-protocol.fas
    0 errors, 3 warnings
    ;; Loaded file /home/susam/.vim/bundle/vlime/lisp/load-vlime.lisp
    ;; Loading file /home/susam/.vim/bundle/vlime/lisp/vlime-patched.asd ...
    ;; Loaded file /home/susam/.vim/bundle/vlime/lisp/vlime-patched.asd
    ;; Loading file /home/susam/.cache/common-lisp/clisp-2.49.92-unix-x64/home/susam/.vim/bundle/vlime/lisp/src/vlime-patched.fas ...
    ;; Loaded file /home/susam/.cache/common-lisp/clisp-2.49.92-unix-x64/home/susam/.vim/bundle/vlime/lisp/src/vlime-patched.fas
    Server created: (#(127 0 0 1) 45637)
    0 errors, 0 warnings
    *** - SOCKET-STATUS on #<INPUT STRING-INPUT-STREAM> is illegal
    
    ;; swank:close-connection: NIL
    CL-USER>
    Bye.
    

    I have shown only the last 15 lines of the server's console output for the sake of brevity.

Workaround With REPL Option

  1. Add the following code to ~/.vimrc:

    function! VlimeBuildServerCommandFor_clisp(vlime_loader, vlime_eval)
        return ["clisp", "-i", "~/quicklisp/setup.lisp",
                       \ "-i", a:vlime_loader,
                       \ "-x", a:vlime_eval,
                       \ "-repl"]

    Note the additional -repl option used in the clisp command line arguments.

  2. Create a new Lisp source code file with Vim.

    vim foo.lisp
  3. Run a new Vlime server and connect to it by pressing \rr. The following output appears in the split window for Vlime server's console output:

    ;;  Loaded file /home/susam/.slime/fasl/2.24/clisp-2.49.92-unix-pc386/contrib/swank-repl.fas
    ;; Loaded file /home/susam/.slime/fasl/2.24/clisp-2.49.92-unix-pc386/contrib/swank-presentations.fas
    ;; Loading file /home/susam/.slime/fasl/2.24/clisp-2.49.92-unix-pc386/contrib/swank-fancy-inspector.fas ...
    ;;  Loading file /home/susam/.slime/fasl/2.24/clisp-2.49.92-unix-pc386/contrib/swank-util.fas ...
    ;;  Loaded file /home/susam/.slime/fasl/2.24/clisp-2.49.92-unix-pc386/contrib/swank-util.fas
    ;; Loaded file /home/susam/.slime/fasl/2.24/clisp-2.49.92-unix-pc386/contrib/swank-fancy-inspector.fas
    ;; Loading file /home/susam/.slime/fasl/2.24/clisp-2.49.92-unix-pc386/contrib/swank-c-p-c.fas ...
    ;; Loaded file /home/susam/.slime/fasl/2.24/clisp-2.49.92-unix-pc386/contrib/swank-c-p-c.fas
    ;; Loading file /home/susam/.slime/fasl/2.24/clisp-2.49.92-unix-pc386/contrib/swank-arglists.fas ...
    WARNING: Test failed: (&KEY #'#'+) => "(&key (function  #'+))"
             Expected: One of: "(&key (function #'+))", "(&key (function (function
             +)))"
    ;; Loaded file /home/susam/.slime/fasl/2.24/clisp-2.49.92-unix-pc386/contrib/swank-arglists.fas
    ;; Loading file /home/susam/.slime/fasl/2.24/clisp-2.49.92-unix-pc386/contrib/swank-fuzzy.fas ...
    ;; Loaded file /home/susam/.slime/fasl/2.24/clisp-2.49.92-unix-pc386/contrib/swank-fuzzy.fas
    

    I have shown only the last 15 lines of the server's console output for the sake of brevity.

  4. The following error appears in the split window for sldb:

    Thread: 0; Level: 1
    
    SOCKET-STATUS on #1=#<INPUT STRING-INPUT-STREAM> is illegal
       [Condition of type SYSTEM::SIMPLE-STREAM-ERROR]
    
    Restarts:
      0.  SOCKET-STATUS    - Return from socket-status.
      1. *ABORT            - Return to SLIME's top level.
      2.  CLOSE-CONNECTION - Close SLIME connection.
      3.  ABORT            - Abort main loop
    
    Frames:
      0.  <1/249> #<SYSTEM-FUNCTION SOCKET-STATUS> 3
    [246] frame binding variables (~ = dynamically):
      | ~ SYSTEM::*ACTIVE-RESTARTS* <-->
    (#S(RESTART :NAME ABORT :TEST #<COMPILED-FUNCTION SYSTEM::DEFAULT-REST..
      1.  [243] catch frame for tag #:SIMPLE-RESTART-30868
      2.  <1/238> #<COMPILED-FUNCTION SWANK/BACKEND:WAIT-FOR-INPUT>
    - #<COMPILED-FUNCTION SWANK/BACKEND:WAIT-FOR-INPUT>
      3.  <1/233> #<COMPILED-FUNCTION SWANK/BACKEND:WAIT-FOR-INPUT>
    - (#<IO BUFFERED SOCKET-STREAM (UNSIGNED-BYTE 8) 127.0.0.1:41651> #<INPUT STRING-INPUT-STREAM>)
      4.  <1/227> #<COMPILED-FUNCTION SWANK::REPL-INPUT-STREAM-READ>
    - #<COMPILED-FUNCTION SWANK::MAKE-REPL-INPUT-STREAM-1>
      5.  <1/224> #<COMPILED-FUNCTION SWANK::MAKE-REPL-INPUT-STREAM-1>
    - #<COMPILED-FUNCTION SWANK::MAKE-REPL-INPUT-STREAM-1>
      6.  <1/221> #<COMPILED-FUNCTION #:|137 150 (DEFMETHOD STREAM-READ-CHAR (#) ...)-15-1-1-1|>
    - #<COMPILED-FUNCTION #:|137 150 (DEFMETHOD STREAM-READ-CHAR (#) ...)-15-1-1-1|>
      7.  <1/219> #<COMPILED-FUNCTION #:|1407 1411 (DEFINTERFACE CALL-WITH-LOCK-HELD (LOCK FUNCTION) ...)-171-3-1|>
    - #<COMPILED-FUNCTION #:|1407 1411 (DEFINTERFACE CALL-WITH-LOCK-HELD (LOCK FUNCTION) ...)-171-..
      8.  <1/214> #<COMPILED-FUNCTION SWANK/BACKEND:CALL-WITH-LOCK-HELD>
    [212] compiled block frame for STREAM-READ-CHAR
      9.  <1/207> #<COMPILED-FUNCTION #:|137 150 (DEFMETHOD STREAM-READ-CHAR (#) ...)-15-1-1|>
    <2/207> #<STANDARD-GENERIC-FUNCTION STREAM-READ-CHAR>
    <3/207> #<STANDARD-GENERIC-FUNCTION STREAM-READ-CHAR>
    - #<SWA..
      10. <1/187> #<SYSTEM-FUNCTION READ>
    [183] handler frame for conditions SWANK::END-OF-REPL-INPUT
      11. <1/174> #<COMPILED-FUNCTION SWANK::SIMPLE-REPL>
    [174] frame binding variables (~ = dynamically):
      | ~ SWANK:*SLDB-QUIT-RESTART* <--> NIL
      12. <1/162> #<COMPILED-FUNCTION SWANK::SIMPLE-SERVE-REQUESTS-1-2-1>
    - #<COMPILED-FUNCTION SWANK::SIMPLE-SERVE-REQUESTS-1-2-1>
      13. [148] catch frame for tag #:SIMPLE-RESTART-35737
      14. <1/144> #<COMPILED-FUNCTION SWANK::SIMPLE-SERVE-REQUESTS-1-2>
    - #<COMPILED-FUNCTION SWANK::SIMPLE-SERVE-REQUESTS-1-2>
      15. [143] handler frame for conditions SYSTEM::SIMPLE-INTERRUPT-CONDITION
      16. <1/138> #<COMPILED-FUNCTION SWANK/BACKEND:CALL-WITH-USER-BREAK-HANDLER>
    - #<COMPILED-FUNCTION SWANK/BACKEND:CALL-WITH-USER-BREAK-HANDLER>
      17. <1/133> #<COMPILED-FUNCTION SWANK/BACKEND:CALL-WITH-USER-BREAK-HANDLER>
    - #<COMPILED-FUNCTION SWANK::SIMPLE-SERVE-REQUESTS-1>
      18. <1/130> #<COMPILED-FUNCTION SWANK::SIMPLE-SERVE-REQUESTS-1>
    - #<COMPILED-FUNCTION SWANK::SIMPLE-SERVE-REQUESTS-1>
      19. <1/125> #<COMPILED-FUNCTION #:|859 864 (DEFINTERFACE CALL-WITH-DEBUGGER-HOOK (HOOK FUN) ...)-93-3-1|>
    - #<COMPILED-FUNCTION #:|859 864 (DEFINTERFACE CALL-WITH-DEBUGGER-HOOK (HOOK FUN) ...)-93-3-1|>
    
  5. Despite the above error, Vlime connects to the server successfully and the following message appears at the bottom:

    Vlime Connection 1 established.
    

    The connection is successful due to the additional -repl option used in step 1 which is documented to:

    Start an interactive read-eval-print loop[2] after processing the -c, -x, and lisp-file options and on any ERROR[18] SIGNAL[22]ed during that processing.

Issue

In the last two sections, we see the SOCKET-STATUS on #<INPUT STRING-INPUT-STREAM> is illegal error. Why does this error occur and how can we avoid it?

Perf improvement wanted for vlime#ui#CurArgPos()

A recent :profile run gave me this for a ~400 line file:

FUNCTION  vlime#ui#CurArgPos()
    Defined: .../vlime/vim/autoload/vlime/ui.vim:1102
Called 7 times
Total time:   3.112130
 Self time:   3.112130

count  total (s)   self (s)
    7              0.000045     let s_pos = get(a:000, 0, v:null)
    7              0.000018     let arg_pos = -1
                            
    7              0.000031     if type(s_pos) == type(v:null)
                                    let [s_line, s_col] = searchpairpos('(', '', ')', 'bnW')
    7              0.000009     else
    7              0.000026         let [s_line, s_col] = s_pos
    7              0.000008     endif
    7              0.000019     if s_line <= 0 || s_col <= 0
                                    return arg_pos
    7              0.000007     endif
                            
    7              0.000032     let cur_pos = getcurpos()
    7              0.000019     let paren_count = 0
    7              0.000017     let last_type = ''
                            
 1211              0.001056     for ln in range(s_line, cur_pos[1])
 1204              0.001902         let line = getline(ln)
 1204              0.002236         let start_idx = (ln == s_line) ? (s_col - 1) : 0
 1204              0.001299         if ln == cur_pos[1]
    7              0.000034             let end_idx = min([cur_pos[2], len(line)])
    7              0.000017             if cur_pos[2] > len(line)
    2              0.000006                 let end_itr = end_idx + 1
    5              0.000003             else
    5              0.000005                 let end_itr = end_idx
    7              0.000005             endif
 1197              0.000546         else
 1197              0.001704             let end_idx = len(line)
 1197              0.001294             let end_itr = end_idx + 1
 1204              0.000525         endif
                            
 1204              0.001143         let idx = start_idx
46753              0.038945         while idx < end_itr
45549              0.034736             if idx < end_idx
44350              0.051868                 let ch = line[idx]
 1199              0.001552             elseif idx < len(line)
                                            break
 1199              0.000519             else
 1199              0.000878                 let ch = "\n"
45549              0.017809             endif
                            
45549              1.784265             let syntax = map(synstack(ln, idx), 'synIDattr(v:val, "name")')
                            
45549              0.170628             if len(syntax) != 0 && syntax[0] =~ '^lispComment'
                                            " do nothing
45171              0.068774             elseif ch == ' ' || ch == "\<tab>" || ch == "\n"
20353              0.028993                 if last_type != 's' && last_type != ')' && paren_count == 1
    7              0.000016                     let arg_pos += 1
20353              0.008339                 endif
20353              0.017246                 let last_type = 's'
24818              0.018264             elseif ch == '('
 1057              0.001245                 let paren_count += 1
 1057              0.001246                 if last_type == '(' && paren_count == 2
                                                let arg_pos += 1
 1057              0.000448                 endif
 1057              0.000887                 let last_type = '('
23761              0.016923             elseif ch == ')'
 1045              0.001217                 let paren_count -= 1
 1045              0.000852                 if paren_count == 1
   38              0.000048                     let arg_pos += 1
 1045              0.000430                 endif
 1045              0.000857                 let last_type = ')'
22716              0.010078             else
                                            " identifiers
22716              0.042731                 if last_type != 's' && last_type != ')' && last_type != 'i' && paren_count == 1
    7              0.000020                     let arg_pos += 1
22716              0.009521                 endif
22716              0.019390                 let last_type = 'i'
45549              0.019133             endif
                            
45549              0.040517             let idx += 1
46753              0.021719         endwhile
                            
 1204              0.001004         let last_type = 's'
 1211              0.000598     endfor
                            
    7              0.000017     return arg_pos

That's 3 CPU seconds, mostly for the inner loop code which is run 45000 times...

Perhaps we can improve performance in some way?

Please provide slimv-compatible keyboard bindings

That would allow much easier transitioning/testing of your plugin.

I'd hope for some config setting that determines whether traditional vlime or slimv compatible ones are installed.

Thank you so much for considering this!

Consider using the echo area for arglists?

I love having the arglist buffer, but it's a little annoying that it's an actual buffer/window that I have to manage (e.g. when I <c-w>H to move a window to the left side of the screen it also resizes the arglist window). Would it be possible to do something like echodoc does to put the arglist in the echo area instead? If not, no worries.

*vlime-home* on windows bug & fix

On windows I had to add :host in make-pathname in start-vlime.lisp and load-vlime.lisp otherwise i would get errors when loading start-vlime.lisp :

`

(defparameter vlime-home
(make-pathname :directory (pathname-directory load-truename)
:device (pathname-device load-truename)
:host (pathname-host load-truename)

`

Thanks for developing this wonderful vim plugin!

Error when leaving "Set package:" buffer (\p)

; Set package:
cl-user
~
~
vlime | input | Vlime Connection 1 | Set package: 2,7 All
Error detected while processing BufWinLeave Autocommands for "<buffer=3>":
E937: Attempt to delete a buffer that is in use
Press ENTER or type command to continue

Connecting to running Swank server?

I have a compiled application (Nyxt browser) which includes a Swank server that I can start on a given port. I would like to connect Vlime to that server, but either I am doing it wrong or there is something broken. Here is what I did:

  • Start Nyxt and execute start-swank (starts the Swank server on port 4006)
  • Start Neovim, open a Lisp buffer and press <localleader>cc
  • I enter 127.0.0.1 and 4006 and the host and port respectively.
  • Try to send (+ 2 3) to the REPL by pressing <localleader>si, entering the expression and hitting <CR>

At this point I get an error:

Error detected while processing function vlime#ui#input#FromBufferComplete[14]..<lambda>28[1]..<SNR>207_CheckInputValidity[2]..<lam
bda>29[1]..vlime#ui#WithBuffer[19]..<SNR>192_SendToREPLInputComplete:
line    2:
E716: Key not present in Dictionary: "ListenerEval, [a:content, function('s:OnListenerEvalComplete')]))"
E116: Invalid arguments for function function
E116: Invalid arguments for function vlime#WithThread
Error detected while processing function vlime#ui#input#FromBufferComplete[14]..<lambda>28[1]..<SNR>207_CheckInputValidity:
line    2:
E171: Missing :endif

Afterwards the REPL buffer opens, but all it contains is

SWANK, remote 127.0.0.1:4006
============================
--

No expressions have been evaluated.

If I understand the documentation correctly, the Vim plugin does not communicate with the Swank server directly, but with a Vlime server, which then communicated with the Swank server. Is there a way of starting the Vlime server from within Vim and telling it to connect to the existing Swank server? Patching Nyxt to include the Vlime server is something I would very much want to avoid.

vlime#Connect: failed to open channel

Hi, I'm using neovim v0.2.2 and SBCL 1.3.1.debian. I start the server as in the readme and open a lisp file in neovim. Then I run the \cc command but I get the error vlime#Connect: failed to open channel. I don't seem to have a firewall running or anything like that. Searching online for the error message was unfruitful.

Has anybody ever seen this bug?

`flet`/`labels` indent incorrectly

flet and labels currently indent like this:

(flet ((foo (a)
            (1+ a)))
  (foo 10))

but the function bodies should indent only two spaces:

(flet ((foo (a)
         (1+ a)))
  (foo 10))

This is an edge case that I had to hack around in my previous lisp indent script, so vlime probably needs to do something similar.

Allow the use of external terminals.

Rather than trying to bring the terminal into vim (unless your Neovim) just use an external one. The current buffer style thing won't work in all circumstances (such as with a full TUI), and can leave a mess of buffers everywhere. Just sending the code to the already open terminal would fix many of these issues.

non-CL dialetcts and porting guide?

Hello...
Which parts if vlim, if any, are CL-specific, as opposed to other dialect? I'd like to add vlim support to my own Lisp implementation. If I write a Swank server, does this suffice? Does vlim itself expect and parse certain special forms (in-package, defun, etc.) so that code completion/x-ref will not work if I use another dialect that uses alternate package and definition macros/forms? If so, can this be changed declaratively or would it require code changes?

thanks

Yanking more things

I've been using Vlime for a few days now and one of the things I find myself constantly wanting to do is to yank an object from the inspector or debugger so I can poke at it further. I know I can use \y in the REPL to yank things there, but is there a way to do the same from the inspector or debugger?

Request consideration to "rename" the project

"vlime" seems to be a carry-over from SLIME, probably because "vlime" (currently) depends on SLIME for SWANK.
That might not hold true in the future and hence I request that you consider renaming the project to something more Vim-like.
My suggestion is "vicle" for "Vim Common Lisp Environment", rhymes with pickle. ;-)

Neovim issues

Hey I’m loving the plugin, and it runs pretty smoothly in Neovim.
There are some small issues though. For instance the interactive mode is non-functional. I can’t precisely track down the cause but I have a feeling its an issue with remapping , if this is the case i think it should be a relatively easy fix.

Clearing the REPL often dumps errors, i think it is trying to evaluate parts of the buffer as vimcript?

Finally REPL and other additional windows do not “scroll to bottom” when new linea appear, i usually need to swap my window and jump to the bottom of the buffer with G.

On the whole i absolutely love the plugin and want to thank you for your incredible work.
Im more than happy to put in time to put in time to fix these for a merge; I just wanted to check in for some direction.

Jump to definition without opening new tab

When I run xd to jump to a definition Vlime will focus the buffer's window if one currently exists, otherwise it opens a new tab page. I never use tabs in Vim and would ideally like it to open in the buffer I just left like Vim's <ctrl-]>, e.g.:

  1. I'm in a window and have my cursor on something.
  2. I press <localleader>xd.
  3. It opens the xref window thing.
  4. I press <cr> to pick one.
  5. It opens the location in the same window from step 1.

Ideally I'd also like two extra things:

  • Close the xref window after I jump, to reduce clutter.
  • If there's only one result, don't bother opening the xref window and making me press return, just jump to that one result.

Is there some way I can implement this stuff myself, or would it require changing Vlime?

Indentation with = does not honor indent_keywords

Hi,

when I enter code manually the auto-indent works fine. Following the example from the docs:

(multiple-value-bind
    a
    b
  c
  d
  e)

However, when I want to indent a block of code that has gone out-of-sync the results neither honor g:vlime_indent_keywords, nor g:vlime_default_indent_keywords. As an example, when I select the form given above and press = the result is

(multiple-value-bind
  a
  b
  c
  d
  e)

I tested it on a fresh .vim config with only Vundle in it. Am I missing something?

Avoid breaking paredit's electric return

Paredit.vim imaps <cr> to provide its electric return functionality: https://github.com/kovisoft/paredit/blob/master/plugin/paredit.vim#L205-L208

Vlime currently also imaps <cr> to show the argument list of the function. It would be nice if Vlime could detect when the user has paredit's electric return enabled and call PareditEnter() to avoid breaking that feature.

Normally I'd be against hacking in special-case support for other plugins, but I think Paredit is a good exception to that rule.

Compile/Send Toplevel Form

I've been playing around with Vlime a bit and wondering about a few things. I'll just brain dump them here into Github and maybe you can help.

I know about the oe and se commands to send the expression under the cursor, but 95% of the time what I really want is to send the entire toplevel form without having to manually move my cursor up to the top of the (defun ...) or whatever.

What's the proper way to do this with Vlime? I can use vim-sexp to select the toplevel form, should I just do that and then call VlimeCompileCurThing("selection")? Or is that function an internal implementation detail I shouldn't rely on.

In general it would be good to have some documentation about the public API of Vlime and what users should use if they want to script things.

Quicklisp not found

I've installed Quicklisp and yet when I launch the server it's complaining that Quicklisp can't be found.

➜  ls ~/quicklisp 
asdf.lisp  client-info.sexp  dists  local-projects  quicklisp  setup.lisp  tmp

➜  sbcl --load ~/.vim/bundle/vlime/lisp/start-vlime.lisp
This is SBCL 1.4.1, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
While evaluating the form starting at line 29, column 0
  of #P"/home/derek/.vim/bundle/vlime/lisp/load-vlime.lisp":
While evaluating the form starting at line 13, column 0
  of #P"/home/derek/.vim/bundle/vlime/lisp/start-vlime.lisp":

debugger invoked on a VLIME::QUICKLISP-NOT-FOUND-ERROR in thread
#<THREAD "main thread" RUNNING {1001928083}>:
  Quicklisp not found. Please set up Quicklisp or install the dependencies for VLIME manually.

JSON communication working

For now just a heads-up that my vlime-repo has JSON communication working on the master branch.

That needs a few small changes to swank (see the slime repo here), I'll try to get them upstream.

Motivation:

  • No extra thread in the inferior lisp needed
  • Easier to port (eg. swankR could benefit)
  • Faster decoding than when decomposing S-expressions via vimscript
  • Much less (communication)-specific code (net diff is a reduction!)

Not entirely clean right now, TODO:

  • I need to define some prefix to know what is a string and what is a symbol across JSON; currently §§ is used. Better ideas?
  • Not sure whether auto-detect of encoding (( vs. [) will be accepted in upstream-swank.
  • swank needs cleanups.

Any discussion welcome, of course!

Implement the Parinfer algorithm

Request implementation of the Parinfer algorithm presented at https://shaunlebron.github.io/parinfer/
I am a neophyte to Common Lisp, but based on what I've noticed at the Parinfer webpage, it looks like a major improvement over ParEdit.
There is a supposedly not-so-clean reference implementation available at https://github.com/oakmac/parinfer-viml
Their license doesn't seem to be compatible with yours, but I guess you could always refer it to write your own from scratch!

Plugin not loaded by Neovim/Vundle because of folder structure

I installed vlime in the usual way by adding Plugin 'l04m33/vlime' to my vimrc and running :PluginInstall. This cloned the repo in the correct place, but I noticed that the plugin was not being loaded after restarting Neovim and opening a lisp buffer.

I believe the plugin was not being loaded because the top level of the plugin folder ~/.vim/bundle/vlime did not contain the expected folders autoload, doc, ftplugin, syntax, etc.

Instead, the project top-level structure of vlime is separated into two folders, lisp and vim.

I tried moving the contents of the vim folder out into the top-level, and after doing that and restarting Neovim, the basic functionality appears to be working. However, <LocalLeader>rr to have vlime start a server for me does not work because it's looking for load-vlime.lisp in the wrong directory, ~/.vim/bundle/lisp instead of ~/.vim/bundle/vlime/lisp.

EDIT: In case it helps anyone, I also ran :VundleDocs to update the helptags. This usually happens automatically when installing or updating plugins.

loading start-vlime.lisp says quicklisp isn't installed but it is

Installed all the dependencies, and started vlime, by running the following command

$ sbcl --load .vim/bundle/vlime/lisp/start-vlime.lisp
This is SBCL 1.4.2, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
While evaluating the form starting at line 29, column 0
  of #P"/home/g/.vim/bundle/vlime/lisp/load-vlime.lisp":
While evaluating the form starting at line 13, column 0
  of #P"/home/g/.vim/bundle/vlime/lisp/start-vlime.lisp":

debugger invoked on a VLIME::QUICKLISP-NOT-FOUND-ERROR in thread
#<THREAD "main thread" RUNNING {1005F41213}>:
  Quicklisp not found. Please set up Quicklisp or install the dependencies for VLIME manually.


Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY   ] Retry EVAL of current toplevel form.
  1: [CONTINUE] Ignore error and continue loading file "/home/g/.vim/bundle/vlime/lisp/load-vlime.lisp".
  2: [ABORT   ] Abort loading file "/home/g/.vim/bundle/vlime/lisp/load-vlime.lisp".
  3:            Retry EVAL of current toplevel form.
  4:            Ignore error and continue loading file "/home/g/.vim/bundle/vlime/lisp/start-vlime.lisp".
  5:            Abort loading file "/home/g/.vim/bundle/vlime/lisp/start-vlime.lisp".
  6:            Ignore runtime option --load ".vim/bundle/vlime/lisp/start-vlime.lisp".
  7:            Skip rest of --eval and --load options.
  8:            Skip to toplevel READ/EVAL/PRINT loop.
  9: [EXIT    ] Exit SBCL (calling #'EXIT, killing the process).

(VLIME::INSTALL-WITH-QUICKLISP :VLIME)
   source: (ERROR (MAKE-CONDITION 'QUICKLISP-NOT-FOUND-ERROR :PACKAGE PACKAGE))

I just installed quicklisp and it has a folder in my $HOME.
I am new to Common Lisp, how do I fix this?

Failure to enter debugger

When evaluating (for example using \ss)

(concatenate 'string '("blabla"))

fails to open debugger for the TYPE-ERROR, it does nothing and whole vlime server is stuck, must be restarted. Other errors are handled fine.

SBCL: 1.4.9 on Linux x64
Vlime: master
NeoVIM: v0.3.3

Input buffer: Attempt to delete a buffer that is in use

When submitting the input buffer with Return, following error happens:

Error detected while processing BufWinLeave Autocommands for "<buffer=5>":
E937: Attempt to delete a buffer that is in use: vlime | input | Vlime Connection 1 | Input string:

The value does go through however.

Tested with following .vimrc with an empty .vim/ directory besides plug.vim:

set nocompatible

call plug#begin('~/.vim/plugs/')

Plug 'vlime/vlime'

call plug#end()

Launching a repl with <LocalLeader>rr, and sending e.g. this:

(read-line *query-io*)

;;

More data:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jan 26 2020 11:45:38)
Included patches: 1-148
Compiled by Arch Linux
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_old_static
+arabic            +file_in_path      +mouse_urxvt       -tag_any_white
+autocmd           +find_in_path      +mouse_xterm       +tcl/dyn
+autochdir         +float             +multi_byte        +termguicolors
-autoservername    +folding           +multi_lang        +terminal
+balloon_eval      -footer            -mzscheme          +terminfo
+balloon_eval_term +fork()            +netbeans_intg     +termresponse
+browse            +gettext           +num64             +textobjects
++builtin_terms    -hangul_input      +packages          +textprop
+byte_offset       +iconv             +path_extra        +timers
+channel           +insert_expand     +perl/dyn          +title
+cindent           +job               +persistent_undo   +toolbar
+clientserver      +jumplist          +popupwin          +user_commands
+clipboard         +keymap            +postscript        +vartabs
+cmdline_compl     +lambda            +printer           +vertsplit
+cmdline_hist      +langmap           +profile           +virtualedit
+cmdline_info      +libcall           +python/dyn        +visual
+comments          +linebreak         +python3/dyn       +visualextra
+conceal           +lispindent        +quickfix          +viminfo
+cryptv            +listcmds          +reltime           +vreplace
+cscope            +localmap          +rightleft         +wildignore
+cursorbind        +lua/dyn           +ruby/dyn          +wildmenu
+cursorshape       +menu              +scrollbind        +windows
+dialog_con_gui    +mksession         +signs             +writebackup
+diff              +modify_fname      +smartindent       +X11
+digraphs          +mouse             +sound             -xfontset
+dnd               +mouseshape        +spell             +xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        +mouse_gpm         +statusline        +xsmp_interact
+eval              -mouse_jsbterm     -sun_workshop      +xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
SBCL 2.0.0
~/.vim/plugs/vlime git log --oneline -n 1
64e6220 (grafted, HEAD -> master, origin/master, origin/HEAD) Merge pull request #50 from vlime/fix/vim-tests

Howto connect to stumpwm REPL (swank)

Hi,
I'm running stumpwm as a windowmanager and I'd like to connect to the swank server.

I tried this with:

:call vlime#plugin#ConnectREPL("127.0.0.1", 4004)

It seems to work but I do not get any output in the repl if I try to send an expression to the REPL.
After a few tries I get the following error, neovim asks me which connection I want to use (there is only one)
When I choose, I get the following error:


Error detected while processing function vlime#plugin#SendToREPL[6]..vlime#ui#input#MaybeInput[33]..<SNR>188_CheckInputValidity[2]..<SNR>175_SendToREPLInputComplete[2]..vlime#WithThread[4]..vlime#ListenerEval[9]..vlime#Send[3]..vlime#comp
at#ch_sendexpr[2]..vlime#compat#neovim#ch_sendexpr:                                                                                                                                                                                           
line    3:                                                                                                                                                                                                                                    
E900: Invalid job id                                                                                                                                                                                                                          
Error detected while processing function vlime#plugin#SendToREPL[6]..vlime#ui#input#MaybeInput[33]..<SNR>188_CheckInputValidity:                                                                                                              
line    2:                                                                                                                                                                                                                                    
E171: Missing :endif                                                                                                                                                                                                                          
Error detected while processing function vlime#plugin#SendToREPL[6]..vlime#ui#input#MaybeInput:                                                                                                                                               
line   33:                                                                                                                                                                                                                                    
E171: Missing :endif

Thanks for your help and great plugin,
Arjen

Inspector `p` doesn't get buffer mapped if `p` is globally mapped

I use miniyank to handle yanking and pasting in most buffers, and have something like nnoremap p ... in my vimrc. Vlime's inspector window doesn't map its p buffer-local mapping unless I remove this global one. Vlime seems to be trying to be "helpful" and not mapping keys that are already mapped, even for windows like the inspector and debugger that aren't editable.

What's the right way for me to work around this? Unmap my keys, run map foo to see what internal Vlime function it's calling, remap my keys, and remap the Vlime key in an autocommand? Is there an easier way?

Error while using Allegro Common Lisp 10.1

An error:
Illegal form for host name: #(127 0 0 1)
is raised while loading start-vlime.lisp in Allegro Common Lisp (alisp) via evaluating:
(load "start-vlime")
in the vlime directory.

Version:

International Allegro CL Enterprise Edition
10.1 [64-bit Linux (x86-64)] (Mar 15, 2017 19:58)
Copyright (C) 1985-2017, Franz Inc., Oakland, CA, USA.  All Rights Reserved.

Incorrect yanking behaviour with <LocalLeader>y

let @" = '(swank:lookup-presented-object ' . p_coord['id'] . ')'

This code does not take into consideration the case when the user has the following setting:

set clipboard^=unnamed,unnamedplus

In this case pasting is carried out from "+ and "* registers, not ""

vlime not installing in gVim

I'm running Windows 10 and gVim 8.0 x64 and am installing vlime using vundle. Even help vlime does not work in the gvim client. However, in the terminal version of vim 8.0 in MSYS2 vlime seems to load just fine. The lisp server appears to start correctly as well.

The fix described in previous threads (appending {'rtp': 'vim/'} to the appropriate line in the .vimrc) has been applied.

EDIT: Bindings associated with vlime are not working in the terminal version of Vim either - it seems only the help file is being loaded correctly.

Sending to the REPL immediately after connection uses `CL-USER` package

99% of the time Vlime manages to autodetect the correct package for my Lisp buffers, but there's one case that trips it up. If I start the Vlime server in another window (and quickload my project from there), then open (n)vim, connect with \cc and immediately try to send with \ss it will use the CL-USER package. If I send again with \ss it works correctly, and if I open new buffers it also works. It just seems to be that first time I try to send after connecting.

Closing the preview window

Is there a way to close the Vlime preview window without manually moving over to it, :qing, and manually moving back to where I was? Doing this dance every time I want to view a docstring is really painful.

If I had a huge monitor I could just leave all various Vlime buffers open in dedicated windows all the time, but I use a laptop need to keep things uncluttered if I want to be able to get anything done.

start-vlime.lisp error on OSX

Hi,

I'm getting this error when I do the initial setup:

sbcl --load <path_to_vlime>/lisp/start-vlime.lisp
; file: <path_to_vlime>/lisp/src/aio-sbcl.lisp
; in: DEFUN AIO-SBCL:TCP-CONNECT
;     (HANDLER-CASE
;      (SB-BSD-SOCKETS:SOCKET-CONNECT SB-BSD-SOCKETS:SOCKET AIO-SBCL::HOST
;                                     AIO-SBCL::PORT)
;      (AIO-SBCL::OPERATION-IN-PROGRESS NIL
;       (SETF (AIO-SBCL:AIO-FD-WRITE-HANDLE AIO-SBCL::AFD)
;               (SB-SYS:ADD-FD-HANDLER AIO-SBCL::FD :OUTPUT
;                                      #'AIO-SBCL::SOCKET-CONNECT-CB)))
;      (SB-BSD-SOCKETS:SOCKET-ERROR (AIO-SBCL::C)
;                                   (AIO-SBCL:AIO-FD-CLOSE AIO-SBCL::AFD)
;                                   (ERROR AIO-SBCL::C)))
; --> SB-INT:DX-FLET FLET BLOCK SB-INT:DX-LET LET TAGBODY 
; --> SB-IMPL::%HANDLER-BIND SB-INT:DX-FLET FLET BLOCK 
; ==>
;   (TYPEP CONDITION 'AIO-SBCL::OPERATION-IN-PROGRESS)
; 
; caught STYLE-WARNING:
;   undefined type: AIO-SBCL::OPERATION-IN-PROGRESS
; 
; compilation unit finished
;   Undefined type:
;     AIO-SBCL::OPERATION-IN-PROGRESS
;   caught 1 STYLE-WARNING condition
  <INFO> [20:01:59] vlime - Server created: (#(127 0 0 1) 7002)

I'm using SBCL on OSX.

Vlime/Swank Security

There's been an open issue on SLIME for a while about how it's terribly insecure, and I'm pretty sure Vlime works similarly: slime/slime#286

I think this is mostly out of your hands and will need to wait for Swank to get support for something like Unix domain sockets, but I figured I'd bring it up so it's on your radar.

I did notice that start-vlime.lisp by default seems to start a swank listening on 0.0.0.0, which seems even more insecure. Is there a way to tell start-vlime.lisp to listen only on localhost instead? It's not perfect (as described in that issue, attackers can still use a browser to attack those listeners) but it's better than just exposing a REPL to the internet.

Question: How to close connection from the server side?

Problem: StumpWM restart (including forced one on certain errors) complains the (hardcoded) socket is busy and the whole thing hangs. A sane way of dealing with this would be to use some machinery that would pick a free socket when running vlime:main.

However, there's also a *restart-hook* that we could use to perhaps close the connection or, handle the situation more gracefully in some other way. The closest thing I've found is connection-close from vlime-connection.lisp, which requires a connection object, which however I'm not sure how to acquire: vlime:main seems to return nil.

Additionally, both these approaches would require handling the interrupted connection on the Vim side, which I'm also not sure how to best do.

Will be grateful for any suggestions :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.