First commit
This commit is contained in:
348
.vim/plugin/README.txt
Normal file
348
.vim/plugin/README.txt
Normal file
@@ -0,0 +1,348 @@
|
||||
Description
|
||||
===========
|
||||
Pydiction allows you to Tab-complete Python code in Vim, including keywords, the standard library, and third-party modules.
|
||||
|
||||
It consists of three main files:
|
||||
|
||||
python_pydiction.vim -- This is an ftplugin you put in your non-system ftplugin directory (i.e., ~/.vim/after/ftplugin/, on Unix or C:\vim\vimfiles\ftplugin\, on Windows)
|
||||
complete-dict -- This is a vim dictionary file that consists of Python keywords and modules. This is what python_pydiction.vim looks at to know which things are completable.
|
||||
pydiction.py -- (Not required) This is a Python script that was used to generate complete-dict. You can optionally run this script to add more modules to complete-dict.
|
||||
|
||||
|
||||
Install Details
|
||||
===============
|
||||
Unix/Linux: Put python_pydiction.vim in ~/.vim/after/ftplugin/ (If this directory doesn't already exist, create it. Vim will know to look there automatically.)
|
||||
Windows: Put python_pydiction.vim in C:\vim\vimfiles\ftplugin (Assuming you installed Vim to C:\vim\).
|
||||
|
||||
You may install the other files (complete-dict and pydiction.py) anywhere you want. For this example, we'll assume you put them in "C:\vim\vimfiles\ftplugin\pydiction\" (Do not put any file but python_pydiction.vim in the ftplugin\ directory, only .vim files should go there.)
|
||||
|
||||
In your vimrc file, first add the following line to enable filetype plugins:
|
||||
|
||||
filetype plugin on
|
||||
|
||||
then make sure you set "g:pydiction_location" to the full path of where you installed complete-dict, i.e.:
|
||||
|
||||
let g:pydiction_location = 'C:/vim/vimfiles/ftplugin/pydiction/complete-dict'
|
||||
|
||||
You can optionally set the height of the completion menu by setting "g:pydiction_menu_height" in your vimrc. For example:
|
||||
|
||||
let g:pydiction_menu_height = 20
|
||||
|
||||
The default menu height is 15.
|
||||
|
||||
Note: If you were using a version of Pydiction less than 1.0, make sure you delete the old pydiction way of doing things from your vimrc. You should ***NOT*** have this in your vimrc anymore:
|
||||
|
||||
if has("autocmd")
|
||||
autocmd FileType python set complete+=k/path/to/pydiction iskeyword+=.,(
|
||||
endif " has("autocmd")
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
Type part of a Python keyword, module name, attribute or method in "insert mode" in Vim, then hit the TAB key and it will auto-complete.
|
||||
|
||||
For example, typing:
|
||||
|
||||
raw<Tab>
|
||||
|
||||
will bring up a menu of possibilities, such as:
|
||||
|
||||
raw_input(
|
||||
raw_unicode_escape_decode(
|
||||
raw_unicode_escape_encode(
|
||||
|
||||
Typing:
|
||||
|
||||
os.p<Tab>
|
||||
|
||||
pops up:
|
||||
|
||||
os.pardir
|
||||
os.path
|
||||
os.pathconf(
|
||||
os.pathconf_names
|
||||
os.pathsep
|
||||
os.pipe(
|
||||
...
|
||||
|
||||
Typing:
|
||||
|
||||
co<Tab>
|
||||
|
||||
pops up:
|
||||
|
||||
continue
|
||||
coerce(
|
||||
compile(
|
||||
...
|
||||
|
||||
and so on.
|
||||
|
||||
As of Pydiction 1.2, there's support for completing modules that were imported via "from module import submodule". For example, you could do:
|
||||
|
||||
from xml.parsers import expat
|
||||
expat.P<Tab>
|
||||
|
||||
which expands to:
|
||||
|
||||
expat.ParserCreate(
|
||||
|
||||
You can also now use Shift-Tab to Tab backwards through the popup menu.
|
||||
|
||||
If you feel you're getting different results in your completion menu, it's probably because you don't have Vim set to ignore case. You can remedy this with ":set noic"
|
||||
|
||||
|
||||
Pydiction versus other forms of completion
|
||||
==========================================
|
||||
Pydiction can complete Python Keywords, as well as Python module names and their attributes and methods. It can also complete both the fully-qualified module names such as "module.method", as well as non-fully qualified names such as simply "method".
|
||||
|
||||
Pydiction only uses the "Tab" key to complete, uses a special dictionary file to complete from, and only attempts to complete while editing Python files. This has the advantages of only requiring one keystroke to do completion and of not polluting all of your completion menus that you may be using for other types of completion, such as Vim's regular omni-completion, or other completion scripts that you may be running.
|
||||
|
||||
Since pydiction uses a dictionary file of possible completion items, it can complete 3rd party modules much more accurately than other ways. You have full control over what it can and cannot complete. If it's unable to complete anything you can either use pydiction.py, to automatically add a new module's contents to the dictionary, or you can manually add them using a text editor. The dictionary is just a plain text file, which also makes it portable across all platforms. For example, if you're a PyQT user, you can add all the PyQT related modules to the dictionary file (complete-dict) by using pydiction.py. The latest default complete-dict already contains most of the standard library, all Python 2.x keywords, Pygame, OpenGL, wxPython, Twisted, PyQT4, ZSI, LDAP, numarray, PyGTK, MySQLdb, PyGreSQL, pyPgSQL, PythonCard, pyvorbis, bcrypt, openid, GnuPGInterface, OpenSSl, pygments and more.
|
||||
|
||||
Also, because pydiction uses a dictionary file, you don't have to import a module before you can complete it, nor do you even have to have the module installed on your machine. This makes completion very fast since it doesn't need to do any type deducing. It also frees you up to use pydiction as a way of looking up what a module or submodule without having to install it first.
|
||||
|
||||
If you want to, you can still use Vim 7's built-in omni-completion for Python (pythoncomplete.vim), and other forms of ins-completion, with Pydiction. In fact, they can all make a great team.
|
||||
|
||||
Pydiction knows when you're completing a callable method or not and, if you are, it will automatically insert an opening parentheses.
|
||||
|
||||
The Tab key will work as normal for everything else. Pydiction will only try to use the Tab key to complete Python code if you're editing a Python file and you first type part of some Python module or keyword.
|
||||
|
||||
Pydiction doesn't even require Python support to be compiled into your version of Vim.
|
||||
|
||||
|
||||
python_pydiction.vim (filetype plugin)
|
||||
======================================
|
||||
Pydiction will make it so the Tab key on your keyboard is able to complete python code.
|
||||
|
||||
Version 1.0 and greater of Pydiction uses a new file called python_pydiction.vim, which is an ftplugin that only activates when you're editing a python file (e.g., you're editing a file with a ".py" extension or you've manually typed ":set filetype=python"). Past versions of pydiction didn't use a plugin and instead just required you to change the value of "isk" in your vimrc, which was not desirable. Version 1.0 and greater do not require you to manually change the value of isk. It now safely changes isk for you temporarily by only setting it while you're doing Tab-completion of Python code, and it automatically changes it back to its original value whenever Tab-completion isn't being activated. Again, only Tab-completion causes pydiction to activate; not even other forms of ins-completion, such as <Ctrl-x> or <Ctrl-n> completion will activate pydiction, so you're still free to use those other types of completion whenever you want to.
|
||||
|
||||
Pydiction works by using Vim's ins-completion functionality by temporarily remapping the Tab key to do the same thing as I_CTRL-X_CTRL_K (dictionary only completion). This means that whenever you're editing a Python file, and you start typing the name of a python keyword or module, you can press the Tab key to complete it. For example, if you type "os.pa" and then press Tab, Pydiction will pop up a completion menu in Vim that will look something like:
|
||||
|
||||
os.pardir
|
||||
os.path
|
||||
os.pathconf(
|
||||
os.pathconf_names
|
||||
os.path.
|
||||
os.path.__all__
|
||||
os.path.__builtins__
|
||||
os.path.__doc__
|
||||
...
|
||||
|
||||
Pressing Tab again while the menu is open will scroll down the menu so you can choose whatever item you want to go with, using the popup-menu keys:
|
||||
|
||||
CTRL-Y Accept the currently selected match and stop completion.
|
||||
<Space> Accept the currently selected match and insert a space.
|
||||
CTRL-E Close the menu and not accept any match.
|
||||
....
|
||||
|
||||
hitting Enter will accept the currently selected match, stop completion, and insert a newline, which is usually not what you want. Use CTRL-Y or <Space>, instead. See ":help popupmenu-keys" for more options.
|
||||
|
||||
As of Pydiction 1.3, you can press Shift-Tab to Tab backwards as well.
|
||||
|
||||
Pydiction temporarily sets completeopt to "menu,menuone", so that you can complete items that have one or more matches. It will set it back to whatever the original value you have completeopt set to when Tab-completion isn't being activated.
|
||||
|
||||
By default, Pydiction ignores case while doing Tab-completion. If you want it to do case-sensitive searches, then set noignorecase (:set noic).
|
||||
|
||||
|
||||
pydiction.py
|
||||
============
|
||||
Note: You can skip this section if you don't plan to add more modules to complete-dict yourself. Check if complete-dict already has the modules you intend to use.
|
||||
|
||||
This is the Python script used to create the "complete-dict" Vim dictionary file. I have created and bundled a default complete-dict for your use. I created it using Ubuntu 9.04 Linux, so there won't be any real win32 specific support in it. You're free to run pydiction.py to add, or upgrade, as modules as you want. The dictionary file will still work if you're using windows, but it won't complete win32 related modules unless you tell it to.
|
||||
|
||||
Usage: In a command prompt, run:
|
||||
|
||||
$ python pydiction.py <module> ... [-v]
|
||||
|
||||
(You need to have python 2.x installed.)
|
||||
|
||||
Say you wanted to add a module called "mymodule" to complete-dict, do the following:
|
||||
|
||||
$ python pydiction.py mymodule
|
||||
|
||||
You can input more than one module name on the command-line, just separate them by spaces:
|
||||
|
||||
$ python pydiction.py mymodule1 mymodule2 mymodule3
|
||||
|
||||
The -v option will just write the results to stdout (standard output) instead of the complete-dict file.
|
||||
|
||||
If the backfup file "complete-dict.last" doesn't exist in the current directory, pydiction.py will create it for you. You should always keep a backup of your last working dictionary in case anything goes wrong, as it can get tedious having to recreate the file from scratch.
|
||||
|
||||
If complete-dict.last already exists, pydiction will ask you if you want to overwrite your old backup with the new backup.
|
||||
|
||||
If you try to add a module that already exists in complete-dict, pydiction will tell you it already exists, so don't worry about adding duplicates. In fact, you can't add duplicates, every time pydiction.py runs it looks for and removes any duplicates in the file.
|
||||
|
||||
When pydiction adds new modules to complete-dict, it does so in two phases. First, it adds the fully-qualified name of the module. For example:
|
||||
|
||||
module.attribute
|
||||
module.method(
|
||||
|
||||
then it adds the non-fully qualified name:
|
||||
|
||||
attribute
|
||||
method(
|
||||
|
||||
this allows you to complete your python code in the way that you imported it. E.g.:
|
||||
|
||||
import module
|
||||
|
||||
or:
|
||||
|
||||
from module import method
|
||||
|
||||
Say you want to complete "pygame.display.set_mode". If you imported Pygame using "import pygame", then you can Tab-complete using:
|
||||
|
||||
pygame.di<Tab>
|
||||
|
||||
to expand to "pygame.display.". Then type:
|
||||
|
||||
se<Tab>
|
||||
|
||||
to expand to "pygame.display.set_mode("
|
||||
|
||||
Now say you imported using "from pygame import display". To expand to "display.set_mode(" just type:
|
||||
|
||||
display.se<Tab>
|
||||
|
||||
And if you imported using "from pygame.display import set_mode" just type:
|
||||
|
||||
se<Tab>
|
||||
|
||||
Keep in mind that if you don't use fully-qualified module names then you might get a lot of possible menu options popping up, so you may want to use more than just two letters before you hit Tab, to try to narrow down the list.
|
||||
|
||||
As of Pydictoin 1.1, there is also limited support for string type method completion. For example:
|
||||
|
||||
"".jo<Tab>"
|
||||
|
||||
will expand to:
|
||||
|
||||
"".join(
|
||||
|
||||
make sure you type at least two letters of the method name if this doesn't seem to work.
|
||||
|
||||
This only works for quoted strings, ie:
|
||||
|
||||
'foo bar'.st<Tab>
|
||||
|
||||
to get
|
||||
|
||||
'foo bar'.startswith(
|
||||
|
||||
but you can't yet do:
|
||||
|
||||
s = 'foo bar'
|
||||
|
||||
s.st<Tab>
|
||||
|
||||
if you want that behavior you can still use Vim 7's omni-completion:
|
||||
|
||||
s.st<Ctrl-x><Ctrl-o>
|
||||
|
||||
which will also give you a preview window describing the methods as well as the argument list the methods take, e,g:
|
||||
|
||||
startswith(prefix[, start[, end]])
|
||||
strip([chars])
|
||||
|
||||
To Tab-complete your own personal modules, you put your functions in a separate file to be reused, as you normally would. For example, say you put the following function in a file called "myFoo.py":
|
||||
|
||||
def myBar():
|
||||
print "hi"
|
||||
|
||||
you would then need to add myFoo to complete-dict by doing:
|
||||
|
||||
./pydiction.py myFoo
|
||||
|
||||
now you can complete myFoo.myBar() by doing:
|
||||
|
||||
myFoo.my<Tab>
|
||||
|
||||
You don't have to restart Vim after you update complete-dict.
|
||||
|
||||
|
||||
complete-dict
|
||||
=============
|
||||
This is the Vim dictionary file that python_pydiction.vim reads from and pydiction.py writes to. Without this file, pydiction wouldn't know which Python keywords and modules it can Tab-complete.
|
||||
|
||||
complete-dict is only an optional file in the sense that you can create your own complete-dict if you don't want to use the default one that is bundled with Pydiction. The default complete-dict gives you a major head start, as far as what you can Tab-complete, because I did my best to put all of the Python keywords, standard library and even some popular third party modules in it for you.
|
||||
|
||||
The default complete-dict currently contains:
|
||||
|
||||
Python keywords:
|
||||
|
||||
and, del, for, is, raise, assert, elif, from, lambda, return, break, else, global, not, try, class, except, if, or, while, continue, exec, import, pass, yield, def, finally, in, print
|
||||
|
||||
Most of the standard library and built ins:
|
||||
|
||||
__builtin__, __future__, os, sys, time, re, sets, string, math, Tkinter, hashlib, urllib, pydoc, etc...
|
||||
|
||||
It also contains some popular third-party libraries:
|
||||
|
||||
Pygame, wxPython, Twisted, ZSI, LDAP, OpenGL, PyGTK, PyQT4, MySQLdb, PyGreSQL, pyPgSQL, SQLite, PythonCard, Numarray, pyvorbis, Bcrypt, OpenID, GnuPGInterface, OpenSSL and Pygments.
|
||||
|
||||
Make sure you download the latest version of Pydiction to get the most up-to-date version of complete-dict. New modules are usually added to it every release.
|
||||
|
||||
If you open complete-dict in your text editor you'll see sections in it for each module, such as:
|
||||
|
||||
--- import os ---
|
||||
os.EX_CANTCREAT
|
||||
os.EX_CONFIG
|
||||
os.EX_DATAERR
|
||||
...
|
||||
|
||||
--- from os import * ---
|
||||
EX_CANTCREAT
|
||||
EX_CONFIG
|
||||
EX_DATAERR
|
||||
...
|
||||
|
||||
If certain attributes seem to be missing, it's probably because pydiction removed them because they were duplicates. This mainly happens with the non-fully qualified module sections. So first try searching the entire file for whatever string you assume is missing before you try adding it. For example, if you don't see:
|
||||
|
||||
__doc__
|
||||
|
||||
under:
|
||||
|
||||
--- import sys ---
|
||||
|
||||
it's probably because a previous module, such as "os", already has it.
|
||||
|
||||
If you try to recreate complete-dict from scratch, you'll need to manually add the Python keywords back to it, as those aren't generated with pydiction.py.
|
||||
|
||||
If you don't want certain things to Tab-complete, such as Python keywords or certain modules, simply delete them by hand from complete-dict.
|
||||
|
||||
Pydiction doesn't ignore "private" attributes or methods. I.e., those starting (but not ending) with one or two underscores, e.g., "_foo" or "__foo". I have manually deleted things starting with a single underscore from the included complete-dict just to keep it a little more sane--since there were so many. In sticking with the Python tradition of not forcing things to be private, I have left it up to the user to decide how they want to treat their own things. If you want to delete them from your custom complete-dict's, you can use a regex to try to delete them, such as doing:
|
||||
|
||||
:g/\._[a-zA-Z]/d
|
||||
:g/^_[a-zA-Z]/d
|
||||
:g/^\%(_\=[^_]\)*\zs__\%(.\{-}__\)\@!/d
|
||||
etc...
|
||||
|
||||
|
||||
Tips
|
||||
====
|
||||
-Say you create a custom object, called "S" by doing something like:
|
||||
|
||||
S = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
you can complete dynamic object methods, such as "S.send()", by using Vim 7's omni-completion ftplugin (a.k.a "pythoncomplete.vim") by doing:
|
||||
|
||||
S.s<Ctrl-x><Ctrl-o>
|
||||
|
||||
-You may get unexpected results if you use autocomplpop.vim, supertab.vim or other completion or python plugins. Try disabling them individually to find out the culprit and please don't hesitate to e-mail me any workarounds or suggestions. Thanks.
|
||||
|
||||
|
||||
License
|
||||
=======
|
||||
As of version 1.0, Pydiction is now under a BSD license instead of GPL.
|
||||
|
||||
|
||||
Further reading
|
||||
===============
|
||||
:help ftplugin
|
||||
:help 'complete
|
||||
:help compl-dictionary
|
||||
:help popupmenu-completion
|
||||
:help popupmenu-keys
|
||||
:help iskeyword
|
||||
http://docs.python.org/modindex.html
|
||||
|
||||
100
.vim/plugin/SearchComplete.vim
Normal file
100
.vim/plugin/SearchComplete.vim
Normal file
@@ -0,0 +1,100 @@
|
||||
" SearchComplete.vim
|
||||
" Author: Chris Russell
|
||||
" Version: 1.1
|
||||
" License: GPL v2.0
|
||||
"
|
||||
" Description:
|
||||
" This script defineds functions and key mappings for Tab completion in
|
||||
" searches.
|
||||
"
|
||||
" Help:
|
||||
" This script catches the <Tab> character when using the '/' search
|
||||
" command. Pressing Tab will expand the current partial word to the
|
||||
" next matching word starting with the partial word.
|
||||
"
|
||||
" If you want to match a tab, use the '\t' pattern.
|
||||
"
|
||||
" Installation:
|
||||
" Simply drop this file into your $HOME/.vim/plugin directory.
|
||||
"
|
||||
" Changelog:
|
||||
" 2002-11-08 v1.1
|
||||
" Convert to unix eol
|
||||
" 2002-11-05 v1.0
|
||||
" Initial release
|
||||
"
|
||||
" TODO:
|
||||
"
|
||||
|
||||
|
||||
"--------------------------------------------------
|
||||
" Avoid multiple sourcing
|
||||
"--------------------------------------------------
|
||||
if exists( "loaded_search_complete" )
|
||||
finish
|
||||
endif
|
||||
let loaded_search_complete = 1
|
||||
|
||||
|
||||
"--------------------------------------------------
|
||||
" Key mappings
|
||||
"--------------------------------------------------
|
||||
noremap / :call SearchCompleteStart()<CR>/
|
||||
|
||||
|
||||
"--------------------------------------------------
|
||||
" Set mappings for search complete
|
||||
"--------------------------------------------------
|
||||
function! SearchCompleteStart()
|
||||
cnoremap <Tab> <C-C>:call SearchComplete()<CR>/<C-R>s
|
||||
cnoremap <silent> <CR> <CR>:call SearchCompleteStop()<CR>
|
||||
cnoremap <silent> <Esc> <C-C>:call SearchCompleteStop()<CR>
|
||||
endfunction
|
||||
|
||||
"--------------------------------------------------
|
||||
" Tab completion in / search
|
||||
"--------------------------------------------------
|
||||
function! SearchComplete()
|
||||
" get current cursor position
|
||||
let l:loc = col( "." ) - 1
|
||||
" get partial search and delete
|
||||
let l:search = histget( '/', -1 )
|
||||
call histdel( '/', -1 )
|
||||
" check if new search
|
||||
if l:search == @s
|
||||
" get root search string
|
||||
let l:search = b:searchcomplete
|
||||
" increase number of autocompletes
|
||||
let b:searchcompletedepth = b:searchcompletedepth . "\<C-N>"
|
||||
else
|
||||
" one autocomplete
|
||||
let b:searchcompletedepth = "\<C-N>"
|
||||
endif
|
||||
" store origional search parameter
|
||||
let b:searchcomplete = l:search
|
||||
" set paste option to disable indent options
|
||||
let l:paste = &paste
|
||||
setlocal paste
|
||||
" on a temporary line put search string and use autocomplete
|
||||
execute "normal! A\n" . l:search . b:searchcompletedepth
|
||||
" get autocomplete result
|
||||
let @s = getline( line( "." ) )
|
||||
" undo and return to first char
|
||||
execute "normal! u0"
|
||||
" return to cursor position
|
||||
if l:loc > 0
|
||||
execute "normal! ". l:loc . "l"
|
||||
endif
|
||||
" reset paste option
|
||||
let &paste = l:paste
|
||||
endfunction
|
||||
|
||||
"--------------------------------------------------
|
||||
" Remove search complete mappings
|
||||
"--------------------------------------------------
|
||||
function! SearchCompleteStop()
|
||||
cunmap <Tab>
|
||||
cunmap <CR>
|
||||
cunmap <Esc>
|
||||
endfunction
|
||||
|
||||
164
.vim/plugin/color_sample_pack.vim
Normal file
164
.vim/plugin/color_sample_pack.vim
Normal file
@@ -0,0 +1,164 @@
|
||||
" Maintainer: Robert Melton ( iam -at- robertmelton -dot- com)
|
||||
" Last Change: 2010 Jan 20th
|
||||
|
||||
" default schemes
|
||||
amenu T&hemes.D&efault.Blue :colo blue<CR>
|
||||
amenu T&hemes.D&efault.DarkBlue :colo darkblue<CR>
|
||||
amenu T&hemes.D&efault.Default :colo default<CR>
|
||||
amenu T&hemes.D&efault.Delek :colo delek<CR>
|
||||
amenu T&hemes.D&efault.Desert :colo desert<CR>
|
||||
amenu T&hemes.D&efault.ElfLord :colo elflord<CR>
|
||||
amenu T&hemes.D&efault.Evening :colo evening<CR>
|
||||
amenu T&hemes.D&efault.Koehler :colo koehler<CR>
|
||||
amenu T&hemes.D&efault.Morning :colo morning<CR>
|
||||
amenu T&hemes.D&efault.Murphy :colo murphy<CR>
|
||||
amenu T&hemes.D&efault.Pablo :colo pablo<CR>
|
||||
amenu T&hemes.D&efault.PeachPuff :colo peachpuff<CR>
|
||||
amenu T&hemes.D&efault.Ron :colo ron<CR>
|
||||
amenu T&hemes.D&efault.Shine :colo shine<CR>
|
||||
amenu T&hemes.D&efault.Torte :colo torte<CR>
|
||||
amenu T&hemes.-s1- :
|
||||
|
||||
" 37 new themes
|
||||
amenu T&hemes.&New.&Dark.Adaryn :colo adaryn<CR>
|
||||
amenu T&hemes.&New.&Dark.Adrian :colo adrian<CR>
|
||||
amenu T&hemes.&New.&Dark.Anotherdark :colo anotherdark<CR>
|
||||
amenu T&hemes.&New.&Dark.BlackSea :colo blacksea<CR>
|
||||
amenu T&hemes.&New.&Dark.Colorer :colo colorer<CR>
|
||||
amenu T&hemes.&New.&Dark.Darkbone :colo darkbone<CR>
|
||||
amenu T&hemes.&New.&Dark.DarkZ :colo darkz<CR>
|
||||
amenu T&hemes.&New.&Dark.Herald :colo herald<CR>
|
||||
amenu T&hemes.&New.&Dark.Jammy :colo jammy<CR>
|
||||
amenu T&hemes.&New.&Dark.Kellys :colo kellys<CR>
|
||||
amenu T&hemes.&New.&Dark.Lettuce :colo lettuce<CR>
|
||||
amenu T&hemes.&New.&Dark.Maroloccio :colo maroloccio<CR>
|
||||
amenu T&hemes.&New.&Dark.Molokai :colo molokai<CR>
|
||||
amenu T&hemes.&New.&Dark.Mustang :colo mustang<CR>
|
||||
amenu T&hemes.&New.&Dark.TIRBlack :colo tir_black<CR>
|
||||
amenu T&hemes.&New.&Dark.Twilight :colo twilight<CR>
|
||||
amenu T&hemes.&New.&Dark.Two2Tango :colo two2tango<CR>
|
||||
amenu T&hemes.&New.&Dark.Wuye :colo wuye<CR>
|
||||
amenu T&hemes.&New.&Dark.Zmrok :colo zmrok<CR>
|
||||
amenu T&hemes.&New.&Light.BClear :colo bclear<CR>
|
||||
amenu T&hemes.&New.&Light.Satori :colo satori<CR>
|
||||
amenu T&hemes.&New.&Light.Silent :colo silent<CR>
|
||||
amenu T&hemes.&New.&Light.SoSo :colo soso<CR>
|
||||
amenu T&hemes.&New.&Light.SummerFruit256 :colo summerfruit256<CR>
|
||||
amenu T&hemes.&New.&Light.TAqua :colo taqua<CR>
|
||||
amenu T&hemes.&New.&Light.TCSoft :colo tcsoft<CR>
|
||||
amenu T&hemes.&New.&Light.VYLight :colo vylight<CR>
|
||||
amenu T&hemes.&New.&Other.Aqua :colo aqua<CR>
|
||||
amenu T&hemes.&New.&Other.Clarity :colo clarity<CR>
|
||||
amenu T&hemes.&New.&Other.CleanPHP :colo cleanphp<CR>
|
||||
amenu T&hemes.&New.&Other.Denim :colo denim<CR>
|
||||
amenu T&hemes.&New.&Other.Guardian :colo guardian<CR>
|
||||
amenu T&hemes.&New.&Other.Moss :colo moss<CR>
|
||||
amenu T&hemes.&New.&Other.Nightshimmer :colo nightshimmer<CR>
|
||||
amenu T&hemes.&New.&Other.NoQuarter :colo no_quarter<CR>
|
||||
amenu T&hemes.&New.&Other.RobinHood :colo robinhood<CR>
|
||||
amenu T&hemes.&New.&Other.SoftBlue :colo softblue<CR>
|
||||
amenu T&hemes.&New.&Other.Wood :colo wood<CR>
|
||||
|
||||
" 30 removed themes
|
||||
amenu T&hemes.De&precated.&Dark.DwBlue :colo dw_blue<CR>
|
||||
amenu T&hemes.De&precated.&Dark.DwCyan :colo dw_cyan<CR>
|
||||
amenu T&hemes.De&precated.&Dark.DwGreen :colo dw_green<CR>
|
||||
amenu T&hemes.De&precated.&Dark.DwOrange :colo dw_orange<CR>
|
||||
amenu T&hemes.De&precated.&Dark.DwPurple :colo dw_purple<CR>
|
||||
amenu T&hemes.De&precated.&Dark.DwRed :colo dw_red<CR>
|
||||
amenu T&hemes.De&precated.&Dark.DwYellow :colo dw_yellow<CR>
|
||||
amenu T&hemes.De&precated.&Dark.Fruity :colo fruity<CR>
|
||||
amenu T&hemes.De&precated.&Dark.Leo :colo leo<CR>
|
||||
amenu T&hemes.De&precated.&Dark.Matrix :colo matrix<CR>
|
||||
amenu T&hemes.De&precated.&Dark.Metacosm :colo metacosm<CR>
|
||||
amenu T&hemes.De&precated.&Dark.Northland :colo northland<CR>
|
||||
amenu T&hemes.De&precated.&Dark.Railscasts2 :colo railscasts2<CR>
|
||||
amenu T&hemes.De&precated.&Dark.Synic :colo synic<CR>
|
||||
amenu T&hemes.De&precated.&Dark.Wombat256 :colo wombat256<CR>
|
||||
amenu T&hemes.De&precated.&Dark.Xoria256 :colo xoria256<CR>
|
||||
amenu T&hemes.De&precated.&Light.Autumn2 :colo autumn2<CR>
|
||||
amenu T&hemes.De&precated.&Light.Buttercream :colo buttercream<CR>
|
||||
amenu T&hemes.De&precated.&Light.Fine_blue :colo fine_blue<CR>
|
||||
amenu T&hemes.De&precated.&Light.Impact :colo impact<CR>
|
||||
amenu T&hemes.De&precated.&Light.Oceanlight :colo oceanlight<CR>
|
||||
amenu T&hemes.De&precated.&Light.Print_bw :colo print_bw<CR>
|
||||
amenu T&hemes.De&precated.&Light.Pyte :colo pyte<CR>
|
||||
amenu T&hemes.De&precated.&Light.Spring :colo spring<CR>
|
||||
amenu T&hemes.De&precated.&Light.Winter :colo winter<CR>
|
||||
amenu T&hemes.De&precated.&Other.Astronaut :colo astronaut<CR>
|
||||
amenu T&hemes.De&precated.&Other.Bluegreen :colo bluegreen<CR>
|
||||
amenu T&hemes.De&precated.&Other.Navajo :colo navajo<CR>
|
||||
amenu T&hemes.De&precated.&Other.Olive :colo olive<CR>
|
||||
amenu T&hemes.De&precated.&Other.Tabula :colo tabula<CR>
|
||||
amenu T&hemes.De&precated.&Other.Xemacs :colo xemacs<CR>
|
||||
|
||||
" Themepack Themes
|
||||
amenu T&hemes.&Dark.Asu1dark :colo asu1dark<CR>
|
||||
amenu T&hemes.&Dark.Brookstream :colo brookstream<CR>
|
||||
amenu T&hemes.&Dark.Calmar256-dark :colo calmar256-dark<CR>
|
||||
amenu T&hemes.&Dark.Camo :colo camo<CR>
|
||||
amenu T&hemes.&Dark.Candy :colo candy<CR>
|
||||
amenu T&hemes.&Dark.Candycode :colo candycode<CR>
|
||||
amenu T&hemes.&Dark.Dante :colo dante<CR>
|
||||
amenu T&hemes.&Dark.Darkspectrum :colo darkspectrum<CR>
|
||||
amenu T&hemes.&Dark.Desert256 :colo desert256<CR>
|
||||
amenu T&hemes.&Dark.DesertEx :colo desertEx<CR>
|
||||
amenu T&hemes.&Dark.Dusk :colo dusk<CR>
|
||||
amenu T&hemes.&Dark.Earendel :colo earendel<CR>
|
||||
amenu T&hemes.&Dark.Ekvoli :colo ekvoli<CR>
|
||||
amenu T&hemes.&Dark.Fnaqevan :colo fnaqevan<CR>
|
||||
amenu T&hemes.&Dark.Freya :colo freya<CR>
|
||||
amenu T&hemes.&Dark.Golden :colo golden<CR>
|
||||
amenu T&hemes.&Dark.Inkpot :colo inkpot<CR>
|
||||
amenu T&hemes.&Dark.Jellybeans :colo jellybeans<CR>
|
||||
amenu T&hemes.&Dark.Lucius :colo lucius<CR>
|
||||
amenu T&hemes.&Dark.Manxome :colo manxome<CR>
|
||||
amenu T&hemes.&Dark.Moria :colo moria<CR>
|
||||
amenu T&hemes.&Dark.Motus :colo motus<CR>
|
||||
amenu T&hemes.&Dark.Neon :colo neon<CR>
|
||||
amenu T&hemes.&Dark.Neverness :colo neverness<CR>
|
||||
amenu T&hemes.&Dark.Oceanblack :colo oceanblack<CR>
|
||||
amenu T&hemes.&Dark.Railscasts :colo railscasts<CR>
|
||||
amenu T&hemes.&Dark.Rdark :colo rdark<CR>
|
||||
amenu T&hemes.&Dark.Relaxedgreen :colo relaxedgreen<CR>
|
||||
amenu T&hemes.&Dark.Rootwater :colo rootwater<CR>
|
||||
amenu T&hemes.&Dark.Tango :colo tango<CR>
|
||||
amenu T&hemes.&Dark.Tango2 :colo tango2<CR>
|
||||
amenu T&hemes.&Dark.Vibrantink :colo vibrantink<CR>
|
||||
amenu T&hemes.&Dark.Vividchalk :colo vividchalk<CR>
|
||||
amenu T&hemes.&Dark.Wombat :colo wombat<CR>
|
||||
amenu T&hemes.&Dark.Zenburn :colo zenburn<CR>
|
||||
|
||||
amenu T&hemes.&Light.Autumn :colo autumn<CR>
|
||||
amenu T&hemes.&Light.Autumnleaf :colo autumnleaf<CR>
|
||||
amenu T&hemes.&Light.Baycomb :colo baycomb<CR>
|
||||
amenu T&hemes.&Light.Biogoo :colo biogoo<CR>
|
||||
amenu T&hemes.&Light.Calmar256-light :colo calmar256-light<CR>
|
||||
amenu T&hemes.&Light.Chela_light :colo chela_light<CR>
|
||||
amenu T&hemes.&Light.Dawn :colo dawn<CR>
|
||||
amenu T&hemes.&Light.Eclipse :colo eclipse<CR>
|
||||
amenu T&hemes.&Light.Fog :colo fog<CR>
|
||||
amenu T&hemes.&Light.Fruit :colo fruit<CR>
|
||||
amenu T&hemes.&Light.Habilight :colo habilight<CR>
|
||||
amenu T&hemes.&Light.Ironman :colo ironman<CR>
|
||||
amenu T&hemes.&Light.Martin_krischik :colo martin_krischik<CR>
|
||||
amenu T&hemes.&Light.Nuvola :colo nuvola<CR>
|
||||
amenu T&hemes.&Light.PapayaWhip :colo PapayaWhip<CR>
|
||||
amenu T&hemes.&Light.Sienna :colo sienna<CR>
|
||||
amenu T&hemes.&Light.Simpleandfriendly :colo simpleandfriendly<CR>
|
||||
amenu T&hemes.&Light.Tolerable :colo tolerable<CR>
|
||||
amenu T&hemes.&Light.Vc :colo vc<CR>
|
||||
|
||||
amenu T&hemes.&Other.Aiseered :colo aiseered<CR>
|
||||
amenu T&hemes.&Other.Borland :colo borland<CR>
|
||||
amenu T&hemes.&Other.Breeze :colo breeze<CR>
|
||||
amenu T&hemes.&Other.Chocolateliquor :colo chocolateliquor<CR>
|
||||
amenu T&hemes.&Other.Darkblue2 :colo darkblue2<CR>
|
||||
amenu T&hemes.&Other.Darkslategray :colo darkslategray<CR>
|
||||
amenu T&hemes.&Other.Marklar :colo marklar<CR>
|
||||
amenu T&hemes.&Other.Navajo-night :colo navajo-night<CR>
|
||||
amenu T&hemes.&Other.Night :colo night<CR>
|
||||
amenu T&hemes.&Other.Oceandeep :colo oceandeep<CR>
|
||||
amenu T&hemes.&Other.Peaksea :colo peaksea<CR>
|
||||
amenu T&hemes.&Other.Sea :colo sea<CR>
|
||||
amenu T&hemes.&Other.Settlemyer :colo settlemyer<CR>
|
||||
93721
.vim/plugin/complete-dict
Normal file
93721
.vim/plugin/complete-dict
Normal file
File diff suppressed because it is too large
Load Diff
284
.vim/plugin/pydiction.py
Normal file
284
.vim/plugin/pydiction.py
Normal file
@@ -0,0 +1,284 @@
|
||||
#!/usr/bin/env python
|
||||
# Last modified: July 23rd, 2009
|
||||
"""
|
||||
|
||||
pydiction.py 1.2 by Ryan Kulla (rkulla AT gmail DOT com).
|
||||
|
||||
Description: Creates a Vim dictionary of Python module attributes for Vim's
|
||||
completion feature. The created dictionary file is used by
|
||||
the Vim ftplugin "python_pydiction.vim".
|
||||
|
||||
Usage: pydiction.py <module> ... [-v]
|
||||
Example: The following will append all the "time" and "math" modules'
|
||||
attributes to a file, in the current directory, called "pydiction"
|
||||
with and without the "time." and "math." prefix:
|
||||
$ python pydiction.py time math
|
||||
To print the output just to stdout, instead of appending to the file,
|
||||
supply the -v option:
|
||||
$ python pydiction.py -v time math
|
||||
|
||||
License: BSD.
|
||||
"""
|
||||
|
||||
|
||||
__author__ = "Ryan Kulla (rkulla AT gmail DOT com)"
|
||||
__version__ = "1.2"
|
||||
__copyright__ = "Copyright (c) 2003-2009 Ryan Kulla"
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import types
|
||||
import shutil
|
||||
|
||||
|
||||
# Path/filename of the vim dictionary file to write to:
|
||||
PYDICTION_DICT = r'complete-dict'
|
||||
# Path/filename of the vim dictionary backup file:
|
||||
PYDICTION_DICT_BACKUP = r'complete-dict.last'
|
||||
|
||||
# Sentintal to test if we should only output to stdout:
|
||||
STDOUT_ONLY = False
|
||||
|
||||
|
||||
def get_submodules(module_name, submodules):
|
||||
"""Build a list of all the submodules of modules."""
|
||||
|
||||
# Try to import a given module, so we can dir() it:
|
||||
try:
|
||||
imported_module = my_import(module_name)
|
||||
except ImportError, err:
|
||||
return submodules
|
||||
|
||||
mod_attrs = dir(imported_module)
|
||||
|
||||
for mod_attr in mod_attrs:
|
||||
if type(getattr(imported_module, mod_attr)) is types.ModuleType:
|
||||
submodules.append(module_name + '.' + mod_attr)
|
||||
|
||||
return submodules
|
||||
|
||||
|
||||
def write_dictionary(module_name):
|
||||
"""Write to module attributes to the vim dictionary file."""
|
||||
prefix_on = '%s.%s'
|
||||
prefix_on_callable = '%s.%s('
|
||||
prefix_off = '%s'
|
||||
prefix_off_callable = '%s('
|
||||
|
||||
try:
|
||||
imported_module = my_import(module_name)
|
||||
except ImportError, err:
|
||||
return
|
||||
|
||||
mod_attrs = dir(imported_module)
|
||||
|
||||
# Generate fully-qualified module names:
|
||||
write_to.write('\n--- import %s ---\n' % module_name)
|
||||
for mod_attr in mod_attrs:
|
||||
if callable(getattr(imported_module, mod_attr)):
|
||||
# If an attribute is callable, show an opening parentheses:
|
||||
format = prefix_on_callable
|
||||
else:
|
||||
format = prefix_on
|
||||
write_to.write(format % (module_name, mod_attr) + '\n')
|
||||
|
||||
# Generate submodule names by themselves, for when someone does
|
||||
# "from foo import bar" and wants to complete bar.baz.
|
||||
# This works the same no matter how many .'s are in the module.
|
||||
if module_name.count('.'):
|
||||
# Get the "from" part of the module. E.g., 'xml.parsers'
|
||||
# if the module name was 'xml.parsers.expat':
|
||||
first_part = module_name[:module_name.rfind('.')]
|
||||
# Get the "import" part of the module. E.g., 'expat'
|
||||
# if the module name was 'xml.parsers.expat'
|
||||
second_part = module_name[module_name.rfind('.') + 1:]
|
||||
write_to.write('\n--- from %s import %s ---\n' %
|
||||
(first_part, second_part))
|
||||
for mod_attr in mod_attrs:
|
||||
if callable(getattr(imported_module, mod_attr)):
|
||||
format = prefix_on_callable
|
||||
else:
|
||||
format = prefix_on
|
||||
write_to.write(format % (second_part, mod_attr) + '\n')
|
||||
|
||||
# Generate non-fully-qualified module names:
|
||||
write_to.write('\n--- from %s import * ---\n' % module_name)
|
||||
for mod_attr in mod_attrs:
|
||||
if callable(getattr(imported_module, mod_attr)):
|
||||
format = prefix_off_callable
|
||||
else:
|
||||
format = prefix_off
|
||||
write_to.write(format % mod_attr + '\n')
|
||||
|
||||
|
||||
def my_import(name):
|
||||
"""Make __import__ import "package.module" formatted names."""
|
||||
mod = __import__(name)
|
||||
components = name.split('.')
|
||||
for comp in components[1:]:
|
||||
mod = getattr(mod, comp)
|
||||
return mod
|
||||
|
||||
|
||||
def remove_duplicates(seq, keep=()):
|
||||
"""
|
||||
|
||||
Remove duplicates from a sequence while perserving order.
|
||||
|
||||
The optional tuple argument "keep" can be given to specificy
|
||||
each string you don't want to be removed as a duplicate.
|
||||
"""
|
||||
seq2 = []
|
||||
seen = set();
|
||||
for i in seq:
|
||||
if i in (keep):
|
||||
seq2.append(i)
|
||||
continue
|
||||
elif i not in seen:
|
||||
seq2.append(i)
|
||||
seen.add(i)
|
||||
return seq2
|
||||
|
||||
|
||||
def get_yesno(msg="[Y/n]?"):
|
||||
"""
|
||||
|
||||
Returns True if user inputs 'n', 'Y', "yes", "Yes"...
|
||||
Returns False if user inputs 'n', 'N', "no", "No"...
|
||||
If they enter an invalid option it tells them so and asks again.
|
||||
Hitting Enter is equivalent to answering Yes.
|
||||
Takes an optional message to display, defaults to "[Y/n]?".
|
||||
|
||||
"""
|
||||
while True:
|
||||
answer = raw_input(msg)
|
||||
if answer == '':
|
||||
return True
|
||||
elif len(answer):
|
||||
answer = answer.lower()[0]
|
||||
if answer == 'y':
|
||||
return True
|
||||
break
|
||||
elif answer == 'n':
|
||||
return False
|
||||
break
|
||||
else:
|
||||
print "Invalid option. Please try again."
|
||||
continue
|
||||
|
||||
|
||||
def main(write_to):
|
||||
"""Generate a dictionary for Vim of python module attributes."""
|
||||
submodules = []
|
||||
|
||||
for module_name in sys.argv[1:]:
|
||||
try:
|
||||
imported_module = my_import(module_name)
|
||||
except ImportError, err:
|
||||
print "Couldn't import: %s. %s" % (module_name, err)
|
||||
sys.argv.remove(module_name)
|
||||
|
||||
cli_modules = sys.argv[1:]
|
||||
|
||||
# Step through each command line argument:
|
||||
for module_name in cli_modules:
|
||||
print "Trying module: %s" % module_name
|
||||
submodules = get_submodules(module_name, submodules)
|
||||
|
||||
# Step through the current module's submodules:
|
||||
for submodule_name in submodules:
|
||||
submodules = get_submodules(submodule_name, submodules)
|
||||
|
||||
# Add the top-level modules to the list too:
|
||||
for module_name in cli_modules:
|
||||
submodules.append(module_name)
|
||||
|
||||
submodules.sort()
|
||||
|
||||
# Step through all of the modules and submodules to create the dict file:
|
||||
for submodule_name in submodules:
|
||||
write_dictionary(submodule_name)
|
||||
|
||||
if STDOUT_ONLY:
|
||||
return
|
||||
|
||||
# Close and Reopen the file for reading and remove all duplicate lines:
|
||||
write_to.close()
|
||||
print "Removing duplicates..."
|
||||
f = open(PYDICTION_DICT, 'r')
|
||||
file_lines = f.readlines()
|
||||
file_lines = remove_duplicates(file_lines, ('\n'))
|
||||
f.close()
|
||||
|
||||
# Delete the original file:
|
||||
os.unlink(PYDICTION_DICT)
|
||||
|
||||
# Recreate the file, this time it won't have any duplicates lines:
|
||||
f = open(PYDICTION_DICT, 'w')
|
||||
for attr in file_lines:
|
||||
f.write(attr)
|
||||
f.close()
|
||||
print "Done."
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
"""Process the command line."""
|
||||
|
||||
if sys.version_info[0:2] < (2, 3):
|
||||
sys.exit("You need a Python 2.x version of at least Python 2.3")
|
||||
|
||||
if len(sys.argv) <= 1:
|
||||
sys.exit("%s requires at least one argument. None given." %
|
||||
sys.argv[0])
|
||||
|
||||
if '-v' in sys.argv:
|
||||
write_to = sys.stdout
|
||||
sys.argv.remove('-v')
|
||||
STDOUT_ONLY = True
|
||||
elif os.path.exists(PYDICTION_DICT):
|
||||
# See if any of the given modules have already been pydiction'd:
|
||||
f = open(PYDICTION_DICT, 'r')
|
||||
file_lines = f.readlines()
|
||||
for module_name in sys.argv[1:]:
|
||||
for line in file_lines:
|
||||
if line.find('--- import %s ' % module_name) != -1:
|
||||
print '"%s" already exists in %s. Skipping...' % \
|
||||
(module_name, PYDICTION_DICT)
|
||||
sys.argv.remove(module_name)
|
||||
break
|
||||
f.close()
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
# Check if there's still enough command-line arguments:
|
||||
sys.exit("Nothing new to do. Aborting.")
|
||||
|
||||
if os.path.exists(PYDICTION_DICT_BACKUP):
|
||||
answer = get_yesno('Overwrite existing backup "%s" [Y/n]? ' % \
|
||||
PYDICTION_DICT_BACKUP)
|
||||
if (answer):
|
||||
print "Backing up old dictionary to: %s" % \
|
||||
PYDICTION_DICT_BACKUP
|
||||
try:
|
||||
shutil.copyfile(PYDICTION_DICT, PYDICTION_DICT_BACKUP)
|
||||
except IOError, err:
|
||||
print "Couldn't back up %s. %s" % (PYDICTION_DICT, err)
|
||||
else:
|
||||
print "Skipping backup..."
|
||||
|
||||
print 'Appending to: "%s"' % PYDICTION_DICT
|
||||
else:
|
||||
print "Backing up current %s to %s" % \
|
||||
(PYDICTION_DICT, PYDICTION_DICT_BACKUP)
|
||||
try:
|
||||
shutil.copyfile(PYDICTION_DICT, PYDICTION_DICT_BACKUP)
|
||||
except IOError, err:
|
||||
print "Couldn't back up %s. %s" % (PYDICTION_DICT, err)
|
||||
else:
|
||||
print 'Creating file: "%s"' % PYDICTION_DICT
|
||||
|
||||
|
||||
if not STDOUT_ONLY:
|
||||
write_to = open(PYDICTION_DICT, 'a')
|
||||
|
||||
main(write_to)
|
||||
339
.vim/plugin/rails.vim
Normal file
339
.vim/plugin/rails.vim
Normal file
@@ -0,0 +1,339 @@
|
||||
" rails.vim - Detect a rails application
|
||||
" Author: Tim Pope <http://tpo.pe/>
|
||||
" GetLatestVimScripts: 1567 1 :AutoInstall: rails.vim
|
||||
|
||||
" Install this file as plugin/rails.vim. See doc/rails.txt for details. (Grab
|
||||
" it from the URL above if you don't have it.) To access it from Vim, see
|
||||
" :help add-local-help (hint: :helptags ~/.vim/doc) Afterwards, you should be
|
||||
" able to do :help rails
|
||||
|
||||
if exists('g:loaded_rails') || &cp || v:version < 700
|
||||
finish
|
||||
endif
|
||||
let g:loaded_rails = 1
|
||||
|
||||
" Utility Functions {{{1
|
||||
|
||||
function! s:error(str)
|
||||
echohl ErrorMsg
|
||||
echomsg a:str
|
||||
echohl None
|
||||
let v:errmsg = a:str
|
||||
endfunction
|
||||
|
||||
function! s:autoload(...)
|
||||
if !exists("g:autoloaded_rails") && v:version >= 700
|
||||
runtime! autoload/rails.vim
|
||||
endif
|
||||
if exists("g:autoloaded_rails")
|
||||
if a:0
|
||||
exe a:1
|
||||
endif
|
||||
return 1
|
||||
endif
|
||||
if !exists("g:rails_no_autoload_warning")
|
||||
let g:rails_no_autoload_warning = 1
|
||||
if v:version >= 700
|
||||
call s:error("Disabling rails.vim: autoload/rails.vim is missing")
|
||||
else
|
||||
call s:error("Disabling rails.vim: Vim version 7 or higher required")
|
||||
endif
|
||||
endif
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
" Configuration {{{
|
||||
|
||||
function! s:SetOptDefault(opt,val)
|
||||
if !exists("g:".a:opt)
|
||||
let g:{a:opt} = a:val
|
||||
endif
|
||||
endfunction
|
||||
|
||||
call s:SetOptDefault("rails_statusline",1)
|
||||
call s:SetOptDefault("rails_syntax",1)
|
||||
call s:SetOptDefault("rails_mappings",1)
|
||||
call s:SetOptDefault("rails_abbreviations",1)
|
||||
call s:SetOptDefault("rails_ctags_arguments","--languages=-javascript")
|
||||
call s:SetOptDefault("rails_default_file","README")
|
||||
call s:SetOptDefault("rails_root_url",'http://localhost:3000/')
|
||||
call s:SetOptDefault("rails_modelines",0)
|
||||
call s:SetOptDefault("rails_menu",!has('mac'))
|
||||
call s:SetOptDefault("rails_gnu_screen",1)
|
||||
call s:SetOptDefault("rails_history_size",5)
|
||||
call s:SetOptDefault("rails_generators","controller\ngenerator\nhelper\nintegration_test\nmailer\nmetal\nmigration\nmodel\nobserver\nperformance_test\nplugin\nresource\nscaffold\nscaffold_controller\nsession_migration\nstylesheets")
|
||||
if exists("g:loaded_dbext") && executable("sqlite3") && ! executable("sqlite")
|
||||
" Since dbext can't find it by itself
|
||||
call s:SetOptDefault("dbext_default_SQLITE_bin","sqlite3")
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
" Detection {{{1
|
||||
|
||||
function! s:escvar(r)
|
||||
let r = fnamemodify(a:r,':~')
|
||||
let r = substitute(r,'\W','\="_".char2nr(submatch(0))."_"','g')
|
||||
let r = substitute(r,'^\d','_&','')
|
||||
return r
|
||||
endfunction
|
||||
|
||||
function! s:Detect(filename)
|
||||
let fn = substitute(fnamemodify(a:filename,":p"),'\c^file://','','')
|
||||
let sep = matchstr(fn,'^[^\\/]\{3,\}\zs[\\/]')
|
||||
if sep != ""
|
||||
let fn = getcwd().sep.fn
|
||||
endif
|
||||
if fn =~ '[\/]config[\/]environment\.rb$'
|
||||
return s:BufInit(strpart(fn,0,strlen(fn)-22))
|
||||
endif
|
||||
if isdirectory(fn)
|
||||
let fn = fnamemodify(fn,':s?[\/]$??')
|
||||
else
|
||||
let fn = fnamemodify(fn,':s?\(.*\)[\/][^\/]*$?\1?')
|
||||
endif
|
||||
let ofn = ""
|
||||
let nfn = fn
|
||||
while nfn != ofn && nfn != ""
|
||||
if exists("s:_".s:escvar(nfn))
|
||||
return s:BufInit(nfn)
|
||||
endif
|
||||
let ofn = nfn
|
||||
let nfn = fnamemodify(nfn,':h')
|
||||
endwhile
|
||||
let ofn = ""
|
||||
while fn != ofn
|
||||
if filereadable(fn . "/config/environment.rb")
|
||||
return s:BufInit(fn)
|
||||
endif
|
||||
let ofn = fn
|
||||
let fn = fnamemodify(ofn,':s?\(.*\)[\/]\(app\|config\|db\|doc\|features\|lib\|log\|public\|script\|spec\|stories\|test\|tmp\|vendor\)\($\|[\/].*$\)?\1?')
|
||||
endwhile
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
function! s:BufInit(path)
|
||||
let s:_{s:escvar(a:path)} = 1
|
||||
if s:autoload()
|
||||
return RailsBufInit(a:path)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
" Initialization {{{1
|
||||
|
||||
augroup railsPluginDetect
|
||||
autocmd!
|
||||
autocmd BufNewFile,BufRead * call s:Detect(expand("<afile>:p"))
|
||||
autocmd VimEnter * if expand("<amatch>") == "" && !exists("b:rails_root") | call s:Detect(getcwd()) | endif | if exists("b:rails_root") | silent doau User BufEnterRails | endif
|
||||
autocmd FileType netrw if !exists("b:rails_root") | call s:Detect(expand("<afile>:p")) | endif | if exists("b:rails_root") | silent doau User BufEnterRails | endif
|
||||
autocmd BufEnter * if exists("b:rails_root")|silent doau User BufEnterRails|endif
|
||||
autocmd BufLeave * if exists("b:rails_root")|silent doau User BufLeaveRails|endif
|
||||
autocmd Syntax railslog if s:autoload()|call rails#log_syntax()|endif
|
||||
augroup END
|
||||
|
||||
command! -bar -bang -nargs=* -complete=dir Rails :if s:autoload()|call rails#new_app_command(<bang>0,<f-args>)|endif
|
||||
|
||||
" }}}1
|
||||
" abolish.vim support {{{1
|
||||
|
||||
function! s:function(name)
|
||||
return function(substitute(a:name,'^s:',matchstr(expand('<sfile>'), '<SNR>\d\+_'),''))
|
||||
endfunction
|
||||
|
||||
augroup railsPluginAbolish
|
||||
autocmd!
|
||||
autocmd VimEnter * call s:abolish_setup()
|
||||
augroup END
|
||||
|
||||
function! s:abolish_setup()
|
||||
if exists('g:Abolish') && has_key(g:Abolish,'Coercions')
|
||||
if !has_key(g:Abolish.Coercions,'l')
|
||||
let g:Abolish.Coercions.l = s:function('s:abolish_l')
|
||||
endif
|
||||
if !has_key(g:Abolish.Coercions,'t')
|
||||
let g:Abolish.Coercions.t = s:function('s:abolish_t')
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:abolish_l(word)
|
||||
let singular = rails#singularize(a:word)
|
||||
return a:word ==? singular ? rails#pluralize(a:word) : singular
|
||||
endfunction
|
||||
|
||||
function! s:abolish_t(word)
|
||||
if a:word =~# '\u'
|
||||
return rails#pluralize(rails#underscore(a:word))
|
||||
else
|
||||
return rails#singularize(rails#camelize(a:word))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
" Menus {{{1
|
||||
|
||||
if !(g:rails_menu && has("menu"))
|
||||
finish
|
||||
endif
|
||||
|
||||
function! s:sub(str,pat,rep)
|
||||
return substitute(a:str,'\v\C'.a:pat,a:rep,'')
|
||||
endfunction
|
||||
|
||||
function! s:gsub(str,pat,rep)
|
||||
return substitute(a:str,'\v\C'.a:pat,a:rep,'g')
|
||||
endfunction
|
||||
|
||||
function! s:menucmd(priority)
|
||||
return 'anoremenu <script> '.(exists("$CREAM") ? 87 : '').s:gsub(g:rails_installed_menu,'[^.]','').'.'.a:priority.' '
|
||||
endfunction
|
||||
|
||||
function! s:CreateMenus() abort
|
||||
if exists("g:rails_installed_menu") && g:rails_installed_menu != ""
|
||||
exe "aunmenu ".s:gsub(g:rails_installed_menu,'\&','')
|
||||
unlet g:rails_installed_menu
|
||||
endif
|
||||
if has("menu") && (exists("g:did_install_default_menus") || exists("$CREAM")) && g:rails_menu
|
||||
if g:rails_menu > 1
|
||||
let g:rails_installed_menu = '&Rails'
|
||||
else
|
||||
let g:rails_installed_menu = '&Plugin.&Rails'
|
||||
endif
|
||||
let dots = s:gsub(g:rails_installed_menu,'[^.]','')
|
||||
let menucmd = s:menucmd(200)
|
||||
if exists("$CREAM")
|
||||
exe menucmd.g:rails_installed_menu.'.-PSep- :'
|
||||
exe menucmd.g:rails_installed_menu.'.&Related\ file\ :R\ /\ Alt+] :R<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Alternate\ file\ :A\ /\ Alt+[ :A<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&File\ under\ cursor\ Ctrl+Enter :Rfind<CR>'
|
||||
else
|
||||
exe menucmd.g:rails_installed_menu.'.-PSep- :'
|
||||
exe menucmd.g:rails_installed_menu.'.&Related\ file\ :R\ /\ ]f :R<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Alternate\ file\ :A\ /\ [f :A<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&File\ under\ cursor\ gf :Rfind<CR>'
|
||||
endif
|
||||
exe menucmd.g:rails_installed_menu.'.&Other\ files.Application\ &Controller :Rcontroller application<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Other\ files.Application\ &Helper :Rhelper application<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Other\ files.Application\ &Javascript :Rjavascript application<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Other\ files.Application\ &Layout :Rlayout application<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Other\ files.Application\ &README :R doc/README_FOR_APP<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Other\ files.&Environment :Renvironment<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Other\ files.&Database\ Configuration :R config/database.yml<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Other\ files.Database\ &Schema :Rmigration 0<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Other\ files.R&outes :Rinitializer<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Other\ files.&Test\ Helper :Rintegrationtest<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.-FSep- :'
|
||||
exe menucmd.g:rails_installed_menu.'.Ra&ke\ :Rake :Rake<CR>'
|
||||
let menucmd = substitute(menucmd,'200 $','500 ','')
|
||||
exe menucmd.g:rails_installed_menu.'.&Server\ :Rserver.&Start\ :Rserver :Rserver<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Server\ :Rserver.&Force\ start\ :Rserver! :Rserver!<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Server\ :Rserver.&Kill\ :Rserver!\ - :Rserver! -<CR>'
|
||||
exe substitute(menucmd,'<script>','<script> <silent>','').g:rails_installed_menu.'.&Evaluate\ Ruby\.\.\.\ :Rp :call <SID>menuprompt("Rp","Code to execute and output: ")<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Console\ :Rscript :Rscript console<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Preview\ :Rpreview :Rpreview<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Log\ file\ :Rlog :Rlog<CR>'
|
||||
exe substitute(s:sub(menucmd,'anoremenu','vnoremenu'),'<script>','<script> <silent>','').g:rails_installed_menu.'.E&xtract\ as\ partial\ :Rextract :call <SID>menuprompt("'."'".'<,'."'".'>Rextract","Partial name (e.g., template or /controller/template): ")<CR>'
|
||||
exe menucmd.g:rails_installed_menu.'.&Migration\ writer\ :Rinvert :Rinvert<CR>'
|
||||
exe menucmd.' '.g:rails_installed_menu.'.-HSep- :'
|
||||
exe substitute(menucmd,'<script>','<script> <silent>','').g:rails_installed_menu.'.&Help\ :help\ rails :if <SID>autoload()<Bar>exe RailsHelpCommand("")<Bar>endif<CR>'
|
||||
exe substitute(menucmd,'<script>','<script> <silent>','').g:rails_installed_menu.'.Abo&ut\ :if <SID>autoload()<Bar>exe RailsHelpCommand("about")<Bar>endif<CR>'
|
||||
let g:rails_did_menus = 1
|
||||
call s:ProjectMenu()
|
||||
call s:menuBufLeave()
|
||||
if exists("b:rails_root")
|
||||
call s:menuBufEnter()
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:ProjectMenu()
|
||||
if exists("g:rails_did_menus") && g:rails_history_size > 0
|
||||
if !exists("g:RAILS_HISTORY")
|
||||
let g:RAILS_HISTORY = ""
|
||||
endif
|
||||
let history = g:RAILS_HISTORY
|
||||
let menu = s:gsub(g:rails_installed_menu,'\&','')
|
||||
silent! exe "aunmenu <script> ".menu.".Projects"
|
||||
let dots = s:gsub(menu,'[^.]','')
|
||||
exe 'anoremenu <script> <silent> '.(exists("$CREAM") ? '87' : '').dots.'.100 '.menu.'.Pro&jects.&New\.\.\.\ :Rails :call <SID>menuprompt("Rails","New application path and additional arguments: ")<CR>'
|
||||
exe 'anoremenu <script> '.menu.'.Pro&jects.-FSep- :'
|
||||
while history =~ '\n'
|
||||
let proj = matchstr(history,'^.\{-\}\ze\n')
|
||||
let history = s:sub(history,'^.{-}\n','')
|
||||
exe 'anoremenu <script> '.menu.'.Pro&jects.'.s:gsub(proj,'[.\\ ]','\\&').' :e '.s:gsub(proj."/".g:rails_default_file,'[ !%#]','\\&')."<CR>"
|
||||
endwhile
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:menuBufEnter()
|
||||
if exists("g:rails_installed_menu") && g:rails_installed_menu != ""
|
||||
let menu = s:gsub(g:rails_installed_menu,'\&','')
|
||||
exe 'amenu enable '.menu.'.*'
|
||||
if RailsFileType() !~ '^view\>'
|
||||
exe 'vmenu disable '.menu.'.Extract\ as\ partial'
|
||||
endif
|
||||
if RailsFileType() !~ '^\%(db-\)\=migration$' || RailsFilePath() =~ '\<db/schema\.rb$'
|
||||
exe 'amenu disable '.menu.'.Migration\ writer'
|
||||
endif
|
||||
call s:ProjectMenu()
|
||||
silent! exe 'aunmenu '.menu.'.Rake\ tasks'
|
||||
silent! exe 'aunmenu '.menu.'.Generate'
|
||||
silent! exe 'aunmenu '.menu.'.Destroy'
|
||||
if rails#app().cache.needs('rake_tasks') || empty(rails#app().rake_tasks())
|
||||
exe substitute(s:menucmd(300),'<script>','<script> <silent>','').g:rails_installed_menu.'.Rake\ &tasks\ :Rake.Fill\ this\ menu :call rails#app().rake_tasks()<Bar>call <SID>menuBufLeave()<Bar>call <SID>menuBufEnter()<CR>'
|
||||
else
|
||||
let i = 0
|
||||
while i < len(rails#app().rake_tasks())
|
||||
let task = rails#app().rake_tasks()[i]
|
||||
exe s:menucmd(300).g:rails_installed_menu.'.Rake\ &tasks\ :Rake.'.s:sub(task,':',':.').' :Rake '.task.'<CR>'
|
||||
let i += 1
|
||||
endwhile
|
||||
endif
|
||||
let i = 0
|
||||
let menucmd = substitute(s:menucmd(400),'<script>','<script> <silent>','').g:rails_installed_menu
|
||||
while i < len(rails#app().generators())
|
||||
let generator = rails#app().generators()[i]
|
||||
exe menucmd.'.&Generate\ :Rgen.'.s:gsub(generator,'_','\\ ').' :call <SID>menuprompt("Rgenerate '.generator.'","Arguments for script/generate '.generator.': ")<CR>'
|
||||
exe menucmd.'.&Destroy\ :Rdestroy.'.s:gsub(generator,'_','\\ ').' :call <SID>menuprompt("Rdestroy '.generator.'","Arguments for script/destroy '.generator.': ")<CR>'
|
||||
let i += 1
|
||||
endwhile
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:menuBufLeave()
|
||||
if exists("g:rails_installed_menu") && g:rails_installed_menu != ""
|
||||
let menu = s:gsub(g:rails_installed_menu,'\&','')
|
||||
exe 'amenu disable '.menu.'.*'
|
||||
exe 'amenu enable '.menu.'.Help\ '
|
||||
exe 'amenu enable '.menu.'.About\ '
|
||||
exe 'amenu enable '.menu.'.Projects'
|
||||
silent! exe 'aunmenu '.menu.'.Rake\ tasks'
|
||||
silent! exe 'aunmenu '.menu.'.Generate'
|
||||
silent! exe 'aunmenu '.menu.'.Destroy'
|
||||
exe s:menucmd(300).g:rails_installed_menu.'.Rake\ tasks\ :Rake.-TSep- :'
|
||||
exe s:menucmd(400).g:rails_installed_menu.'.&Generate\ :Rgen.-GSep- :'
|
||||
exe s:menucmd(400).g:rails_installed_menu.'.&Destroy\ :Rdestroy.-DSep- :'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:menuprompt(vimcmd,prompt)
|
||||
let res = inputdialog(a:prompt,'','!!!')
|
||||
if res == '!!!'
|
||||
return ""
|
||||
endif
|
||||
exe a:vimcmd." ".res
|
||||
endfunction
|
||||
|
||||
call s:CreateMenus()
|
||||
|
||||
augroup railsPluginMenu
|
||||
autocmd!
|
||||
autocmd User BufEnterRails call s:menuBufEnter()
|
||||
autocmd User BufLeaveRails call s:menuBufLeave()
|
||||
" g:RAILS_HISTORY hasn't been set when s:InitPlugin() is called.
|
||||
autocmd VimEnter * call s:ProjectMenu()
|
||||
augroup END
|
||||
|
||||
" }}}1
|
||||
" vim:set sw=2 sts=2:
|
||||
507
.vim/plugin/showmarks.vim
Normal file
507
.vim/plugin/showmarks.vim
Normal file
@@ -0,0 +1,507 @@
|
||||
" ==============================================================================
|
||||
" Name: ShowMarks
|
||||
" Description: Visually displays the location of marks.
|
||||
" Authors: Anthony Kruize <trandor@labyrinth.net.au>
|
||||
" Michael Geddes <michaelrgeddes@optushome.com.au>
|
||||
" Version: 2.2
|
||||
" Modified: 17 August 2004
|
||||
" License: Released into the public domain.
|
||||
" ChangeLog: See :help showmarks-changelog
|
||||
"
|
||||
" Usage: Copy this file into the plugins directory so it will be
|
||||
" automatically sourced.
|
||||
"
|
||||
" Default keymappings are:
|
||||
" <Leader>mt - Toggles ShowMarks on and off.
|
||||
" <Leader>mo - Turns ShowMarks on, and displays marks.
|
||||
" <Leader>mh - Clears a mark.
|
||||
" <Leader>ma - Clears all marks.
|
||||
" <Leader>mm - Places the next available mark.
|
||||
"
|
||||
" Hiding a mark doesn't actually remove it, it simply moves it
|
||||
" to line 1 and hides it visually.
|
||||
"
|
||||
" Configuration: ***********************************************************
|
||||
" * PLEASE read the included help file(showmarks.txt) for a *
|
||||
" * more thorough explanation of how to use ShowMarks. *
|
||||
" ***********************************************************
|
||||
" The following options can be used to customize the behavior
|
||||
" of ShowMarks. Simply include them in your vimrc file with
|
||||
" the desired settings.
|
||||
"
|
||||
" showmarks_enable (Default: 1)
|
||||
" Defines whether ShowMarks is enabled by default.
|
||||
" Example: let g:showmarks_enable=0
|
||||
" showmarks_include (Default: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.'`^<>[]{}()\"")
|
||||
" Defines all marks, in precedence order (only the highest
|
||||
" precence will show on lines having more than one mark).
|
||||
" Can be buffer-specific (set b:showmarks_include)
|
||||
" showmarks_ignore_type (Default: "hq")
|
||||
" Defines the buffer types to be ignored.
|
||||
" Valid types are:
|
||||
" h - Help p - preview
|
||||
" q - quickfix r - readonly
|
||||
" m - non-modifiable
|
||||
" showmarks_textlower (Default: ">")
|
||||
" Defines how the mark is to be displayed.
|
||||
" A maximum of two characters can be displayed. To include
|
||||
" the mark in the text use a tab(\t) character. A single
|
||||
" character will display as the mark with the character
|
||||
" suffixed (same as "\t<character>")
|
||||
" Examples:
|
||||
" To display the mark with a > suffixed:
|
||||
" let g:showmarks_textlower="\t>"
|
||||
" or
|
||||
" let g:showmarks_textlower=">"
|
||||
" To display the mark with a ( prefixed:
|
||||
" let g:showmarks_textlower="(\t"
|
||||
" To display two > characters:
|
||||
" let g:showmarks_textlower=">>"
|
||||
" showmarks_textupper (Default: ">")
|
||||
" Same as above but for the marks A-Z.
|
||||
" Example: let g:showmarks_textupper="**"
|
||||
" showmarks_textother (Default: ">")
|
||||
" Same as above but for all other marks.
|
||||
" Example: let g:showmarks_textother="--"
|
||||
" showmarks_hlline_lower (Default: 0)
|
||||
" showmarks_hlline_upper (Default: 0)
|
||||
" showmarks_hlline_other (Default: 0)
|
||||
" Defines whether the entire line for a particular mark
|
||||
" should be highlighted.
|
||||
" Example: let g:showmarks_hlline_lower=1
|
||||
"
|
||||
" Setting Highlighting Colours
|
||||
" ShowMarks uses the following highlighting groups:
|
||||
" ShowMarksHLl - For marks a-z
|
||||
" ShowMarksHLu - For marks A-Z
|
||||
" ShowMarksHLo - For all other marks
|
||||
" ShowMarksHLm - For multiple marks on the same line.
|
||||
" (Highest precendece mark is shown)
|
||||
"
|
||||
" By default they are set to a bold blue on light blue.
|
||||
" Defining a highlight for each of these groups will
|
||||
" override the default highlighting.
|
||||
" See the VIM help for more information about highlighting.
|
||||
" ==============================================================================
|
||||
|
||||
" Check if we should continue loading
|
||||
if exists( "loaded_showmarks" )
|
||||
finish
|
||||
endif
|
||||
let loaded_showmarks = 1
|
||||
|
||||
" Bail if Vim isn't compiled with signs support.
|
||||
if has( "signs" ) == 0
|
||||
echohl ErrorMsg
|
||||
echo "ShowMarks requires Vim to have +signs support."
|
||||
echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
" Options: Set up some nice defaults
|
||||
if !exists('g:showmarks_enable' ) | let g:showmarks_enable = 1 | endif
|
||||
if !exists('g:showmarks_textlower' ) | let g:showmarks_textlower = ">" | endif
|
||||
if !exists('g:showmarks_textupper' ) | let g:showmarks_textupper = ">" | endif
|
||||
if !exists('g:showmarks_textother' ) | let g:showmarks_textother = ">" | endif
|
||||
if !exists('g:showmarks_ignore_type' ) | let g:showmarks_ignore_type = "hq" | endif
|
||||
if !exists('g:showmarks_ignore_name' ) | let g:showmarks_ignore_name = "" | endif
|
||||
if !exists('g:showmarks_hlline_lower') | let g:showmarks_hlline_lower = "0" | endif
|
||||
if !exists('g:showmarks_hlline_upper') | let g:showmarks_hlline_upper = "0" | endif
|
||||
if !exists('g:showmarks_hlline_other') | let g:showmarks_hlline_other = "0" | endif
|
||||
|
||||
" This is the default, and used in ShowMarksSetup to set up info for any
|
||||
" possible mark (not just those specified in the possibly user-supplied list
|
||||
" of marks to show -- it can be changed on-the-fly).
|
||||
let s:all_marks = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.'`^<>[]{}()\""
|
||||
|
||||
" Commands
|
||||
com! -nargs=0 ShowMarksToggle :call <sid>ShowMarksToggle()
|
||||
com! -nargs=0 ShowMarksOn :call <sid>ShowMarksOn()
|
||||
com! -nargs=0 ShowMarksClearMark :call <sid>ShowMarksClearMark()
|
||||
com! -nargs=0 ShowMarksClearAll :call <sid>ShowMarksClearAll()
|
||||
com! -nargs=0 ShowMarksPlaceMark :call <sid>ShowMarksPlaceMark()
|
||||
|
||||
" Mappings (NOTE: Leave the '|'s immediately following the '<cr>' so the mapping does not contain any trailing spaces!)
|
||||
if !hasmapto( '<Plug>ShowmarksShowMarksToggle' ) | map <silent> <unique> <leader>mt :ShowMarksToggle<cr>| endif
|
||||
if !hasmapto( '<Plug>ShowmarksShowMarksOn' ) | map <silent> <unique> <leader>mo :ShowMarksOn<cr>| endif
|
||||
if !hasmapto( '<Plug>ShowmarksClearMark' ) | map <silent> <unique> <leader>mh :ShowMarksClearMark<cr>| endif
|
||||
if !hasmapto( '<Plug>ShowmarksClearAll' ) | map <silent> <unique> <leader>ma :ShowMarksClearAll<cr>| endif
|
||||
if !hasmapto( '<Plug>ShowmarksPlaceMark' ) | map <silent> <unique> <leader>mm :ShowMarksPlaceMark<cr>| endif
|
||||
noremap <unique> <script> \sm m
|
||||
noremap <silent> m :exe 'norm \sm'.nr2char(getchar())<bar>call <sid>ShowMarks()<CR>
|
||||
|
||||
" AutoCommands: Only if ShowMarks is enabled
|
||||
if g:showmarks_enable == 1
|
||||
aug ShowMarks
|
||||
au!
|
||||
autocmd CursorHold * call s:ShowMarks()
|
||||
aug END
|
||||
endif
|
||||
|
||||
" Highlighting: Setup some nice colours to show the mark positions.
|
||||
hi default ShowMarksHLl ctermfg=darkblue ctermbg=blue cterm=bold guifg=blue guibg=lightblue gui=bold
|
||||
hi default ShowMarksHLu ctermfg=darkblue ctermbg=blue cterm=bold guifg=blue guibg=lightblue gui=bold
|
||||
hi default ShowMarksHLo ctermfg=darkblue ctermbg=blue cterm=bold guifg=blue guibg=lightblue gui=bold
|
||||
hi default ShowMarksHLm ctermfg=darkblue ctermbg=blue cterm=bold guifg=blue guibg=lightblue gui=bold
|
||||
|
||||
" Function: IncludeMarks()
|
||||
" Description: This function returns the list of marks (in priority order) to
|
||||
" show in this buffer. Each buffer, if not already set, inherits the global
|
||||
" setting; if the global include marks have not been set; that is set to the
|
||||
" default value.
|
||||
fun! s:IncludeMarks()
|
||||
if exists('b:showmarks_include') && exists('b:showmarks_previous_include') && b:showmarks_include != b:showmarks_previous_include
|
||||
" The user changed the marks to include; hide all marks; change the
|
||||
" included mark list, then show all marks. Prevent infinite
|
||||
" recursion during this switch.
|
||||
if exists('s:use_previous_include')
|
||||
" Recursive call from ShowMarksHideAll()
|
||||
return b:showmarks_previous_include
|
||||
elseif exists('s:use_new_include')
|
||||
" Recursive call from ShowMarks()
|
||||
return b:showmarks_include
|
||||
else
|
||||
let s:use_previous_include = 1
|
||||
call <sid>ShowMarksHideAll()
|
||||
unlet s:use_previous_include
|
||||
let s:use_new_include = 1
|
||||
call <sid>ShowMarks()
|
||||
unlet s:use_new_include
|
||||
endif
|
||||
endif
|
||||
|
||||
if !exists('g:showmarks_include')
|
||||
let g:showmarks_include = s:all_marks
|
||||
endif
|
||||
if !exists('b:showmarks_include')
|
||||
let b:showmarks_include = g:showmarks_include
|
||||
endif
|
||||
|
||||
" Save this include setting so we can detect if it was changed.
|
||||
let b:showmarks_previous_include = b:showmarks_include
|
||||
|
||||
return b:showmarks_include
|
||||
endf
|
||||
|
||||
" Function: NameOfMark()
|
||||
" Paramaters: mark - Specifies the mark to find the name of.
|
||||
" Description: Convert marks that cannot be used as part of a variable name to
|
||||
" something that can be. i.e. We cannot use [ as a variable-name suffix (as
|
||||
" in 'placed_['; this function will return something like 63, so the variable
|
||||
" will be something like 'placed_63').
|
||||
" 10 is added to the mark's index to avoid colliding with the numeric marks
|
||||
" 0-9 (since a non-word mark could be listed in showmarks_include in the
|
||||
" first 10 characters if the user overrides the default).
|
||||
" Returns: The name of the requested mark.
|
||||
fun! s:NameOfMark(mark)
|
||||
let name = a:mark
|
||||
if a:mark =~# '\W'
|
||||
let name = stridx(s:all_marks, a:mark) + 10
|
||||
endif
|
||||
return name
|
||||
endf
|
||||
|
||||
" Function: VerifyText()
|
||||
" Paramaters: which - Specifies the variable to verify.
|
||||
" Description: Verify the validity of a showmarks_text{upper,lower,other} setup variable.
|
||||
" Default to ">" if it is found to be invalid.
|
||||
fun! s:VerifyText(which)
|
||||
if strlen(g:showmarks_text{a:which}) == 0 || strlen(g:showmarks_text{a:which}) > 2
|
||||
echohl ErrorMsg
|
||||
echo "ShowMarks: text".a:which." must contain only 1 or 2 characters."
|
||||
echohl None
|
||||
let g:showmarks_text{a:which}=">"
|
||||
endif
|
||||
endf
|
||||
|
||||
" Function: ShowMarksSetup()
|
||||
" Description: This function sets up the sign definitions for each mark.
|
||||
" It uses the showmarks_textlower, showmarks_textupper and showmarks_textother
|
||||
" variables to determine how to draw the mark.
|
||||
fun! s:ShowMarksSetup()
|
||||
" Make sure the textlower, textupper, and textother options are valid.
|
||||
call s:VerifyText('lower')
|
||||
call s:VerifyText('upper')
|
||||
call s:VerifyText('other')
|
||||
|
||||
let n = 0
|
||||
let s:maxmarks = strlen(s:all_marks)
|
||||
while n < s:maxmarks
|
||||
let c = strpart(s:all_marks, n, 1)
|
||||
let nm = s:NameOfMark(c)
|
||||
let text = '>'.c
|
||||
let lhltext = ''
|
||||
if c =~# '[a-z]'
|
||||
if strlen(g:showmarks_textlower) == 1
|
||||
let text=c.g:showmarks_textlower
|
||||
elseif strlen(g:showmarks_textlower) == 2
|
||||
let t1 = strpart(g:showmarks_textlower,0,1)
|
||||
let t2 = strpart(g:showmarks_textlower,1,1)
|
||||
if t1 == "\t"
|
||||
let text=c.t2
|
||||
elseif t2 == "\t"
|
||||
let text=t1.c
|
||||
else
|
||||
let text=g:showmarks_textlower
|
||||
endif
|
||||
endif
|
||||
let s:ShowMarksDLink{nm} = 'ShowMarksHLl'
|
||||
if g:showmarks_hlline_lower == 1
|
||||
let lhltext = 'linehl='.s:ShowMarksDLink{nm}.nm
|
||||
endif
|
||||
elseif c =~# '[A-Z]'
|
||||
if strlen(g:showmarks_textupper) == 1
|
||||
let text=c.g:showmarks_textupper
|
||||
elseif strlen(g:showmarks_textupper) == 2
|
||||
let t1 = strpart(g:showmarks_textupper,0,1)
|
||||
let t2 = strpart(g:showmarks_textupper,1,1)
|
||||
if t1 == "\t"
|
||||
let text=c.t2
|
||||
elseif t2 == "\t"
|
||||
let text=t1.c
|
||||
else
|
||||
let text=g:showmarks_textupper
|
||||
endif
|
||||
endif
|
||||
let s:ShowMarksDLink{nm} = 'ShowMarksHLu'
|
||||
if g:showmarks_hlline_upper == 1
|
||||
let lhltext = 'linehl='.s:ShowMarksDLink{nm}.nm
|
||||
endif
|
||||
else " Other signs, like ', ., etc.
|
||||
if strlen(g:showmarks_textother) == 1
|
||||
let text=c.g:showmarks_textother
|
||||
elseif strlen(g:showmarks_textother) == 2
|
||||
let t1 = strpart(g:showmarks_textother,0,1)
|
||||
let t2 = strpart(g:showmarks_textother,1,1)
|
||||
if t1 == "\t"
|
||||
let text=c.t2
|
||||
elseif t2 == "\t"
|
||||
let text=t1.c
|
||||
else
|
||||
let text=g:showmarks_textother
|
||||
endif
|
||||
endif
|
||||
let s:ShowMarksDLink{nm} = 'ShowMarksHLo'
|
||||
if g:showmarks_hlline_other == 1
|
||||
let lhltext = 'linehl='.s:ShowMarksDLink{nm}.nm
|
||||
endif
|
||||
endif
|
||||
|
||||
" Define the sign with a unique highlight which will be linked when placed.
|
||||
exe 'sign define ShowMark'.nm.' '.lhltext.' text='.text.' texthl='.s:ShowMarksDLink{nm}.nm
|
||||
let b:ShowMarksLink{nm} = ''
|
||||
let n = n + 1
|
||||
endw
|
||||
endf
|
||||
|
||||
" Set things up
|
||||
call s:ShowMarksSetup()
|
||||
|
||||
" Function: ShowMarksOn
|
||||
" Description: Enable showmarks, and show them now.
|
||||
fun! s:ShowMarksOn()
|
||||
if g:showmarks_enable == 0
|
||||
call <sid>ShowMarksToggle()
|
||||
else
|
||||
call <sid>ShowMarks()
|
||||
endif
|
||||
endf
|
||||
|
||||
" Function: ShowMarksToggle()
|
||||
" Description: This function toggles whether marks are displayed or not.
|
||||
fun! s:ShowMarksToggle()
|
||||
if g:showmarks_enable == 0
|
||||
let g:showmarks_enable = 1
|
||||
call <sid>ShowMarks()
|
||||
aug ShowMarks
|
||||
au!
|
||||
autocmd CursorHold * call s:ShowMarks()
|
||||
aug END
|
||||
else
|
||||
let g:showmarks_enable = 0
|
||||
call <sid>ShowMarksHideAll()
|
||||
aug ShowMarks
|
||||
au!
|
||||
autocmd BufEnter * call s:ShowMarksHideAll()
|
||||
aug END
|
||||
endif
|
||||
endf
|
||||
|
||||
" Function: ShowMarks()
|
||||
" Description: This function runs through all the marks and displays or
|
||||
" removes signs as appropriate. It is called on the CursorHold autocommand.
|
||||
" We use the marked_{ln} variables (containing a timestamp) to track what marks
|
||||
" we've shown (placed) in this call to ShowMarks; to only actually place the
|
||||
" first mark on any particular line -- this forces only the first mark
|
||||
" (according to the order of showmarks_include) to be shown (i.e., letters
|
||||
" take precedence over marks like paragraph and sentence.)
|
||||
fun! s:ShowMarks()
|
||||
if g:showmarks_enable == 0
|
||||
return
|
||||
endif
|
||||
|
||||
if ((match(g:showmarks_ignore_type, "[Hh]") > -1) && (&buftype == "help" ))
|
||||
\ || ((match(g:showmarks_ignore_type, "[Qq]") > -1) && (&buftype == "quickfix"))
|
||||
\ || ((match(g:showmarks_ignore_type, "[Pp]") > -1) && (&pvw == 1 ))
|
||||
\ || ((match(g:showmarks_ignore_type, "[Rr]") > -1) && (&readonly == 1 ))
|
||||
\ || ((match(g:showmarks_ignore_type, "[Mm]") > -1) && (&modifiable == 0 ))
|
||||
return
|
||||
endif
|
||||
|
||||
let n = 0
|
||||
let s:maxmarks = strlen(s:IncludeMarks())
|
||||
while n < s:maxmarks
|
||||
let c = strpart(s:IncludeMarks(), n, 1)
|
||||
let nm = s:NameOfMark(c)
|
||||
let id = n + (s:maxmarks * winbufnr(0))
|
||||
let ln = line("'".c)
|
||||
|
||||
if ln == 0 && (exists('b:placed_'.nm) && b:placed_{nm} != ln)
|
||||
exe 'sign unplace '.id.' buffer='.winbufnr(0)
|
||||
elseif ln > 1 || c !~ '[a-zA-Z]'
|
||||
" Have we already placed a mark here in this call to ShowMarks?
|
||||
if exists('mark_at'.ln)
|
||||
" Already placed a mark, set the highlight to multiple
|
||||
if c =~# '[a-zA-Z]' && b:ShowMarksLink{mark_at{ln}} != 'ShowMarksHLm'
|
||||
let b:ShowMarksLink{mark_at{ln}} = 'ShowMarksHLm'
|
||||
exe 'hi link '.s:ShowMarksDLink{mark_at{ln}}.mark_at{ln}.' '.b:ShowMarksLink{mark_at{ln}}
|
||||
endif
|
||||
else
|
||||
if !exists('b:ShowMarksLink'.nm) || b:ShowMarksLink{nm} != s:ShowMarksDLink{nm}
|
||||
let b:ShowMarksLink{nm} = s:ShowMarksDLink{nm}
|
||||
exe 'hi link '.s:ShowMarksDLink{nm}.nm.' '.b:ShowMarksLink{nm}
|
||||
endif
|
||||
let mark_at{ln} = nm
|
||||
if !exists('b:placed_'.nm) || b:placed_{nm} != ln
|
||||
exe 'sign unplace '.id.' buffer='.winbufnr(0)
|
||||
exe 'sign place '.id.' name=ShowMark'.nm.' line='.ln.' buffer='.winbufnr(0)
|
||||
let b:placed_{nm} = ln
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
let n = n + 1
|
||||
endw
|
||||
endf
|
||||
|
||||
" Function: ShowMarksClearMark()
|
||||
" Description: This function hides the mark at the current line.
|
||||
" It simply moves the mark to line 1 and removes the sign.
|
||||
" Only marks a-z and A-Z are supported.
|
||||
fun! s:ShowMarksClearMark()
|
||||
let ln = line(".")
|
||||
let n = 0
|
||||
let s:maxmarks = strlen(s:IncludeMarks())
|
||||
while n < s:maxmarks
|
||||
let c = strpart(s:IncludeMarks(), n, 1)
|
||||
if c =~# '[a-zA-Z]' && ln == line("'".c)
|
||||
let nm = s:NameOfMark(c)
|
||||
let id = n + (s:maxmarks * winbufnr(0))
|
||||
exe 'sign unplace '.id.' buffer='.winbufnr(0)
|
||||
exe '1 mark '.c
|
||||
let b:placed_{nm} = 1
|
||||
endif
|
||||
let n = n + 1
|
||||
endw
|
||||
endf
|
||||
|
||||
" Function: ShowMarksClearAll()
|
||||
" Description: This function clears all marks in the buffer.
|
||||
" It simply moves the marks to line 1 and removes the signs.
|
||||
" Only marks a-z and A-Z are supported.
|
||||
fun! s:ShowMarksClearAll()
|
||||
let n = 0
|
||||
let s:maxmarks = strlen(s:IncludeMarks())
|
||||
while n < s:maxmarks
|
||||
let c = strpart(s:IncludeMarks(), n, 1)
|
||||
if c =~# '[a-zA-Z]'
|
||||
let nm = s:NameOfMark(c)
|
||||
let id = n + (s:maxmarks * winbufnr(0))
|
||||
exe 'sign unplace '.id.' buffer='.winbufnr(0)
|
||||
exe '1 mark '.c
|
||||
let b:placed_{nm} = 1
|
||||
endif
|
||||
let n = n + 1
|
||||
endw
|
||||
endf
|
||||
|
||||
" Function: ShowMarksHideAll()
|
||||
" Description: This function hides all marks in the buffer.
|
||||
" It simply removes the signs.
|
||||
fun! s:ShowMarksHideAll()
|
||||
let n = 0
|
||||
let s:maxmarks = strlen(s:IncludeMarks())
|
||||
while n < s:maxmarks
|
||||
let c = strpart(s:IncludeMarks(), n, 1)
|
||||
let nm = s:NameOfMark(c)
|
||||
if exists('b:placed_'.nm)
|
||||
let id = n + (s:maxmarks * winbufnr(0))
|
||||
exe 'sign unplace '.id.' buffer='.winbufnr(0)
|
||||
unlet b:placed_{nm}
|
||||
endif
|
||||
let n = n + 1
|
||||
endw
|
||||
endf
|
||||
|
||||
" Function: ShowMarksPlaceMark()
|
||||
" Description: This function will place the next unplaced mark (in priority
|
||||
" order) to the current location. The idea here is to automate the placement
|
||||
" of marks so the user doesn't have to remember which marks are placed or not.
|
||||
" Hidden marks are considered to be unplaced.
|
||||
" Only marks a-z are supported.
|
||||
fun! s:ShowMarksPlaceMark()
|
||||
" Find the first, next, and last [a-z] mark in showmarks_include (i.e.
|
||||
" priority order), so we know where to "wrap".
|
||||
let first_alpha_mark = -1
|
||||
let last_alpha_mark = -1
|
||||
let next_mark = -1
|
||||
|
||||
if !exists('b:previous_auto_mark')
|
||||
let b:previous_auto_mark = -1
|
||||
endif
|
||||
|
||||
" Find the next unused [a-z] mark (in priority order); if they're all
|
||||
" used, find the next one after the previously auto-assigned mark.
|
||||
let n = 0
|
||||
let s:maxmarks = strlen(s:IncludeMarks())
|
||||
while n < s:maxmarks
|
||||
let c = strpart(s:IncludeMarks(), n, 1)
|
||||
if c =~# '[a-z]'
|
||||
if line("'".c) <= 1
|
||||
" Found an unused [a-z] mark; we're done.
|
||||
let next_mark = n
|
||||
break
|
||||
endif
|
||||
|
||||
if first_alpha_mark < 0
|
||||
let first_alpha_mark = n
|
||||
endif
|
||||
let last_alpha_mark = n
|
||||
if n > b:previous_auto_mark && next_mark == -1
|
||||
let next_mark = n
|
||||
endif
|
||||
endif
|
||||
let n = n + 1
|
||||
endw
|
||||
|
||||
if next_mark == -1 && (b:previous_auto_mark == -1 || b:previous_auto_mark == last_alpha_mark)
|
||||
" Didn't find an unused mark, and haven't placed any auto-chosen marks yet,
|
||||
" or the previously placed auto-chosen mark was the last alpha mark --
|
||||
" use the first alpha mark this time.
|
||||
let next_mark = first_alpha_mark
|
||||
endif
|
||||
|
||||
if (next_mark == -1)
|
||||
echohl WarningMsg
|
||||
echo 'No marks in [a-z] included! (No "next mark" to choose from)'
|
||||
echohl None
|
||||
return
|
||||
endif
|
||||
|
||||
let c = strpart(s:IncludeMarks(), next_mark, 1)
|
||||
let b:previous_auto_mark = next_mark
|
||||
exe 'mark '.c
|
||||
call <sid>ShowMarks()
|
||||
endf
|
||||
|
||||
" -----------------------------------------------------------------------------
|
||||
" vim:ts=4:sw=4:noet
|
||||
264
.vim/plugin/supertab.vba
Normal file
264
.vim/plugin/supertab.vba
Normal file
@@ -0,0 +1,264 @@
|
||||
*showmarks.txt* Visually show the location of marks
|
||||
|
||||
By Anthony Kruize <trandor@labyrinth.net.au>
|
||||
Michael Geddes <michaelrgeddes@optushome.com.au>
|
||||
|
||||
|
||||
ShowMarks provides a visual representation of |marks| local to a buffer.
|
||||
Marks are useful for jumping back and forth between interesting points in a
|
||||
buffer, but can be hard to keep track of without any way to see where you have
|
||||
placed them.
|
||||
|
||||
ShowMarks hopefully makes life easier by placing a |sign| in the
|
||||
leftmost column of the buffer. The sign indicates the label of the mark and
|
||||
its location.
|
||||
|
||||
ShowMarks is activated by the |CursorHold| |autocommand| which is triggered
|
||||
every |updatetime| milliseconds. This is set to 4000(4 seconds) by default.
|
||||
If this is too slow, setting it to a lower value will make it more responsive.
|
||||
|
||||
Note: This plugin requires Vim 6.x compiled with the |+signs| feature.
|
||||
|
||||
===============================================================================
|
||||
1. Contents *showmarks* *showmarks-contents*
|
||||
|
||||
1. Contents |showmarks-contents|
|
||||
2. Configuration |showmarks-configuration|
|
||||
3. Highlighting |showmarks-highlighting|
|
||||
4. Key mappings |showmarks-mappings|
|
||||
5. Commands |showmarks-commands|
|
||||
6. ChangeLog |showmarks-changelog|
|
||||
|
||||
Appendix
|
||||
A. Using marks |marks|
|
||||
B. Using signs |sign|
|
||||
C. Defining updatetime |updatetime|
|
||||
D. Defining a mapleader |mapleader|
|
||||
E. Defining highlighting |highlight|
|
||||
|
||||
===============================================================================
|
||||
2. Configuration *showmarks-configuration*
|
||||
|
||||
ShowMarks can be configured to suit your needs.
|
||||
The following options can be added to your |vimrc| to change how ShowMarks
|
||||
behaves:
|
||||
|
||||
*'showmarks_enable'*
|
||||
'showmarks_enable' boolean (default: 1)
|
||||
global
|
||||
This option enables or disables ShowMarks on startup. Normally ShowMarks
|
||||
will be enabled when Vim starts, setting this to 0 will disable ShowMarks
|
||||
by default.
|
||||
ShowMarks can be turned back on using the |ShowMarksToggle| command.
|
||||
|
||||
*'showmarks_include'*
|
||||
'showmarks_include' string (default:
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.'`^<>[]{}()\"")
|
||||
global or local to buffer
|
||||
This option specifies which marks will be shown and in which order if
|
||||
placed on the same line. Marks earlier in the list take precedence over
|
||||
marks later in the list.
|
||||
This option can also be specified as a buffer option which will override
|
||||
the global version.
|
||||
|
||||
NOTE: When including the " mark, it must be escaped with a \.
|
||||
|
||||
For example to only include marks 'abcdefzxABHJio', in that order:
|
||||
>
|
||||
let g:showmarks_include="abcdefzxABJio"
|
||||
<
|
||||
To override this for a particular buffer with 'ABCDhj.'^':
|
||||
>
|
||||
let b:showmarks_include="abcdefzxABJio"
|
||||
<
|
||||
*'showmarks_ignore_type'*
|
||||
'showmarks_ignore_type' string (default: "hq")
|
||||
global
|
||||
This option defines which types of buffers should be ignored.
|
||||
Each type is represented by a letter. This option is not case-sensitive.
|
||||
Valid buffer types are:
|
||||
- h : Help
|
||||
- m : Non-modifiable
|
||||
- p : Preview
|
||||
- q : Quickfix
|
||||
- r : Readonly
|
||||
|
||||
For example to ignore help, preview and readonly files:
|
||||
>
|
||||
let g:showmarks_ignore_type="hpr"
|
||||
<
|
||||
*'showmarks_ignore_name'*
|
||||
'showmarks_textlower' string (default: ">" )
|
||||
global
|
||||
This option defines how the marks a-z will be displayed.
|
||||
A maximum of two characters can be defined.
|
||||
To include the mark in the text use a tab(\t) character. A single
|
||||
character will display as the mark with the character suffixed (same as
|
||||
"\t<character>"). Specifying two characters will simply display those two
|
||||
characters.
|
||||
|
||||
Some examples:
|
||||
To display the mark with a > suffixed: >
|
||||
let g:showmarks_textlower="\t>"
|
||||
< or >
|
||||
let g:showmarks_textlower=">"
|
||||
<
|
||||
To display the mark with a ( prefixed: >
|
||||
let g:showmarks_textlower="(\t"
|
||||
<
|
||||
To display two > characters: >
|
||||
let g:showmarks_textlower=">>"
|
||||
<
|
||||
*'showmarks_textupper'*
|
||||
'showmarks_textupper' string (default: ">")
|
||||
global
|
||||
This option defines how the marks A-Z will be displayed. It behaves the same
|
||||
as the |'showmarks_textlower'| option.
|
||||
|
||||
*'showmarks_textother'*
|
||||
'showmarks_textother' string (default: ">")
|
||||
global
|
||||
This option defines how all other marks will be displayed. It behaves the
|
||||
same as the |'showmarks_textlower'| option.
|
||||
|
||||
'showmarks_hlline_lower' boolean (default: 0) *'showmarks_hlline_lower'*
|
||||
global
|
||||
This option defines whether the entire line a lowercase mark is on will
|
||||
be highlighted.
|
||||
|
||||
'showmarks_hlline_upper' boolean (default: 0) *'showmarks_hlline_upper'*
|
||||
global
|
||||
This option defines whether the entire line an uppercase mark is on will
|
||||
be highlighted.
|
||||
|
||||
'showmarks_hlline_other' boolean (default: 0) *'showmarks_hlline_other'*
|
||||
global
|
||||
This option defines whether the entire line other marks are on will be
|
||||
highlighted.
|
||||
|
||||
===============================================================================
|
||||
3. Highlighting *showmarks-highlighting*
|
||||
|
||||
Four highlighting groups are used by ShowMarks to define the colours used to
|
||||
highlight each of the marks.
|
||||
|
||||
- ShowMarksHLl : This group is used to highlight all the lowercase marks.
|
||||
- ShowMarksHLu : This group is used to highlight all the uppercase marks.
|
||||
- ShowMarksHLo : This group is used to highlight all other marks.
|
||||
- ShowMarksHLm : This group is used when multiple marks are on the same line.
|
||||
|
||||
You can define your own highlighting by overriding these groups in your |vimrc|.
|
||||
For example: >
|
||||
|
||||
highlight ShowMarksHLl guifg=red guibg=green
|
||||
<
|
||||
Will set all lowercase marks to be red on green when running in GVim.
|
||||
See |highlight| for more information.
|
||||
|
||||
===============================================================================
|
||||
4. Mappings *showmarks-mappings*
|
||||
|
||||
The following mappings are setup by default:
|
||||
|
||||
<Leader>mt - Toggles ShowMarks on and off.
|
||||
<Leader>mo - Forces ShowMarks on.
|
||||
<Leader>mh - Clears the mark at the current line.
|
||||
<Leader>ma - Clears all marks in the current buffer.
|
||||
<Leader>mm - Places the next available mark on the current line.
|
||||
|
||||
(see |mapleader| for how to setup the mapleader variable.)
|
||||
|
||||
===============================================================================
|
||||
5. Commands *showmarks-commands*
|
||||
|
||||
*ShowMarksToggle*
|
||||
:ShowMarksToggle
|
||||
This command will toggle the display of marks on or off.
|
||||
|
||||
|
||||
:ShowMarksOn *ShowMarksOn*
|
||||
This command will force the display of marks on.
|
||||
|
||||
*ShowMarksClearMark*
|
||||
:ShowMarksClearMark
|
||||
This command will clear the mark on the current line.
|
||||
It doesn't actually remove the mark, it simply moves it to line 1 and
|
||||
removes the sign.
|
||||
|
||||
*ShowMarksClearAll*
|
||||
:ShowMarksClearAll
|
||||
This command will clear all marks in the current buffer.
|
||||
It doesn't actually remove the marks, it simply moves them to line 1 and
|
||||
removes the signs.
|
||||
|
||||
*ShowMarksPlaceMark*
|
||||
:ShowMarksPlaceMark
|
||||
This command will place the next available mark on the current line. This
|
||||
effectively automates mark placement so you don't have to remember which
|
||||
marks are placed or not. Hidden marks are considered to be available.
|
||||
NOTE: Only marks a-z are supported by this function.
|
||||
|
||||
===============================================================================
|
||||
6. ChangeLog *showmarks-changelog*
|
||||
|
||||
2.2 - 2004-08-17
|
||||
Fixed highlighting of the A-Z marks when ignorecase is on. (Mike Kelly)
|
||||
Fixed the delay with ShowMarks triggering when entering a buffer for the
|
||||
first time. (Mikolaj Machowski)
|
||||
Added support for highlighting the entire line where a mark is placed.
|
||||
Now uses HelpExtractor by Charles E. Campbell to install the help file.
|
||||
|
||||
2.1 - 2004-03-04
|
||||
Added ShowMarksOn. It forces ShowMarks to be enabled whether it's on or not.
|
||||
(Gary Holloway)
|
||||
Marks now have a definable order of precedence for when mulitple alpha marks
|
||||
have been placed on the same line. A new highlight group, ShowMarksHLm is
|
||||
used to identify this situation. (Gary Holloway)
|
||||
- showmarks_include has changed accordingly.
|
||||
- ShowMarksHL is now ShowMarksHLl.
|
||||
ShowMarksPlaceMark now places marks in the order specified by
|
||||
showmarks_include. (Gary Holloway)
|
||||
showmarks_include can now be specified per buffer. (Gary Holloway)
|
||||
|
||||
2.0 - 2003-08-11
|
||||
Added ability to ignore buffers by type.
|
||||
Fixed toggling ShowMarks off when switching buffers.
|
||||
ShowMarksHideMark and ShowMarksHideAll have been renamed to
|
||||
ShowMarksClearMark and ShowMarksClearAll.
|
||||
Marks a-z, A-Z and others now have different highlighting from each other.
|
||||
Added support for all other marks. (Gary Holloway)
|
||||
Enhanced customization of how marks are displayed by allowing a prefix to
|
||||
be specified.(Gary Holloway & Anthony Kruize)
|
||||
Fixed CursorHold autocmd triggering even when ShowMarks is disabled.
|
||||
(Charles E. Campbell)
|
||||
|
||||
1.5 - 2002-07-16
|
||||
Added ability to customize how the marks are displayed.
|
||||
|
||||
1.4 - 2002-05-29
|
||||
Added support for placing the next available mark.
|
||||
(Thanks to Shishir Ramam for the idea)
|
||||
Added support for hiding all marks.
|
||||
Marks on line 1 are no longer shown. This stops hidden marks from
|
||||
reappearing when the file is opened again.
|
||||
Added a help file.
|
||||
|
||||
1.3 - 2002-05-20
|
||||
Fixed toggling ShowMarks not responding immediately.
|
||||
Added user commands for toggling/hiding marks.
|
||||
Added ability to disable ShowMarks by default.
|
||||
|
||||
1.2 - 2002-03-06
|
||||
Added a check that Vim was compiled with +signs support.
|
||||
Added the ability to define which marks are shown.
|
||||
Removed debugging code that was accidently left in.
|
||||
|
||||
1.1 - 2002-02-05
|
||||
Added support for the A-Z marks.
|
||||
Fixed sign staying placed if the line it was on is deleted.
|
||||
Clear autocommands before making new ones.
|
||||
|
||||
1.0 - 2001-11-20
|
||||
First release.
|
||||
|
||||
vim:tw=78:ts=8:ft=help
|
||||
4546
.vim/plugin/taglist.vim
Normal file
4546
.vim/plugin/taglist.vim
Normal file
File diff suppressed because it is too large
Load Diff
262
.vim/plugin/vcsbzr.vim
Normal file
262
.vim/plugin/vcsbzr.vim
Normal file
@@ -0,0 +1,262 @@
|
||||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" BZR extension for VCSCommand.
|
||||
"
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) Bob Hiestand
|
||||
"
|
||||
" 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.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandBZRExec
|
||||
" This variable specifies the BZR executable. If not set, it defaults to
|
||||
" 'bzr' executed from the user's executable path.
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandBZRExec', 'bzr'))
|
||||
" BZR is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:bzrFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke bzr suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return VCSCommandGetOption('VCSCommandBZRExec', 'bzr')
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the BZR executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'BZR'
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'BZR VCSCommand plugin called on non-BZR item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:bzrFunctions.Identify(buffer) {{{2
|
||||
function! s:bzrFunctions.Identify(buffer)
|
||||
let fileName = resolve(bufname(a:buffer))
|
||||
let l:save_bzr_log=$BZR_LOG
|
||||
try
|
||||
let $BZR_LOG=has("win32") || has("win95") || has("win64") || has("win16") ? "nul" : "/dev/null"
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' info -- "' . fileName . '"')
|
||||
finally
|
||||
let $BZR_LOG=l:save_bzr_log
|
||||
endtry
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Add() {{{2
|
||||
function! s:bzrFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Annotate(argList) {{{2
|
||||
function! s:bzrFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'BZRannotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = ''
|
||||
let options = ''
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = join(a:argList, ' ')
|
||||
let options = ' ' . caption
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
|
||||
if resultBuffer > 0
|
||||
normal! 1G2dd
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Commit(argList) {{{2
|
||||
function! s:bzrFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Delete() {{{2
|
||||
function! s:bzrFunctions.Delete(argList)
|
||||
return s:DoCommand(join(['rm'] + a:argList, ' '), 'rm', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Diff(argList) {{{2
|
||||
function! s:bzrFunctions.Diff(argList)
|
||||
if len(a:argList) == 0
|
||||
let revOptions = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let revOptions = ['-r' . join(a:argList, '..')]
|
||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
||||
else
|
||||
" Pass-through
|
||||
let caption = join(a:argList, ' ')
|
||||
let revOptions = a:argList
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin.
|
||||
" Returns: List of results: [revision, repository]
|
||||
|
||||
function! s:bzrFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = resolve(bufname(originalBuffer))
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -S -- "' . fileName . '"')
|
||||
let revision = s:VCSCommandUtility.system(s:Executable() . ' revno -- "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
|
||||
" File not under BZR control.
|
||||
if statusText =~ '^?'
|
||||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let [flags, repository] = matchlist(statusText, '^\(.\{3}\)\s\+\(\S\+\)')[1:2]
|
||||
if revision == ''
|
||||
" Error
|
||||
return ['Unknown']
|
||||
elseif flags =~ '^A'
|
||||
return ['New', 'New']
|
||||
else
|
||||
return [revision, repository]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Info(argList) {{{2
|
||||
function! s:bzrFunctions.Info(argList)
|
||||
return s:DoCommand(join(['version-info'] + a:argList, ' '), 'version-info', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Lock(argList) {{{2
|
||||
function! s:bzrFunctions.Lock(argList)
|
||||
echomsg 'bzr lock is not necessary'
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Log() {{{2
|
||||
function! s:bzrFunctions.Log(argList)
|
||||
if len(a:argList) == 0
|
||||
let options = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let options = ['-r' . join(a:argList, ':')]
|
||||
let caption = options[0]
|
||||
else
|
||||
" Pass-through
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Revert(argList) {{{2
|
||||
function! s:bzrFunctions.Revert(argList)
|
||||
return s:DoCommand('revert', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Review(argList) {{{2
|
||||
function! s:bzrFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let versiontag = '(current)'
|
||||
let versionOption = ''
|
||||
else
|
||||
let versiontag = a:argList[0]
|
||||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Status(argList) {{{2
|
||||
function! s:bzrFunctions.Status(argList)
|
||||
let options = ['-S']
|
||||
if len(a:argList) != 0
|
||||
let options = a:argList
|
||||
endif
|
||||
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:bzrFunctions.Unlock(argList) {{{2
|
||||
function! s:bzrFunctions.Unlock(argList)
|
||||
echomsg 'bzr unlock is not necessary'
|
||||
endfunction
|
||||
" Function: s:bzrFunctions.Update(argList) {{{2
|
||||
function! s:bzrFunctions.Update(argList)
|
||||
return s:DoCommand('update', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:bzrFunctions.AnnotateSplitRegex = '^[^|]\+ | '
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('BZR', expand('<sfile>'), s:bzrFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
1442
.vim/plugin/vcscommand.vim
Normal file
1442
.vim/plugin/vcscommand.vim
Normal file
File diff suppressed because it is too large
Load Diff
451
.vim/plugin/vcscvs.vim
Normal file
451
.vim/plugin/vcscvs.vim
Normal file
@@ -0,0 +1,451 @@
|
||||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" CVS extension for VCSCommand.
|
||||
"
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) Bob Hiestand
|
||||
"
|
||||
" 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.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Command documentation {{{2
|
||||
"
|
||||
" The following commands only apply to files under CVS source control.
|
||||
"
|
||||
" CVSEdit Performs "cvs edit" on the current file.
|
||||
"
|
||||
" CVSEditors Performs "cvs editors" on the current file.
|
||||
"
|
||||
" CVSUnedit Performs "cvs unedit" on the current file.
|
||||
"
|
||||
" CVSWatch Takes an argument which must be one of [on|off|add|remove].
|
||||
" Performs "cvs watch" with the given argument on the current
|
||||
" file.
|
||||
"
|
||||
" CVSWatchers Performs "cvs watchers" on the current file.
|
||||
"
|
||||
" CVSWatchAdd Alias for "CVSWatch add"
|
||||
"
|
||||
" CVSWatchOn Alias for "CVSWatch on"
|
||||
"
|
||||
" CVSWatchOff Alias for "CVSWatch off"
|
||||
"
|
||||
" CVSWatchRemove Alias for "CVSWatch remove"
|
||||
"
|
||||
" Mapping documentation: {{{2
|
||||
"
|
||||
" By default, a mapping is defined for each command. User-provided mappings
|
||||
" can be used instead by mapping to <Plug>CommandName, for instance:
|
||||
"
|
||||
" nnoremap ,ce <Plug>CVSEdit
|
||||
"
|
||||
" The default mappings are as follow:
|
||||
"
|
||||
" <Leader>ce CVSEdit
|
||||
" <Leader>cE CVSEditors
|
||||
" <Leader>ct CVSUnedit
|
||||
" <Leader>cwv CVSWatchers
|
||||
" <Leader>cwa CVSWatchAdd
|
||||
" <Leader>cwn CVSWatchOn
|
||||
" <Leader>cwf CVSWatchOff
|
||||
" <Leader>cwr CVSWatchRemove
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandCVSExec
|
||||
" This variable specifies the CVS executable. If not set, it defaults to
|
||||
" 'cvs' executed from the user's executable path.
|
||||
"
|
||||
" VCSCommandCVSDiffOpt
|
||||
" This variable, if set, determines the options passed to the cvs diff
|
||||
" command. If not set, it defaults to 'u'.
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandCVSExec', 'cvs'))
|
||||
" CVS is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:cvsFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke cvs suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return VCSCommandGetOption('VCSCommandCVSExec', 'cvs')
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the CVS executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'CVS'
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
let ret = VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
|
||||
if ret > 0
|
||||
if getline(line('$')) =~ '^cvs \w\+: closing down connection'
|
||||
$d
|
||||
1
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
return ret
|
||||
else
|
||||
throw 'CVS VCSCommand plugin called on non-CVS item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:GetRevision() {{{2
|
||||
" Function for retrieving the current buffer's revision number.
|
||||
" Returns: Revision number or an empty string if an error occurs.
|
||||
|
||||
function! s:GetRevision()
|
||||
if !exists('b:VCSCommandBufferInfo')
|
||||
let b:VCSCommandBufferInfo = s:cvsFunctions.GetBufferInfo()
|
||||
endif
|
||||
|
||||
if len(b:VCSCommandBufferInfo) > 0
|
||||
return b:VCSCommandBufferInfo[0]
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:cvsFunctions.Identify(buffer) {{{2
|
||||
function! s:cvsFunctions.Identify(buffer)
|
||||
let fileName = resolve(bufname(a:buffer))
|
||||
if isdirectory(fileName)
|
||||
let directoryName = fileName
|
||||
else
|
||||
let directoryName = fnamemodify(fileName, ':h')
|
||||
endif
|
||||
if strlen(directoryName) > 0
|
||||
let CVSRoot = directoryName . '/CVS/Root'
|
||||
else
|
||||
let CVSRoot = 'CVS/Root'
|
||||
endif
|
||||
if filereadable(CVSRoot)
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Add(argList) {{{2
|
||||
function! s:cvsFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Annotate(argList) {{{2
|
||||
function! s:cvsFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'CVSannotate'
|
||||
" This is a CVSAnnotate buffer. Perform annotation of the version
|
||||
" indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^[0-9.]+')
|
||||
|
||||
if VCSCommandGetOption('VCSCommandCVSAnnotateParent', 0) != 0
|
||||
if caption != '1.1'
|
||||
let revmaj = matchstr(caption,'\v[0-9.]+\ze\.[0-9]+')
|
||||
let revmin = matchstr(caption,'\v[0-9.]+\.\zs[0-9]+') - 1
|
||||
if revmin == 0
|
||||
" Jump to ancestor branch
|
||||
let caption = matchstr(revmaj,'\v[0-9.]+\ze\.[0-9]+')
|
||||
else
|
||||
let caption = revmaj . "." . revmin
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
let options = ['-r' . caption]
|
||||
else
|
||||
" CVS defaults to pulling HEAD, regardless of current branch.
|
||||
" Therefore, always pass desired revision.
|
||||
let caption = ''
|
||||
let options = ['-r' . s:GetRevision()]
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ['-r' . caption]
|
||||
else
|
||||
let caption = join(a:argList)
|
||||
let options = a:argList
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['-q', 'annotate'] + options), 'annotate', caption, {})
|
||||
if resultBuffer > 0
|
||||
" Remove header lines from standard error
|
||||
silent v/^\d\+\%(\.\d\+\)\+/d
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Commit(argList) {{{2
|
||||
function! s:cvsFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Delete() {{{2
|
||||
" By default, use the -f option to remove the file first. If options are
|
||||
" passed in, use those instead.
|
||||
function! s:cvsFunctions.Delete(argList)
|
||||
let options = ['-f']
|
||||
let caption = ''
|
||||
if len(a:argList) > 0
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
return s:DoCommand(join(['remove'] + options, ' '), 'delete', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Diff(argList) {{{2
|
||||
function! s:cvsFunctions.Diff(argList)
|
||||
if len(a:argList) == 0
|
||||
let revOptions = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let revOptions = ['-r' . join(a:argList, ' -r')]
|
||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
||||
else
|
||||
" Pass-through
|
||||
let caption = join(a:argList, ' ')
|
||||
let revOptions = a:argList
|
||||
endif
|
||||
|
||||
let cvsDiffOpt = VCSCommandGetOption('VCSCommandCVSDiffOpt', 'u')
|
||||
if cvsDiffOpt == ''
|
||||
let diffOptions = []
|
||||
else
|
||||
let diffOptions = ['-' . cvsDiffOpt]
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['diff'] + diffOptions + revOptions), 'diff', caption, {'allowNonZeroExit': 1})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin. This CVS extension adds branch name to the return
|
||||
" list as well.
|
||||
" Returns: List of results: [revision, repository, branch]
|
||||
|
||||
function! s:cvsFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = bufname(originalBuffer)
|
||||
if isdirectory(fileName)
|
||||
let tag = ''
|
||||
if filereadable(fileName . '/CVS/Tag')
|
||||
let tagFile = readfile(fileName . '/CVS/Tag')
|
||||
if len(tagFile) == 1
|
||||
let tag = substitute(tagFile[0], '^T', '', '')
|
||||
endif
|
||||
endif
|
||||
return [tag]
|
||||
endif
|
||||
let realFileName = fnamemodify(resolve(fileName), ':t')
|
||||
if !filereadable(fileName)
|
||||
return ['Unknown']
|
||||
endif
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(fileName)
|
||||
try
|
||||
let statusText=s:VCSCommandUtility.system(s:Executable() . ' status -- "' . realFileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
let revision=substitute(statusText, '^\_.*Working revision:\s*\(\d\+\%(\.\d\+\)\+\|New file!\)\_.*$', '\1', '')
|
||||
|
||||
" We can still be in a CVS-controlled directory without this being a CVS
|
||||
" file
|
||||
if match(revision, '^New file!$') >= 0
|
||||
let revision='New'
|
||||
elseif match(revision, '^\d\+\.\d\+\%(\.\d\+\.\d\+\)*$') <0
|
||||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let branch=substitute(statusText, '^\_.*Sticky Tag:\s\+\(\d\+\%(\.\d\+\)\+\|\a[A-Za-z0-9-_]*\|(none)\).*$', '\1', '')
|
||||
let repository=substitute(statusText, '^\_.*Repository revision:\s*\(\d\+\%(\.\d\+\)\+\|New file!\|No revision control file\)\_.*$', '\1', '')
|
||||
let repository=substitute(repository, '^New file!\|No revision control file$', 'New', '')
|
||||
return [revision, repository, branch]
|
||||
finally
|
||||
call VCSCommandChdir(oldCwd)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Log() {{{2
|
||||
function! s:cvsFunctions.Log(argList)
|
||||
if len(a:argList) == 0
|
||||
let options = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let options = ['-r' . join(a:argList, ':')]
|
||||
let caption = options[0]
|
||||
else
|
||||
" Pass-through
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['log'] + options), 'log', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Revert(argList) {{{2
|
||||
function! s:cvsFunctions.Revert(argList)
|
||||
return s:DoCommand('update -C', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Review(argList) {{{2
|
||||
function! s:cvsFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let versiontag = '(current)'
|
||||
let versionOption = ''
|
||||
else
|
||||
let versiontag = a:argList[0]
|
||||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
return s:DoCommand('-q update -p' . versionOption, 'review', versiontag, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Status(argList) {{{2
|
||||
function! s:cvsFunctions.Status(argList)
|
||||
return s:DoCommand(join(['status'] + a:argList, ' '), 'status', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:cvsFunctions.Update(argList) {{{2
|
||||
function! s:cvsFunctions.Update(argList)
|
||||
return s:DoCommand('update', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Section: CVS-specific functions {{{1
|
||||
|
||||
" Function: s:CVSEdit() {{{2
|
||||
function! s:CVSEdit()
|
||||
return s:DoCommand('edit', 'cvsedit', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:CVSEditors() {{{2
|
||||
function! s:CVSEditors()
|
||||
return s:DoCommand('editors', 'cvseditors', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:CVSUnedit() {{{2
|
||||
function! s:CVSUnedit()
|
||||
return s:DoCommand('unedit', 'cvsunedit', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:CVSWatch(onoff) {{{2
|
||||
function! s:CVSWatch(onoff)
|
||||
if a:onoff !~ '^\c\%(on\|off\|add\|remove\)$'
|
||||
echoerr 'Argument to CVSWatch must be one of [on|off|add|remove]'
|
||||
return -1
|
||||
end
|
||||
return s:DoCommand('watch ' . tolower(a:onoff), 'cvswatch', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:CVSWatchers() {{{2
|
||||
function! s:CVSWatchers()
|
||||
return s:DoCommand('watchers', 'cvswatchers', '', {})
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:cvsFunctions.AnnotateSplitRegex = '): '
|
||||
|
||||
" Section: Command definitions {{{1
|
||||
" Section: Primary commands {{{2
|
||||
com! CVSEdit call s:CVSEdit()
|
||||
com! CVSEditors call s:CVSEditors()
|
||||
com! CVSUnedit call s:CVSUnedit()
|
||||
com! -nargs=1 CVSWatch call s:CVSWatch(<f-args>)
|
||||
com! CVSWatchAdd call s:CVSWatch('add')
|
||||
com! CVSWatchOn call s:CVSWatch('on')
|
||||
com! CVSWatchOff call s:CVSWatch('off')
|
||||
com! CVSWatchRemove call s:CVSWatch('remove')
|
||||
com! CVSWatchers call s:CVSWatchers()
|
||||
|
||||
" Section: Plugin command mappings {{{1
|
||||
|
||||
let s:cvsExtensionMappings = {}
|
||||
if !exists("no_plugin_maps")
|
||||
let mappingInfo = [
|
||||
\['CVSEdit', 'CVSEdit', 'e'],
|
||||
\['CVSEditors', 'CVSEditors', 'E'],
|
||||
\['CVSUnedit', 'CVSUnedit', 't'],
|
||||
\['CVSWatchers', 'CVSWatchers', 'wv'],
|
||||
\['CVSWatchAdd', 'CVSWatch add', 'wa'],
|
||||
\['CVSWatchOff', 'CVSWatch off', 'wf'],
|
||||
\['CVSWatchOn', 'CVSWatch on', 'wn'],
|
||||
\['CVSWatchRemove', 'CVSWatch remove', 'wr']
|
||||
\]
|
||||
|
||||
for [pluginName, commandText, shortCut] in mappingInfo
|
||||
execute 'nnoremap <silent> <Plug>' . pluginName . ' :' . commandText . '<CR>'
|
||||
if !hasmapto('<Plug>' . pluginName)
|
||||
let s:cvsExtensionMappings[shortCut] = commandText
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('CVS', expand('<sfile>'), s:cvsFunctions, s:cvsExtensionMappings)
|
||||
|
||||
" Section: Menu items {{{1
|
||||
for [s:shortcut, s:command] in [
|
||||
\['CVS.&Edit', '<Plug>CVSEdit'],
|
||||
\['CVS.Ed&itors', '<Plug>CVSEditors'],
|
||||
\['CVS.Unedi&t', '<Plug>CVSUnedit'],
|
||||
\['CVS.&Watchers', '<Plug>CVSWatchers'],
|
||||
\['CVS.WatchAdd', '<Plug>CVSWatchAdd'],
|
||||
\['CVS.WatchOn', '<Plug>CVSWatchOn'],
|
||||
\['CVS.WatchOff', '<Plug>CVSWatchOff'],
|
||||
\['CVS.WatchRemove', '<Plug>CVSWatchRemove']
|
||||
\]
|
||||
call s:VCSCommandUtility.addMenuItem(s:shortcut, s:command)
|
||||
endfor
|
||||
unlet s:shortcut s:command
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
247
.vim/plugin/vcsgit.vim
Normal file
247
.vim/plugin/vcsgit.vim
Normal file
@@ -0,0 +1,247 @@
|
||||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" git extension for VCSCommand.
|
||||
"
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) Bob Hiestand
|
||||
"
|
||||
" 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.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandGitExec
|
||||
" This variable specifies the git executable. If not set, it defaults to
|
||||
" 'git' executed from the user's executable path.
|
||||
"
|
||||
" VCSCommandGitDiffOpt
|
||||
" This variable, if set, determines the default options passed to the
|
||||
" VCSDiff command. If any options (starting with '-') are passed to the
|
||||
" command, this variable is not used.
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandGitExec', 'git'))
|
||||
" git is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:gitFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke git suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return VCSCommandGetOption('VCSCommandGitExec', 'git')
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the git executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'git'
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'git VCSCommand plugin called on non-git item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:gitFunctions.Identify(buffer) {{{2
|
||||
" This function only returns an inexact match due to the detection method used
|
||||
" by git, which simply traverses the directory structure upward.
|
||||
function! s:gitFunctions.Identify(buffer)
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
|
||||
try
|
||||
call s:VCSCommandUtility.system(s:Executable() . ' rev-parse --is-inside-work-tree')
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
return g:VCSCOMMAND_IDENTIFY_INEXACT
|
||||
endif
|
||||
finally
|
||||
call VCSCommandChdir(oldCwd)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Add(argList) {{{2
|
||||
function! s:gitFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + ['-v'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Annotate(argList) {{{2
|
||||
function! s:gitFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'gitannotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let options = matchstr(getline('.'),'^\x\+')
|
||||
else
|
||||
let options = ''
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let options = a:argList[0]
|
||||
else
|
||||
let options = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
return s:DoCommand('blame ' . options, 'annotate', options, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Commit(argList) {{{2
|
||||
function! s:gitFunctions.Commit(argList)
|
||||
try
|
||||
return s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
catch /\m^Version control command failed.*nothing\%( added\)\? to commit/
|
||||
echomsg 'No commit needed.'
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Delete() {{{2
|
||||
" All options are passed through.
|
||||
function! s:gitFunctions.Delete(argList)
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
return s:DoCommand(join(['rm'] + options, ' '), 'delete', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Diff(argList) {{{2
|
||||
" Pass-through call to git-diff. If no options (starting with '-') are found,
|
||||
" then the options in the 'VCSCommandGitDiffOpt' variable are added.
|
||||
function! s:gitFunctions.Diff(argList)
|
||||
let gitDiffOpt = VCSCommandGetOption('VCSCommandGitDiffOpt', '')
|
||||
if gitDiffOpt == ''
|
||||
let diffOptions = []
|
||||
else
|
||||
let diffOptions = [gitDiffOpt]
|
||||
for arg in a:argList
|
||||
if arg =~ '^-'
|
||||
let diffOptions = []
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['diff'] + diffOptions + a:argList), 'diff', join(a:argList), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin. This CVS extension adds branch name to the return
|
||||
" list as well.
|
||||
" Returns: List of results: [revision, repository, branch]
|
||||
|
||||
function! s:gitFunctions.GetBufferInfo()
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname('%')))
|
||||
try
|
||||
let branch = substitute(s:VCSCommandUtility.system(s:Executable() . ' symbolic-ref -q HEAD'), '\n$', '', '')
|
||||
if v:shell_error
|
||||
let branch = 'DETACHED'
|
||||
else
|
||||
let branch = substitute(branch, '^refs/heads/', '', '')
|
||||
endif
|
||||
|
||||
let info = [branch]
|
||||
|
||||
for method in split(VCSCommandGetOption('VCSCommandGitDescribeArgList', (',tags,all,always')), ',', 1)
|
||||
if method != ''
|
||||
let method = ' --' . method
|
||||
endif
|
||||
let tag = substitute(s:VCSCommandUtility.system(s:Executable() . ' describe' . method), '\n$', '', '')
|
||||
if !v:shell_error
|
||||
call add(info, tag)
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
return info
|
||||
finally
|
||||
call VCSCommandChdir(oldCwd)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Log() {{{2
|
||||
function! s:gitFunctions.Log(argList)
|
||||
return s:DoCommand(join(['log'] + a:argList), 'log', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Revert(argList) {{{2
|
||||
function! s:gitFunctions.Revert(argList)
|
||||
return s:DoCommand('checkout', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Review(argList) {{{2
|
||||
function! s:gitFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let revision = 'HEAD'
|
||||
else
|
||||
let revision = a:argList[0]
|
||||
endif
|
||||
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(VCSCommandGetOriginalBuffer('%'))))
|
||||
try
|
||||
let prefix = s:VCSCommandUtility.system(s:Executable() . ' rev-parse --show-prefix')
|
||||
finally
|
||||
call VCSCommandChdir(oldCwd)
|
||||
endtry
|
||||
|
||||
let prefix = substitute(prefix, '\n$', '', '')
|
||||
let blob = '"' . revision . ':' . prefix . '<VCSCOMMANDFILE>"'
|
||||
return s:DoCommand('show ' . blob, 'review', revision, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Status(argList) {{{2
|
||||
function! s:gitFunctions.Status(argList)
|
||||
return s:DoCommand(join(['status'] + a:argList), 'status', join(a:argList), {'allowNonZeroExit': 1})
|
||||
endfunction
|
||||
|
||||
" Function: s:gitFunctions.Update(argList) {{{2
|
||||
function! s:gitFunctions.Update(argList)
|
||||
throw "This command is not implemented for git because file-by-file update doesn't make much sense in that context. If you have an idea for what it should do, please let me know."
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:gitFunctions.AnnotateSplitRegex = ') '
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('git', expand('<sfile>'), s:gitFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
273
.vim/plugin/vcshg.vim
Normal file
273
.vim/plugin/vcshg.vim
Normal file
@@ -0,0 +1,273 @@
|
||||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" Mercurial extension for VCSCommand.
|
||||
"
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) Bob Hiestand
|
||||
"
|
||||
" 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.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandHGExec
|
||||
" This variable specifies the mercurial executable. If not set, it defaults
|
||||
" to 'hg' executed from the user's executable path.
|
||||
"
|
||||
" VCSCommandHGDiffExt
|
||||
" This variable, if set, sets the external diff program used by Subversion.
|
||||
"
|
||||
" VCSCommandHGDiffOpt
|
||||
" This variable, if set, determines the options passed to the hg diff
|
||||
" command (such as 'u', 'w', or 'b').
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandHGExec', 'hg'))
|
||||
" HG is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:hgFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke hg suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return VCSCommandGetOption('VCSCommandHGExec', 'hg')
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the HG executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'HG'
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'HG VCSCommand plugin called on non-HG item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:hgFunctions.Identify(buffer) {{{2
|
||||
function! s:hgFunctions.Identify(buffer)
|
||||
let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer)))
|
||||
try
|
||||
call s:VCSCommandUtility.system(s:Executable() . ' root')
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
return g:VCSCOMMAND_IDENTIFY_INEXACT
|
||||
endif
|
||||
finally
|
||||
call VCSCommandChdir(oldCwd)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Add() {{{2
|
||||
function! s:hgFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add -v'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Annotate(argList) {{{2
|
||||
function! s:hgFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'HGannotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = ''
|
||||
let options = ' -un'
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ' -un -r' . caption
|
||||
else
|
||||
let caption = join(a:argList, ' ')
|
||||
let options = ' ' . caption
|
||||
endif
|
||||
|
||||
return s:DoCommand('blame' . options, 'annotate', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Commit(argList) {{{2
|
||||
function! s:hgFunctions.Commit(argList)
|
||||
try
|
||||
return s:DoCommand('commit -v -l "' . a:argList[0] . '"', 'commit', '', {})
|
||||
catch /Version control command failed.*nothing changed/
|
||||
echomsg 'No commit needed.'
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Delete() {{{2
|
||||
function! s:hgFunctions.Delete(argList)
|
||||
return s:DoCommand(join(['remove'] + a:argList, ' '), 'remove', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Diff(argList) {{{2
|
||||
function! s:hgFunctions.Diff(argList)
|
||||
if len(a:argList) == 0
|
||||
let revOptions = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let revOptions = ['-r' . join(a:argList, ':')]
|
||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
||||
else
|
||||
" Pass-through
|
||||
let caption = join(a:argList, ' ')
|
||||
let revOptions = a:argList
|
||||
endif
|
||||
|
||||
let hgDiffExt = VCSCommandGetOption('VCSCommandHGDiffExt', '')
|
||||
if hgDiffExt == ''
|
||||
let diffExt = []
|
||||
else
|
||||
let diffExt = ['--diff-cmd ' . hgDiffExt]
|
||||
endif
|
||||
|
||||
let hgDiffOpt = VCSCommandGetOption('VCSCommandHGDiffOpt', '')
|
||||
if hgDiffOpt == ''
|
||||
let diffOptions = []
|
||||
else
|
||||
let diffOptions = ['-x -' . hgDiffOpt]
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['diff'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Info(argList) {{{2
|
||||
function! s:hgFunctions.Info(argList)
|
||||
return s:DoCommand(join(['log --limit 1'] + a:argList, ' '), 'log', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin.
|
||||
" Returns: List of results: [revision, repository, branch]
|
||||
|
||||
function! s:hgFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = bufname(originalBuffer)
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -- "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
|
||||
" File not under HG control.
|
||||
if statusText =~ '^?'
|
||||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let parentsText = s:VCSCommandUtility.system(s:Executable() . ' parents -- "' . fileName . '"')
|
||||
let revision = matchlist(parentsText, '^changeset:\s\+\(\S\+\)\n')[1]
|
||||
|
||||
let logText = s:VCSCommandUtility.system(s:Executable() . ' log -- "' . fileName . '"')
|
||||
let repository = matchlist(logText, '^changeset:\s\+\(\S\+\)\n')[1]
|
||||
|
||||
if revision == ''
|
||||
" Error
|
||||
return ['Unknown']
|
||||
elseif statusText =~ '^A'
|
||||
return ['New', 'New']
|
||||
else
|
||||
return [revision, repository]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Log(argList) {{{2
|
||||
function! s:hgFunctions.Log(argList)
|
||||
if len(a:argList) == 0
|
||||
let options = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let options = ['-r' . join(a:argList, ':')]
|
||||
let caption = options[0]
|
||||
else
|
||||
" Pass-through
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Revert(argList) {{{2
|
||||
function! s:hgFunctions.Revert(argList)
|
||||
return s:DoCommand('revert', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Review(argList) {{{2
|
||||
function! s:hgFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let versiontag = '(current)'
|
||||
let versionOption = ''
|
||||
else
|
||||
let versiontag = a:argList[0]
|
||||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Status(argList) {{{2
|
||||
function! s:hgFunctions.Status(argList)
|
||||
let options = ['-A', '-v']
|
||||
if len(a:argList) != 0
|
||||
let options = a:argList
|
||||
endif
|
||||
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:hgFunctions.Update(argList) {{{2
|
||||
function! s:hgFunctions.Update(argList)
|
||||
return s:DoCommand('update', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:hgFunctions.AnnotateSplitRegex = '\d\+: '
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('HG', expand('<sfile>'), s:hgFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
257
.vim/plugin/vcssvk.vim
Normal file
257
.vim/plugin/vcssvk.vim
Normal file
@@ -0,0 +1,257 @@
|
||||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" SVK extension for VCSCommand.
|
||||
"
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) Bob Hiestand
|
||||
"
|
||||
" 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.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandSVKExec
|
||||
" This variable specifies the SVK executable. If not set, it defaults to
|
||||
" 'svk' executed from the user's executable path.
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandSVKExec', 'svk'))
|
||||
" SVK is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:svkFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke SVK suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return VCSCommandGetOption('VCSCommandSVKExec', 'svk')
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the SVK executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'SVK'
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'SVK VCSCommand plugin called on non-SVK item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:svkFunctions.Identify(buffer) {{{2
|
||||
function! s:svkFunctions.Identify(buffer)
|
||||
let fileName = resolve(bufname(a:buffer))
|
||||
if isdirectory(fileName)
|
||||
let directoryName = fileName
|
||||
else
|
||||
let directoryName = fnamemodify(fileName, ':p:h')
|
||||
endif
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' info -- "' . directoryName . '"', "no")
|
||||
if(v:shell_error)
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Add() {{{2
|
||||
function! s:svkFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Annotate(argList) {{{2
|
||||
function! s:svkFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'SVKannotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = ''
|
||||
let options = ''
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = join(a:argList, ' ')
|
||||
let options = ' ' . caption
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand('blame' . options, 'annotate', caption, {})
|
||||
if resultBuffer > 0
|
||||
normal! 1G2dd
|
||||
endif
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Commit(argList) {{{2
|
||||
function! s:svkFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Delete() {{{2
|
||||
function! s:svkFunctions.Delete(argList)
|
||||
return s:DoCommand(join(['delete'] + a:argList, ' '), 'delete', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Diff(argList) {{{2
|
||||
function! s:svkFunctions.Diff(argList)
|
||||
if len(a:argList) == 0
|
||||
let revOptions = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let revOptions = ['-r' . join(a:argList, ':')]
|
||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
||||
else
|
||||
" Pass-through
|
||||
let caption = join(a:argList, ' ')
|
||||
let revOptions = a:argList
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['diff'] + revOptions), 'diff', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin.
|
||||
" Returns: List of results: [revision, repository]
|
||||
|
||||
function! s:svkFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = resolve(bufname(originalBuffer))
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status -v -- "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
|
||||
" File not under SVK control.
|
||||
if statusText =~ '^?'
|
||||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let [flags, revision, repository] = matchlist(statusText, '^\(.\{3}\)\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\S\+\)\s')[1:3]
|
||||
if revision == ''
|
||||
" Error
|
||||
return ['Unknown']
|
||||
elseif flags =~ '^A'
|
||||
return ['New', 'New']
|
||||
else
|
||||
return [revision, repository]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Info(argList) {{{2
|
||||
function! s:svkFunctions.Info(argList)
|
||||
return s:DoCommand(join(['info'] + a:argList, ' '), 'info', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Lock(argList) {{{2
|
||||
function! s:svkFunctions.Lock(argList)
|
||||
return s:DoCommand(join(['lock'] + a:argList, ' '), 'lock', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Log() {{{2
|
||||
function! s:svkFunctions.Log(argList)
|
||||
if len(a:argList) == 0
|
||||
let options = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let options = ['-r' . join(a:argList, ':')]
|
||||
let caption = options[0]
|
||||
else
|
||||
" Pass-through
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['log', '-v'] + options), 'log', caption, {})
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Revert(argList) {{{2
|
||||
function! s:svkFunctions.Revert(argList)
|
||||
return s:DoCommand('revert', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Review(argList) {{{2
|
||||
function! s:svkFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let versiontag = '(current)'
|
||||
let versionOption = ''
|
||||
else
|
||||
let versiontag = a:argList[0]
|
||||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
return s:DoCommand('cat' . versionOption, 'review', versiontag, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Status(argList) {{{2
|
||||
function! s:svkFunctions.Status(argList)
|
||||
let options = ['-v']
|
||||
if len(a:argList) != 0
|
||||
let options = a:argList
|
||||
endif
|
||||
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svkFunctions.Unlock(argList) {{{2
|
||||
function! s:svkFunctions.Unlock(argList)
|
||||
return s:DoCommand(join(['unlock'] + a:argList, ' '), 'unlock', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
" Function: s:svkFunctions.Update(argList) {{{2
|
||||
function! s:svkFunctions.Update(argList)
|
||||
return s:DoCommand('update', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('SVK', expand('<sfile>'), s:svkFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
284
.vim/plugin/vcssvn.vim
Normal file
284
.vim/plugin/vcssvn.vim
Normal file
@@ -0,0 +1,284 @@
|
||||
" vim600: set foldmethod=marker:
|
||||
"
|
||||
" SVN extension for VCSCommand.
|
||||
"
|
||||
" Maintainer: Bob Hiestand <bob.hiestand@gmail.com>
|
||||
" License:
|
||||
" Copyright (c) Bob Hiestand
|
||||
"
|
||||
" 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.
|
||||
"
|
||||
" Section: Documentation {{{1
|
||||
"
|
||||
" Options documentation: {{{2
|
||||
"
|
||||
" VCSCommandSVNExec
|
||||
" This variable specifies the SVN executable. If not set, it defaults to
|
||||
" 'svn' executed from the user's executable path.
|
||||
"
|
||||
" VCSCommandSVNDiffExt
|
||||
" This variable, if set, sets the external diff program used by Subversion.
|
||||
"
|
||||
" VCSCommandSVNDiffOpt
|
||||
" This variable, if set, determines the options passed to the svn diff
|
||||
" command (such as 'u', 'w', or 'b').
|
||||
|
||||
" Section: Plugin header {{{1
|
||||
|
||||
if exists('VCSCommandDisableAll')
|
||||
finish
|
||||
endif
|
||||
|
||||
if v:version < 700
|
||||
echohl WarningMsg|echomsg 'VCSCommand requires at least VIM 7.0'|echohl None
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime plugin/vcscommand.vim
|
||||
|
||||
if !executable(VCSCommandGetOption('VCSCommandSVNExec', 'svn'))
|
||||
" SVN is not installed
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:save_cpo=&cpo
|
||||
set cpo&vim
|
||||
|
||||
" Section: Variable initialization {{{1
|
||||
|
||||
let s:svnFunctions = {}
|
||||
|
||||
" Section: Utility functions {{{1
|
||||
|
||||
" Function: s:Executable() {{{2
|
||||
" Returns the executable used to invoke git suitable for use in a shell
|
||||
" command.
|
||||
function! s:Executable()
|
||||
return VCSCommandGetOption('VCSCommandSVNExec', 'svn')
|
||||
endfunction
|
||||
|
||||
" Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2
|
||||
" Wrapper to VCSCommandDoCommand to add the name of the SVN executable to the
|
||||
" command argument.
|
||||
function! s:DoCommand(cmd, cmdName, statusText, options)
|
||||
if VCSCommandGetVCSType(expand('%')) == 'SVN'
|
||||
let fullCmd = s:Executable() . ' ' . a:cmd
|
||||
return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options)
|
||||
else
|
||||
throw 'SVN VCSCommand plugin called on non-SVN item.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Section: VCS function implementations {{{1
|
||||
|
||||
" Function: s:svnFunctions.Identify(buffer) {{{2
|
||||
function! s:svnFunctions.Identify(buffer)
|
||||
let fileName = resolve(bufname(a:buffer))
|
||||
if isdirectory(fileName)
|
||||
let directoryName = fileName
|
||||
else
|
||||
let directoryName = fnamemodify(fileName, ':h')
|
||||
endif
|
||||
if strlen(directoryName) > 0
|
||||
let svnDir = directoryName . '/.svn'
|
||||
else
|
||||
let svnDir = '.svn'
|
||||
endif
|
||||
if isdirectory(svnDir)
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Add() {{{2
|
||||
function! s:svnFunctions.Add(argList)
|
||||
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Annotate(argList) {{{2
|
||||
function! s:svnFunctions.Annotate(argList)
|
||||
if len(a:argList) == 0
|
||||
if &filetype == 'SVNannotate'
|
||||
" Perform annotation of the version indicated by the current line.
|
||||
let caption = matchstr(getline('.'),'\v^\s+\zs\d+')
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = ''
|
||||
let options = ''
|
||||
endif
|
||||
elseif len(a:argList) == 1 && a:argList[0] !~ '^-'
|
||||
let caption = a:argList[0]
|
||||
let options = ' -r' . caption
|
||||
else
|
||||
let caption = join(a:argList, ' ')
|
||||
let options = ' ' . caption
|
||||
endif
|
||||
|
||||
return s:DoCommand('blame --non-interactive' . options, 'annotate', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Commit(argList) {{{2
|
||||
function! s:svnFunctions.Commit(argList)
|
||||
let resultBuffer = s:DoCommand('commit --non-interactive -F "' . a:argList[0] . '"', 'commit', '', {})
|
||||
if resultBuffer == 0
|
||||
echomsg 'No commit needed.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Delete() {{{2
|
||||
function! s:svnFunctions.Delete(argList)
|
||||
return s:DoCommand(join(['delete --non-interactive'] + a:argList, ' '), 'delete', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Diff(argList) {{{2
|
||||
function! s:svnFunctions.Diff(argList)
|
||||
if len(a:argList) == 0
|
||||
let revOptions = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let revOptions = ['-r' . join(a:argList, ':')]
|
||||
let caption = '(' . a:argList[0] . ' : ' . get(a:argList, 1, 'current') . ')'
|
||||
else
|
||||
" Pass-through
|
||||
let caption = join(a:argList, ' ')
|
||||
let revOptions = a:argList
|
||||
endif
|
||||
|
||||
let svnDiffExt = VCSCommandGetOption('VCSCommandSVNDiffExt', '')
|
||||
if svnDiffExt == ''
|
||||
let diffExt = []
|
||||
else
|
||||
let diffExt = ['--diff-cmd ' . svnDiffExt]
|
||||
endif
|
||||
|
||||
let svnDiffOpt = VCSCommandGetOption('VCSCommandSVNDiffOpt', '')
|
||||
if svnDiffOpt == ''
|
||||
let diffOptions = []
|
||||
else
|
||||
let diffOptions = ['-x -' . svnDiffOpt]
|
||||
endif
|
||||
|
||||
return s:DoCommand(join(['diff --non-interactive'] + diffExt + diffOptions + revOptions), 'diff', caption, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.GetBufferInfo() {{{2
|
||||
" Provides version control details for the current file. Current version
|
||||
" number and current repository version number are required to be returned by
|
||||
" the vcscommand plugin.
|
||||
" Returns: List of results: [revision, repository, branch]
|
||||
|
||||
function! s:svnFunctions.GetBufferInfo()
|
||||
let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%'))
|
||||
let fileName = bufname(originalBuffer)
|
||||
let statusText = s:VCSCommandUtility.system(s:Executable() . ' status --non-interactive -vu -- "' . fileName . '"')
|
||||
if(v:shell_error)
|
||||
return []
|
||||
endif
|
||||
|
||||
" File not under SVN control.
|
||||
if statusText =~ '^?'
|
||||
return ['Unknown']
|
||||
endif
|
||||
|
||||
let [flags, revision, repository] = matchlist(statusText, '^\(.\{9}\)\s*\(\d\+\)\s\+\(\d\+\)')[1:3]
|
||||
if revision == ''
|
||||
" Error
|
||||
return ['Unknown']
|
||||
elseif flags =~ '^A'
|
||||
return ['New', 'New']
|
||||
elseif flags =~ '*'
|
||||
return [revision, repository, '*']
|
||||
else
|
||||
return [revision, repository]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Info(argList) {{{2
|
||||
function! s:svnFunctions.Info(argList)
|
||||
return s:DoCommand(join(['info --non-interactive'] + a:argList, ' '), 'info', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Lock(argList) {{{2
|
||||
function! s:svnFunctions.Lock(argList)
|
||||
return s:DoCommand(join(['lock --non-interactive'] + a:argList, ' '), 'lock', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Log(argList) {{{2
|
||||
function! s:svnFunctions.Log(argList)
|
||||
if len(a:argList) == 0
|
||||
let options = []
|
||||
let caption = ''
|
||||
elseif len(a:argList) <= 2 && match(a:argList, '^-') == -1
|
||||
let options = ['-r' . join(a:argList, ':')]
|
||||
let caption = options[0]
|
||||
else
|
||||
" Pass-through
|
||||
let options = a:argList
|
||||
let caption = join(a:argList, ' ')
|
||||
endif
|
||||
|
||||
let resultBuffer = s:DoCommand(join(['log --non-interactive', '-v'] + options), 'log', caption, {})
|
||||
return resultBuffer
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Revert(argList) {{{2
|
||||
function! s:svnFunctions.Revert(argList)
|
||||
return s:DoCommand('revert', 'revert', '', {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Review(argList) {{{2
|
||||
function! s:svnFunctions.Review(argList)
|
||||
if len(a:argList) == 0
|
||||
let versiontag = '(current)'
|
||||
let versionOption = ''
|
||||
else
|
||||
let versiontag = a:argList[0]
|
||||
let versionOption = ' -r ' . versiontag . ' '
|
||||
endif
|
||||
|
||||
return s:DoCommand('cat --non-interactive' . versionOption, 'review', versiontag, {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Status(argList) {{{2
|
||||
function! s:svnFunctions.Status(argList)
|
||||
let options = ['-u', '-v']
|
||||
if len(a:argList) != 0
|
||||
let options = a:argList
|
||||
endif
|
||||
return s:DoCommand(join(['status --non-interactive'] + options, ' '), 'status', join(options, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Unlock(argList) {{{2
|
||||
function! s:svnFunctions.Unlock(argList)
|
||||
return s:DoCommand(join(['unlock --non-interactive'] + a:argList, ' '), 'unlock', join(a:argList, ' '), {})
|
||||
endfunction
|
||||
|
||||
" Function: s:svnFunctions.Update(argList) {{{2
|
||||
function! s:svnFunctions.Update(argList)
|
||||
return s:DoCommand('update --non-interactive', 'update', '', {})
|
||||
endfunction
|
||||
|
||||
" Annotate setting {{{2
|
||||
let s:svnFunctions.AnnotateSplitRegex = '\s\+\S\+\s\+\S\+ '
|
||||
|
||||
" Section: Plugin Registration {{{1
|
||||
let s:VCSCommandUtility = VCSCommandRegisterModule('SVN', expand('<sfile>'), s:svnFunctions, [])
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
Reference in New Issue
Block a user