uh more cleanup of dot vim
This commit is contained in:
@@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2103 Benjamin Mills
|
|
||||||
|
|
||||||
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.
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
# vimux
|
|
||||||
|
|
||||||
Easily interact with tmux from vim.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
What inspired me to write vimux was [tslime.vim](https://github.com/kikijump/tslime.vim), a plugin that lets you send input to tmux. While tslime.vim works well, I felt it wasn't optimized for my primary use case which was having a smaller tmux pane that I would use to run tests or play with a REPL.
|
|
||||||
|
|
||||||
My goal with vimux is to make interacting with tmux from vim effortless. By default when you call `VimuxRunCommand` vimux will create a 20% tall horizontal pane under your current tmux pane and execute a command in it without losing focus of vim. Once that pane exists whenever you call `VimuxRunCommand` again the command will be executed in that pane. As I was using vimux myself I wanted to rerun commands over and over. An example of this was running the current file through rspec. Rather than typing that over and over I wrote `VimuxRunLastCommand` that will execute the last command you called with `VimuxRunCommand`.
|
|
||||||
|
|
||||||
Other auxiliary functions and the ones I talked about above can be found bellow with a full description and example key binds for your vimrc.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
With **[vim-bundle](https://github.com/benmills/vim-bundle)**: `vim-bundle install benmills/vimux`
|
|
||||||
With **[Vundle](https://github.com/gmarik/Vundle.vim)**: 'Plugin benmills/vimux' in your .vimrc
|
|
||||||
|
|
||||||
Otherwise download the latest [tarball](https://github.com/benmills/vimux/tarball/master), extract it and move `plugin/vimux.vim` inside `~/.vim/plugin`. If you're using [pathogen](https://github.com/tpope/vim-pathogen), then move the entire folder extracted from the tarball into `~/.vim/bundle`.
|
|
||||||
|
|
||||||
_Notes:_
|
|
||||||
|
|
||||||
* Vimux assumes a tmux version >= 1.5. Some older versions might work but it is recommeded to use at least version 1.5.
|
|
||||||
|
|
||||||
## Platform-specific Plugins
|
|
||||||
|
|
||||||
* [vim-vroom](https://github.com/skalnik/vim-vroom) runner for rspec, cucumber and test/unit; vimux support via `g:vroom_use_vimux`
|
|
||||||
* [vimux-ruby-test](https://github.com/pgr0ss/vimux-ruby-test) a set of commands to easily run ruby tests
|
|
||||||
* [vimux-cucumber](https://github.com/cloud8421/vimux-cucumber) run Cucumber Features through Vimux
|
|
||||||
* [vim-turbux](https://github.com/jgdavey/vim-turbux) Turbo Ruby testing with tmux
|
|
||||||
* [vimux-pyutils](https://github.com/julienr/vimux-pyutils) A set of functions for vimux that allow to run code blocks in ipython
|
|
||||||
* [vimux-nose-test](https://github.com/pitluga/vimux-nose-test) Run nose tests in vimux
|
|
||||||
* [vimux-golang](https://github.com/benmills/vimux-golang) Run go tests in vimux
|
|
||||||
* [vimux-zeus](https://github.com/jingweno/vimux-zeus) Run zeus commands in vimux
|
|
||||||
* [vimix](https://github.com/spiegela/vimix) Run Elixir mix commands in vimux
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
The full documentation is available [online](https://raw.github.com/benmills/vimux/master/doc/vimux.txt) and accessible inside vim `:help vimux`
|
|
||||||
@@ -1,355 +0,0 @@
|
|||||||
*vimux.txt* easily interact with tmux
|
|
||||||
|
|
||||||
Vimux
|
|
||||||
effortless vim and tmux interaction
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
CONTENTS *vimux-contents*
|
|
||||||
|
|
||||||
1. About............................ |VimuxAbout|
|
|
||||||
2. Usage ........................... |VimuxUsage|
|
|
||||||
2.1 .............................. |VimuxPromptCommand|
|
|
||||||
2.2 .............................. |VimuxRunLastCommand|
|
|
||||||
2.3 .............................. |VimuxInspectRunner|
|
|
||||||
2.4 .............................. |VimuxCloseRunner|
|
|
||||||
2.5 .............................. |VimuxInterruptRunner|
|
|
||||||
2.6 .............................. |VimuxClearRunnerHistory|
|
|
||||||
2.7 .............................. |VimuxZoomRunner|
|
|
||||||
2.8 .............................. |VimuxRunCommandInDir|
|
|
||||||
3. Misc ............................ |VimuxMisc|
|
|
||||||
3.1 Example Keybinding............ |VimuxExampleKeybinding|
|
|
||||||
3.2 Tslime Replacement............ |VimuxTslimeReplacement|
|
|
||||||
4. Configuration ................... |VimuxConfiguration|
|
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
ABOUT (1) *VimuxAbout*
|
|
||||||
|
|
||||||
Vimux -- Easily interact with tmux from vim.
|
|
||||||
|
|
||||||
What inspired me to write vimux was tslime.vim [1], a plugin that lets you
|
|
||||||
send input to tmux. While tslime.vim works well, I felt it wasn't optimized
|
|
||||||
for my primary use case which was having a smaller tmux pane that I would use
|
|
||||||
to run tests or play with a REPL.
|
|
||||||
|
|
||||||
My goal with vimux is to make interacting with tmux from vim effortless. By
|
|
||||||
default when you call `VimuxRunCommand` vimux will create a 20% tall
|
|
||||||
horizontal pane under your current tmux pane and execute a command in it
|
|
||||||
without losing focus of vim. Once that pane exists whenever you call
|
|
||||||
`VimuxRunCommand` again the command will be executed in that pane. As I was
|
|
||||||
using vimux myself I wanted to rerun commands over and over. An example of
|
|
||||||
this was running the current file through rspec. Rather than typing that over
|
|
||||||
and over I wrote `VimuxRunLastCommand` that will execute the last command
|
|
||||||
you called with `VimuxRunCommand`.
|
|
||||||
|
|
||||||
Other auxiliary functions and the ones I talked about above can be found
|
|
||||||
bellow with a full description and example key binds for your vimrc.
|
|
||||||
|
|
||||||
[1] https://github.com/kikijump/tslime.vim
|
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
USAGE (2) *VimuxUsage*
|
|
||||||
|
|
||||||
The function VimuxRunCommand(command) is the core of Vimux. It will
|
|
||||||
create a split pane in the current window and run the passed command in it.
|
|
||||||
>
|
|
||||||
:call VimuxRunCommand("ls")
|
|
||||||
<
|
|
||||||
This will run the command in a split pane without losing focus of vim. If the
|
|
||||||
command takes a long time to return you can continue to use vim while the
|
|
||||||
process finishes and will see the output in the pane when it's finished.
|
|
||||||
|
|
||||||
Furthermore there are several handy commands all starting with 'Vimux':
|
|
||||||
- |VimuxRunCommand|
|
|
||||||
- |VimuxSendText|
|
|
||||||
- |VimuxSendKeys|
|
|
||||||
- |VimuxOpenPane|
|
|
||||||
- |VimuxRunLastCommand|
|
|
||||||
- |VimuxCloseRunner|
|
|
||||||
- |VimuxInspectRunner|
|
|
||||||
- |VimuxInterruptRunner|
|
|
||||||
- |VimuxPromptCommand|
|
|
||||||
- |VimuxClearRunnerHistory|
|
|
||||||
- |VimuxZoomRunner|
|
|
||||||
- |VimuxRunCommandInDir|
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxRunCommand*
|
|
||||||
VimuxRunCommand~
|
|
||||||
|
|
||||||
Run a system command in a small horizontal split bellow
|
|
||||||
the current pane vim is in. You can optionally pass a second argument to stop
|
|
||||||
vimux from automatically sending a return after the command.
|
|
||||||
>
|
|
||||||
" Run the current file with rspec
|
|
||||||
map <Leader>rb :call VimuxRunCommand("clear; rspec " . bufname("%"))<CR>
|
|
||||||
" Run command without sending a return
|
|
||||||
map <Leader>rq :call VimuxRunCommand("clear; rspec " . bufname("%"), 0)<CR>
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxSendText*
|
|
||||||
VimuxSendText~
|
|
||||||
|
|
||||||
Send raw text to the runer pane. This command will not open a new pane if one
|
|
||||||
does not already exist. You will need to use VimuxOpenPane to do this. This
|
|
||||||
command can be used to interact with REPLs or other interactive terminal
|
|
||||||
programs that are not shells.
|
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxSendKeys*
|
|
||||||
VimuxSendKeys~
|
|
||||||
|
|
||||||
Send keys to the runner pane. This command will not open a new pane if one
|
|
||||||
does not already exist. You will need to use VimuxOpenPane to do this. You can
|
|
||||||
use this command to send keys such as "Enter" or "C-c" to the runner pane.
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxOpenPane*
|
|
||||||
VimuxOpenPane~
|
|
||||||
|
|
||||||
This will either open a new pane or use the nearest pane and set it as the
|
|
||||||
vimux runner pane for the other vimux commands. You can control if this command
|
|
||||||
uses the nearest pane or always creates a new one with g:VimuxUseNearest
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxPromptCommand*
|
|
||||||
VimuxPromptCommand~
|
|
||||||
|
|
||||||
Prompt for a command and run it in a small horizontal split bellow the current
|
|
||||||
pane. A parameter can be supplied to predefine a command or a part of the
|
|
||||||
command which can be edited in the prompt.
|
|
||||||
>
|
|
||||||
" Prompt for a command to run map
|
|
||||||
map <Leader>vp :VimuxPromptCommand<CR>
|
|
||||||
map <Leader>vm :VimuxPromptCommand("make ")<CR>
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxRunLastCommand*
|
|
||||||
VimuxRunLastCommand~
|
|
||||||
|
|
||||||
Run the last command executed by `VimuxRunCommand`
|
|
||||||
>
|
|
||||||
" Run last command executed by VimuxRunCommand
|
|
||||||
map <Leader>vl :VimuxRunLastCommand<CR>
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxInspectRunner*
|
|
||||||
VimuxInspectRunner~
|
|
||||||
|
|
||||||
Move into the tmux runner pane created by `VimuxRunCommand` and enter copy
|
|
||||||
pmode (scroll mode).
|
|
||||||
>
|
|
||||||
" Inspect runner pane map
|
|
||||||
map <Leader>vi :VimuxInspectRunner<CR>
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxCloseRunner*
|
|
||||||
VimuxCloseRunner~
|
|
||||||
|
|
||||||
Close the tmux runner created by `VimuxRunCommand`
|
|
||||||
>
|
|
||||||
" Close vim tmux runner opened by VimuxRunCommand
|
|
||||||
map <Leader>vq :VimuxCloseRunner<CR>
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxInterruptRunner*
|
|
||||||
VimuxInterruptRunner~
|
|
||||||
|
|
||||||
Interrupt any command that is running inside the
|
|
||||||
runner pane.
|
|
||||||
>
|
|
||||||
" Interrupt any command running in the runner pane map
|
|
||||||
map <Leader>vs :VimuxInterruptRunner<CR>
|
|
||||||
<
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxClearRunnerHistory*
|
|
||||||
VimuxClearRunnerHistory~
|
|
||||||
|
|
||||||
Clear the tmux history of the runner pane for when
|
|
||||||
you enter tmux scroll mode inside the runner pane.
|
|
||||||
>
|
|
||||||
" Clear the tmux history of the runner pane
|
|
||||||
map <Leader>vc :VimuxClearRunnerHistory<CR>
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxZoomRunner*
|
|
||||||
VimuxZoomRunner~
|
|
||||||
|
|
||||||
Zoom the runner pane. Once its zoomed, you will need
|
|
||||||
to use tmux "<bind-key> z" to restore the runner pane.
|
|
||||||
Zoom requires tmux version >= 1.8
|
|
||||||
>
|
|
||||||
|
|
||||||
" Zoom the tmux runner page
|
|
||||||
map <Leader>vz :VimuxZoomRunner<CR>
|
|
||||||
<
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxRunCommandInDir*
|
|
||||||
VimuxRunCommandInDir~
|
|
||||||
|
|
||||||
Runs the specified command inside the directory of
|
|
||||||
the currently opened file. Takes two arguments. command and inFile
|
|
||||||
|
|
||||||
command: The command to run
|
|
||||||
inFile: If 1 the filename will be appended to the command
|
|
||||||
>
|
|
||||||
|
|
||||||
" Compile currently opened latex file to pdf
|
|
||||||
autocmd Filetype tex nnoremap <buffer> <Leader>rr :update<Bar>:call VimuxRunCommandInDir('latexmk -pdf', 1)<CR>
|
|
||||||
" Push the repository of the currently opened file
|
|
||||||
nnoremap <leader>gp :call VimuxRunCommandInDir("git push", 0)<CR>
|
|
||||||
<
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
MISC (3) *VimuxMisc*
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxExampleKeybinding*
|
|
||||||
Full Keybind Example~
|
|
||||||
|
|
||||||
>
|
|
||||||
" Run the current file with rspec
|
|
||||||
map <Leader>rb :call VimuxRunCommand("clear; rspec " . bufname("%"))<CR>
|
|
||||||
|
|
||||||
" Prompt for a command to run
|
|
||||||
map <Leader>vp :VimuxPromptCommand<CR>
|
|
||||||
|
|
||||||
" Run last command executed by VimuxRunCommand
|
|
||||||
map <Leader>vl :VimuxRunLastCommand<CR>
|
|
||||||
|
|
||||||
" Inspect runner pane
|
|
||||||
map <Leader>vi :VimuxInspectRunner<CR>
|
|
||||||
|
|
||||||
" Close vim tmux runner opened by VimuxRunCommand
|
|
||||||
map <Leader>vq :VimuxCloseRunner<CR>
|
|
||||||
|
|
||||||
" Interrupt any command running in the runner pane
|
|
||||||
map <Leader>vx :VimuxInterruptRunner<CR>
|
|
||||||
|
|
||||||
" Zoom the runner pane (use <bind-key> z to restore runner pane)
|
|
||||||
map <Leader>vz :call VimuxZoomRunner()<CR>
|
|
||||||
>
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxTslimeReplacement*
|
|
||||||
Vimux as tslime replacement~
|
|
||||||
|
|
||||||
Here is how to use vimux to send code to a REPL. This is similar to tslime.
|
|
||||||
First, add some helpful mappings.
|
|
||||||
|
|
||||||
>
|
|
||||||
function! VimuxSlime()
|
|
||||||
call VimuxSendText(@v)
|
|
||||||
call VimuxSendKeys("Enter")
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" If text is selected, save it in the v buffer and send that buffer it to tmux
|
|
||||||
vmap <LocalLeader>vs "vy :call VimuxSlime()<CR>
|
|
||||||
|
|
||||||
" Select current paragraph and send it to tmux
|
|
||||||
nmap <LocalLeader>vs vip<LocalLeader>vs<CR>
|
|
||||||
<
|
|
||||||
|
|
||||||
Now, open a clojure file. Let's say your leader is backslash (\). Type \vp,
|
|
||||||
and then type lein repl at the prompt. This opens a tmux split running a REPL.
|
|
||||||
Then, select text or put the cursor on a function and type \vs. This will send
|
|
||||||
it to the REPL and evaluate it. The reason we pass `0` to `VimuxRunCommand`
|
|
||||||
is to stop the normal return that is sent to the runner pane and use our own
|
|
||||||
new line so the clojure REPL will evaluate the selected text without adding an
|
|
||||||
extra return. Thanks to @trptcolin for discovering this issue.
|
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
CONFIGURATION (4) *VimuxConfiguration*
|
|
||||||
|
|
||||||
You can configure Vimux like this:
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxConfiguration_height*
|
|
||||||
2.1 g:VimuxHeight~
|
|
||||||
|
|
||||||
The percent of the screen the split pane Vimux will spawn should take up.
|
|
||||||
|
|
||||||
let g:VimuxHeight = "40"
|
|
||||||
|
|
||||||
Default: "20"
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxConfiguration_orientation*
|
|
||||||
2.2 g:VimuxOrientation~
|
|
||||||
|
|
||||||
The default orientation of the split tmux pane. This tells tmux to make the
|
|
||||||
pane either vertically or horizontally, which is backward from how Vim handles
|
|
||||||
creating splits.
|
|
||||||
|
|
||||||
let g:VimuxOrientation = "h"
|
|
||||||
|
|
||||||
Options:
|
|
||||||
"v": vertical
|
|
||||||
"h": horizontal
|
|
||||||
|
|
||||||
Default: "v"
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxConfiguration_use_nearest*
|
|
||||||
2.3 g:VimuxUseNearest
|
|
||||||
|
|
||||||
Use exising pane or window (not used by vim) if found instead of running
|
|
||||||
split-window.
|
|
||||||
|
|
||||||
let VimuxUseNearest = 1
|
|
||||||
|
|
||||||
Default: 1
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxConfiguration_reset_sequence*
|
|
||||||
2.4 g:VimuxResetSequence~
|
|
||||||
|
|
||||||
The keys sent to the runner pane before running a command. By default it sends
|
|
||||||
`q` to make sure the pane is not in scroll-mode and `C-u` to clear the line.
|
|
||||||
|
|
||||||
let VimuxResetSequence = ""
|
|
||||||
|
|
||||||
Default: "q C-u"
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxPromptString*
|
|
||||||
2.5 g:VimuxPromptString~
|
|
||||||
|
|
||||||
The string presented in the vim command line when Vimux is invoked. Be sure
|
|
||||||
to put a space at the end of the string to allow for distinction between
|
|
||||||
the prompt and your input.
|
|
||||||
|
|
||||||
let g:VimuxPromptString = ""
|
|
||||||
|
|
||||||
Default: "Command? "
|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
*VimuxRunnerType*
|
|
||||||
2.6 g:VimuxRunnerType~
|
|
||||||
|
|
||||||
The type of view object Vimux should use for the runner. For reference, a
|
|
||||||
tmux session is a group of windows, and a window is a layout of panes.
|
|
||||||
|
|
||||||
let g:VimuxRunnerType = "window"
|
|
||||||
|
|
||||||
Options:
|
|
||||||
"pane": for panes
|
|
||||||
"window": for windows
|
|
||||||
|
|
||||||
Default: "pane"
|
|
||||||
|
|
||||||
==============================================================================
|
|
||||||
vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl:
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
doc/tags
|
|
||||||
@@ -1,198 +0,0 @@
|
|||||||
if exists("g:loaded_vimux") || &cp
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let g:loaded_vimux = 1
|
|
||||||
|
|
||||||
command -nargs=* VimuxRunCommand :call VimuxRunCommand(<args>)
|
|
||||||
command VimuxRunLastCommand :call VimuxRunLastCommand()
|
|
||||||
command VimuxCloseRunner :call VimuxCloseRunner()
|
|
||||||
command VimuxZoomRunner :call VimuxZoomRunner()
|
|
||||||
command VimuxInspectRunner :call VimuxInspectRunner()
|
|
||||||
command VimuxScrollUpInspect :call VimuxScrollUpInspect()
|
|
||||||
command VimuxScrollDownInspect :call VimuxScrollDownInspect()
|
|
||||||
command VimuxInterruptRunner :call VimuxInterruptRunner()
|
|
||||||
command -nargs=? VimuxPromptCommand :call VimuxPromptCommand(<args>)
|
|
||||||
command VimuxClearRunnerHistory :call VimuxClearRunnerHistory()
|
|
||||||
command VimuxTogglePane :call VimuxTogglePane()
|
|
||||||
|
|
||||||
function! VimuxRunCommandInDir(command, useFile)
|
|
||||||
let l:file = ""
|
|
||||||
if a:useFile ==# 1
|
|
||||||
let l:file = shellescape(expand('%:t'), 1)
|
|
||||||
endif
|
|
||||||
call VimuxRunCommand("cd ".shellescape(expand('%:p:h'), 1)." && ".a:command." ".l:file." && cd - > /dev/null")
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxRunLastCommand()
|
|
||||||
if exists("g:VimuxRunnerIndex")
|
|
||||||
call VimuxRunCommand(g:VimuxLastCommand)
|
|
||||||
else
|
|
||||||
echo "No last vimux command."
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxRunCommand(command, ...)
|
|
||||||
if !exists("g:VimuxRunnerIndex") || _VimuxHasRunner(g:VimuxRunnerIndex) == -1
|
|
||||||
call VimuxOpenRunner()
|
|
||||||
endif
|
|
||||||
|
|
||||||
let l:autoreturn = 1
|
|
||||||
if exists("a:1")
|
|
||||||
let l:autoreturn = a:1
|
|
||||||
endif
|
|
||||||
|
|
||||||
let resetSequence = _VimuxOption("g:VimuxResetSequence", "q C-u")
|
|
||||||
let g:VimuxLastCommand = a:command
|
|
||||||
|
|
||||||
call VimuxSendKeys(resetSequence)
|
|
||||||
call VimuxSendText(a:command)
|
|
||||||
|
|
||||||
if l:autoreturn == 1
|
|
||||||
call VimuxSendKeys("Enter")
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxSendText(text)
|
|
||||||
call VimuxSendKeys('"'.escape(a:text, '"$').'"')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxSendKeys(keys)
|
|
||||||
if exists("g:VimuxRunnerIndex")
|
|
||||||
call system("tmux send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
|
|
||||||
else
|
|
||||||
echo "No vimux runner pane/window. Create one with VimuxOpenRunner"
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxOpenRunner()
|
|
||||||
let nearestIndex = _VimuxNearestIndex()
|
|
||||||
|
|
||||||
if _VimuxOption("g:VimuxUseNearest", 1) == 1 && nearestIndex != -1
|
|
||||||
let g:VimuxRunnerIndex = nearestIndex
|
|
||||||
else
|
|
||||||
if _VimuxRunnerType() == "pane"
|
|
||||||
let height = _VimuxOption("g:VimuxHeight", 20)
|
|
||||||
let orientation = _VimuxOption("g:VimuxOrientation", "v")
|
|
||||||
call system("tmux split-window -p ".height." -".orientation)
|
|
||||||
elseif _VimuxRunnerType() == "window"
|
|
||||||
call system("tmux new-window")
|
|
||||||
endif
|
|
||||||
|
|
||||||
let g:VimuxRunnerIndex = _VimuxTmuxIndex()
|
|
||||||
call system("tmux last-"._VimuxRunnerType())
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxCloseRunner()
|
|
||||||
if exists("g:VimuxRunnerIndex")
|
|
||||||
call system("tmux kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
|
|
||||||
unlet g:VimuxRunnerIndex
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxTogglePane()
|
|
||||||
if exists("g:VimuxRunnerIndex")
|
|
||||||
if _VimuxRunnerType() == "window"
|
|
||||||
call system("tmux join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20))
|
|
||||||
let g:VimuxRunnerType = "pane"
|
|
||||||
elseif _VimuxRunnerType() == "pane"
|
|
||||||
let g:VimuxRunnerIndex=substitute(system("tmux break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_index}'"), "\n", "", "")
|
|
||||||
let g:VimuxRunnerType = "window"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxZoomRunner()
|
|
||||||
if exists("g:VimuxRunnerIndex")
|
|
||||||
if _VimuxRunnerType() == "pane"
|
|
||||||
call system("tmux resize-pane -Z -t ".g:VimuxRunnerIndex)
|
|
||||||
elseif _VimuxRunnerType() == "window"
|
|
||||||
call system("tmux select-window -t ".g:VimuxRunnerIndex)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxInspectRunner()
|
|
||||||
call system("tmux select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
|
|
||||||
call system("tmux copy-mode")
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxScrollUpInspect()
|
|
||||||
call VimuxInspectRunner()
|
|
||||||
call system("tmux last-"._VimuxRunnerType())
|
|
||||||
call VimuxSendKeys("C-u")
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxScrollDownInspect()
|
|
||||||
call VimuxInspectRunner()
|
|
||||||
call system("tmux last-"._VimuxRunnerType())
|
|
||||||
call VimuxSendKeys("C-d")
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxInterruptRunner()
|
|
||||||
call VimuxSendKeys("^c")
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxClearRunnerHistory()
|
|
||||||
if exists("g:VimuxRunnerIndex")
|
|
||||||
call system("tmux clear-history -t ".g:VimuxRunnerIndex)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! VimuxPromptCommand(...)
|
|
||||||
let command = a:0 == 1 ? a:1 : ""
|
|
||||||
let l:command = input(_VimuxOption("g:VimuxPromptString", "Command? "), command)
|
|
||||||
call VimuxRunCommand(l:command)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! _VimuxTmuxSession()
|
|
||||||
return _VimuxTmuxProperty("#S")
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! _VimuxTmuxIndex()
|
|
||||||
if _VimuxRunnerType() == "pane"
|
|
||||||
return _VimuxTmuxPaneIndex()
|
|
||||||
else
|
|
||||||
return _VimuxTmuxWindowIndex()
|
|
||||||
end
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! _VimuxTmuxPaneIndex()
|
|
||||||
return _VimuxTmuxProperty("#I.#P")
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! _VimuxTmuxWindowIndex()
|
|
||||||
return _VimuxTmuxProperty("#I")
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! _VimuxNearestIndex()
|
|
||||||
let views = split(system("tmux list-"._VimuxRunnerType()."s"), "\n")
|
|
||||||
|
|
||||||
for view in views
|
|
||||||
if match(view, "(active)") == -1
|
|
||||||
return split(view, ":")[0]
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
|
|
||||||
return -1
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! _VimuxRunnerType()
|
|
||||||
return _VimuxOption("g:VimuxRunnerType", "pane")
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! _VimuxOption(option, default)
|
|
||||||
if exists(a:option)
|
|
||||||
return eval(a:option)
|
|
||||||
else
|
|
||||||
return a:default
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! _VimuxTmuxProperty(property)
|
|
||||||
return substitute(system("tmux display -p '".a:property."'"), '\n$', '', '')
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! _VimuxHasRunner(index)
|
|
||||||
return match(system("tmux list-"._VimuxRunnerType()."s -a"), a:index.":")
|
|
||||||
endfunction
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
"
|
|
||||||
" limp/vim/limp.vim
|
|
||||||
"
|
|
||||||
" URL:
|
|
||||||
" http://mikael.jansson.be/hacking
|
|
||||||
"
|
|
||||||
" Description:
|
|
||||||
" Setup the Limp environment
|
|
||||||
"
|
|
||||||
" Version:
|
|
||||||
" 0.2
|
|
||||||
"
|
|
||||||
" Date:
|
|
||||||
" 2008-04-28
|
|
||||||
"
|
|
||||||
" Authors:
|
|
||||||
" Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
"
|
|
||||||
" Changelog:
|
|
||||||
" * 2008-04-28 by Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" Only change colorscheme and nocompatible when not previously set.
|
|
||||||
"
|
|
||||||
" * 2008-04-25 by Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" Catch-all key <F12> for Lisp boot, connect & display
|
|
||||||
"
|
|
||||||
" * 2008-04-20 by Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" Initial version.
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
|
|
||||||
if exists("b:did_ftplugin")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let b:did_ftplugin = 1
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" external dependencies
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
silent! runtime plugin/matchit.vim
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" the Limp library
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
|
|
||||||
runtime ftplugin/lisp/limp/cursor.vim
|
|
||||||
runtime ftplugin/lisp/limp/highlight.vim
|
|
||||||
runtime ftplugin/lisp/limp/sexp.vim
|
|
||||||
runtime ftplugin/lisp/limp/bridge.vim
|
|
||||||
runtime ftplugin/lisp/limp/autoclose.vim
|
|
||||||
runtime ftplugin/lisp/limp/keys.vim
|
|
||||||
runtime ftplugin/lisp/limp/mode.vim
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,208 +0,0 @@
|
|||||||
"
|
|
||||||
" limp/vim/autoclose.vim
|
|
||||||
"
|
|
||||||
" URL:
|
|
||||||
" http://mikael.jansson.be/hacking
|
|
||||||
"
|
|
||||||
" Description:
|
|
||||||
" AutoClose, closes what's opened.
|
|
||||||
"
|
|
||||||
" This plugin closes opened parenthesis, braces, brackets, quotes as you
|
|
||||||
" type them. As of 1.1, if you type the open brace twice ({{), the closing
|
|
||||||
" brace will be pushed down to a new line.
|
|
||||||
"
|
|
||||||
" You can enable or disable this plugin by typing \a (or <Leader>a if
|
|
||||||
" you've redefined your leader character) in normal mode. You'll also
|
|
||||||
" probably want to know you can type <C-V> (<C-Q> if mswin is set) and the next
|
|
||||||
" character you type doesn't have mappings applied. This is useful when you
|
|
||||||
" want to insert only an opening paren or something.
|
|
||||||
"
|
|
||||||
" Version:
|
|
||||||
" 0.2
|
|
||||||
"
|
|
||||||
" Date:
|
|
||||||
" September 20, 2007
|
|
||||||
"
|
|
||||||
" Authors:
|
|
||||||
" Karl Guertin <grayrest@gr.ayre.st>
|
|
||||||
" Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
"
|
|
||||||
" Changelog:
|
|
||||||
" 2008-04-20 by Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" * Factored out start/stop functions.
|
|
||||||
" * Removed the default mappings to toggle autoclose
|
|
||||||
"
|
|
||||||
" 2007-09-20 by Karl Guertin <grayrest@gr.ayre.st>
|
|
||||||
" 1.1.2 -- Fixed a mapping typo and caught a double brace problem
|
|
||||||
" 1.1.1 -- Missed a bug in 1.1, September 19, 2007
|
|
||||||
" 1.1 -- When not inserting at the end, previous version would eat chars
|
|
||||||
" at end of line, added double open->newline, September 19, 2007
|
|
||||||
" 1.0.1 -- Cruft from other parts of the mapping, knew I shouldn't have
|
|
||||||
" released the first as 1.0, April 3, 2007
|
|
||||||
|
|
||||||
" Setup -----------------------------------------------------{{{1
|
|
||||||
|
|
||||||
let s:omni_active = 0
|
|
||||||
let s:cotstate = &completeopt
|
|
||||||
|
|
||||||
if !exists('g:autoclose_on')
|
|
||||||
let g:autoclose_on = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
" assume everything has been defined already if one of the functions are
|
|
||||||
" defined.
|
|
||||||
if exists("*AutoClose_start")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists("*AutoClose_stop")
|
|
||||||
fun! AutoClose_stop()
|
|
||||||
if g:autoclose_on
|
|
||||||
iunmap "
|
|
||||||
iunmap (
|
|
||||||
iunmap )
|
|
||||||
iunmap [
|
|
||||||
iunmap ]
|
|
||||||
iunmap {
|
|
||||||
iunmap }
|
|
||||||
iunmap <BS>
|
|
||||||
iunmap <C-h>
|
|
||||||
iunmap <Esc>
|
|
||||||
""iunmap <C-[>
|
|
||||||
let g:autoclose_on = 0
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists("*AutoClose_start")
|
|
||||||
fun! AutoClose_start()
|
|
||||||
if !g:autoclose_on
|
|
||||||
inoremap <silent> " <C-R>=<SID>QuoteDelim('"')<CR>
|
|
||||||
inoremap <silent> ( (<C-R>=<SID>CloseStackPush(')')<CR>
|
|
||||||
inoremap <silent> ) <C-R>=<SID>CloseStackPop(')')<CR>
|
|
||||||
inoremap <silent> [ [<C-R>=<SID>CloseStackPush(']')<CR>
|
|
||||||
inoremap <silent> ] <C-R>=<SID>CloseStackPop(']')<CR>
|
|
||||||
inoremap <silent> { <C-R>=<SID>OpenSpecial('{','}')<CR>
|
|
||||||
inoremap <silent> } <C-R>=<SID>CloseStackPop('}')<CR>
|
|
||||||
inoremap <silent> <BS> <C-R>=<SID>OpenCloseBackspace()<CR>
|
|
||||||
inoremap <silent> <C-h> <C-R>=<SID>OpenCloseBackspace()<CR>
|
|
||||||
inoremap <silent> <Esc> <C-R>=<SID>CloseStackPop('')<CR><Esc>
|
|
||||||
inoremap <silent> <C-[> <C-R>=<SID>CloseStackPop('')<CR><C-[>
|
|
||||||
let g:autoclose_on = 1
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
endif
|
|
||||||
let s:closeStack = []
|
|
||||||
|
|
||||||
" AutoClose Utilities -----------------------------------------{{{1
|
|
||||||
if !exists("*<SID>OpenSpecial")
|
|
||||||
function <SID>OpenSpecial(ochar,cchar) " ---{{{2
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.') - 2
|
|
||||||
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
|
||||||
if a:ochar == line[(col)] && a:cchar == line[(col+1)] "&& strlen(line) - (col) == 2
|
|
||||||
"echom string(s:closeStack)
|
|
||||||
while len(s:closeStack) > 0
|
|
||||||
call remove(s:closeStack, 0)
|
|
||||||
endwhile
|
|
||||||
return "\<esc>a\<CR>a\<CR>".a:cchar."\<esc>\"_xk$\"_xa"
|
|
||||||
endif
|
|
||||||
return a:ochar.<SID>CloseStackPush(a:cchar)
|
|
||||||
endfunction
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists("*<SID>CloseStackPush")
|
|
||||||
function <SID>CloseStackPush(char) " ---{{{2
|
|
||||||
"echom "push"
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.')-2
|
|
||||||
if (col) < 0
|
|
||||||
call setline('.',a:char.line)
|
|
||||||
else
|
|
||||||
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
|
||||||
call setline('.',line[:(col)].a:char.line[(col+1):])
|
|
||||||
endif
|
|
||||||
call insert(s:closeStack, a:char)
|
|
||||||
"echom join(s:closeStack,'').' -- '.a:char
|
|
||||||
return ''
|
|
||||||
endfunction
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists("*<SID>CloseStackPop")
|
|
||||||
function <SID>CloseStackPop(char) " ---{{{2
|
|
||||||
"echom "pop"
|
|
||||||
if len(s:closeStack) == 0
|
|
||||||
return a:char
|
|
||||||
endif
|
|
||||||
let popped = ''
|
|
||||||
let lastpop = ''
|
|
||||||
"echom join(s:closeStack,'').' || '.lastpop
|
|
||||||
while len(s:closeStack) > 0 && ((lastpop == '' && popped == '') || lastpop != a:char)
|
|
||||||
let lastpop = remove(s:closeStack,0)
|
|
||||||
let popped .= lastpop
|
|
||||||
"echom join(s:closeStack,'').' || '.lastpop.' || '.popped
|
|
||||||
endwhile
|
|
||||||
"echom ' --> '.popped
|
|
||||||
let col = col('.') - 2
|
|
||||||
let line = getline('.')
|
|
||||||
let splits = split(line[:col],popped,1)
|
|
||||||
"echom string(splits)
|
|
||||||
"echom col.' '.line[(col+2):].' '.popped
|
|
||||||
call setline('.',join(splits,popped).line[(col+strlen(popped)+1):])
|
|
||||||
return popped
|
|
||||||
endfunction
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists("*<SID>QuoteDelim")
|
|
||||||
function <SID>QuoteDelim(char) " ---{{{2
|
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.')
|
|
||||||
if line[col - 2] == "\\"
|
|
||||||
"Inserting a quoted quotation mark into the string
|
|
||||||
return a:char
|
|
||||||
elseif line[col - 1] == a:char
|
|
||||||
"Escaping out of the string
|
|
||||||
return "\<C-R>=".s:SID()."CloseStackPop(\"\\".a:char."\")\<CR>"
|
|
||||||
else
|
|
||||||
"Starting a string
|
|
||||||
return a:char."\<C-R>=".s:SID()."CloseStackPush(\"\\".a:char."\")\<CR>"
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
endif
|
|
||||||
|
|
||||||
" The strings returned from QuoteDelim aren't in scope for <SID>, so I
|
|
||||||
" have to fake it using this function (from the Vim help, but tweaked)
|
|
||||||
"
|
|
||||||
if !exists("*s:SID")
|
|
||||||
function s:SID()
|
|
||||||
return matchstr(expand('<sfile>'), '<SNR>\d\+_\zeSID$')
|
|
||||||
endfun
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists("*<SID>OpenCloseBackspace")
|
|
||||||
function <SID>OpenCloseBackspace() " ---{{{2
|
|
||||||
"if pumvisible()
|
|
||||||
" pclose
|
|
||||||
" call <SID>StopOmni()
|
|
||||||
" return "\<C-E>"
|
|
||||||
"else
|
|
||||||
let curline = getline('.')
|
|
||||||
let curpos = col('.')
|
|
||||||
let curletter = curline[curpos-1]
|
|
||||||
let prevletter = curline[curpos-2]
|
|
||||||
if (prevletter == '"' && curletter == '"') ||
|
|
||||||
\ (prevletter == "'" && curletter == "'") ||
|
|
||||||
\ (prevletter == "(" && curletter == ")") ||
|
|
||||||
\ (prevletter == "{" && curletter == "}") ||
|
|
||||||
\ (prevletter == "[" && curletter == "]")
|
|
||||||
if len(s:closeStack) > 0
|
|
||||||
call remove(s:closeStack,0)
|
|
||||||
endif
|
|
||||||
return "\<Delete>\<BS>"
|
|
||||||
else
|
|
||||||
return "\<BS>"
|
|
||||||
endif
|
|
||||||
"endif
|
|
||||||
endf
|
|
||||||
endif
|
|
||||||
|
|
||||||
@@ -1,510 +0,0 @@
|
|||||||
"
|
|
||||||
" limp/vim/bridge.vim
|
|
||||||
"
|
|
||||||
" URL:
|
|
||||||
" http://mikael.jansson.be/hacking
|
|
||||||
"
|
|
||||||
" Description:
|
|
||||||
" Handle communication between Vim and Lisp, including boot, connect and
|
|
||||||
" display. Relies on 'lisp.sh' from the Limp package.
|
|
||||||
"
|
|
||||||
" Version:
|
|
||||||
" 0.2
|
|
||||||
"
|
|
||||||
" Date:
|
|
||||||
" 2008-04-25
|
|
||||||
"
|
|
||||||
" Authors:
|
|
||||||
" Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" Larry Clapp <vim@theclapp.org>
|
|
||||||
|
|
||||||
" Changelog:
|
|
||||||
" 2008-08-26 by Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" * Optionally specify core at startup and exit.
|
|
||||||
"
|
|
||||||
" 2008-08-25 by Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" * Now boots a new Lisp or connects to an existing via screen.
|
|
||||||
" No longer needs the funnel (although it does need a file to read to/from
|
|
||||||
" screen: it doesn't seem as if 'stuff' can handle very large amounts of
|
|
||||||
" texts)
|
|
||||||
"
|
|
||||||
" 2008-08-18 by Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" * Tab-completed prompt that lets you choose the Lisp process to connect to.
|
|
||||||
" Moved the startup to before the loaded check.
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" startup
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" only do these things once
|
|
||||||
|
|
||||||
let s:Limp_version="0.3.4"
|
|
||||||
|
|
||||||
let s:Limp_location = expand("$LIMPRUNTIME")
|
|
||||||
"if s:Limp_location == "" || s:Limp_location == "$LIMPRUNTIME"
|
|
||||||
if !filereadable(s:Limp_location . "/vim/limp.vim")
|
|
||||||
let s:Limp_location = "/usr/local/limp/" . s:Limp_version
|
|
||||||
endif
|
|
||||||
|
|
||||||
" prefix for the pipe used for communication
|
|
||||||
let s:limp_bridge_channel_base = $HOME . "/.limp_bridge_channel-"
|
|
||||||
let s:limp_bridge_connected=0
|
|
||||||
exe "setlocal complete+=s" . s:Limp_location . "/vim/thesaurus"
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" talk to multiple Lisps using LimpBridge_connect()
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
fun! LimpBridge_complete_lisp(A,L,P)
|
|
||||||
let prefix = s:limp_bridge_channel_base
|
|
||||||
"echom "ls -1 ".prefix."*"
|
|
||||||
let output = system("ls -1 ".prefix."*")
|
|
||||||
if stridx(output, prefix."*") >= 0
|
|
||||||
echom "No Lisps started yet?"
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let files = split(output, "\n")
|
|
||||||
let names = []
|
|
||||||
for f in files
|
|
||||||
let names += [f[strlen(prefix):]]
|
|
||||||
endfor
|
|
||||||
return names
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" optionally specify the screen id to connect to
|
|
||||||
"
|
|
||||||
" return values:
|
|
||||||
"
|
|
||||||
" -1 if user didn't want to connect
|
|
||||||
" 0 if connection wasn't possible
|
|
||||||
" 1 if the user did connect
|
|
||||||
" 2 if the user was already connected
|
|
||||||
"
|
|
||||||
fun! LimpBridge_connect(...)
|
|
||||||
if s:limp_bridge_connected == 1
|
|
||||||
echom "Already connected to Lisp!"
|
|
||||||
return 2
|
|
||||||
endif
|
|
||||||
if a:0 == 1 && a:1 != ""
|
|
||||||
" format: 7213.limp_listener-foo
|
|
||||||
let pid = a:1[:stridx(a:1, '.')-1]
|
|
||||||
let fullname = a:1[stridx(a:1, '.')+1:]
|
|
||||||
let name = fullname[strlen("limp_listener-"):]
|
|
||||||
|
|
||||||
let s:limp_bridge_channel = s:limp_bridge_channel_base.name.".".pid
|
|
||||||
else
|
|
||||||
let s:limp_bridge_channel = s:limp_bridge_channel_base
|
|
||||||
let name = input("Connect to [boot new]: ", "", "customlist,LimpBridge_complete_lisp")
|
|
||||||
if name == ""
|
|
||||||
return -1
|
|
||||||
endif
|
|
||||||
let s:limp_bridge_channel .= name
|
|
||||||
if 0 == filewritable(s:limp_bridge_channel) "|| s:limp_bridge_channel = s:limp_bridge_channel_base
|
|
||||||
echom "Not a Limp channel."
|
|
||||||
return 0
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
" extract the PID from format: foo.104982
|
|
||||||
" (backward from screen sty naming to ease tab completion)
|
|
||||||
|
|
||||||
" bridge id is the file used for communication between Vim and screen
|
|
||||||
let s:limp_bridge_id = strpart(s:limp_bridge_channel, strlen(s:limp_bridge_channel_base))
|
|
||||||
|
|
||||||
" bridge screenid is the screen in which the Lisp is running
|
|
||||||
let s:limp_bridge_screenid = s:limp_bridge_id[strridx(s:limp_bridge_id, '.')+1:]
|
|
||||||
"let s:limp_bridge_scratch = $HOME . "/.limp_bridge_scratch-" . s:limp_bridge_id
|
|
||||||
let s:limp_bridge_test = $HOME . '/.limp_bridge_test-' . s:limp_bridge_id
|
|
||||||
|
|
||||||
silent exe "new" s:limp_bridge_channel
|
|
||||||
if exists( "#BufEnter#*.lisp#" )
|
|
||||||
doauto BufEnter x.lisp
|
|
||||||
endif
|
|
||||||
setlocal syntax=lisp
|
|
||||||
" XXX: in ViLisp, buftype=nowrite, but w/ limp_bridge_channel, vim
|
|
||||||
" complains about the file being write-only.
|
|
||||||
"setlocal buftype=nowrite
|
|
||||||
setlocal bufhidden=hide
|
|
||||||
setlocal nobuflisted
|
|
||||||
setlocal noswapfile
|
|
||||||
hide
|
|
||||||
|
|
||||||
silent exe "new" s:limp_bridge_test
|
|
||||||
if exists( "#BufEnter#*.lisp#" )
|
|
||||||
doauto BufEnter x.lisp
|
|
||||||
endif
|
|
||||||
setlocal syntax=lisp
|
|
||||||
" setlocal buftype=nofile
|
|
||||||
setlocal bufhidden=hide
|
|
||||||
setlocal nobuflisted
|
|
||||||
" setlocal noswapfile
|
|
||||||
hide
|
|
||||||
|
|
||||||
" hide from the user that we created and deleted (hid, really) a couple of
|
|
||||||
" buffers
|
|
||||||
"normal!
|
|
||||||
redraw
|
|
||||||
|
|
||||||
let s:limp_bridge_connected=1
|
|
||||||
|
|
||||||
echom "Welcome to Limp. May your journey be pleasant."
|
|
||||||
|
|
||||||
return 1
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! LimpBridge_connection_status()
|
|
||||||
if s:limp_bridge_connected == 1
|
|
||||||
return "Connected to ".s:limp_bridge_id
|
|
||||||
else
|
|
||||||
return "Disconnected"
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! LimpBridge_disconnect()
|
|
||||||
let s:limp_bridge_connected = 0
|
|
||||||
let s:limp_bridge_id = "<disconnected>"
|
|
||||||
endfun
|
|
||||||
|
|
||||||
"
|
|
||||||
" optionally, specify the path of the core to save to
|
|
||||||
"
|
|
||||||
fun! LimpBridge_quit_lisp(...)
|
|
||||||
" we were given a file
|
|
||||||
if a:0 == 1 && a:1 != ""
|
|
||||||
let core = a:1
|
|
||||||
call LimpBridge_send_to_lisp("(sb-ext:save-lisp-and-die \"".core."\")\n")
|
|
||||||
echom "Lisp ".s:limp_bridge_id." is gone, core saved to ".core."."
|
|
||||||
else
|
|
||||||
call LimpBridge_send_to_lisp("(sb-ext:quit)\n")
|
|
||||||
echom "Lisp ".s:limp_bridge_id." is gone."
|
|
||||||
endif
|
|
||||||
call LimpBridge_disconnect()
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! LimpBridge_shutdown_lisp()
|
|
||||||
if s:limp_bridge_connected == 1
|
|
||||||
let core = input("Name of core to save [none]: ", "", "file")
|
|
||||||
call LimpBridge_quit_lisp(core)
|
|
||||||
else
|
|
||||||
echom "Not connected."
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
|
|
||||||
"
|
|
||||||
" when not connected, start new or connect to existing
|
|
||||||
" otherwise, switch to Lisp (screen)
|
|
||||||
fun! LimpBridge_boot_or_connect_or_display()
|
|
||||||
if s:limp_bridge_connected
|
|
||||||
" is it still running?
|
|
||||||
let status = system("screen -ls")
|
|
||||||
if stridx(status, s:limp_bridge_screenid) == -1
|
|
||||||
call LimpBridge_disconnect()
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let cmd = "screen -x ".s:limp_bridge_screenid
|
|
||||||
if has("gui_running") || b:listener_always_open_window == 1
|
|
||||||
let cmd = "xterm -e " . cmd
|
|
||||||
if b:listener_keep_open == 1
|
|
||||||
let cmd .= " &"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
silent exe "!".cmd
|
|
||||||
redraw!
|
|
||||||
else
|
|
||||||
" connect to a fresh Lisp
|
|
||||||
let what = LimpBridge_connect()
|
|
||||||
if what <= 0
|
|
||||||
" user didn't want to connect, let's boot!
|
|
||||||
let name = input("Name the Lisp: ")
|
|
||||||
if strlen(name) == 0
|
|
||||||
" give up
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let core = input("Path to core to boot [use system-default]: ", "", "file")
|
|
||||||
let core_opt = ""
|
|
||||||
if filereadable(core)
|
|
||||||
let core_opt = "-c ".core
|
|
||||||
echom "Booting ".core."..."
|
|
||||||
else
|
|
||||||
echom "Booting..."
|
|
||||||
endif
|
|
||||||
let styfile = tempname()
|
|
||||||
let cmd = s:Limp_location . "/bin/lisp.sh ".core_opt."-s ".styfile." -b ".name
|
|
||||||
call system(cmd)
|
|
||||||
while getfsize(styfile) <= len("limp_listener")
|
|
||||||
sleep 200m
|
|
||||||
endwhile
|
|
||||||
" needs to be binary, or readfile() expects a newline...
|
|
||||||
let lines = readfile(styfile, 'b')
|
|
||||||
if len(lines) < 1
|
|
||||||
echom "Error getting screen ID!"
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let sty = lines[0]
|
|
||||||
call delete(styfile)
|
|
||||||
call LimpBridge_connect(sty)
|
|
||||||
call LimpBridge_boot_or_connect_or_display()
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
|
|
||||||
augroup LimpBridge
|
|
||||||
au!
|
|
||||||
autocmd BufLeave .LimpBridge_* setlocal nobuflisted
|
|
||||||
autocmd BufLeave *.lisp let g:limp_bridge_last_lisp = bufname( "%" )
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" plugin <-> function mappings
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
|
|
||||||
nnoremap <silent> <buffer> <Plug>LimpBootConnectDisplay :call LimpBridge_boot_or_connect_or_display()<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>LimpDisconnect :call LimpBridge_disconnect()<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>LimpShutdownLisp :call LimpBridge_shutdown_lisp()<CR>
|
|
||||||
|
|
||||||
nnoremap <silent> <buffer> <Plug>EvalTop :call LimpBridge_eval_top_form()<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>EvalCurrent :call LimpBridge_eval_current_form()<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>EvalExpression :call LimpBridge_prompt_eval_expression()<CR>
|
|
||||||
|
|
||||||
vnoremap <silent> <buffer> <Plug>EvalBlock :call LimpBridge_eval_block()<cr>
|
|
||||||
|
|
||||||
nnoremap <silent> <buffer> <Plug>AbortReset :call LimpBridge_send_to_lisp( "ABORT\n" )<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>AbortInterrupt :call LimpBridge_send_to_lisp( "" )<CR>
|
|
||||||
|
|
||||||
nnoremap <silent> <buffer> <Plug>TestCurrent :call LimpBridge_stuff_current_form()<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>TestTop :call LimpBridge_stuff_top_form()<CR>
|
|
||||||
|
|
||||||
nnoremap <silent> <buffer> <Plug>LoadThisFile :call LimpBridge_send_to_lisp( "(load \"" . expand( "%:p" ) . "\")\n")<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>LoadAnyFile :call LimpBridge_send_to_lisp( "(load \"" . expand( "%:p:r" ) . "\")\n")<CR>
|
|
||||||
|
|
||||||
nnoremap <silent> <buffer> <Plug>CompileFile :w! <bar> call LimpBridge_send_to_lisp("(compile-file \"".expand("%:p")."\")\n")<CR>
|
|
||||||
|
|
||||||
" XXX: What's the proprer syntax for calling >1 Plug?
|
|
||||||
""nnoremap <buffer> <Plug>CompileAndLoadFile <Plug>CompileFile <bar> <Plug>LoadAnyFile
|
|
||||||
nnoremap <silent> <buffer> <Plug>CompileAndLoadFile :w! <bar> call LimpBridge_send_to_lisp("(compile-file \"".expand("%:p")."\")\n") <bar> call LimpBridge_send_to_lisp( "(load \"" . expand( "%:p:r" ) . "\")\n")<CR>
|
|
||||||
|
|
||||||
" Goto Test Buffer:
|
|
||||||
" Goto Split: split current buffer and goto test buffer
|
|
||||||
nnoremap <silent> <buffer> <Plug>GotoTestBuffer :call LimpBridge_goto_buffer_or_window(g:limp_bridge_test)<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>GotoTestBufferAndSplit :sb <bar> call LimpBridge_goto_buffer_or_window(g:limp_bridge_test)<CR>
|
|
||||||
|
|
||||||
" Goto Last: return to g:limp_bridge_last_lisp, i.e. last buffer
|
|
||||||
nnoremap <silent> <buffer> <Plug>GotoLastLispBuffer :call LimpBridge_goto_buffer_or_window(g:limp_bridge_last_lisp)<CR>
|
|
||||||
|
|
||||||
" HyperSpec:
|
|
||||||
nnoremap <silent> <buffer> <Plug>HyperspecExact :call LimpBridge_hyperspec("exact", 0)<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>HyperspecPrefix :call LimpBridge_hyperspec("prefix", 1)<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>HyperspecSuffix :call LimpBridge_hyperspec("suffix", 1)<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>HyperspecGrep :call LimpBridge_hyperspec("grep", 1)<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>HyperspecFirstLetterIndex :call LimpBridge_hyperspec("index", 0)<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>HyperspecFullIndex :call LimpBridge_hyperspec("index-page", 0)<CR>
|
|
||||||
|
|
||||||
" Help Describe: ask Lisp about the current symbol
|
|
||||||
nnoremap <silent> <buffer> <Plug>HelpDescribe :call LimpBridge_send_to_lisp("(describe '".expand("<cword>").")")<CR>
|
|
||||||
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" library
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" assume that all of the file has been loaded & defined once
|
|
||||||
" if one of the functions are defined.
|
|
||||||
if exists("*LimpBridge_goto_buffer_or_window")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
function! LimpBridge_goto_buffer_or_window( buff )
|
|
||||||
if -1 == bufwinnr( a:buff )
|
|
||||||
exe "hide bu" a:buff
|
|
||||||
else
|
|
||||||
exe bufwinnr( a:buff ) . "wincmd w"
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
function! LimpBridge_get_pos()
|
|
||||||
" what buffer are we in?
|
|
||||||
let bufnr = bufnr( "%" )
|
|
||||||
|
|
||||||
" get current position
|
|
||||||
let c_cur = virtcol( "." )
|
|
||||||
let l_cur = line( "." )
|
|
||||||
normal! H
|
|
||||||
let l_top = line( "." )
|
|
||||||
|
|
||||||
let pos = bufnr . "|" . l_top . "," . l_cur . "," . c_cur
|
|
||||||
|
|
||||||
" go back
|
|
||||||
exe "normal! " l_cur . "G" . c_cur . "|"
|
|
||||||
|
|
||||||
return( pos )
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
function! LimpBridge_goto_pos( pos )
|
|
||||||
let mx = '\(\d\+\)|\(\d\+\),\(\d\+\),\(\d\+\)'
|
|
||||||
let bufnr = substitute( a:pos, mx, '\1', '' )
|
|
||||||
let l_top = substitute( a:pos, mx, '\2', '' )
|
|
||||||
let l_cur = substitute( a:pos, mx, '\3', '' )
|
|
||||||
let c_cur = substitute( a:pos, mx, '\4', '' )
|
|
||||||
|
|
||||||
silent exe "hide bu" bufnr
|
|
||||||
silent exe "normal! " . l_top . "Gzt" . l_cur . "G" . c_cur . "|"
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
function! LimpBridge_yank( motion )
|
|
||||||
let value = ''
|
|
||||||
|
|
||||||
let p = LimpBridge_get_pos()
|
|
||||||
silent! exec 'normal!' a:motion
|
|
||||||
let new_p = LimpBridge_get_pos()
|
|
||||||
|
|
||||||
" did we move?
|
|
||||||
if p != new_p
|
|
||||||
" go back
|
|
||||||
silent! exec 'normal!' a:motion
|
|
||||||
|
|
||||||
let old_l = @l
|
|
||||||
exec 'normal! "ly' . a:motion
|
|
||||||
let value = @l
|
|
||||||
let @l = old_l
|
|
||||||
endif
|
|
||||||
|
|
||||||
call LimpBridge_goto_pos( p )
|
|
||||||
|
|
||||||
return( value )
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
" copy an expression to a buffer
|
|
||||||
function! LimpBridge_send_sexp_to_buffer( sexp, buffer )
|
|
||||||
let p = LimpBridge_get_pos()
|
|
||||||
|
|
||||||
" go to the given buffer, go to the bottom
|
|
||||||
exe "hide bu" a:buffer
|
|
||||||
silent normal! G
|
|
||||||
|
|
||||||
" tried append() -- doesn't work the way I need it to
|
|
||||||
let old_l = @l
|
|
||||||
let @l = a:sexp
|
|
||||||
silent exe "put l"
|
|
||||||
" normal! "lp
|
|
||||||
let @l = old_l
|
|
||||||
|
|
||||||
call LimpBridge_goto_pos( p )
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
" destroys contents of LimpBridge_channel buffer
|
|
||||||
function! LimpBridge_send_to_lisp( sexp )
|
|
||||||
if a:sexp == ''
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !s:limp_bridge_connected
|
|
||||||
echom "Not connected to Lisp!"
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
let p = LimpBridge_get_pos()
|
|
||||||
|
|
||||||
" goto LimpBridge_channel, delete it, put s-exp, write it to lisp
|
|
||||||
try
|
|
||||||
exe "hide bu" s:limp_bridge_channel
|
|
||||||
exe "%d"
|
|
||||||
normal! 1G
|
|
||||||
|
|
||||||
" tried append() -- doesn't work the way I need it to
|
|
||||||
let old_l = @l
|
|
||||||
let @l = a:sexp
|
|
||||||
normal! "lP
|
|
||||||
let @l = old_l
|
|
||||||
|
|
||||||
silent exe 'w!'
|
|
||||||
call system('screen -x '.s:limp_bridge_screenid.' -p 0 -X eval "readbuf" "paste ."')
|
|
||||||
catch /^Vim:E211:/
|
|
||||||
echom "Lisp is gone!"
|
|
||||||
" file not available, Lisp disappeared
|
|
||||||
call LimpBridge_disconnect()
|
|
||||||
endtry
|
|
||||||
|
|
||||||
call LimpBridge_goto_pos( p )
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! LimpBridge_prompt_eval_expression()
|
|
||||||
let whatwhat = input("Eval: ")
|
|
||||||
call LimpBridge_send_to_lisp(whatwhat)
|
|
||||||
endfun
|
|
||||||
|
|
||||||
|
|
||||||
" Actually evals current top level form
|
|
||||||
function! LimpBridge_eval_top_form()
|
|
||||||
" save position
|
|
||||||
let p = LimpBridge_get_pos()
|
|
||||||
|
|
||||||
silent! exec "normal! 99[("
|
|
||||||
call LimpBridge_send_to_lisp( LimpBridge_yank( "%" ) )
|
|
||||||
|
|
||||||
" fix cursor position, in case of error below
|
|
||||||
call LimpBridge_goto_pos( p )
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
function! LimpBridge_eval_current_form()
|
|
||||||
" save position
|
|
||||||
let pos = LimpBridge_get_pos()
|
|
||||||
|
|
||||||
" find & yank current s-exp
|
|
||||||
normal! [(
|
|
||||||
let sexp = LimpBridge_yank( "%" )
|
|
||||||
call LimpBridge_send_to_lisp( sexp )
|
|
||||||
call LimpBridge_goto_pos( pos )
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
function! LimpBridge_eval_block() range
|
|
||||||
" save position
|
|
||||||
let pos = LimpBridge_get_pos()
|
|
||||||
|
|
||||||
" yank current visual block
|
|
||||||
let old_l = @l
|
|
||||||
'<,'> yank l
|
|
||||||
let sexp = @l
|
|
||||||
let @l = old_l
|
|
||||||
|
|
||||||
call LimpBridge_send_to_lisp( sexp )
|
|
||||||
call LimpBridge_goto_pos( pos )
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
function! LimpBridge_stuff_current_form()
|
|
||||||
" save position
|
|
||||||
let pos = LimpBridge_get_pos()
|
|
||||||
|
|
||||||
" find & yank current s-exp
|
|
||||||
normal! [(
|
|
||||||
call LimpBridge_send_sexp_to_buffer( LimpBridge_yank( "%" ), s:limp_bridge_test )
|
|
||||||
|
|
||||||
call LimpBridge_goto_pos( pos )
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! LimpBridge_stuff_top_form()
|
|
||||||
" save position
|
|
||||||
let pos = LimpBridge_get_pos()
|
|
||||||
|
|
||||||
" find & yank top-level s-exp
|
|
||||||
silent! exec "normal! 99[("
|
|
||||||
call LimpBridge_send_sexp_to_buffer( LimpBridge_yank( "%" ), s:limp_bridge_test )
|
|
||||||
|
|
||||||
call LimpBridge_goto_pos( pos )
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! LimpBridge_hyperspec(type, make_page)
|
|
||||||
" get current word under cursor
|
|
||||||
let word = expand( "<cword>" )
|
|
||||||
let cmd = "! perl " . s:Limp_location . "/bin/limp-hyperspec.pl"
|
|
||||||
let cmd = cmd . " " . a:type . " " . a:make_page . " '" . word . "'"
|
|
||||||
silent! exe cmd
|
|
||||||
redraw!
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
@@ -1,207 +0,0 @@
|
|||||||
"
|
|
||||||
" limp/vim/cursor.vim
|
|
||||||
"
|
|
||||||
" URL:
|
|
||||||
" http://mikael.jansson.be/hacking
|
|
||||||
"
|
|
||||||
" Description:
|
|
||||||
" Save/restore cursor position in window (mostly obsoleted by Vim7 though)
|
|
||||||
"
|
|
||||||
" Version:
|
|
||||||
" 0.2
|
|
||||||
"
|
|
||||||
" Date:
|
|
||||||
" 2008-04-25
|
|
||||||
"
|
|
||||||
" Authors:
|
|
||||||
" Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" Charles E. Campbell, Jr. <drNchipO@ScampbellPfamilyA.Mbiz>-NOSPAM
|
|
||||||
"
|
|
||||||
" Changelog:
|
|
||||||
" 2008-04-18
|
|
||||||
" * Removed all leader mappings
|
|
||||||
"
|
|
||||||
" Usage:
|
|
||||||
" call Cursor_push()
|
|
||||||
" let cursor = Cursor_get()
|
|
||||||
"
|
|
||||||
" call Cursor_pop()
|
|
||||||
" call Cursor_set(cursor)
|
|
||||||
"
|
|
||||||
|
|
||||||
" Load Once: {{{1
|
|
||||||
|
|
||||||
let s:keepcpo = &cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
" -----------------------
|
|
||||||
" Public Interface: {{{1
|
|
||||||
" -----------------------
|
|
||||||
let s:modifier= "sil keepj "
|
|
||||||
|
|
||||||
|
|
||||||
" assume that all of the file has been loaded & defined once
|
|
||||||
" if one of the functions are defined.
|
|
||||||
if exists("*Cursor_get")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Cursor_get: {{{1
|
|
||||||
" Return the current cursor (as an executable command!)
|
|
||||||
"
|
|
||||||
fun! Cursor_get()
|
|
||||||
if line(".") == 1 && getline(1) == ""
|
|
||||||
return ""
|
|
||||||
endif
|
|
||||||
|
|
||||||
" disable various scrolling trickery
|
|
||||||
let so_keep = &so
|
|
||||||
let siso_keep = &siso
|
|
||||||
let ss_keep = &ss
|
|
||||||
set so=0 siso=0 ss=0
|
|
||||||
|
|
||||||
let swline = line(".")
|
|
||||||
let swcol = col(".")
|
|
||||||
let swwline = winline() - 1
|
|
||||||
let swwcol = virtcol(".") - wincol()
|
|
||||||
let cursordata = "call Window_goto_by_buffer_number(".winbufnr(0).")|silent ".swline
|
|
||||||
let cursordata = cursordata."|".s:modifier."norm! 0z\<cr>"
|
|
||||||
if swwline > 0
|
|
||||||
let cursordata = cursordata.":".s:modifier."norm! ".swwline."\<c-y>\<cr>"
|
|
||||||
endif
|
|
||||||
if swwcol > 0
|
|
||||||
let cursordata = cursordata.":".s:modifier."norm! 0".swwcol."zl\<cr>"
|
|
||||||
endif
|
|
||||||
let cursordata = cursordata.":".s:modifier."call cursor(".swline.",".swcol.")\<cr>"
|
|
||||||
|
|
||||||
" restore scrolling flags
|
|
||||||
let &so = so_keep
|
|
||||||
let &siso = siso_keep
|
|
||||||
let &ss = ss_keep
|
|
||||||
|
|
||||||
return cursordata
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" Cursor_set: {{{1
|
|
||||||
" Set the current cursor to an old one
|
|
||||||
"
|
|
||||||
fun! Cursor_set(cursordata)
|
|
||||||
exe "silent ".a:cursordata
|
|
||||||
endfun
|
|
||||||
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Cursor_push {{{1
|
|
||||||
" let cursor = Cursor_push() save window position in b:cursor_position_{b:cursor_position_index}
|
|
||||||
" and return cursor.
|
|
||||||
fun! Cursor_push(...)
|
|
||||||
let cursordata = Cursor_get()
|
|
||||||
|
|
||||||
" save window position in
|
|
||||||
" b:cursor_position_{b:cursor_position_index} (stack)
|
|
||||||
if !exists("b:cursor_position_index")
|
|
||||||
let b:cursor_position_index= 1
|
|
||||||
else
|
|
||||||
let b:cursor_position_index = b:cursor_position_index + 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
let b:cursor_position_{b:cursor_position_index} = cursordata
|
|
||||||
|
|
||||||
return cursordata
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Cursor_pop: {{{1
|
|
||||||
fun! Cursor_pop()
|
|
||||||
if line(".") == 1 && getline(1) == ""
|
|
||||||
return ""
|
|
||||||
endif
|
|
||||||
let so_keep = &so
|
|
||||||
let siso_keep = &siso
|
|
||||||
let ss_keep = &ss
|
|
||||||
set so=0 siso=0 ss=0
|
|
||||||
|
|
||||||
" use saved window position in b:cursor_position_{b:cursor_position_index} if it exists
|
|
||||||
if exists("b:cursor_position_index") && exists("b:cursor_position_{b:cursor_position_index}")
|
|
||||||
try
|
|
||||||
exe "silent! ".b:cursor_position_{b:cursor_position_index}
|
|
||||||
catch /^Vim\%((\a\+)\)\=:E749/
|
|
||||||
" ignore empty buffer error messages
|
|
||||||
endtry
|
|
||||||
" normally drop top-of-stack by one
|
|
||||||
" but while new top-of-stack doesn't exist
|
|
||||||
" drop top-of-stack index by one again
|
|
||||||
if b:cursor_position_index >= 1
|
|
||||||
unlet b:cursor_position_{b:cursor_position_index}
|
|
||||||
let b:cursor_position_index= b:cursor_position_index - 1
|
|
||||||
while b:cursor_position_index >= 1 && !exists("b:cursor_position_{b:cursor_position_index}")
|
|
||||||
let b:cursor_position_index= b:cursor_position_index - 1
|
|
||||||
endwhile
|
|
||||||
if b:cursor_position_index < 1
|
|
||||||
unlet b:cursor_position_index
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
echohl WarningMsg
|
|
||||||
echomsg "***warning*** need to cursor_save() first!"
|
|
||||||
echohl None
|
|
||||||
endif
|
|
||||||
|
|
||||||
" seems to be something odd: vertical motions after RWP
|
|
||||||
" cause jump to first column. Following fixes that
|
|
||||||
if wincol() > 1
|
|
||||||
silent norm! hl
|
|
||||||
elseif virtcol(".") < virtcol("$")
|
|
||||||
silent norm! lh
|
|
||||||
endif
|
|
||||||
|
|
||||||
let &so = so_keep
|
|
||||||
let &siso = siso_keep
|
|
||||||
let &ss = ss_keep
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Window_goto_by_buffer_number: go to window holding given buffer (by number) {{{1
|
|
||||||
" Prefers current window; if its buffer number doesn't match,
|
|
||||||
" then will try from topleft to bottom right
|
|
||||||
fun! Window_goto_by_buffer_number(bufnum)
|
|
||||||
if winbufnr(0) == a:bufnum
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
winc t
|
|
||||||
let first=1
|
|
||||||
while winbufnr(0) != a:bufnum && (first || winnr() != 1)
|
|
||||||
winc w
|
|
||||||
let first= 0
|
|
||||||
endwhile
|
|
||||||
endfun
|
|
||||||
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" ListWinPosn:
|
|
||||||
"fun! ListWinPosn() " Decho
|
|
||||||
" if !exists("b:cursor_position_index") || b:cursor_position_index == 0 " Decho
|
|
||||||
" call Decho("nothing on SWP stack") " Decho
|
|
||||||
" else " Decho
|
|
||||||
" let jwinposn= b:cursor_position_index " Decho
|
|
||||||
" while jwinposn >= 1 " Decho
|
|
||||||
" if exists("b:cursor_position{jwinposn}") " Decho
|
|
||||||
" call Decho("winposn{".jwinposn."}<".b:cursor_position{jwinposn}.">") " Decho
|
|
||||||
" else " Decho
|
|
||||||
" call Decho("winposn{".jwinposn."} -- doesn't exist") " Decho
|
|
||||||
" endif " Decho
|
|
||||||
" let jwinposn= jwinposn - 1 " Decho
|
|
||||||
" endwhile " Decho
|
|
||||||
" endif " Decho
|
|
||||||
"endfun " Decho
|
|
||||||
"com! -nargs=0 LWP call ListWinPosn() " Decho
|
|
||||||
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Restore: {{{1
|
|
||||||
let &cpo = s:keepcpo
|
|
||||||
unlet s:keepcpo
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Modelines: {{{1
|
|
||||||
" vim: ts=4 fdm=marker
|
|
||||||
@@ -1,338 +0,0 @@
|
|||||||
" Vim color file
|
|
||||||
" Maintainer: Henry So, Jr. <henryso@panix.com>
|
|
||||||
|
|
||||||
" These are the colors of the "desert" theme by Hans Fugal with a few small
|
|
||||||
" modifications (namely that I lowered the intensity of the normal white and
|
|
||||||
" made the normal and nontext backgrounds black), modified to work with 88-
|
|
||||||
" and 256-color xterms.
|
|
||||||
"
|
|
||||||
" The original "desert" theme is available as part of the vim distribution or
|
|
||||||
" at http://hans.fugal.net/vim/colors/.
|
|
||||||
"
|
|
||||||
" The real feature of this color scheme, with a wink to the "inkpot" theme, is
|
|
||||||
" the programmatic approximation of the gui colors to the palettes of 88- and
|
|
||||||
" 256- color xterms. The functions that do this (folded away, for
|
|
||||||
" readability) are calibrated to the colors used for Thomas E. Dickey's xterm
|
|
||||||
" (version 200), which is available at http://dickey.his.com/xterm/xterm.html.
|
|
||||||
"
|
|
||||||
" I struggled with trying to parse the rgb.txt file to avoid the necessity of
|
|
||||||
" converting color names to #rrggbb form, but decided it was just not worth
|
|
||||||
" the effort. Maybe someone seeing this may decide otherwise...
|
|
||||||
|
|
||||||
set background=dark
|
|
||||||
if version > 580
|
|
||||||
" no guarantees for version 5.8 and below, but this makes it stop
|
|
||||||
" complaining
|
|
||||||
hi clear
|
|
||||||
if exists("syntax_on")
|
|
||||||
syntax reset
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
let g:colors_name="desert256"
|
|
||||||
|
|
||||||
if has("gui_running") || &t_Co == 88 || &t_Co == 256
|
|
||||||
" functions {{{
|
|
||||||
" returns an approximate grey index for the given grey level
|
|
||||||
fun <SID>grey_number(x)
|
|
||||||
if &t_Co == 88
|
|
||||||
if a:x < 23
|
|
||||||
return 0
|
|
||||||
elseif a:x < 69
|
|
||||||
return 1
|
|
||||||
elseif a:x < 103
|
|
||||||
return 2
|
|
||||||
elseif a:x < 127
|
|
||||||
return 3
|
|
||||||
elseif a:x < 150
|
|
||||||
return 4
|
|
||||||
elseif a:x < 173
|
|
||||||
return 5
|
|
||||||
elseif a:x < 196
|
|
||||||
return 6
|
|
||||||
elseif a:x < 219
|
|
||||||
return 7
|
|
||||||
elseif a:x < 243
|
|
||||||
return 8
|
|
||||||
else
|
|
||||||
return 9
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
if a:x < 14
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
let l:n = (a:x - 8) / 10
|
|
||||||
let l:m = (a:x - 8) % 10
|
|
||||||
if l:m < 5
|
|
||||||
return l:n
|
|
||||||
else
|
|
||||||
return l:n + 1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" returns the actual grey level represented by the grey index
|
|
||||||
fun <SID>grey_level(n)
|
|
||||||
if &t_Co == 88
|
|
||||||
if a:n == 0
|
|
||||||
return 0
|
|
||||||
elseif a:n == 1
|
|
||||||
return 46
|
|
||||||
elseif a:n == 2
|
|
||||||
return 92
|
|
||||||
elseif a:n == 3
|
|
||||||
return 115
|
|
||||||
elseif a:n == 4
|
|
||||||
return 139
|
|
||||||
elseif a:n == 5
|
|
||||||
return 162
|
|
||||||
elseif a:n == 6
|
|
||||||
return 185
|
|
||||||
elseif a:n == 7
|
|
||||||
return 208
|
|
||||||
elseif a:n == 8
|
|
||||||
return 231
|
|
||||||
else
|
|
||||||
return 255
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
if a:n == 0
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 8 + (a:n * 10)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" returns the palette index for the given grey index
|
|
||||||
fun <SID>grey_color(n)
|
|
||||||
if &t_Co == 88
|
|
||||||
if a:n == 0
|
|
||||||
return 16
|
|
||||||
elseif a:n == 9
|
|
||||||
return 79
|
|
||||||
else
|
|
||||||
return 79 + a:n
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
if a:n == 0
|
|
||||||
return 16
|
|
||||||
elseif a:n == 25
|
|
||||||
return 231
|
|
||||||
else
|
|
||||||
return 231 + a:n
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" returns an approximate color index for the given color level
|
|
||||||
fun <SID>rgb_number(x)
|
|
||||||
if &t_Co == 88
|
|
||||||
if a:x < 69
|
|
||||||
return 0
|
|
||||||
elseif a:x < 172
|
|
||||||
return 1
|
|
||||||
elseif a:x < 230
|
|
||||||
return 2
|
|
||||||
else
|
|
||||||
return 3
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
if a:x < 75
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
let l:n = (a:x - 55) / 40
|
|
||||||
let l:m = (a:x - 55) % 40
|
|
||||||
if l:m < 20
|
|
||||||
return l:n
|
|
||||||
else
|
|
||||||
return l:n + 1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" returns the actual color level for the given color index
|
|
||||||
fun <SID>rgb_level(n)
|
|
||||||
if &t_Co == 88
|
|
||||||
if a:n == 0
|
|
||||||
return 0
|
|
||||||
elseif a:n == 1
|
|
||||||
return 139
|
|
||||||
elseif a:n == 2
|
|
||||||
return 205
|
|
||||||
else
|
|
||||||
return 255
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
if a:n == 0
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
return 55 + (a:n * 40)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" returns the palette index for the given R/G/B color indices
|
|
||||||
fun <SID>rgb_color(x, y, z)
|
|
||||||
if &t_Co == 88
|
|
||||||
return 16 + (a:x * 16) + (a:y * 4) + a:z
|
|
||||||
else
|
|
||||||
return 16 + (a:x * 36) + (a:y * 6) + a:z
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" returns the palette index to approximate the given R/G/B color levels
|
|
||||||
fun <SID>color(r, g, b)
|
|
||||||
" get the closest grey
|
|
||||||
let l:gx = <SID>grey_number(a:r)
|
|
||||||
let l:gy = <SID>grey_number(a:g)
|
|
||||||
let l:gz = <SID>grey_number(a:b)
|
|
||||||
|
|
||||||
" get the closest color
|
|
||||||
let l:x = <SID>rgb_number(a:r)
|
|
||||||
let l:y = <SID>rgb_number(a:g)
|
|
||||||
let l:z = <SID>rgb_number(a:b)
|
|
||||||
|
|
||||||
if l:gx == l:gy && l:gy == l:gz
|
|
||||||
" there are two possibilities
|
|
||||||
let l:dgr = <SID>grey_level(l:gx) - a:r
|
|
||||||
let l:dgg = <SID>grey_level(l:gy) - a:g
|
|
||||||
let l:dgb = <SID>grey_level(l:gz) - a:b
|
|
||||||
let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
|
|
||||||
let l:dr = <SID>rgb_level(l:gx) - a:r
|
|
||||||
let l:dg = <SID>rgb_level(l:gy) - a:g
|
|
||||||
let l:db = <SID>rgb_level(l:gz) - a:b
|
|
||||||
let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
|
|
||||||
if l:dgrey < l:drgb
|
|
||||||
" use the grey
|
|
||||||
return <SID>grey_color(l:gx)
|
|
||||||
else
|
|
||||||
" use the color
|
|
||||||
return <SID>rgb_color(l:x, l:y, l:z)
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
" only one possibility
|
|
||||||
return <SID>rgb_color(l:x, l:y, l:z)
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" returns the palette index to approximate the 'rrggbb' hex string
|
|
||||||
fun <SID>rgb(rgb)
|
|
||||||
let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
|
|
||||||
let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
|
|
||||||
let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
|
|
||||||
|
|
||||||
return <SID>color(l:r, l:g, l:b)
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" sets the highlighting for the given group
|
|
||||||
fun <SID>X(group, fg, bg, attr)
|
|
||||||
if a:fg != ""
|
|
||||||
exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . <SID>rgb(a:fg)
|
|
||||||
endif
|
|
||||||
if a:bg != ""
|
|
||||||
exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . <SID>rgb(a:bg)
|
|
||||||
endif
|
|
||||||
if a:attr != ""
|
|
||||||
exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
|
|
||||||
endif
|
|
||||||
endfun
|
|
||||||
" }}}
|
|
||||||
|
|
||||||
call <SID>X("Normal", "cccccc", "000000", "")
|
|
||||||
|
|
||||||
" highlight groups
|
|
||||||
call <SID>X("Cursor", "708090", "f0e68c", "")
|
|
||||||
"CursorIM
|
|
||||||
"Directory
|
|
||||||
"DiffAdd
|
|
||||||
"DiffChange
|
|
||||||
"DiffDelete
|
|
||||||
"DiffText
|
|
||||||
"ErrorMsg
|
|
||||||
call <SID>X("VertSplit", "c2bfa5", "7f7f7f", "reverse")
|
|
||||||
call <SID>X("Folded", "ffd700", "4d4d4d", "")
|
|
||||||
call <SID>X("FoldColumn", "d2b48c", "4d4d4d", "")
|
|
||||||
call <SID>X("IncSearch", "708090", "f0e68c", "")
|
|
||||||
"LineNr
|
|
||||||
call <SID>X("ModeMsg", "daa520", "", "")
|
|
||||||
call <SID>X("MoreMsg", "2e8b57", "", "")
|
|
||||||
call <SID>X("NonText", "addbe7", "000000", "bold")
|
|
||||||
call <SID>X("Question", "00ff7f", "", "")
|
|
||||||
call <SID>X("Search", "f5deb3", "cd853f", "")
|
|
||||||
call <SID>X("SpecialKey", "9acd32", "", "")
|
|
||||||
call <SID>X("StatusLine", "c2bfa5", "000000", "reverse")
|
|
||||||
call <SID>X("StatusLineNC", "c2bfa5", "7f7f7f", "reverse")
|
|
||||||
call <SID>X("Title", "cd5c5c", "", "")
|
|
||||||
call <SID>X("Visual", "6b8e23", "f0e68c", "reverse")
|
|
||||||
"VisualNOS
|
|
||||||
call <SID>X("WarningMsg", "fa8072", "", "")
|
|
||||||
"WildMenu
|
|
||||||
"Menu
|
|
||||||
"Scrollbar
|
|
||||||
"Tooltip
|
|
||||||
|
|
||||||
" syntax highlighting groups
|
|
||||||
call <SID>X("Comment", "87ceeb", "", "")
|
|
||||||
call <SID>X("Constant", "ffa0a0", "", "")
|
|
||||||
call <SID>X("Identifier", "98fb98", "", "none")
|
|
||||||
call <SID>X("Statement", "f0e68c", "", "bold")
|
|
||||||
call <SID>X("PreProc", "cd5c5c", "", "")
|
|
||||||
call <SID>X("Type", "bdb76b", "", "bold")
|
|
||||||
call <SID>X("Special", "ffdead", "", "")
|
|
||||||
"Underlined
|
|
||||||
call <SID>X("Ignore", "666666", "", "")
|
|
||||||
"Error
|
|
||||||
call <SID>X("Todo", "ff4500", "eeee00", "")
|
|
||||||
|
|
||||||
" delete functions {{{
|
|
||||||
delf <SID>X
|
|
||||||
delf <SID>rgb
|
|
||||||
delf <SID>color
|
|
||||||
delf <SID>rgb_color
|
|
||||||
delf <SID>rgb_level
|
|
||||||
delf <SID>rgb_number
|
|
||||||
delf <SID>grey_color
|
|
||||||
delf <SID>grey_level
|
|
||||||
delf <SID>grey_number
|
|
||||||
" }}}
|
|
||||||
else
|
|
||||||
" color terminal definitions
|
|
||||||
hi SpecialKey ctermfg=darkgreen
|
|
||||||
hi NonText cterm=bold ctermfg=darkblue
|
|
||||||
hi Directory ctermfg=darkcyan
|
|
||||||
hi ErrorMsg cterm=bold ctermfg=7 ctermbg=1
|
|
||||||
hi IncSearch cterm=NONE ctermfg=yellow ctermbg=green
|
|
||||||
hi Search cterm=NONE ctermfg=grey ctermbg=blue
|
|
||||||
hi MoreMsg ctermfg=darkgreen
|
|
||||||
hi ModeMsg cterm=NONE ctermfg=brown
|
|
||||||
hi LineNr ctermfg=3
|
|
||||||
hi Question ctermfg=green
|
|
||||||
hi StatusLine cterm=bold,reverse
|
|
||||||
hi StatusLineNC cterm=reverse
|
|
||||||
hi VertSplit cterm=reverse
|
|
||||||
hi Title ctermfg=5
|
|
||||||
hi Visual cterm=reverse
|
|
||||||
hi VisualNOS cterm=bold,underline
|
|
||||||
hi WarningMsg ctermfg=1
|
|
||||||
hi WildMenu ctermfg=0 ctermbg=3
|
|
||||||
hi Folded ctermfg=darkgrey ctermbg=NONE
|
|
||||||
hi FoldColumn ctermfg=darkgrey ctermbg=NONE
|
|
||||||
hi DiffAdd ctermbg=4
|
|
||||||
hi DiffChange ctermbg=5
|
|
||||||
hi DiffDelete cterm=bold ctermfg=4 ctermbg=6
|
|
||||||
hi DiffText cterm=bold ctermbg=1
|
|
||||||
hi Comment ctermfg=darkcyan
|
|
||||||
hi Constant ctermfg=brown
|
|
||||||
hi Special ctermfg=5
|
|
||||||
hi Identifier ctermfg=6
|
|
||||||
hi Statement ctermfg=3
|
|
||||||
hi PreProc ctermfg=5
|
|
||||||
hi Type ctermfg=2
|
|
||||||
hi Underlined cterm=underline ctermfg=5
|
|
||||||
hi Ignore ctermfg=darkgrey
|
|
||||||
hi Error cterm=bold ctermfg=7 ctermbg=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" vim: set fdl=0 fdm=marker:
|
|
||||||
@@ -1,236 +0,0 @@
|
|||||||
"
|
|
||||||
" limp/vim/highlight.vim
|
|
||||||
"
|
|
||||||
" URL:
|
|
||||||
" http://mikael.jansson.be/hacking
|
|
||||||
"
|
|
||||||
" Description:
|
|
||||||
" Highlight parens and containing s-exps
|
|
||||||
"
|
|
||||||
" Version:
|
|
||||||
" 0.2
|
|
||||||
"
|
|
||||||
" Date:
|
|
||||||
" 2008-04-25
|
|
||||||
"
|
|
||||||
" Authors:
|
|
||||||
" Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" Charles E. Campbell, Jr. <drNchipO@ScampbellPfamilyA.Mbiz>-NOSPAM
|
|
||||||
"
|
|
||||||
" Changelog:
|
|
||||||
" 2008-04-25
|
|
||||||
" * Fixed regressions. Now properly highlights blocks again.
|
|
||||||
"
|
|
||||||
" 2008-04-18
|
|
||||||
" * Removed all mappings
|
|
||||||
" * Removed < 7.00 compatibility
|
|
||||||
" * Renamed to Lim-Highlight
|
|
||||||
" * Changed from Search to Brackets[Block]
|
|
||||||
"
|
|
||||||
" Usage: {{{1
|
|
||||||
" Before loading:
|
|
||||||
" let g:LimpHighlight = 1
|
|
||||||
" or after loading:
|
|
||||||
" call LimpHighlight_start()
|
|
||||||
"
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" Load Once: {{{1
|
|
||||||
|
|
||||||
let s:keepcpo = &cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
" disable matchparen: we do that ourselves.
|
|
||||||
let g:loaded_matchparen = 1
|
|
||||||
|
|
||||||
" assume that all of the file has been loaded & defined once
|
|
||||||
" if one of the functions are defined.
|
|
||||||
if exists("*LimpHighlight_start")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
fun! LimpHighlight_start()
|
|
||||||
if exists("g:limp_highlight_active")
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let g:limp_highlight_active = 1
|
|
||||||
|
|
||||||
if !exists("*Cursor_get")
|
|
||||||
" due to loading order, <limp/cursor.vim> may not have loaded yet.
|
|
||||||
" attempt to force a load now. Ditto for matchit!
|
|
||||||
silent! runtime limp/cursor.vim
|
|
||||||
endif
|
|
||||||
silent! runtime plugin/matchit.vim
|
|
||||||
|
|
||||||
" set whichwrap
|
|
||||||
let s:wwkeep = &ww
|
|
||||||
set ww=b,s,<,>,[,]
|
|
||||||
|
|
||||||
augroup LimpHighlight
|
|
||||||
au!
|
|
||||||
au CursorMoved * silent call s:LimpHighlight_handler()
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
set lz
|
|
||||||
call s:LimpHighlight_handler()
|
|
||||||
set nolz
|
|
||||||
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! LimpHighlight_stop()
|
|
||||||
"echom "Stopping highlight"
|
|
||||||
set lz
|
|
||||||
if exists("g:limp_highlight_active")
|
|
||||||
unlet g:limp_highlight_active
|
|
||||||
endif
|
|
||||||
match none
|
|
||||||
2match none
|
|
||||||
|
|
||||||
" remove cursorhold event for highlighting matching bracket
|
|
||||||
augroup LimpHighlight
|
|
||||||
au!
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
let &ww = s:wwkeep
|
|
||||||
set nolz
|
|
||||||
endfun
|
|
||||||
|
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
|
||||||
" LimpHighlight_handler: this routine actually performs the highlighting of {{{1
|
|
||||||
" the matching bracket.
|
|
||||||
fun! <SID>LimpHighlight_handler()
|
|
||||||
if mode() =~ '['."\<c-v>".'vV]'
|
|
||||||
" don't try to highlight matching/surrounding brackets while in
|
|
||||||
" visual-block mode
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
" save
|
|
||||||
let magickeep = &magic
|
|
||||||
let regdq = @"
|
|
||||||
let regunnamed = @@
|
|
||||||
let sokeep = &so
|
|
||||||
let sskeep = &ss
|
|
||||||
let sisokeep = &siso
|
|
||||||
let solkeep = &sol
|
|
||||||
let t_vbkeep = &t_vb
|
|
||||||
let vbkeep = &vb
|
|
||||||
silent! let regpaste = @*
|
|
||||||
|
|
||||||
" turn beep/visual flash off
|
|
||||||
set nosol vb t_vb= so=0 siso=0 ss=0 magic
|
|
||||||
|
|
||||||
" remove every other character from the mps option set
|
|
||||||
let mps = substitute(&mps,'\(.\).','\1','g')
|
|
||||||
|
|
||||||
" grab a copy of the character under the cursor into @0
|
|
||||||
silent! norm! yl
|
|
||||||
|
|
||||||
" if the character grabbed in @0 is in the mps option set, then highlight
|
|
||||||
" the matching character
|
|
||||||
if stridx(mps,@0) != -1
|
|
||||||
"------------------------------------------
|
|
||||||
" We are at a bracket character
|
|
||||||
"------------------------------------------
|
|
||||||
let curchr = @0
|
|
||||||
" determine match line, column.
|
|
||||||
" Restrict search to currently visible portion of window.
|
|
||||||
if &mps =~ curchr.':'
|
|
||||||
let stopline = line("w$")
|
|
||||||
let chrmatch = substitute(&mps,'^.*'.curchr.':\(.\).*$','\1','')
|
|
||||||
let [mtchline,mtchcol] = searchpairpos(escape(curchr,'[]'),'',escape(chrmatch,'[]'),'n','synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"',stopline)
|
|
||||||
else
|
|
||||||
let stopline = line("w0")
|
|
||||||
let chrmatch = substitute(&mps,'^.*\(.\):'.curchr.'.*$','\1','')
|
|
||||||
let [mtchline,mtchcol] = searchpairpos(escape(chrmatch,'[]'),'',escape(curchr,'[]'),'bn','synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"',stopline)
|
|
||||||
endif
|
|
||||||
|
|
||||||
if mtchline != 0 && mtchcol != 0
|
|
||||||
let mtchline2 = line('.')
|
|
||||||
let mtchcol2 = col('.')
|
|
||||||
let mtchline1 = mtchline
|
|
||||||
let mtchcol1 = mtchcol
|
|
||||||
|
|
||||||
call s:PerformMatch(mtchline1, mtchcol1, mtchline2, mtchcol2)
|
|
||||||
else
|
|
||||||
2match none
|
|
||||||
match none
|
|
||||||
endif
|
|
||||||
|
|
||||||
" if g:HiMtchBrkt_surround exists and is true, then highlight the surrounding brackets
|
|
||||||
"elseif exists("g:HiMtchBrkt_surround") && g:HiMtchBrkt_surround
|
|
||||||
else
|
|
||||||
"------------------------------------------
|
|
||||||
" We are inside brackets!
|
|
||||||
"------------------------------------------
|
|
||||||
let swp = Cursor_get()
|
|
||||||
let openers = '['.escape(substitute(&mps,':.,\=',"","g"),']').']'
|
|
||||||
let closers = '['.escape(substitute(&mps,',\=.:',"","g"),']').']'
|
|
||||||
call searchpair(openers,"",closers,'','synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"')
|
|
||||||
silent! norm! yl
|
|
||||||
if stridx(mps,@0) != -1
|
|
||||||
let mtchline1 = line('.')
|
|
||||||
let mtchcol1 = virtcol('.')
|
|
||||||
keepj norm! %
|
|
||||||
let mtchline2 = line('.')
|
|
||||||
let mtchcol2 = virtcol('.')
|
|
||||||
call Cursor_set(swp)
|
|
||||||
|
|
||||||
call s:PerformMatch(mtchline1, mtchcol1, mtchline2, mtchcol2)
|
|
||||||
else
|
|
||||||
match none
|
|
||||||
2match none
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" restore
|
|
||||||
let &magic = magickeep
|
|
||||||
let @" = regdq
|
|
||||||
let @@ = regunnamed
|
|
||||||
let &sol = solkeep
|
|
||||||
let &so = sokeep
|
|
||||||
let &siso = sisokeep
|
|
||||||
let &ss = sskeep
|
|
||||||
let &t_vb = t_vbkeep
|
|
||||||
let &vb = vbkeep
|
|
||||||
silent! let @* = regpaste
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! s:PerformMatch(line1, col1, line2, col2)
|
|
||||||
let line1 = a:line1
|
|
||||||
let col1 = a:col1
|
|
||||||
let line2 = a:line2
|
|
||||||
let col2 = a:col2
|
|
||||||
|
|
||||||
if line1 == line2
|
|
||||||
" at a single line => sort points on columns
|
|
||||||
if col1 > col2
|
|
||||||
let tmp = col2
|
|
||||||
let col2 = col1
|
|
||||||
let col1 = tmp
|
|
||||||
let tmp = line2
|
|
||||||
let line2 = line1
|
|
||||||
let line1 = tmp
|
|
||||||
endif
|
|
||||||
exe '2match BracketsBlock /\%'.line1.'l\%>'.col1.'v\%<'.col2.'v/'
|
|
||||||
else
|
|
||||||
" at a single line => sort points on lines
|
|
||||||
if line1 > line2
|
|
||||||
let tmp = line2
|
|
||||||
let line2 = line1
|
|
||||||
let line1 = tmp
|
|
||||||
let tmp = col2
|
|
||||||
let col2 = col1
|
|
||||||
let col1 = tmp
|
|
||||||
endif
|
|
||||||
exe '2match BracketsBlock /\%'.line1.'l\%>'.col1.'v\|\%>'.line1.'l\%<'.line2.'l\|\%'.line2.'l\%<'.col2.'v/'
|
|
||||||
endif
|
|
||||||
|
|
||||||
exe 'match Brackets /\%'.line1.'l\%'.col1.'v\|\%'.line2.'l\%'.col2.'v/'
|
|
||||||
endfun
|
|
||||||
|
|
||||||
let &cpo = s:keepcpo
|
|
||||||
unlet s:keepcpo
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
"
|
|
||||||
" limp/vim/keys.vim
|
|
||||||
"
|
|
||||||
" Description:
|
|
||||||
" Limp key bindings
|
|
||||||
"
|
|
||||||
" Authors:
|
|
||||||
" Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
"
|
|
||||||
|
|
||||||
nmap <buffer> <F12> <Plug>LimpBootConnectDisplay
|
|
||||||
nmap <buffer> <C-F12> <Plug>LimpDisconnect
|
|
||||||
nmap <buffer> <S-F12> <Plug>LimpShutdownLisp
|
|
||||||
|
|
||||||
" Eval Top: send top-level s-exp to Lisp
|
|
||||||
" Eval Current: send current s-exp to Lisp
|
|
||||||
" Eval Expression: send arbitrary code to Lisp
|
|
||||||
nmap <buffer> <LocalLeader>et <Plug>EvalTop
|
|
||||||
nmap <buffer> <LocalLeader>ec <Plug>EvalCurrent
|
|
||||||
nmap <buffer> <LocalLeader>ex <Plug>EvalExpression
|
|
||||||
|
|
||||||
" Eval Block: visual mode
|
|
||||||
vmap <buffer> <LocalLeader>et <Plug>EvalBlock
|
|
||||||
vmap <buffer> <LocalLeader>ec <Plug>EvalBlock
|
|
||||||
vmap <buffer> <LocalLeader>ex <Plug>EvalBlock
|
|
||||||
|
|
||||||
" SBCL Abort Reset: abort from the debugger
|
|
||||||
nmap <buffer> <LocalLeader>ar <Plug>AbortReset
|
|
||||||
|
|
||||||
" Abort Interrupt: send ^C to interpreter
|
|
||||||
nmap <buffer> <LocalLeader>ai <Plug>AbortInterrupt
|
|
||||||
|
|
||||||
" Test Current: copy current s-exp to test buffer
|
|
||||||
" Test Top: copy top s-exp to test buffer
|
|
||||||
nmap <buffer> <LocalLeader>tc <Plug>TestCurrent
|
|
||||||
nmap <buffer> <LocalLeader>tt <Plug>TestTop
|
|
||||||
|
|
||||||
" Load File: load /this/ file into Lisp
|
|
||||||
" Load Any File: load whichever version of this file (.lisp not given)
|
|
||||||
nmap <buffer> <LocalLeader>lf <Plug>LoadThisFile
|
|
||||||
nmap <buffer> <LocalLeader>la <Plug>LoadAnyFile
|
|
||||||
|
|
||||||
" Compile File: compile the current file
|
|
||||||
" Compile Load File: compile, then load the current file
|
|
||||||
nmap <buffer> <LocalLeader>cf <Plug>CompileFile
|
|
||||||
nmap <buffer> <LocalLeader>cl <Plug>CompileAndLoadFile
|
|
||||||
|
|
||||||
" Goto Test Buffer:
|
|
||||||
" Goto Split: split current buffer and goto test buffer
|
|
||||||
nmap <buffer> <LocalLeader>gt <Plug>GotoTestBuffer
|
|
||||||
nmap <buffer> <LocalLeader>gs <Plug>GotoTestBufferAndSplit
|
|
||||||
|
|
||||||
" Goto Last: return to last Lisp buffer
|
|
||||||
nmap <buffer> <LocalLeader>gl <Plug>GotoLastLispBuffer
|
|
||||||
|
|
||||||
" HyperSpec:
|
|
||||||
nmap <buffer> <LocalLeader>he <Plug>HyperspecExact
|
|
||||||
nmap <buffer> <LocalLeader>hp <Plug>HyperspecPrefix
|
|
||||||
nmap <buffer> <LocalLeader>hs <Plug>HyperspecSuffix
|
|
||||||
nmap <buffer> <LocalLeader>hg <Plug>HyperspecGrep
|
|
||||||
nmap <buffer> <LocalLeader>hi <Plug>HyperspecFirstLetterIndex
|
|
||||||
nmap <buffer> <LocalLeader>hI <Plug>HyperspecFullIndex
|
|
||||||
nmap <buffer> K <Plug>HyperspecExact
|
|
||||||
|
|
||||||
" Help Describe: ask Lisp about the current symbol
|
|
||||||
nmap <buffer> <LocalLeader>hd <Plug>HelpDescribe
|
|
||||||
|
|
||||||
" Mark Top: mark visual block
|
|
||||||
nmap <buffer> <LocalLeader>mt <Plug>MarkTop
|
|
||||||
|
|
||||||
" Format Current: reindent/format
|
|
||||||
" Format Top:
|
|
||||||
nmap <buffer> <LocalLeader>fc <Plug>FormatCurrent
|
|
||||||
nmap <buffer> <LocalLeader>ft <Plug>FormatTop
|
|
||||||
|
|
||||||
" Sexp Wrap: wrap the current form in a list
|
|
||||||
" Sexp Peel: peel a list off the current form
|
|
||||||
nmap <buffer> <LocalLeader>sw <Plug>SexpWrap
|
|
||||||
nmap <buffer> <LocalLeader>sp <Plug>SexpPeel
|
|
||||||
|
|
||||||
" Sexp Previous: navigate to previous s-exp
|
|
||||||
" Sexp Next: navigate to previous s-exp
|
|
||||||
nmap <buffer> ( <Plug>SexpPrevious
|
|
||||||
nmap <buffer> ) <Plug>SexpNext
|
|
||||||
|
|
||||||
" Sexp Move Back: swap this and previous s-exp
|
|
||||||
" Sexp Move Forward: swap this and next s-exp
|
|
||||||
nmap <buffer> { <Plug>SexpMoveBack
|
|
||||||
nmap <buffer> } <Plug>SexpMoveForward
|
|
||||||
|
|
||||||
" Sexp Comment: comment all the way from the top level
|
|
||||||
nmap <buffer> <LocalLeader>sc <Plug>SexpComment
|
|
||||||
|
|
||||||
" Sexp Comment Current: comment current form
|
|
||||||
nmap <buffer> <LocalLeader>sC <Plug>SexpCommentCurrent
|
|
||||||
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
"
|
|
||||||
" limp/vim/limp.vim
|
|
||||||
"
|
|
||||||
" URL:
|
|
||||||
" http://mikael.jansson.be/hacking
|
|
||||||
"
|
|
||||||
" Description:
|
|
||||||
" Setup the Limp environment
|
|
||||||
"
|
|
||||||
" Version:
|
|
||||||
" 0.2
|
|
||||||
"
|
|
||||||
" Date:
|
|
||||||
" 2008-04-28
|
|
||||||
"
|
|
||||||
" Authors:
|
|
||||||
" Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
"
|
|
||||||
" Changelog:
|
|
||||||
" * 2008-04-28 by Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" Only change colorscheme and nocompatible when not previously set.
|
|
||||||
"
|
|
||||||
" * 2008-04-25 by Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" Catch-all key <F12> for Lisp boot, connect & display
|
|
||||||
"
|
|
||||||
" * 2008-04-20 by Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
" Initial version.
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
|
|
||||||
if exists("b:did_ftplugin")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
let b:did_ftplugin = 1
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" external dependencies
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
silent! runtime plugin/matchit.vim
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" the Limp library
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
|
|
||||||
runtime ftplugin/lisp/limp/cursor.vim
|
|
||||||
runtime ftplugin/lisp/limp/highlight.vim
|
|
||||||
runtime ftplugin/lisp/limp/sexp.vim
|
|
||||||
runtime ftplugin/lisp/limp/bridge.vim
|
|
||||||
runtime ftplugin/lisp/limp/autoclose.vim
|
|
||||||
runtime ftplugin/lisp/limp/keys.vim
|
|
||||||
runtime ftplugin/lisp/limp/mode.vim
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
"
|
|
||||||
" limp/vim/mode.vim
|
|
||||||
"
|
|
||||||
" URL:
|
|
||||||
" http://mikael.jansson.be
|
|
||||||
"
|
|
||||||
" Description:
|
|
||||||
" Lisp-mode specific functions
|
|
||||||
"
|
|
||||||
" Authors:
|
|
||||||
" Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
"
|
|
||||||
"Eval (say-hello 'mikael)
|
|
||||||
command! -buffer -nargs=* Eval silent call LimpBridge_send_to_lisp(<q-args>)
|
|
||||||
|
|
||||||
let b:listener_always_open_window=0
|
|
||||||
let b:listener_keep_open=0
|
|
||||||
|
|
||||||
let g:lisp_mode_active = 0
|
|
||||||
fun! LimpMode_start()
|
|
||||||
if g:lisp_mode_active
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
let g:lisp_mode_active = 1
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" coloring
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
let g:lisp_rainbow=1
|
|
||||||
|
|
||||||
set t_Co=256
|
|
||||||
if !exists("g:colors_name")
|
|
||||||
colorscheme desert256
|
|
||||||
endif
|
|
||||||
|
|
||||||
hi Brackets ctermbg=53 ctermfg=white
|
|
||||||
hi BracketsBlock ctermbg=235 guibg=lightgray
|
|
||||||
hi StatusLine ctermbg=white ctermfg=160
|
|
||||||
hi StatusLineNC ctermbg=black ctermfg=gray
|
|
||||||
hi Pmenu ctermbg=53 ctermfg=255
|
|
||||||
hi PmenuSel ctermbg=255 ctermfg=53
|
|
||||||
|
|
||||||
"
|
|
||||||
" set all parens to gray
|
|
||||||
"
|
|
||||||
hi hlLevel0 ctermfg=238
|
|
||||||
hi hlLevel1 ctermfg=238
|
|
||||||
hi hlLevel2 ctermfg=238
|
|
||||||
hi hlLevel3 ctermfg=238
|
|
||||||
hi hlLevel4 ctermfg=238
|
|
||||||
hi hlLevel5 ctermfg=238
|
|
||||||
hi hlLevel6 ctermfg=238
|
|
||||||
hi hlLevel7 ctermfg=238
|
|
||||||
hi hlLevel8 ctermfg=238
|
|
||||||
hi hlLevel9 ctermfg=238
|
|
||||||
hi hlLevel10 ctermfg=238
|
|
||||||
hi hlLevel11 ctermfg=238
|
|
||||||
|
|
||||||
call LimpHighlight_start()
|
|
||||||
call AutoClose_start()
|
|
||||||
|
|
||||||
" for whatever reason, nocursorline isn't set after pressing F12... (i.e.,
|
|
||||||
" switching back to the buffer)
|
|
||||||
setlocal nocursorline
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! LimpMode_stop()
|
|
||||||
let g:lisp_mode_active = 0
|
|
||||||
call LimpHighlight_stop()
|
|
||||||
call AutoClose_stop()
|
|
||||||
endfun
|
|
||||||
|
|
||||||
augroup LimpMode
|
|
||||||
au!
|
|
||||||
au BufEnter * :if &filetype == "lisp" | call LimpMode_start() | endif
|
|
||||||
au BufLeave * :if &filetype == "lisp" | call LimpMode_stop() | endif
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" init filetype plugin
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
syntax on
|
|
||||||
setlocal nocompatible nocursorline
|
|
||||||
setlocal lisp syntax=lisp
|
|
||||||
setlocal ls=2 bs=2 si et sw=2 ts=2 tw=0
|
|
||||||
setlocal statusline=%<%f\ \(%{LimpBridge_connection_status()}\)\ %h%m%r%=%-14.(%l,%c%V%)\ %P\ of\ %L\ \(%.45{getcwd()}\)
|
|
||||||
setlocal iskeyword=&,*,+,45,/,48-57,:,<,=,>,@,A-Z,a-z,_
|
|
||||||
setlocal cpoptions=-mp
|
|
||||||
setlocal foldmethod=marker foldmarker=(,) foldminlines=1
|
|
||||||
|
|
||||||
|
|
||||||
" This allows gf and :find to work. Fix path to your needs
|
|
||||||
setlocal suffixesadd=.lisp,cl path=/home/mikael/hacking/lisp/**
|
|
||||||
|
|
||||||
" This allows [d [i [D [I work across files if an ASDF buffer is opened
|
|
||||||
" If I used load, it would be there too.
|
|
||||||
setlocal include=(:file\
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
" reset to previous values
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
|
|
||||||
let s:save_cpo = &cpo
|
|
||||||
set cpo&vim
|
|
||||||
|
|
||||||
let b:undo_ftplugin = "setlocal syntax< lisp< ls< bs< si< et< sw< "
|
|
||||||
\ . "ts< tw< complete< nocursorline< nocompatible< statusline< iskeyword< "
|
|
||||||
\ . "cpoptions< foldmethod< foldmarker< foldminlines< "
|
|
||||||
\ . "suffixesadd< path< include< "
|
|
||||||
|
|
||||||
let &cpo = s:save_cpo
|
|
||||||
unlet s:save_cpo
|
|
||||||
|
|
||||||
|
|
||||||
"------------- boot!
|
|
||||||
|
|
||||||
call LimpMode_start()
|
|
||||||
|
|
||||||
@@ -1,308 +0,0 @@
|
|||||||
"
|
|
||||||
" limp/vim/sexp.vim
|
|
||||||
"
|
|
||||||
" URL:
|
|
||||||
" http://mikael.jansson.be/hacking
|
|
||||||
"
|
|
||||||
" Description:
|
|
||||||
" Things to help you out with s-exps.
|
|
||||||
"
|
|
||||||
" Version:
|
|
||||||
" 0.2
|
|
||||||
"
|
|
||||||
" Date:
|
|
||||||
" 2008-04-20
|
|
||||||
"
|
|
||||||
" Authors:
|
|
||||||
" Mikael Jansson <mail@mikael.jansson.be>
|
|
||||||
"
|
|
||||||
" Changelog:
|
|
||||||
" 2008-04-20
|
|
||||||
" * Initial version.
|
|
||||||
" * Based on ViLisp.vim by Larry Clapp <vim@theclapp.org>
|
|
||||||
|
|
||||||
" Mark Top: mark visual block
|
|
||||||
nnoremap <buffer> <Plug>MarkTop 99[(V%
|
|
||||||
|
|
||||||
" Format Current: reindent/format
|
|
||||||
" Format Top:
|
|
||||||
nnoremap <buffer> <Plug>FormatCurrent [(=%`'
|
|
||||||
nnoremap <buffer> <Plug>FormatTop 99[(=%`'
|
|
||||||
|
|
||||||
" Sexp Wrap: wrap the current form in a list
|
|
||||||
" Sexp Peel: peel a list off the current form
|
|
||||||
nnoremap <silent> <buffer> <Plug>SexpWrap :call Cursor_push()<CR>[(%a)<ESC>h%i(<ESC>:call Cursor_pop()<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>SexpPeel :call Cursor_push()<CR>[(:call Cursor_push()<CR>%x:call Cursor_pop()<CR>x:call Cursor_pop()<CR>
|
|
||||||
|
|
||||||
" Sexp Previous: navigate to previous s-exp
|
|
||||||
" Sexp Next: navigate to previous s-exp
|
|
||||||
nnoremap <silent> <buffer> <Plug>SexpPrevious :call Sexp_Previous()<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>SexpNext :call Sexp_Next()<CR>
|
|
||||||
|
|
||||||
" Sexp Move Back: swap this and previous s-exp
|
|
||||||
" Sexp Move Forward: swap this and next s-exp
|
|
||||||
nnoremap <silent> <buffer> <Plug>SexpMoveBack :call Sexp_MoveBack()<CR>
|
|
||||||
nnoremap <silent> <buffer> <Plug>SexpMoveForward :call Sexp_MoveForward()<CR>
|
|
||||||
|
|
||||||
" Sexp Comment: comment all the way from the top level
|
|
||||||
nnoremap <silent> <buffer> <Plug>SexpComment :call Cursor_push()<CR>99[(%a\|#<ESC>hh%i#\|<ESC>:call Cursor_pop()<CR>
|
|
||||||
|
|
||||||
" Sexp Comment Current: comment current form
|
|
||||||
nnoremap <silent> <buffer> <Plug>SexpCommentCurrent :call Cursor_push()<CR>[(%a\|#<ESC>hh%i#\|<ESC>:call Cursor_pop()<CR>
|
|
||||||
|
|
||||||
|
|
||||||
"-------------------------------------------------------------------
|
|
||||||
|
|
||||||
fun! Sexp_Next()
|
|
||||||
let [l, c] = Sexp_get_Next()
|
|
||||||
call cursor(l, c)
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! Sexp_Previous()
|
|
||||||
let [l, c] = Sexp_get_Previous()
|
|
||||||
if l == 0 && c == 0
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
call cursor(l, c)
|
|
||||||
return
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" return the position of the next s-exp
|
|
||||||
fun! Sexp_get_Next()
|
|
||||||
return searchpos('(', 'nW')
|
|
||||||
endfun
|
|
||||||
|
|
||||||
" return the position of the previous s-exp
|
|
||||||
fun! Sexp_get_Previous()
|
|
||||||
let p = getpos(".")
|
|
||||||
|
|
||||||
" If outside of *any* s-exps, move to the previous s-exp first.
|
|
||||||
let [l, c] = searchpairpos('(', '', ')', 'bnW')
|
|
||||||
if l == 0 && c == 0
|
|
||||||
call searchpos(')', 'Wb')
|
|
||||||
endif
|
|
||||||
|
|
||||||
" now, move to the start of this s-exp, wherever it may be.
|
|
||||||
let [l, c] = searchpos('(', 'Wnb')
|
|
||||||
|
|
||||||
call setpos(".", p)
|
|
||||||
|
|
||||||
return [l, c]
|
|
||||||
endfun
|
|
||||||
|
|
||||||
"XXX: MoveBack/MoveForward share much code
|
|
||||||
|
|
||||||
fun! Sexp_MoveBack()
|
|
||||||
" Inside an s-exp?
|
|
||||||
let [l, c] = searchpairpos('(', '', ')', 'bcnW')
|
|
||||||
if l == 0 || c == 0
|
|
||||||
" Nope,
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
silent! let regs = @*
|
|
||||||
|
|
||||||
" mark the start of this s-exp
|
|
||||||
silent! norm! yl
|
|
||||||
if @0 != "("
|
|
||||||
call Sexp_Previous()
|
|
||||||
endif
|
|
||||||
|
|
||||||
"
|
|
||||||
" Find out if the previous s-exp is the parent of the current
|
|
||||||
"
|
|
||||||
" This by searching to the previous s-exp, doing a % and checking either
|
|
||||||
" of the following conditions:
|
|
||||||
"
|
|
||||||
" * prev_line2 == this_line2 && prev_col2 > this_col2
|
|
||||||
" * prev_line2 > this_line2
|
|
||||||
"
|
|
||||||
" where prev_line2/prev_col2 = the ) of the previous match, and
|
|
||||||
" this_line2/this_col2 = the ) of the current s-exp.
|
|
||||||
"
|
|
||||||
|
|
||||||
" so we can get back.
|
|
||||||
silent! norm! ma
|
|
||||||
let [b, this_line1, this_col1, o] = getpos('.')
|
|
||||||
|
|
||||||
" where does the *current* s-exp end?
|
|
||||||
silent! norm! %
|
|
||||||
let [b, this_line2, this_col2, o] = getpos('.')
|
|
||||||
silent! norm! %
|
|
||||||
|
|
||||||
" where does the previous s-exp end?
|
|
||||||
call Sexp_Previous()
|
|
||||||
silent! norm! mb
|
|
||||||
|
|
||||||
let [b, prev_line1, prev_col1, o] = getpos('.')
|
|
||||||
silent! norm! %
|
|
||||||
let [b, prev_line2, prev_col2, o] = getpos('.')
|
|
||||||
|
|
||||||
if (prev_line2 == this_line2 && prev_col2 > this_col2) || (prev_line2 > this_line2)
|
|
||||||
" For now, just do nothing
|
|
||||||
echom "Error: Trying to transpose s-exp backwards with parent."
|
|
||||||
silent! norm! `a
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
" --------------------------------------------------------
|
|
||||||
|
|
||||||
" get the s-exps
|
|
||||||
silent! norm! `a
|
|
||||||
silent! norm! "ayab
|
|
||||||
silent! norm! `b
|
|
||||||
silent! norm! "byab
|
|
||||||
|
|
||||||
" copy and replace current s-exp with whitespace
|
|
||||||
let @c = Fill(" ", len(@b))
|
|
||||||
let @d = Fill(" ", len(@a))
|
|
||||||
|
|
||||||
silent! norm! `a"_dab
|
|
||||||
silent! norm! `a"cP
|
|
||||||
|
|
||||||
silent! norm! `b"_dab
|
|
||||||
silent! norm! `b"dP
|
|
||||||
|
|
||||||
if this_line1 == prev_line1
|
|
||||||
|
|
||||||
let diff = len(@a) - len(@b)
|
|
||||||
if diff > 0
|
|
||||||
let movement = ''.diff.'l'
|
|
||||||
elseif diff < 0
|
|
||||||
let movement = ''.(-diff).'h'
|
|
||||||
else
|
|
||||||
let movement = ''
|
|
||||||
endif
|
|
||||||
|
|
||||||
silent! norm! `b"aPl
|
|
||||||
silent! exe 'norm! '.len(@a).'x'
|
|
||||||
|
|
||||||
silent! exe 'norm! `a'.movement.'"bPl'
|
|
||||||
silent! exe 'norm! '.len(@b).'x'
|
|
||||||
|
|
||||||
silent! norm! `b
|
|
||||||
else
|
|
||||||
" different lines, so a simple paste will do
|
|
||||||
|
|
||||||
silent! norm! `a"bP
|
|
||||||
silent! exe 'norm! l'.len(@a).'x'
|
|
||||||
silent! norm! `b"aP
|
|
||||||
silent! exe 'norm! l'.len(@b).'x'
|
|
||||||
silent! norm! `b
|
|
||||||
endif
|
|
||||||
|
|
||||||
silent! let @* = regs
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! Sexp_MoveForward()
|
|
||||||
" Inside an s-exp?
|
|
||||||
let [l, c] = searchpairpos('(', '', ')', 'bcnW')
|
|
||||||
if l == 0 || c == 0
|
|
||||||
" Nope,
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
silent! let regs = @*
|
|
||||||
|
|
||||||
" mark the start of this s-exp
|
|
||||||
silent! norm! yl
|
|
||||||
if @0 != "("
|
|
||||||
call Sexp_Previous()
|
|
||||||
endif
|
|
||||||
|
|
||||||
"
|
|
||||||
" Find out if the next s-exp is the parent of the current.
|
|
||||||
"
|
|
||||||
" Search for the next ')', then see where the matching '(' ends.
|
|
||||||
" Check for any of the following conditions.
|
|
||||||
"
|
|
||||||
" * prev_line1 == this_line1 && prev_col1 < this_col1
|
|
||||||
" * prev_line1 < this_line1
|
|
||||||
"
|
|
||||||
" where prev_line1/prev_col1 = the ( of the previous match, and
|
|
||||||
" this_line1/this_col1 = the ( of the current s-exp.
|
|
||||||
"
|
|
||||||
|
|
||||||
" so we can get back.
|
|
||||||
silent! norm! ma
|
|
||||||
let [b, this_line1, this_col1, o] = getpos('.')
|
|
||||||
|
|
||||||
" where does the *current* s-exp end?
|
|
||||||
silent! norm! %
|
|
||||||
let [b, this_line2, this_col2, o] = getpos('.')
|
|
||||||
|
|
||||||
" where does the next s-exp end?
|
|
||||||
call search(')', 'W')
|
|
||||||
|
|
||||||
let [b, prev_line2, prev_col2, o] = getpos('.')
|
|
||||||
silent! norm! %
|
|
||||||
|
|
||||||
silent! norm! mb
|
|
||||||
let [b, prev_line1, prev_col1, o] = getpos('.')
|
|
||||||
|
|
||||||
if (prev_line1 == this_line1 && prev_col1 < this_col1) || (prev_line1 < this_line1)
|
|
||||||
" For now, just do nothing
|
|
||||||
echom "Error: Trying to transpose s-exp forward with parent."
|
|
||||||
silent! norm! `a
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
" --------------------------------------------------------
|
|
||||||
|
|
||||||
" get the s-exps
|
|
||||||
silent! norm! `a
|
|
||||||
silent! norm! "ayab
|
|
||||||
silent! norm! `b
|
|
||||||
silent! norm! "byab
|
|
||||||
|
|
||||||
" copy and replace current s-exp with whitespace
|
|
||||||
let @c = Fill(" ", len(@b))
|
|
||||||
let @d = Fill(" ", len(@a))
|
|
||||||
|
|
||||||
silent! norm! `b"_dab
|
|
||||||
silent! norm! `b"dP
|
|
||||||
|
|
||||||
silent! norm! `a"_dab
|
|
||||||
silent! norm! `a"cP
|
|
||||||
|
|
||||||
if this_line1 == prev_line1
|
|
||||||
|
|
||||||
let diff = len(@a) - len(@b)
|
|
||||||
if diff > 0
|
|
||||||
let movement = ''.diff.'h'
|
|
||||||
elseif diff < 0
|
|
||||||
let movement = ''.(-diff).'l'
|
|
||||||
else
|
|
||||||
let movement = ''
|
|
||||||
endif
|
|
||||||
|
|
||||||
silent! norm! `a"bPl
|
|
||||||
silent! exe 'norm! '.len(@b).'x'
|
|
||||||
|
|
||||||
silent! exe 'norm! `b'.movement.'"aPl'
|
|
||||||
silent! exe 'norm! '.len(@a).'x'
|
|
||||||
|
|
||||||
silent! exe 'norm! `b'.movement
|
|
||||||
else
|
|
||||||
" different lines, so a simple paste will do
|
|
||||||
|
|
||||||
silent! norm! `a"bP
|
|
||||||
silent! exe 'norm! l'.len(@a).'x'
|
|
||||||
silent! norm! `b"aP
|
|
||||||
silent! exe 'norm! l'.len(@b).'x'
|
|
||||||
silent! norm! `b
|
|
||||||
endif
|
|
||||||
|
|
||||||
silent! let @* = regs
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! Fill(c, n)
|
|
||||||
let s = ""
|
|
||||||
let n = a:n
|
|
||||||
while n > 0
|
|
||||||
let s = s.a:c
|
|
||||||
let n = n-1
|
|
||||||
endwhile
|
|
||||||
return s
|
|
||||||
endfun
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user