Commit 28defd0f authored by HiPhish's avatar HiPhish

Initial commit

parents
# Fast-load file of compiled code, generated by the Common Lisp implementation
*.fasl
# Documentation tags
doc/tags
The MIT License (MIT)
Copyright (c) 2016 Alejandro "HiPhish" Sanchez
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
.. default-role:: code
###########################
Hacking on Quicklisp.nvim
###########################
Setup
#####
You should first install the dependencies (the Common Lisp API client and
Quicklisp) by following their instructions.
https://github.com/adolenc/cl-neovim/
https://www.quicklisp.org/
If you are using Vlime while developing you should also connect your Vlime
connection to your running Neovim instance or else you will get errors when
compiling a file that contains Neovim code. Here is what is going on: a Vlime
connection is a connection to a running Swank server, which is a Common Lisp
process. Swank tries to compile your file your file, and when it sees a
`nvim:defun` or similar, it will require a connection. The easiest way to
satisfy the compiler is to execute
.. code-block:: lisp
(nvim:connect :file NVIM-LISTEN-ADDRESS)
where `NVIM-LISTEN-ADDRESS` is for example the value of `$NVIM_LISTEN_ADDRESS`.
.. default-role: code
######################
Quicklisp for Neovim
######################
A Neovim client for Quicklisp_, the Common Lisp package manager.
.. image:: doc/screenshot.png
:align: center
.. _Quicklisp: https://www.quicklisp.org/
Installation
############
Install Quicklisp.nvim like any other Neovim plugin and execute afterwards
`:UpdateRemotePlugins`. Since this is a remote plugin you will also need to
install the `Common Lisp API client`, and you will need to have Quicklisp set
up for the API client's Common Lisp implementation. Please refer to the
included documentation of Quicklisp.nvim.
.. _Common Lisp API client: https://github.com/adolenc/cl-neovim/
.. _SBCL: http://sbcl.org/
Usage
#####
You can use Quicklisp functionality from within Neovim now. There are two
parts: Vimscript functions which give you data from Quicklisp for further
processing in your own scripts, and Vim commands to be executed manually. Here
is an example:
.. code-block: vim
" Get a list of all packages containing "vim" in their name
let vim_packages = QuicklispSystemApropos('vim')
" Get a list of all packages depending on MessagePack
let msgpack_packages = QuicklispWhoDependsOn('cl-messagepack')
" Display human-readably all packages depending on MesagePack
:Quicklisp who-depends-on cl-messagepack
As you can see the function- and command names resemble the names from
Quicklisp.
License
#######
Quicklisp.nvim is release under the terms of the MIT license. See the
`COPYING.txt`_ file for details.
.. _COPYING.txt: COPYING.txt
Self-promotion
##############
If you like this plugin please consider financially supporting its development,
every small amount helps; you can become a regular supporter through LiberaPay
or tip me with a one-time donation over Ko-Fi. Feel free to explore my other
software projects as well.
* http://hiphish.github.io/
* https://ko-fi.com/hiphish/
* https://liberapay.com/HiPhish/
.. default-role:: code
Things that would be nice to have:
- Health check for Quicklisp (requires somehow calling Lisp code from Neovim)
- Actual tests (how should I test a Quicklisp client with a mock Quicklisp?)
- Stream output instead of collecting it. Quicklisp sends output to
`standard-output`, which we can capture in a string and echo out in Neovim,
but this means the output will not gradually stream, it will appear all at
once when the Quicklisp procedure terminates.
*quicklisp.txt* Quicklisp client for Neovim
*quicklisp.nvim*
____ _ __ ___~
/ __ \__ __(_)___/ /__ / (_)__ ___~
/ /_/ / // / / __/ '_// / (_-</ _ \~
\___\_\_,_/_/\__/_/\_\/_/_/___/ .__/~
/_/~
Version: 0.0.0
Author: Alejandro "HiPhish" Sanchez
License: MIT License
==============================================================================
TABLE OF CONTENTS *quicklisp-contents*
1. Introduction ................................. |quicklisp-introduction|
2. Installation ................................. |quicklisp-installation|
3. Functions .................................... |quicklisp-functions|
4. Commands ..................................... |quicklisp-commands|
==============================================================================
INTRODUCTION *quicklisp-introduction*
Quicklisp.nvim is a Neovim wrapper for the Common Lisp package manager
Quicklisp. It aims to make the functionality of Quicklisp available for
interactive use without needing a Common Lisp REPL running, and for scripting
in Vimscript.
It is a remote plugin, which means that most of the code of Quicklisp.nvim is
written in Common Lisp itself, not Vimscript. This makes it possible to use
Quicklisp directly as a Common Lisp library.
==============================================================================
INSTALLATION *quicklisp-installation*
Quicklisp.nvim is installed like any other remote plugin: install it like any
Vim plugin, then execute |:UpdateRemotePlugins|.
There are two dependencies though:
* Quicklisp (https://www.quicklisp.org/)
* A Common Lisp API client (e.g. https://github.com/adolenc/cl-neovim/)
Please see the instructions for Quicklisp and the API client on how to install
them. Make sure that Quicklisp is available to the Common Lisp implementation
used by your API client. Please make sure that Quicklisp works from the REPL
and that the API client works first before submitting a bug report or trying
to troubleshoot Quicklisp.nvim.
==============================================================================
QUICKLISP FUNCTIONS *quicklisp-functions*
------------------------------------------------------------------------------
QuicklispWhoDependsOn({system}) *QuicklispWhoDependsOn()*
Return a list of names of systems depending on {system} (which is also a
system name).
------------------------------------------------------------------------------
QuicklispSystemApropos({pattern}) *QuicklispSystemApropos()*
Return a list of string representation of systems whose name matches
{pattern}.
==============================================================================
QUICKLISP COMMANDS *quicklisp-commands*
:Quicklisp {sub-command} [arguments] *:Quicklisp*
Execute the {sub-command} of Quicklisp, possibly with arguments. There is only
this one command and it serves mostly as a wrapper around the Quicklisp
functions.
------------------------------------------------------------------------------
:Quicklisp quickload {system} [...]
Load one or more {system}s into the Common Lisp process running the API
client. If the system has not been installed it will first be downloaded and
installed before being loaded.
------------------------------------------------------------------------------
:Quicklisp uninstall {system} [...]
Uninstall one or more {system}s.
------------------------------------------------------------------------------
:Quicklisp system-apropos {pattern}
List all systems whose name matches {pattern}.
------------------------------------------------------------------------------
:Quicklisp who-depends-on {system}
List all systems which have {system} as their dependency.
------------------------------------------------------------------------------
:Quicklisp update-dist {distro}
Update definitions from distribution {distro}.
------------------------------------------------------------------------------
:Quicklisp update-client
Update the Quicklisp client itself.
==============================================================================
vim:tw=78:ts=8:ft=help:norl:
" Author: Alejandro "HiPhish" Sanchez
" License: The MIT License (MIT) {{{
" Copyright (c) 2018 HiPhish
"
" Permission is hereby granted, free of charge, to any person obtaining a
" copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to permit
" persons to whom the Software is furnished to do so, subject to the
" following conditions:
"
" The above copyright notice and this permission notice shall be included
" in all copies or substantial portions of the Software.
"
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
" NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
" USE OR OTHER DEALINGS IN THE SOFTWARE.
" }}}
" It was easier to just write this in Vimscript and make use of its regex
" engine than to import PCRE as an extra dependency in Lisp.
function! __quicklisp_cmd_completion(ArgLead, CmdLine, CursorPos)
if len(split(a:CmdLine, '\v\s+')) > 1 && empty(a:ArgLead)
return ''
else
return "quickload\nsystem-apropos\nuninstall\nupdate-client\nupdate-dist\nwho-depends-on"
endif
endfunction
;;;; Copyright (c) 2018 HiPhish
;;;;
;;;; Permission is hereby granted, free of charge, to any person obtaining a
;;;; copy of this software and associated documentation files (the
;;;; "Software"), to deal in the Software without restriction, including
;;;; without limitation the rights to use, copy, modify, merge, publish,
;;;; distribute, sublicense, and/or sell copies of the Software, and to permit
;;;; persons to whom the Software is furnished to do so, subject to the
;;;; following conditions:
;;;;
;;;; The above copyright notice and this permission notice shall be included
;;;; in all copies or substantial portions of the Software.
;;;;
;;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
;;;; OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
;;;; NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
;;;; DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
;;;; OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
;;;; USE OR OTHER DEALINGS IN THE SOFTWARE.
;;;; This file implements the entire Quicklisp remote plugin. It defines the
;;;; functions and the command available to Vim. Tab-completion for the plugin
;;;; is implemented in a Vimscript function in another file.
(eval-when (:compile-toplevel)
(ql:quickload :cl-neovim))
(defpackage #:quicklisp-nvim
(:use #:cl))
(in-package #:quicklisp-nvim)
;;; ---------------------------------------------------------------------------
(defun display-nvim-error (message)
"Display an error message in Neovim, but do not throw an actual error"
(nvim:err-writeln message))
(defun out-writeln (message)
"Display a MESSAGE in Neovim. Unlike `nvim:out-write` the message will be
terminated with a line feed."
(nvim:out-write message)
(nvim:out-write "
"))
;;; ---[ NEOVIM FUNCTIONS ]----------------------------------------------------
(nvim:defun/s "QuicklispWhoDependsOn" (system-name)
"Return a list system name strings of systems depending on SYSTEM-NAME"
(declare (type string system-name))
(ql:who-depends-on system-name))
(nvim:defun/s "QuicklispSystemApropos" (substring)
"Return a list of strings representing systems containing SUBSTRING"
(declare (type string substring))
(mapcar (lambda (system) (format nil "~A" system))
(ql:system-apropos-list substring)))
;;; ---[ NEOVIM COMMANDS ]-----------------------------------------------------
(defun quickload (systems)
(declare (type list systems))
"Quick-loads systems from the list SYSTEMS."
(dolist (system systems)
(declare (type string system))
(nvim:out-write
(format nil "~A~&"
(with-output-to-string (*standard-output*)
(with-output-to-string (*error-output*)
(ql:quickload system)))))))
(defun system-apropos (pattern)
(declare (type string pattern))
"Display a message listing all systems matching PATTERN"
(let ((systems (ql:system-apropos-list pattern)))
(nvim:out-write
(format nil
"Systems matching '~A':~%~{ ~A~%~}~&"
pattern
(mapcar (lambda (system) (format nil "~A" system))
systems)))))
(defun who-depends-on (system)
"Display a message in Neovim listing all packages dependent on SYSTEM"
(declare (type string system))
(let ((systems (ql:who-depends-on system)))
(nvim:out-write
(format nil
"The following packages depend on '~A':~%~{ ~A~%~}~&"
system
systems))))
(defun update-dist (distro)
(declare (type string distro))
"Update the distribution DISTRO"
(out-writeln
(with-output-to-string (*standard-output*)
(with-output-to-string (*error-output*)
(ql:update-dist distro)))))
(defun update-client ()
"Update the Quicklisp client itself"
(out-writeln
(with-output-to-string (*standard-output*)
(with-output-to-string (*error-output*)
(ql:update-client)))))
(nvim:defcommand/s "Quicklisp" (sub-command &rest arg*)
(declare (type string sub-command)
(type list arg*)
(opts (complete "custom,__quicklisp_cmd_completion")))
"The main Quicklisp command for Neovim; dispatches dynamically on SUB-COMMAND"
(cond
((string= sub-command "quickload")
(quickload arg*))
((string= sub-command "uninstall")
(dolist (system arg*)
(declare (type string system))
(ql:uninstall system)))
((string= sub-command "system-apropos")
(if (= (length arg*) 1)
(system-apropos (elt arg* 0))
(out-writeln "Wrong number of arguments: requires a pattern")))
((string= sub-command "who-depends-on")
(if (= (length arg*) 1)
(who-depends-on (elt arg* 0))
(out-writeln "Wrong number of arguments: requires a package name")))
((string= sub-command "update-dist")
(if (= (length arg*) 1)
(update-dist (elt arg* 0))
(out-writeln "Wrong number of arguments: requires a distro name")))
((string= sub-command "update-client")
(if arg*
(out-writeln "Wrong number of arguments: takes no arguments")
(update-client)))
(t (nvim:out-write
(format nil
"Unknown Quicklisp command, use one of ~{~& ~A~}~&"
'("quickload" "uninstall" "system-apropos" "who-depends-on" "update-dist" "update-client"))))))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment