Initial commit.

This commit is contained in:
yan 2011-11-17 15:45:33 -06:00
commit 882015bc6d
1819 changed files with 111625 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.DS_Store
vim/backups
*un~

40
README.md Normal file
View File

@ -0,0 +1,40 @@
Yan's Excellent Dotfiles!
====
To set these up as your own (careful, don't overwrite your bash_profile unintentionally!):
git clone git://github.com/skwp/dotfiles ~/.dotfiles
ln -s ~/.dotfiles/bash_profile ~/.bash_profile
. ~/.bash_profile
Lots of things I do every day are done with
two or three character mnemonic aliases. Please
feel free to edit them:
ae # alias edit
ar # alias reload
To use the vim files:
ln -s ~/.dotfiles/vimrc ~/.vimrc
ln -s ~/.dotfiles/vim ~/.vim
The .vimrc is well commented and broken up by settings. I encourage you
to take a look and learn some of my handy aliases, or comment them out
if you don't like them, or make your own.
Credits
===
I can't take credit for all of this. The vim files are a combination of
work by tpope, scrooloose, and many hours of scouring blogs, vimscripts,
and other places for the cream of the crop of vim and bash awesomeness.
TODO
===
I started migrating to tpope's pathogen, but only a few plugins are
currently under vim/bundles.
For more tips and tricks
===
Follow my blog: [yan http://yanpritzker.com]

94
bash_aliases Normal file
View File

@ -0,0 +1,94 @@
# PS
alias psg="ps aux | grep $1"
alias psr='ps aux | grep ruby'
# Moving around
alias ..='cd ..'
alias cdb='cd -'
# Show human friendly numbers and colors
alias df='df -h'
alias ll='ls -alGh'
alias ls='ls -Gh'
alias du='du -h -d 1'
# show me files matching "ls grep"
alias lsg='ll | grep'
# Alias Editing
alias ae='vi ~/dev/config/bash_aliases' #alias edit
alias ar='. ~/dev/config/bash_aliases' #alias reload
# Bash Options Editing
alias boe='vi ~/dev/config/bash_options'
alias bor='. ~/dev/config/bash_options'
# .bash_profile editing
alias bp='vi ~/.bash_profile'
alias br='. ~/.bash_profile'
# Git Aliases
alias gs='git status'
alias gstsh='git stash'
alias gst='git stash'
alias gsh='git show'
alias gshw='git show'
alias gshow='git show'
alias gi='vi .gitignore'
alias gcm='git ci -m'
alias gcim='git ci -m'
alias gci='git ci'
alias gco='git co'
alias ga='git add -A'
alias gu='git unstage'
alias gm='git merge'
alias gms='git merge --squash'
alias gam='git amend'
alias gr='git rebase'
alias gra='git rebase --abort'
alias grc='git rebase --continue'
alias gbi='git rebase --interactive'
alias gl='git log'
alias glg='git log'
alias glog='git log'
alias co='git co'
alias gf='git fetch'
alias gfch='git fetch'
alias gd='git diff'
alias gb='git b'
alias gdc='git diff --cached'
alias gpub='grb publish'
alias gtr='grb track'
alias gpl='git pull'
alias gps='git push'
alias gpsh='git push'
alias gnb='git nb' # new branch aka checkout -b
# Common bash functions
alias less='less -r'
alias tf='tail -f'
alias l='less'
alias lh='ls -alt | head' # see the last modified files
alias fn="find . -name"
alias screen='TERM=screen screen'
# Zippin
alias gz='tar -zcvf'
# Ruby
alias irb='pry'
alias c='script/console --irb=pry'
alias ms='mongrel_rails start'
# Vim/ctags "mctags = make ctags"
alias mctags='/opt/local/bin/ctags -Rf ./tags *'
alias ka9='killall -9'
alias k9='kill -9'
# This trick makes sudo understand all my aliases
alias sudo='sudo '
# Gem install
alias sgi='sudo gem install --no-ri --no-rdoc'

26
bash_options Normal file
View File

@ -0,0 +1,26 @@
# vi mode, of course
set -o vi
# case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2)" scp sftp ssh
# Colors the way I like em
export LSCOLORS=BxGxFxdxCxDxDxhbadBxBx
# Larger bash history (allow 32k entries; default is 500)
export HISTSIZE=32768
export HISTFILESIZE=$HISTSIZE
export HISTCONTROL=ignoredups
# Make some commands not show up in history
export HISTIGNORE="ls:ls *"
export EVENT_NOKQUEUE=1
export COPY_EXTENDED_ATTRIBUTES_DISABLE=true
export COPYFILE_DISABLE=true
# Prompt
export PS1='\[\033[01;34m\]\u:\[\033[01;32m\]\w\[\033[00;34m\]\[\033[01;32m\]\[\033[00m\]\[\033[01;33m\]$(__git_ps1)$ \[\033[00;37m\]'

11
bash_profile Executable file
View File

@ -0,0 +1,11 @@
# Load secret stuff that I don't want to share with the world on github :)
if [ -e ~/.secrets ]; then
. ~/.secrets
fi
# Load git completion
. ~/dev/bin/git-completion.bash
# My aliases and options
. ~/dev/config/bash_aliases
. ~/dev/config/bash_options

91
gitconfig Normal file
View File

@ -0,0 +1,91 @@
[user]
name = yan
email = yan@pritzker.ws
[color]
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
; [color "status"]
; added = green
; changed = yellow
; untracked = red
[alias]
d = diff # show unstaged changes
dc = diff --cached # show staged changes
last = diff HEAD^ # show last committed change
unstage = reset HEAD # remove files from index (tracking)
uncommit = reset --soft HEAD^ # go back before last commit, with files in uncommitted state
chunkyadd = add --patch # stage commits chunk by chunk
filelog = log -u # show changes to a file
amend = commit --amend
ammend = commit --amend
mt = mergetool #fire up the merge tool
addall = !sh -c 'git add . && git add -u'
# stashselective = !f(){ git add -A; git unstage $1; git ci -m "temp"; git stash; git uncommit; }; f
# rebasing
rc = rebase --continue
rs = rebase --skip
# save some typing for common commands
ci = commit
co = checkout
b = branch -v
r = remote -v
t = tag -n
# create and switch to a new branch (mnemonic: "git new branch branchname...")
nb = checkout -b
stat = status
s = status
# stashing
ss = stash
sl = stash list
sa = stash apply
sd = stash drop
# grab a change from a branch
cp = cherry-pick -x
# move patch
# nice logs
changes = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\" --name-status
short = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\"
changelog = log --pretty=format:\" * %s\"
shortnocolor = log --pretty=format:\"%h %cr %cn %s\"
# svn helpers
svnr = svn rebase
svnd = svn dcommit
svnl = svn log --oneline --show-commit
drop = !sh -c 'git add . && git stash && git stash drop'
grab = !sh -c 'git-grab.sh'
[gc]
# auto = 1
[merge]
summary = true
verbosity = 1
[apply]
whitespace = nowarn
[branch]
autosetupmerge = true
[push]
default = matching
[github]
user = skwp
[core]
autocrlf = false
editor = /usr/bin/vim

1
inputrc Normal file
View File

@ -0,0 +1 @@
set editing-mode vi

16
irbrc Normal file
View File

@ -0,0 +1,16 @@
require 'rubygems'
require 'wirble'
# require 'hirb'
# Hirb::View.enable
# Wirble.init
# Wirble.colorize
IRB.conf[:AUTO_INDENT]=true
# require 'irb/completion'
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
IRB.conf[:PROMPT_MODE] = :SIMPLE

158
osx Executable file
View File

@ -0,0 +1,158 @@
#!/bin/bash
# Via https://raw.github.com/mathiasbynens/dotfiles/master/.osx
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Enable subpixel font rendering on non-Apple LCDs
defaults write NSGlobalDomain AppleFontSmoothing -int 2
# Enable the 2D Dock
defaults write com.apple.dock no-glass -bool true
# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true
# Make Dock icons of hidden applications translucent
defaults write com.apple.dock showhidden -bool true
# Disable menu bar transparency
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false
# Show remaining battery time; hide percentage
defaults write com.apple.menuextra.battery ShowPercent -string "NO"
defaults write com.apple.menuextra.battery ShowTime -string "YES"
# Always show scrollbars
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"
# Allow quitting Finder via ⌘ + Q; doing so will also hide desktop icons
defaults write com.apple.finder QuitMenuItem -bool true
# Show all filename extensions in Finder
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Expand save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
# Expand print panel by default
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
# Disable the “Are you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Disable shadow in screenshots
defaults write com.apple.screencapture disable-shadow -bool true
# Enable highlight hover effect for the grid view of a stack (Dock)
defaults write com.apple.dock mouse-over-hilte-stack -bool true
# Enable spring loading for all Dock items
defaults write enable-spring-load-actions-on-all-items -bool true
# Show indicator lights for open applications in the Dock
defaults write com.apple.dock show-process-indicators -bool true
# Dont animate opening applications from the Dock
defaults write com.apple.dock launchanim -bool false
# Disable press-and-hold for keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 0
# Disable auto-correct
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
# Disable window animations
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
# Enable AirDrop over Ethernet and on unsupported Macs running Lion
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
# Disable disk image verification
defaults write com.apple.frameworks.diskimages skip-verify -bool true
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
# Automatically open a new Finder window when a volume is mounted
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true
# Display full POSIX path as Finder window title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
# Increase window resize speed for Cocoa applications
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
# Avoid creating .DS_Store files on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
# Disable the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Show item info below desktop icons
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
# Disable the warning before emptying the Trash
defaults write com.apple.finder WarnOnEmptyTrash -bool false
# Empty Trash securely by default
# defaults write com.apple.finder EmptyTrashSecurely -bool false
# Require password immediately after sleep or screen saver begins
# defaults write com.apple.screensaver askForPassword -int 1
# defaults write com.apple.screensaver askForPasswordDelay -int 0
# Enable tap to click (Trackpad)
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
# Map bottom right Trackpad corner to right-click
# defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadCornerSecondaryClick -int 2
# defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -bool true
# Disable Safaris thumbnail cache for History and Top Sites
defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
# Enable Safaris debug menu
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
# Remove useless icons from Safaris bookmarks bar
# defaults write com.apple.Safari ProxiesInBookmarksBar "()"
# Only use UTF-8 in Terminal.app
defaults write com.apple.terminal StringEncodings -array 4
# Disable the Ping sidebar in iTunes
defaults write com.apple.iTunes disablePingSidebar -bool true
# Disable all the other Ping stuff in iTunes
defaults write com.apple.iTunes disablePing -bool true
# Disable send and reply animations in Mail.app
defaults write com.apple.Mail DisableReplyAnimations -bool true
defaults write com.apple.Mail DisableSendAnimations -bool true
# Disable Resume system-wide
# defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
# Enable Dashboard dev mode (allows keeping widgets on the desktop)
defaults write com.apple.dashboard devmode -bool true
# Reset Launchpad
# [ -e ~/Library/Application\ Support/Dock/*.db ] && rm ~/Library/Application\ Support/Dock/*.db
# Show the ~/Library folder
chflags nohidden ~/Library
# Disable local Time Machine backups
# hash tmutil &> /dev/null && sudo tmutil disablelocal
# Remove Dropboxs green checkmark icons in Finder.app
#file=/Applications/Dropbox.app/Contents/Resources/check.icns
#[ -e "$file" ] && mv -f "$file" "$file.bak"
#unset file
# Kill affected applications

5
vim/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
tags
*~
*.swp
.VimballRecord
view

3
vim/.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "snippets"]
path = snippets
url = git://github.com/scrooloose/snipmate-snippets.git

7
vim/.netrwhist Normal file
View File

@ -0,0 +1,7 @@
let g:netrw_dirhistmax =10
let g:netrw_dirhist_cnt =5
let g:netrw_dirhist_1='/Users/yan/dev/cft/builder-tools/get-base-iso'
let g:netrw_dirhist_2='/Users/yan/dev/piglatin'
let g:netrw_dirhist_3='/Users/yan/dev/config/vim/autoload/conque_term'
let g:netrw_dirhist_4='/Users/yan/Documents/Vuze'
let g:netrw_dirhist_5='/Users/yan/dev/config'

View File

@ -0,0 +1,24 @@
" These are the mappings for snipMate.vim. Putting it here ensures that it
" will be mapped after other plugins such as supertab.vim.
if exists('s:did_snips_mappings') || &cp || version < 700
finish
endif
let s:did_snips_mappings = 1
ino <silent> <tab> <c-r>=TriggerSnippet()<cr>
snor <silent> <tab> <esc>i<right><c-r>=TriggerSnippet()<cr>
ino <silent> <c-r><tab> <c-r>=ShowAvailableSnips()<cr>
snor <bs> b<bs>
snor ' b<bs>'
snor <right> <esc>a
snor <left> <esc>bi
" By default load snippets in snippets_dir
if !exists("snippets_dir")
finish
endif
call GetSnippets(snippets_dir, '_') " Get global snippets
au FileType * if &ft != 'help' | call GetSnippets(snippets_dir, &ft) | endif
" vim:noet:sw=4:ts=4:ft=vim

848
vim/autoload/AnsiEsc.vim Normal file
View File

@ -0,0 +1,848 @@
" AnsiEsc.vim: Uses syntax highlighting. A vim 7.0 plugin!
" Language: Text with ansi escape sequences
" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz>
" Version: 12
" Date: Dec 13, 2010
"
" Usage: :AnsiEsc
"
" Note: this plugin requires Vince Negri's conceal-ownsyntax patch
" See http://groups.google.com/group/vim_dev/web/vim-patches, Patch#14
"
" GetLatestVimScripts: 302 1 :AutoInstall: AnsiEsc.vim
"redraw!|call DechoSep()|call inputsave()|call input("Press <cr> to continue")|call inputrestore()
" ---------------------------------------------------------------------
"DechoTabOn
" Load Once: {{{1
if exists("g:loaded_AnsiEsc")
finish
endif
let g:loaded_AnsiEsc = "v12"
if v:version < 700
echohl WarningMsg
echo "***warning*** this version of AnsiEsc needs vim 7.0"
echohl Normal
finish
endif
let s:keepcpo= &cpo
set cpo&vim
" ---------------------------------------------------------------------
" AnsiEsc#AnsiEsc: toggles ansi-escape code visualization {{{2
fun! AnsiEsc#AnsiEsc(rebuild)
" call Dfunc("AnsiEsc#AnsiEsc(rebuild=".a:rebuild.")")
if a:rebuild
" call Decho("rebuilding AnsiEsc tables")
call AnsiEsc#AnsiEsc(0)
call AnsiEsc#AnsiEsc(0)
" call Dret("AnsiEsc#AnsiEsc")
return
endif
let bn= bufnr("%")
if !exists("s:AnsiEsc_enabled_{bn}")
let s:AnsiEsc_enabled_{bn}= 0
endif
if s:AnsiEsc_enabled_{bn}
" disable AnsiEsc highlighting
" call Decho("disable AnsiEsc highlighting: s:AnsiEsc_ft_".bn."<".s:AnsiEsc_ft_{bn}."> bn#".bn)
if exists("g:colors_name")|let colorname= g:colors_name|endif
if exists("s:conckeep_{bufnr('%')}")|let &l:conc= s:conckeep_{bufnr('%')}|unlet s:conckeep_{bufnr('%')}|endif
if exists("s:colekeep_{bufnr('%')}")|let &l:cole= s:colekeep_{bufnr('%')}|unlet s:colekeep_{bufnr('%')}|endif
if exists("s:cocukeep_{bufnr('%')}")|let &l:cocu= s:cocukeep_{bufnr('%')}|unlet s:cocukeep_{bufnr('%')}|endif
hi! link ansiStop NONE
syn clear
hi clear
syn reset
exe "set ft=".s:AnsiEsc_ft_{bn}
if exists("colorname")|exe "colors ".colorname|endif
let s:AnsiEsc_enabled_{bn}= 0
if has("gui_running") && has("menu") && &go =~ 'm'
" menu support
exe 'silent! unmenu '.g:DrChipTopLvlMenu.'AnsiEsc'
exe 'menu '.g:DrChipTopLvlMenu.'AnsiEsc.Start<tab>:AnsiEsc :AnsiEsc<cr>'
endif
let &l:hl= s:hlkeep_{bufnr("%")}
" call Dret("AnsiEsc#AnsiEsc")
return
else
let s:AnsiEsc_ft_{bn} = &ft
let s:AnsiEsc_enabled_{bn} = 1
" call Decho("enable AnsiEsc highlighting: s:AnsiEsc_ft_".bn."<".s:AnsiEsc_ft_{bn}."> bn#".bn)
if has("gui_running") && has("menu") && &go =~ 'm'
" menu support
exe 'silent! unmenu '.g:DrChipTopLvlMenu.'AnsiEsc'
exe 'menu '.g:DrChipTopLvlMenu.'AnsiEsc.Stop<tab>:AnsiEsc :AnsiEsc<cr>'
endif
" -----------------
" Conceal Support: {{{2
" -----------------
if has("conceal")
if v:version < 703
if &l:conc != 3
let s:conckeep_{bufnr('%')}= &cole
setlocal conc=3
" call Decho("l:conc=".&l:conc)
endif
else
if &l:cole != 3 || &l:cocu != "nv"
let s:colekeep_{bufnr('%')}= &l:cole
let s:cocukeep_{bufnr('%')}= &l:cocu
setlocal cole=3 cocu=nv
" call Decho("l:cole=".&l:cole." l:cocu=".&l:cocu)
endif
endif
endif
endif
syn clear
" suppress escaped sequences that don't involve colors (which may or may not be ansi-compliant)
if has("conceal")
syn match ansiSuppress conceal '\e\[[0-9;]*[^m]'
syn match ansiSuppress conceal '\e\[?\d*[^m]'
syn match ansiSuppress conceal '\b'
else
syn match ansiSuppress '\e\[[0-9;]*[^m]'
syn match ansiSuppress conceal '\e\[?\d*[^m]'
syn match ansiSuppress '\b'
endif
" ------------------------------
" Ansi Escape Sequence Handling: {{{2
" ------------------------------
syn region ansiNone start="\e\[[01;]m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiNone start="\e\[m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlack start="\e\[;\=0\{0,2};\=30m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRed start="\e\[;\=0\{0,2};\=31m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiGreen start="\e\[;\=0\{0,2};\=32m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiYellow start="\e\[;\=0\{0,2};\=33m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlue start="\e\[;\=0\{0,2};\=34m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiMagenta start="\e\[;\=0\{0,2};\=35m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiCyan start="\e\[;\=0\{0,2};\=36m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiWhite start="\e\[;\=0\{0,2};\=37m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlackBg start="\e\[;\=0\{0,2};\=\%(1;\)\=40\%(1;\)\=m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRedBg start="\e\[;\=0\{0,2};\=\%(1;\)\=41\%(1;\)\=m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiGreenBg start="\e\[;\=0\{0,2};\=\%(1;\)\=42\%(1;\)\=m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiYellowBg start="\e\[;\=0\{0,2};\=\%(1;\)\=43\%(1;\)\=m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlueBg start="\e\[;\=0\{0,2};\=\%(1;\)\=44\%(1;\)\=m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiMagentaBg start="\e\[;\=0\{0,2};\=\%(1;\)\=45\%(1;\)\=m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiCyanBg start="\e\[;\=0\{0,2};\=\%(1;\)\=46\%(1;\)\=m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiWhiteBg start="\e\[;\=0\{0,2};\=\%(1;\)\=47\%(1;\)\=m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBoldBlack start="\e\[;\=0\{0,2};\=\%(1;30\|30;1\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBoldRed start="\e\[;\=0\{0,2};\=\%(1;31\|31;1\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBoldGreen start="\e\[;\=0\{0,2};\=\%(1;32\|32;1\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBoldYellow start="\e\[;\=0\{0,2};\=\%(1;33\|33;1\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBoldBlue start="\e\[;\=0\{0,2};\=\%(1;34\|34;1\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBoldMagenta start="\e\[;\=0\{0,2};\=\%(1;35\|35;1\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBoldCyan start="\e\[;\=0\{0,2};\=\%(1;36\|36;1\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBoldWhite start="\e\[;\=0\{0,2};\=\%(1;37\|37;1\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiStandoutBlack start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(3;30\|30;3\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiStandoutRed start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(3;31\|31;3\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiStandoutGreen start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(3;32\|32;3\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiStandoutYellow start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(3;33\|33;3\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiStandoutBlue start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(3;34\|34;3\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiStandoutMagenta start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(3;35\|35;3\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiStandoutCyan start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(3;36\|36;3\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiStandoutWhite start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(3;37\|37;3\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiItalicBlack start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(2;30\|30;2\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiItalicRed start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(2;31\|31;2\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiItalicGreen start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(2;32\|32;2\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiItalicYellow start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(2;33\|33;2\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiItalicBlue start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(2;34\|34;2\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiItalicMagenta start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(2;35\|35;2\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiItalicCyan start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(2;36\|36;2\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiItalicWhite start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(2;37\|37;2\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiUnderlineBlack start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(4;30\|30;4\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiUnderlineRed start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(4;31\|31;4\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiUnderlineGreen start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(4;32\|32;4\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiUnderlineYellow start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(4;33\|33;4\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiUnderlineBlue start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(4;34\|34;4\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiUnderlineMagenta start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(4;35\|35;4\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiUnderlineCyan start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(4;36\|36;4\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiUnderlineWhite start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(4;37\|37;4\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlinkBlack start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(5;30\|30;5\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlinkRed start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(5;31\|31;5\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlinkGreen start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(5;32\|32;5\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlinkYellow start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(5;33\|33;5\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlinkBlue start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(5;34\|34;5\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlinkMagenta start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(5;35\|35;5\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlinkCyan start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(5;36\|36;5\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlinkWhite start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(5;37\|37;5\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRapidBlinkBlack start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(6;30\|30;6\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRapidBlinkRed start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(6;31\|31;6\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRapidBlinkGreen start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(6;32\|32;6\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRapidBlinkYellow start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(6;33\|33;6\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRapidBlinkBlue start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(6;34\|34;6\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRapidBlinkMagenta start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(6;35\|35;6\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRapidBlinkCyan start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(6;36\|36;6\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRapidBlinkWhite start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(6;37\|37;6\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRVBlack start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(7;30\|30;7\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRVRed start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(7;31\|31;7\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRVGreen start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(7;32\|32;7\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRVYellow start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(7;33\|33;7\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRVBlue start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(7;34\|34;7\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRVMagenta start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(7;35\|35;7\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRVCyan start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(7;36\|36;7\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRVWhite start="\e\[;\=0\{0,2};\=\%(1;\)\=\%(7;37\|37;7\)m" end="\e\["me=e-2 contains=ansiConceal
if has("conceal")
syn match ansiStop conceal "\e\[;\=0\{1,2}m"
syn match ansiStop conceal "\e\[K"
syn match ansiStop conceal "\e\[H"
syn match ansiStop conceal "\e\[2J"
else
syn match ansiStop "\e\[;\=0\{0,2}m"
syn match ansiStop "\e\[K"
syn match ansiStop "\e\[H"
syn match ansiStop "\e\[2J"
endif
"syn match ansiIgnore conceal "\e\[\([56];3[0-9]\|3[0-9];[56]\)m"
"syn match ansiIgnore conceal "\e\[\([0-9]\+;\)\{2,}[0-9]\+m"
" ---------------------------------------------------------------------
" Some Color Combinations: - can't do 'em all, the qty of highlighting groups is limited! {{{2
" ---------------------------------------------------------------------
syn region ansiBlackBlack start="\e\[0\{0,2};\=\(30;40\|40;30\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRedBlack start="\e\[0\{0,2};\=\(31;40\|40;31\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiGreenBlack start="\e\[0\{0,2};\=\(32;40\|40;32\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiYellowBlack start="\e\[0\{0,2};\=\(33;40\|40;33\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlueBlack start="\e\[0\{0,2};\=\(34;40\|40;34\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiMagentaBlack start="\e\[0\{0,2};\=\(35;40\|40;35\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiCyanBlack start="\e\[0\{0,2};\=\(36;40\|40;36\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiWhiteBlack start="\e\[0\{0,2};\=\(37;40\|40;37\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlackRed start="\e\[0\{0,2};\=\(30;41\|41;30\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRedRed start="\e\[0\{0,2};\=\(31;41\|41;31\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiGreenRed start="\e\[0\{0,2};\=\(32;41\|41;32\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiYellowRed start="\e\[0\{0,2};\=\(33;41\|41;33\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlueRed start="\e\[0\{0,2};\=\(34;41\|41;34\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiMagentaRed start="\e\[0\{0,2};\=\(35;41\|41;35\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiCyanRed start="\e\[0\{0,2};\=\(36;41\|41;36\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiWhiteRed start="\e\[0\{0,2};\=\(37;41\|41;37\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlackGreen start="\e\[0\{0,2};\=\(30;42\|42;30\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRedGreen start="\e\[0\{0,2};\=\(31;42\|42;31\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiGreenGreen start="\e\[0\{0,2};\=\(32;42\|42;32\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiYellowGreen start="\e\[0\{0,2};\=\(33;42\|42;33\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlueGreen start="\e\[0\{0,2};\=\(34;42\|42;34\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiMagentaGreen start="\e\[0\{0,2};\=\(35;42\|42;35\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiCyanGreen start="\e\[0\{0,2};\=\(36;42\|42;36\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiWhiteGreen start="\e\[0\{0,2};\=\(37;42\|42;37\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlackYellow start="\e\[0\{0,2};\=\(30;43\|43;30\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRedYellow start="\e\[0\{0,2};\=\(31;43\|43;31\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiGreenYellow start="\e\[0\{0,2};\=\(32;43\|43;32\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiYellowYellow start="\e\[0\{0,2};\=\(33;43\|43;33\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlueYellow start="\e\[0\{0,2};\=\(34;43\|43;34\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiMagentaYellow start="\e\[0\{0,2};\=\(35;43\|43;35\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiCyanYellow start="\e\[0\{0,2};\=\(36;43\|43;36\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiWhiteYellow start="\e\[0\{0,2};\=\(37;43\|43;37\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlackBlue start="\e\[0\{0,2};\=\(30;44\|44;30\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRedBlue start="\e\[0\{0,2};\=\(31;44\|44;31\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiGreenBlue start="\e\[0\{0,2};\=\(32;44\|44;32\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiYellowBlue start="\e\[0\{0,2};\=\(33;44\|44;33\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlueBlue start="\e\[0\{0,2};\=\(34;44\|44;34\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiMagentaBlue start="\e\[0\{0,2};\=\(35;44\|44;35\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiCyanBlue start="\e\[0\{0,2};\=\(36;44\|44;36\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiWhiteBlue start="\e\[0\{0,2};\=\(37;44\|44;37\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlackMagenta start="\e\[0\{0,2};\=\(30;45\|45;30\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRedMagenta start="\e\[0\{0,2};\=\(31;45\|45;31\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiGreenMagenta start="\e\[0\{0,2};\=\(32;45\|45;32\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiYellowMagenta start="\e\[0\{0,2};\=\(33;45\|45;33\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlueMagenta start="\e\[0\{0,2};\=\(34;45\|45;34\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiMagentaMagenta start="\e\[0\{0,2};\=\(35;45\|45;35\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiCyanMagenta start="\e\[0\{0,2};\=\(36;45\|45;36\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiWhiteMagenta start="\e\[0\{0,2};\=\(37;45\|45;37\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlackCyan start="\e\[0\{0,2};\=\(30;46\|46;30\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRedCyan start="\e\[0\{0,2};\=\(31;46\|46;31\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiGreenCyan start="\e\[0\{0,2};\=\(32;46\|46;32\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiYellowCyan start="\e\[0\{0,2};\=\(33;46\|46;33\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlueCyan start="\e\[0\{0,2};\=\(34;46\|46;34\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiMagentaCyan start="\e\[0\{0,2};\=\(35;46\|46;35\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiCyanCyan start="\e\[0\{0,2};\=\(36;46\|46;36\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiWhiteCyan start="\e\[0\{0,2};\=\(37;46\|46;37\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlackWhite start="\e\[0\{0,2};\=\(30;47\|47;30\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiRedWhite start="\e\[0\{0,2};\=\(31;47\|47;31\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiGreenWhite start="\e\[0\{0,2};\=\(32;47\|47;32\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiYellowWhite start="\e\[0\{0,2};\=\(33;47\|47;33\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiBlueWhite start="\e\[0\{0,2};\=\(34;47\|47;34\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiMagentaWhite start="\e\[0\{0,2};\=\(35;47\|47;35\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiCyanWhite start="\e\[0\{0,2};\=\(36;47\|47;36\)m" end="\e\["me=e-2 contains=ansiConceal
syn region ansiWhiteWhite start="\e\[0\{0,2};\=\(37;47\|47;37\)m" end="\e\["me=e-2 contains=ansiConceal
syn match ansiExtended "\e\[;\=\(0;\)\=[34]8;\(\d*;\)*\d*m" contains=ansiConceal
if has("conceal")
syn match ansiConceal contained conceal "\e\[\(\d*;\)*\d*m"
else
syn match ansiConceal contained "\e\[\(\d*;\)*\d*m"
endif
" -------------
" Highlighting: {{{2
" -------------
if !has("conceal")
" --------------
" ansiesc_ignore: {{{3
" --------------
hi def link ansiConceal Ignore
hi def link ansiSuppress Ignore
hi def link ansiIgnore ansiStop
hi def link ansiStop Ignore
hi def link ansiExtended Ignore
endif
let s:hlkeep_{bufnr("%")}= &l:hl
exe "setlocal hl=".substitute(&hl,'8:[^,]\{-},','8:Ignore,',"")
" handle 3 or more element ansi escape sequences by building syntax and highlighting rules
" specific to the current file
call s:MultiElementHandler()
hi ansiNone cterm=NONE gui=NONE
if &t_Co == 8 || &t_Co == 256
" ---------------------
" eight-color handling: {{{3
" ---------------------
" call Decho("set up 8-color highlighting groups")
hi ansiBlack ctermfg=black guifg=black cterm=none gui=none
hi ansiRed ctermfg=red guifg=red cterm=none gui=none
hi ansiGreen ctermfg=green guifg=green cterm=none gui=none
hi ansiYellow ctermfg=yellow guifg=yellow cterm=none gui=none
hi ansiBlue ctermfg=blue guifg=blue cterm=none gui=none
hi ansiMagenta ctermfg=magenta guifg=magenta cterm=none gui=none
hi ansiCyan ctermfg=cyan guifg=cyan cterm=none gui=none
hi ansiWhite ctermfg=white guifg=white cterm=none gui=none
hi ansiBlackBg ctermbg=black guibg=black cterm=none gui=none
hi ansiRedBg ctermbg=red guibg=red cterm=none gui=none
hi ansiGreenBg ctermbg=green guibg=green cterm=none gui=none
hi ansiYellowBg ctermbg=yellow guibg=yellow cterm=none gui=none
hi ansiBlueBg ctermbg=blue guibg=blue cterm=none gui=none
hi ansiMagentaBg ctermbg=magenta guibg=magenta cterm=none gui=none
hi ansiCyanBg ctermbg=cyan guibg=cyan cterm=none gui=none
hi ansiWhiteBg ctermbg=white guibg=white cterm=none gui=none
hi ansiBoldBlack ctermfg=black guifg=black cterm=bold gui=bold
hi ansiBoldRed ctermfg=red guifg=red cterm=bold gui=bold
hi ansiBoldGreen ctermfg=green guifg=green cterm=bold gui=bold
hi ansiBoldYellow ctermfg=yellow guifg=yellow cterm=bold gui=bold
hi ansiBoldBlue ctermfg=blue guifg=blue cterm=bold gui=bold
hi ansiBoldMagenta ctermfg=magenta guifg=magenta cterm=bold gui=bold
hi ansiBoldCyan ctermfg=cyan guifg=cyan cterm=bold gui=bold
hi ansiBoldWhite ctermfg=white guifg=white cterm=bold gui=bold
hi ansiStandoutBlack ctermfg=black guifg=black cterm=standout gui=standout
hi ansiStandoutRed ctermfg=red guifg=red cterm=standout gui=standout
hi ansiStandoutGreen ctermfg=green guifg=green cterm=standout gui=standout
hi ansiStandoutYellow ctermfg=yellow guifg=yellow cterm=standout gui=standout
hi ansiStandoutBlue ctermfg=blue guifg=blue cterm=standout gui=standout
hi ansiStandoutMagenta ctermfg=magenta guifg=magenta cterm=standout gui=standout
hi ansiStandoutCyan ctermfg=cyan guifg=cyan cterm=standout gui=standout
hi ansiStandoutWhite ctermfg=white guifg=white cterm=standout gui=standout
hi ansiItalicBlack ctermfg=black guifg=black cterm=italic gui=italic
hi ansiItalicRed ctermfg=red guifg=red cterm=italic gui=italic
hi ansiItalicGreen ctermfg=green guifg=green cterm=italic gui=italic
hi ansiItalicYellow ctermfg=yellow guifg=yellow cterm=italic gui=italic
hi ansiItalicBlue ctermfg=blue guifg=blue cterm=italic gui=italic
hi ansiItalicMagenta ctermfg=magenta guifg=magenta cterm=italic gui=italic
hi ansiItalicCyan ctermfg=cyan guifg=cyan cterm=italic gui=italic
hi ansiItalicWhite ctermfg=white guifg=white cterm=italic gui=italic
hi ansiUnderlineBlack ctermfg=black guifg=black cterm=underline gui=underline
hi ansiUnderlineRed ctermfg=red guifg=red cterm=underline gui=underline
hi ansiUnderlineGreen ctermfg=green guifg=green cterm=underline gui=underline
hi ansiUnderlineYellow ctermfg=yellow guifg=yellow cterm=underline gui=underline
hi ansiUnderlineBlue ctermfg=blue guifg=blue cterm=underline gui=underline
hi ansiUnderlineMagenta ctermfg=magenta guifg=magenta cterm=underline gui=underline
hi ansiUnderlineCyan ctermfg=cyan guifg=cyan cterm=underline gui=underline
hi ansiUnderlineWhite ctermfg=white guifg=white cterm=underline gui=underline
hi ansiBlinkBlack ctermfg=black guifg=black cterm=standout gui=undercurl
hi ansiBlinkRed ctermfg=red guifg=red cterm=standout gui=undercurl
hi ansiBlinkGreen ctermfg=green guifg=green cterm=standout gui=undercurl
hi ansiBlinkYellow ctermfg=yellow guifg=yellow cterm=standout gui=undercurl
hi ansiBlinkBlue ctermfg=blue guifg=blue cterm=standout gui=undercurl
hi ansiBlinkMagenta ctermfg=magenta guifg=magenta cterm=standout gui=undercurl
hi ansiBlinkCyan ctermfg=cyan guifg=cyan cterm=standout gui=undercurl
hi ansiBlinkWhite ctermfg=white guifg=white cterm=standout gui=undercurl
hi ansiRapidBlinkBlack ctermfg=black guifg=black cterm=standout gui=undercurl
hi ansiRapidBlinkRed ctermfg=red guifg=red cterm=standout gui=undercurl
hi ansiRapidBlinkGreen ctermfg=green guifg=green cterm=standout gui=undercurl
hi ansiRapidBlinkYellow ctermfg=yellow guifg=yellow cterm=standout gui=undercurl
hi ansiRapidBlinkBlue ctermfg=blue guifg=blue cterm=standout gui=undercurl
hi ansiRapidBlinkMagenta ctermfg=magenta guifg=magenta cterm=standout gui=undercurl
hi ansiRapidBlinkCyan ctermfg=cyan guifg=cyan cterm=standout gui=undercurl
hi ansiRapidBlinkWhite ctermfg=white guifg=white cterm=standout gui=undercurl
hi ansiRVBlack ctermfg=black guifg=black cterm=reverse gui=reverse
hi ansiRVRed ctermfg=red guifg=red cterm=reverse gui=reverse
hi ansiRVGreen ctermfg=green guifg=green cterm=reverse gui=reverse
hi ansiRVYellow ctermfg=yellow guifg=yellow cterm=reverse gui=reverse
hi ansiRVBlue ctermfg=blue guifg=blue cterm=reverse gui=reverse
hi ansiRVMagenta ctermfg=magenta guifg=magenta cterm=reverse gui=reverse
hi ansiRVCyan ctermfg=cyan guifg=cyan cterm=reverse gui=reverse
hi ansiRVWhite ctermfg=white guifg=white cterm=reverse gui=reverse
hi ansiBlackBlack ctermfg=black ctermbg=black guifg=Black guibg=Black cterm=none gui=none
hi ansiRedBlack ctermfg=red ctermbg=black guifg=Red guibg=Black cterm=none gui=none
hi ansiGreenBlack ctermfg=green ctermbg=black guifg=Green guibg=Black cterm=none gui=none
hi ansiYellowBlack ctermfg=yellow ctermbg=black guifg=Yellow guibg=Black cterm=none gui=none
hi ansiBlueBlack ctermfg=blue ctermbg=black guifg=Blue guibg=Black cterm=none gui=none
hi ansiMagentaBlack ctermfg=magenta ctermbg=black guifg=Magenta guibg=Black cterm=none gui=none
hi ansiCyanBlack ctermfg=cyan ctermbg=black guifg=Cyan guibg=Black cterm=none gui=none
hi ansiWhiteBlack ctermfg=white ctermbg=black guifg=White guibg=Black cterm=none gui=none
hi ansiBlackRed ctermfg=black ctermbg=red guifg=Black guibg=Red cterm=none gui=none
hi ansiRedRed ctermfg=red ctermbg=red guifg=Red guibg=Red cterm=none gui=none
hi ansiGreenRed ctermfg=green ctermbg=red guifg=Green guibg=Red cterm=none gui=none
hi ansiYellowRed ctermfg=yellow ctermbg=red guifg=Yellow guibg=Red cterm=none gui=none
hi ansiBlueRed ctermfg=blue ctermbg=red guifg=Blue guibg=Red cterm=none gui=none
hi ansiMagentaRed ctermfg=magenta ctermbg=red guifg=Magenta guibg=Red cterm=none gui=none
hi ansiCyanRed ctermfg=cyan ctermbg=red guifg=Cyan guibg=Red cterm=none gui=none
hi ansiWhiteRed ctermfg=white ctermbg=red guifg=White guibg=Red cterm=none gui=none
hi ansiBlackGreen ctermfg=black ctermbg=green guifg=Black guibg=Green cterm=none gui=none
hi ansiRedGreen ctermfg=red ctermbg=green guifg=Red guibg=Green cterm=none gui=none
hi ansiGreenGreen ctermfg=green ctermbg=green guifg=Green guibg=Green cterm=none gui=none
hi ansiYellowGreen ctermfg=yellow ctermbg=green guifg=Yellow guibg=Green cterm=none gui=none
hi ansiBlueGreen ctermfg=blue ctermbg=green guifg=Blue guibg=Green cterm=none gui=none
hi ansiMagentaGreen ctermfg=magenta ctermbg=green guifg=Magenta guibg=Green cterm=none gui=none
hi ansiCyanGreen ctermfg=cyan ctermbg=green guifg=Cyan guibg=Green cterm=none gui=none
hi ansiWhiteGreen ctermfg=white ctermbg=green guifg=White guibg=Green cterm=none gui=none
hi ansiBlackYellow ctermfg=black ctermbg=yellow guifg=Black guibg=Yellow cterm=none gui=none
hi ansiRedYellow ctermfg=red ctermbg=yellow guifg=Red guibg=Yellow cterm=none gui=none
hi ansiGreenYellow ctermfg=green ctermbg=yellow guifg=Green guibg=Yellow cterm=none gui=none
hi ansiYellowYellow ctermfg=yellow ctermbg=yellow guifg=Yellow guibg=Yellow cterm=none gui=none
hi ansiBlueYellow ctermfg=blue ctermbg=yellow guifg=Blue guibg=Yellow cterm=none gui=none
hi ansiMagentaYellow ctermfg=magenta ctermbg=yellow guifg=Magenta guibg=Yellow cterm=none gui=none
hi ansiCyanYellow ctermfg=cyan ctermbg=yellow guifg=Cyan guibg=Yellow cterm=none gui=none
hi ansiWhiteYellow ctermfg=white ctermbg=yellow guifg=White guibg=Yellow cterm=none gui=none
hi ansiBlackBlue ctermfg=black ctermbg=blue guifg=Black guibg=Blue cterm=none gui=none
hi ansiRedBlue ctermfg=red ctermbg=blue guifg=Red guibg=Blue cterm=none gui=none
hi ansiGreenBlue ctermfg=green ctermbg=blue guifg=Green guibg=Blue cterm=none gui=none
hi ansiYellowBlue ctermfg=yellow ctermbg=blue guifg=Yellow guibg=Blue cterm=none gui=none
hi ansiBlueBlue ctermfg=blue ctermbg=blue guifg=Blue guibg=Blue cterm=none gui=none
hi ansiMagentaBlue ctermfg=magenta ctermbg=blue guifg=Magenta guibg=Blue cterm=none gui=none
hi ansiCyanBlue ctermfg=cyan ctermbg=blue guifg=Cyan guibg=Blue cterm=none gui=none
hi ansiWhiteBlue ctermfg=white ctermbg=blue guifg=White guibg=Blue cterm=none gui=none
hi ansiBlackMagenta ctermfg=black ctermbg=magenta guifg=Black guibg=Magenta cterm=none gui=none
hi ansiRedMagenta ctermfg=red ctermbg=magenta guifg=Red guibg=Magenta cterm=none gui=none
hi ansiGreenMagenta ctermfg=green ctermbg=magenta guifg=Green guibg=Magenta cterm=none gui=none
hi ansiYellowMagenta ctermfg=yellow ctermbg=magenta guifg=Yellow guibg=Magenta cterm=none gui=none
hi ansiBlueMagenta ctermfg=blue ctermbg=magenta guifg=Blue guibg=Magenta cterm=none gui=none
hi ansiMagentaMagenta ctermfg=magenta ctermbg=magenta guifg=Magenta guibg=Magenta cterm=none gui=none
hi ansiCyanMagenta ctermfg=cyan ctermbg=magenta guifg=Cyan guibg=Magenta cterm=none gui=none
hi ansiWhiteMagenta ctermfg=white ctermbg=magenta guifg=White guibg=Magenta cterm=none gui=none
hi ansiBlackCyan ctermfg=black ctermbg=cyan guifg=Black guibg=Cyan cterm=none gui=none
hi ansiRedCyan ctermfg=red ctermbg=cyan guifg=Red guibg=Cyan cterm=none gui=none
hi ansiGreenCyan ctermfg=green ctermbg=cyan guifg=Green guibg=Cyan cterm=none gui=none
hi ansiYellowCyan ctermfg=yellow ctermbg=cyan guifg=Yellow guibg=Cyan cterm=none gui=none
hi ansiBlueCyan ctermfg=blue ctermbg=cyan guifg=Blue guibg=Cyan cterm=none gui=none
hi ansiMagentaCyan ctermfg=magenta ctermbg=cyan guifg=Magenta guibg=Cyan cterm=none gui=none
hi ansiCyanCyan ctermfg=cyan ctermbg=cyan guifg=Cyan guibg=Cyan cterm=none gui=none
hi ansiWhiteCyan ctermfg=white ctermbg=cyan guifg=White guibg=Cyan cterm=none gui=none
hi ansiBlackWhite ctermfg=black ctermbg=white guifg=Black guibg=White cterm=none gui=none
hi ansiRedWhite ctermfg=red ctermbg=white guifg=Red guibg=White cterm=none gui=none
hi ansiGreenWhite ctermfg=green ctermbg=white guifg=Green guibg=White cterm=none gui=none
hi ansiYellowWhite ctermfg=yellow ctermbg=white guifg=Yellow guibg=White cterm=none gui=none
hi ansiBlueWhite ctermfg=blue ctermbg=white guifg=Blue guibg=White cterm=none gui=none
hi ansiMagentaWhite ctermfg=magenta ctermbg=white guifg=Magenta guibg=White cterm=none gui=none
hi ansiCyanWhite ctermfg=cyan ctermbg=white guifg=Cyan guibg=White cterm=none gui=none
hi ansiWhiteWhite ctermfg=white ctermbg=white guifg=White guibg=White cterm=none gui=none
if v:version >= 700 && exists("&t_Co") && &t_Co == 256 && exists("g:ansiesc_256color")
" ---------------------------
" handle 256-color terminals: {{{3
" ---------------------------
" call Decho("set up 256-color highlighting groups")
let icolor= 1
while icolor < 256
let jcolor= 1
exe "hi ansiHL_".icolor."_0 ctermfg=".icolor
exe "hi ansiHL_0_".icolor." ctermbg=".icolor
" call Decho("exe hi ansiHL_".icolor." ctermfg=".icolor)
while jcolor < 256
exe "hi ansiHL_".icolor."_".jcolor." ctermfg=".icolor." ctermbg=".jcolor
" call Decho("exe hi ansiHL_".icolor."_".jcolor." ctermfg=".icolor." ctermbg=".jcolor)
let jcolor= jcolor + 1
endwhile
let icolor= icolor + 1
endwhile
endif
else
" ----------------------------------
" not 8 or 256 color terminals (gui): {{{3
" ----------------------------------
" call Decho("set up gui highlighting groups")
hi ansiBlack ctermfg=black guifg=black cterm=none gui=none
hi ansiRed ctermfg=red guifg=red cterm=none gui=none
hi ansiGreen ctermfg=green guifg=green cterm=none gui=none
hi ansiYellow ctermfg=yellow guifg=yellow cterm=none gui=none
hi ansiBlue ctermfg=blue guifg=blue cterm=none gui=none
hi ansiMagenta ctermfg=magenta guifg=magenta cterm=none gui=none
hi ansiCyan ctermfg=cyan guifg=cyan cterm=none gui=none
hi ansiWhite ctermfg=white guifg=white cterm=none gui=none
hi ansiBlackBg ctermbg=black guibg=black cterm=none gui=none
hi ansiRedBg ctermbg=red guibg=red cterm=none gui=none
hi ansiGreenBg ctermbg=green guibg=green cterm=none gui=none
hi ansiYellowBg ctermbg=yellow guibg=yellow cterm=none gui=none
hi ansiBlueBg ctermbg=blue guibg=blue cterm=none gui=none
hi ansiMagentaBg ctermbg=magenta guibg=magenta cterm=none gui=none
hi ansiCyanBg ctermbg=cyan guibg=cyan cterm=none gui=none
hi ansiWhiteBg ctermbg=white guibg=white cterm=none gui=none
hi ansiBoldBlack ctermfg=black guifg=black cterm=bold gui=bold
hi ansiBoldRed ctermfg=red guifg=red cterm=bold gui=bold
hi ansiBoldGreen ctermfg=green guifg=green cterm=bold gui=bold
hi ansiBoldYellow ctermfg=yellow guifg=yellow cterm=bold gui=bold
hi ansiBoldBlue ctermfg=blue guifg=blue cterm=bold gui=bold
hi ansiBoldMagenta ctermfg=magenta guifg=magenta cterm=bold gui=bold
hi ansiBoldCyan ctermfg=cyan guifg=cyan cterm=bold gui=bold
hi ansiBoldWhite ctermfg=white guifg=white cterm=bold gui=bold
hi ansiStandoutBlack ctermfg=black guifg=black cterm=standout gui=standout
hi ansiStandoutRed ctermfg=red guifg=red cterm=standout gui=standout
hi ansiStandoutGreen ctermfg=green guifg=green cterm=standout gui=standout
hi ansiStandoutYellow ctermfg=yellow guifg=yellow cterm=standout gui=standout
hi ansiStandoutBlue ctermfg=blue guifg=blue cterm=standout gui=standout
hi ansiStandoutMagenta ctermfg=magenta guifg=magenta cterm=standout gui=standout
hi ansiStandoutCyan ctermfg=cyan guifg=cyan cterm=standout gui=standout
hi ansiStandoutWhite ctermfg=white guifg=white cterm=standout gui=standout
hi ansiItalicBlack ctermfg=black guifg=black cterm=italic gui=italic
hi ansiItalicRed ctermfg=red guifg=red cterm=italic gui=italic
hi ansiItalicGreen ctermfg=green guifg=green cterm=italic gui=italic
hi ansiItalicYellow ctermfg=yellow guifg=yellow cterm=italic gui=italic
hi ansiItalicBlue ctermfg=blue guifg=blue cterm=italic gui=italic
hi ansiItalicMagenta ctermfg=magenta guifg=magenta cterm=italic gui=italic
hi ansiItalicCyan ctermfg=cyan guifg=cyan cterm=italic gui=italic
hi ansiItalicWhite ctermfg=white guifg=white cterm=italic gui=italic
hi ansiUnderlineBlack ctermfg=black guifg=black cterm=underline gui=underline
hi ansiUnderlineRed ctermfg=red guifg=red cterm=underline gui=underline
hi ansiUnderlineGreen ctermfg=green guifg=green cterm=underline gui=underline
hi ansiUnderlineYellow ctermfg=yellow guifg=yellow cterm=underline gui=underline
hi ansiUnderlineBlue ctermfg=blue guifg=blue cterm=underline gui=underline
hi ansiUnderlineMagenta ctermfg=magenta guifg=magenta cterm=underline gui=underline
hi ansiUnderlineCyan ctermfg=cyan guifg=cyan cterm=underline gui=underline
hi ansiUnderlineWhite ctermfg=white guifg=white cterm=underline gui=underline
hi ansiBlinkBlack ctermfg=black guifg=black cterm=standout gui=undercurl
hi ansiBlinkRed ctermfg=red guifg=red cterm=standout gui=undercurl
hi ansiBlinkGreen ctermfg=green guifg=green cterm=standout gui=undercurl
hi ansiBlinkYellow ctermfg=yellow guifg=yellow cterm=standout gui=undercurl
hi ansiBlinkBlue ctermfg=blue guifg=blue cterm=standout gui=undercurl
hi ansiBlinkMagenta ctermfg=magenta guifg=magenta cterm=standout gui=undercurl
hi ansiBlinkCyan ctermfg=cyan guifg=cyan cterm=standout gui=undercurl
hi ansiBlinkWhite ctermfg=white guifg=white cterm=standout gui=undercurl
hi ansiRapidBlinkBlack ctermfg=black guifg=black cterm=standout gui=undercurl
hi ansiRapidBlinkRed ctermfg=red guifg=red cterm=standout gui=undercurl
hi ansiRapidBlinkGreen ctermfg=green guifg=green cterm=standout gui=undercurl
hi ansiRapidBlinkYellow ctermfg=yellow guifg=yellow cterm=standout gui=undercurl
hi ansiRapidBlinkBlue ctermfg=blue guifg=blue cterm=standout gui=undercurl
hi ansiRapidBlinkMagenta ctermfg=magenta guifg=magenta cterm=standout gui=undercurl
hi ansiRapidBlinkCyan ctermfg=cyan guifg=cyan cterm=standout gui=undercurl
hi ansiRapidBlinkWhite ctermfg=white guifg=white cterm=standout gui=undercurl
hi ansiRVBlack ctermfg=black guifg=black cterm=reverse gui=reverse
hi ansiRVRed ctermfg=red guifg=red cterm=reverse gui=reverse
hi ansiRVGreen ctermfg=green guifg=green cterm=reverse gui=reverse
hi ansiRVYellow ctermfg=yellow guifg=yellow cterm=reverse gui=reverse
hi ansiRVBlue ctermfg=blue guifg=blue cterm=reverse gui=reverse
hi ansiRVMagenta ctermfg=magenta guifg=magenta cterm=reverse gui=reverse
hi ansiRVCyan ctermfg=cyan guifg=cyan cterm=reverse gui=reverse
hi ansiRVWhite ctermfg=white guifg=white cterm=reverse gui=reverse
hi ansiBlackBlack ctermfg=black ctermbg=black guifg=Black guibg=Black cterm=none gui=none
hi ansiRedBlack ctermfg=black ctermbg=black guifg=Black guibg=Black cterm=none gui=none
hi ansiRedBlack ctermfg=red ctermbg=black guifg=Red guibg=Black cterm=none gui=none
hi ansiGreenBlack ctermfg=green ctermbg=black guifg=Green guibg=Black cterm=none gui=none
hi ansiYellowBlack ctermfg=yellow ctermbg=black guifg=Yellow guibg=Black cterm=none gui=none
hi ansiBlueBlack ctermfg=blue ctermbg=black guifg=Blue guibg=Black cterm=none gui=none
hi ansiMagentaBlack ctermfg=magenta ctermbg=black guifg=Magenta guibg=Black cterm=none gui=none
hi ansiCyanBlack ctermfg=cyan ctermbg=black guifg=Cyan guibg=Black cterm=none gui=none
hi ansiWhiteBlack ctermfg=white ctermbg=black guifg=White guibg=Black cterm=none gui=none
hi ansiBlackRed ctermfg=black ctermbg=red guifg=Black guibg=Red cterm=none gui=none
hi ansiRedRed ctermfg=red ctermbg=red guifg=Red guibg=Red cterm=none gui=none
hi ansiGreenRed ctermfg=green ctermbg=red guifg=Green guibg=Red cterm=none gui=none
hi ansiYellowRed ctermfg=yellow ctermbg=red guifg=Yellow guibg=Red cterm=none gui=none
hi ansiBlueRed ctermfg=blue ctermbg=red guifg=Blue guibg=Red cterm=none gui=none
hi ansiMagentaRed ctermfg=magenta ctermbg=red guifg=Magenta guibg=Red cterm=none gui=none
hi ansiCyanRed ctermfg=cyan ctermbg=red guifg=Cyan guibg=Red cterm=none gui=none
hi ansiWhiteRed ctermfg=white ctermbg=red guifg=White guibg=Red cterm=none gui=none
hi ansiBlackGreen ctermfg=black ctermbg=green guifg=Black guibg=Green cterm=none gui=none
hi ansiRedGreen ctermfg=red ctermbg=green guifg=Red guibg=Green cterm=none gui=none
hi ansiGreenGreen ctermfg=green ctermbg=green guifg=Green guibg=Green cterm=none gui=none
hi ansiYellowGreen ctermfg=yellow ctermbg=green guifg=Yellow guibg=Green cterm=none gui=none
hi ansiBlueGreen ctermfg=blue ctermbg=green guifg=Blue guibg=Green cterm=none gui=none
hi ansiMagentaGreen ctermfg=magenta ctermbg=green guifg=Magenta guibg=Green cterm=none gui=none
hi ansiCyanGreen ctermfg=cyan ctermbg=green guifg=Cyan guibg=Green cterm=none gui=none
hi ansiWhiteGreen ctermfg=white ctermbg=green guifg=White guibg=Green cterm=none gui=none
hi ansiBlackYellow ctermfg=black ctermbg=yellow guifg=Black guibg=Yellow cterm=none gui=none
hi ansiRedYellow ctermfg=red ctermbg=yellow guifg=Red guibg=Yellow cterm=none gui=none
hi ansiGreenYellow ctermfg=green ctermbg=yellow guifg=Green guibg=Yellow cterm=none gui=none
hi ansiYellowYellow ctermfg=yellow ctermbg=yellow guifg=Yellow guibg=Yellow cterm=none gui=none
hi ansiBlueYellow ctermfg=blue ctermbg=yellow guifg=Blue guibg=Yellow cterm=none gui=none
hi ansiMagentaYellow ctermfg=magenta ctermbg=yellow guifg=Magenta guibg=Yellow cterm=none gui=none
hi ansiCyanYellow ctermfg=cyan ctermbg=yellow guifg=Cyan guibg=Yellow cterm=none gui=none
hi ansiWhiteYellow ctermfg=white ctermbg=yellow guifg=White guibg=Yellow cterm=none gui=none
hi ansiBlackBlue ctermfg=black ctermbg=blue guifg=Black guibg=Blue cterm=none gui=none
hi ansiRedBlue ctermfg=red ctermbg=blue guifg=Red guibg=Blue cterm=none gui=none
hi ansiGreenBlue ctermfg=green ctermbg=blue guifg=Green guibg=Blue cterm=none gui=none
hi ansiYellowBlue ctermfg=yellow ctermbg=blue guifg=Yellow guibg=Blue cterm=none gui=none
hi ansiBlueBlue ctermfg=blue ctermbg=blue guifg=Blue guibg=Blue cterm=none gui=none
hi ansiMagentaBlue ctermfg=magenta ctermbg=blue guifg=Magenta guibg=Blue cterm=none gui=none
hi ansiCyanBlue ctermfg=cyan ctermbg=blue guifg=Cyan guibg=Blue cterm=none gui=none
hi ansiWhiteBlue ctermfg=white ctermbg=blue guifg=White guibg=Blue cterm=none gui=none
hi ansiBlackMagenta ctermfg=black ctermbg=magenta guifg=Black guibg=Magenta cterm=none gui=none
hi ansiRedMagenta ctermfg=red ctermbg=magenta guifg=Red guibg=Magenta cterm=none gui=none
hi ansiGreenMagenta ctermfg=green ctermbg=magenta guifg=Green guibg=Magenta cterm=none gui=none
hi ansiYellowMagenta ctermfg=yellow ctermbg=magenta guifg=Yellow guibg=Magenta cterm=none gui=none
hi ansiBlueMagenta ctermfg=blue ctermbg=magenta guifg=Blue guibg=Magenta cterm=none gui=none
hi ansiMagentaMagenta ctermfg=magenta ctermbg=magenta guifg=Magenta guibg=Magenta cterm=none gui=none
hi ansiCyanMagenta ctermfg=cyan ctermbg=magenta guifg=Cyan guibg=Magenta cterm=none gui=none
hi ansiWhiteMagenta ctermfg=white ctermbg=magenta guifg=White guibg=Magenta cterm=none gui=none
hi ansiBlackCyan ctermfg=black ctermbg=cyan guifg=Black guibg=Cyan cterm=none gui=none
hi ansiRedCyan ctermfg=red ctermbg=cyan guifg=Red guibg=Cyan cterm=none gui=none
hi ansiGreenCyan ctermfg=green ctermbg=cyan guifg=Green guibg=Cyan cterm=none gui=none
hi ansiYellowCyan ctermfg=yellow ctermbg=cyan guifg=Yellow guibg=Cyan cterm=none gui=none
hi ansiBlueCyan ctermfg=blue ctermbg=cyan guifg=Blue guibg=Cyan cterm=none gui=none
hi ansiMagentaCyan ctermfg=magenta ctermbg=cyan guifg=Magenta guibg=Cyan cterm=none gui=none
hi ansiCyanCyan ctermfg=cyan ctermbg=cyan guifg=Cyan guibg=Cyan cterm=none gui=none
hi ansiWhiteCyan ctermfg=white ctermbg=cyan guifg=White guibg=Cyan cterm=none gui=none
hi ansiBlackWhite ctermfg=black ctermbg=white guifg=Black guibg=White cterm=none gui=none
hi ansiRedWhite ctermfg=red ctermbg=white guifg=Red guibg=White cterm=none gui=none
hi ansiGreenWhite ctermfg=green ctermbg=white guifg=Green guibg=White cterm=none gui=none
hi ansiYellowWhite ctermfg=yellow ctermbg=white guifg=Yellow guibg=White cterm=none gui=none
hi ansiBlueWhite ctermfg=blue ctermbg=white guifg=Blue guibg=White cterm=none gui=none
hi ansiMagentaWhite ctermfg=magenta ctermbg=white guifg=Magenta guibg=White cterm=none gui=none
hi ansiCyanWhite ctermfg=cyan ctermbg=white guifg=Cyan guibg=White cterm=none gui=none
hi ansiWhiteWhite ctermfg=white ctermbg=white guifg=White guibg=White cterm=none gui=none
endif
" call Dret("AnsiEsc#AnsiEsc")
endfun
" ---------------------------------------------------------------------
" s:MultiElementHandler: builds custom syntax highlighting for three or more element ansi escape sequences {{{2
fun! s:MultiElementHandler()
" call Dfunc("s:MultiElementHandler()")
let curwp= SaveWinPosn(0)
keepj 1
keepj norm! 0
let mehcnt = 0
let mehrules = []
while search('\e\[;\=\d\+;\d\+;\d\+\(;\d\+\)*m','cW')
let curcol = col(".")+1
call search('m','cW')
let mcol = col(".")
let ansiesc = strpart(getline("."),curcol,mcol - curcol)
let aecodes = split(ansiesc,'[;m]')
" call Decho("ansiesc<".ansiesc."> aecodes=".string(aecodes))
let skip = 0
let mod = "NONE,"
let fg = ""
let bg = ""
" if the ansiesc is
if index(mehrules,ansiesc) == -1
let mehrules+= [ansiesc]
for code in aecodes
" handle multi-code sequences (38;5;color and 48;5;color)
if skip == 38 && code == 5
" handling <esc>[38;5
let skip= 385
" call Decho(" 1: building code=".code." skip=".skip.": mod<".mod."> fg<".fg."> bg<".bg.">")
continue
elseif skip == 385
" handling <esc>[38;5;...
if has("gui") && has("gui_running")
let fg= s:Ansi2Gui(code)
else
let fg= code
endif
let skip= 0
" call Decho(" 2: building code=".code." skip=".skip.": mod<".mod."> fg<".fg."> bg<".bg.">")
continue
elseif skip == 48 && code == 5
" handling <esc>[48;5
let skip= 485
" call Decho(" 3: building code=".code." skip=".skip.": mod<".mod."> fg<".fg."> bg<".bg.">")
continue
elseif skip == 485
" handling <esc>[48;5;...
if has("gui") && has("gui_running")
let bg= s:Ansi2Gui(code)
else
let bg= code
endif
let skip= 0
" call Decho(" 4: building code=".code." skip=".skip.": mod<".mod."> fg<".fg."> bg<".bg.">")
continue
else
let skip= 0
endif
" handle single-code sequences
if code == 1
let mod=mod."bold,"
elseif code == 2
let mod=mod."italic,"
elseif code == 3
let mod=mod."standout,"
elseif code == 4
let mod=mod."underline,"
elseif code == 5 || code == 6
let mod=mod."undercurl,"
elseif code == 7
let mod=mod."reverse,"
elseif code == 30
let fg= "black"
elseif code == 31
let fg= "red"
elseif code == 32
let fg= "green"
elseif code == 33
let fg= "yellow"
elseif code == 34
let fg= "blue"
elseif code == 35
let fg= "magenta"
elseif code == 36
let fg= "cyan"
elseif code == 37
let fg= "white"
elseif code == 40
let bg= "black"
elseif code == 41
let bg= "red"
elseif code == 42
let bg= "green"
elseif code == 43
let bg= "yellow"
elseif code == 44
let bg= "blue"
elseif code == 45
let bg= "magenta"
elseif code == 46
let bg= "cyan"
elseif code == 47
let bg= "white"
elseif code == 38
let skip= 38
elseif code == 48
let skip= 48
endif
" call Decho(" 5: building code=".code." skip=".skip.": mod<".mod."> fg<".fg."> bg<".bg.">")
endfor
" fixups
let mod= substitute(mod,',$','','')
" build syntax-recognition rule
let mehcnt = mehcnt + 1
let synrule = "syn region ansiMEH".mehcnt
let synrule = synrule.' start="\e\['.ansiesc.'"'
let synrule = synrule.' end="\e\["me=e-2'
let synrule = synrule." contains=ansiConceal"
" call Decho(" exe synrule: ".synrule)
exe synrule
" build highlighting rule
let hirule= "hi ansiMEH".mehcnt
if has("gui") && has("gui_running")
let hirule=hirule." gui=".mod
if fg != ""| let hirule=hirule." guifg=".fg| endif
if bg != ""| let hirule=hirule." guibg=".bg| endif
else
let hirule=hirule." cterm=".mod
if fg != ""| let hirule=hirule." ctermfg=".fg| endif
if bg != ""| let hirule=hirule." ctermbg=".bg| endif
endif
" call Decho(" exe hirule: ".hirule)
exe hirule
endif
endwhile
call RestoreWinPosn(curwp)
" call Dret("s:MultiElementHandler")
endfun
" ---------------------------------------------------------------------
" s:Ansi2Gui: converts an ansi-escape sequence (for 256-color xterms) {{{2
" to an equivalent gui color
" colors 0- 15:
" colors 16-231: 6x6x6 color cube, code= 16+r*36+g*6+b with r,g,b each in [0,5]
" colors 232-255: grayscale ramp, code= 10*gray + 8 with gray in [0,23] (black,white left out)
fun! s:Ansi2Gui(code)
" call Dfunc("s:Ansi2Gui(code=)".a:code)
let guicolor= a:code
if a:code < 16
let code2rgb = [ "black", "red3", "green3", "yellow3", "blue3", "magenta3", "cyan3", "gray70", "gray40", "red", "green", "yellow", "royalblue3", "magenta", "cyan", "white"]
let guicolor = code2rgb[a:code]
elseif a:code >= 232
let code = a:code - 232
let code = 10*code + 8
let guicolor = printf("#%02x%02x%02x",code,code,code)
else
let code = a:code - 16
let code2rgb = [43,85,128,170,213,255]
let r = code2rgb[code/36]
let g = code2rgb[(code%36)/6]
let b = code2rgb[code%6]
let guicolor = printf("#%02x%02x%02x",r,g,b)
endif
" call Dret("s:Ansi2Gui ".guicolor)
return guicolor
endfun
" ---------------------------------------------------------------------
" Restore: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
" ---------------------------------------------------------------------
" Modelines: {{{1
" vim: ts=12 fdm=marker

573
vim/autoload/EasyMotion.vim Executable file
View File

@ -0,0 +1,573 @@
" EasyMotion - Vim motions on speed!
"
" Author: Kim Silkebækken <kim.silkebaekken+vim@gmail.com>
" Source repository: https://github.com/Lokaltog/vim-easymotion
" Default configuration functions {{{
function! EasyMotion#InitOptions(options) " {{{
for [key, value] in items(a:options)
if ! exists('g:EasyMotion_' . key)
exec 'let g:EasyMotion_' . key . ' = ' . string(value)
endif
endfor
endfunction " }}}
function! EasyMotion#InitHL(group, colors) " {{{
let group_default = a:group . 'Default'
" Prepare highlighting variables
let guihl = printf('guibg=%s guifg=%s gui=%s', a:colors.gui[0], a:colors.gui[1], a:colors.gui[2])
if !exists('g:CSApprox_loaded')
let ctermhl = &t_Co == 256
\ ? printf('ctermbg=%s ctermfg=%s cterm=%s', a:colors.cterm256[0], a:colors.cterm256[1], a:colors.cterm256[2])
\ : printf('ctermbg=%s ctermfg=%s cterm=%s', a:colors.cterm[0], a:colors.cterm[1], a:colors.cterm[2])
else
let ctermhl = ''
endif
" Create default highlighting group
execute printf('hi default %s %s %s', group_default, guihl, ctermhl)
" Check if the hl group exists
if hlexists(a:group)
redir => hlstatus | exec 'silent hi ' . a:group | redir END
" Return if the group isn't cleared
if hlstatus !~ 'cleared'
return
endif
endif
" No colors are defined for this group, link to defaults
execute printf('hi default link %s %s', a:group, group_default)
endfunction " }}}
function! EasyMotion#InitMappings(motions) "{{{
for motion in keys(a:motions)
call EasyMotion#InitOptions({ 'mapping_' . motion : g:EasyMotion_leader_key . motion })
endfor
if g:EasyMotion_do_mapping
for [motion, fn] in items(a:motions)
if empty(g:EasyMotion_mapping_{motion})
continue
endif
silent exec 'nnoremap <silent> ' . g:EasyMotion_mapping_{motion} . ' :call EasyMotion#' . fn.name . '(0, ' . fn.dir . ')<CR>'
silent exec 'onoremap <silent> ' . g:EasyMotion_mapping_{motion} . ' :call EasyMotion#' . fn.name . '(0, ' . fn.dir . ')<CR>'
silent exec 'vnoremap <silent> ' . g:EasyMotion_mapping_{motion} . ' :<C-U>call EasyMotion#' . fn.name . '(1, ' . fn.dir . ')<CR>'
endfor
endif
endfunction "}}}
" }}}
" Motion functions {{{
function! EasyMotion#F(visualmode, direction) " {{{
let char = s:GetSearchChar(a:visualmode)
if empty(char)
return
endif
let re = '\C' . escape(char, '.$^~')
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
endfunction " }}}
function! EasyMotion#T(visualmode, direction) " {{{
let char = s:GetSearchChar(a:visualmode)
if empty(char)
return
endif
if a:direction == 1
let re = '\C' . escape(char, '.$^~') . '\zs.'
else
let re = '\C.' . escape(char, '.$^~')
endif
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
endfunction " }}}
function! EasyMotion#WB(visualmode, direction) " {{{
call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', '')
endfunction " }}}
function! EasyMotion#WBW(visualmode, direction) " {{{
call s:EasyMotion('\(\(^\|\s\)\@<=\S\|^$\)', a:direction, a:visualmode ? visualmode() : '', '')
endfunction " }}}
function! EasyMotion#E(visualmode, direction) " {{{
call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', mode(1))
endfunction " }}}
function! EasyMotion#EW(visualmode, direction) " {{{
call s:EasyMotion('\(\S\(\s\|$\)\|^$\)', a:direction, a:visualmode ? visualmode() : '', mode(1))
endfunction " }}}
function! EasyMotion#JK(visualmode, direction) " {{{
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', a:direction, a:visualmode ? visualmode() : '', '')
endfunction " }}}
function! EasyMotion#Search(visualmode, direction) " {{{
call s:EasyMotion(@/, a:direction, a:visualmode ? visualmode() : '', '')
endfunction " }}}
" }}}
" Helper functions {{{
function! s:Message(message) " {{{
echo 'EasyMotion: ' . a:message
endfunction " }}}
function! s:Prompt(message) " {{{
echohl Question
echo a:message . ': '
echohl None
endfunction " }}}
function! s:VarReset(var, ...) " {{{
if ! exists('s:var_reset')
let s:var_reset = {}
endif
let buf = bufname("")
if a:0 == 0 && has_key(s:var_reset, a:var)
" Reset var to original value
call setbufvar(buf, a:var, s:var_reset[a:var])
elseif a:0 == 1
let new_value = a:0 == 1 ? a:1 : ''
" Store original value
let s:var_reset[a:var] = getbufvar(buf, a:var)
" Set new var value
call setbufvar(buf, a:var, new_value)
endif
endfunction " }}}
function! s:SetLines(lines, key) " {{{
try
" Try to join changes with previous undo block
undojoin
catch
endtry
for [line_num, line] in a:lines
call setline(line_num, line[a:key])
endfor
endfunction " }}}
function! s:GetChar() " {{{
let char = getchar()
if char == 27
" Escape key pressed
redraw
call s:Message('Cancelled')
return ''
endif
return nr2char(char)
endfunction " }}}
function! s:GetSearchChar(visualmode) " {{{
call s:Prompt('Search for character')
let char = s:GetChar()
" Check that we have an input char
if empty(char)
" Restore selection
if ! empty(a:visualmode)
silent exec 'normal! gv'
endif
return ''
endif
return char
endfunction " }}}
" }}}
" Grouping algorithms {{{
let s:grouping_algorithms = {
\ 1: 'SCTree'
\ , 2: 'Original'
\ }
" Single-key/closest target priority tree {{{
" This algorithm tries to assign one-key jumps to all the targets closest to the cursor.
" It works recursively and will work correctly with as few keys as two.
function! s:GroupingAlgorithmSCTree(targets, keys)
" Prepare variables for working
let targets_len = len(a:targets)
let keys_len = len(a:keys)
let groups = {}
let keys = reverse(copy(a:keys))
" Semi-recursively count targets {{{
" We need to know exactly how many child nodes (targets) this branch will have
" in order to pass the correct amount of targets to the recursive function.
" Prepare sorted target count list {{{
" This is horrible, I know. But dicts aren't sorted in vim, so we need to
" work around that. That is done by having one sorted list with key counts,
" and a dict which connects the key with the keys_count list.
let keys_count = []
let keys_count_keys = {}
let i = 0
for key in keys
call add(keys_count, 0)
let keys_count_keys[key] = i
let i += 1
endfor
" }}}
let targets_left = targets_len
let level = 0
let i = 0
while targets_left > 0
" Calculate the amount of child nodes based on the current level
let childs_len = (level == 0 ? 1 : (keys_len - 1) )
for key in keys
" Add child node count to the keys_count array
let keys_count[keys_count_keys[key]] += childs_len
" Subtract the child node count
let targets_left -= childs_len
if targets_left <= 0
" Subtract the targets left if we added too many too
" many child nodes to the key count
let keys_count[keys_count_keys[key]] += targets_left
break
endif
let i += 1
endfor
let level += 1
endwhile
" }}}
" Create group tree {{{
let i = 0
let key = 0
call reverse(keys_count)
for key_count in keys_count
if key_count > 1
" We need to create a subgroup
" Recurse one level deeper
let groups[a:keys[key]] = s:GroupingAlgorithmSCTree(a:targets[i : i + key_count - 1], a:keys)
elseif key_count == 1
" Assign single target key
let groups[a:keys[key]] = a:targets[i]
else
" No target
continue
endif
let key += 1
let i += key_count
endfor
" }}}
" Finally!
return groups
endfunction
" }}}
" Original {{{
function! s:GroupingAlgorithmOriginal(targets, keys)
" Split targets into groups (1 level)
let targets_len = len(a:targets)
let keys_len = len(a:keys)
let groups = {}
let i = 0
let root_group = 0
try
while root_group < targets_len
let groups[a:keys[root_group]] = {}
for key in a:keys
let groups[a:keys[root_group]][key] = a:targets[i]
let i += 1
endfor
let root_group += 1
endwhile
catch | endtry
" Flatten the group array
if len(groups) == 1
let groups = groups[a:keys[0]]
endif
return groups
endfunction
" }}}
" Coord/key dictionary creation {{{
function! s:CreateCoordKeyDict(groups, ...)
" Dict structure:
" 1,2 : a
" 2,3 : b
let sort_list = []
let coord_keys = {}
let group_key = a:0 == 1 ? a:1 : ''
for [key, item] in items(a:groups)
let key = ( ! empty(group_key) ? group_key : key)
if type(item) == 3
" Destination coords
" The key needs to be zero-padded in order to
" sort correctly
let dict_key = printf('%05d,%05d', item[0], item[1])
let coord_keys[dict_key] = key
" We need a sorting list to loop correctly in
" PromptUser, dicts are unsorted
call add(sort_list, dict_key)
else
" Item is a dict (has children)
let coord_key_dict = s:CreateCoordKeyDict(item, key)
" Make sure to extend both the sort list and the
" coord key dict
call extend(sort_list, coord_key_dict[0])
call extend(coord_keys, coord_key_dict[1])
endif
unlet item
endfor
return [sort_list, coord_keys]
endfunction
" }}}
" }}}
" Core functions {{{
function! s:PromptUser(groups) "{{{
" If only one possible match, jump directly to it {{{
let group_values = values(a:groups)
if len(group_values) == 1
redraw
return group_values[0]
endif
" }}}
" Prepare marker lines {{{
let lines = {}
let hl_coords = []
let coord_key_dict = s:CreateCoordKeyDict(a:groups)
for dict_key in sort(coord_key_dict[0])
let target_key = coord_key_dict[1][dict_key]
let [line_num, col_num] = split(dict_key, ',')
let line_num = str2nr(line_num)
let col_num = str2nr(col_num)
" Add original line and marker line
if ! has_key(lines, line_num)
let current_line = getline(line_num)
let lines[line_num] = { 'orig': current_line, 'marker': current_line, 'mb_compensation': 0 }
endif
" Compensate for byte difference between marker
" character and target character
"
" This has to be done in order to match the correct
" column; \%c matches the byte column and not display
" column.
let target_char_len = strlen(matchstr(lines[line_num]['marker'], '\%' . col_num . 'c.'))
let target_key_len = strlen(target_key)
" Solve multibyte issues by matching the byte column
" number instead of the visual column
let col_num -= lines[line_num]['mb_compensation']
if strlen(lines[line_num]['marker']) > 0
" Substitute marker character if line length > 0
let lines[line_num]['marker'] = substitute(lines[line_num]['marker'], '\%' . col_num . 'c.', target_key, '')
else
" Set the line to the marker character if the line is empty
let lines[line_num]['marker'] = target_key
endif
" Add highlighting coordinates
call add(hl_coords, '\%' . line_num . 'l\%' . col_num . 'c')
" Add marker/target lenght difference for multibyte
" compensation
let lines[line_num]['mb_compensation'] += (target_char_len - target_key_len)
endfor
let lines_items = items(lines)
" }}}
" Highlight targets {{{
let target_hl_id = matchadd(g:EasyMotion_hl_group_target, join(hl_coords, '\|'), 1)
" }}}
try
" Set lines with markers
call s:SetLines(lines_items, 'marker')
redraw
" Get target character {{{
call s:Prompt('Target key')
let char = s:GetChar()
" }}}
finally
" Restore original lines
call s:SetLines(lines_items, 'orig')
" Un-highlight targets {{{
if exists('target_hl_id')
call matchdelete(target_hl_id)
endif
" }}}
redraw
endtry
" Check if we have an input char {{{
if empty(char)
throw 'Cancelled'
endif
" }}}
" Check if the input char is valid {{{
if ! has_key(a:groups, char)
throw 'Invalid target'
endif
" }}}
let target = a:groups[char]
if type(target) == 3
" Return target coordinates
return target
else
" Prompt for new target character
return s:PromptUser(target)
endif
endfunction "}}}
function! s:EasyMotion(regexp, direction, visualmode, mode) " {{{
let orig_pos = [line('.'), col('.')]
let targets = []
try
" Reset properties {{{
call s:VarReset('&scrolloff', 0)
call s:VarReset('&modified', 0)
call s:VarReset('&modifiable', 1)
call s:VarReset('&readonly', 0)
call s:VarReset('&spell', 0)
call s:VarReset('&virtualedit', '')
" }}}
" Find motion targets {{{
let search_direction = (a:direction == 1 ? 'b' : '')
let search_stopline = line(a:direction == 1 ? 'w0' : 'w$')
while 1
let pos = searchpos(a:regexp, search_direction, search_stopline)
" Reached end of search range
if pos == [0, 0]
break
endif
" Skip folded lines
if foldclosed(pos[0]) != -1
continue
endif
call add(targets, pos)
endwhile
let targets_len = len(targets)
if targets_len == 0
throw 'No matches'
endif
" }}}
let GroupingFn = function('s:GroupingAlgorithm' . s:grouping_algorithms[g:EasyMotion_grouping])
let groups = GroupingFn(targets, split(g:EasyMotion_keys, '\zs'))
" Shade inactive source {{{
if g:EasyMotion_do_shade
let shade_hl_pos = '\%' . orig_pos[0] . 'l\%'. orig_pos[1] .'c'
if a:direction == 1
" Backward
let shade_hl_re = '\%'. line('w0') .'l\_.*' . shade_hl_pos
else
" Forward
let shade_hl_re = shade_hl_pos . '\_.*\%'. line('w$') .'l'
endif
let shade_hl_id = matchadd(g:EasyMotion_hl_group_shade, shade_hl_re, 0)
endif
" }}}
" Prompt user for target group/character
let coords = s:PromptUser(groups)
" Update selection {{{
if ! empty(a:visualmode)
keepjumps call cursor(orig_pos[0], orig_pos[1])
exec 'normal! ' . a:visualmode
endif
" }}}
" Handle operator-pending mode {{{
if a:mode == 'no'
" This mode requires that we eat one more
" character to the right if we're using
" a forward motion
if a:direction != 1
let coords[1] += 1
endif
endif
" }}}
" Update cursor position
call cursor(orig_pos[0], orig_pos[1])
mark '
call cursor(coords[0], coords[1])
call s:Message('Jumping to [' . coords[0] . ', ' . coords[1] . ']')
catch
redraw
" Show exception message
call s:Message(v:exception)
" Restore original cursor position/selection {{{
if ! empty(a:visualmode)
silent exec 'normal! gv'
else
keepjumps call cursor(orig_pos[0], orig_pos[1])
endif
" }}}
finally
" Restore properties {{{
call s:VarReset('&scrolloff')
call s:VarReset('&modified')
call s:VarReset('&modifiable')
call s:VarReset('&readonly')
call s:VarReset('&spell')
call s:VarReset('&virtualedit')
" }}}
" Remove shading {{{
if g:EasyMotion_do_shade && exists('shade_hl_id')
call matchdelete(shade_hl_id)
endif
" }}}
endtry
endfunction " }}}
" }}}
" vim: fdm=marker:noet:ts=4:sw=4:sts=4

1508
vim/autoload/conque_term.vim Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,315 @@
# FILE: autoload/conque_term/conque_globals.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2011-09-02
# VERSION: 2.3, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2011 Nico Raffo
#
# MIT License
#
# 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.
"""Common global constants and functions for Conque."""
import sys
import re
# PYTHON VERSION
CONQUE_PYTHON_VERSION = sys.version_info[0]
# Encoding
try:
# Vim's character encoding
import vim
CONQUE_VIM_ENCODING = vim.eval('&encoding')
except:
CONQUE_VIM_ENCODING = 'utf-8'
def u(str_val, str_encoding='utf-8', errors='strict'):
""" Foolhardy attempt to make unicode string syntax compatible with both python 2 and 3. """
if not str_val:
str_val = ''
if CONQUE_PYTHON_VERSION == 3:
return str_val
else:
return unicode(str_val, str_encoding, errors)
def uchr(str):
""" Foolhardy attempt to make unicode string syntax compatible with both python 2 and 3. """
if CONQUE_PYTHON_VERSION == 3:
return chr(str)
else:
return unichr(str)
# Logging
# Unix escape sequence settings
CONQUE_CTL = {
1: 'soh', # start of heading
2: 'stx', # start of text
7: 'bel', # bell
8: 'bs', # backspace
9: 'tab', # tab
10: 'nl', # new line
13: 'cr', # carriage return
14: 'so', # shift out
15: 'si' # shift in
}
# 11 : 'vt', # vertical tab
# 12 : 'ff', # form feed
# Escape sequences
CONQUE_ESCAPE = {
'm': 'font',
'J': 'clear_screen',
'K': 'clear_line',
'@': 'add_spaces',
'A': 'cursor_up',
'B': 'cursor_down',
'C': 'cursor_right',
'D': 'cursor_left',
'G': 'cursor_to_column',
'H': 'cursor',
'P': 'delete_chars',
'f': 'cursor',
'g': 'tab_clear',
'r': 'set_coords',
'h': 'set',
'l': 'reset'
}
# 'L': 'insert_lines',
# 'M': 'delete_lines',
# 'd': 'cusor_vpos',
# Alternate escape sequences, no [
CONQUE_ESCAPE_PLAIN = {
'D': 'scroll_up',
'E': 'next_line',
'H': 'set_tab',
'M': 'scroll_down'
}
# 'N': 'single_shift_2',
# 'O': 'single_shift_3',
# '=': 'alternate_keypad',
# '>': 'numeric_keypad',
# '7': 'save_cursor',
# '8': 'restore_cursor',
# Character set escape sequences, with "("
CONQUE_ESCAPE_CHARSET = {
'A': 'uk',
'B': 'us',
'0': 'graphics'
}
# Uber alternate escape sequences, with # or ?
CONQUE_ESCAPE_QUESTION = {
'1h': 'new_line_mode',
'3h': '132_cols',
'4h': 'smooth_scrolling',
'5h': 'reverse_video',
'6h': 'relative_origin',
'7h': 'set_auto_wrap',
'8h': 'set_auto_repeat',
'9h': 'set_interlacing_mode',
'1l': 'set_cursor_key',
'2l': 'set_vt52',
'3l': '80_cols',
'4l': 'set_jump_scrolling',
'5l': 'normal_video',
'6l': 'absolute_origin',
'7l': 'reset_auto_wrap',
'8l': 'reset_auto_repeat',
'9l': 'reset_interlacing_mode'
}
CONQUE_ESCAPE_HASH = {
'8': 'screen_alignment_test'
}
# '3': 'double_height_top',
# '4': 'double_height_bottom',
# '5': 'single_height_single_width',
# '6': 'single_height_double_width',
CONQUE_GRAPHICS_SET = [
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028, 0x0029, 0x002A, 0x2192, 0x2190, 0x2191, 0x2193, 0x002F,
0x2588, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x00A0,
0x25C6, 0x2592, 0x2409, 0x240C, 0x240D, 0x240A, 0x00B0, 0x00B1,
0x2591, 0x240B, 0x2518, 0x2510, 0x250C, 0x2514, 0x253C, 0xF800,
0xF801, 0x2500, 0xF803, 0xF804, 0x251C, 0x2524, 0x2534, 0x252C,
0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00B7, 0x007F,
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
]
# Font codes
CONQUE_FONT = {
0: {'description': 'Normal (default)', 'attributes': {'cterm': 'NONE', 'ctermfg': 'NONE', 'ctermbg': 'NONE', 'gui': 'NONE', 'guifg': 'NONE', 'guibg': 'NONE'}, 'normal': True},
1: {'description': 'Bold', 'attributes': {'cterm': 'BOLD', 'gui': 'BOLD'}, 'normal': False},
4: {'description': 'Underlined', 'attributes': {'cterm': 'UNDERLINE', 'gui': 'UNDERLINE'}, 'normal': False},
5: {'description': 'Blink (appears as Bold)', 'attributes': {'cterm': 'BOLD', 'gui': 'BOLD'}, 'normal': False},
7: {'description': 'Inverse', 'attributes': {'cterm': 'REVERSE', 'gui': 'REVERSE'}, 'normal': False},
8: {'description': 'Invisible (hidden)', 'attributes': {'ctermfg': '0', 'ctermbg': '0', 'guifg': '#000000', 'guibg': '#000000'}, 'normal': False},
22: {'description': 'Normal (neither bold nor faint)', 'attributes': {'cterm': 'NONE', 'gui': 'NONE'}, 'normal': True},
24: {'description': 'Not underlined', 'attributes': {'cterm': 'NONE', 'gui': 'NONE'}, 'normal': True},
25: {'description': 'Steady (not blinking)', 'attributes': {'cterm': 'NONE', 'gui': 'NONE'}, 'normal': True},
27: {'description': 'Positive (not inverse)', 'attributes': {'cterm': 'NONE', 'gui': 'NONE'}, 'normal': True},
28: {'description': 'Visible (not hidden)', 'attributes': {'ctermfg': 'NONE', 'ctermbg': 'NONE', 'guifg': 'NONE', 'guibg': 'NONE'}, 'normal': True},
30: {'description': 'Set foreground color to Black', 'attributes': {'ctermfg': '16', 'guifg': '#000000'}, 'normal': False},
31: {'description': 'Set foreground color to Red', 'attributes': {'ctermfg': '1', 'guifg': '#ff0000'}, 'normal': False},
32: {'description': 'Set foreground color to Green', 'attributes': {'ctermfg': '2', 'guifg': '#00ff00'}, 'normal': False},
33: {'description': 'Set foreground color to Yellow', 'attributes': {'ctermfg': '3', 'guifg': '#ffff00'}, 'normal': False},
35: {'description': 'Set foreground color to Magenta', 'attributes': {'ctermfg': '5', 'guifg': '#990099'}, 'normal': False},
36: {'description': 'Set foreground color to Cyan', 'attributes': {'ctermfg': '6', 'guifg': '#009999'}, 'normal': False},
37: {'description': 'Set foreground color to White', 'attributes': {'ctermfg': '7', 'guifg': '#ffffff'}, 'normal': False},
39: {'description': 'Set foreground color to default (original)', 'attributes': {'ctermfg': 'NONE', 'guifg': 'NONE'}, 'normal': True},
40: {'description': 'Set background color to Black', 'attributes': {'ctermbg': '16', 'guibg': '#000000'}, 'normal': False},
41: {'description': 'Set background color to Red', 'attributes': {'ctermbg': '1', 'guibg': '#ff0000'}, 'normal': False},
42: {'description': 'Set background color to Green', 'attributes': {'ctermbg': '2', 'guibg': '#00ff00'}, 'normal': False},
43: {'description': 'Set background color to Yellow', 'attributes': {'ctermbg': '3', 'guibg': '#ffff00'}, 'normal': False},
45: {'description': 'Set background color to Magenta', 'attributes': {'ctermbg': '5', 'guibg': '#990099'}, 'normal': False},
46: {'description': 'Set background color to Cyan', 'attributes': {'ctermbg': '6', 'guibg': '#009999'}, 'normal': False},
47: {'description': 'Set background color to White', 'attributes': {'ctermbg': '7', 'guibg': '#ffffff'}, 'normal': False},
49: {'description': 'Set background color to default (original).', 'attributes': {'ctermbg': 'NONE', 'guibg': 'NONE'}, 'normal': True},
90: {'description': 'Set foreground color to Black', 'attributes': {'ctermfg': '8', 'guifg': '#000000'}, 'normal': False},
91: {'description': 'Set foreground color to Red', 'attributes': {'ctermfg': '9', 'guifg': '#ff0000'}, 'normal': False},
92: {'description': 'Set foreground color to Green', 'attributes': {'ctermfg': '10', 'guifg': '#00ff00'}, 'normal': False},
93: {'description': 'Set foreground color to Yellow', 'attributes': {'ctermfg': '11', 'guifg': '#ffff00'}, 'normal': False},
95: {'description': 'Set foreground color to Magenta', 'attributes': {'ctermfg': '13', 'guifg': '#990099'}, 'normal': False},
96: {'description': 'Set foreground color to Cyan', 'attributes': {'ctermfg': '14', 'guifg': '#009999'}, 'normal': False},
97: {'description': 'Set foreground color to White', 'attributes': {'ctermfg': '15', 'guifg': '#ffffff'}, 'normal': False},
100: {'description': 'Set background color to Black', 'attributes': {'ctermbg': '8', 'guibg': '#000000'}, 'normal': False},
101: {'description': 'Set background color to Red', 'attributes': {'ctermbg': '9', 'guibg': '#ff0000'}, 'normal': False},
102: {'description': 'Set background color to Green', 'attributes': {'ctermbg': '10', 'guibg': '#00ff00'}, 'normal': False},
103: {'description': 'Set background color to Yellow', 'attributes': {'ctermbg': '11', 'guibg': '#ffff00'}, 'normal': False},
105: {'description': 'Set background color to Magenta', 'attributes': {'ctermbg': '13', 'guibg': '#990099'}, 'normal': False},
106: {'description': 'Set background color to Cyan', 'attributes': {'ctermbg': '14', 'guibg': '#009999'}, 'normal': False},
107: {'description': 'Set background color to White', 'attributes': {'ctermbg': '15', 'guibg': '#ffffff'}, 'normal': False}
}
# regular expression matching (almost) all control sequences
CONQUE_SEQ_REGEX = re.compile("(\x1b\[?\??#?[0-9;]*[a-zA-Z0-9@=>]|\x1b\][0-9];.*?\x07|[\x01-\x0f]|\x1b\([AB0])")
CONQUE_SEQ_REGEX_CTL = re.compile("^[\x01-\x0f]$")
CONQUE_SEQ_REGEX_CSI = re.compile("^\x1b\[")
CONQUE_SEQ_REGEX_TITLE = re.compile("^\x1b\]")
CONQUE_SEQ_REGEX_HASH = re.compile("^\x1b#")
CONQUE_SEQ_REGEX_ESC = re.compile("^\x1b.$")
CONQUE_SEQ_REGEX_CHAR = re.compile("^\x1b[()]")
# match table output
CONQUE_TABLE_OUTPUT = re.compile("^\s*\|\s.*\s\|\s*$|^\s*\+[=+-]+\+\s*$")
# basic terminal colors
CONQUE_COLOR_SEQUENCE = (
'000', '009', '090', '099', '900', '909', '990', '999',
'000', '00f', '0f0', '0ff', 'f00', 'f0f', 'ff0', 'fff'
)
# Windows subprocess constants
# shared memory size
CONQUE_SOLE_BUFFER_LENGTH = 1000
CONQUE_SOLE_INPUT_SIZE = 1000
CONQUE_SOLE_STATS_SIZE = 1000
CONQUE_SOLE_COMMANDS_SIZE = 255
CONQUE_SOLE_RESCROLL_SIZE = 255
CONQUE_SOLE_RESIZE_SIZE = 255
# interval of screen redraw
# larger number means less frequent
CONQUE_SOLE_SCREEN_REDRAW = 50
# interval of full buffer redraw
# larger number means less frequent
CONQUE_SOLE_BUFFER_REDRAW = 500
# interval of full output bucket replacement
# larger number means less frequent, 1 = every time
CONQUE_SOLE_MEM_REDRAW = 1000
# maximum number of lines with terminal colors
# ignored if g:ConqueTerm_Color = 2
CONQUE_MAX_SYNTAX_LINES = 200
# windows input splitting on special keys
CONQUE_WIN32_REGEX_VK = re.compile("(\x1b\[[0-9;]+VK)")
# windows attribute string splitting
CONQUE_WIN32_REGEX_ATTR = re.compile("((.)\\2*)", re.DOTALL)
# special key attributes
CONQUE_VK_ATTR_CTRL_PRESSED = u('1024')

View File

@ -0,0 +1,233 @@
# FILE: autoload/conque_term/conque_screen.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2011-09-02
# VERSION: 2.3, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2011 Nico Raffo
#
# MIT License
#
# 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.
"""
ConqueScreen is an extention of the vim.current.buffer object
Unix terminal escape sequences usually reference line numbers relative to the
top of the visible screen. However the visible portion of the Vim buffer
representing the terminal probably doesn't start at the first line of the
buffer.
The ConqueScreen class allows access to the Vim buffer with screen-relative
line numbering. And handles a few other related tasks, such as setting the
correct cursor position.
E.g.:
s = ConqueScreen()
...
s[5] = 'Set 5th line in terminal to this line'
s.append('Add new line to terminal')
s[5] = 'Since previous append() command scrolled the terminal down, this is a different line than first cb[5] call'
"""
import vim
class ConqueScreen(object):
# the buffer
buffer = None
# screen and scrolling regions
screen_top = 1
# screen width
screen_width = 80
screen_height = 80
# char encoding for vim buffer
screen_encoding = 'utf-8'
def __init__(self):
""" Initialize screen size and character encoding. """
self.buffer = vim.current.buffer
# initialize screen size
self.screen_top = 1
self.screen_width = vim.current.window.width
self.screen_height = vim.current.window.height
# save screen character encoding type
self.screen_encoding = vim.eval('&fileencoding')
def __len__(self):
""" Define the len() function for ConqueScreen objects. """
return len(self.buffer)
def __getitem__(self, key):
""" Define value access for ConqueScreen objects. """
buffer_line = self.get_real_idx(key)
# if line is past buffer end, add lines to buffer
if buffer_line >= len(self.buffer):
for i in range(len(self.buffer), buffer_line + 1):
self.append(' ')
return u(self.buffer[buffer_line], 'utf-8')
def __setitem__(self, key, value):
""" Define value assignments for ConqueScreen objects. """
buffer_line = self.get_real_idx(key)
if CONQUE_PYTHON_VERSION == 2:
val = value.encode(self.screen_encoding)
else:
# XXX / Vim's python3 interface doesn't accept bytes object
val = str(value)
# if line is past end of screen, append
if buffer_line == len(self.buffer):
self.buffer.append(val)
else:
self.buffer[buffer_line] = val
def __delitem__(self, key):
""" Define value deletion for ConqueScreen objects. """
del self.buffer[self.screen_top + key - 2]
def append(self, value):
""" Define value appending for ConqueScreen objects. """
if len(self.buffer) > self.screen_top + self.screen_height - 1:
self.buffer[len(self.buffer) - 1] = value
else:
self.buffer.append(value)
if len(self.buffer) > self.screen_top + self.screen_height - 1:
self.screen_top += 1
if vim.current.buffer.number == self.buffer.number:
vim.command('normal! G')
def insert(self, line, value):
""" Define value insertion for ConqueScreen objects. """
l = self.screen_top + line - 2
try:
self.buffer.append(value, l)
except:
self.buffer[l:l] = [value]
def get_top(self):
""" Get the Vim line number representing the top of the visible terminal. """
return self.screen_top
def get_real_idx(self, line):
""" Get the zero index Vim line number corresponding to the provided screen line. """
return (self.screen_top + line - 2)
def get_buffer_line(self, line):
""" Get the Vim line number corresponding to the provided screen line. """
return (self.screen_top + line - 1)
def set_screen_width(self, width):
""" Set the screen width. """
self.screen_width = width
def clear(self):
""" Clear the screen. Does not clear the buffer, just scrolls down past all text. """
self.screen_width = width
self.buffer.append(' ')
vim.command('normal! Gzt')
self.screen_top = len(self.buffer)
def set_cursor(self, line, column):
""" Set cursor position. """
# figure out line
buffer_line = self.screen_top + line - 1
if buffer_line > len(self.buffer):
for l in range(len(self.buffer) - 1, buffer_line):
self.buffer.append('')
# figure out column
real_column = column
if len(self.buffer[buffer_line - 1]) < real_column:
self.buffer[buffer_line - 1] = self.buffer[buffer_line - 1] + ' ' * (real_column - len(self.buffer[buffer_line - 1]))
if not CONQUE_FAST_MODE:
# set cursor at byte index of real_column'th character
vim.command('call cursor(' + str(buffer_line) + ', byteidx(getline(' + str(buffer_line) + '), ' + str(real_column) + '))')
else:
# old version
# python version is occasionally grumpy
try:
vim.current.window.cursor = (buffer_line, real_column - 1)
except:
vim.command('call cursor(' + str(buffer_line) + ', ' + str(real_column) + ')')
def reset_size(self, line):
""" Change screen size """
# save cursor line number
buffer_line = self.screen_top + line
# reset screen size
self.screen_width = vim.current.window.width
self.screen_height = vim.current.window.height
self.screen_top = len(self.buffer) - vim.current.window.height + 1
if self.screen_top < 1:
self.screen_top = 1
# align bottom of buffer to bottom of screen
vim.command('normal! ' + str(self.screen_height) + 'kG')
# return new relative line number
return (buffer_line - self.screen_top)
def align(self):
""" align bottom of buffer to bottom of screen """
vim.command('normal! ' + str(self.screen_height) + 'kG')

View File

@ -0,0 +1,458 @@
# FILE: autoload/conque_term/conque_sole.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2011-09-02
# VERSION: 2.3, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2011 Nico Raffo
#
# MIT License
#
# 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.
"""
Windows Console Emulator
This is the main interface to the Windows emulator. It reads new output from the background console
and updates the Vim buffer.
"""
import vim
class ConqueSole(Conque):
window_top = None
window_bottom = None
color_cache = {}
attribute_cache = {}
color_mode = None
color_conceals = {}
buffer = None
encoding = None
# counters for periodic rendering
buffer_redraw_ct = 1
screen_redraw_ct = 1
# line offset, shifts output down
offset = 0
def open(self):
""" Start command and initialize this instance
Arguments:
command - Command string, e.g. "Powershell.exe"
options - Dictionary of config options
python_exe - Path to the python.exe executable. Usually C:\PythonXX\python.exe
communicator_py - Path to subprocess controller script in user's vimfiles directory
"""
# get arguments
command = vim.eval('command')
options = vim.eval('options')
python_exe = vim.eval('py_exe')
communicator_py = vim.eval('py_vim')
# init size
self.columns = vim.current.window.width
self.lines = vim.current.window.height
self.window_top = 0
self.window_bottom = vim.current.window.height - 1
# color mode
self.color_mode = vim.eval('g:ConqueTerm_ColorMode')
# line offset
self.offset = int(options['offset'])
# init color
self.enable_colors = options['color'] and not CONQUE_FAST_MODE
# open command
self.proc = ConqueSoleWrapper()
self.proc.open(command, self.lines, self.columns, python_exe, communicator_py, options)
self.buffer = vim.current.buffer
self.screen_encoding = vim.eval('&fileencoding')
def read(self, timeout=1, set_cursor=True, return_output=False, update_buffer=True):
""" Read from console and update Vim buffer. """
try:
stats = self.proc.get_stats()
if not stats:
return
# disable screen and buffer redraws in fast mode
if not CONQUE_FAST_MODE:
self.buffer_redraw_ct += 1
self.screen_redraw_ct += 1
update_top = 0
update_bottom = 0
lines = []
# full buffer redraw, our favorite!
#if self.buffer_redraw_ct == CONQUE_SOLE_BUFFER_REDRAW:
# self.buffer_redraw_ct = 0
# update_top = 0
# update_bottom = stats['top_offset'] + self.lines
# (lines, attributes) = self.proc.read(update_top, update_bottom)
# if return_output:
# output = self.get_new_output(lines, update_top, stats)
# if update_buffer:
# for i in range(update_top, update_bottom + 1):
# if CONQUE_FAST_MODE:
# self.plain_text(i, lines[i], None, stats)
# else:
# self.plain_text(i, lines[i], attributes[i], stats)
# full screen redraw
if stats['cursor_y'] + 1 != self.l or stats['top_offset'] != self.window_top or self.screen_redraw_ct >= CONQUE_SOLE_SCREEN_REDRAW:
self.screen_redraw_ct = 0
update_top = self.window_top
update_bottom = max([stats['top_offset'] + self.lines + 1, stats['cursor_y']])
(lines, attributes) = self.proc.read(update_top, update_bottom - update_top + 1)
if return_output:
output = self.get_new_output(lines, update_top, stats)
if update_buffer:
for i in range(update_top, update_bottom + 1):
if CONQUE_FAST_MODE:
self.plain_text(i, lines[i - update_top], None, stats)
else:
self.plain_text(i, lines[i - update_top], attributes[i - update_top], stats)
# single line redraw
else:
update_top = stats['cursor_y']
(lines, attributes) = self.proc.read(update_top, 1)
if return_output:
output = self.get_new_output(lines, update_top, stats)
if update_buffer:
if lines[0].rstrip() != u(self.buffer[update_top].rstrip()):
if CONQUE_FAST_MODE:
self.plain_text(update_top, lines[0], None, stats)
else:
self.plain_text(update_top, lines[0], attributes[0], stats)
# reset current position
self.window_top = stats['top_offset']
self.l = stats['cursor_y'] + 1
self.c = stats['cursor_x'] + 1
# reposition cursor if this seems plausible
if set_cursor:
self.set_cursor(self.l, self.c)
if return_output:
return output
except:
pass
def get_new_output(self, lines, update_top, stats):
""" Calculate the "new" output from this read. Fake but useful """
if not (stats['cursor_y'] + 1 > self.l or (stats['cursor_y'] + 1 == self.l and stats['cursor_x'] + 1 > self.c)):
return ""
try:
num_to_return = stats['cursor_y'] - self.l + 2
lines = lines[self.l - update_top - 1:]
new_output = []
# first line
new_output.append(lines[0][self.c - 1:].rstrip())
# the rest
for i in range(1, num_to_return):
new_output.append(lines[i].rstrip())
except:
pass
return "\n".join(new_output)
def plain_text(self, line_nr, text, attributes, stats):
""" Write plain text to Vim buffer. """
# handle line offset
line_nr += self.offset
self.l = line_nr + 1
# remove trailing whitespace
text = text.rstrip()
# if we're using concealed text for color, then s- is weird
if self.color_mode == 'conceal':
text = self.add_conceal_color(text, attributes, stats, line_nr)
# deal with character encoding
if CONQUE_PYTHON_VERSION == 2:
val = text.encode(self.screen_encoding)
else:
# XXX / Vim's python3 interface doesn't accept bytes object
val = str(text)
# update vim buffer
if len(self.buffer) <= line_nr:
self.buffer.append(val)
else:
self.buffer[line_nr] = val
if self.enable_colors and not self.color_mode == 'conceal' and line_nr > self.l - CONQUE_MAX_SYNTAX_LINES:
relevant = attributes[0:len(text)]
if line_nr not in self.attribute_cache or self.attribute_cache[line_nr] != relevant:
self.do_color(attributes=relevant, stats=stats)
self.attribute_cache[line_nr] = relevant
def add_conceal_color(self, text, attributes, stats, line_nr):
""" Add 'conceal' color strings to output text """
# stop here if coloration is disabled
if not self.enable_colors:
return text
# if no colors for this line, clear everything out
if len(attributes) == 0 or attributes == u(chr(stats['default_attribute'])) * len(attributes):
return text
new_text = ''
self.color_conceals[line_nr] = []
attribute_chunks = CONQUE_WIN32_REGEX_ATTR.findall(attributes)
offset = 0
ends = []
for attr in attribute_chunks:
attr_num = ord(attr[1])
ends = []
if attr_num != stats['default_attribute']:
color = self.translate_color(attr_num)
new_text += chr(27) + 'sf' + color['fg_code'] + ';'
ends.append(chr(27) + 'ef' + color['fg_code'] + ';')
self.color_conceals[line_nr].append(offset)
if attr_num > 15:
new_text += chr(27) + 'sb' + color['bg_code'] + ';'
ends.append(chr(27) + 'eb' + color['bg_code'] + ';')
self.color_conceals[line_nr].append(offset)
new_text += text[offset:offset + len(attr[0])]
# close color regions
ends.reverse()
for i in range(0, len(ends)):
self.color_conceals[line_nr].append(len(new_text))
new_text += ends[i]
offset += len(attr[0])
return new_text
def do_color(self, start=0, end=0, attributes='', stats=None):
""" Convert Windows console attributes into Vim syntax highlighting """
# if no colors for this line, clear everything out
if len(attributes) == 0 or attributes == u(chr(stats['default_attribute'])) * len(attributes):
self.color_changes = {}
self.apply_color(1, len(attributes), self.l)
return
attribute_chunks = CONQUE_WIN32_REGEX_ATTR.findall(attributes)
offset = 0
for attr in attribute_chunks:
attr_num = ord(attr[1])
if attr_num != stats['default_attribute']:
self.color_changes = self.translate_color(attr_num)
self.apply_color(offset + 1, offset + len(attr[0]) + 1, self.l)
offset += len(attr[0])
def translate_color(self, attr):
""" Convert Windows console attributes into RGB colors """
# check for cached color
if attr in self.color_cache:
return self.color_cache[attr]
# convert attribute integer to bit string
bit_str = bin(attr)
bit_str = bit_str.replace('0b', '')
# slice foreground and background portions of bit string
fg = bit_str[-4:].rjust(4, '0')
bg = bit_str[-8:-4].rjust(4, '0')
# ok, first create foreground #rbg
red = int(fg[1]) * 204 + int(fg[0]) * int(fg[1]) * 51
green = int(fg[2]) * 204 + int(fg[0]) * int(fg[2]) * 51
blue = int(fg[3]) * 204 + int(fg[0]) * int(fg[3]) * 51
fg_str = "#%02x%02x%02x" % (red, green, blue)
fg_code = "%02x%02x%02x" % (red, green, blue)
fg_code = fg_code[0] + fg_code[2] + fg_code[4]
# ok, first create foreground #rbg
red = int(bg[1]) * 204 + int(bg[0]) * int(bg[1]) * 51
green = int(bg[2]) * 204 + int(bg[0]) * int(bg[2]) * 51
blue = int(bg[3]) * 204 + int(bg[0]) * int(bg[3]) * 51
bg_str = "#%02x%02x%02x" % (red, green, blue)
bg_code = "%02x%02x%02x" % (red, green, blue)
bg_code = bg_code[0] + bg_code[2] + bg_code[4]
# build value for color_changes
color = {'guifg': fg_str, 'guibg': bg_str}
if self.color_mode == 'conceal':
color['fg_code'] = fg_code
color['bg_code'] = bg_code
self.color_cache[attr] = color
return color
def write_vk(self, vk_code):
""" write virtual key code to shared memory using proprietary escape seq """
self.proc.write_vk(vk_code)
def update_window_size(self):
""" Resize underlying console if Vim buffer size has changed """
if vim.current.window.width != self.columns or vim.current.window.height != self.lines:
# reset all window size attributes to default
self.columns = vim.current.window.width
self.lines = vim.current.window.height
self.working_columns = vim.current.window.width
self.working_lines = vim.current.window.height
self.bottom = vim.current.window.height
self.proc.window_resize(vim.current.window.height, vim.current.window.width)
def set_cursor(self, line, column):
""" Update cursor position in Vim buffer """
# handle offset
line += self.offset
# shift cursor position to handle concealed text
if self.enable_colors and self.color_mode == 'conceal':
if line - 1 in self.color_conceals:
for c in self.color_conceals[line - 1]:
if c < column:
column += 7
else:
break
# figure out line
buffer_line = line
if buffer_line > len(self.buffer):
for l in range(len(self.buffer) - 1, buffer_line):
self.buffer.append('')
# figure out column
real_column = column
if len(self.buffer[buffer_line - 1]) < real_column:
self.buffer[buffer_line - 1] = self.buffer[buffer_line - 1] + ' ' * (real_column - len(self.buffer[buffer_line - 1]))
# python version is occasionally grumpy
try:
vim.current.window.cursor = (buffer_line, real_column - 1)
except:
vim.command('call cursor(' + str(buffer_line) + ', ' + str(real_column) + ')')
def idle(self):
""" go into idle mode """
self.proc.idle()
def resume(self):
""" resume from idle mode """
self.proc.resume()
def close(self):
""" end console subprocess """
self.proc.close()
def abort(self):
""" end subprocess forcefully """
self.proc.close()
def get_buffer_line(self, line):
""" get buffer line """
return line
# vim:foldmethod=marker

View File

@ -0,0 +1,183 @@
# FILE: autoload/conque_term/conque_sole_communicator.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2011-09-02
# VERSION: 2.3, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2011 Nico Raffo
#
# MIT License
#
# 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.
"""
ConqueSoleCommunicator
This script will create a new Windows console and start the requested program
inside of it. This process is launched independently from the parent Vim
program, so it has no access to the vim module.
The main loop in this script reads data from the console and syncs it onto
blocks of memory shared with the Vim process. In this way the Vim process
and this script can communicate with each other.
"""
import time
import sys
from conque_globals import *
from conque_win32_util import *
from conque_sole_subprocess import *
from conque_sole_shared_memory import *
##############################################################
# only run if this file was run directly
if __name__ == '__main__':
# attempt to catch ALL exceptions to fend of zombies
try:
# simple arg validation
if len(sys.argv) < 5:
exit()
# maximum time this thing reads. 0 means no limit. Only for testing.
max_loops = 0
# read interval, in seconds
sleep_time = 0.01
# idle read interval, in seconds
idle_sleep_time = 0.10
# are we idled?
is_idle = False
# mem key
mem_key = sys.argv[1]
# console width
console_width = int(sys.argv[2])
# console height
console_height = int(sys.argv[3])
# code page
code_page = int(sys.argv[4])
# code page
fast_mode = int(sys.argv[5])
# the actual subprocess to run
cmd_line = " ".join(sys.argv[6:])
# width and height
options = {'LINES': console_height, 'COLUMNS': console_width, 'CODE_PAGE': code_page, 'FAST_MODE': fast_mode}
# set initial idle status
shm_command = ConqueSoleSharedMemory(CONQUE_SOLE_COMMANDS_SIZE, 'command', mem_key, serialize=True)
shm_command.create('write')
cmd = shm_command.read()
if cmd:
if cmd['cmd'] == 'idle':
is_idle = True
shm_command.clear()
##############################################################
# Create the subprocess
proc = ConqueSoleSubprocess()
res = proc.open(cmd_line, mem_key, options)
if not res:
exit()
##############################################################
# main loop!
loops = 0
while True:
# check for idle/resume
if is_idle or loops % 25 == 0:
# check process health
if not proc.is_alive():
proc.close()
break
# check for change in buffer focus
cmd = shm_command.read()
if cmd:
if cmd['cmd'] == 'idle':
is_idle = True
shm_command.clear()
elif cmd['cmd'] == 'resume':
is_idle = False
shm_command.clear()
# sleep between loops if moderation is requested
if sleep_time > 0:
if is_idle:
time.sleep(idle_sleep_time)
else:
time.sleep(sleep_time)
# write, read, etc
proc.write()
proc.read()
# increment loops, and exit if max has been reached
loops += 1
if max_loops and loops >= max_loops:
break
##############################################################
# all done!
proc.close()
# if an exception was thrown, croak
except:
proc.close()
# vim:foldmethod=marker

View File

@ -0,0 +1,210 @@
# FILE: autoload/conque_term/conque_sole_shared_memory.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2011-09-02
# VERSION: 2.3, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2011 Nico Raffo
#
# MIT License
#
# 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.
"""
Wrapper class for shared memory between Windows python processes
Adds a small amount of functionality to the standard mmap module.
"""
import mmap
import sys
# PYTHON VERSION
CONQUE_PYTHON_VERSION = sys.version_info[0]
if CONQUE_PYTHON_VERSION == 2:
import cPickle as pickle
else:
import pickle
class ConqueSoleSharedMemory():
# is the data being stored not fixed length
fixed_length = False
# maximum number of bytes per character, for fixed width blocks
char_width = 1
# fill memory with this character when clearing and fixed_length is true
FILL_CHAR = None
# serialize and unserialize data automatically
serialize = False
# size of shared memory, in bytes / chars
mem_size = None
# size of shared memory, in bytes / chars
mem_type = None
# unique key, so multiple console instances are possible
mem_key = None
# mmap instance
shm = None
# character encoding, dammit
encoding = 'utf-8'
# pickle terminator
TERMINATOR = None
def __init__(self, mem_size, mem_type, mem_key, fixed_length=False, fill_char=' ', serialize=False, encoding='utf-8'):
""" Initialize new shared memory block instance
Arguments:
mem_size -- Memory size in characters, depends on encoding argument to calcuate byte size
mem_type -- Label to identify what will be stored
mem_key -- Unique, probably random key to identify this block
fixed_length -- If set to true, assume the data stored will always fill the memory size
fill_char -- Initialize memory block with this character, only really helpful with fixed_length blocks
serialize -- Automatically serialize data passed to write. Allows storing non-byte data
encoding -- Character encoding to use when storing character data
"""
self.mem_size = mem_size
self.mem_type = mem_type
self.mem_key = mem_key
self.fixed_length = fixed_length
self.fill_char = fill_char
self.serialize = serialize
self.encoding = encoding
self.TERMINATOR = str(chr(0)).encode(self.encoding)
if CONQUE_PYTHON_VERSION == 3:
self.FILL_CHAR = fill_char
else:
self.FILL_CHAR = unicode(fill_char)
if fixed_length and encoding == 'utf-8':
self.char_width = 4
def create(self, access='write'):
""" Create a new block of shared memory using the mmap module. """
if access == 'write':
mmap_access = mmap.ACCESS_WRITE
else:
mmap_access = mmap.ACCESS_READ
name = "conque_%s_%s" % (self.mem_type, self.mem_key)
self.shm = mmap.mmap(0, self.mem_size * self.char_width, name, mmap_access)
if not self.shm:
return False
else:
return True
def read(self, chars=1, start=0):
""" Read data from shared memory.
If this is a fixed length block, read 'chars' characters from memory.
Otherwise read up until the TERMINATOR character (null byte).
If this memory is serialized, unserialize it automatically.
"""
# go to start position
self.shm.seek(start * self.char_width)
if self.fixed_length:
chars = chars * self.char_width
else:
chars = self.shm.find(self.TERMINATOR)
if chars == 0:
return ''
shm_str = self.shm.read(chars)
# return unpickled byte object
if self.serialize:
return pickle.loads(shm_str)
# decode byes in python 3
if CONQUE_PYTHON_VERSION == 3:
return str(shm_str, self.encoding)
# encoding
if self.encoding != 'ascii':
shm_str = unicode(shm_str, self.encoding)
return shm_str
def write(self, text, start=0):
""" Write data to memory.
If memory is fixed length, simply write the 'text' characters at 'start' position.
Otherwise write 'text' characters and append a null character.
If memory is serializable, do so first.
"""
# simple scenario, let pickle create bytes
if self.serialize:
if CONQUE_PYTHON_VERSION == 3:
tb = pickle.dumps(text, 0)
else:
tb = pickle.dumps(text, 0).encode(self.encoding)
else:
tb = text.encode(self.encoding, 'replace')
# write to memory
self.shm.seek(start * self.char_width)
if self.fixed_length:
self.shm.write(tb)
else:
self.shm.write(tb + self.TERMINATOR)
def clear(self, start=0):
""" Clear memory block using self.fill_char. """
self.shm.seek(start)
if self.fixed_length:
self.shm.write(str(self.fill_char * self.mem_size * self.char_width).encode(self.encoding))
else:
self.shm.write(self.TERMINATOR)
def close(self):
""" Close/destroy memory block. """
self.shm.close()

View File

@ -0,0 +1,762 @@
# FILE: autoload/conque_term/conque_sole_subprocess.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2011-09-02
# VERSION: 2.3, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2011 Nico Raffo
#
# MIT License
#
# 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.
""" ConqueSoleSubprocess
Creates a new subprocess with it's own (hidden) console window.
Mirrors console window text onto a block of shared memory (mmap), along with
text attribute data. Also handles translation of text input into the format
Windows console expects.
Sample Usage:
sh = ConqueSoleSubprocess()
sh.open("cmd.exe", "unique_str")
shm_in = ConqueSoleSharedMemory(mem_key = "unique_str", mem_type = "input", ...)
shm_out = ConqueSoleSharedMemory(mem_key = "unique_str", mem_type = "output", ...)
output = shm_out.read(...)
shm_in.write("dir\r")
output = shm_out.read(...)
"""
import time
import re
import os
import ctypes
from conque_globals import *
from conque_win32_util import *
from conque_sole_shared_memory import *
class ConqueSoleSubprocess():
# subprocess handle and pid
handle = None
pid = None
# input / output handles
stdin = None
stdout = None
# size of console window
window_width = 160
window_height = 40
# max lines for the console buffer
buffer_width = 160
buffer_height = 100
# keep track of the buffer number at the top of the window
top = 0
line_offset = 0
# buffer height is CONQUE_SOLE_BUFFER_LENGTH * output_blocks
output_blocks = 1
# cursor position
cursor_line = 0
cursor_col = 0
# console data, array of lines
data = []
# console attribute data, array of array of int
attributes = []
attribute_cache = {}
# default attribute
default_attribute = 7
# shared memory objects
shm_input = None
shm_output = None
shm_attributes = None
shm_stats = None
shm_command = None
shm_rescroll = None
shm_resize = None
# are we still a valid process?
is_alive = True
# running in fast mode
fast_mode = 0
# used for periodic execution of screen and memory redrawing
screen_redraw_ct = 0
mem_redraw_ct = 0
def open(self, cmd, mem_key, options={}):
""" Create subproccess running in hidden console window. """
self.reset = True
try:
# if we're already attached to a console, then unattach
try:
ctypes.windll.kernel32.FreeConsole()
except:
pass
# set buffer height
self.buffer_height = CONQUE_SOLE_BUFFER_LENGTH
if 'LINES' in options and 'COLUMNS' in options:
self.window_width = options['COLUMNS']
self.window_height = options['LINES']
self.buffer_width = options['COLUMNS']
# fast mode
self.fast_mode = options['FAST_MODE']
# console window options
si = STARTUPINFO()
# hide window
si.dwFlags |= STARTF_USESHOWWINDOW
si.wShowWindow = SW_HIDE
#si.wShowWindow = SW_MINIMIZE
# process options
flags = NORMAL_PRIORITY_CLASS | CREATE_NEW_PROCESS_GROUP | CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE
# created process info
pi = PROCESS_INFORMATION()
# create the process!
res = ctypes.windll.kernel32.CreateProcessW(None, u(cmd), None, None, 0, flags, None, u('.'), ctypes.byref(si), ctypes.byref(pi))
# process info
self.pid = pi.dwProcessId
self.handle = pi.hProcess
# attach ourselves to the new console
# console is not immediately available
for i in range(10):
time.sleep(0.25)
try:
res = ctypes.windll.kernel32.AttachConsole(self.pid)
break
except:
pass
# get input / output handles
self.stdout = ctypes.windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
self.stdin = ctypes.windll.kernel32.GetStdHandle(STD_INPUT_HANDLE)
# set buffer size
size = COORD(self.buffer_width, self.buffer_height)
res = ctypes.windll.kernel32.SetConsoleScreenBufferSize(self.stdout, size)
# prev set size call needs to process
time.sleep(0.2)
# set window size
self.set_window_size(self.window_width, self.window_height)
# set utf-8 code page
if 'CODE_PAGE' in options and options['CODE_PAGE'] > 0:
if ctypes.windll.kernel32.IsValidCodePage(ctypes.c_uint(options['CODE_PAGE'])):
ctypes.windll.kernel32.SetConsoleCP(ctypes.c_uint(options['CODE_PAGE']))
ctypes.windll.kernel32.SetConsoleOutputCP(ctypes.c_uint(options['CODE_PAGE']))
# init shared memory
self.init_shared_memory(mem_key)
# init read buffers
self.tc = ctypes.create_unicode_buffer(self.buffer_width)
self.ac = ctypes.create_unicode_buffer(self.buffer_width)
return True
except:
return False
def init_shared_memory(self, mem_key):
""" Create shared memory objects. """
self.shm_input = ConqueSoleSharedMemory(CONQUE_SOLE_INPUT_SIZE, 'input', mem_key)
self.shm_input.create('write')
self.shm_input.clear()
self.shm_output = ConqueSoleSharedMemory(self.buffer_height * self.buffer_width, 'output', mem_key, True)
self.shm_output.create('write')
self.shm_output.clear()
if not self.fast_mode:
buf_info = self.get_buffer_info()
self.shm_attributes = ConqueSoleSharedMemory(self.buffer_height * self.buffer_width, 'attributes', mem_key, True, chr(buf_info.wAttributes), encoding='latin-1')
self.shm_attributes.create('write')
self.shm_attributes.clear()
self.shm_stats = ConqueSoleSharedMemory(CONQUE_SOLE_STATS_SIZE, 'stats', mem_key, serialize=True)
self.shm_stats.create('write')
self.shm_stats.clear()
self.shm_command = ConqueSoleSharedMemory(CONQUE_SOLE_COMMANDS_SIZE, 'command', mem_key, serialize=True)
self.shm_command.create('write')
self.shm_command.clear()
self.shm_resize = ConqueSoleSharedMemory(CONQUE_SOLE_RESIZE_SIZE, 'resize', mem_key, serialize=True)
self.shm_resize.create('write')
self.shm_resize.clear()
self.shm_rescroll = ConqueSoleSharedMemory(CONQUE_SOLE_RESCROLL_SIZE, 'rescroll', mem_key, serialize=True)
self.shm_rescroll.create('write')
self.shm_rescroll.clear()
return True
def check_commands(self):
""" Check for and process commands from Vim. """
cmd = self.shm_command.read()
if cmd:
# shut it all down
if cmd['cmd'] == 'close':
# clear command
self.shm_command.clear()
self.close()
return
cmd = self.shm_resize.read()
if cmd:
# clear command
self.shm_resize.clear()
# resize console
if cmd['cmd'] == 'resize':
# only change buffer width if it's larger
if cmd['data']['width'] > self.buffer_width:
self.buffer_width = cmd['data']['width']
# always change console width and height
self.window_width = cmd['data']['width']
self.window_height = cmd['data']['height']
# reset the console
buf_info = self.get_buffer_info()
self.reset_console(buf_info, add_block=False)
def read(self):
""" Read from windows console and update shared memory blocks. """
# no point really
if self.screen_redraw_ct == 0 and not self.is_alive():
stats = {'top_offset': 0, 'default_attribute': 0, 'cursor_x': 0, 'cursor_y': self.cursor_line, 'is_alive': 0}
self.shm_stats.write(stats)
return
# check for commands
self.check_commands()
# get cursor position
buf_info = self.get_buffer_info()
curs_line = buf_info.dwCursorPosition.Y
curs_col = buf_info.dwCursorPosition.X
# set update range
if curs_line != self.cursor_line or self.top != buf_info.srWindow.Top or self.screen_redraw_ct == CONQUE_SOLE_SCREEN_REDRAW:
self.screen_redraw_ct = 0
read_start = self.top
read_end = max([buf_info.srWindow.Bottom + 1, curs_line + 1])
else:
read_start = curs_line
read_end = curs_line + 1
# vars used in for loop
coord = COORD(0, 0)
chars_read = ctypes.c_int(0)
# read new data
for i in range(read_start, read_end):
coord.Y = i
res = ctypes.windll.kernel32.ReadConsoleOutputCharacterW(self.stdout, ctypes.byref(self.tc), self.buffer_width, coord, ctypes.byref(chars_read))
if not self.fast_mode:
ctypes.windll.kernel32.ReadConsoleOutputAttribute(self.stdout, ctypes.byref(self.ac), self.buffer_width, coord, ctypes.byref(chars_read))
t = self.tc.value
if not self.fast_mode:
a = self.ac.value
# add data
if i >= len(self.data):
for j in range(len(self.data), i + 1):
self.data.append('')
if not self.fast_mode:
self.attributes.append('')
self.data[i] = t
if not self.fast_mode:
self.attributes[i] = a
#for i in range(0, len(t)):
# write new output to shared memory
try:
if self.mem_redraw_ct == CONQUE_SOLE_MEM_REDRAW:
self.mem_redraw_ct = 0
for i in range(0, len(self.data)):
self.shm_output.write(text=self.data[i], start=self.buffer_width * i)
if not self.fast_mode:
self.shm_attributes.write(text=self.attributes[i], start=self.buffer_width * i)
else:
for i in range(read_start, read_end):
self.shm_output.write(text=self.data[i], start=self.buffer_width * i)
if not self.fast_mode:
self.shm_attributes.write(text=self.attributes[i], start=self.buffer_width * i)
#self.shm_output.write(text=''.join(self.data[read_start:read_end]), start=read_start * self.buffer_width)
#self.shm_attributes.write(text=''.join(self.attributes[read_start:read_end]), start=read_start * self.buffer_width)
# write cursor position to shared memory
stats = {'top_offset': buf_info.srWindow.Top, 'default_attribute': buf_info.wAttributes, 'cursor_x': curs_col, 'cursor_y': curs_line, 'is_alive': 1}
self.shm_stats.write(stats)
# adjust screen position
self.top = buf_info.srWindow.Top
self.cursor_line = curs_line
# check for reset
if curs_line > buf_info.dwSize.Y - 200:
self.reset_console(buf_info)
except:
pass
# increment redraw counters
self.screen_redraw_ct += 1
self.mem_redraw_ct += 1
return None
def reset_console(self, buf_info, add_block=True):
""" Extend the height of the current console if the cursor postion gets within 200 lines of the current size. """
# sometimes we just want to change the buffer width,
# in which case no need to add another block
if add_block:
self.output_blocks += 1
# close down old memory
self.shm_output.close()
self.shm_output = None
if not self.fast_mode:
self.shm_attributes.close()
self.shm_attributes = None
# new shared memory key
mem_key = 'mk' + str(time.time())
# reallocate memory
self.shm_output = ConqueSoleSharedMemory(self.buffer_height * self.buffer_width * self.output_blocks, 'output', mem_key, True)
self.shm_output.create('write')
self.shm_output.clear()
# backfill data
if len(self.data[0]) < self.buffer_width:
for i in range(0, len(self.data)):
self.data[i] = self.data[i] + ' ' * (self.buffer_width - len(self.data[i]))
self.shm_output.write(''.join(self.data))
if not self.fast_mode:
self.shm_attributes = ConqueSoleSharedMemory(self.buffer_height * self.buffer_width * self.output_blocks, 'attributes', mem_key, True, chr(buf_info.wAttributes), encoding='latin-1')
self.shm_attributes.create('write')
self.shm_attributes.clear()
# backfill attributes
if len(self.attributes[0]) < self.buffer_width:
for i in range(0, len(self.attributes)):
self.attributes[i] = self.attributes[i] + chr(buf_info.wAttributes) * (self.buffer_width - len(self.attributes[i]))
if not self.fast_mode:
self.shm_attributes.write(''.join(self.attributes))
# notify wrapper of new output block
self.shm_rescroll.write({'cmd': 'new_output', 'data': {'blocks': self.output_blocks, 'mem_key': mem_key}})
# set buffer size
size = COORD(X=self.buffer_width, Y=self.buffer_height * self.output_blocks)
res = ctypes.windll.kernel32.SetConsoleScreenBufferSize(self.stdout, size)
# prev set size call needs to process
time.sleep(0.2)
# set window size
self.set_window_size(self.window_width, self.window_height)
# init read buffers
self.tc = ctypes.create_unicode_buffer(self.buffer_width)
self.ac = ctypes.create_unicode_buffer(self.buffer_width)
def write(self):
""" Write text to console.
This function just parses out special sequences for special key events
and passes on the text to the plain or virtual key functions.
"""
# get input from shared mem
text = self.shm_input.read()
# nothing to do here
if text == u(''):
return
# clear input queue
self.shm_input.clear()
# split on VK codes
chunks = CONQUE_WIN32_REGEX_VK.split(text)
# if len() is one then no vks
if len(chunks) == 1:
self.write_plain(text)
return
# loop over chunks and delegate
for t in chunks:
if t == '':
continue
if CONQUE_WIN32_REGEX_VK.match(t):
self.write_vk(t[2:-2])
else:
self.write_plain(t)
def write_plain(self, text):
""" Write simple text to subprocess. """
li = INPUT_RECORD * len(text)
list_input = li()
for i in range(0, len(text)):
# create keyboard input
ke = KEY_EVENT_RECORD()
ke.bKeyDown = ctypes.c_byte(1)
ke.wRepeatCount = ctypes.c_short(1)
cnum = ord(text[i])
ke.wVirtualKeyCode = ctypes.windll.user32.VkKeyScanW(cnum)
ke.wVirtualScanCode = ctypes.c_short(ctypes.windll.user32.MapVirtualKeyW(int(cnum), 0))
if cnum > 31:
ke.uChar.UnicodeChar = uchr(cnum)
elif cnum == 3:
ctypes.windll.kernel32.GenerateConsoleCtrlEvent(0, self.pid)
ke.uChar.UnicodeChar = uchr(cnum)
ke.wVirtualKeyCode = ctypes.windll.user32.VkKeyScanW(cnum + 96)
ke.dwControlKeyState |= LEFT_CTRL_PRESSED
else:
ke.uChar.UnicodeChar = uchr(cnum)
if cnum in CONQUE_WINDOWS_VK_INV:
ke.wVirtualKeyCode = cnum
else:
ke.wVirtualKeyCode = ctypes.windll.user32.VkKeyScanW(cnum + 96)
ke.dwControlKeyState |= LEFT_CTRL_PRESSED
kc = INPUT_RECORD(KEY_EVENT)
kc.Event.KeyEvent = ke
list_input[i] = kc
# write input array
events_written = ctypes.c_int()
res = ctypes.windll.kernel32.WriteConsoleInputW(self.stdin, list_input, len(text), ctypes.byref(events_written))
def write_vk(self, vk_code):
""" Write special characters to console subprocess. """
code = None
ctrl_pressed = False
# this could be made more generic when more attributes
# other than ctrl_pressed are available
vk_attributes = vk_code.split(';')
for attr in vk_attributes:
if attr == CONQUE_VK_ATTR_CTRL_PRESSED:
ctrl_pressed = True
else:
code = attr
li = INPUT_RECORD * 1
# create keyboard input
ke = KEY_EVENT_RECORD()
ke.uChar.UnicodeChar = uchr(0)
ke.wVirtualKeyCode = ctypes.c_short(int(code))
ke.wVirtualScanCode = ctypes.c_short(ctypes.windll.user32.MapVirtualKeyW(int(code), 0))
ke.bKeyDown = ctypes.c_byte(1)
ke.wRepeatCount = ctypes.c_short(1)
# set enhanced key mode for arrow keys
if code in CONQUE_WINDOWS_VK_ENHANCED:
ke.dwControlKeyState |= ENHANCED_KEY
if ctrl_pressed:
ke.dwControlKeyState |= LEFT_CTRL_PRESSED
kc = INPUT_RECORD(KEY_EVENT)
kc.Event.KeyEvent = ke
list_input = li(kc)
# write input array
events_written = ctypes.c_int()
res = ctypes.windll.kernel32.WriteConsoleInputW(self.stdin, list_input, 1, ctypes.byref(events_written))
def close(self):
""" Close all running subproccesses """
# record status
self.is_alive = False
try:
stats = {'top_offset': 0, 'default_attribute': 0, 'cursor_x': 0, 'cursor_y': self.cursor_line, 'is_alive': 0}
self.shm_stats.write(stats)
except:
pass
pid_list = (ctypes.c_int * 10)()
num = ctypes.windll.kernel32.GetConsoleProcessList(pid_list, 10)
current_pid = os.getpid()
# kill subprocess pids
for pid in pid_list[0:num]:
if not pid:
break
# kill current pid last
if pid == current_pid:
continue
try:
self.close_pid(pid)
except:
pass
# kill this process
try:
self.close_pid(current_pid)
except:
pass
def close_pid(self, pid):
""" Terminate a single process. """
handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, 0, pid)
ctypes.windll.kernel32.TerminateProcess(handle, -1)
ctypes.windll.kernel32.CloseHandle(handle)
def is_alive(self):
""" Check process health. """
status = ctypes.windll.kernel32.WaitForSingleObject(self.handle, 1)
if status == 0:
self.is_alive = False
return self.is_alive
def get_screen_text(self):
""" Return screen data as string. """
return "\n".join(self.data)
def set_window_size(self, width, height):
""" Change Windows console size. """
# get current window size object
window_size = SMALL_RECT(0, 0, 0, 0)
# buffer info has maximum window size data
buf_info = self.get_buffer_info()
# set top left corner
window_size.Top = 0
window_size.Left = 0
# set bottom right corner
if buf_info.dwMaximumWindowSize.X < width:
window_size.Right = buf_info.dwMaximumWindowSize.X - 1
else:
window_size.Right = width - 1
if buf_info.dwMaximumWindowSize.Y < height:
window_size.Bottom = buf_info.dwMaximumWindowSize.Y - 1
else:
window_size.Bottom = height - 1
# set the window size!
res = ctypes.windll.kernel32.SetConsoleWindowInfo(self.stdout, ctypes.c_bool(True), ctypes.byref(window_size))
# reread buffer info to get final console max lines
buf_info = self.get_buffer_info()
self.window_width = buf_info.srWindow.Right + 1
self.window_height = buf_info.srWindow.Bottom + 1
def get_buffer_info(self):
""" Retrieve commonly-used buffer information. """
buf_info = CONSOLE_SCREEN_BUFFER_INFO()
ctypes.windll.kernel32.GetConsoleScreenBufferInfo(self.stdout, ctypes.byref(buf_info))
return buf_info

View File

@ -0,0 +1,278 @@
# FILE: autoload/conque_term/conque_sole_wrapper.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2011-09-02
# VERSION: 2.3, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2011 Nico Raffo
#
# MIT License
#
# 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.
"""
ConqueSoleSubprocessWrapper
Subprocess wrapper to deal with Windows insanity. Launches console based python,
which in turn launches originally requested command. Communicates with cosole
python through shared memory objects.
"""
import ctypes
import time
class ConqueSoleWrapper():
# unique key used for shared memory block names
shm_key = ''
# process info
handle = None
pid = None
# queue input in this bucket
bucket = None
# console size
lines = 24
columns = 80
# shared memory objects
shm_input = None
shm_output = None
shm_attributes = None
shm_stats = None
shm_command = None
shm_rescroll = None
shm_resize = None
# console python process
proc = None
def open(self, cmd, lines, columns, python_exe='python.exe', communicator_py='conque_sole_communicator.py', options={}):
""" Launch python.exe subprocess which will in turn launch the user's program.
Arguments:
cmd -- The user's command to run. E.g. "Powershell.exe" or "C:\Python27\Scripts\ipython.bat"
lines, columns -- The size of the console, also the size of the Vim buffer
python.exe -- The path to the python executable, typically C:\PythonXX\python.exe
communicator_py -- The path to the subprocess controller script in the user's vimfiles directory
options -- optional configuration
"""
self.lines = lines
self.columns = columns
self.bucket = u('')
# create a shm key
self.shm_key = 'mk' + str(time.time())
# python command
cmd_line = '%s "%s" %s %d %d %d %d %s' % (python_exe, communicator_py, self.shm_key, int(self.columns), int(self.lines), int(options['CODE_PAGE']), int(CONQUE_FAST_MODE), cmd)
# console window attributes
flags = NORMAL_PRIORITY_CLASS | DETACHED_PROCESS | CREATE_UNICODE_ENVIRONMENT
si = STARTUPINFO()
pi = PROCESS_INFORMATION()
# start the stupid process already
try:
res = ctypes.windll.kernel32.CreateProcessW(None, u(cmd_line), None, None, 0, flags, None, u('.'), ctypes.byref(si), ctypes.byref(pi))
except:
raise
# handle
self.pid = pi.dwProcessId
# init shared memory objects
self.init_shared_memory(self.shm_key)
def read(self, start_line, num_lines, timeout=0):
""" Read a range of console lines from shared memory.
Returns a pair of lists containing the console text and console text attributes.
"""
# emulate timeout by sleeping timeout time
if timeout > 0:
read_timeout = float(timeout) / 1000
time.sleep(read_timeout)
output = []
attributes = []
# get output
for i in range(start_line, start_line + num_lines + 1):
output.append(self.shm_output.read(self.columns, i * self.columns))
if not CONQUE_FAST_MODE:
attributes.append(self.shm_attributes.read(self.columns, i * self.columns))
return (output, attributes)
def get_stats(self):
""" Return a dictionary with current console cursor and scrolling information. """
try:
rescroll = self.shm_rescroll.read()
if rescroll != '' and rescroll != None:
self.shm_rescroll.clear()
# close down old memory
self.shm_output.close()
self.shm_output = None
if not CONQUE_FAST_MODE:
self.shm_attributes.close()
self.shm_attributes = None
# reallocate memory
self.shm_output = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns * rescroll['data']['blocks'], 'output', rescroll['data']['mem_key'], True)
self.shm_output.create('read')
if not CONQUE_FAST_MODE:
self.shm_attributes = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns * rescroll['data']['blocks'], 'attributes', rescroll['data']['mem_key'], True, encoding='latin-1')
self.shm_attributes.create('read')
stats_str = self.shm_stats.read()
if stats_str != '':
self.stats = stats_str
else:
return False
except:
return False
return self.stats
def is_alive(self):
""" Get process status. """
if not self.shm_stats:
return True
stats_str = self.shm_stats.read()
if stats_str:
return (stats_str['is_alive'])
else:
return True
def write(self, text):
""" Write input to shared memory. """
self.bucket += text
istr = self.shm_input.read()
if istr == '':
self.shm_input.write(self.bucket[:500])
self.bucket = self.bucket[500:]
def write_vk(self, vk_code):
""" Write virtual key code to shared memory using proprietary escape sequences. """
seq = u("\x1b[") + u(str(vk_code)) + u("VK")
self.write(seq)
def idle(self):
""" Write idle command to shared memory block, so subprocess controller can hibernate. """
self.shm_command.write({'cmd': 'idle', 'data': {}})
def resume(self):
""" Write resume command to shared memory block, so subprocess controller can wake up. """
self.shm_command.write({'cmd': 'resume', 'data': {}})
def close(self):
""" Shut it all down. """
self.shm_command.write({'cmd': 'close', 'data': {}})
time.sleep(0.2)
def window_resize(self, lines, columns):
""" Resize console window. """
self.lines = lines
# we don't shrink buffer width
if columns > self.columns:
self.columns = columns
self.shm_resize.write({'cmd': 'resize', 'data': {'width': columns, 'height': lines}})
def init_shared_memory(self, mem_key):
""" Create shared memory objects. """
self.shm_input = ConqueSoleSharedMemory(CONQUE_SOLE_INPUT_SIZE, 'input', mem_key)
self.shm_input.create('write')
self.shm_input.clear()
self.shm_output = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns, 'output', mem_key, True)
self.shm_output.create('write')
if not CONQUE_FAST_MODE:
self.shm_attributes = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns, 'attributes', mem_key, True, encoding='latin-1')
self.shm_attributes.create('write')
self.shm_stats = ConqueSoleSharedMemory(CONQUE_SOLE_STATS_SIZE, 'stats', mem_key, serialize=True)
self.shm_stats.create('write')
self.shm_stats.clear()
self.shm_command = ConqueSoleSharedMemory(CONQUE_SOLE_COMMANDS_SIZE, 'command', mem_key, serialize=True)
self.shm_command.create('write')
self.shm_command.clear()
self.shm_resize = ConqueSoleSharedMemory(CONQUE_SOLE_RESIZE_SIZE, 'resize', mem_key, serialize=True)
self.shm_resize.create('write')
self.shm_resize.clear()
self.shm_rescroll = ConqueSoleSharedMemory(CONQUE_SOLE_RESCROLL_SIZE, 'rescroll', mem_key, serialize=True)
self.shm_rescroll.create('write')
self.shm_rescroll.clear()
return True
# vim:foldmethod=marker

View File

@ -0,0 +1,198 @@
# FILE: autoload/conque_term/conque_subprocess.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2011-09-02
# VERSION: 2.3, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2011 Nico Raffo
#
# MIT License
#
# 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.
"""
ConqueSubprocess
Create and interact with a subprocess through a pty.
Usage:
p = ConqueSubprocess()
p.open('bash', {'TERM':'vt100'})
output = p.read()
p.write('cd ~/vim' + "\r")
p.write('ls -lha' + "\r")
output += p.read(timeout = 500)
p.close()
"""
import os
import signal
import pty
import tty
import select
import fcntl
import termios
import struct
import shlex
class ConqueSubprocess:
# process id
pid = 0
# stdout+stderr file descriptor
fd = None
def open(self, command, env={}):
""" Create subprocess using forkpty() """
# parse command
command_arr = shlex.split(command)
executable = command_arr[0]
args = command_arr
# try to fork a new pty
try:
self.pid, self.fd = pty.fork()
except:
return False
# child proc, replace with command after altering terminal attributes
if self.pid == 0:
# set requested environment variables
for k in env.keys():
os.environ[k] = env[k]
# set tty attributes
try:
attrs = tty.tcgetattr(1)
attrs[0] = attrs[0] ^ tty.IGNBRK
attrs[0] = attrs[0] | tty.BRKINT | tty.IXANY | tty.IMAXBEL
attrs[2] = attrs[2] | tty.HUPCL
attrs[3] = attrs[3] | tty.ICANON | tty.ECHO | tty.ISIG | tty.ECHOKE
attrs[6][tty.VMIN] = 1
attrs[6][tty.VTIME] = 0
tty.tcsetattr(1, tty.TCSANOW, attrs)
except:
pass
# replace this process with the subprocess
os.execvp(executable, args)
# else master, do nothing
else:
pass
def read(self, timeout=1):
""" Read from subprocess and return new output """
output = ''
read_timeout = float(timeout) / 1000
read_ct = 0
try:
# read from fd until no more output
while 1:
s_read, s_write, s_error = select.select([self.fd], [], [], read_timeout)
lines = ''
for s_fd in s_read:
try:
# increase read buffer so huge reads don't slow down
if read_ct < 10:
lines = os.read(self.fd, 32)
elif read_ct < 50:
lines = os.read(self.fd, 512)
else:
lines = os.read(self.fd, 2048)
read_ct += 1
except:
pass
output = output + lines.decode('utf-8')
if lines == '' or read_ct > 100:
break
except:
pass
return output
def write(self, input):
""" Write new input to subprocess """
try:
if CONQUE_PYTHON_VERSION == 2:
os.write(self.fd, input.encode('utf-8', 'ignore'))
else:
os.write(self.fd, bytes(input, 'utf-8'))
except:
pass
def signal(self, signum):
""" signal process """
try:
os.kill(self.pid, signum)
except:
pass
def close(self):
""" close process with sigterm signal """
self.signal(15)
def is_alive(self):
""" get process status """
p_status = True
try:
if os.waitpid(self.pid, os.WNOHANG)[0]:
p_status = False
except:
p_status = False
return p_status
def window_resize(self, lines, columns):
""" update window size in kernel, then send SIGWINCH to fg process """
try:
fcntl.ioctl(self.fd, termios.TIOCSWINSZ, struct.pack("HHHH", lines, columns, 0, 0))
os.kill(self.pid, signal.SIGWINCH)
except:
pass
# vim:foldmethod=marker

View File

@ -0,0 +1,448 @@
# FILE: autoload/conque_term/conque_win32_util.py
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
# WEBSITE: http://conque.googlecode.com
# MODIFIED: 2011-09-02
# VERSION: 2.3, for Vim 7.0
# LICENSE:
# Conque - Vim terminal/console emulator
# Copyright (C) 2009-2011 Nico Raffo
#
# MIT License
#
# 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.
""" Python constants and structures used for ctypes interaction. """
from ctypes import *
# Constants
# create process flag constants
CREATE_BREAKAWAY_FROM_JOB = 0x01000000
CREATE_DEFAULT_ERROR_MODE = 0x04000000
CREATE_NEW_CONSOLE = 0x00000010
CREATE_NEW_PROCESS_GROUP = 0x00000200
CREATE_NO_WINDOW = 0x08000000
CREATE_PROTECTED_PROCESS = 0x00040000
CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000
CREATE_SEPARATE_WOW_VDM = 0x00000800
CREATE_SHARED_WOW_VDM = 0x00001000
CREATE_SUSPENDED = 0x00000004
CREATE_UNICODE_ENVIRONMENT = 0x00000400
DETACHED_PROCESS = 0x00000008
EXTENDED_STARTUPINFO_PRESENT = 0x00080000
INHERIT_PARENT_AFFINITY = 0x00010000
# process priority constants
ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000
BELOW_NORMAL_PRIORITY_CLASS = 0x00004000
HIGH_PRIORITY_CLASS = 0x00000080
IDLE_PRIORITY_CLASS = 0x00000040
NORMAL_PRIORITY_CLASS = 0x00000020
REALTIME_PRIORITY_CLASS = 0x00000100
# startup info constants
STARTF_FORCEONFEEDBACK = 0x00000040
STARTF_FORCEOFFFEEDBACK = 0x00000080
STARTF_PREVENTPINNING = 0x00002000
STARTF_RUNFULLSCREEN = 0x00000020
STARTF_TITLEISAPPID = 0x00001000
STARTF_TITLEISLINKNAME = 0x00000800
STARTF_USECOUNTCHARS = 0x00000008
STARTF_USEFILLATTRIBUTE = 0x00000010
STARTF_USEHOTKEY = 0x00000200
STARTF_USEPOSITION = 0x00000004
STARTF_USESHOWWINDOW = 0x00000001
STARTF_USESIZE = 0x00000002
STARTF_USESTDHANDLES = 0x00000100
# show window constants
SW_FORCEMINIMIZE = 11
SW_HIDE = 0
SW_MAXIMIZE = 3
SW_MINIMIZE = 6
SW_RESTORE = 9
SW_SHOW = 5
SW_SHOWDEFAULT = 10
SW_SHOWMAXIMIZED = 3
SW_SHOWMINIMIZED = 2
SW_SHOWMINNOACTIVE = 7
SW_SHOWNA = 8
SW_SHOWNOACTIVATE = 4
SW_SHOWNORMAL = 1
# input event types
FOCUS_EVENT = 0x0010
KEY_EVENT = 0x0001
MENU_EVENT = 0x0008
MOUSE_EVENT = 0x0002
WINDOW_BUFFER_SIZE_EVENT = 0x0004
# key event modifiers
CAPSLOCK_ON = 0x0080
ENHANCED_KEY = 0x0100
LEFT_ALT_PRESSED = 0x0002
LEFT_CTRL_PRESSED = 0x0008
NUMLOCK_ON = 0x0020
RIGHT_ALT_PRESSED = 0x0001
RIGHT_CTRL_PRESSED = 0x0004
SCROLLLOCK_ON = 0x0040
SHIFT_PRESSED = 0x0010
# process access
PROCESS_CREATE_PROCESS = 0x0080
PROCESS_CREATE_THREAD = 0x0002
PROCESS_DUP_HANDLE = 0x0040
PROCESS_QUERY_INFORMATION = 0x0400
PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
PROCESS_SET_INFORMATION = 0x0200
PROCESS_SET_QUOTA = 0x0100
PROCESS_SUSPEND_RESUME = 0x0800
PROCESS_TERMINATE = 0x0001
PROCESS_VM_OPERATION = 0x0008
PROCESS_VM_READ = 0x0010
PROCESS_VM_WRITE = 0x0020
# input / output handles
STD_INPUT_HANDLE = c_ulong(-10)
STD_OUTPUT_HANDLE = c_ulong(-11)
STD_ERROR_HANDLE = c_ulong(-12)
CONQUE_WINDOWS_VK = {
'VK_LBUTTON': 0x0001,
'VK_RBUTTON': 0x0002,
'VK_CANCEL': 0x0003,
'VK_BACK': 0x0008,
'VK_TAB': 0x0009,
'VK_CLEAR': 0x000C,
'VK_RETURN': 0x0D,
'VK_SHIFT': 0x10,
'VK_CONTROL': 0x11,
'VK_MENU': 0x12,
'VK_PAUSE': 0x0013,
'VK_CAPITAL': 0x0014,
'VK_ESCAPE': 0x001B,
'VK_SPACE': 0x0020,
'VK_PRIOR': 0x0021,
'VK_NEXT': 0x0022,
'VK_END': 0x0023,
'VK_HOME': 0x0024,
'VK_LEFT': 0x0025,
'VK_UP': 0x0026,
'VK_RIGHT': 0x0027,
'VK_DOWN': 0x0028,
'VK_SELECT': 0x0029,
'VK_PRINT': 0x002A,
'VK_EXECUTE': 0x002B,
'VK_SNAPSHOT': 0x002C,
'VK_INSERT': 0x002D,
'VK_DELETE': 0x002E,
'VK_HELP': 0x002F,
'VK_0': 0x0030,
'VK_1': 0x0031,
'VK_2': 0x0032,
'VK_3': 0x0033,
'VK_4': 0x0034,
'VK_5': 0x0035,
'VK_6': 0x0036,
'VK_7': 0x0037,
'VK_8': 0x0038,
'VK_9': 0x0039,
'VK_A': 0x0041,
'VK_B': 0x0042,
'VK_C': 0x0043,
'VK_D': 0x0044,
'VK_E': 0x0045,
'VK_F': 0x0046,
'VK_G': 0x0047,
'VK_H': 0x0048,
'VK_I': 0x0049,
'VK_J': 0x004A,
'VK_K': 0x004B,
'VK_L': 0x004C,
'VK_M': 0x004D,
'VK_N': 0x004E,
'VK_O': 0x004F,
'VK_P': 0x0050,
'VK_Q': 0x0051,
'VK_R': 0x0052,
'VK_S': 0x0053,
'VK_T': 0x0054,
'VK_U': 0x0055,
'VK_V': 0x0056,
'VK_W': 0x0057,
'VK_X': 0x0058,
'VK_Y': 0x0059,
'VK_Z': 0x005A,
'VK_LWIN': 0x005B,
'VK_RWIN': 0x005C,
'VK_APPS': 0x005D,
'VK_SLEEP': 0x005F,
'VK_NUMPAD0': 0x0060,
'VK_NUMPAD1': 0x0061,
'VK_NUMPAD2': 0x0062,
'VK_NUMPAD3': 0x0063,
'VK_NUMPAD4': 0x0064,
'VK_NUMPAD5': 0x0065,
'VK_NUMPAD6': 0x0066,
'VK_NUMPAD7': 0x0067,
'VK_NUMPAD8': 0x0068,
'VK_MULTIPLY': 0x006A,
'VK_ADD': 0x006B,
'VK_SEPARATOR': 0x006C,
'VK_SUBTRACT': 0x006D,
'VK_DECIMAL': 0x006E,
'VK_DIVIDE': 0x006F,
'VK_F1': 0x0070,
'VK_F2': 0x0071,
'VK_F3': 0x0072,
'VK_F4': 0x0073,
'VK_F5': 0x0074,
'VK_F6': 0x0075,
'VK_F7': 0x0076,
'VK_F8': 0x0077,
'VK_F9': 0x0078,
'VK_F10': 0x0079,
'VK_F11': 0x007A,
'VK_F12': 0x007B,
'VK_F13': 0x007C,
'VK_F14': 0x007D,
'VK_F15': 0x007E,
'VK_F16': 0x007F,
'VK_F17': 0x0080,
'VK_F18': 0x0081,
'VK_F19': 0x0082,
'VK_F20': 0x0083,
'VK_F21': 0x0084,
'VK_F22': 0x0085,
'VK_F23': 0x0086,
'VK_F24': 0x0087,
'VK_NUMLOCK': 0x0090,
'VK_SCROLL': 0x0091,
'VK_LSHIFT': 0x00A0,
'VK_RSHIFT': 0x00A1,
'VK_LCONTROL': 0x00A2,
'VK_RCONTROL': 0x00A3,
'VK_LMENU': 0x00A4,
'VK_RMENU': 0x00A5
}
CONQUE_WINDOWS_VK_INV = dict([v, k] for k, v in CONQUE_WINDOWS_VK.items())
CONQUE_WINDOWS_VK_ENHANCED = {
str(int(CONQUE_WINDOWS_VK['VK_UP'])): 1,
str(int(CONQUE_WINDOWS_VK['VK_DOWN'])): 1,
str(int(CONQUE_WINDOWS_VK['VK_LEFT'])): 1,
str(int(CONQUE_WINDOWS_VK['VK_RIGHT'])): 1,
str(int(CONQUE_WINDOWS_VK['VK_HOME'])): 1,
str(int(CONQUE_WINDOWS_VK['VK_END'])): 1
}
# structures used for CreateProcess
# Odd types
LPBYTE = POINTER(c_ubyte)
LPTSTR = POINTER(c_char)
class STARTUPINFO(Structure):
_fields_ = [("cb", c_ulong),
("lpReserved", LPTSTR),
("lpDesktop", LPTSTR),
("lpTitle", LPTSTR),
("dwX", c_ulong),
("dwY", c_ulong),
("dwXSize", c_ulong),
("dwYSize", c_ulong),
("dwXCountChars", c_ulong),
("dwYCountChars", c_ulong),
("dwFillAttribute", c_ulong),
("dwFlags", c_ulong),
("wShowWindow", c_short),
("cbReserved2", c_short),
("lpReserved2", LPBYTE),
("hStdInput", c_void_p),
("hStdOutput", c_void_p),
("hStdError", c_void_p),]
def to_str(self):
return ''
class PROCESS_INFORMATION(Structure):
_fields_ = [("hProcess", c_void_p),
("hThread", c_void_p),
("dwProcessId", c_ulong),
("dwThreadId", c_ulong),]
def to_str(self):
return ''
class MEMORY_BASIC_INFORMATION(Structure):
_fields_ = [("BaseAddress", c_void_p),
("AllocationBase", c_void_p),
("AllocationProtect", c_ulong),
("RegionSize", c_ulong),
("State", c_ulong),
("Protect", c_ulong),
("Type", c_ulong),]
def to_str(self):
return ''
class SECURITY_ATTRIBUTES(Structure):
_fields_ = [("Length", c_ulong),
("SecDescriptor", c_void_p),
("InheritHandle", c_bool)]
def to_str(self):
return ''
class COORD(Structure):
_fields_ = [("X", c_short),
("Y", c_short)]
def to_str(self):
return ''
class SMALL_RECT(Structure):
_fields_ = [("Left", c_short),
("Top", c_short),
("Right", c_short),
("Bottom", c_short)]
def to_str(self):
return ''
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
_fields_ = [("dwSize", COORD),
("dwCursorPosition", COORD),
("wAttributes", c_short),
("srWindow", SMALL_RECT),
("dwMaximumWindowSize", COORD)]
def to_str(self):
return ''
class CHAR_UNION(Union):
_fields_ = [("UnicodeChar", c_wchar),
("AsciiChar", c_char)]
def to_str(self):
return ''
class CHAR_INFO(Structure):
_fields_ = [("Char", CHAR_UNION),
("Attributes", c_short)]
def to_str(self):
return ''
class KEY_EVENT_RECORD(Structure):
_fields_ = [("bKeyDown", c_byte),
("pad2", c_byte),
('pad1', c_short),
("wRepeatCount", c_short),
("wVirtualKeyCode", c_short),
("wVirtualScanCode", c_short),
("uChar", CHAR_UNION),
("dwControlKeyState", c_int)]
def to_str(self):
return ''
class MOUSE_EVENT_RECORD(Structure):
_fields_ = [("dwMousePosition", COORD),
("dwButtonState", c_int),
("dwControlKeyState", c_int),
("dwEventFlags", c_int)]
def to_str(self):
return ''
class WINDOW_BUFFER_SIZE_RECORD(Structure):
_fields_ = [("dwSize", COORD)]
def to_str(self):
return ''
class MENU_EVENT_RECORD(Structure):
_fields_ = [("dwCommandId", c_uint)]
def to_str(self):
return ''
class FOCUS_EVENT_RECORD(Structure):
_fields_ = [("bSetFocus", c_byte)]
def to_str(self):
return ''
class INPUT_UNION(Union):
_fields_ = [("KeyEvent", KEY_EVENT_RECORD),
("MouseEvent", MOUSE_EVENT_RECORD),
("WindowBufferSizeEvent", WINDOW_BUFFER_SIZE_RECORD),
("MenuEvent", MENU_EVENT_RECORD),
("FocusEvent", FOCUS_EVENT_RECORD)]
def to_str(self):
return ''
class INPUT_RECORD(Structure):
_fields_ = [("EventType", c_short),
("Event", INPUT_UNION)]
def to_str(self):
return ''

810
vim/autoload/csapprox.vim Normal file
View File

@ -0,0 +1,810 @@
let s:rgb = {}
let s:rgb["alice blue"] = "#f0f8ff"
let s:rgb["aliceblue"] = "#f0f8ff"
let s:rgb["antique white"] = "#faebd7"
let s:rgb["antiquewhite"] = "#faebd7"
let s:rgb["antiquewhite1"] = "#ffefdb"
let s:rgb["antiquewhite2"] = "#eedfcc"
let s:rgb["antiquewhite3"] = "#cdc0b0"
let s:rgb["antiquewhite4"] = "#8b8378"
let s:rgb["aquamarine"] = "#7fffd4"
let s:rgb["aquamarine1"] = "#7fffd4"
let s:rgb["aquamarine2"] = "#76eec6"
let s:rgb["aquamarine3"] = "#66cdaa"
let s:rgb["aquamarine4"] = "#458b74"
let s:rgb["azure"] = "#f0ffff"
let s:rgb["azure1"] = "#f0ffff"
let s:rgb["azure2"] = "#e0eeee"
let s:rgb["azure3"] = "#c1cdcd"
let s:rgb["azure4"] = "#838b8b"
let s:rgb["beige"] = "#f5f5dc"
let s:rgb["bisque"] = "#ffe4c4"
let s:rgb["bisque1"] = "#ffe4c4"
let s:rgb["bisque2"] = "#eed5b7"
let s:rgb["bisque3"] = "#cdb79e"
let s:rgb["bisque4"] = "#8b7d6b"
let s:rgb["black"] = "#000000"
let s:rgb["blanched almond"] = "#ffebcd"
let s:rgb["blanchedalmond"] = "#ffebcd"
let s:rgb["blue violet"] = "#8a2be2"
let s:rgb["blue"] = "#0000ff"
let s:rgb["blue1"] = "#0000ff"
let s:rgb["blue2"] = "#0000ee"
let s:rgb["blue3"] = "#0000cd"
let s:rgb["blue4"] = "#00008b"
let s:rgb["blueviolet"] = "#8a2be2"
let s:rgb["brown"] = "#a52a2a"
let s:rgb["brown1"] = "#ff4040"
let s:rgb["brown2"] = "#ee3b3b"
let s:rgb["brown3"] = "#cd3333"
let s:rgb["brown4"] = "#8b2323"
let s:rgb["burlywood"] = "#deb887"
let s:rgb["burlywood1"] = "#ffd39b"
let s:rgb["burlywood2"] = "#eec591"
let s:rgb["burlywood3"] = "#cdaa7d"
let s:rgb["burlywood4"] = "#8b7355"
let s:rgb["cadet blue"] = "#5f9ea0"
let s:rgb["cadetblue"] = "#5f9ea0"
let s:rgb["cadetblue1"] = "#98f5ff"
let s:rgb["cadetblue2"] = "#8ee5ee"
let s:rgb["cadetblue3"] = "#7ac5cd"
let s:rgb["cadetblue4"] = "#53868b"
let s:rgb["chartreuse"] = "#7fff00"
let s:rgb["chartreuse1"] = "#7fff00"
let s:rgb["chartreuse2"] = "#76ee00"
let s:rgb["chartreuse3"] = "#66cd00"
let s:rgb["chartreuse4"] = "#458b00"
let s:rgb["chocolate"] = "#d2691e"
let s:rgb["chocolate1"] = "#ff7f24"
let s:rgb["chocolate2"] = "#ee7621"
let s:rgb["chocolate3"] = "#cd661d"
let s:rgb["chocolate4"] = "#8b4513"
let s:rgb["coral"] = "#ff7f50"
let s:rgb["coral1"] = "#ff7256"
let s:rgb["coral2"] = "#ee6a50"
let s:rgb["coral3"] = "#cd5b45"
let s:rgb["coral4"] = "#8b3e2f"
let s:rgb["cornflower blue"] = "#6495ed"
let s:rgb["cornflowerblue"] = "#6495ed"
let s:rgb["cornsilk"] = "#fff8dc"
let s:rgb["cornsilk1"] = "#fff8dc"
let s:rgb["cornsilk2"] = "#eee8cd"
let s:rgb["cornsilk3"] = "#cdc8b1"
let s:rgb["cornsilk4"] = "#8b8878"
let s:rgb["cyan"] = "#00ffff"
let s:rgb["cyan1"] = "#00ffff"
let s:rgb["cyan2"] = "#00eeee"
let s:rgb["cyan3"] = "#00cdcd"
let s:rgb["cyan4"] = "#008b8b"
let s:rgb["dark blue"] = "#00008b"
let s:rgb["dark cyan"] = "#008b8b"
let s:rgb["dark goldenrod"] = "#b8860b"
let s:rgb["dark gray"] = "#a9a9a9"
let s:rgb["dark green"] = "#006400"
let s:rgb["dark grey"] = "#a9a9a9"
let s:rgb["dark khaki"] = "#bdb76b"
let s:rgb["dark magenta"] = "#8b008b"
let s:rgb["dark olive green"] = "#556b2f"
let s:rgb["dark orange"] = "#ff8c00"
let s:rgb["dark orchid"] = "#9932cc"
let s:rgb["dark red"] = "#8b0000"
let s:rgb["dark salmon"] = "#e9967a"
let s:rgb["dark sea green"] = "#8fbc8f"
let s:rgb["dark slate blue"] = "#483d8b"
let s:rgb["dark slate gray"] = "#2f4f4f"
let s:rgb["dark slate grey"] = "#2f4f4f"
let s:rgb["dark turquoise"] = "#00ced1"
let s:rgb["dark violet"] = "#9400d3"
let s:rgb["dark yellow"] = "#bbbb00"
let s:rgb["darkblue"] = "#00008b"
let s:rgb["darkcyan"] = "#008b8b"
let s:rgb["darkgoldenrod"] = "#b8860b"
let s:rgb["darkgoldenrod1"] = "#ffb90f"
let s:rgb["darkgoldenrod2"] = "#eead0e"
let s:rgb["darkgoldenrod3"] = "#cd950c"
let s:rgb["darkgoldenrod4"] = "#8b6508"
let s:rgb["darkgray"] = "#a9a9a9"
let s:rgb["darkgreen"] = "#006400"
let s:rgb["darkgrey"] = "#a9a9a9"
let s:rgb["darkkhaki"] = "#bdb76b"
let s:rgb["darkmagenta"] = "#8b008b"
let s:rgb["darkolivegreen"] = "#556b2f"
let s:rgb["darkolivegreen1"] = "#caff70"
let s:rgb["darkolivegreen2"] = "#bcee68"
let s:rgb["darkolivegreen3"] = "#a2cd5a"
let s:rgb["darkolivegreen4"] = "#6e8b3d"
let s:rgb["darkorange"] = "#ff8c00"
let s:rgb["darkorange1"] = "#ff7f00"
let s:rgb["darkorange2"] = "#ee7600"
let s:rgb["darkorange3"] = "#cd6600"
let s:rgb["darkorange4"] = "#8b4500"
let s:rgb["darkorchid"] = "#9932cc"
let s:rgb["darkorchid1"] = "#bf3eff"
let s:rgb["darkorchid2"] = "#b23aee"
let s:rgb["darkorchid3"] = "#9a32cd"
let s:rgb["darkorchid4"] = "#68228b"
let s:rgb["darkred"] = "#8b0000"
let s:rgb["darksalmon"] = "#e9967a"
let s:rgb["darkseagreen"] = "#8fbc8f"
let s:rgb["darkseagreen1"] = "#c1ffc1"
let s:rgb["darkseagreen2"] = "#b4eeb4"
let s:rgb["darkseagreen3"] = "#9bcd9b"
let s:rgb["darkseagreen4"] = "#698b69"
let s:rgb["darkslateblue"] = "#483d8b"
let s:rgb["darkslategray"] = "#2f4f4f"
let s:rgb["darkslategray1"] = "#97ffff"
let s:rgb["darkslategray2"] = "#8deeee"
let s:rgb["darkslategray3"] = "#79cdcd"
let s:rgb["darkslategray4"] = "#528b8b"
let s:rgb["darkslategrey"] = "#2f4f4f"
let s:rgb["darkturquoise"] = "#00ced1"
let s:rgb["darkviolet"] = "#9400d3"
let s:rgb["darkyellow"] = "#bbbb00"
let s:rgb["deep pink"] = "#ff1493"
let s:rgb["deep sky blue"] = "#00bfff"
let s:rgb["deeppink"] = "#ff1493"
let s:rgb["deeppink1"] = "#ff1493"
let s:rgb["deeppink2"] = "#ee1289"
let s:rgb["deeppink3"] = "#cd1076"
let s:rgb["deeppink4"] = "#8b0a50"
let s:rgb["deepskyblue"] = "#00bfff"
let s:rgb["deepskyblue1"] = "#00bfff"
let s:rgb["deepskyblue2"] = "#00b2ee"
let s:rgb["deepskyblue3"] = "#009acd"
let s:rgb["deepskyblue4"] = "#00688b"
let s:rgb["dim gray"] = "#696969"
let s:rgb["dim grey"] = "#696969"
let s:rgb["dimgray"] = "#696969"
let s:rgb["dimgrey"] = "#696969"
let s:rgb["dodger blue"] = "#1e90ff"
let s:rgb["dodgerblue"] = "#1e90ff"
let s:rgb["dodgerblue1"] = "#1e90ff"
let s:rgb["dodgerblue2"] = "#1c86ee"
let s:rgb["dodgerblue3"] = "#1874cd"
let s:rgb["dodgerblue4"] = "#104e8b"
let s:rgb["firebrick"] = "#b22222"
let s:rgb["firebrick1"] = "#ff3030"
let s:rgb["firebrick2"] = "#ee2c2c"
let s:rgb["firebrick3"] = "#cd2626"
let s:rgb["firebrick4"] = "#8b1a1a"
let s:rgb["floral white"] = "#fffaf0"
let s:rgb["floralwhite"] = "#fffaf0"
let s:rgb["forest green"] = "#228b22"
let s:rgb["forestgreen"] = "#228b22"
let s:rgb["gainsboro"] = "#dcdcdc"
let s:rgb["ghost white"] = "#f8f8ff"
let s:rgb["ghostwhite"] = "#f8f8ff"
let s:rgb["gold"] = "#ffd700"
let s:rgb["gold1"] = "#ffd700"
let s:rgb["gold2"] = "#eec900"
let s:rgb["gold3"] = "#cdad00"
let s:rgb["gold4"] = "#8b7500"
let s:rgb["goldenrod"] = "#daa520"
let s:rgb["goldenrod1"] = "#ffc125"
let s:rgb["goldenrod2"] = "#eeb422"
let s:rgb["goldenrod3"] = "#cd9b1d"
let s:rgb["goldenrod4"] = "#8b6914"
let s:rgb["gray"] = "#bebebe"
let s:rgb["gray0"] = "#000000"
let s:rgb["gray1"] = "#030303"
let s:rgb["gray10"] = "#1a1a1a"
let s:rgb["gray100"] = "#ffffff"
let s:rgb["gray11"] = "#1c1c1c"
let s:rgb["gray12"] = "#1f1f1f"
let s:rgb["gray13"] = "#212121"
let s:rgb["gray14"] = "#242424"
let s:rgb["gray15"] = "#262626"
let s:rgb["gray16"] = "#292929"
let s:rgb["gray17"] = "#2b2b2b"
let s:rgb["gray18"] = "#2e2e2e"
let s:rgb["gray19"] = "#303030"
let s:rgb["gray2"] = "#050505"
let s:rgb["gray20"] = "#333333"
let s:rgb["gray21"] = "#363636"
let s:rgb["gray22"] = "#383838"
let s:rgb["gray23"] = "#3b3b3b"
let s:rgb["gray24"] = "#3d3d3d"
let s:rgb["gray25"] = "#404040"
let s:rgb["gray26"] = "#424242"
let s:rgb["gray27"] = "#454545"
let s:rgb["gray28"] = "#474747"
let s:rgb["gray29"] = "#4a4a4a"
let s:rgb["gray3"] = "#080808"
let s:rgb["gray30"] = "#4d4d4d"
let s:rgb["gray31"] = "#4f4f4f"
let s:rgb["gray32"] = "#525252"
let s:rgb["gray33"] = "#545454"
let s:rgb["gray34"] = "#575757"
let s:rgb["gray35"] = "#595959"
let s:rgb["gray36"] = "#5c5c5c"
let s:rgb["gray37"] = "#5e5e5e"
let s:rgb["gray38"] = "#616161"
let s:rgb["gray39"] = "#636363"
let s:rgb["gray4"] = "#0a0a0a"
let s:rgb["gray40"] = "#666666"
let s:rgb["gray41"] = "#696969"
let s:rgb["gray42"] = "#6b6b6b"
let s:rgb["gray43"] = "#6e6e6e"
let s:rgb["gray44"] = "#707070"
let s:rgb["gray45"] = "#737373"
let s:rgb["gray46"] = "#757575"
let s:rgb["gray47"] = "#787878"
let s:rgb["gray48"] = "#7a7a7a"
let s:rgb["gray49"] = "#7d7d7d"
let s:rgb["gray5"] = "#0d0d0d"
let s:rgb["gray50"] = "#7f7f7f"
let s:rgb["gray51"] = "#828282"
let s:rgb["gray52"] = "#858585"
let s:rgb["gray53"] = "#878787"
let s:rgb["gray54"] = "#8a8a8a"
let s:rgb["gray55"] = "#8c8c8c"
let s:rgb["gray56"] = "#8f8f8f"
let s:rgb["gray57"] = "#919191"
let s:rgb["gray58"] = "#949494"
let s:rgb["gray59"] = "#969696"
let s:rgb["gray6"] = "#0f0f0f"
let s:rgb["gray60"] = "#999999"
let s:rgb["gray61"] = "#9c9c9c"
let s:rgb["gray62"] = "#9e9e9e"
let s:rgb["gray63"] = "#a1a1a1"
let s:rgb["gray64"] = "#a3a3a3"
let s:rgb["gray65"] = "#a6a6a6"
let s:rgb["gray66"] = "#a8a8a8"
let s:rgb["gray67"] = "#ababab"
let s:rgb["gray68"] = "#adadad"
let s:rgb["gray69"] = "#b0b0b0"
let s:rgb["gray7"] = "#121212"
let s:rgb["gray70"] = "#b3b3b3"
let s:rgb["gray71"] = "#b5b5b5"
let s:rgb["gray72"] = "#b8b8b8"
let s:rgb["gray73"] = "#bababa"
let s:rgb["gray74"] = "#bdbdbd"
let s:rgb["gray75"] = "#bfbfbf"
let s:rgb["gray76"] = "#c2c2c2"
let s:rgb["gray77"] = "#c4c4c4"
let s:rgb["gray78"] = "#c7c7c7"
let s:rgb["gray79"] = "#c9c9c9"
let s:rgb["gray8"] = "#141414"
let s:rgb["gray80"] = "#cccccc"
let s:rgb["gray81"] = "#cfcfcf"
let s:rgb["gray82"] = "#d1d1d1"
let s:rgb["gray83"] = "#d4d4d4"
let s:rgb["gray84"] = "#d6d6d6"
let s:rgb["gray85"] = "#d9d9d9"
let s:rgb["gray86"] = "#dbdbdb"
let s:rgb["gray87"] = "#dedede"
let s:rgb["gray88"] = "#e0e0e0"
let s:rgb["gray89"] = "#e3e3e3"
let s:rgb["gray9"] = "#171717"
let s:rgb["gray90"] = "#e5e5e5"
let s:rgb["gray91"] = "#e8e8e8"
let s:rgb["gray92"] = "#ebebeb"
let s:rgb["gray93"] = "#ededed"
let s:rgb["gray94"] = "#f0f0f0"
let s:rgb["gray95"] = "#f2f2f2"
let s:rgb["gray96"] = "#f5f5f5"
let s:rgb["gray97"] = "#f7f7f7"
let s:rgb["gray98"] = "#fafafa"
let s:rgb["gray99"] = "#fcfcfc"
let s:rgb["green yellow"] = "#adff2f"
let s:rgb["green"] = "#00ff00"
let s:rgb["green1"] = "#00ff00"
let s:rgb["green2"] = "#00ee00"
let s:rgb["green3"] = "#00cd00"
let s:rgb["green4"] = "#008b00"
let s:rgb["greenyellow"] = "#adff2f"
let s:rgb["grey"] = "#bebebe"
let s:rgb["grey0"] = "#000000"
let s:rgb["grey1"] = "#030303"
let s:rgb["grey10"] = "#1a1a1a"
let s:rgb["grey100"] = "#ffffff"
let s:rgb["grey11"] = "#1c1c1c"
let s:rgb["grey12"] = "#1f1f1f"
let s:rgb["grey13"] = "#212121"
let s:rgb["grey14"] = "#242424"
let s:rgb["grey15"] = "#262626"
let s:rgb["grey16"] = "#292929"
let s:rgb["grey17"] = "#2b2b2b"
let s:rgb["grey18"] = "#2e2e2e"
let s:rgb["grey19"] = "#303030"
let s:rgb["grey2"] = "#050505"
let s:rgb["grey20"] = "#333333"
let s:rgb["grey21"] = "#363636"
let s:rgb["grey22"] = "#383838"
let s:rgb["grey23"] = "#3b3b3b"
let s:rgb["grey24"] = "#3d3d3d"
let s:rgb["grey25"] = "#404040"
let s:rgb["grey26"] = "#424242"
let s:rgb["grey27"] = "#454545"
let s:rgb["grey28"] = "#474747"
let s:rgb["grey29"] = "#4a4a4a"
let s:rgb["grey3"] = "#080808"
let s:rgb["grey30"] = "#4d4d4d"
let s:rgb["grey31"] = "#4f4f4f"
let s:rgb["grey32"] = "#525252"
let s:rgb["grey33"] = "#545454"
let s:rgb["grey34"] = "#575757"
let s:rgb["grey35"] = "#595959"
let s:rgb["grey36"] = "#5c5c5c"
let s:rgb["grey37"] = "#5e5e5e"
let s:rgb["grey38"] = "#616161"
let s:rgb["grey39"] = "#636363"
let s:rgb["grey4"] = "#0a0a0a"
let s:rgb["grey40"] = "#666666"
let s:rgb["grey41"] = "#696969"
let s:rgb["grey42"] = "#6b6b6b"
let s:rgb["grey43"] = "#6e6e6e"
let s:rgb["grey44"] = "#707070"
let s:rgb["grey45"] = "#737373"
let s:rgb["grey46"] = "#757575"
let s:rgb["grey47"] = "#787878"
let s:rgb["grey48"] = "#7a7a7a"
let s:rgb["grey49"] = "#7d7d7d"
let s:rgb["grey5"] = "#0d0d0d"
let s:rgb["grey50"] = "#7f7f7f"
let s:rgb["grey51"] = "#828282"
let s:rgb["grey52"] = "#858585"
let s:rgb["grey53"] = "#878787"
let s:rgb["grey54"] = "#8a8a8a"
let s:rgb["grey55"] = "#8c8c8c"
let s:rgb["grey56"] = "#8f8f8f"
let s:rgb["grey57"] = "#919191"
let s:rgb["grey58"] = "#949494"
let s:rgb["grey59"] = "#969696"
let s:rgb["grey6"] = "#0f0f0f"
let s:rgb["grey60"] = "#999999"
let s:rgb["grey61"] = "#9c9c9c"
let s:rgb["grey62"] = "#9e9e9e"
let s:rgb["grey63"] = "#a1a1a1"
let s:rgb["grey64"] = "#a3a3a3"
let s:rgb["grey65"] = "#a6a6a6"
let s:rgb["grey66"] = "#a8a8a8"
let s:rgb["grey67"] = "#ababab"
let s:rgb["grey68"] = "#adadad"
let s:rgb["grey69"] = "#b0b0b0"
let s:rgb["grey7"] = "#121212"
let s:rgb["grey70"] = "#b3b3b3"
let s:rgb["grey71"] = "#b5b5b5"
let s:rgb["grey72"] = "#b8b8b8"
let s:rgb["grey73"] = "#bababa"
let s:rgb["grey74"] = "#bdbdbd"
let s:rgb["grey75"] = "#bfbfbf"
let s:rgb["grey76"] = "#c2c2c2"
let s:rgb["grey77"] = "#c4c4c4"
let s:rgb["grey78"] = "#c7c7c7"
let s:rgb["grey79"] = "#c9c9c9"
let s:rgb["grey8"] = "#141414"
let s:rgb["grey80"] = "#cccccc"
let s:rgb["grey81"] = "#cfcfcf"
let s:rgb["grey82"] = "#d1d1d1"
let s:rgb["grey83"] = "#d4d4d4"
let s:rgb["grey84"] = "#d6d6d6"
let s:rgb["grey85"] = "#d9d9d9"
let s:rgb["grey86"] = "#dbdbdb"
let s:rgb["grey87"] = "#dedede"
let s:rgb["grey88"] = "#e0e0e0"
let s:rgb["grey89"] = "#e3e3e3"
let s:rgb["grey9"] = "#171717"
let s:rgb["grey90"] = "#e5e5e5"
let s:rgb["grey91"] = "#e8e8e8"
let s:rgb["grey92"] = "#ebebeb"
let s:rgb["grey93"] = "#ededed"
let s:rgb["grey94"] = "#f0f0f0"
let s:rgb["grey95"] = "#f2f2f2"
let s:rgb["grey96"] = "#f5f5f5"
let s:rgb["grey97"] = "#f7f7f7"
let s:rgb["grey98"] = "#fafafa"
let s:rgb["grey99"] = "#fcfcfc"
let s:rgb["honeydew"] = "#f0fff0"
let s:rgb["honeydew1"] = "#f0fff0"
let s:rgb["honeydew2"] = "#e0eee0"
let s:rgb["honeydew3"] = "#c1cdc1"
let s:rgb["honeydew4"] = "#838b83"
let s:rgb["hot pink"] = "#ff69b4"
let s:rgb["hotpink"] = "#ff69b4"
let s:rgb["hotpink1"] = "#ff6eb4"
let s:rgb["hotpink2"] = "#ee6aa7"
let s:rgb["hotpink3"] = "#cd6090"
let s:rgb["hotpink4"] = "#8b3a62"
let s:rgb["indian red"] = "#cd5c5c"
let s:rgb["indianred"] = "#cd5c5c"
let s:rgb["indianred1"] = "#ff6a6a"
let s:rgb["indianred2"] = "#ee6363"
let s:rgb["indianred3"] = "#cd5555"
let s:rgb["indianred4"] = "#8b3a3a"
let s:rgb["ivory"] = "#fffff0"
let s:rgb["ivory1"] = "#fffff0"
let s:rgb["ivory2"] = "#eeeee0"
let s:rgb["ivory3"] = "#cdcdc1"
let s:rgb["ivory4"] = "#8b8b83"
let s:rgb["khaki"] = "#f0e68c"
let s:rgb["khaki1"] = "#fff68f"
let s:rgb["khaki2"] = "#eee685"
let s:rgb["khaki3"] = "#cdc673"
let s:rgb["khaki4"] = "#8b864e"
let s:rgb["lavender blush"] = "#fff0f5"
let s:rgb["lavender"] = "#e6e6fa"
let s:rgb["lavenderblush"] = "#fff0f5"
let s:rgb["lavenderblush1"] = "#fff0f5"
let s:rgb["lavenderblush2"] = "#eee0e5"
let s:rgb["lavenderblush3"] = "#cdc1c5"
let s:rgb["lavenderblush4"] = "#8b8386"
let s:rgb["lawn green"] = "#7cfc00"
let s:rgb["lawngreen"] = "#7cfc00"
let s:rgb["lemon chiffon"] = "#fffacd"
let s:rgb["lemonchiffon"] = "#fffacd"
let s:rgb["lemonchiffon1"] = "#fffacd"
let s:rgb["lemonchiffon2"] = "#eee9bf"
let s:rgb["lemonchiffon3"] = "#cdc9a5"
let s:rgb["lemonchiffon4"] = "#8b8970"
let s:rgb["light blue"] = "#add8e6"
let s:rgb["light coral"] = "#f08080"
let s:rgb["light cyan"] = "#e0ffff"
let s:rgb["light goldenrod yellow"] = "#fafad2"
let s:rgb["light goldenrod"] = "#eedd82"
let s:rgb["light gray"] = "#d3d3d3"
let s:rgb["light green"] = "#90ee90"
let s:rgb["light grey"] = "#d3d3d3"
let s:rgb["light magenta"] = "#ffbbff"
let s:rgb["light pink"] = "#ffb6c1"
let s:rgb["light red"] = "#ffbbbb"
let s:rgb["light salmon"] = "#ffa07a"
let s:rgb["light sea green"] = "#20b2aa"
let s:rgb["light sky blue"] = "#87cefa"
let s:rgb["light slate blue"] = "#8470ff"
let s:rgb["light slate gray"] = "#778899"
let s:rgb["light slate grey"] = "#778899"
let s:rgb["light steel blue"] = "#b0c4de"
let s:rgb["light yellow"] = "#ffffe0"
let s:rgb["lightblue"] = "#add8e6"
let s:rgb["lightblue1"] = "#bfefff"
let s:rgb["lightblue2"] = "#b2dfee"
let s:rgb["lightblue3"] = "#9ac0cd"
let s:rgb["lightblue4"] = "#68838b"
let s:rgb["lightcoral"] = "#f08080"
let s:rgb["lightcyan"] = "#e0ffff"
let s:rgb["lightcyan1"] = "#e0ffff"
let s:rgb["lightcyan2"] = "#d1eeee"
let s:rgb["lightcyan3"] = "#b4cdcd"
let s:rgb["lightcyan4"] = "#7a8b8b"
let s:rgb["lightgoldenrod"] = "#eedd82"
let s:rgb["lightgoldenrod1"] = "#ffec8b"
let s:rgb["lightgoldenrod2"] = "#eedc82"
let s:rgb["lightgoldenrod3"] = "#cdbe70"
let s:rgb["lightgoldenrod4"] = "#8b814c"
let s:rgb["lightgoldenrodyellow"] = "#fafad2"
let s:rgb["lightgray"] = "#d3d3d3"
let s:rgb["lightgreen"] = "#90ee90"
let s:rgb["lightgrey"] = "#d3d3d3"
let s:rgb["lightmagenta"] = "#ffbbff"
let s:rgb["lightpink"] = "#ffb6c1"
let s:rgb["lightpink1"] = "#ffaeb9"
let s:rgb["lightpink2"] = "#eea2ad"
let s:rgb["lightpink3"] = "#cd8c95"
let s:rgb["lightpink4"] = "#8b5f65"
let s:rgb["lightred"] = "#ffbbbb"
let s:rgb["lightsalmon"] = "#ffa07a"
let s:rgb["lightsalmon1"] = "#ffa07a"
let s:rgb["lightsalmon2"] = "#ee9572"
let s:rgb["lightsalmon3"] = "#cd8162"
let s:rgb["lightsalmon4"] = "#8b5742"
let s:rgb["lightseagreen"] = "#20b2aa"
let s:rgb["lightskyblue"] = "#87cefa"
let s:rgb["lightskyblue1"] = "#b0e2ff"
let s:rgb["lightskyblue2"] = "#a4d3ee"
let s:rgb["lightskyblue3"] = "#8db6cd"
let s:rgb["lightskyblue4"] = "#607b8b"
let s:rgb["lightslateblue"] = "#8470ff"
let s:rgb["lightslategray"] = "#778899"
let s:rgb["lightslategrey"] = "#778899"
let s:rgb["lightsteelblue"] = "#b0c4de"
let s:rgb["lightsteelblue1"] = "#cae1ff"
let s:rgb["lightsteelblue2"] = "#bcd2ee"
let s:rgb["lightsteelblue3"] = "#a2b5cd"
let s:rgb["lightsteelblue4"] = "#6e7b8b"
let s:rgb["lightyellow"] = "#ffffe0"
let s:rgb["lightyellow1"] = "#ffffe0"
let s:rgb["lightyellow2"] = "#eeeed1"
let s:rgb["lightyellow3"] = "#cdcdb4"
let s:rgb["lightyellow4"] = "#8b8b7a"
let s:rgb["lime green"] = "#32cd32"
let s:rgb["limegreen"] = "#32cd32"
let s:rgb["linen"] = "#faf0e6"
let s:rgb["magenta"] = "#ff00ff"
let s:rgb["magenta1"] = "#ff00ff"
let s:rgb["magenta2"] = "#ee00ee"
let s:rgb["magenta3"] = "#cd00cd"
let s:rgb["magenta4"] = "#8b008b"
let s:rgb["maroon"] = "#b03060"
let s:rgb["maroon1"] = "#ff34b3"
let s:rgb["maroon2"] = "#ee30a7"
let s:rgb["maroon3"] = "#cd2990"
let s:rgb["maroon4"] = "#8b1c62"
let s:rgb["medium aquamarine"] = "#66cdaa"
let s:rgb["medium blue"] = "#0000cd"
let s:rgb["medium orchid"] = "#ba55d3"
let s:rgb["medium purple"] = "#9370db"
let s:rgb["medium sea green"] = "#3cb371"
let s:rgb["medium slate blue"] = "#7b68ee"
let s:rgb["medium spring green"] = "#00fa9a"
let s:rgb["medium turquoise"] = "#48d1cc"
let s:rgb["medium violet red"] = "#c71585"
let s:rgb["mediumaquamarine"] = "#66cdaa"
let s:rgb["mediumblue"] = "#0000cd"
let s:rgb["mediumorchid"] = "#ba55d3"
let s:rgb["mediumorchid1"] = "#e066ff"
let s:rgb["mediumorchid2"] = "#d15fee"
let s:rgb["mediumorchid3"] = "#b452cd"
let s:rgb["mediumorchid4"] = "#7a378b"
let s:rgb["mediumpurple"] = "#9370db"
let s:rgb["mediumpurple1"] = "#ab82ff"
let s:rgb["mediumpurple2"] = "#9f79ee"
let s:rgb["mediumpurple3"] = "#8968cd"
let s:rgb["mediumpurple4"] = "#5d478b"
let s:rgb["mediumseagreen"] = "#3cb371"
let s:rgb["mediumslateblue"] = "#7b68ee"
let s:rgb["mediumspringgreen"] = "#00fa9a"
let s:rgb["mediumturquoise"] = "#48d1cc"
let s:rgb["mediumvioletred"] = "#c71585"
let s:rgb["midnight blue"] = "#191970"
let s:rgb["midnightblue"] = "#191970"
let s:rgb["mint cream"] = "#f5fffa"
let s:rgb["mintcream"] = "#f5fffa"
let s:rgb["misty rose"] = "#ffe4e1"
let s:rgb["mistyrose"] = "#ffe4e1"
let s:rgb["mistyrose1"] = "#ffe4e1"
let s:rgb["mistyrose2"] = "#eed5d2"
let s:rgb["mistyrose3"] = "#cdb7b5"
let s:rgb["mistyrose4"] = "#8b7d7b"
let s:rgb["moccasin"] = "#ffe4b5"
let s:rgb["navajo white"] = "#ffdead"
let s:rgb["navajowhite"] = "#ffdead"
let s:rgb["navajowhite1"] = "#ffdead"
let s:rgb["navajowhite2"] = "#eecfa1"
let s:rgb["navajowhite3"] = "#cdb38b"
let s:rgb["navajowhite4"] = "#8b795e"
let s:rgb["navy blue"] = "#000080"
let s:rgb["navy"] = "#000080"
let s:rgb["navyblue"] = "#000080"
let s:rgb["old lace"] = "#fdf5e6"
let s:rgb["oldlace"] = "#fdf5e6"
let s:rgb["olive drab"] = "#6b8e23"
let s:rgb["olivedrab"] = "#6b8e23"
let s:rgb["olivedrab1"] = "#c0ff3e"
let s:rgb["olivedrab2"] = "#b3ee3a"
let s:rgb["olivedrab3"] = "#9acd32"
let s:rgb["olivedrab4"] = "#698b22"
let s:rgb["orange red"] = "#ff4500"
let s:rgb["orange"] = "#ffa500"
let s:rgb["orange1"] = "#ffa500"
let s:rgb["orange2"] = "#ee9a00"
let s:rgb["orange3"] = "#cd8500"
let s:rgb["orange4"] = "#8b5a00"
let s:rgb["orangered"] = "#ff4500"
let s:rgb["orangered1"] = "#ff4500"
let s:rgb["orangered2"] = "#ee4000"
let s:rgb["orangered3"] = "#cd3700"
let s:rgb["orangered4"] = "#8b2500"
let s:rgb["orchid"] = "#da70d6"
let s:rgb["orchid1"] = "#ff83fa"
let s:rgb["orchid2"] = "#ee7ae9"
let s:rgb["orchid3"] = "#cd69c9"
let s:rgb["orchid4"] = "#8b4789"
let s:rgb["pale goldenrod"] = "#eee8aa"
let s:rgb["pale green"] = "#98fb98"
let s:rgb["pale turquoise"] = "#afeeee"
let s:rgb["pale violet red"] = "#db7093"
let s:rgb["palegoldenrod"] = "#eee8aa"
let s:rgb["palegreen"] = "#98fb98"
let s:rgb["palegreen1"] = "#9aff9a"
let s:rgb["palegreen2"] = "#90ee90"
let s:rgb["palegreen3"] = "#7ccd7c"
let s:rgb["palegreen4"] = "#548b54"
let s:rgb["paleturquoise"] = "#afeeee"
let s:rgb["paleturquoise1"] = "#bbffff"
let s:rgb["paleturquoise2"] = "#aeeeee"
let s:rgb["paleturquoise3"] = "#96cdcd"
let s:rgb["paleturquoise4"] = "#668b8b"
let s:rgb["palevioletred"] = "#db7093"
let s:rgb["palevioletred1"] = "#ff82ab"
let s:rgb["palevioletred2"] = "#ee799f"
let s:rgb["palevioletred3"] = "#cd6889"
let s:rgb["palevioletred4"] = "#8b475d"
let s:rgb["papaya whip"] = "#ffefd5"
let s:rgb["papayawhip"] = "#ffefd5"
let s:rgb["peach puff"] = "#ffdab9"
let s:rgb["peachpuff"] = "#ffdab9"
let s:rgb["peachpuff1"] = "#ffdab9"
let s:rgb["peachpuff2"] = "#eecbad"
let s:rgb["peachpuff3"] = "#cdaf95"
let s:rgb["peachpuff4"] = "#8b7765"
let s:rgb["peru"] = "#cd853f"
let s:rgb["pink"] = "#ffc0cb"
let s:rgb["pink1"] = "#ffb5c5"
let s:rgb["pink2"] = "#eea9b8"
let s:rgb["pink3"] = "#cd919e"
let s:rgb["pink4"] = "#8b636c"
let s:rgb["plum"] = "#dda0dd"
let s:rgb["plum1"] = "#ffbbff"
let s:rgb["plum2"] = "#eeaeee"
let s:rgb["plum3"] = "#cd96cd"
let s:rgb["plum4"] = "#8b668b"
let s:rgb["powder blue"] = "#b0e0e6"
let s:rgb["powderblue"] = "#b0e0e6"
let s:rgb["purple"] = "#a020f0"
let s:rgb["purple1"] = "#9b30ff"
let s:rgb["purple2"] = "#912cee"
let s:rgb["purple3"] = "#7d26cd"
let s:rgb["purple4"] = "#551a8b"
let s:rgb["red"] = "#ff0000"
let s:rgb["red1"] = "#ff0000"
let s:rgb["red2"] = "#ee0000"
let s:rgb["red3"] = "#cd0000"
let s:rgb["red4"] = "#8b0000"
let s:rgb["rosy brown"] = "#bc8f8f"
let s:rgb["rosybrown"] = "#bc8f8f"
let s:rgb["rosybrown1"] = "#ffc1c1"
let s:rgb["rosybrown2"] = "#eeb4b4"
let s:rgb["rosybrown3"] = "#cd9b9b"
let s:rgb["rosybrown4"] = "#8b6969"
let s:rgb["royal blue"] = "#4169e1"
let s:rgb["royalblue"] = "#4169e1"
let s:rgb["royalblue1"] = "#4876ff"
let s:rgb["royalblue2"] = "#436eee"
let s:rgb["royalblue3"] = "#3a5fcd"
let s:rgb["royalblue4"] = "#27408b"
let s:rgb["saddle brown"] = "#8b4513"
let s:rgb["saddlebrown"] = "#8b4513"
let s:rgb["salmon"] = "#fa8072"
let s:rgb["salmon1"] = "#ff8c69"
let s:rgb["salmon2"] = "#ee8262"
let s:rgb["salmon3"] = "#cd7054"
let s:rgb["salmon4"] = "#8b4c39"
let s:rgb["sandy brown"] = "#f4a460"
let s:rgb["sandybrown"] = "#f4a460"
let s:rgb["sea green"] = "#2e8b57"
let s:rgb["seagreen"] = "#2e8b57"
let s:rgb["seagreen1"] = "#54ff9f"
let s:rgb["seagreen2"] = "#4eee94"
let s:rgb["seagreen3"] = "#43cd80"
let s:rgb["seagreen4"] = "#2e8b57"
let s:rgb["seashell"] = "#fff5ee"
let s:rgb["seashell1"] = "#fff5ee"
let s:rgb["seashell2"] = "#eee5de"
let s:rgb["seashell3"] = "#cdc5bf"
let s:rgb["seashell4"] = "#8b8682"
let s:rgb["sienna"] = "#a0522d"
let s:rgb["sienna1"] = "#ff8247"
let s:rgb["sienna2"] = "#ee7942"
let s:rgb["sienna3"] = "#cd6839"
let s:rgb["sienna4"] = "#8b4726"
let s:rgb["sky blue"] = "#87ceeb"
let s:rgb["skyblue"] = "#87ceeb"
let s:rgb["skyblue1"] = "#87ceff"
let s:rgb["skyblue2"] = "#7ec0ee"
let s:rgb["skyblue3"] = "#6ca6cd"
let s:rgb["skyblue4"] = "#4a708b"
let s:rgb["slate blue"] = "#6a5acd"
let s:rgb["slate gray"] = "#708090"
let s:rgb["slate grey"] = "#708090"
let s:rgb["slateblue"] = "#6a5acd"
let s:rgb["slateblue1"] = "#836fff"
let s:rgb["slateblue2"] = "#7a67ee"
let s:rgb["slateblue3"] = "#6959cd"
let s:rgb["slateblue4"] = "#473c8b"
let s:rgb["slategray"] = "#708090"
let s:rgb["slategray1"] = "#c6e2ff"
let s:rgb["slategray2"] = "#b9d3ee"
let s:rgb["slategray3"] = "#9fb6cd"
let s:rgb["slategray4"] = "#6c7b8b"
let s:rgb["slategrey"] = "#708090"
let s:rgb["snow"] = "#fffafa"
let s:rgb["snow1"] = "#fffafa"
let s:rgb["snow2"] = "#eee9e9"
let s:rgb["snow3"] = "#cdc9c9"
let s:rgb["snow4"] = "#8b8989"
let s:rgb["spring green"] = "#00ff7f"
let s:rgb["springgreen"] = "#00ff7f"
let s:rgb["springgreen1"] = "#00ff7f"
let s:rgb["springgreen2"] = "#00ee76"
let s:rgb["springgreen3"] = "#00cd66"
let s:rgb["springgreen4"] = "#008b45"
let s:rgb["steel blue"] = "#4682b4"
let s:rgb["steelblue"] = "#4682b4"
let s:rgb["steelblue1"] = "#63b8ff"
let s:rgb["steelblue2"] = "#5cacee"
let s:rgb["steelblue3"] = "#4f94cd"
let s:rgb["steelblue4"] = "#36648b"
let s:rgb["tan"] = "#d2b48c"
let s:rgb["tan1"] = "#ffa54f"
let s:rgb["tan2"] = "#ee9a49"
let s:rgb["tan3"] = "#cd853f"
let s:rgb["tan4"] = "#8b5a2b"
let s:rgb["thistle"] = "#d8bfd8"
let s:rgb["thistle1"] = "#ffe1ff"
let s:rgb["thistle2"] = "#eed2ee"
let s:rgb["thistle3"] = "#cdb5cd"
let s:rgb["thistle4"] = "#8b7b8b"
let s:rgb["tomato"] = "#ff6347"
let s:rgb["tomato1"] = "#ff6347"
let s:rgb["tomato2"] = "#ee5c42"
let s:rgb["tomato3"] = "#cd4f39"
let s:rgb["tomato4"] = "#8b3626"
let s:rgb["turquoise"] = "#40e0d0"
let s:rgb["turquoise1"] = "#00f5ff"
let s:rgb["turquoise2"] = "#00e5ee"
let s:rgb["turquoise3"] = "#00c5cd"
let s:rgb["turquoise4"] = "#00868b"
let s:rgb["violet red"] = "#d02090"
let s:rgb["violet"] = "#ee82ee"
let s:rgb["violetred"] = "#d02090"
let s:rgb["violetred1"] = "#ff3e96"
let s:rgb["violetred2"] = "#ee3a8c"
let s:rgb["violetred3"] = "#cd3278"
let s:rgb["violetred4"] = "#8b2252"
let s:rgb["wheat"] = "#f5deb3"
let s:rgb["wheat1"] = "#ffe7ba"
let s:rgb["wheat2"] = "#eed8ae"
let s:rgb["wheat3"] = "#cdba96"
let s:rgb["wheat4"] = "#8b7e66"
let s:rgb["white smoke"] = "#f5f5f5"
let s:rgb["white"] = "#ffffff"
let s:rgb["whitesmoke"] = "#f5f5f5"
let s:rgb["yellow green"] = "#9acd32"
let s:rgb["yellow"] = "#ffff00"
let s:rgb["yellow1"] = "#ffff00"
let s:rgb["yellow2"] = "#eeee00"
let s:rgb["yellow3"] = "#cdcd00"
let s:rgb["yellow4"] = "#8b8b00"
let s:rgb["yellowgreen"] = "#9acd32"
if has('mac') && !has('macunix')
let s:rgb["dark gray"] = "0x808080"
let s:rgb["darkgray"] = "0x808080"
let s:rgb["dark grey"] = "0x808080"
let s:rgb["darkgrey"] = "0x808080"
let s:rgb["gray"] = "0xc0c0c0"
let s:rgb["grey"] = "0xc0c0c0"
let s:rgb["light gray"] = "0xe0e0e0"
let s:rgb["lightgray"] = "0xe0e0e0"
let s:rgb["light grey"] = "0xe0e0e0"
let s:rgb["lightgrey"] = "0xe0e0e0"
let s:rgb["dark red"] = "0x800000"
let s:rgb["darkred"] = "0x800000"
let s:rgb["red"] = "0xdd0806"
let s:rgb["light red"] = "0xffa0a0"
let s:rgb["lightred"] = "0xffa0a0"
let s:rgb["dark blue"] = "0x000080"
let s:rgb["darkblue"] = "0x000080"
let s:rgb["blue"] = "0x0000d4"
let s:rgb["light blue"] = "0xa0a0ff"
let s:rgb["lightblue"] = "0xa0a0ff"
let s:rgb["dark green"] = "0x008000"
let s:rgb["darkgreen"] = "0x008000"
let s:rgb["green"] = "0x006411"
let s:rgb["light green"] = "0xa0ffa0"
let s:rgb["lightgreen"] = "0xa0ffa0"
let s:rgb["dark cyan"] = "0x008080"
let s:rgb["darkcyan"] = "0x008080"
let s:rgb["cyan"] = "0x02abea"
let s:rgb["light cyan"] = "0xa0ffff"
let s:rgb["lightcyan"] = "0xa0ffff"
let s:rgb["dark magenta"] = "0x800080"
let s:rgb["darkmagenta"] = "0x800080"
let s:rgb["magenta"] = "0xf20884"
let s:rgb["light magenta"] = "0xf0a0f0"
let s:rgb["lightmagenta"] = "0xf0a0f0"
let s:rgb["brown"] = "0x804040"
let s:rgb["yellow"] = "0xfcf305"
let s:rgb["light yellow"] = "0xffffa0"
let s:rgb["lightyellow"] = "0xffffa0"
let s:rgb["orange"] = "0xfc8000"
let s:rgb["purple"] = "0xa020f0"
let s:rgb["slateblue"] = "0x6a5acd"
let s:rgb["violet"] = "0x8d38c9"
endif
function! csapprox#rgb()
return s:rgb
endfunction

View File

@ -0,0 +1,46 @@
let s:xterm_colors = [ 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF ]
let s:eterm_colors = [ 0x00, 0x2A, 0x55, 0x7F, 0xAA, 0xD4 ]
let s:konsole_colors = [ 0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF ]
let s:xterm_greys = [ 0x08, 0x12, 0x1C, 0x26, 0x30, 0x3A,
\ 0x44, 0x4E, 0x58, 0x62, 0x6C, 0x76,
\ 0x80, 0x8A, 0x94, 0x9E, 0xA8, 0xB2,
\ 0xBC, 0xC6, 0xD0, 0xDA, 0xE4, 0xEE ]
let s:urxvt_colors = [ 0x00, 0x8B, 0xCD, 0xFF ]
let s:urxvt_greys = [ 0x2E, 0x5C, 0x73, 0x8B,
\ 0xA2, 0xB9, 0xD0, 0xE7 ]
" Uses &term to determine which cube should be use. If &term is set to
" "xterm" or begins with "screen", the variables g:CSApprox_eterm and
" g:CSApprox_konsole can be used to select a different palette.
function! csapprox#common#PaletteType()
if &t_Co == 88
let type = 'urxvt'
elseif &term ==# 'xterm' || &term =~# '^screen' || &term==# 'builtin_gui'
if exists('g:CSApprox_konsole') && g:CSApprox_konsole
let type = 'konsole'
elseif exists('g:CSApprox_eterm') && g:CSApprox_eterm
let type = 'eterm'
else
let type = 'xterm'
endif
elseif &term =~? '^konsole'
let type = 'konsole'
elseif &term =~? '^eterm'
let type = 'eterm'
else
let type = 'xterm'
endif
return type
endfunction
" Retrieve the list of greyscale ramp colors for the current palette
function! csapprox#common#Greys()
return (&t_Co == 88 ? s:urxvt_greys : s:xterm_greys)
endfunction
" Retrieve the list of non-greyscale ramp colors for the current palette
function! csapprox#common#Colors()
return s:{csapprox#common#PaletteType()}_colors
endfunction

View File

@ -0,0 +1,66 @@
" Integer comparator used to sort the complete list of possible colors
function! s:IntCompare(i1, i2)
return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
endfunc
" Color comparator to find the nearest element to a given one in a given list
function! s:NearestElemInList(elem, list)
let len = len(a:list)
for i in range(len-1)
if (a:elem <= (a:list[i] + a:list[i+1]) / 2)
return a:list[i]
endif
endfor
return a:list[len-1]
endfunction
" Takes 3 decimal values for r, g, and b, and returns the closest cube number.
"
" This approximator considers closeness based upon the individiual components.
" For each of r, g, and b, it finds the closest cube component available on
" the cube. If the three closest matches can combine to form a valid color,
" this color is used, otherwise we repeat the search with the greys removed,
" meaning that the three new matches must make a valid color when combined.
function! csapprox#per_component#Approximate(r,g,b)
let hex = printf("%02x%02x%02x", a:r, a:g, a:b)
let colors = csapprox#common#Colors()
let greys = csapprox#common#Greys()
let type = csapprox#common#PaletteType()
if !exists('s:approximator_cache_'.type)
let s:approximator_cache_{type} = {}
endif
let rv = get(s:approximator_cache_{type}, hex, -1)
if rv != -1
return rv
endif
" Only obtain sorted list once
if !exists("s:".type."_greys_colors")
let s:{type}_greys_colors = sort(greys + colors, "s:IntCompare")
endif
let greys_colors = s:{type}_greys_colors
let r = s:NearestElemInList(a:r, greys_colors)
let g = s:NearestElemInList(a:g, greys_colors)
let b = s:NearestElemInList(a:b, greys_colors)
let len = len(colors)
if (r == g && g == b && index(greys, r) != -1)
let rv = 16 + len * len * len + index(greys, r)
else
let r = s:NearestElemInList(a:r, colors)
let g = s:NearestElemInList(a:g, colors)
let b = s:NearestElemInList(a:b, colors)
let rv = index(colors, r) * len * len
\ + index(colors, g) * len
\ + index(colors, b)
\ + 16
endif
let s:approximator_cache_{type}[hex] = rv
return rv
endfunction

View File

@ -0,0 +1,586 @@
" File: autoload/delimitMate.vim
" Version: 2.6
" Modified: 2011-01-14
" Description: This plugin provides auto-completion for quotes, parens, etc.
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
" Manual: Read ":help delimitMate".
" ============================================================================
" Utilities {{{
let delimitMate_loaded = 1
function! delimitMate#ShouldJump() "{{{
" Returns 1 if the next character is a closing delimiter.
let col = col('.')
let lcol = col('$')
let char = getline('.')[col - 1]
" Closing delimiter on the right.
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
if char == cdel
return 1
endif
endfor
" Closing delimiter with space expansion.
let nchar = getline('.')[col]
if b:_l_delimitMate_expand_space && char == " "
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
if nchar == cdel
return 1
endif
endfor
endif
" Closing delimiter with CR expansion.
let uchar = getline(line('.') + 1)[0]
if b:_l_delimitMate_expand_cr && char == ""
for cdel in b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
if uchar == cdel
return 1
endif
endfor
endif
return 0
endfunction "}}}
function! delimitMate#IsEmptyPair(str) "{{{
for pair in b:_l_delimitMate_matchpairs_list
if a:str == join( split( pair, ':' ),'' )
return 1
endif
endfor
for quote in b:_l_delimitMate_quotes_list
if a:str == quote . quote
return 1
endif
endfor
return 0
endfunction "}}}
function! delimitMate#IsCRExpansion() " {{{
let nchar = getline(line('.')-1)[-1:]
let schar = getline(line('.')+1)[:0]
let isEmpty = getline('.') == ""
if index(b:_l_delimitMate_left_delims, nchar) > -1 &&
\ index(b:_l_delimitMate_left_delims, nchar) == index(b:_l_delimitMate_right_delims, schar) &&
\ isEmpty
return 1
elseif index(b:_l_delimitMate_quotes_list, nchar) > -1 &&
\ index(b:_l_delimitMate_quotes_list, nchar) == index(b:_l_delimitMate_quotes_list, schar) &&
\ isEmpty
return 1
else
return 0
endif
endfunction " }}} delimitMate#IsCRExpansion()
function! delimitMate#IsSpaceExpansion() " {{{
let line = getline('.')
let col = col('.')-2
if col > 0
let pchar = line[col - 1]
let nchar = line[col + 2]
let isSpaces = (line[col] == line[col+1] && line[col] == " ")
if index(b:_l_delimitMate_left_delims, pchar) > -1 &&
\ index(b:_l_delimitMate_left_delims, pchar) == index(b:_l_delimitMate_right_delims, nchar) &&
\ isSpaces
return 1
elseif index(b:_l_delimitMate_quotes_list, pchar) > -1 &&
\ index(b:_l_delimitMate_quotes_list, pchar) == index(b:_l_delimitMate_quotes_list, nchar) &&
\ isSpaces
return 1
endif
endif
return 0
endfunction " }}} IsSpaceExpansion()
function! delimitMate#WithinEmptyPair() "{{{
let cur = strpart( getline('.'), col('.')-2, 2 )
return delimitMate#IsEmptyPair( cur )
endfunction "}}}
function! delimitMate#WriteBefore(str) "{{{
let len = len(a:str)
let line = getline('.')
let col = col('.')-2
if col < 0
call setline('.',line[(col+len+1):])
else
call setline('.',line[:(col)].line[(col+len+1):])
endif
return a:str
endfunction " }}}
function! delimitMate#WriteAfter(str) "{{{
let len = len(a:str)
let line = getline('.')
let col = col('.')-2
if (col) < 0
call setline('.',a:str.line)
else
call setline('.',line[:(col)].a:str.line[(col+len):])
endif
return ''
endfunction " }}}
function! delimitMate#GetSyntaxRegion(line, col) "{{{
return synIDattr(synIDtrans(synID(a:line, a:col, 1)), 'name')
endfunction " }}}
function! delimitMate#GetCurrentSyntaxRegion() "{{{
let col = col('.')
if col == col('$')
let col = col - 1
endif
return delimitMate#GetSyntaxRegion(line('.'), col)
endfunction " }}}
function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
let col = col('.')
let origin_line = getline('.')
let changed_line = strpart(origin_line, 0, col - 1) . a:char . strpart(origin_line, col - 1)
call setline('.', changed_line)
let region = delimitMate#GetSyntaxRegion(line('.'), col)
call setline('.', origin_line)
return region
endfunction "}}}
function! delimitMate#IsForbidden(char) "{{{
if b:_l_delimitMate_excluded_regions_enabled == 0
return 0
endif
"let result = index(b:_l_delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
if index(b:_l_delimitMate_excluded_regions_list, delimitMate#GetCurrentSyntaxRegion()) >= 0
"echom "Forbidden 1!"
return 1
endif
let region = delimitMate#GetCurrentSyntaxRegionIf(a:char)
"let result = index(b:_l_delimitMate_excluded_regions_list, region) >= 0
"return result || region == 'Comment'
"echom "Forbidden 2!"
return index(b:_l_delimitMate_excluded_regions_list, region) >= 0
endfunction "}}}
function! delimitMate#FlushBuffer() " {{{
let b:_l_delimitMate_buffer = []
return ''
endfunction " }}}
function! delimitMate#BalancedParens(char) "{{{
" Returns:
" = 0 => Parens balanced.
" > 0 => More opening parens.
" < 0 => More closing parens.
let line = getline('.')
let col = col('.') - 2
let col = col >= 0 ? col : 0
let list = split(line, '\zs')
let left = b:_l_delimitMate_left_delims[index(b:_l_delimitMate_right_delims, a:char)]
let right = a:char
let opening = 0
let closing = 0
" If the cursor is not at the beginning, count what's behind it.
if col > 0
" Find the first opening paren:
let start = index(list, left)
" Must be before cursor:
let start = start < col ? start : col - 1
" Now count from the first opening until the cursor, this will prevent
" extra closing parens from being counted.
let opening = count(list[start : col - 1], left)
let closing = count(list[start : col - 1], right)
" I don't care if there are more closing parens than opening parens.
let closing = closing > opening ? opening : closing
endif
" Evaluate parens from the cursor to the end:
let opening += count(list[col :], left)
let closing += count(list[col :], right)
"echom ""
"echom line
"echom col
""echom left.":".a:char
"echom string(list)
"echom string(list[start : col - 1]) . " : " . string(list[col :])
"echom opening . " - " . closing . " = " . (opening - closing)
" Return the found balance:
return opening - closing
endfunction "}}}
function! delimitMate#RmBuffer(num) " {{{
if len(b:_l_delimitMate_buffer) > 0
call remove(b:_l_delimitMate_buffer, 0, (a:num-1))
endif
return ""
endfunction " }}}
" }}}
" Doers {{{
function! delimitMate#SkipDelim(char) "{{{
if delimitMate#IsForbidden(a:char)
return a:char
endif
let col = col('.') - 1
let line = getline('.')
if col > 0
let cur = line[col]
let pre = line[col-1]
else
let cur = line[col]
let pre = ""
endif
if pre == "\\"
" Escaped character
return a:char
elseif cur == a:char
" Exit pair
"return delimitMate#WriteBefore(a:char)
return a:char . delimitMate#Del()
elseif delimitMate#IsEmptyPair( pre . a:char )
" Add closing delimiter and jump back to the middle.
call insert(b:_l_delimitMate_buffer, a:char)
return delimitMate#WriteAfter(a:char)
else
" Nothing special here, return the same character.
return a:char
endif
endfunction "}}}
function! delimitMate#ParenDelim(char) " {{{
if delimitMate#IsForbidden(a:char)
return ''
endif
" Try to balance matchpairs
if b:_l_delimitMate_balance_matchpairs &&
\ delimitMate#BalancedParens(a:char) <= 0
return ''
endif
let line = getline('.')
let col = col('.')-2
let left = b:_l_delimitMate_left_delims[index(b:_l_delimitMate_right_delims,a:char)]
let smart_matchpairs = substitute(b:_l_delimitMate_smart_matchpairs, '\\!', left, 'g')
let smart_matchpairs = substitute(smart_matchpairs, '\\#', a:char, 'g')
"echom left.':'.smart_matchpairs . ':' . matchstr(line[col+1], smart_matchpairs)
if b:_l_delimitMate_smart_matchpairs != '' &&
\ line[col+1:] =~ smart_matchpairs
return ''
elseif (col) < 0
call setline('.',a:char.line)
call insert(b:_l_delimitMate_buffer, a:char)
else
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
call setline('.',line[:(col)].a:char.line[(col+1):])
call insert(b:_l_delimitMate_buffer, a:char)
endif
return ''
endfunction " }}}
function! delimitMate#QuoteDelim(char) "{{{
if delimitMate#IsForbidden(a:char)
return a:char
endif
let line = getline('.')
let col = col('.') - 2
if line[col] == "\\"
" Seems like a escaped character, insert one quotation mark.
return a:char
elseif line[col + 1] == a:char &&
\ index(b:_l_delimitMate_nesting_quotes, a:char) < 0
" Get out of the string.
return a:char . delimitMate#Del()
elseif (line[col] =~ '\w' && a:char == "'") ||
\ (b:_l_delimitMate_smart_quotes &&
\ (line[col] =~ '\w' ||
\ line[col + 1] =~ '\w'))
" Seems like an apostrophe or a smart quote case, insert a single quote.
return a:char
elseif (line[col] == a:char && line[col + 1 ] != a:char) && b:_l_delimitMate_smart_quotes
" Seems like we have an unbalanced quote, insert one quotation mark and jump to the middle.
call insert(b:_l_delimitMate_buffer, a:char)
return delimitMate#WriteAfter(a:char)
else
" Insert a pair and jump to the middle.
call insert(b:_l_delimitMate_buffer, a:char)
call delimitMate#WriteAfter(a:char)
return a:char
endif
endfunction "}}}
function! delimitMate#JumpOut(char) "{{{
if delimitMate#IsForbidden(a:char)
return a:char
endif
let line = getline('.')
let col = col('.')-2
if line[col+1] == a:char
return a:char . delimitMate#Del()
else
return a:char
endif
endfunction " }}}
function! delimitMate#JumpAny(key) " {{{
if delimitMate#IsForbidden('')
return a:key
endif
if !delimitMate#ShouldJump()
return a:key
endif
" Let's get the character on the right.
let char = getline('.')[col('.')-1]
if char == " "
" Space expansion.
"let char = char . getline('.')[col('.')] . delimitMate#Del()
return char . getline('.')[col('.')] . delimitMate#Del() . delimitMate#Del()
"call delimitMate#RmBuffer(1)
elseif char == ""
" CR expansion.
"let char = "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
let b:_l_delimitMate_buffer = []
return "\<CR>" . getline(line('.') + 1)[0] . "\<Del>"
else
"call delimitMate#RmBuffer(1)
return char . delimitMate#Del()
endif
endfunction " delimitMate#JumpAny() }}}
function! delimitMate#JumpMany() " {{{
let line = getline('.')[col('.') - 1 : ]
let len = len(line)
let rights = ""
let found = 0
let i = 0
while i < len
let char = line[i]
if index(b:_l_delimitMate_quotes_list, char) >= 0 ||
\ index(b:_l_delimitMate_right_delims, char) >= 0
let rights .= "\<Right>"
let found = 1
elseif found == 0
let rights .= "\<Right>"
else
break
endif
let i += 1
endwhile
if found == 1
return rights
else
return ''
endif
endfunction " delimitMate#JumpMany() }}}
function! delimitMate#ExpandReturn() "{{{
if delimitMate#IsForbidden("")
return "\<CR>"
endif
if delimitMate#WithinEmptyPair()
" Expand:
call delimitMate#FlushBuffer()
"return "\<Esc>a\<CR>x\<CR>\<Esc>k$\"_xa"
return "\<CR>\<UP>\<Esc>o"
else
return "\<CR>"
endif
endfunction "}}}
function! delimitMate#ExpandSpace() "{{{
if delimitMate#IsForbidden("\<Space>")
return "\<Space>"
endif
if delimitMate#WithinEmptyPair()
" Expand:
call insert(b:_l_delimitMate_buffer, 's')
return delimitMate#WriteAfter(' ') . "\<Space>"
else
return "\<Space>"
endif
endfunction "}}}
function! delimitMate#BS() " {{{
if delimitMate#IsForbidden("")
return "\<BS>"
endif
if delimitMate#WithinEmptyPair()
"call delimitMate#RmBuffer(1)
return "\<BS>" . delimitMate#Del()
" return "\<Right>\<BS>\<BS>"
elseif delimitMate#IsSpaceExpansion()
"call delimitMate#RmBuffer(1)
return "\<BS>" . delimitMate#Del()
elseif delimitMate#IsCRExpansion()
return "\<BS>\<Del>"
else
return "\<BS>"
endif
endfunction " }}} delimitMate#BS()
function! delimitMate#Del() " {{{
if len(b:_l_delimitMate_buffer) > 0
let line = getline('.')
let col = col('.') - 2
call delimitMate#RmBuffer(1)
call setline('.', line[:col] . line[col+2:])
return ''
else
return "\<Del>"
endif
endfunction " }}}
function! delimitMate#Finish(move_back) " {{{
let len = len(b:_l_delimitMate_buffer)
if len > 0
let buffer = join(b:_l_delimitMate_buffer, '')
let len2 = len(buffer)
" Reset buffer:
let b:_l_delimitMate_buffer = []
let line = getline('.')
let col = col('.') -2
"echom 'col: ' . col . '-' . line[:col] . "|" . line[col+len+1:] . '%' . buffer
if col < 0
call setline('.', line[col+len2+1:])
else
call setline('.', line[:col] . line[col+len2+1:])
endif
let i = 1
let lefts = ""
while i <= len && a:move_back
let lefts = lefts . "\<Left>"
let i += 1
endwhile
return substitute(buffer, "s", "\<Space>", 'g') . lefts
endif
return ''
endfunction " }}}
" }}}
" Tools: {{{
function! delimitMate#TestMappings() "{{{
let options = sort(keys(delimitMate#OptionsList()))
let optoutput = ['delimitMate Report', '==================', '', '* Options: ( ) default, (g) global, (b) buffer','']
for option in options
exec 'call add(optoutput, ''('.(exists('b:delimitMate_'.option) ? 'b' : exists('g:delimitMate_'.option) ? 'g' : ' ').') delimitMate_''.option.'' = ''.string(b:_l_delimitMate_'.option.'))'
endfor
call append(line('$'), optoutput + ['--------------------',''])
" Check if mappings were set. {{{
let imaps = b:_l_delimitMate_right_delims
let imaps = imaps + ( b:_l_delimitMate_autoclose ? b:_l_delimitMate_left_delims : [] )
let imaps = imaps +
\ b:_l_delimitMate_quotes_list +
\ b:_l_delimitMate_apostrophes_list +
\ ['<BS>', '<S-BS>', '<Del>', '<S-Tab>', '<Esc>'] +
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>', '<C-G>g']
let imaps = imaps + ( b:_l_delimitMate_expand_cr ? ['<CR>'] : [] )
let imaps = imaps + ( b:_l_delimitMate_expand_space ? ['<Space>'] : [] )
let vmaps =
\ b:_l_delimitMate_right_delims +
\ b:_l_delimitMate_left_delims +
\ b:_l_delimitMate_quotes_list
let ibroken = []
for map in imaps
if maparg(map, "i") !~? 'delimitMate'
let output = ''
if map == '|'
let map = '<Bar>'
endif
redir => output | execute "verbose imap ".map | redir END
let ibroken = ibroken + [map.": is not set:"] + split(output, '\n')
endif
endfor
unlet! output
if ibroken == []
let output = ['* Mappings:', '', 'All mappings were set-up.', '--------------------', '', '']
else
let output = ['* Mappings:', ''] + ibroken + ['--------------------', '']
endif
call append('$', output+['* Showcase:', ''])
" }}}
if b:_l_delimitMate_autoclose
" {{{
for i in range(len(b:_l_delimitMate_left_delims))
exec "normal Go0\<C-D>Open: " . b:_l_delimitMate_left_delims[i]. "|"
exec "normal o0\<C-D>Delete: " . b:_l_delimitMate_left_delims[i] . "\<BS>|"
exec "normal o0\<C-D>Exit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
if b:_l_delimitMate_expand_space == 1
exec "normal o0\<C-D>Space: " . b:_l_delimitMate_left_delims[i] . " |"
exec "normal o0\<C-D>Delete space: " . b:_l_delimitMate_left_delims[i] . " \<BS>|"
endif
if b:_l_delimitMate_expand_cr == 1
exec "normal o0\<C-D>Car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>|"
exec "normal Go0\<C-D>Delete car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>0\<C-D>\<BS>|"
endif
call append(line('$'), '')
endfor
for i in range(len(b:_l_delimitMate_quotes_list))
exec "normal Go0\<C-D>Open: " . b:_l_delimitMate_quotes_list[i] . "|"
exec "normal o0\<C-D>Delete: " . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
exec "normal o0\<C-D>Exit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
if b:_l_delimitMate_expand_space == 1
exec "normal o0\<C-D>Space: " . b:_l_delimitMate_quotes_list[i] . " |"
exec "normal o0\<C-D>Delete space: " . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
endif
if b:_l_delimitMate_expand_cr == 1
exec "normal o0\<C-D>Car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
exec "normal Go0\<C-D>Delete car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|"
endif
call append(line('$'), '')
endfor
"}}}
else
"{{{
for i in range(len(b:_l_delimitMate_left_delims))
exec "normal GoOpen & close: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<BS>|"
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
if b:_l_delimitMate_expand_space == 1
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " |"
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " \<BS>|"
endif
if b:_l_delimitMate_expand_cr == 1
exec "normal oCar return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>|"
exec "normal GoDelete car return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>\<BS>|"
endif
call append(line('$'), '')
endfor
for i in range(len(b:_l_delimitMate_quotes_list))
exec "normal GoOpen & close: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
exec "normal oDelete: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
if b:_l_delimitMate_expand_space == 1
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " |"
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
endif
if b:_l_delimitMate_expand_cr == 1
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
exec "normal GoDelete car return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|"
endif
call append(line('$'), '')
endfor
endif "}}}
redir => setoptions | set | filetype | redir END
call append(line('$'), split(setoptions,"\n")
\ + ['--------------------'])
setlocal nowrap
endfunction "}}}
function! delimitMate#OptionsList() "{{{
return {'autoclose' : 1,'matchpairs': &matchpairs, 'quotes' : '" '' `', 'nesting_quotes' : [], 'expand_cr' : 0, 'expand_space' : 0, 'smart_quotes' : 1, 'smart_matchpairs' : '\w', 'balance_matchpairs' : 0, 'excluded_regions' : 'Comment', 'excluded_ft' : '', 'apostrophes' : ''}
endfunction " delimitMate#OptionsList }}}
"}}}
" vim:foldmethod=marker:foldcolumn=4

230
vim/autoload/pathogen.vim Normal file
View File

@ -0,0 +1,230 @@
" pathogen.vim - path option manipulation
" Maintainer: Tim Pope <http://tpo.pe/>
" Version: 2.0
" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
"
" For management of individually installed plugins in ~/.vim/bundle (or
" ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc
" prior to `fileype plugin indent on` is the only other setup necessary.
"
" The API is documented inline below. For maximum ease of reading,
" :set foldmethod=marker
if exists("g:loaded_pathogen") || &cp
finish
endif
let g:loaded_pathogen = 1
" Point of entry for basic default usage. Give a directory name to invoke
" pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path
" to invoke pathogen#runtime_prepend_subdirectories(). Afterwards,
" pathogen#cycle_filetype() is invoked.
function! pathogen#infect(...) abort " {{{1
let source_path = a:0 ? a:1 : 'bundle'
if source_path =~# '[\\/]'
call pathogen#runtime_prepend_subdirectories(source_path)
else
call pathogen#runtime_append_all_bundles(source_path)
endif
call pathogen#cycle_filetype()
endfunction " }}}1
" Split a path into a list.
function! pathogen#split(path) abort " {{{1
if type(a:path) == type([]) | return a:path | endif
let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
endfunction " }}}1
" Convert a list to a path.
function! pathogen#join(...) abort " {{{1
if type(a:1) == type(1) && a:1
let i = 1
let space = ' '
else
let i = 0
let space = ''
endif
let path = ""
while i < a:0
if type(a:000[i]) == type([])
let list = a:000[i]
let j = 0
while j < len(list)
let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
let path .= ',' . escaped
let j += 1
endwhile
else
let path .= "," . a:000[i]
endif
let i += 1
endwhile
return substitute(path,'^,','','')
endfunction " }}}1
" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
function! pathogen#legacyjoin(...) abort " {{{1
return call('pathogen#join',[1] + a:000)
endfunction " }}}1
" Remove duplicates from a list.
function! pathogen#uniq(list) abort " {{{1
let i = 0
let seen = {}
while i < len(a:list)
if has_key(seen,a:list[i])
call remove(a:list,i)
else
let seen[a:list[i]] = 1
let i += 1
endif
endwhile
return a:list
endfunction " }}}1
" \ on Windows unless shellslash is set, / everywhere else.
function! pathogen#separator() abort " {{{1
return !exists("+shellslash") || &shellslash ? '/' : '\'
endfunction " }}}1
" Convenience wrapper around glob() which returns a list.
function! pathogen#glob(pattern) abort " {{{1
let files = split(glob(a:pattern),"\n")
return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
endfunction "}}}1
" Like pathogen#glob(), only limit the results to directories.
function! pathogen#glob_directories(pattern) abort " {{{1
return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
endfunction "}}}1
" Turn filetype detection off and back on again if it was already enabled.
function! pathogen#cycle_filetype() " {{{1
if exists('g:did_load_filetypes')
filetype off
filetype on
endif
endfunction " }}}1
" Checks if a bundle is 'disabled'. A bundle is considered 'disabled' if
" its 'basename()' is included in g:pathogen_disabled[]' or ends in a tilde.
function! pathogen#is_disabled(path) " {{{1
if a:path =~# '\~$'
return 1
elseif !exists("g:pathogen_disabled")
return 0
endif
let sep = pathogen#separator()
return index(g:pathogen_disabled, strpart(a:path, strridx(a:path, sep)+1)) != -1
endfunction "}}}1
" Prepend all subdirectories of path to the rtp, and append all 'after'
" directories in those subdirectories.
function! pathogen#runtime_prepend_subdirectories(path) " {{{1
let sep = pathogen#separator()
let before = filter(pathogen#glob_directories(a:path.sep."*"), '!pathogen#is_disabled(v:val)')
let after = filter(pathogen#glob_directories(a:path.sep."*".sep."after"), '!pathogen#is_disabled(v:val[0:-7])')
let rtp = pathogen#split(&rtp)
let path = expand(a:path)
call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
return &rtp
endfunction " }}}1
" For each directory in rtp, check for a subdirectory named dir. If it
" exists, add all subdirectories of that subdirectory to the rtp, immediately
" after the original directory. If no argument is given, 'bundle' is used.
" Repeated calls with the same arguments are ignored.
function! pathogen#runtime_append_all_bundles(...) " {{{1
let sep = pathogen#separator()
let name = a:0 ? a:1 : 'bundle'
if "\n".s:done_bundles =~# "\\M\n".name."\n"
return ""
endif
let s:done_bundles .= name . "\n"
let list = []
for dir in pathogen#split(&rtp)
if dir =~# '\<after$'
let list += filter(pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir]
else
let list += [dir] + filter(pathogen#glob_directories(dir.sep.name.sep.'*[^~]'), '!pathogen#is_disabled(v:val)')
endif
endfor
let &rtp = pathogen#join(pathogen#uniq(list))
return 1
endfunction
let s:done_bundles = ''
" }}}1
" Invoke :helptags on all non-$VIM doc directories in runtimepath.
function! pathogen#helptags() " {{{1
let sep = pathogen#separator()
for dir in pathogen#split(&rtp)
if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.'/doc') == 2 && !empty(glob(dir.'/doc/*')) && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
helptags `=dir.'/doc'`
endif
endfor
endfunction " }}}1
command! -bar Helptags :call pathogen#helptags()
" Like findfile(), but hardcoded to use the runtimepath.
function! pathogen#rtpfindfile(file,count) "{{{1
let rtp = pathogen#join(1,pathogen#split(&rtp))
return fnamemodify(findfile(a:file,rtp,a:count),':p')
endfunction " }}}1
function! s:find(count,cmd,file,...) " {{{1
let rtp = pathogen#join(1,pathogen#split(&runtimepath))
let file = pathogen#rtpfindfile(a:file,a:count)
if file ==# ''
return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
elseif a:0
let path = file[0:-strlen(a:file)-2]
execute a:1.' `=path`'
return a:cmd.' '.fnameescape(a:file)
else
return a:cmd.' '.fnameescape(file)
endif
endfunction " }}}1
function! s:Findcomplete(A,L,P) " {{{1
let sep = pathogen#separator()
let cheats = {
\'a': 'autoload',
\'d': 'doc',
\'f': 'ftplugin',
\'i': 'indent',
\'p': 'plugin',
\'s': 'syntax'}
if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
let request = cheats[a:A[0]].a:A[1:-1]
else
let request = a:A
endif
let pattern = substitute(request,'\'.sep,'*'.sep,'g').'*'
let found = {}
for path in pathogen#split(&runtimepath)
let matches = split(glob(path.sep.pattern),"\n")
call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
call map(matches,'v:val[strlen(path)+1:-1]')
for match in matches
let found[match] = 1
endfor
endfor
return sort(keys(found))
endfunction " }}}1
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read<bang>',<q-args>)
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,'lcd')
" vim:set ft=vim ts=8 sw=2 sts=2:

View File

@ -0,0 +1,40 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Module: railmoon#ctags_util
" Purpose: some common ctags process operations
function! railmoon#ctags_util#taglist_for_file(filename, language, kinds, fields)
let language_for_ctags = a:language
if language_for_ctags == 'cpp'
let language_for_ctags = 'c++'
endif
let kind_option = "--".language_for_ctags.'-kinds=+'.a:kinds.' --language-force='.language_for_ctags
let field_option = '--fields='.a:fields
if !exists('g:ctags_exe')
let g:ctags_exe = 'ctags'
endif
let ctags_tmp_file_name = 't_m_p_f_i_l_e'
let ctags_cmd = g:ctags_exe . " -n --sort=no -f " . ctags_tmp_file_name . ' ' . kind_option . ' ' . field_option . ' ' . a:filename
call system(ctags_cmd)
let old_tags = &tags
let &tags = ctags_tmp_file_name
let ctags_tags = taglist('.*')
let &tags = old_tags
call delete(ctags_tmp_file_name)
return ctags_tags
endfunction
" returns not sorted tags for file treated as c++ file
function! railmoon#ctags_util#taglist_for_cppfile(filename)
return railmoon#ctags_util#taglist_for_file(a:filename, 'c++', 'cdefgmnpstuvx', 'sikaS')
endfunction

115
vim/autoload/railmoon/id.vim Executable file
View File

@ -0,0 +1,115 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Home: www.railmoon.com
" Module: railmoon#id
" Purpose: util functions for work with id
"
" -
" [ public library function ]
" Name: railmoon#id#acquire
" Purpose: return new unique id for widget
" [ parameters ]
" pool_name id pool name
" -
function! railmoon#id#acquire(pool_name)
if ! has_key(s:list, a:pool_name)
let s:list[a:pool_name] = []
endif
if ! has_key(s:last_id, a:pool_name)
let s:last_id[a:pool_name] = 0
endif
if empty(s:list[a:pool_name])
let s:last_id[a:pool_name] += 1
call add(s:list[a:pool_name], s:last_id[a:pool_name])
endif
let result = s:list[a:pool_name][0]
let s:list[a:pool_name] = s:list[a:pool_name][1:]
call railmoon#trace#debug('id#acquire pool = '.a:pool_name.'; id = '.result)
return result
endfunction
" -
" [ public library function ]
" Name: railmoon#id#release
" Purpose: return id to pool
" [ parameters ]
" pool_name id pool name
" id id that no longer in use
" -
function! railmoon#id#release(pool_name, id)
call railmoon#trace#debug('id#release pool = '.a:pool_name.'; id = '.a:id)
if index(s:list[a:pool_name], a:id) != -1
throw 'railmoon:id:release:already_present:'.a:id
endif
if a:id > s:last_id[a:pool_name]
throw 'railmoon:id:release:wasnt_acquired'
endif
call add(s:list[a:pool_name], a:id)
endfunction
" -
" [ internal usage ]
" store last widget id
" -
let s:last_id = {}
" -
" [ internal usage ]
" store available ids
" -
let s:list = {}
" -
" Section: unit testing
" -
let s:library_unit_test = railmoon#unit_test#create('railmoon#id test')
function! s:library_unit_test.test_acquire_release()
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 1)
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 2)
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 3)
call self.assert_equal(railmoon#id#acquire('test2_id_pool'), 1)
call self.assert_equal(railmoon#id#acquire('test2_id_pool'), 2)
call self.assert_equal(railmoon#id#acquire('test2_id_pool'), 3)
call railmoon#id#release('test_id_pool', 3)
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 3)
call railmoon#id#release('test2_id_pool', 3)
call self.assert_equal(railmoon#id#acquire('test2_id_pool'), 3)
call railmoon#id#release('test_id_pool', 2)
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 2)
call railmoon#id#release('test_id_pool', 1)
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 1)
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 4)
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 5)
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 6)
call railmoon#id#release('test_id_pool', 1)
call self.assert_equal(railmoon#id#acquire('test_id_pool'), 1)
call railmoon#id#release('test_id_pool', 1)
call railmoon#id#release('test_id_pool', 2)
call railmoon#id#release('test_id_pool', 3)
call railmoon#id#release('test_id_pool', 4)
call railmoon#id#release('test_id_pool', 5)
call railmoon#id#release('test_id_pool', 6)
endfunction
function! s:library_unit_test.test_acquire_release_case_1()
call self.assert_equal(railmoon#id#acquire('test_acquire_release_case_1'), 1)
call railmoon#id#release('test_acquire_release_case_1', 1)
endfunction
call s:library_unit_test.run()

File diff suppressed because it is too large Load Diff

724
vim/autoload/railmoon/oscan.vim Executable file
View File

@ -0,0 +1,724 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Purpose: quick move through current document or through any entities that can be tagged
if ! exists('g:ctags_exe')
if exists('Tlist_Ctags_Cmd')
let g:ctags_exe = Tlist_Ctags_Cmd
else
let g:ctags_exe = "ctags"
endif
endif
let s:previous_records_to_print_count = 1
let s:previous_suggestions_count = 1
let s:records_to_print = []
let s:suggestions = []
" -
" [ internal usage ]
" Purpose: find tag position inside line.
" tag can be with spaces. delimiter is comma.
" return list with begin and end ( start from 0 ).
" [ parameters ]
" line string
" column column that starts from 1
" -
function! s:tag_in_line_position(line, column)
let column = a:column - 1
while a:line[column] == ',' && column > 0
let column -= 1
endwhile
let begin = column
let end = column
let length = len(a:line)
while begin > 0 && a:line[begin - 1] != ','
let begin -= 1
endwhile
while end < length && a:line[end + 1] != ','
let end += 1
endwhile
return [begin, end]
endfunction
" -
" [ internal usage ]
" Purpose: find tag inside line.
" details in function above
" [ parameters ]
" line string
" column column that starts from 1
" -
function! s:tag_in_line(line, column)
let position = s:tag_in_line_position(a:line, a:column)
let result = a:line[position[0] : position[1]]
if result == ','
return ''
endif
return result
endfunction
" -
" call backs for widgets
" -
let s:plugin_window_goes_close = 0
let s:common_widget_callback = {}
function! s:common_widget_callback.on_close()
call railmoon#trace#push('common_widget_callback.on_close')
try
let s:plugin_window_goes_close = 1
call s:turnon_unexpected_plugins()
call railmoon#trace#debug('tabclose')
tabclose
call railmoon#widget#window#load_selected(s:plugin_invoker_position)
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
function! s:common_widget_callback.on_tab_leave()
call railmoon#trace#push('common_widget_callback.on_tab_leave')
try
call railmoon#trace#debug('leaving tab')
if ! s:plugin_window_goes_close
let s:plugin_window_goes_close = 1
call s:turnon_unexpected_plugins()
tabclose " TODO make sure we close right tabpage
endif
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
function! s:common_widget_callback.on_close_with_tab_page()
call railmoon#trace#push('common_widget_callback.on_close_with_tab_page')
try
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
let s:suggestion_window_callback = copy(s:common_widget_callback)
function! s:suggestion_window_callback.on_select(line)
endfunction
let s:result_window_callback = copy(s:common_widget_callback)
function! s:result_window_callback.on_select(line)
call s:result_select()
endfunction
let s:tag_enter_window_callback = copy(s:common_widget_callback)
let s:tag_enter_window_callback.edit_column = -1
let s:suggestion_window_model = {}
function! s:suggestion_window_model.get_item(i)
let item = { 'data':[], 'header':'' }
if len(s:suggestions) > 0
call add(item.data, s:suggestions[a:i] )
endif
return item
endfunction
function! s:suggestion_window_model.get_item_count()
return len(s:suggestions)
endfunction
let s:result_window_model = {}
function! s:result_window_model.get_item(i)
if len(s:records_to_print) == 0
return {'data':[], 'header':''}
endif
let record = s:records_to_print[a:i]
let item = { 'data':[], 'header':record.additional_info }
call extend( item.data, record.header )
return item
endfunction
function! s:result_window_model.get_item_count()
return len(s:records_to_print)
endfunction
function! s:tag_enter_window_callback.on_type(character, is_alpha_numeric)
let line = getline('.')
let column = col('.')
" magic with ','
" change entered part to tag from suggestion list
" TODO clean algorithm
" TODO extract method and test it
if ! a:is_alpha_numeric
if a:character == ',' && self.available_tags_window.model.get_item_count() > 0
let selected_tag = self.available_tags_window.selected_item()
let position = s:tag_in_line_position(line, column)
let begin = position[0]
let end = position[1]
if begin != 0
let new_line = line[ : begin - 1]
else
let new_line = ''
endif
let selected_tag_text = selected_tag.data[0]
if line[end + 1] == ','
let new_line .= selected_tag_text . line[ end + 1: ]
else
let new_line .= selected_tag_text . ',' . line[ end + 1 : ]
endif
call self.edit_line_window.set_line(new_line)
call self.edit_line_window.go_to_position(begin + len(selected_tag_text) + 2)
endif
return ''
endif
" character isn't at line yet
" so imagine it'is here
let line_with_character = line[ : column] . a:character . line[column + 1 : ]
let current_tag = s:tag_in_line(line_with_character, column)
let suggestions = self.refresh_suggestion_list(current_tag, line_with_character)
let self.edit_column = col('.') + 1
if empty(suggestions)
return ''
endif
return a:character
endfunction
function! s:suggestions_sort(lhs, rhs)
if a:lhs == a:rhs
return 0
endif
let as_current_tag_start_pattern = '^'.s:current_tag
let number_pattern = '\d\+'
let left_is_number = a:lhs =~ number_pattern
let right_is_number = a:rhs =~ number_pattern
if a:lhs =~ as_current_tag_start_pattern && a:rhs !~ as_current_tag_start_pattern
return -1
endif
if left_is_number && right_is_number
return a:lhs > a:rhs ? 1 : -1
endif
if left_is_number && ! right_is_number
return 1
endif
if right_is_number && ! left_is_number
return -1
endif
if a:lhs !~ as_current_tag_start_pattern && a:rhs =~ as_current_tag_start_pattern
return 1
endif
return a:lhs > a:rhs ? 1 : -1
endfunction
function! s:tag_enter_window_callback.refresh_suggestion_list(current_tag, line)
let entered_tags = split(a:line, ',')
let current_tag = a:current_tag
if current_tag == '.'
let current_tag = '\.'
endif
if current_tag =~ '"'
call filter(entered_tags, "v:val != '". current_tag. "'")
else
call filter(entered_tags, 'v:val != "'.current_tag.'"')
endif
call add(entered_tags, '~'.current_tag)
let available_records = s:record_browser.get_matched_records( entered_tags )
let available_tags = s:record_browser.get_available_tags_for_records( available_records, entered_tags )
let s:suggestions = []
for w in available_tags
if w =~ current_tag
call add(s:suggestions, w)
endif
endfor
let s:current_tag = current_tag
call sort(s:suggestions, 's:suggestions_sort')
let s:records_to_print = available_records
let records_to_print_count = len(s:records_to_print)
let suggestions_count = len(s:suggestions)
if records_to_print_count != s:previous_records_to_print_count
let self.result_window.selected_item_number = 1
endif
if suggestions_count != s:previous_suggestions_count
let self.available_tags_window.selected_item_number = 1
endif
let s:previous_records_to_print_count = records_to_print_count
let s:previous_suggestions_count = suggestions_count
call self.result_window.draw()
call self.available_tags_window.draw()
return s:suggestions
endfunction
function! s:tag_enter_window_callback.on_enter()
endfunction
function! s:tag_enter_window_callback.on_insert_move()
let line = getline('.')
let column = col('.')
if self.edit_column == column
return
endif
let current_tag = s:tag_in_line(line, column)
call self.refresh_suggestion_list(current_tag, line)
endfunction
function! s:tag_selection_up()
call s:available_tags_window.selection_up(1)
endfunction
function! s:tag_selection_down()
call s:available_tags_window.selection_down(1)
endfunction
function! s:result_selection_up()
call s:result_window.selection_up(1)
endfunction
function! s:result_selection_down()
call s:result_window.selection_down(1)
endfunction
function! s:result_select()
call railmoon#trace#push('s:result_select')
try
if empty(s:records_to_print)
return
endif
let selected_item_number = s:result_window.selected_item_number
let record = s:records_to_print[selected_item_number - 1]
let s:last_entred_tags_line = s:tag_enter_window_callback.edit_line_window.get_line()
let s:last_selected_result_item_number = selected_item_number
tabclose
call railmoon#widget#window#load_selected(s:plugin_invoker_position)
call s:record_browser.record_extractor.process(record)
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
function! s:close_all()
call railmoon#trace#debug('close_all')
call s:result_window.close()
endfunction
function! s:map_result_moving_keys()
let result_down_keys = [ '<down>', '<C-n>', '<C-j>' ]
let result_up_keys = [ '<up>', '<C-p>', '<C-k>' ]
for key in result_down_keys
let command = 'inoremap <silent> <buffer> '.key.' <C-R>=<SID>result_selection_down()?"":""<CR>'
exec command
let command = 'noremap <silent> <buffer> '.key.' :call <SID>result_selection_down()<CR>'
exec command
endfor
for key in result_up_keys
let command = 'inoremap <silent> <buffer> '.key.' <C-R>=<SID>result_selection_up()?"":""<CR>'
exec command
let command = 'noremap <silent> <buffer> '.key.' :call <SID>result_selection_up()<CR>'
exec command
endfor
inoremap <silent> <buffer> <C-p> <C-R>=<SID>result_selection_up()?'':''<CR>
inoremap <silent> <buffer> <cr> <C-R>=<SID>result_select()?' ':' '<CR>
endfunction
function! s:map_suggestion_moving_keys()
inoremap <silent> <buffer> <Tab> <C-R>=<SID>tag_selection_down()?'':''<CR>
inoremap <silent> <buffer> <C-Tab> <C-R>=<SID>tag_selection_up()?'':''<CR>
noremap <silent> <buffer> <Tab> :call <SID>tag_selection_down()<CR>
noremap <silent> <buffer> <C-Tab> :call <SID>tag_selection_up()<CR>
endfunction
function! s:map_common_keys()
nnoremap <silent> <buffer> <esc> :call <SID>close_all()<CR>
endfunction
" information to help 0scan repeat
let s:last_extractor = {}
let s:last_record_browser = {}
let s:last_entred_tags_line = ''
let s:last_selected_result_item_number = 0
function! s:turnoff_unexpected_plugins()
if exists('g:loaded_minibufexplorer')
CMiniBufExplorer
endif
if exists('g:loaded_autocomplpop')
call railmoon#trace#debug('Turn off autocomplpop.vim')
AutoComplPopLock
endif
endfunction
function! s:turnon_unexpected_plugins()
if exists('g:loaded_autocomplpop')
call railmoon#trace#debug('Turn on autocomplpop.vim')
AutoComplPopUnlock
endif
endfunction
function! s:process_last_extractor_new_selection( record_number )
let record = s:records_to_print[ a:record_number - 1 ]
call s:last_extractor.process(record)
endfunction
function! s:print_error( message )
echohl Error | echo '[ 0scan ] '.a:message | echohl None
endfunction
function! s:process_last_extractor_select_next( shift )
let records_count = len( s:records_to_print )
let new_record_number = s:last_selected_result_item_number + a:shift
if new_record_number < 1
call s:print_error( 'first record reached' )
return
endif
if new_record_number > records_count
call s:print_error( "last record reached" )
return
endif
let s:last_selected_result_item_number = new_record_number
call s:process_last_extractor_new_selection( new_record_number )
endfunction
function! s:process_last_extractor_quick_selection( command )
if a:command == 'lastup'
call s:process_last_extractor_select_next( -1 )
elseif a:command == 'lastdown'
call s:process_last_extractor_select_next( 1 )
endif
endfunction
function! s:create_extractor( name )
let extractor = eval('railmoon#oscan#extractor#'.a:name.'#create()')
return extractor
endfunction
" returns files from dir
"
function! s:get_filenames_from_dir( dir )
let files_list = split( glob( a:dir."/*" ), "\n" )
let result = []
for item in files_list
if filereadable( item )
call add( result, item )
endif
endfor
return result
endfunction
" returns list of [ extractor_name, extractor_description, not_implemented_flag ]
"
function! s:get_available_extractors()
let extractor_files = []
let vimfiles_folders = split( &runtimepath, ',' )
for folder in vimfiles_folders
if folder =~ 'after$'
continue
endif
let extractor_folder = folder.'/autoload/railmoon/oscan/extractor'
call extend( extractor_files, s:get_filenames_from_dir( extractor_folder ) )
endfor
let extractors = []
for extractor_file in extractor_files
"echo extractor_file
let extractor_name = fnamemodify( extractor_file, ":t:r" )
try
let extractor = s:create_extractor( extractor_name )
catch /.*/
continue
endtry
let extractor_description = extractor.description
let extractor_not_implemented = has_key( extractor, 'not_implemented' ) ? extractor.not_implemented : 0
call add( extractors, [ extractor_name, extractor_description, extractor_not_implemented ] )
endfor
return extractors
endfunction
function! s:show_available_extractors()
let extractors = s:get_available_extractors()
let max_extractor_name_len = 0
for extractor_description in extractors
let len = len( extractor_description[0] )
if len > max_extractor_name_len
let max_extractor_name_len = len
endif
endfor
echohl Comment
echo "Please specify scan you would like you use"
echo ":OScan scan_name [tag1] [tag2]<CR>"
echohl None
for extractor_description in extractors
echohl Keyword | echo printf( "%".max_extractor_name_len."s\t", extractor_description[0] )
if extractor_description[2]
echohl Error | echon "[ Not implemented ]" | echohl None | echon " "
endif
echohl String | echon extractor_description[1] | echohl None
endfor
endfunction
" completition function for :OScan command
"
function! railmoon#oscan#complete( argLead, cmdLine, cursorPos )
let result = ''
let extractors = s:get_available_extractors()
for extractor_description in extractors
if extractor_description[2]
continue
endif
if ! empty( result )
let result .= "\n"
endif
let result .= extractor_description[0]
endfor
return result
endfunction
function! railmoon#oscan#open(...)
"call railmoon#trace#start_debug('oscan.debug')
if empty( a:000 )
call s:show_available_extractors()
return
endif
let extractor_name = a:000[0]
" not real extractor, but convinient way to quick run through last
" results
"
if ( extractor_name == 'lastup' || extractor_name == 'lastdown' ) && !empty( s:last_extractor )
call s:process_last_extractor_quick_selection( extractor_name )
return
endif
call railmoon#trace#debug('save invoker position')
let s:plugin_invoker_position = railmoon#widget#window#save_selected()
call railmoon#trace#debug('create tag browser:'.extractor_name)
let extractor = {}
let extractor_description = ''
let is_repeat_last_extractor = extractor_name == 'last' && ! empty(s:last_extractor)
if is_repeat_last_extractor
let extractor = s:last_extractor
let extractor_description = extractor.description
let s:record_browser = s:last_record_browser
elseif extractor_name == 'last'
call s:print_error( 'Nothing to repeat' )
return
else
let extractor = {}
try
let extractor = s:create_extractor( extractor_name )
catch /.*/
call s:print_error( "Can't create \"".extractor_name."\" scan" )
return
endtry
let extractor_description = extractor.description
let s:record_browser = railmoon#oscan#record_browser#create(extractor)
endif
if s:record_browser.is_empty()
call s:print_error( 'no records with tags found' )
return
endif
let s:last_record_browser = deepcopy(s:record_browser)
let s:last_extractor = deepcopy(extractor)
call railmoon#trace#debug('create new tab page')
try
"set lazyredraw
silent tab help
let width = winwidth('%')
let s:plugin_window_goes_close = 0
call railmoon#widget#stop_handle_autocommands()
call s:turnoff_unexpected_plugins()
call railmoon#trace#debug('create available_tags_window')
let tags_window_width = width/5
exec tags_window_width.' vsplit'
let s:available_tags_window = railmoon#widget#selection_window#create(
\ 'Available tags window',
\ extractor_description,
\ 'TODO',
\ s:suggestion_window_model,
\ s:suggestion_window_callback)
call s:map_common_keys()
call s:available_tags_window.draw()
call railmoon#trace#debug('create result_window')
wincmd w
let s:result_window = railmoon#widget#selection_window#create(
\ 'Result window',
\ extractor_description,
\ 'DiffAdd',
\ s:result_window_model,
\ s:result_window_callback)
call s:map_common_keys()
call extractor.colorize()
if is_repeat_last_extractor
call s:result_window.select_item(s:last_selected_result_item_number)
endif
call railmoon#trace#debug('create tag_enter_window')
split
resize 1
let edit_line_window = railmoon#widget#edit_line_window#create(
\'Tag enter window',
\ extractor_description,
\ s:tag_enter_window_callback)
call s:map_common_keys()
call s:map_result_moving_keys()
call s:map_suggestion_moving_keys()
if ! is_repeat_last_extractor
let tag_line = join(a:000[ 1: ], ',')
if len(tag_line) > 0
let tag_line .= ','
endif
call edit_line_window.set_line(tag_line)
else
call edit_line_window.set_line(s:last_entred_tags_line)
endif
call railmoon#widget#window#select(edit_line_window.id)
startinsert!
catch /.*/
call s:print_error( v:exception )
finally
call railmoon#widget#start_handle_autocommands()
"set nolazyredraw
"redraw
endtry
let s:tag_enter_window_callback.edit_line_window = edit_line_window
let s:tag_enter_window_callback.available_tags_window = s:available_tags_window
let s:tag_enter_window_callback.result_window = s:result_window
endfunction
" -
" [ testing ]
" -
let s:unit_test = railmoon#unit_test#create('oscan')
function! s:unit_test.test_tag_in_line()
call self.assert_equal(s:tag_in_line('January,', 7), 'January')
call self.assert_equal(s:tag_in_line('January,', 8), 'January')
call self.assert_equal(s:tag_in_line('January,', 9), '')
call self.assert_equal(s:tag_in_line('January,February', 8), 'January')
call self.assert_equal(s:tag_in_line(',word,', 2), 'word')
call self.assert_equal(s:tag_in_line(',word,', 3), 'word')
call self.assert_equal(s:tag_in_line(',word,', 4), 'word')
call self.assert_equal(s:tag_in_line(',word,', 5), 'word')
call self.assert_equal(s:tag_in_line(',word,', 6), 'word')
call self.assert_equal(s:tag_in_line('word,', 4), 'word')
call self.assert_equal(s:tag_in_line('word,', 5), 'word')
call self.assert_equal(s:tag_in_line('word,', 6), '')
call self.assert_equal(s:tag_in_line('word,,', 6), 'word')
call self.assert_equal(s:tag_in_line('', 1), '')
call self.assert_equal(s:tag_in_line(',', 1), '')
endfunction
call s:unit_test.run()

View File

@ -0,0 +1,73 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#buffers
" Purpose: extract buffer names to select
function! railmoon#oscan#extractor#buffers#create()
let new_extractor = copy(s:tag_scan_buffers_extractor)
let new_extractor.description = 'Select buffer to edit'
return new_extractor
endfunction
let s:tag_scan_buffers_extractor = {}
function! s:tag_scan_buffers_extractor.process(record)
if &modified
let choice = inputlist( [ "Buffer is modified.", "1. Save current and continue" , "2. Break", "3. Open in new tab" ] )
if 1 == choice
update
elseif 2 == choice
return
elseif 3 == choice
tab new
else
tab new
endif
endif
exec 'buffer '.a:record.data
endfunction
function! s:tag_scan_buffers_extractor.tags_by_name(buffer_name, buffer_number)
let tags = railmoon#oscan#extractor#util#tags_from_file_name(a:buffer_name)
if index(tags, string(a:buffer_number)) == -1
call add(tags, a:buffer_number)
endif
return tags
endfunction
function! s:tag_scan_buffers_extractor.header_by_name(buffer_name, buffer_number)
return [ a:buffer_name ]
endfunction
function! s:tag_scan_buffers_extractor.extract()
let result = []
let buffers = railmoon#oscan#extractor#util#buffer_list()
for buffer_info in buffers
let buffer_number = buffer_info[0]
let buffer_name = buffer_info[1]
call add(result, railmoon#oscan#record#create( self.header_by_name(buffer_name, buffer_number),
\ self.tags_by_name(buffer_name, buffer_number),
\ buffer_number,
\ buffer_number))
endfor
return result
endfunction
function! s:tag_scan_buffers_extractor.colorize()
syntax match FileName /.*\zs\/.*\ze/
hi link FileName Identifier
endfunction

View File

@ -0,0 +1,54 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#changes
" Purpose: extract recently changed lines to jump to
function! railmoon#oscan#extractor#changes#create()
let new_extractor = copy(s:tag_scan_changes_extractor)
let new_extractor.description = 'Select recently changed lines to jump to'
let new_extractor.filetype = &filetype
return new_extractor
endfunction
let s:tag_scan_changes_extractor = {}
function! s:tag_scan_changes_extractor.process(record)
exec a:record.data
endfunction
function! s:tag_scan_changes_extractor.extract()
let result = []
redir => changes_string
silent changes
redir END
let changes_list = split(changes_string, "\n")
let pattern = '\s*\(\d\+\)\s*\(\d\+\)\s*\(\d\+\)\s*\(.*\)$'
call reverse(changes_list)
for change_el in changes_list
if change_el !~ pattern
continue
endif
let line_number = substitute(change_el, pattern, '\2', '')
let line = substitute(change_el, pattern, '\4', '')
let tags = railmoon#oscan#extractor#util#tags_from_line(line)
let header = [ line ]
call add(result, railmoon#oscan#record#create( header,
\ tags,
\ line_number,
\ line_number))
endfor
return result
endfunction
function! s:tag_scan_changes_extractor.colorize()
endfunction

View File

@ -0,0 +1,137 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#ctags
" Purpose: extract ctags record from current buffer
function! railmoon#oscan#extractor#ctags#create()
let new_extractor = copy(s:tag_scan_ctags_extractor)
let new_extractor.file_name = expand("%:p")
let new_extractor.buffer_number = bufnr('%')
let new_extractor.file_extension = expand("%:e")
let new_extractor.filetype = &filetype
let new_extractor.description = 'Extract ctags records from "'.new_extractor.file_name.'"'
return new_extractor
endfunction
function! railmoon#oscan#extractor#ctags#language_function(language, function_name,...)
call railmoon#trace#debug( 'call language_function "'.a:function_name.'" for "'.a:language.'"' )
try
let result = eval('railmoon#oscan#extractor#ctags#'.a:language.'#'.a:function_name.'('.join(a:000,',').')')
catch /.*/
call railmoon#trace#debug( 'failed.['.v:exception.'] use cpp' )
let result = eval('railmoon#oscan#extractor#ctags#cpp#'.a:function_name.'('.join(a:000,',').')')
endtry
return result
endfunction
function! railmoon#oscan#extractor#ctags#colorize_for_langauge(language)
call railmoon#oscan#extractor#ctags#language_function(a:language, 'colorize')
endfunction
" by language name return kinds to use while ctags build tags base
" default language c++
function! railmoon#oscan#extractor#ctags#kind_types_for_langauge(language)
return railmoon#oscan#extractor#ctags#language_function(a:language, 'kinds')
endfunction
function! railmoon#oscan#extractor#ctags#process(tag_item)
try
let previous_magic = &magic
set nomagic
if fnamemodify( @%, ':p' ) != fnamemodify( a:tag_item.filename, ':p' )
exec 'silent edit '.a:tag_item.filename
endif
silent 1
exec a:tag_item.cmd
finally
let &magic = previous_magic
endtry
endfunction
" by language name and ctags tag return record
" default language c++
function! railmoon#oscan#extractor#ctags#record_for_language_tag( language, ctag_item )
return railmoon#oscan#extractor#ctags#language_function( a:language, 'record', a:ctag_item )
endfunction
" return language name by extension
" default language c++
function! railmoon#oscan#extractor#ctags#language_by_extension( extension )
if index(['c', 'cpp', 'h', 'cxx', 'hxx', 'cc', 'hh', 'hpp'], a:extension) != -1
return 'cpp'
elseif a:extension == 'vim'
return 'vim'
elseif a:extension == 'pl'
return 'perl'
elseif a:extension == 'py'
return 'python'
endif
return 'cpp'
endfunction
" return language name for current buffer
" default language c++
function! railmoon#oscan#extractor#ctags#language_by_current_buffer()
let extension = fnamemodify(@%, ':e')
let language = exists( '&filetype' ) ? &filetype : railmoon#oscan#extractor#ctags#language_by_extension(extension)
return language
endfunction
let s:tag_scan_ctags_extractor = {}
function! s:tag_scan_ctags_extractor.process(record)
call railmoon#oscan#extractor#ctags#process(a:record.data)
endfunction
function! s:tag_scan_ctags_extractor.extract()
let result = []
let self.language = railmoon#oscan#extractor#ctags#language_by_current_buffer()
" fields
" f - file name
" s - structures
" i - inherits
" k - kinds
" K - kinds full written
" a - access
" l - language
" t,m,z - unknown for me yet
" n - line numbers
" S - signature
" extra
" q - tag names include namespace
" f - file names added
let ctags_tags = railmoon#ctags_util#taglist_for_file(self.file_name,
\ self.language,
\ railmoon#oscan#extractor#ctags#kind_types_for_langauge(self.language),
\ 'sikaS')
for item in ctags_tags
let record = railmoon#oscan#extractor#ctags#record_for_language_tag(self.language, item)
" no need file name to show in each row ( all tags in one file )
let record.additional_info = ''
call add(result, record)
endfor
return result
endfunction
function! railmoon#oscan#extractor#ctags#colorize_keywords(language)
call railmoon#oscan#extractor#ctags#colorize_for_langauge(a:language)
endfunction
function! s:tag_scan_ctags_extractor.colorize()
let &filetype = self.filetype
call railmoon#oscan#extractor#ctags#colorize_for_langauge(self.language)
endfunction

View File

@ -0,0 +1,153 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#ctags#cpp
" Purpose: extract ctags cpp record from buffer
function! railmoon#oscan#extractor#ctags#cpp#kinds()
return "cdefgmnpstuvx"
endfunction
function! railmoon#oscan#extractor#ctags#cpp#colorize()
syntax keyword Type variable inner field enumeration function method public private protected global
syntax keyword Keyword constructor destructor
syntax keyword Identifier decl def
endfunction
function! railmoon#oscan#extractor#ctags#cpp#record( tag_item )
let tag_list = []
let header = ""
let line_number = a:tag_item.cmd
let kind = a:tag_item.kind
let namespace = has_key(a:tag_item, 'namespace') ? a:tag_item.namespace : ''
let is_object = 0
let object_name = ''
for name in ( [ has_key(a:tag_item, 'class') ? a:tag_item.class : ''
\, has_key(a:tag_item, 'struct') ? a:tag_item.struct : ''
\, has_key(a:tag_item, 'enum') ? a:tag_item.enum : ''
\, has_key(a:tag_item, 'union') ? a:tag_item.union : '' ] )
if ! empty(name)
let object_name = name
let is_object = 1
break
endif
endfor
let tagname = split(a:tag_item.name, '::')[ -1]
let is_constructor = 0
let is_destructor = 0
if is_object
let last_part_of_object_name = split(object_name, '::')[ -1]
let is_constructor = tagname == last_part_of_object_name
let is_destructor = tagname == '~'.last_part_of_object_name
endif
if kind == 'f' || kind == 'p'
if is_object
if is_constructor
let header .= 'constructor '
call add(tag_list, 'constructor')
elseif is_destructor
let header .= 'destructor '
call add(tag_list, 'destructor')
else
let header .= 'method '
call add(tag_list, 'method')
endif
else
let header .= "function "
call add(tag_list, "function")
endif
if kind == 'p'
let header .= 'decl. '
call add(tag_list, "decl")
else
let header .= 'def. '
call add(tag_list, "def")
endif
elseif kind == 'c'
let header .= "class "
call add(tag_list, "class")
call add(tag_list, "object")
elseif kind == 'u'
let header .= "union "
call add(tag_list, "union")
call add(tag_list, "object")
elseif kind == 's'
let header .= "struct "
call add(tag_list, "struct")
call add(tag_list, "object")
elseif kind == 'g'
let header .= "enum "
call add(tag_list, "enum")
elseif kind == 'd'
let header .= "#define "
call add(tag_list, "define")
elseif kind == 'm'
let header .= "field "
call add(tag_list, "field")
elseif kind == 'n'
let header .= "namespace "
call add(tag_list, "namespace")
elseif kind == 't'
let header .= "typedef "
call add(tag_list, "typedef")
elseif kind == 'v'
let header .= "global variable "
call extend(tag_list, ["variable", "global"])
elseif kind == 'e'
let header .= "enumeration "
call add(tag_list, "enumeration")
endif
call add(tag_list, tagname)
if is_object
call extend(tag_list, split(object_name, '::'))
endif
if ! empty(namespace)
call extend(tag_list, split(namespace, '::'))
endif
if is_object
let header .= object_name.'::'
endif
if ! empty(namespace)
let header .= namespace.'::'
endif
let header .= tagname
if kind =~ '[fp]' && has_key(a:tag_item, 'signature')
let header .= a:tag_item.signature
endif
let access = has_key(a:tag_item, 'access') ? a:tag_item.access : ''
if ! empty(access)
if kind =~ '[csug]'
call add(tag_list, 'inner')
let header = 'inner '.header
endif
let header = access.' '.header
call add(tag_list, access)
endif
let file_name = has_key(a:tag_item, 'filename') ? a:tag_item.filename : ''
return railmoon#oscan#record#create([header], tag_list, a:tag_item, fnamemodify(file_name, ':t'))
endfunction

View File

@ -0,0 +1,42 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#ctags#py
" Purpose: extract ctags html record from buffer
function! railmoon#oscan#extractor#ctags#html#kinds()
return "af"
endfunction
function! railmoon#oscan#extractor#ctags#html#colorize()
syntax keyword Type anchor function
endfunction
function! railmoon#oscan#extractor#ctags#html#record( tag_item )
let tag_list = []
let header = ""
let kind = a:tag_item.kind
let tagname = a:tag_item.name
"let tagname = substitute( tagname, "'\\(.*\\)'", "\1", "g" )
if kind =~ 'a'
let header .= 'anchor '
call add(tag_list, 'anchor')
elseif kind == 'f'
let header .= "function "
call add(tag_list, "function")
endif
call add(tag_list, tagname)
let header .= tagname
let file_name = has_key(a:tag_item, 'filename') ? a:tag_item.filename : ''
return railmoon#oscan#record#create([header], tag_list, a:tag_item, fnamemodify(file_name, ':t'))
endfunction

View File

@ -0,0 +1,91 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#ctags#py
" Purpose: extract ctags python record from buffer
function! railmoon#oscan#extractor#ctags#python#kinds()
return "cfm"
endfunction
function! railmoon#oscan#extractor#ctags#python#colorize()
syntax keyword Type class function method inner public private
syntax keyword Keyword constructor method
endfunction
function! railmoon#oscan#extractor#ctags#python#record( tag_item )
let tag_list = []
let header = ""
let line_number = a:tag_item.cmd
let kind = a:tag_item.kind
let is_object = 0
let object_name = ''
for name in ( [ has_key(a:tag_item, 'class') ? a:tag_item.class : '' ] )
if ! empty(name)
let object_name = name
let is_object = 1
break
endif
endfor
let tagname = a:tag_item.name
let is_constructor = 0
if is_object
let is_constructor = tagname == '__init__'
endif
if kind == 'm'
if is_object
if is_constructor
let header .= 'constructor '
call add(tag_list, 'constructor')
else
let header .= 'method '
call add(tag_list, 'method')
endif
endif
elseif kind == 'c'
let header .= "class "
call add(tag_list, "class")
call add(tag_list, "object")
elseif kind == 'm'
let header .= "function "
call add(tag_list, "function")
endif
call add(tag_list, tagname)
if is_object
call extend(tag_list, split(object_name, '::'))
endif
if is_object
let header .= object_name.'.'
endif
let header .= tagname
if kind == 'c' && ! empty(object_name)
call add(tag_list, 'inner')
let header = 'inner '.header
endif
let access = has_key(a:tag_item, 'access') ? a:tag_item.access : ''
if ! empty(access)
let header = access.' '.header
call add(tag_list, access)
endif
let file_name = has_key(a:tag_item, 'filename') ? a:tag_item.filename : ''
return railmoon#oscan#record#create([header], tag_list, a:tag_item, fnamemodify(file_name, ':t'))
endfunction

View File

@ -0,0 +1,43 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#ctags#vim
" Purpose: extract ctags vim record from buffer
function! railmoon#oscan#extractor#ctags#vim#kinds()
return "afk"
endfunction
function! railmoon#oscan#extractor#ctags#vim#colorize()
syntax keyword Type function variable autogroup
endfunction
function! railmoon#oscan#extractor#ctags#vim#record( tag_item )
let tag_list = []
let header = ""
let line_number = a:tag_item
let kind = a:tag_item.kind
call add(tag_list, a:tag_item.name)
if kind == 'a'
let header .= "autogroup "
call add(tag_list, "autogroup")
elseif kind == 'f'
let header .= "function "
call add(tag_list, "function")
elseif kind == 'v'
let header .= "variable "
call add(tag_list, "variable")
endif
let header .= a:tag_item.name
return railmoon#oscan#record#create( [ ' '.header ], tag_list, line_number)
endfunction

View File

@ -0,0 +1,121 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#definition_declaration
" Purpose: extract ctags record from buffer
function! railmoon#oscan#extractor#definition_declaration#create()
let new_extractor = copy(s:tag_scan_definition_declaration_extractor)
let new_extractor.file_name = expand("%:p")
let new_extractor.buffer_number = bufnr('%')
let new_extractor.file_extension = expand("%:e")
let new_extractor.filetype = &filetype
let new_extractor.description = 'Go to possible definition/declaration for current function'
return new_extractor
endfunction
let s:tag_scan_definition_declaration_extractor = {}
function! s:tag_scan_definition_declaration_extractor.process(record)
call railmoon#oscan#extractor#ctags#process(a:record.data)
endfunction
function! s:get_nearest_ctags_tag()
let filename = @%
let linenumber = line('.')
let self.language = railmoon#oscan#extractor#ctags#language_by_current_buffer()
let ctags_tags = railmoon#ctags_util#taglist_for_file(filename, language, railmoon#oscan#extractor#ctags#kind_types_for_langauge(language), 'sikaS')
let i = len(ctags_tags) - 1
while i >= 0
let tag_item = ctags_tags[i]
if linenumber >= tag_item.cmd
return tag_item
endif
let i -= 1
endwhile
return {}
endfunction
function! s:is_equal_tag_attribute(tag_left, tag_right, attribute)
let left_has_attribute = has_key(a:tag_left, a:attribute)
let right_has_attribute = has_key(a:tag_right, a:attribute)
if left_has_attribute && right_has_attribute
return a:tag_left[a:attribute] == a:tag_right[a:attribute]
endif
if ! left_has_attribute && ! right_has_attribute
return 1
endif
return 0
endfunction
function! s:return_definitions(ctags_tag)
let result = []
let similar_tags = taglist('\<'.a:ctags_tag.name.'\>')
for tag_item in similar_tags
if tag_item.kind == 'p'
continue
endif
if s:is_equal_tag_attribute(a:ctags_tag, tag_item, 'class') &&
\ s:is_equal_tag_attribute(a:ctags_tag, tag_item, 'namespace')
call add(result, tag_item)
endif
endfor
return result
endfunction
function! s:return_declarations(ctags_tag)
let result = []
let similar_tags = taglist('\<'.a:ctags_tag.name.'\>')
for tag_item in similar_tags
if tag_item.kind != 'p'
continue
endif
if s:is_equal_tag_attribute(a:ctags_tag, tag_item, 'class') &&
\ s:is_equal_tag_attribute(a:ctags_tag, tag_item, 'namespace')
call add(result, tag_item)
endif
endfor
return result
endfunction
function! s:tag_scan_definition_declaration_extractor.extract()
let result = []
let extension = self.file_extension
let language = railmoon#oscan#extractor#ctags#language_by_extension(extension)
let self.language = language
let nearest_tag = s:get_nearest_ctags_tag()
let ctags_tags = nearest_tag.kind =~ 'p' ? s:return_definitions(nearest_tag) : s:return_declarations(nearest_tag)
for item in ctags_tags
let record = railmoon#oscan#extractor#ctags#record_for_language_tag(language, item)
call add(result, record)
endfor
return result
endfunction
function! s:tag_scan_definition_declaration_extractor.colorize()
let &filetype = self.filetype
call railmoon#oscan#extractor#ctags#colorize_keywords(self.language)
endfunction

View File

@ -0,0 +1,31 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#file
" Purpose: create extractor by file extension and or name
function! railmoon#oscan#extractor#file#create()
let file_name = expand("%:p")
let file_extension = expand("%:e")
try
return eval('railmoon#oscan#extractor#'.file_extension.'#'.'create()')
catch /.*/
endtry
let extractor_name = 'railmoon#oscan#extractor#ctags'
try
let extractor = eval(extractor_name.'#'.'create()')
catch /.*/
echo 'extractor "'.extractor_name. '" not found. use ctags as default'
echo '.'
echo '.'
echo '.'
endtry
return railmoon#oscan#extractor#ctags#create()
endfunction

View File

@ -0,0 +1,86 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#files
" Purpose: extract files from current file directory to open
function! railmoon#oscan#extractor#files#create()
let new_extractor = copy(s:tag_scan_files_extractor)
let file_name = expand("%:p")
let new_extractor.current_file_dir = fnamemodify(file_name, ":p:h")
let new_extractor.description = 'Select file from "'.new_extractor.current_file_dir.'" directory to open'
return new_extractor
endfunction
let s:tag_scan_files_extractor = {}
function! s:tag_scan_files_extractor.process(record)
if &modified
let choice = inputlist( [ "Buffer is modified.", "1. Save current and continue" , "2. Break", "3. Open in new tab" ] )
if 1 == choice
update
elseif 2 == choice
return
elseif 3 == choice
tab new
else
tab new
endif
endif
let buf_number = bufnr(a:record.data)
if -1 == buf_number
exec 'edit '.escape(a:record.data,' ')
else
exec 'buffer '.buf_number
endif
endfunction
function! s:tag_scan_files_extractor.tags_by_name(buffer_name, buffer_number)
let tags = railmoon#oscan#extractor#util#tags_from_file_name(a:buffer_name)
if index(tags, string(a:buffer_number)) == -1
call add(tags, a:buffer_number)
endif
return tags
endfunction
function! s:tag_scan_files_extractor.header_by_name(buffer_name, buffer_number)
return [ a:buffer_name ]
endfunction
function! s:tag_scan_files_extractor.extract()
let result = []
let files = split(glob( self.current_file_dir."/*" ), "\n")
"call extend(files, split(glob( self.current_file_dir."/.*" ), "\n"))
for file in files
if ! filereadable(file)
continue
endif
let just_name = fnamemodify(file, ":t:r")
let ext = fnamemodify(file, ":e")
let tags = [ just_name, ext ]
call add(result, railmoon#oscan#record#create( [ just_name ],
\ tags,
\ file,
\ ext))
endfor
return result
endfunction
function! s:tag_scan_files_extractor.colorize()
endfunction

View File

@ -0,0 +1,86 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#marks
" Purpose: extract marks to select
function! railmoon#oscan#extractor#marks#create()
let new_extractor = copy(s:tag_scan_marks_extractor)
let new_extractor.description = 'Select mark to jump'
let new_extractor.filetype = &filetype
return new_extractor
endfunction
let s:tag_scan_marks_extractor = {}
function! s:tag_scan_marks_extractor.process(record)
exec "normal \'".a:record.data
endfunction
function! s:tag_scan_marks_extractor.extract()
let result = []
redir => marks_string
silent marks
redir END
let marks_list = split(marks_string, "\n")
let pattern = '\s*\(\S\+\)\s*\(\d\+\)\s*\(\d\+\)\s*\(.*\)$'
for mark_value in marks_list
if mark_value !~ pattern
continue
endif
let mark_symbol = substitute(mark_value, pattern, '\1', '')
let mark_line = substitute(mark_value, pattern, '\2', '')
let mark_col = substitute(mark_value, pattern, '\3', '')
let mark_file_or_line = substitute(mark_value, pattern, '\4', '')
let tags = []
let file_name = fnamemodify(mark_file_or_line, ':p')
let is_file = filereadable(file_name)
if is_file
let header_line = '<# '.file_name.' #>'
let tags = railmoon#oscan#extractor#util#tags_from_file_name(file_name)
else
let header_line = mark_file_or_line
let tags = split(mark_file_or_line, '\W')
call filter(tags, 'v:val != ""')
call add(tags, 'buffer')
endif
if mark_symbol =~ '[QWERTYUIOPASDFGHJKLZXCVBNM1234567890]'
call add(tags, 'global')
endif
if mark_symbol =~ '[QWERTYUIOPASDFGHJKLZXCVBNM]'
call add(tags, 'user')
endif
let header_line = printf("%5s %5s ", mark_line, mark_col).header_line
let header = [ header_line ]
call add(result, railmoon#oscan#record#create( header,
\ tags,
\ mark_symbol,
\ mark_symbol))
endfor
return result
endfunction
function! s:tag_scan_marks_extractor.colorize()
syn match Comment /.*/ contained contains=Identifier
syn region Identifier matchgroup=Ignore start='<#' end='#>' contained
syn match TODO /\|/ nextgroup=Keyword
syn match Keyword /\d\+\s/ nextgroup=Statement contained skipwhite
syn match Statement /\d\+/ nextgroup=Comment contained skipwhite
endfunction

View File

@ -0,0 +1,123 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#multiline_search
" Purpose: extract strings ( and their neighbours) with search pattern from current file
function! railmoon#oscan#extractor#multiline_search#create()
let new_extractor = copy(s:tag_scan_multiline_search_extractor)
let new_extractor.file_name = expand("%:p")
let new_extractor.file_extension = expand("%:e")
let new_extractor.first_line_to_search = 1
let new_extractor.last_line_to_search = line('$')
let new_extractor.pattern = @/
let new_extractor.filetype = &filetype
let new_extractor.description = 'Mutliline search "'.new_extractor.pattern.'" in "'.new_extractor.file_name.'"'
return new_extractor
endfunction
let s:tag_scan_multiline_search_extractor = {}
function! s:tag_scan_multiline_search_extractor.process(record)
exec a:record.data
endfunction
function! s:tag_scan_multiline_search_extractor.tags_by_line(line_number_start, data)
let tags = []
let i = 0
for line in a:data
call extend(tags, railmoon#oscan#extractor#util#tags_from_searched_line(a:line_number_start + i, line) )
let i += 1
endfor
return tags
endfunction
function! s:tag_scan_multiline_search_extractor.extract()
let result = []
let pos = getpos('.')
call cursor(self.first_line_to_search, 1)
let pattern = self.pattern
let last_search_result = -1
let option = 'Wc'
let match_pattern_line_numbers = []
while 1
let search_result = search(pattern, option, self.last_line_to_search)
if search_result == 0
break
endif
if search_result != last_search_result
call add(match_pattern_line_numbers, search_result)
endif
let last_search_result = search_result
let option = 'W'
endwhile
let match_cout = len(match_pattern_line_numbers)
if match_cout == 0
return result
endif
let min_block_size = 2
let i = 0
while i < match_cout
let block_begin = match_pattern_line_numbers[i] - min_block_size
let delta = 0
if block_begin < self.first_line_to_search
let delta = self.first_line_to_search - block_begin
let block_begin = self.first_line_to_search
endif
let block_end = match_pattern_line_numbers[i] + min_block_size + delta
if block_end > self.last_line_to_search
let block_end = self.last_line_to_search
endif
while i < match_cout
if match_pattern_line_numbers[i] - min_block_size > block_end
let i -= 1
break
endif
let block_end = match_pattern_line_numbers[i] + min_block_size
let i += 1
endwhile
let data = getline(block_begin, block_end)
let tag_list = self.tags_by_line(block_begin, data)
call add(tag_list, block_begin)
call add(result, railmoon#oscan#record#create(data, tag_list, block_begin, block_begin))
let i +=1
endwhile
call setpos('.', pos)
return result
endfunction
function! s:tag_scan_multiline_search_extractor.colorize()
let &filetype = self.filetype
exec 'syn match Search "'.'\c'.self.pattern.'"'
" exec 'syn match Identifier "[**].*"'
endfunction

View File

@ -0,0 +1,69 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#paste
" Purpose: extract registers texts to paste
function! railmoon#oscan#extractor#paste#create()
let new_extractor = copy(s:tag_scan_paste_extractor)
let new_extractor.description = 'Select register to paste'
let new_extractor.filetype = &filetype
return new_extractor
endfunction
let s:tag_scan_paste_extractor = {}
function! s:tag_scan_paste_extractor.process(record)
exec 'normal "'.a:record.data."p"
endfunction
function! s:tag_scan_paste_extractor.extract()
let result = []
redir => paste_string
silent registers
redir END
let paste_list = split(paste_string, "\n")
let pattern = '^"\(\S\)\s\s\s\(.*\)$'
for line in paste_list
if line !~ pattern
continue
endif
let register_name = substitute(line, pattern, '\1', '')
let register_value = eval('@'.register_name)
let tags = railmoon#oscan#extractor#util#tags_from_line(register_value)
let register_value_list = split( register_value, "\n" )
let shortened_value_list = register_value_list
if len( register_value_list ) > 5
let shortened_value_list = register_value_list[0:2]
call add(shortened_value_list, "... more ...")
call extend(shortened_value_list, register_value_list[-2:-1])
endif
let additional_data = register_name
let header = shortened_value_list
if empty(header)
continue
endif
call add(result, railmoon#oscan#record#create(header,
\ tags,
\ register_name,
\ register_name))
endfor
return result
endfunction
function! s:tag_scan_paste_extractor.colorize()
syn match Identifier /\.\.\. more \.\.\./
endfunction

View File

@ -0,0 +1,138 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#sco
" Purpose: extract sco taged headers or sco folded result
function! railmoon#oscan#extractor#sco#create()
let new_extractor = copy(s:tag_scan_sco_extractor)
let new_extractor.folded_result_start = searchpair('>>>', '', '<<<', 'bnW')
let new_extractor.folded_result_end = searchpair('>>>', '', '<<<', 'nW')
let new_extractor.buffer_number = bufnr('%')
let new_extractor.is_extract_tag_headers = 0 == new_extractor.folded_result_start
if new_extractor.is_extract_tag_headers
let new_extractor.description = 'SourceCodeObedience. Select header to move to'
else
let new_extractor.description = 'SourceCodeObedience. Select result to move to'
endif
return new_extractor
endfunction
let s:tag_scan_sco_extractor = {}
function! s:tag_scan_sco_extractor.process(record)
exec 'buffer '.self.buffer_number
update
e
exec a:record.data
if ! self.is_extract_tag_headers
Enter
endif
endfunction
function! s:tag_scan_sco_extractor.taged_headers_tags_by_line(line_number, line)
return split(substitute(a:line, '^\s*tags:\(.*\)', '\1', ''), ',')
endfunction
function! s:tag_scan_sco_extractor.taged_headers_header_by_line(line_number, line)
let line_with_header = getline(a:line_number - 1)
if line_with_header =~ '^\s*header:'
return [ substitute(line_with_header, '^\s*header:\(.*\)', '\1', '') ]
endif
return [ '[ '.substitute(a:line, '^\s*tags:\(.*\)', '\1', '').' ]' ]
endfunction
function! s:tag_scan_sco_extractor.extract_taged_headers()
let result = []
let pos = getpos('.')
call cursor(1, 1)
let pattern = '^\s*tags:'
let option = 'Wc'
while 1
let search_result = search(pattern, option)
if search_result == 0
break
endif
let line = getline(search_result)
let data = self.taged_headers_header_by_line(search_result, line)
let tag_list = self.taged_headers_tags_by_line(search_result, line)
call add(result, railmoon#oscan#record#create(data, tag_list, search_result, search_result))
let option = 'W'
endwhile
call setpos('.', pos)
return result
endfunction
let s:smart_mark_pattern_comment = '\s\+```\(.*[^>]\)>>.*$'
let s:smart_mark_pattern_without_comment = '@\s\+\(\S\+\)\s\+\(\d*\)\s\(.*\)'
let s:smart_mark_pattern = s:smart_mark_pattern_without_comment.s:smart_mark_pattern_comment
let s:sco_result_pattern = '^#\s\+\(\S\+\)\s\+\(\S\+\)\s\+\(\d\+\)\s\+\(.*\)$'
function! s:tag_scan_sco_extractor.extract_sco_results()
let result = []
let line_number = self.folded_result_start + 1
while line_number < self.folded_result_end
let line = getline(line_number)
if line =~ s:sco_result_pattern
let file_name = substitute(line, s:sco_result_pattern, '\1', '')
let function_name = substitute(line, s:sco_result_pattern, '\2', '')
let file_line_number = substitute(line, s:sco_result_pattern, '\3', '')
let body = substitute(line, s:sco_result_pattern, '\4', '')
let short_file_name = fnamemodify(file_name, ':t')
let tag_list = []
call extend(tag_list, railmoon#oscan#extractor#util#tags_from_line(body))
call add(tag_list, function_name)
call extend(tag_list, railmoon#oscan#extractor#util#tags_from_file_name(file_name))
call add(result, railmoon#oscan#record#create([ body ], tag_list, line_number, short_file_name))
endif
let line_number += 1
endwhile
return result
endfunction
function! s:tag_scan_sco_extractor.extract()
if self.is_extract_tag_headers
return self.extract_taged_headers()
endif
return self.extract_sco_results()
endfunction
function! s:tag_scan_sco_extractor.colorize()
if self.is_extract_tag_headers
syntax match Comment '\[.*\]' contains=Keyword
syntax keyword Keyword tag symbol file include text grep calling contained
else
setf cpp
endif
endfunction

View File

@ -0,0 +1,85 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#search
" Purpose: extract strings with search pattern from current file
function! railmoon#oscan#extractor#search#create()
let new_extractor = copy(s:tag_scan_search_extractor)
let new_extractor.file_name = expand("%:p")
let new_extractor.buffer_number = bufnr('%')
let new_extractor.file_extension = expand("%:e")
let new_extractor.line_number_width = len(line('$'))
let new_extractor.first_line_to_search = 1
let new_extractor.last_line_to_search = line('$')
let new_extractor.pattern = @/
let new_extractor.remove_leader_space = 1
let new_extractor.filetype = &filetype
let new_extractor.description = 'Search "'.new_extractor.pattern.'" in "'.new_extractor.file_name.'"'
return new_extractor
endfunction
let s:tag_scan_search_extractor = {}
function! s:tag_scan_search_extractor.process(record)
exec 'buffer '.self.buffer_number
exec a:record.data
endfunction
function! s:tag_scan_search_extractor.tags_by_line(line_number, line) " line
return railmoon#oscan#extractor#util#tags_from_searched_line(a:line_number, a:line)
endfunction
function! s:tag_scan_search_extractor.header_by_line(line_number, line)
if self.remove_leader_space
let line = substitute(a:line, '^\s*', '', 'g')
else
let line = a:line
endif
return [ line ]
endfunction
function! s:tag_scan_search_extractor.extract()
let result = []
let pos = getpos('.')
call cursor(self.first_line_to_search, 1)
let pattern = self.pattern
let last_search_result = -1
let option = 'Wc'
while 1
let search_result = search(pattern, option, self.last_line_to_search)
if search_result == 0
break
endif
if search_result != last_search_result
let line = getline(search_result)
let data = self.header_by_line(search_result, line)
let tag_list = self.tags_by_line(search_result, line)
call add(result, railmoon#oscan#record#create(data, tag_list, search_result, search_result))
endif
let last_search_result = search_result
let option = 'W'
endwhile
call setpos('.', pos)
return result
endfunction
function! s:tag_scan_search_extractor.colorize()
let &filetype = self.filetype
endfunction

View File

@ -0,0 +1,19 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#search_in_scope
" Purpose: extract strings that visible in current scope
function! railmoon#oscan#extractor#search_in_scope#create()
let new_extractor = railmoon#oscan#extractor#search#create()
let new_extractor.first_line_to_search = searchpair('{', '', '}', 'bn')
let new_extractor.last_line_to_search = searchpair('{', '', '}', 'n')
let new_extractor.pattern = '.*'
let new_extractor.remove_leader_space = 0
let new_extractor.description = 'Search in current scope. '.new_extractor.first_line_to_search.':'.new_extractor.last_line_to_search
return new_extractor
endfunction

View File

@ -0,0 +1,41 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#search_in_windows
" Purpose: extract strings with search pattern from all windows
function! railmoon#oscan#extractor#search_in_windows#create()
let new_extractor = copy(s:tag_scan_search_in_windows_extractor)
let new_extractor.pattern = @/
let new_extractor.buffer_number = bufnr('%')
let new_extractor.filetype = &filetype
let new_extractor.description = 'Search "'.new_extractor.pattern.'" in all opened windows'
let new_extractor.not_implemented = 1
return new_extractor
endfunction
let s:tag_scan_search_in_windows_extractor = {}
function! s:tag_scan_search_in_windows_extractor.process(record)
endfunction
function! s:tag_scan_search_in_windows_extractor.tags_by_line(line_number, line) " line
"return railmoon#oscan#extractor#util#tags_from_searched_line(a:line_number, a:line)
endfunction
function! s:tag_scan_search_in_windows_extractor.header_by_line(line_number, line)
"let line = substitute(a:line, '^\s*', '', 'g')
"return [ line ]
endfunction
function! s:tag_scan_search_in_windows_extractor.search_in_buffer(tabpage_number, window_number)
endfunction
function! s:tag_scan_search_in_windows_extractor.extract()
endfunction
function! s:tag_scan_search_in_windows_extractor.colorize()
endfunction

View File

@ -0,0 +1,19 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#search_on_screen
" Purpose: extract strings that visible on window from current file
function! railmoon#oscan#extractor#search_on_screen#create()
let new_extractor = railmoon#oscan#extractor#search#create()
let new_extractor.first_line_to_search = line('w0')
let new_extractor.last_line_to_search = line('w$')
let new_extractor.pattern = '.*'
let new_extractor.remove_leader_space = 0
let new_extractor.description = 'Search on current window visible range. From line '. new_extractor.first_line_to_search.' to line '.new_extractor.last_line_to_search
return new_extractor
endfunction

View File

@ -0,0 +1,34 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#ctags
" Purpose: extract ctags record from tags
function! railmoon#oscan#extractor#taglist#create()
let new_extractor = copy(s:tag_scan_taglist_extractor)
let new_extractor.file_name = expand("%:p")
let new_extractor.file_extension = expand("%:e")
let new_extractor.filetype = &filetype
let new_extractor.description = 'Move through all tags in "set tags=..." database'
let new_extractor.not_implemented = 1
return new_extractor
endfunction
let s:tag_scan_taglist_extractor = {}
function! s:tag_scan_taglist_extractor.process(record)
endfunction
function! s:tag_scan_taglist_extractor.extract()
let result = []
return result
endfunction
function! s:tag_scan_taglist_extractor.colorize()
let &filetype = self.filetype
call railmoon#oscan#extractor#ctags#colorize_keywords()
endfunction

View File

@ -0,0 +1,11 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#taglist_by_ooo
" Purpose: extract records by object oriented type.
function! railmoon#oscan#extractor#taglist_by_ooo#create()
return railmoon#oscan#extractor#taglist_by_type#create('s')
endfunction

View File

@ -0,0 +1,39 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#taglist_by_type
" Purpose: extract records by type. help module for taglist_by_class , etc..
function! railmoon#oscan#extractor#taglist_by_type#create(type)
let new_extractor = copy(s:tag_scan_taglist_by_type_extractor)
let new_extractor.file_name = expand("%:p")
let new_extractor.file_extension = expand("%:e")
let new_extractor.filetype = &filetype
let new_extractor.type = a:type
let new_extractor.description = 'Move through tags with ceratain type in "set tags=..." database "'
let new_extractor.not_implemented = 1
return new_extractor
endfunction
let s:tag_scan_taglist_by_type_extractor = {}
function! s:tag_scan_taglist_by_type_extractor.process(record)
endfunction
function! s:record_for_language_tag( language, ctag_item )
return railmoon#oscan#extractor#ctags#language_function( a:language, 'record', a:ctag_item )
endfunction
function! s:tag_scan_taglist_by_type_extractor.extract()
let result = []
return result
endfunction
function! s:tag_scan_taglist_by_type_extractor.colorize()
let &filetype = self.filetype
call railmoon#oscan#extractor#ctags#colorize_keywords()
endfunction

View File

@ -0,0 +1,54 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#taglist_under_cursor
" Purpose: extract ctags records that fit word under curosr
function! railmoon#oscan#extractor#taglist_under_cursor#create()
let new_extractor = copy(s:tag_scan_taglist_under_cursor_extractor)
let new_extractor.file_name = expand("%:p")
let new_extractor.file_extension = expand("%:e")
let new_extractor.filetype = &filetype
let new_extractor.word_under_cursor = expand('<cword>')
let new_extractor.description = 'Jump to tag "'.new_extractor.word_under_cursor.'" according to "'.&tags.'" tags dabase'
return new_extractor
endfunction
let s:tag_scan_taglist_under_cursor_extractor = {}
function! s:tag_scan_taglist_under_cursor_extractor.process(record)
exec 'tag '.self.word_under_cursor
call railmoon#oscan#extractor#ctags#process(a:record.data)
endfunction
function! s:record_for_language_tag( language, ctag_item )
return railmoon#oscan#extractor#ctags#language_function( a:language, 'record', a:ctag_item )
endfunction
function! s:tag_scan_taglist_under_cursor_extractor.extract()
if empty(self.word_under_cursor)
return []
endif
let result = []
let self.language = railmoon#oscan#extractor#ctags#language_by_current_buffer()
let ctags_tags = taglist('\<'.self.word_under_cursor.'\>')
for item in ctags_tags
let record = s:record_for_language_tag(self.language, item)
let record.data = item
call add(result, record)
endfor
return result
endfunction
function! s:tag_scan_taglist_under_cursor_extractor.colorize()
let &filetype = self.filetype
call railmoon#oscan#extractor#ctags#colorize_keywords(self.language)
endfunction

View File

@ -0,0 +1,74 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#util
" Purpose: common extration and tag generation functions
function! railmoon#oscan#extractor#util#tags_from_file_name(file_name)
let tags = []
let name_tags = split(a:file_name, '\W')
for l:tag in name_tags
if empty(l:tag)
continue
endif
if index(tags, string(l:tag)) != -1
continue
endif
call add(tags, l:tag)
endfor
return tags
endfunction
function! railmoon#oscan#extractor#util#tags_from_line(line)
let tags = split(a:line, '\W')
call filter(tags, 'v:val != ""')
if a:line =~ '='
call extend(tags, ['equal', '='])
endif
if a:line =~ '"' || a:line =~ "'"
call extend(tags, ['quotes', '"'])
endif
if a:line =~ '\.'
call extend(tags, ['dot', '.'])
endif
if a:line =~ '[+-/\*]'
call add(tags, 'sign')
endif
if a:line =~ '&&' || a:line =~ '||' || a:line =~ '==' || a:line =~ '!=' " TODO in one expression
call add(tags, 'logic')
endif
return tags
endfunction
function! railmoon#oscan#extractor#util#tags_from_searched_line(line_number, line)
let tags = railmoon#oscan#extractor#util#tags_from_line( a:line )
call add(tags, a:line_number)
return tags
endfunction
function! railmoon#oscan#extractor#util#buffer_list()
let result = []
for buffer_number in range(1, bufnr('$'))
if !buflisted(buffer_number)
continue
endif
call add(result, [buffer_number, fnamemodify(bufname(buffer_number), ':p')] )
endfor
return result
endfunction

View File

@ -0,0 +1,84 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#vims
" Purpose: extract vim servers to select
function! railmoon#oscan#extractor#vims#create()
let new_extractor = copy(s:tag_scan_vim_extractor)
let new_extractor.last_buffer_number = bufnr('$')
let new_extractor.buffer_number_width = len(line('$'))
let new_extractor.description = "Select buffer to edit among all opened Vims"
return new_extractor
endfunction
function! railmoon#oscan#extractor#vims#select_buffer(buffer_number)
let current_tabpage = tabpagenr()
let current_window = winnr()
for tabpage_number in range(1, tabpagenr('$'))
exec (tabpage_number) . 'tabnext'
for window_number in range(1, winnr('$'))
let buffer_number = winbufnr(window_number)
if buffer_number == a:buffer_number
exec (window_number) . 'wincmd w'
return
endif
endfor
endfor
exec (current_tabpage) . 'tabnext'
exec (current_window) . 'wincmd w'
endfunction
let s:tag_scan_vim_extractor = {}
function! s:tag_scan_vim_extractor.process(record)
let server_name = a:record.data[0]
let buffer_number = a:record.data[1]
call remote_foreground(server_name)
call remote_expr(server_name, 'railmoon#oscan#extractor#vims#select_buffer('.buffer_number.')')
endfunction
function! s:tag_scan_vim_extractor.extract()
let result = []
let vim_servers = split(serverlist(), "\n")
for servername in vim_servers
"echo servername
"redraw
let buffers_result = remote_expr(servername, 'railmoon#oscan#extractor#util#buffer_list()')
let buffers_result = '['.join(split(buffers_result, "\n"), ',').']'
let buffers_list = eval(buffers_result)
for buffer_info in buffers_list
let tags = [ servername ]
let buffer_number = buffer_info[0]
let buffer_name = buffer_info[1]
call add(tags, fnamemodify(buffer_name, ':p:t'))
call add(result, railmoon#oscan#record#create( [ buffer_name ],
\ tags,
\ [ servername, buffer_number ],
\ servername))
endfor
endfor
return result
endfunction
function! s:tag_scan_vim_extractor.colorize()
endfunction

View File

@ -0,0 +1,79 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: extractor#windows
" Purpose: extract window names to select
function! railmoon#oscan#extractor#windows#create()
let new_extractor = copy(s:tag_scan_windows_extractor)
let new_extractor.description = 'Select window to be active'
return new_extractor
endfunction
let s:tag_scan_windows_extractor = {}
function! s:tag_scan_windows_extractor.process(record)
exec a:record.data[0].'tabnext'
exec a:record.data[1].'wincmd w'
endfunction
function! s:tag_scan_windows_extractor.tags_by_name(buffer_name, buffer_number, tabpage_number, window_number)
let tags = railmoon#oscan#extractor#util#tags_from_file_name(a:buffer_name)
if index(tags, string(a:buffer_number)) == -1
call add(tags, a:buffer_number)
endif
call add(tags, 'tabpage'.a:tabpage_number)
call add(tags, 'window'.a:window_number)
return tags
endfunction
function! s:tag_scan_windows_extractor.header_by_name(buffer_name, buffer_number)
return [ a:buffer_name ]
endfunction
function! s:tag_scan_windows_extractor.extract()
let lazyredraw_status = &lazyredraw
set lazyredraw
let result = []
try
for tabpage_number in range(1, tabpagenr('$'))
exec (tabpage_number) . 'tabnext'
for window_number in range(1, winnr('$'))
let buffer_number = winbufnr(window_number)
let buffer_name = bufname(buffer_number)
exec window_number.'wincmd w'
let line_number = line('.')
call add(result, railmoon#oscan#record#create( self.header_by_name(buffer_name, buffer_number),
\ self.tags_by_name(buffer_name, buffer_number, tabpage_number, window_number),
\ [tabpage_number, window_number],
\ '[ '.tabpage_number.', '.window_number.' ] '.fnamemodify(buffer_name, ':p:t').' '.line_number))
endfor
endfor
catch /.*/
echo v:exception
echo v:throwpoint
finally
let &lazyredraw = lazyredraw_status
return result
endtry
endfunction
function! s:tag_scan_windows_extractor.colorize()
syntax match Comment /|.\{-}|/
syntax match Keyword /[\\/]/
syntax match Number /[0-9]\+/
endfunction

View File

@ -0,0 +1,138 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: record
" Purpose: represent record in oscan
" -
" [ plugin function ]
" Name: railmoon#oscan#record#create
" Purpose: create record
" [ parameters ]
" header record header -- list
" tag_list list of tags associated with record
" data record data ( line number, or buffer number, or whatever )
" -
function! railmoon#oscan#record#create( header, tag_list, data, ... )
let new_record = copy( s:record )
let s:record_id += 1
let new_record.header = a:header
let new_record.tag_list = a:tag_list
let new_record.data = a:data
let new_record.id = s:record_id
if empty(a:000)
let new_record.additional_info = ''
else
let new_record.additional_info = a:1
endif
return new_record
endfunction
let s:record = {}
let s:record_id = 0
" -
" [ object method ]
" Object: record
" Name: has_tag
" Purpose: determine tag presence
" [ parameters ]
" tag tag
" -
function! s:record.has_tag( tag )
if a:tag[0] == '~'
for l:tag in self.tag_list
if l:tag =~ '\c'.a:tag[1 : ]
return 1
endif
endfor
return 0
endif
for l:tag in self.tag_list
if l:tag ==? a:tag
return 1
endif
endfor
return 0
endfunction
" -
" [ object method ]
" Object: record
" Name: match_by_tags
" Purpose: determine if record match with given tags
" [ parameters ]
" tags list of tags
" -
function! s:record.match_by_tags( tags )
for l:tag in a:tags
if ! self.has_tag( l:tag )
return 0
endif
endfor
return 1
endfunction
" -
" [ object method ]
" Object: record
" Name: other_tags
" Purpose: find tags that not in list but in that record
" [ parameters ]
" tags1 list of tags
" tags2 list of tags
" -
function! s:record.other_tags( tags1, tags2 )
let result = []
for l:tag in self.tag_list
let string_tag = l:tag.''
if index(a:tags1, string_tag) == -1 &&
\index(a:tags2, string_tag) == -1
call add(result, string_tag)
endif
endfor
return result
endfunction
" -
" [ testing ]
" -
function! s:create_test_record1()
return railmoon#oscan#record#create( ['createTestRecord1'], [ 'edit', 'gui', 'form' ], 23 )
endfunction
function! s:create_test_record2()
return railmoon#oscan#record#create( ['createTestRecord2'], [ 'simple', 'gui' ], 26 )
endfunction
let s:unit_test = railmoon#unit_test#create('oscan#record')
function! s:unit_test.test_record()
call self.assert_equal(s:create_test_record1().match_by_tags(['edit']), 1)
call self.assert_equal(s:create_test_record1().match_by_tags(['~dit']), 1)
call self.assert_equal(s:create_test_record1().match_by_tags(['gui']), 1)
call self.assert_equal(s:create_test_record1().match_by_tags(['form']), 1)
call self.assert_equal(s:create_test_record1().match_by_tags(['form', 'gui']), 1)
call self.assert_equal(s:create_test_record1().match_by_tags(['edit', 'form', 'gui']), 1)
call self.assert_equal(! s:create_test_record1().match_by_tags(['simple', 'gui']), 1)
call self.assert_equal(! s:create_test_record1().match_by_tags(['edit', 'fronmt', 'gui']), 1)
call self.assert_equal(s:create_test_record1().other_tags(['edit', 'gui'], []), ['form'])
call self.assert_equal(s:create_test_record1().other_tags(['gui'], []), ['edit', 'form'])
call self.assert_equal(s:create_test_record1().other_tags([''], []), ['edit', 'gui', 'form'])
call self.assert_equal(s:create_test_record1().other_tags(['edit', 'gui', 'form'], []), [])
endfunction
call s:unit_test.run()

View File

@ -0,0 +1,132 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Plugin: oscan
" Module: record_browser
" Purpose: represent record browser in oscan
function! railmoon#oscan#record_browser#create( record_extractor )
let new_record_browser = copy( s:record_browser )
let new_record_browser.record_extractor = a:record_extractor
let new_record_browser.all_records = new_record_browser.record_extractor.extract()
return new_record_browser
endfunction
let s:record_browser = {}
function! s:record_browser.is_empty()
return empty(self.all_records)
endfunction
" by list of tags return records that match tag list
" record1 tags = ['method', 'create', 'button']
" record2 tags = ['function', 'create', 'widget']
" record3 tags = ['method', 'create', 'file']
" tag_list = ['method', 'create']
" result = [record1, record3]
function! s:record_browser.get_matched_records( tag_list )
let result = []
for record in self.all_records
if record.match_by_tags( a:tag_list )
call add(result, record)
endif
endfor
return result
endfunction
" by list of tags return tags that can specify other records
" example:
" record1 tags = ['method', 'create', 'button']
" record2 tags = ['method', 'create', 'widget']
" record3 tags = ['method', 'create', 'file']
" tag_list = ['method', 'create']
" result = ['widget', 'button', 'file']
function! s:record_browser.get_available_tags( tag_list ) " TODO useful?
let result = []
for record in self.all_records
if record.match_by_tags( a:tag_list )
call extend(result, record.other_tags( result, a:tag_list ))
endif
endfor
return result
endfunction
" by list of tags return tags that can specify other records
" example above
function! s:record_browser.get_available_tags_for_records( matched_records, tag_list )
let result = []
for record in a:matched_records
let other_tags = record.other_tags( result, a:tag_list )
for element in other_tags
let string_tag = element.''
if index(result, string_tag) == -1
call add(result, string_tag)
endif
endfor
" call extend(result, record.other_tags( result, a:tag_list ))
endfor
return result
endfunction
" -
" [ testing ]
" -
function! s:create_test_record1()
return railmoon#oscan#record#create( 'createTestRecord1', [ 'edit', 'gui', 'form' ], 23 )
endfunction
function! s:create_test_record2()
return railmoon#oscan#record#create( 'createTestRecord2', [ 'simple', 'gui' ], 26 )
endfunction
let s:test_record_extractor = {}
function! s:test_record_extractor.new()
let new_test_record_extractor = copy( s:test_record_extractor )
let new_test_record_extractor.record1 = s:create_test_record1()
let new_test_record_extractor.record2 = s:create_test_record2()
let new_test_record_extractor.records = [ new_test_record_extractor.record1, new_test_record_extractor.record2 ]
return new_test_record_extractor
endfunction
function! s:test_record_extractor.extract()
return self.records
endfunction
let s:unit_test = railmoon#unit_test#create('oscan#record_browser')
function! s:unit_test.test_record_browser()
let record_extractor = s:test_record_extractor.new()
let record_browser = railmoon#oscan#record_browser#create(record_extractor)
call self.assert_equal(len(record_browser.get_matched_records( [] )), 2)
call self.assert_equal(len(record_browser.get_matched_records( ['simple'] )), 1)
call self.assert_equal((record_browser.get_matched_records( ['simple'] ))[0].id, record_extractor.record2.id)
call self.assert_equal((record_browser.get_matched_records( ['edit', 'form'] ))[0].id, record_extractor.record1.id)
let matched_records = record_browser.get_matched_records(['gui'])
call self.assert_equal(record_browser.get_available_tags_for_records(matched_records, ['gui']), ['edit', 'form', 'simple'])
let matched_records = record_browser.get_matched_records(['form', 'gui'])
call self.assert_equal(record_browser.get_available_tags_for_records(matched_records, ['form', 'gui']), ['edit'])
endfunction
call s:unit_test.run()

45
vim/autoload/railmoon/trace.vim Executable file
View File

@ -0,0 +1,45 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Module: railmoon#trace
" Purpose: help write debug information and call stack
function! railmoon#trace#start_debug(file_name)
let s:is_debug_on = 1
let s:debug = 1
let s:log_file_name = a:file_name
call delete(s:log_file_name)
exec 'redir! > '.s:log_file_name
echo 'start_debug'
exec 'redir END'
endfunction
function! railmoon#trace#push(function_name)
if s:is_debug_on
call add(s:stack, a:function_name)
endif
endfunction
function! railmoon#trace#pop()
if s:is_debug_on
let s:stack = s:stack[ : -2]
endif
endfunction
function! railmoon#trace#debug(message)
if s:debug
call s:write(a:message)
endif
endfunction
function! s:write(message)
exec 'redir >> '.s:log_file_name
silent echo '[ '.join(s:stack, ' >> ').'] '.a:message
exec 'redir END'
endfunction
let s:is_debug_on = 0
let s:debug = 0
let s:stack = []

View File

@ -0,0 +1,69 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Module: railmoon#unit_test
" Purpose: provide unit test object
" -
" [ public library function ]
" Name: railmoon#unit_test#create
" Purpose: create "unit test" object
" [ parameters ]
" name name of test
" -
function! railmoon#unit_test#create(name)
let new_object = deepcopy(s:unit_test)
let new_object.name = a:name
let new_object.number_of_test = 0
return new_object
endfunction
" -
" [ internal usage ]
" Name: unit_test
" Purpose: object "unit test"
" -
let s:unit_test = {}
" -
" [ object method ]
" Object: unit_test
" Name: assert_equal
" Purpose: compare two values
" -
function! s:unit_test.assert_equal(first, second)
if !( a:second == a:first )
throw string(a:first).' != '.string(a:second)
endif
let self.number_of_test += 1
endfunction
" -
" [ object method ]
" Object: unit_test
" Name: run
" Purpose: run all unit tests from suit
" -
function! s:unit_test.run()
let test_name = ''
try
for key in keys(self)
if key =~ '^test_'
let self.number_of_test = 1
let call_command = 'call self.'.key.'()'
let test_name = substitute(key, '^test_\(.*\)', '\1', '')
exec call_command
endif
endfor
catch /.*/
echohl Identifier | echo 'Suit:'.self.name | echohl None
echohl Identifier | echo 'Test:'.test_name | echohl None
echohl Identifier | echo 'Number:'.self.number_of_test | echohl None
echohl Statement | echo v:exception | echohl None
echohl Statement | echo v:throwpoint | echohl None
endtry
endfunction

View File

@ -0,0 +1,21 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Module: railmoon#widget
" Purpose: common util function for widget functionality
let s:handle_autocommands = 1
function! railmoon#widget#stop_handle_autocommands()
let s:handle_autocommands = 0
endfunction
function! railmoon#widget#start_handle_autocommands()
let s:handle_autocommands = 1
endfunction
function! railmoon#widget#handle_autocommands()
return s:handle_autocommands
endfunction

View File

@ -0,0 +1,571 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Module: railmoon#widget#base
" Purpose: base widget functionality and vim windows triggers handler
" -
" [ internal usage ]
" Purpose: collect widget that will be closed
" -
let s:widget_for_close = []
function! s:clear_widget_for_close()
let s:widget_for_close = []
endfunction
function! s:widget_present(list, widget)
for widget in a:list
if widget.id == a:widget.id
return 1
endif
endfor
return 0
endfunction
function! s:add_widget_for_close(widget)
if s:widget_present(s:widget_for_close, a:widget)
return
endif
call add(s:widget_for_close, a:widget)
endfunction
function! s:remove_widget_from_delete(widget)
if ! s:widget_present(s:widget_for_close, a:widget)
return
endif
call filter(s:widget_for_close, 'v:val.id != '.a:widget.id)
endfunction
let s:buffer_name_prefix = 'rmwidget'
let s:in_create_widget_state = 0
" -
" [ public for extend library function ]
" Name: railmoon#widget#base#create
" Purpose: create base widget
" [ parameters ]
" name widget window name
" titlename name that will on title bar
" child widget that inherit base
" child_callback_object call back object with following methods that child can
" react on
" on_close
" on_close_with_tab_page
" on_focus
" on_focus_lost
" on_setup
" callback_object user defined call back object
" -
function! railmoon#widget#base#create(name, titlename, child, child_callback_object, callback_object)
call s:clear_widget_for_close()
let new_object = extend( deepcopy(s:base), deepcopy(a:child) )
call railmoon#trace#debug('create base:'.a:name)
call railmoon#trace#debug(string(new_object))
" if bufexists(escaped_name)
" throw 'widget:base:buffer_exists'
" endif
let new_object.id = railmoon#id#acquire('railmoon_widget_id')
let new_object.name = a:name
let new_object.titlename = a:titlename
let new_object.child_callback_object = a:child_callback_object
let new_object.callback_object = a:callback_object
let new_object.is_closed = 0
let buffer_name = s:buffer_name_prefix.new_object.id
let s:in_create_widget_state = 1
let buffer_number = bufnr( buffer_name )
if -1 == buffer_number
exec 'silent edit '.buffer_name
else
exec 'silent buffer '.buffer_number
endif
exec 'setlocal statusline='.escape(new_object.name, ' ')
setlocal noreadonly
let w:widget_id = new_object.id
let w:widget = new_object
let b:widget_id = new_object.id
let b:widget = new_object
call s:buffer_auto_command_setup()
call s:buffer_setup()
let s:in_create_widget_state = 0
return new_object
endfunction
" -
" [ internal usage ]
" Name: railmoon#widget#base#call_back
" Purpose: call back method for handlers
" -
function! railmoon#widget#base#call_back(widget, method_name, ... )
let arguments = join(a:000, ';')
call railmoon#trace#debug('call back for widget. name:'. a:widget.name. '; method:'.a:method_name.' ; arguments:'.arguments)
let exec_line = 'call object.'.a:method_name.'('.arguments.')'
for object in [ a:widget.child_callback_object, a:widget.callback_object ]
if has_key(object, a:method_name)
call railmoon#trace#debug(exec_line)
exec exec_line
endif
endfor
endfunction
" -
" [ internal usage ]
" Name: buffer_option_setup
" Purpose: setup common local options for widget buffer
" -
function! s:buffer_option_setup()
setlocal noswapfile
setlocal nomodifiable
setlocal bufhidden=delete
setlocal buftype=nofile
setlocal nobuflisted
setlocal nonumber
setlocal nowrap
setlocal nocursorline
endfunction
function! s:redraw_widget()
if has_key(b:widget, 'draw')
call b:widget.draw()
endif
endfunction
" -
" [ internal usage ]
" Name: buffer_setup
" Purpose: when buffer needs to be resetup. after reopen in widget window
" -
function! s:buffer_setup()
call s:buffer_option_setup()
let b:widget = w:widget
let b:widget_id = w:widget_id
call s:set_widget_title()
if s:in_create_widget_state
return
endif
call railmoon#widget#base#call_back(b:widget, 'on_setup')
call s:redraw_widget()
endfunction
" -
" [ internal usage ]
" Name: buffer_auto_command_setup
" Purpose: setup common handlers for window triggers
" -
function! s:buffer_auto_command_setup()
autocmd! * <buffer>
autocmd BufWinLeave <buffer> call s:on_buffer_win_leave()
autocmd WinEnter <buffer> call s:on_window_enter()
autocmd WinLeave <buffer> call s:on_window_leave()
autocmd TabLeave <buffer> call s:on_tab_leave()
endfunction
" -
" [ internal usage ]
" Name: auto_command_setup
" Purpose: setup handlers for any window or buffer to resolve conflicts
" -
function! s:auto_command_setup()
augroup base_widget_autocommands
autocmd!
autocmd WinEnter * call s:on_any_window_enter()
autocmd BufEnter * call s:on_any_buffer_enter()
autocmd BufWinEnter * call s:on_any_buffer_window_enter()
" autocmd BufWinLeave * call s:on_any_buffer_win_leave()
augroup END
endfunction
function! s:widget_in_auto_command()
let buffer_name = expand('<afile>')
let widget = getbufvar(buffer_name, 'widget')
if empty(widget)
throw 'widget not found!!!! TODO'
endif
return widget
endfunction
function! s:on_any_buffer_window_enter()
call railmoon#trace#push('on_any_buffer_window_enter')
try
let buffer_name = expand('<afile>')
call railmoon#trace#debug('name: '.buffer_name)
if empty(buffer_name) " TODO
return
endif
if ! railmoon#widget#handle_autocommands()
call railmoon#trace#debug('handle autocommands stoped')
return
endif
if exists('w:widget_id') && !exists('b:widget_id')
call railmoon#trace#debug('w:widget_id present but b:widget_id not')
call s:remove_widget_from_delete(w:widget)
let buffer_number = bufnr(s:buffer_name_prefix.w:widget_id)
let buffer_change_cmd = 'buffer '.buffer_number
call railmoon#trace#debug(buffer_change_cmd)
exec buffer_change_cmd
call s:buffer_setup()
return
endif
if exists('b:widget_id') && !exists('w:widget_id')
call railmoon#trace#debug('b:widget exists but w:widget not')
close
return
endif
catch /.*/
echo v:exception
call railmoon#trace#debug(v:exception)
finally
if exists('w:widget')
call s:remove_widget_from_delete(w:widget)
endif
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
" -
" [ internal usage ]
" Name: on_buffer_win_leave
" Purpose: handle widget close event
" -
function! s:on_buffer_win_leave()
call railmoon#trace#push('on_buffer_win_leave')
try
let widget = s:widget_in_auto_command()
call railmoon#trace#debug('widget for close set up')
call s:add_widget_for_close(widget)
if widget.is_closed
call railmoon#trace#debug('already closed')
return
endif
let buffer_name = expand('<afile>')
" closed by close tab page
" TODO find out another cases
" when <afile> != %
if buffer_name != bufname('%')
let s:close_with_tab_page = 1
" TODO s:close_with_tab_page
else
let s:close_with_tab_page = 0
endif
finally
call s:close_ready_for_close_widgets()
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
function! railmoon#widget#base#gui_tab_label()
if v:lnum == s:current_tab_page_number
return s:current_widget_name
endif
" let old_line = s:old_gui_tab_label
" let old_line = substitute(old_line, '%{\(.\{-}\)}', '\1', 'g')
" return eval(old_line)
return ''
endfunction
function! railmoon#widget#base#tab_line()
return s:current_widget_name
endfunction
function! s:set_widget_title()
let s:current_tab_page_number = tabpagenr()
let s:current_widget_name = b:widget.name
let s:current_widget_title_name = b:widget.titlename
if ! exists('s:old_title_string')
let s:old_title_string = &titlestring
let s:old_gui_tab_label = &guitablabel
let s:old_tab_line = &tabline
endif
let &titlestring = s:current_widget_title_name
set guitablabel=%{railmoon#widget#base#gui_tab_label()}
set tabline=%!railmoon#widget#base#tab_line()
exec 'setlocal statusline='.escape(s:current_widget_name, ' ')
endfunction
function! s:restore_original_title()
if exists('s:old_title_string')
let &titlestring = s:old_title_string
let &guitablabel = s:old_gui_tab_label
let &tabline = s:old_tab_line
unlet s:old_title_string
unlet s:old_gui_tab_label
endif
endfunction
" -
" [ internal usage ]
" Name: on_window_enter
" Purpose: handle gain focus event
" -
function! s:on_window_enter()
call railmoon#trace#push('on_window_enter')
try
let widget = s:widget_in_auto_command()
call s:set_widget_title()
call railmoon#widget#base#call_back(widget, 'on_focus')
catch /widget not found/
call railmoon#trace#debug(v:exception)
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
function! s:on_any_buffer_enter()
call railmoon#trace#push('on_any_buffer_enter')
try
if ! railmoon#widget#handle_autocommands()
call railmoon#trace#debug('handle autocommands stoped')
return
endif
let buffer_name = expand('<afile>')
call railmoon#trace#debug('buffer name:'.buffer_name)
call railmoon#trace#debug('in_create_widget_state:'.s:in_create_widget_state)
" attempt to edit file with name reserved to widget buffers
"
if !exists('b:widget_id') && ! s:in_create_widget_state
call railmoon#trace#debug('b:widget not found')
if buffer_name =~ s:buffer_name_prefix
call railmoon#trace#debug('name of widget buffer')
if buffer_name == expand('%')
call railmoon#trace#debug('open alternate window')
buffer #
endif
endif
"
" attempt to re open widget buffer
elseif exists('b:widget_id') && ! s:in_create_widget_state
call railmoon#widget#base#call_back(b:widget, 'on_setup')
call s:redraw_widget()
endif
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
function! s:close_ready_for_close_widgets()
call railmoon#trace#push('s:close_ready_for_close_widgets()')
try
for widget in s:widget_for_close
call railmoon#trace#debug('s:widget_for_close exists')
if widget.is_closed
call railmoon#trace#debug('already closed')
else
if s:close_with_tab_page
call railmoon#widget#base#call_back(widget, 'on_close_with_tab_page')
else
call railmoon#widget#base#call_back(widget, 'on_close')
endif
let widget.is_closed = 1
call railmoon#id#release('railmoon_widget_id', widget.id)
endif
endfor
call s:clear_widget_for_close()
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
function! s:on_any_window_enter()
call railmoon#trace#push('on_any_window_enter')
try
call railmoon#trace#debug('name: '.expand('<afile>'))
if ! railmoon#widget#handle_autocommands()
call railmoon#trace#debug('handle autocommands stoped')
return
endif
call s:close_ready_for_close_widgets()
" split or something like that
if exists('b:widget_id') && !exists('w:widget_id') && ! s:in_create_widget_state
call railmoon#trace#debug('b:widget_id present but w:widget_id not')
call railmoon#trace#debug('closing')
close
endif
if exists('w:widget_id') && !exists('b:widget_id')
call railmoon#trace#debug('w:widget_id present but b:widget_id not')
close
endif
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
" -
" [ internal usage ]
" Name: on_tab_leave
" Purpose: handle tab page lost focus event
" -
function! s:on_tab_leave()
call railmoon#trace#push('on_window_leave')
try
call railmoon#widget#base#call_back(b:widget, 'on_tab_leave')
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
" -
" [ internal usage ]
" Name: on_window_leave
" Purpose: handle lost focus event
" -
function! s:on_window_leave()
call railmoon#trace#push('on_window_leave')
try
if !exists('b:widget')
call railmoon#trace#debug('b:widget not present')
return
endif
if b:widget.is_closed
call railmoon#trace#debug('already closed')
return
endif
call railmoon#widget#base#call_back(b:widget, 'on_focus_lost')
catch /.*/
call railmoon#trace#debug(v:exception)
call railmoon#trace#debug(v:throwpoint)
finally
call s:restore_original_title()
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
" -
" [ internal usage ]
" Name: base
" Purpose: base widget object
" -
let s:base = {}
function! s:base.select()
call railmoon#trace#push('base.select')
try
let id = self.id
call railmoon#trace#debug('selecting...')
call railmoon#widget#window#select(id)
finally
call railmoon#trace#debug('id = '.id)
call railmoon#trace#pop()
endtry
endfunction
function! s:base.close()
call railmoon#trace#push('base.close')
try
if self.is_closed
call railmoon#trace#debug('already closed')
return
endif
let not_active = (w:widget_id != self.id)
if not_active
let selected = railmoon#widget#window#save_selected()
endif
call self.select()
call railmoon#trace#debug('closing.. id = '.self.id)
let window_numbers = winnr('$')
let self.is_closed = 1
close
if not_active
call railmoon#widget#window#load_selected(selected)
endif
call railmoon#id#release('railmoon_widget_id', self.id)
if window_numbers > 1
call railmoon#widget#base#call_back(self, 'on_close')
else
call railmoon#widget#base#call_back(self, 'on_close_with_tab_page')
endif
finally
call s:close_ready_for_close_widgets()
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
call s:auto_command_setup()

View File

@ -0,0 +1,82 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Module: railmoon#widget#canvas
" Purpose: widget for drawing inside it
" -
" [ internal usage ]
" Name: callback_object
" Purpose: handler for base back calls
" -
let s:callback_object = {}
" -
" [ public library function ]
" Name: railmoon#widget#canvas#create
" Purpose: create "canvas" widget
" [ parameters ]
" name name of new vim window that will represent widget
" callback_object call back object with following methods
" on_draw() draw what inside canvas
" -
function! railmoon#widget#canvas#create(name, callback_object)
let new_object = railmoon#widget#base#create(a:name, s:canvas, [a:callback_object, s:callback_object])
call s:auto_command_setup()
return new_object
endfunction
" -
" [ internal usage ]
" Name: auto_command_setup
" Purpose: setup handlers for window triggers
" -
function! s:auto_command_setup()
" autocmd CursorMoved <buffer> call s:on_cursor_moved()
endfunction
function! s:callback_object.on_setup()
endfunction
" -
" [ internal usage ]
" Name: canvas
" Purpose: widget object "canvas"
" -
let s:canvas = {}
" -
" [ object method ]
" Object: canvas
" Name: draw
" Purpose: prepare_canvas for drawing and call user defined on_draw method
" -
function! s:canvas.draw()
call railmoon#trace#push('canvas.draw')
try
let selected = railmoon#widget#window#save_selected()
let is_selected = railmoon#widget#window#select(self.id)
if ! is_selected
throw 'widget:selection_window:draw:window_not_found'
endif
setlocal modifiable
0,$delete _
call railmoon#draw#prepare_canvas(winwidth('%'), winheight('%'))
call railmoon#widget#base#call_back(self, 'on_draw()')
setlocal nomodifiable
call railmoon#widget#window#load_selected(selected)
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction

View File

@ -0,0 +1,207 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Home: www.railmoon.com
" Module: railmoon#widget#edit_line_window
" Purpose: provide window with callbacks for editing single line
let s:callback_object = {}
" -
" [ public library function ]
" Name: railmoon#widget#edit_line_window#create
" Purpose: create "edit line window" widget
" [ parameters ]
" name name of new vim window that will represent widget
" titlename name that will on title bar
" callback_object call back object with following methods
" on_normal_move
" on_insert_move
" on_type(character, is_alpha_numeric) : should return character to type
" -- and common handlers
" -
function! railmoon#widget#edit_line_window#create(name, titlename, callback_object)
let new_object = railmoon#widget#base#create(a:name, a:titlename, s:edit_line_window, s:callback_object, a:callback_object)
call railmoon#trace#debug('create edit line window:'.a:name)
" call railmoon#trace#debug(string(new_object))
setlocal modifiable
call s:auto_command_setup()
call s:insert_mode_key_typing_setup()
return new_object
endfunction
" -
" [ internal usage ]
" Name: edit_line_window
" Purpose: widget object "edit line window"
" -
let s:edit_line_window = {}
" -
" [ object method ]
" Object: edit_line_window
" Name: get_line
" Purpose: return entered line
" -
function! s:edit_line_window.get_line()
let selected = railmoon#widget#window#save_selected()
call self.select()
let text_line = getline(1)
call railmoon#widget#window#load_selected(selected)
return text_line
endfunction
" -
" [ object method ]
" Object: edit_line_window
" Name: set_line
" Purpose: setup text line to "edit line window"
" -
function! s:edit_line_window.set_line(line)
let selected = railmoon#widget#window#save_selected()
call self.select()
call setline(1, a:line)
call railmoon#widget#window#load_selected(selected)
endfunction
" -
" [ object method ]
" Object: edit_line_window
" Name: go_to_position
" Purpose: move cursor to specified position
" -
function! s:edit_line_window.go_to_position(position)
call self.select()
call cursor(1, a:position)
endfunction
" -
" [ object method ]
" Object: edit_line_window
" Name: go_to_end
" Purpose: move cursor to end
" -
function! s:edit_line_window.go_to_end()
call self.select()
call cursor(1, col('$'))
endfunction
" -
" [ object method ]
" Object: edit_line_window
" Name: go_to_start
" Purpose: move cursor to start of line
" -
function! s:edit_line_window.go_to_start()
call self.select()
call cursor(1, 1)
endfunction
" -
" [ internal usage ]
" Name: insert_mode_key_typing_setup
" Purpose: setup handlers for typing characters
" -
function! s:insert_mode_key_typing_setup()
for item in s:alpha_numeric_characters
execute 'inoremap <buffer> <silent> ' . item . ' <C-R>=<SID>on_insert_typing('''.item.''', 1)<CR>'
endfor
for item in s:not_alpha_numeric_characters
execute 'inoremap <buffer> <silent> ' . item . ' <C-R>=<SID>on_insert_typing('''.item.''', 0)<CR>'
endfor
endfunction
function! s:callback_object.on_setup()
call s:insert_mode_key_typing_setup()
endfunction
" -
" [ internal usage ]
" Name: on_insert_typing
" Purpose: handle typing
" -
function! s:on_insert_typing(character, is_alpha_numeric)
let callback_object = b:widget.callback_object
if has_key(callback_object, 'on_type')
return callback_object.on_type( a:character, a:is_alpha_numeric )
endif
return a:character
endfunction
" -
" [ internal usage ]
" Name: auto_command_setup
" Purpose: setup auto commands
" -
function! s:auto_command_setup()
autocmd CursorMoved <buffer> call s:on_cursor_moved(s:normal_mode)
autocmd CursorMovedI <buffer> call s:on_cursor_moved(s:insert_mode)
endfunction
" -
" [ internal usage ]
" Name: on_cursor_moved
" Purpose: handle cursor movement
" -
function! s:on_cursor_moved(mode)
if line('$') > 1
let new_line = join(getline(1, '$'), '')
2,$d
call setline(1, new_line)
call cursor(1, col('$'))
endif
let callback_object = w:widget.callback_object
if a:mode == s:normal_mode
call railmoon#widget#base#call_back(w:widget, 'on_normal_move')
else
call railmoon#widget#base#call_back(w:widget, 'on_insert_move')
endif
endfunction
" -
" [ internal usage ]
" Name: normal_mode
" Purpose: enumeration of mode
" -
let s:normal_mode = 0
" -
" [ internal usage ]
" Name: insert_mode
" Purpose: enumeration of mode
" -
let s:insert_mode = 1
" -
" [ internal usage ]
" Name: alpha_numeric_characters
" Purpose: store all typing characters
" -
let s:alpha_numeric_characters =
\ ['a','b','c','d','e','f','g','h','i','j','k','l','m',
\ 'n','o','p','q','r','s','t','u','v','w','x','y','z',
\ 'A','B','C','D','E','F','G','H','I','J','K','L','M',
\ 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
\ '0','1','2','3','4','5','6','7','8','9','<space>','_','=','"',':',';','.']
" -
" [ internal usage ]
" Name: not_alpha_numeric_characters
" Purpose: store not alpha numeric characters
" -
let s:not_alpha_numeric_characters =
\ ['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '-',
\ '{', '}', '[', ']', "'", '<', '>', ',', '?', '`', '~', '\', '\|']

View File

@ -0,0 +1,408 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Site: www.railmoon.com
" Module: railmoon#widget#selection_window
" Purpose: provide window with ability to select elements
" -
" [ internal usage ]
" Name: callback_object
" Purpose: handler for base back calls
" -
let s:callback_object = {}
"
" elements for selection windows are dictionaries that have
" .data as list [] of text
" .header optional value that will be right aligned at left side of list
" -
" [ public library function ]
" Name: railmoon#widget#selection_window#create
" Purpose: create "selection window" widget
" [ parameters ]
" name name of new vim window that will represent widget
" titlename name that will on title bar
" callback_object call back object with following methods
" on_select(selected_line_text)
" on_close
" on_close_with_tab_page
" model model representation with following methods
" get_item(element)
" get_item_count()
" -
function! railmoon#widget#selection_window#create(name, titlename, selection_group, model, callback_object)
let new_object = railmoon#widget#base#create(a:name, a:titlename, s:selection_window, s:callback_object, a:callback_object)
call railmoon#trace#debug('create selection_window:'.a:name)
call railmoon#trace#debug(string(new_object))
let new_object.selected_item_number = 1
let new_object.selection_group = a:selection_group
let new_object.model = a:model
let new_object.yoffset = 0
let new_object.item_positions = []
" call new_object.draw_selection()
call s:auto_command_setup()
call s:key_mappings_setup()
return new_object
endfunction
" -
" [ internal usage ]
" Name: auto_command_setup
" Purpose: setup handlers for window triggers
" -
function! s:auto_command_setup()
autocmd CursorMoved <buffer> call s:on_cursor_moved()
endfunction
function! s:callback_object.on_setup()
call s:key_mappings_setup()
endfunction
" -
" [ internal usage ]
" Name: key_mappings_setup
" Purpose: setup key handlers for "selection window"
" -
function! s:key_mappings_setup()
nnoremap <buffer> <CR> :call <SID>on_select()<CR>
nnoremap <buffer> <2-LeftMouse> :call <SID>on_select()<CR>
endfunction
" -
" [ internal usage ]
" Name: on_select
" Purpose: handle item select command
" -
function! s:on_select()
let selected_item = w:widget.selected_item()
call railmoon#widget#base#call_back(w:widget, 'on_select', '"'.escape(string(selected_item),"\"'").'"')
endfunction
" -
" [ internal usage ]
" Name: on_cursor_moved
" Purpose: handle normal mode curor movement
" -
function! s:on_cursor_moved()
let line_number = line('.')
call w:widget.select_line(line_number)
endfunction
" -
" [ internal usage ]
" Name: selection_window
" Purpose: widget object "selection window"
" -
let s:selection_window = {}
" -
" [ internal usage ]
" Name: highlight_line
" Purpose: highlight line in selection window
" [ parameters ]
" line_number number of line to highlight
" group highlight group to use as highlight
" -
function! s:highlight_line(start, end, group)
let start = '"\%'.(a:start + 1).'l"'
let end = '"\%'.(a:end + 1).'l"'
let id = w:widget_id
let syn_command = 'syn region selection_window_selected_line'.id.' start='.start.' end = '.end.' contains=Search'
let hi_link_command = 'hi link selection_window_selected_line'.id.' '.a:group
exec syn_command
exec hi_link_command
endfunction
" -
" [ internal usage ]
" Name: clear_highlight_line
" Purpose: remove highlight line in selection window
" -
function! s:clear_highlight_line()
let id = w:widget_id
try
exec 'syntax clear selection_window_selected_line'.id
catch /.*/
endtry
endfunction
" -
" [ object method ]
" Object: selection_window
" Name: draw
" Purpose: append all lines to buffer while remove old ones
" -
function! s:selection_window.draw()
call railmoon#trace#push('selection_window.draw')
try
let selected = railmoon#widget#window#save_selected()
let is_selected = railmoon#widget#window#select(self.id)
if ! is_selected
throw 'widget:selection_window:draw:window_not_found'
endif
setlocal modifiable
0,$delete _
let y = 0
let i = 0
let item_count = self.model.get_item_count()
let item_size = len(self.model.get_item(0).data)
let header_max_lenght = 0
let self.item_positions = []
let items_to_draw = []
" gathrer visual items on window
" determine max header length
"
while y <= ( winheight('%') - item_size ) && ( i < item_count )
let item = self.model.get_item(i)
let item_header_len = len(item.header)
if item_header_len > header_max_lenght
let header_max_lenght = item_header_len
endif
call add(items_to_draw, item)
let item_size = len(item.data)
call add( self.item_positions, [ y, y + item_size ] )
let y += item_size
let i += 1
endwhile
let is_no_headers = header_max_lenght == 0
" highlight headers if any
"
let window_id = w:widget_id
try
exec 'syntax clear selection_window_lines_header'.window_id
catch /.*/
endtry
if ! is_no_headers
exec 'syntax match selection_window_lines_header'.window_id.' "^[^|]\+|"'
endif
try
exec 'hi link selection_window_lines_header'.window_id.' String'
catch /.*/
endtry
let lines = []
" build lines to append to buffer
"
for item in items_to_draw
let item_header = item.header
let is_header_present = len(item_header) > 0
if is_header_present
call add(lines, printf(' %-'.header_max_lenght.'s | ', item_header).item.data[0])
elseif is_no_headers
call add(lines, ' '.item.data[0])
else
call add(lines, printf(' %'.header_max_lenght.'s ', item_header).item.data[0])
endif
for line in item.data[1:]
if is_header_present
call add(lines, printf(' %-'.header_max_lenght.'s | ', '').line)
elseif is_no_headers
call add(lines, ' '.line)
else
call add(lines, printf(' %'.header_max_lenght.'s ', '').line)
endif
endfor
endfor
let win_width = winwidth('%')
let wide_lines = []
for line in lines
let diff = win_width - len(line)
let new_line = line
if diff > 0
let new_line = line . printf('%'.diff.'s', ' ')
endif
call add(wide_lines, new_line)
endfor
call setline(1, wide_lines)
call self.draw_selection()
setlocal nomodifiable
call railmoon#widget#window#load_selected(selected)
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
" -
" [ object method ]
" Object: selection_window
" Name: draw_selection
" Purpose: show selection in selection window
" -
function! s:selection_window.draw_selection()
call railmoon#trace#push('selection_window.draw_selection')
call railmoon#trace#debug('id = '.self.id)
try
let selected = railmoon#widget#window#save_selected()
call self.select()
if len(self.item_positions) > 0
let start_line_number_in_window = self.item_positions[ self.selected_item_number - 1 ][0]
let end_line_number_in_window = self.item_positions[ self.selected_item_number - 1 ][1]
exec start_line_number_in_window
call s:clear_highlight_line()
call s:highlight_line(start_line_number_in_window, end_line_number_in_window, self.selection_group)
endif
call railmoon#widget#window#load_selected(selected)
finally
call railmoon#trace#pop()
endtry
endfunction
" -
" [ object method ]
" Object: selection_window
" Name: scrool_to
" Purpose: scrool window to show given line as first line
" [ parameters ]
" line_number line to show first in window
" -
function! s:selection_window.scrool_to(line_number)
let self.yoffset = a:line_number
call self.draw()
endfunction
" -
" [ object method ]
" Object: selection_window
" Name: selection_down
" Purpose: select next item
" [ parameters ]
" cycle cycle or not movement
" -
function! s:selection_window.selection_down(cycle)
let last_item_number_on_window = len(self.item_positions)
if self.selected_item_number >= last_item_number_on_window
if ! a:cycle
return
else
let self.selected_item_number = 1
endif
else
let self.selected_item_number += 1
endif
call self.draw_selection()
endfunction
" -
" [ object method ]
" Object: selection_window
" Name: selection_up
" Purpose: select previous item
" [ parameters ]
" cycle cycle or not movement
" -
function! s:selection_window.selection_up(cycle)
let last_item_number_on_window = len(self.item_positions)
if self.selected_item_number <= 1
if ! a:cycle
return
else
let self.selected_item_number = last_item_number_on_window
endif
else
let self.selected_item_number -= 1
endif
call self.draw_selection()
endfunction
" -
" [ object method ]
" Object: selection_window
" Name: select_line
" Purpose: select pointed line
" [ parameters ]
" line_number number of line to select
" -
function! s:selection_window.select_line(line_number)
let item_count = self.model.get_item_count()
let i = 0
for region in self.item_positions
if a:line_number >= region[0] && a:line_number <= region[1]
let self.selected_item_number = i + 1
break
endif
let i+=1
endfor
call self.draw_selection()
endfunction
" -
" [ object method ]
" Object: selection_window
" Name: select_item
" Purpose: select pointed item by number
" [ parameters ]
" item_number number of item to select
" -
function! s:selection_window.select_item(item_number)
let self.selected_item_number = a:item_number
call self.draw_selection()
endfunction
" -
" [ object method ]
" Object: selection_window
" Name: selected_item
" Purpose: return selected item text
" -
function! s:selection_window.selected_item()
let item = self.model.get_item(self.selected_item_number - 1)
return item
endfunction

View File

@ -0,0 +1,167 @@
" Author: Mykola Golubyev ( Nickolay Golubev )
" Email: golubev.nikolay@gmail.com
" Home: www.railmoon.com
" Module: railmoon#widget#window
" Purpose: util functions for work with widget windows id
"
" -
" [ public library function ]
" Name: railmoon#widget#window#find_on_tab
" Purpose: determine window number on given tab with pointed id
" [ parameters ]
" tabpage_number number of tabpage
" variable_name name of window id variable
" id window id to search
" -
function! railmoon#widget#window#find_on_tab(tabpage_number, variable_name, id)
let windows_count = tabpagewinnr(a:tabpage_number, '$')
let window_number = 1
while window_number <= windows_count
let window_id = gettabwinvar(a:tabpage_number, window_number, a:variable_name)
if a:id == window_id
return window_number
endif
let window_number += 1
endwhile
return 0
endfunction
" -
" [ public library function ]
" Name: railmoon#widget#window#find
" Purpose: determine tabpage number and window number as list of two elements with pointed id
" [ parameters ]
" id widget id to search
" -
function! railmoon#widget#window#find(id)
let tabpage_count = tabpagenr('$')
let tabpage_number = 1
while tabpage_number <= tabpage_count
let window_number = railmoon#widget#window#find_on_tab(tabpage_number, 'widget_id', a:id)
if window_number
return [ tabpage_number, window_number ]
endif
let tabpage_number += 1
endwhile
throw 'window with "widget_id" = '.a:id.' not found'
return [0, 0]
endfunction
" -
" [ public library function ]
" Name: railmoon#widget#window#visible
" Purpose: determine visible or not widget window with pointed id
" [ parameters ]
" id widget id to select
" -
function! railmoon#widget#window#visible(id)
if exists('w:widget_id') && w:widget_id == a:id
return 1
endif
let window_number = railmoon#widget#window#find_on_tab(tabpagenr(), 'widget_id', a:id)
return window_number > 0
endfunction
" -
" [ public library function ]
" Name: railmoon#widget#window#select
" Purpose: make window with given widget id active
" [ parameters ]
" id widget id to select
" -
function! railmoon#widget#window#select(id)
call railmoon#trace#push('window#select')
call railmoon#trace#debug('id = '.a:id)
try
if exists('w:widget_id') && w:widget_id == a:id
return 1
endif
let tabpage_and_window_number = railmoon#widget#window#find(a:id)
if tabpage_and_window_number[0] == 0
return 0
endif
call s:select_window(tabpage_and_window_number[0], tabpage_and_window_number[1])
return 1
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
" -
" [ public library function ]
" Name: railmoon#widget#window#save_selected
" Purpose: save current tabpage number, window mark id, position, mode
" -
function! railmoon#widget#window#save_selected()
call railmoon#trace#push('window#save_selected')
try
if ! exists('w:railmoon_window_mark_id')
let w:railmoon_window_mark_id = railmoon#id#acquire('railmoon_window_mark_id')
endif
return [tabpagenr(), w:railmoon_window_mark_id, getpos('.'), mode()]
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
" -
" [ public library function ]
" Name: railmoon#widget#window#load_selected
" Purpose: select tabpage number, window number, position, mode
" [ parameters ]
" selection list with four elements: tabpage number, window mark id,
" position, mode
" -
function! railmoon#widget#window#load_selected(selection)
call railmoon#trace#push('window#load_selected')
try
exec a:selection[0].'tabnext'
let window_number =
\ railmoon#widget#window#find_on_tab(a:selection[0],
\ 'railmoon_window_mark_id',
\ a:selection[1])
exec window_number.'wincmd w'
if a:selection[3] == 'n'
stopinsert
elseif a:selection[3] == 'i'
startinsert
endif
call setpos('.', a:selection[2])
finally
call railmoon#trace#debug('...')
call railmoon#trace#pop()
endtry
endfunction
" -
" [ internal usage ]
" Purpose: open tabpage number and select window number
" -
function! s:select_window(tabpage_number, window_number)
exec a:tabpage_number . 'tabnext'
exec a:window_number.'wincmd w'
endfunction

4685
vim/autoload/rails.vim Executable file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,174 @@
"if !has("ruby")
" finish
"end
command RunRubyFocusedUnitTest :call <SID>RunRubyFocusedUnitTest()
command RunRubyFocusedContext :call <SID>RunRubyFocusedContext()
command RunAllRubyTests :call <SID>RunAllRubyTests()
command RunLastRubyTest :call <SID>RunLastRubyTest()
function! s:RunRubyFocusedUnitTest()
ruby RubyFocusedUnitTest.new.run_test
endfunction
function! s:RunRubyFocusedContext()
ruby RubyFocusedUnitTest.new.run_context
endfunction
function! s:RunAllRubyTests()
ruby RubyFocusedUnitTest.new.run_all
endfunction
function! s:RunLastRubyTest()
ruby RubyFocusedUnitTest.new.run_last
endfunction
ruby << EOF
module VIM
class Buffer
class << self
include Enumerable
def each(&block)
(0...VIM::Buffer.count).each do |index|
yield self[index]
end
end
def create(name, opts={})
location = opts[:location] || :below
VIM.command("#{location} new #{name}")
buf = VIM::Buffer.current
if opts[:text]
buf.text = opts[:text]
end
buf
end
end
def text=(content)
content.split("\n").each_with_index do |line,index|
self.append index, line
end
end
def method_missing(method, *args, &block)
VIM.command "#{method} #{self.name}"
end
end
end
class RubyFocusedUnitTest
DEFAULT_OUTPUT_BUFFER = "rb_test_output"
SAVED_TEST_COMMAND_FILE = '/tmp/last_ruby_focused_unit_test'
def write_output_to_buffer(test_command)
save_test_command(test_command)
if buffer = VIM::Buffer.find { |b| b.name =~ /#{DEFAULT_OUTPUT_BUFFER}/ }
buffer.bdelete!
end
buffer = VIM::Buffer.create DEFAULT_OUTPUT_BUFFER, :location => :below, :text => "--- Run Focused Unit Test ---\n\n"
VIM.command("setlocal buftype=nowrite")
VIM.command "redraw"
IO.popen("#{test_command} 2>&1", "r") do |io|
begin
loop do
input = io.readpartial(10)
first, *rest = input.split(/\n/, -1)
buffer[buffer.length] = buffer[buffer.length] + first
rest.each {|l| buffer.append buffer.length, l }
VIM.command "redraw"
end
rescue EOFError
end
end
end
def save_test_command(test_command)
File.open(SAVED_TEST_COMMAND_FILE, 'w') { |f| f.write(test_command) }
end
def current_file
VIM::Buffer.current.name
end
def spec_file?
current_file =~ /spec_|_spec/
end
def line_number
VIM::Buffer.current.line_number
end
def run_spec
write_output_to_buffer("spec #{current_file} -l #{line_number}")
end
def run_unit_test
method_name = nil
(line_number + 1).downto(1) do |line_number|
if VIM::Buffer.current[line_number] =~ /def (test_\w+)/
method_name = $1
break
elsif VIM::Buffer.current[line_number] =~ /test "([^"]+)"/ ||
VIM::Buffer.current[line_number] =~ /test '([^']+)'/
method_name = "test_" + $1.split(" ").join("_")
break
elsif VIM::Buffer.current[line_number] =~ /should "([^"]+)"/ ||
VIM::Buffer.current[line_number] =~ /should '([^']+)'/
method_name = "\"/#{Regexp.escape($1)}/\""
break
end
end
write_output_to_buffer("ruby #{current_file} -n #{method_name}") if method_name
end
def run_test
if spec_file?
run_spec
else
run_unit_test
end
end
def run_context
method_name = nil
context_line_number = nil
(line_number + 1).downto(1) do |line_number|
if VIM::Buffer.current[line_number] =~ /(context|describe) "([^"]+)"/ ||
VIM::Buffer.current[line_number] =~ /(context|describe) '([^']+)'/
method_name = $2
context_line_number = line_number
break
end
end
if method_name
if spec_file?
write_output_to_buffer("spec #{current_file} -l #{context_line_number}")
else
method_name = "\"/#{Regexp.escape(method_name)}/\""
write_output_to_buffer("ruby #{current_file} -n #{method_name}")
end
end
end
def run_all
if spec_file?
write_output_to_buffer("spec #{current_file}")
else
write_output_to_buffer("ruby #{current_file}")
end
end
def run_last
write_output_to_buffer(File.read(SAVED_TEST_COMMAND_FILE))
end
end
EOF

View File

@ -0,0 +1,801 @@
" Vim completion script
" Language: Ruby
" Maintainer: Mark Guzman <segfault@hasno.info>
" URL: http://vim-ruby.rubyforge.org
" Anon CVS: See above site
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
" Maintainer Version: 0.8.1
" ----------------------------------------------------------------------------
"
" Ruby IRB/Complete author: Keiju ISHITSUKA(keiju@ishitsuka.com)
" ----------------------------------------------------------------------------
" {{{ requirement checks
if !has('ruby')
s:ErrMsg( "Error: Rubycomplete requires vim compiled with +ruby" )
s:ErrMsg( "Error: falling back to syntax completion" )
" lets fall back to syntax completion
setlocal omnifunc=syntaxcomplete#Complete
finish
endif
if version < 700
s:ErrMsg( "Error: Required vim >= 7.0" )
finish
endif
" }}} requirement checks
" {{{ configuration failsafe initialization
if !exists("g:rubycomplete_rails")
let g:rubycomplete_rails = 0
endif
if !exists("g:rubycomplete_classes_in_global")
let g:rubycomplete_classes_in_global = 0
endif
if !exists("g:rubycomplete_buffer_loading")
let g:rubycomplete_buffer_loading = 0
endif
if !exists("g:rubycomplete_include_object")
let g:rubycomplete_include_object = 0
endif
if !exists("g:rubycomplete_include_objectspace")
let g:rubycomplete_include_objectspace = 0
endif
" }}} configuration failsafe initialization
" {{{ vim-side support functions
let s:rubycomplete_debug = 0
function! s:ErrMsg(msg)
echohl ErrorMsg
echo a:msg
echohl None
endfunction
function! s:dprint(msg)
if s:rubycomplete_debug == 1
echom a:msg
endif
endfunction
function! s:GetBufferRubyModule(name, ...)
if a:0 == 1
let [snum,enum] = s:GetBufferRubyEntity(a:name, "module", a:1)
else
let [snum,enum] = s:GetBufferRubyEntity(a:name, "module")
endif
return snum . '..' . enum
endfunction
function! s:GetBufferRubyClass(name, ...)
if a:0 >= 1
let [snum,enum] = s:GetBufferRubyEntity(a:name, "class", a:1)
else
let [snum,enum] = s:GetBufferRubyEntity(a:name, "class")
endif
return snum . '..' . enum
endfunction
function! s:GetBufferRubySingletonMethods(name)
endfunction
function! s:GetBufferRubyEntity( name, type, ... )
let lastpos = getpos(".")
let lastline = lastpos
if (a:0 >= 1)
let lastline = [ 0, a:1, 0, 0 ]
call cursor( a:1, 0 )
endif
let stopline = 1
let crex = '^\s*\<' . a:type . '\>\s*\<' . a:name . '\>\s*\(<\s*.*\s*\)\?'
let [lnum,lcol] = searchpos( crex, 'w' )
"let [lnum,lcol] = searchpairpos( crex . '\zs', '', '\(end\|}\)', 'w' )
if lnum == 0 && lcol == 0
call cursor(lastpos[1], lastpos[2])
return [0,0]
endif
let curpos = getpos(".")
let [enum,ecol] = searchpairpos( crex, '', '\(end\|}\)', 'wr' )
call cursor(lastpos[1], lastpos[2])
if lnum > enum
return [0,0]
endif
" we found a the class def
return [lnum,enum]
endfunction
function! s:IsInClassDef()
return s:IsPosInClassDef( line('.') )
endfunction
function! s:IsPosInClassDef(pos)
let [snum,enum] = s:GetBufferRubyEntity( '.*', "class" )
let ret = 'nil'
if snum < a:pos && a:pos < enum
let ret = snum . '..' . enum
endif
return ret
endfunction
function! s:GetRubyVarType(v)
let stopline = 1
let vtp = ''
let pos = getpos('.')
let sstr = '^\s*#\s*@var\s*'.a:v.'\>\s\+[^ \t]\+\s*$'
let [lnum,lcol] = searchpos(sstr,'nb',stopline)
if lnum != 0 && lcol != 0
call setpos('.',pos)
let str = getline(lnum)
let vtp = substitute(str,sstr,'\1','')
return vtp
endif
call setpos('.',pos)
let ctors = '\(now\|new\|open\|get_instance'
if exists('g:rubycomplete_rails') && g:rubycomplete_rails == 1 && s:rubycomplete_rails_loaded == 1
let ctors = ctors.'\|find\|create'
else
endif
let ctors = ctors.'\)'
let fstr = '=\s*\([^ \t]\+.' . ctors .'\>\|[\[{"''/]\|%[xwQqr][(\[{@]\|[A-Za-z0-9@:\-()\.]\+...\?\|lambda\|&\)'
let sstr = ''.a:v.'\>\s*[+\-*/]*'.fstr
let [lnum,lcol] = searchpos(sstr,'nb',stopline)
if lnum != 0 && lcol != 0
let str = matchstr(getline(lnum),fstr,lcol)
let str = substitute(str,'^=\s*','','')
call setpos('.',pos)
if str == '"' || str == '''' || stridx(tolower(str), '%q[') != -1
return 'String'
elseif str == '[' || stridx(str, '%w[') != -1
return 'Array'
elseif str == '{'
return 'Hash'
elseif str == '/' || str == '%r{'
return 'Regexp'
elseif strlen(str) >= 4 && stridx(str,'..') != -1
return 'Range'
elseif stridx(str, 'lambda') != -1 || str == '&'
return 'Proc'
elseif strlen(str) > 4
let l = stridx(str,'.')
return str[0:l-1]
end
return ''
endif
call setpos('.',pos)
return ''
endfunction
"}}} vim-side support functions
"{{{ vim-side completion function
function! rubycomplete#Init()
execute "ruby VimRubyCompletion.preload_rails"
endfunction
function! rubycomplete#Complete(findstart, base)
"findstart = 1 when we need to get the text length
if a:findstart
let line = getline('.')
let idx = col('.')
while idx > 0
let idx -= 1
let c = line[idx-1]
if c =~ '\w'
continue
elseif ! c =~ '\.'
idx = -1
break
else
break
endif
endwhile
return idx
"findstart = 0 when we need to return the list of completions
else
let g:rubycomplete_completions = []
execute "ruby VimRubyCompletion.get_completions('" . a:base . "')"
return g:rubycomplete_completions
endif
endfunction
"}}} vim-side completion function
"{{{ ruby-side code
function! s:DefRuby()
ruby << RUBYEOF
# {{{ ruby completion
begin
require 'rubygems' # let's assume this is safe...?
rescue Exception
#ignore?
end
class VimRubyCompletion
# {{{ constants
@@debug = false
@@ReservedWords = [
"BEGIN", "END",
"alias", "and",
"begin", "break",
"case", "class",
"def", "defined", "do",
"else", "elsif", "end", "ensure",
"false", "for",
"if", "in",
"module",
"next", "nil", "not",
"or",
"redo", "rescue", "retry", "return",
"self", "super",
"then", "true",
"undef", "unless", "until",
"when", "while",
"yield",
]
@@Operators = [ "%", "&", "*", "**", "+", "-", "/",
"<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>",
"[]", "[]=", "^", ]
# }}} constants
# {{{ buffer analysis magic
def load_requires
buf = VIM::Buffer.current
enum = buf.line_number
nums = Range.new( 1, enum )
nums.each do |x|
ln = buf[x]
begin
eval( "require %s" % $1 ) if /.*require\s*(.*)$/.match( ln )
rescue Exception
#ignore?
end
end
end
def load_buffer_class(name)
dprint "load_buffer_class(%s) START" % name
classdef = get_buffer_entity(name, 's:GetBufferRubyClass("%s")')
return if classdef == nil
pare = /^\s*class\s*(.*)\s*<\s*(.*)\s*\n/.match( classdef )
load_buffer_class( $2 ) if pare != nil && $2 != name # load parent class if needed
mixre = /.*\n\s*include\s*(.*)\s*\n/.match( classdef )
load_buffer_module( $2 ) if mixre != nil && $2 != name # load mixins if needed
begin
eval classdef
rescue Exception
VIM::evaluate( "s:ErrMsg( 'Problem loading class \"%s\", was it already completed?' )" % name )
end
dprint "load_buffer_class(%s) END" % name
end
def load_buffer_module(name)
dprint "load_buffer_module(%s) START" % name
classdef = get_buffer_entity(name, 's:GetBufferRubyModule("%s")')
return if classdef == nil
begin
eval classdef
rescue Exception
VIM::evaluate( "s:ErrMsg( 'Problem loading module \"%s\", was it already completed?' )" % name )
end
dprint "load_buffer_module(%s) END" % name
end
def get_buffer_entity(name, vimfun)
loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading")
return nil if loading_allowed.to_i.zero?
return nil if /(\"|\')+/.match( name )
buf = VIM::Buffer.current
nums = eval( VIM::evaluate( vimfun % name ) )
return nil if nums == nil
return nil if nums.min == nums.max && nums.min == 0
dprint "get_buffer_entity START"
visited = []
clscnt = 0
bufname = VIM::Buffer.current.name
classdef = ""
cur_line = VIM::Buffer.current.line_number
while (nums != nil && !(nums.min == 0 && nums.max == 0) )
dprint "visited: %s" % visited.to_s
break if visited.index( nums )
visited << nums
nums.each do |x|
if x != cur_line
next if x == 0
ln = buf[x]
if /^\s*(module|class|def|include)\s+/.match(ln)
clscnt += 1 if $1 == "class"
#dprint "\$1$1
classdef += "%s\n" % ln
classdef += "end\n" if /def\s+/.match(ln)
dprint ln
end
end
end
nm = "%s(::.*)*\", %s, \"" % [ name, nums.last ]
nums = eval( VIM::evaluate( vimfun % nm ) )
dprint "nm: \"%s\"" % nm
dprint "vimfun: %s" % (vimfun % nm)
dprint "got nums: %s" % nums.to_s
end
if classdef.length > 1
classdef += "end\n"*clscnt
# classdef = "class %s\n%s\nend\n" % [ bufname.gsub( /\/|\\/, "_" ), classdef ]
end
dprint "get_buffer_entity END"
dprint "classdef====start"
lns = classdef.split( "\n" )
lns.each { |x| dprint x }
dprint "classdef====end"
return classdef
end
def get_var_type( receiver )
if /(\"|\')+/.match( receiver )
"String"
else
VIM::evaluate("s:GetRubyVarType('%s')" % receiver)
end
end
def dprint( txt )
print txt if @@debug
end
def get_buffer_entity_list( type )
# this will be a little expensive.
loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading")
allow_aggressive_load = VIM::evaluate("exists('g:rubycomplete_classes_in_global') && g:rubycomplete_classes_in_global")
return [] if allow_aggressive_load.to_i.zero? || loading_allowed.to_i.zero?
buf = VIM::Buffer.current
eob = buf.length
ret = []
rg = 1..eob
re = eval( "/^\s*%s\s*([A-Za-z0-9_:-]*)(\s*<\s*([A-Za-z0-9_:-]*))?\s*/" % type )
rg.each do |x|
if re.match( buf[x] )
next if type == "def" && eval( VIM::evaluate("s:IsPosInClassDef(%s)" % x) ) != nil
ret.push $1
end
end
return ret
end
def get_buffer_modules
return get_buffer_entity_list( "modules" )
end
def get_buffer_methods
return get_buffer_entity_list( "def" )
end
def get_buffer_classes
return get_buffer_entity_list( "class" )
end
def load_rails
allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails")
return if allow_rails.to_i.zero?
buf_path = VIM::evaluate('expand("%:p")')
file_name = VIM::evaluate('expand("%:t")')
vim_dir = VIM::evaluate('getcwd()')
file_dir = buf_path.gsub( file_name, '' )
file_dir.gsub!( /\\/, "/" )
vim_dir.gsub!( /\\/, "/" )
vim_dir << "/"
dirs = [ vim_dir, file_dir ]
sdirs = [ "", "./", "../", "../../", "../../../", "../../../../" ]
rails_base = nil
dirs.each do |dir|
sdirs.each do |sub|
trail = "%s%s" % [ dir, sub ]
tcfg = "%sconfig" % trail
if File.exists?( tcfg )
rails_base = trail
break
end
end
break if rails_base
end
return if rails_base == nil
$:.push rails_base unless $:.index( rails_base )
rails_config = rails_base + "config/"
rails_lib = rails_base + "lib/"
$:.push rails_config unless $:.index( rails_config )
$:.push rails_lib unless $:.index( rails_lib )
bootfile = rails_config + "boot.rb"
envfile = rails_config + "environment.rb"
if File.exists?( bootfile ) && File.exists?( envfile )
begin
require bootfile
require envfile
begin
require 'console_app'
require 'console_with_helpers'
rescue Exception
dprint "Rails 1.1+ Error %s" % $!
# assume 1.0
end
#eval( "Rails::Initializer.run" ) #not necessary?
VIM::command('let s:rubycomplete_rails_loaded = 1')
dprint "rails loaded"
rescue Exception
dprint "Rails Error %s" % $!
VIM::evaluate( "s:ErrMsg('Error loading rails environment')" )
end
end
end
def get_rails_helpers
allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails")
rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded')
return [] if allow_rails.to_i.zero? || rails_loaded.to_i.zero?
buf_path = VIM::evaluate('expand("%:p")')
buf_path.gsub!( /\\/, "/" )
path_elm = buf_path.split( "/" )
dprint "buf_path: %s" % buf_path
types = [ "app", "db", "lib", "test", "components", "script" ]
i = nil
ret = []
type = nil
types.each do |t|
i = path_elm.index( t )
break if i
end
type = path_elm[i]
type.downcase!
dprint "type: %s" % type
case type
when "app"
i += 1
subtype = path_elm[i]
subtype.downcase!
dprint "subtype: %s" % subtype
case subtype
when "views"
ret += ActionView::Base.instance_methods
ret += ActionView::Base.methods
when "controllers"
ret += ActionController::Base.instance_methods
ret += ActionController::Base.methods
when "models"
ret += ActiveRecord::Base.instance_methods
ret += ActiveRecord::Base.methods
end
when "db"
ret += ActiveRecord::ConnectionAdapters::SchemaStatements.instance_methods
ret += ActiveRecord::ConnectionAdapters::SchemaStatements.methods
end
return ret
end
def add_rails_columns( cls )
allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails")
rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded')
return [] if allow_rails.to_i.zero? || rails_loaded.to_i.zero?
begin
eval( "#{cls}.establish_connection" )
return [] unless eval( "#{cls}.ancestors.include?(ActiveRecord::Base).to_s" )
col = eval( "#{cls}.column_names" )
return col if col
rescue
dprint "add_rails_columns err: (cls: %s) %s" % [ cls, $! ]
return []
end
return []
end
def clean_sel(sel, msg)
sel.delete_if { |x| x == nil }
sel.uniq!
sel.grep(/^#{Regexp.quote(msg)}/) if msg != nil
end
def get_rails_view_methods
allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails")
rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded')
return [] if allow_rails.to_i.zero? || rails_loaded.to_i.zero?
buf_path = VIM::evaluate('expand("%:p")')
buf_path.gsub!( /\\/, "/" )
pelm = buf_path.split( "/" )
idx = pelm.index( "views" )
return [] unless idx
idx += 1
clspl = pelm[idx].camelize.pluralize
cls = clspl.singularize
ret = []
begin
ret += eval( "#{cls}.instance_methods" )
ret += eval( "#{clspl}Helper.instance_methods" )
rescue Exception
dprint "Error: Unable to load rails view helpers for %s: %s" % [ cls, $! ]
end
return ret
end
# }}} buffer analysis magic
# {{{ main completion code
def self.preload_rails
a = VimRubyCompletion.new
require 'Thread'
Thread.new(a) do |b|
begin
b.load_rails
rescue
end
end
a.load_rails
rescue
end
def self.get_completions(base)
b = VimRubyCompletion.new
b.get_completions base
end
def get_completions(base)
loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading")
if loading_allowed.to_i == 1
load_requires
load_rails
end
input = VIM::Buffer.current.line
cpos = VIM::Window.current.cursor[1] - 1
input = input[0..cpos]
input += base
input.sub!(/.*[ \t\n\"\\'`><=;|&{(]/, '') # Readline.basic_word_break_characters
input.sub!(/self\./, '')
input.sub!(/.*((\.\.[\[(]?)|([\[(]))/, '')
dprint 'input %s' % input
message = nil
receiver = nil
methods = []
variables = []
classes = []
constants = []
case input
when /^(\/[^\/]*\/)\.([^.]*)$/ # Regexp
receiver = $1
message = Regexp.quote($2)
methods = Regexp.instance_methods(true)
when /^([^\]]*\])\.([^.]*)$/ # Array
receiver = $1
message = Regexp.quote($2)
methods = Array.instance_methods(true)
when /^([^\}]*\})\.([^.]*)$/ # Proc or Hash
receiver = $1
message = Regexp.quote($2)
methods = Proc.instance_methods(true) | Hash.instance_methods(true)
when /^(:[^:.]*)$/ # Symbol
dprint "symbol"
if Symbol.respond_to?(:all_symbols)
receiver = $1
message = $1.sub( /:/, '' )
methods = Symbol.all_symbols.collect{|s| s.id2name}
methods.delete_if { |c| c.match( /'/ ) }
end
when /^::([A-Z][^:\.\(]*)$/ # Absolute Constant or class methods
dprint "const or cls"
receiver = $1
methods = Object.constants
methods.grep(/^#{receiver}/).collect{|e| "::" + e}
when /^(((::)?[A-Z][^:.\(]*)+?)::?([^:.]*)$/ # Constant or class methods
receiver = $1
message = Regexp.quote($4)
dprint "const or cls 2 [recv: \'%s\', msg: \'%s\']" % [ receiver, message ]
load_buffer_class( receiver )
begin
classes = eval("#{receiver}.constants")
#methods = eval("#{receiver}.methods")
rescue Exception
dprint "exception: %s" % $!
methods = []
end
methods.grep(/^#{message}/).collect{|e| receiver + "::" + e}
when /^(:[^:.]+)\.([^.]*)$/ # Symbol
dprint "symbol"
receiver = $1
message = Regexp.quote($2)
methods = Symbol.instance_methods(true)
when /^([0-9_]+(\.[0-9_]+)?(e[0-9]+)?)\.([^.]*)$/ # Numeric
dprint "numeric"
receiver = $1
message = Regexp.quote($4)
begin
methods = eval(receiver).methods
rescue Exception
methods = []
end
when /^(\$[^.]*)$/ #global
dprint "global"
methods = global_variables.grep(Regexp.new(Regexp.quote($1)))
when /^((\.?[^.]+)+?)\.([^.]*)$/ # variable
dprint "variable"
receiver = $1
message = Regexp.quote($3)
load_buffer_class( receiver )
cv = eval("self.class.constants")
vartype = get_var_type( receiver )
dprint "vartype: %s" % vartype
if vartype != ''
load_buffer_class( vartype )
begin
methods = eval("#{vartype}.instance_methods")
variables = eval("#{vartype}.instance_variables")
rescue Exception
dprint "load_buffer_class err: %s" % $!
end
elsif (cv).include?(receiver)
# foo.func and foo is local var.
methods = eval("#{receiver}.methods")
vartype = receiver
elsif /^[A-Z]/ =~ receiver and /\./ !~ receiver
vartype = receiver
# Foo::Bar.func
begin
methods = eval("#{receiver}.methods")
rescue Exception
end
else
# func1.func2
ObjectSpace.each_object(Module){|m|
next if m.name != "IRB::Context" and
/^(IRB|SLex|RubyLex|RubyToken)/ =~ m.name
methods.concat m.instance_methods(false)
}
end
variables += add_rails_columns( "#{vartype}" ) if vartype && vartype.length > 0
when /^\(?\s*[A-Za-z0-9:^@.%\/+*\(\)]+\.\.\.?[A-Za-z0-9:^@.%\/+*\(\)]+\s*\)?\.([^.]*)/
message = $1
methods = Range.instance_methods(true)
when /^\.([^.]*)$/ # unknown(maybe String)
message = Regexp.quote($1)
methods = String.instance_methods(true)
else
dprint "default/other"
inclass = eval( VIM::evaluate("s:IsInClassDef()") )
if inclass != nil
dprint "inclass"
classdef = "%s\n" % VIM::Buffer.current[ inclass.min ]
found = /^\s*class\s*([A-Za-z0-9_-]*)(\s*<\s*([A-Za-z0-9_:-]*))?\s*\n$/.match( classdef )
if found != nil
receiver = $1
message = input
load_buffer_class( receiver )
begin
methods = eval( "#{receiver}.instance_methods" )
variables += add_rails_columns( "#{receiver}" )
rescue Exception
found = nil
end
end
end
if inclass == nil || found == nil
dprint "inclass == nil"
methods = get_buffer_methods
methods += get_rails_view_methods
cls_const = Class.constants
constants = cls_const.select { |c| /^[A-Z_-]+$/.match( c ) }
classes = eval("self.class.constants") - constants
classes += get_buffer_classes
classes += get_buffer_modules
include_objectspace = VIM::evaluate("exists('g:rubycomplete_include_objectspace') && g:rubycomplete_include_objectspace")
ObjectSpace.each_object(Class) { |cls| classes << cls.to_s } if include_objectspace == "1"
message = receiver = input
end
methods += get_rails_helpers
methods += Kernel.public_methods
end
include_object = VIM::evaluate("exists('g:rubycomplete_include_object') && g:rubycomplete_include_object")
methods = clean_sel( methods, message )
methods = (methods-Object.instance_methods) if include_object == "0"
rbcmeth = (VimRubyCompletion.instance_methods-Object.instance_methods) # lets remove those rubycomplete methods
methods = (methods-rbcmeth)
variables = clean_sel( variables, message )
classes = clean_sel( classes, message ) - ["VimRubyCompletion"]
constants = clean_sel( constants, message )
valid = []
valid += methods.collect { |m| { :name => m, :type => 'm' } }
valid += variables.collect { |v| { :name => v, :type => 'v' } }
valid += classes.collect { |c| { :name => c, :type => 't' } }
valid += constants.collect { |d| { :name => d, :type => 'd' } }
valid.sort! { |x,y| x[:name] <=> y[:name] }
outp = ""
rg = 0..valid.length
rg.step(150) do |x|
stpos = 0+x
enpos = 150+x
valid[stpos..enpos].each { |c| outp += "{'word':'%s','item':'%s','kind':'%s'}," % [ c[:name], c[:name], c[:type] ] }
outp.sub!(/,$/, '')
VIM::command("call extend(g:rubycomplete_completions, [%s])" % outp)
outp = ""
end
end
# }}} main completion code
end # VimRubyCompletion
# }}} ruby completion
RUBYEOF
endfunction
let s:rubycomplete_rails_loaded = 0
call s:DefRuby()
"}}} ruby-side code
" vim:tw=78:sw=4:ts=8:et:fdm=marker:ft=vim:norl:

392
vim/autoload/snipMate.vim Normal file
View File

@ -0,0 +1,392 @@
fun! Filename(...)
let filename = expand('%:t:r')
if filename == '' | return a:0 == 2 ? a:2 : '' | endif
return !a:0 || a:1 == '' ? filename : substitute(a:1, '$1', filename, 'g')
endf
fun s:RemoveSnippet()
unl g:snipPos s:curPos s:snipLen s:endSnip s:endSnipLine s:prevLen
endf
fun snipMate#expandSnip(snip, col)
let lnum = line('.') | let col = a:col
let snippet = s:ProcessSnippet(a:snip)
if snippet == '' | return '' | endif
let snipLines = split(substitute(snippet, '$\d\+\|${\d\+.\{-}}', '', 'g'), "\n", 1)
let line = getline(lnum)
let afterCursor = strpart(line, col - 1)
if afterCursor != "\t" && afterCursor != ' '
let line = strpart(line, 0, col - 1)
let snipLines[-1] .= afterCursor
else
let afterCursor = ''
" For some reason the cursor needs to move one right after this
if line != '' && col == 1 && &ve != 'all' && &ve != 'onemore'
let col += 1
endif
endif
call setline(lnum, line.snipLines[0])
" Autoindent snippet according to previous indentation
let indent = matchend(line, '^.\{-}\ze\(\S\|$\)') + 1
call append(lnum, map(snipLines[1:], "'".strpart(line, 0, indent - 1)."'.v:val"))
if &fen | sil! exe lnum.','.(lnum + len(snipLines) - 1).'foldopen' | endif
let [g:snipPos, s:snipLen] = s:BuildTabStops(snippet, lnum, col - indent, indent)
if s:snipLen
let s:curPos = 0
let s:endSnip = g:snipPos[s:curPos][1]
let s:endSnipLine = g:snipPos[s:curPos][0]
call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1])
let s:prevLen = [line('$'), col('$')]
if g:snipPos[s:curPos][2] != -1 | return s:SelectWord() | endif
else
unl g:snipPos s:snipLen
" Place cursor at end of snippet if no tab stop is given
let newlines = len(snipLines) - 1
call cursor(lnum + newlines, indent + len(snipLines[-1]) - len(afterCursor)
\ + (newlines ? 0: col - 1))
endif
return ''
endf
fun s:ProcessSnippet(snip)
let snippet = a:snip
" Evaluate eval (`...`) expressions.
" Using a loop here instead of a regex fixes a bug with nested "\=".
if stridx(snippet, '`') != -1
while match(snippet, '`.\{-}`') != -1
let snippet = substitute(snippet, '`.\{-}`',
\ substitute(eval(matchstr(snippet, '`\zs.\{-}\ze`')),
\ "\n\\%$", '', ''), '')
endw
let snippet = substitute(snippet, "\r", "\n", 'g')
endif
" Place all text after a colon in a tab stop after the tab stop
" (e.g. "${#:foo}" becomes "${:foo}foo").
" This helps tell the position of the tab stops later.
let snippet = substitute(snippet, '${\d\+:\(.\{-}\)}', '&\1', 'g')
" Update the a:snip so that all the $# become the text after
" the colon in their associated ${#}.
" (e.g. "${1:foo}" turns all "$1"'s into "foo")
let i = 1
while stridx(snippet, '${'.i) != -1
let s = matchstr(snippet, '${'.i.':\zs.\{-}\ze}')
if s != ''
let snippet = substitute(snippet, '$'.i, s.'&', 'g')
endif
let i += 1
endw
if &et " Expand tabs to spaces if 'expandtab' is set.
return substitute(snippet, '\t', repeat(' ', &sts ? &sts : &sw), 'g')
endif
return snippet
endf
fun s:Count(haystack, needle)
let counter = 0
let index = stridx(a:haystack, a:needle)
while index != -1
let index = stridx(a:haystack, a:needle, index+1)
let counter += 1
endw
return counter
endf
" This function builds a list of a list of each tab stop in the
" snippet containing:
" 1.) The tab stop's line number.
" 2.) The tab stop's column number
" (by getting the length of the string between the last "\n" and the
" tab stop).
" 3.) The length of the text after the colon for the current tab stop
" (e.g. "${1:foo}" would return 3). If there is no text, -1 is returned.
" 4.) If the "${#:}" construct is given, another list containing all
" the matches of "$#", to be replaced with the placeholder. This list is
" composed the same way as the parent; the first item is the line number,
" and the second is the column.
fun s:BuildTabStops(snip, lnum, col, indent)
let snipPos = []
let i = 1
let withoutVars = substitute(a:snip, '$\d\+', '', 'g')
while stridx(a:snip, '${'.i) != -1
let beforeTabStop = matchstr(withoutVars, '^.*\ze${'.i.'\D')
let withoutOthers = substitute(withoutVars, '${\('.i.'\D\)\@!\d\+.\{-}}', '', 'g')
let j = i - 1
call add(snipPos, [0, 0, -1])
let snipPos[j][0] = a:lnum + s:Count(beforeTabStop, "\n")
let snipPos[j][1] = a:indent + len(matchstr(withoutOthers, '.*\(\n\|^\)\zs.*\ze${'.i.'\D'))
if snipPos[j][0] == a:lnum | let snipPos[j][1] += a:col | endif
" Get all $# matches in another list, if ${#:name} is given
if stridx(withoutVars, '${'.i.':') != -1
let snipPos[j][2] = len(matchstr(withoutVars, '${'.i.':\zs.\{-}\ze}'))
let dots = repeat('.', snipPos[j][2])
call add(snipPos[j], [])
let withoutOthers = substitute(a:snip, '${\d\+.\{-}}\|$'.i.'\@!\d\+', '', 'g')
while match(withoutOthers, '$'.i.'\D') != -1
let beforeMark = matchstr(withoutOthers, '^.\{-}\ze'.dots.'$'.i.'\D')
call add(snipPos[j][3], [0, 0])
let snipPos[j][3][-1][0] = a:lnum + s:Count(beforeMark, "\n")
let snipPos[j][3][-1][1] = a:indent + (snipPos[j][3][-1][0] > a:lnum
\ ? len(matchstr(beforeMark, '.*\n\zs.*'))
\ : a:col + len(beforeMark))
let withoutOthers = substitute(withoutOthers, '$'.i.'\ze\D', '', '')
endw
endif
let i += 1
endw
return [snipPos, i - 1]
endf
fun snipMate#jumpTabStop()
if exists('s:update')
call s:UpdatePlaceholderTabStops()
else
call s:UpdateTabStops()
endif
let s:curPos += 1
if s:curPos == s:snipLen
let sMode = s:endSnip == g:snipPos[s:curPos-1][1]+g:snipPos[s:curPos-1][2]
call s:RemoveSnippet()
return sMode ? "\<tab>" : TriggerSnippet()
endif
call cursor(g:snipPos[s:curPos][0], g:snipPos[s:curPos][1])
let s:endSnipLine = g:snipPos[s:curPos][0]
let s:endSnip = g:snipPos[s:curPos][1]
let s:prevLen = [line('$'), col('$')]
return g:snipPos[s:curPos][2] == -1 ? '' : s:SelectWord()
endf
fun s:UpdatePlaceholderTabStops()
let changeLen = s:origWordLen - g:snipPos[s:curPos][2]
unl s:startSnip s:origWordLen s:update
if !exists('s:origPos') | return | endif
" Update tab stops in snippet if text has been added via "$#"
" (e.g., in "${1:foo}bar$1${2}").
if changeLen != 0
let curLine = line('.')
for pos in g:snipPos[s:curPos + 1:]
let changed = pos[0] == curLine && pos[1] > s:origSnipPos
let changedVars = 0
let endPlaceholder = pos[2] - 1 + pos[1]
" Subtract changeLen from each tab stop that was after any of
" the current tab stop's placeholders.
for [lnum, col] in s:origPos
if lnum > pos[0] | break | endif
if pos[0] == lnum
if pos[1] > col || (pos[2] == -1 && pos[1] == col)
let changed += 1
elseif col < endPlaceholder
let changedVars += 1
endif
endif
endfor
let pos[1] -= changeLen * changed
let pos[2] -= changeLen * changedVars " Parse variables within placeholders
" e.g., "${1:foo} ${2:$1bar}"
if pos[2] == -1 | continue | endif
" Do the same to any placeholders in the other tab stops.
for nPos in pos[3]
let changed = nPos[0] == curLine && nPos[1] > s:origSnipPos
for [lnum, col] in s:origPos
if lnum > nPos[0] | break | endif
if nPos[0] == lnum && nPos[1] > col
let changed += 1
endif
endfor
let nPos[1] -= changeLen * changed
endfor
endfor
endif
unl s:endSnip s:origPos s:origSnipPos
endf
fun s:UpdateTabStops()
let changeLine = s:endSnipLine - g:snipPos[s:curPos][0]
let changeCol = s:endSnip - g:snipPos[s:curPos][1]
if exists('s:origWordLen')
let changeCol -= s:origWordLen
unl s:origWordLen
endif
let lnum = g:snipPos[s:curPos][0]
let col = g:snipPos[s:curPos][1]
" Update the line number of all proceeding tab stops if <cr> has
" been inserted.
if changeLine != 0
let changeLine -= 1
for pos in g:snipPos[s:curPos + 1:]
if pos[0] >= lnum
if pos[0] == lnum | let pos[1] += changeCol | endif
let pos[0] += changeLine
endif
if pos[2] == -1 | continue | endif
for nPos in pos[3]
if nPos[0] >= lnum
if nPos[0] == lnum | let nPos[1] += changeCol | endif
let nPos[0] += changeLine
endif
endfor
endfor
elseif changeCol != 0
" Update the column of all proceeding tab stops if text has
" been inserted/deleted in the current line.
for pos in g:snipPos[s:curPos + 1:]
if pos[1] >= col && pos[0] == lnum
let pos[1] += changeCol
endif
if pos[2] == -1 | continue | endif
for nPos in pos[3]
if nPos[0] > lnum | break | endif
if nPos[0] == lnum && nPos[1] >= col
let nPos[1] += changeCol
endif
endfor
endfor
endif
endf
fun s:SelectWord()
let s:origWordLen = g:snipPos[s:curPos][2]
let s:oldWord = strpart(getline('.'), g:snipPos[s:curPos][1] - 1,
\ s:origWordLen)
let s:prevLen[1] -= s:origWordLen
if !empty(g:snipPos[s:curPos][3])
let s:update = 1
let s:endSnip = -1
let s:startSnip = g:snipPos[s:curPos][1] - 1
endif
if !s:origWordLen | return '' | endif
let l = col('.') != 1 ? 'l' : ''
if &sel == 'exclusive'
return "\<esc>".l.'v'.s:origWordLen."l\<c-g>"
endif
return s:origWordLen == 1 ? "\<esc>".l.'gh'
\ : "\<esc>".l.'v'.(s:origWordLen - 1)."l\<c-g>"
endf
" This updates the snippet as you type when text needs to be inserted
" into multiple places (e.g. in "${1:default text}foo$1bar$1",
" "default text" would be highlighted, and if the user types something,
" UpdateChangedSnip() would be called so that the text after "foo" & "bar"
" are updated accordingly)
"
" It also automatically quits the snippet if the cursor is moved out of it
" while in insert mode.
au CursorMovedI * call s:UpdateChangedSnip(0)
au InsertEnter * call s:UpdateChangedSnip(1)
fun s:UpdateChangedSnip(entering)
if exists('s:update') " If modifying a placeholder
if !exists('s:origPos') && s:curPos + 1 < s:snipLen
" Save the old snippet & word length before it's updated
" s:startSnip must be saved too, in case text is added
" before the snippet (e.g. in "foo$1${2}bar${1:foo}").
let s:origSnipPos = s:startSnip
let s:origPos = deepcopy(g:snipPos[s:curPos][3])
endif
let col = col('.') - 1
if s:endSnip != -1
let changeLen = col('$') - s:prevLen[1]
let s:endSnip += changeLen
else " When being updated the first time, after leaving select mode
if a:entering | return | endif
let s:endSnip = col - 1
endif
" If the cursor moves outside the snippet, quit it
if line('.') != g:snipPos[s:curPos][0] || col < s:startSnip ||
\ col - 1 > s:endSnip
unl! s:startSnip s:origWordLen s:origPos s:update
return s:RemoveSnippet()
endif
call s:UpdateVars()
let s:prevLen[1] = col('$')
elseif exists('g:snipPos')
let col = col('.')
let lnum = line('.')
let changeLine = line('$') - s:prevLen[0]
if lnum == s:endSnipLine
let s:endSnip += col('$') - s:prevLen[1]
let s:prevLen = [line('$'), col('$')]
endif
if changeLine != 0
let s:endSnipLine += changeLine
let s:endSnip = col
endif
" Delete snippet if cursor moves out of it in insert mode
if (lnum == s:endSnipLine && (col > s:endSnip || col < g:snipPos[s:curPos][1]))
\ || lnum > s:endSnipLine || lnum < g:snipPos[s:curPos][0]
call s:RemoveSnippet()
endif
endif
endf
" This updates the variables in a snippet when a placeholder has been edited.
" (e.g., each "$1" in "${1:foo} $1bar $1bar")
fun s:UpdateVars()
let newWordLen = s:endSnip - s:startSnip + 1
let newWord = strpart(getline('.'), s:startSnip, newWordLen)
if newWord == s:oldWord || empty(g:snipPos[s:curPos][3])
return
endif
let changeLen = g:snipPos[s:curPos][2] - newWordLen
let curLine = line('.')
let startCol = col('.')
let oldStartSnip = s:startSnip
let updateTabStops = changeLen != 0
let i = 0
for [lnum, col] in g:snipPos[s:curPos][3]
if updateTabStops
let start = s:startSnip
if lnum == curLine && col <= start
let s:startSnip -= changeLen
let s:endSnip -= changeLen
endif
for nPos in g:snipPos[s:curPos][3][(i):]
" This list is in ascending order, so quit if we've gone too far.
if nPos[0] > lnum | break | endif
if nPos[0] == lnum && nPos[1] > col
let nPos[1] -= changeLen
endif
endfor
if lnum == curLine && col > start
let col -= changeLen
let g:snipPos[s:curPos][3][i][1] = col
endif
let i += 1
endif
" "Very nomagic" is used here to allow special characters.
call setline(lnum, substitute(getline(lnum), '\%'.col.'c\V'.
\ escape(s:oldWord, '\'), escape(newWord, '\&'), ''))
endfor
if oldStartSnip != s:startSnip
call cursor(0, startCol + s:startSnip - oldStartSnip)
endif
let s:oldWord = newWord
let g:snipPos[s:curPos][2] = newWordLen
endf
" vim:noet:sw=4:ts=4:ft=vim

194
vim/autoload/syntastic.vim Executable file
View File

@ -0,0 +1,194 @@
if exists("g:loaded_syntastic_autoload")
finish
endif
let g:loaded_syntastic_autoload = 1
let s:save_cpo = &cpo
set cpo&vim
function! syntastic#ErrorBalloonExpr()
if !exists('b:syntastic_balloons') | return '' | endif
return get(b:syntastic_balloons, v:beval_lnum, '')
endfunction
function! syntastic#HighlightErrors(errors, termfunc, ...)
call clearmatches()
let forcecb = a:0 && a:1
for item in a:errors
let group = item['type'] == 'E' ? 'SpellBad' : 'SpellCap'
if item['col'] && !forcecb
let lastcol = col([item['lnum'], '$'])
let lcol = min([lastcol, item['col']])
call matchadd(group, '\%'.item['lnum'].'l\%'.lcol.'c')
else
let term = a:termfunc(item)
if len(term) > 0
call matchadd(group, '\%' . item['lnum'] . 'l' . term)
endif
endif
endfor
endfunction
" initialize c/cpp syntax checker handlers
function! s:Init()
let s:handlers = []
let s:cflags = {}
call s:RegHandler('gtk', 'syntastic#CheckPKG',
\ ['gtk', 'gtk+-2.0', 'gtk+', 'glib-2.0', 'glib'])
call s:RegHandler('glib', 'syntastic#CheckPKG',
\ ['glib', 'glib-2.0', 'glib'])
call s:RegHandler('glade', 'syntastic#CheckPKG',
\ ['glade', 'libglade-2.0', 'libglade'])
call s:RegHandler('libsoup', 'syntastic#CheckPKG',
\ ['libsoup', 'libsoup-2.4', 'libsoup-2.2'])
call s:RegHandler('webkit', 'syntastic#CheckPKG',
\ ['webkit', 'webkit-1.0'])
call s:RegHandler('cairo', 'syntastic#CheckPKG',
\ ['cairo', 'cairo'])
call s:RegHandler('pango', 'syntastic#CheckPKG',
\ ['pango', 'pango'])
call s:RegHandler('libxml', 'syntastic#CheckPKG',
\ ['libxml', 'libxml-2.0', 'libxml'])
call s:RegHandler('freetype', 'syntastic#CheckPKG',
\ ['freetype', 'freetype2', 'freetype'])
call s:RegHandler('SDL', 'syntastic#CheckPKG',
\ ['sdl', 'sdl'])
call s:RegHandler('opengl', 'syntastic#CheckPKG',
\ ['opengl', 'gl'])
call s:RegHandler('ruby', 'syntastic#CheckRuby', [])
call s:RegHandler('Python\.h', 'syntastic#CheckPython', [])
call s:RegHandler('php\.h', 'syntastic#CheckPhp', [])
endfunction
" search the first 100 lines for include statements that are
" given in the handlers dictionary
function! syntastic#SearchHeaders()
let includes = ''
let files = []
let found = []
let lines = filter(getline(1, 100), 'v:val =~# "#\s*include"')
" search current buffer
for line in lines
let file = matchstr(line, '"\zs\S\+\ze"')
if file != ''
call add(files, file)
continue
endif
for handler in s:handlers
if line =~# handler["regex"]
let includes .= call(handler["func"], handler["args"])
call add(found, handler["regex"])
break
endif
endfor
endfor
" search included headers
for hfile in files
if hfile != ''
let filename = expand('%:p:h') . ((has('win32') || has('win64')) ?
\ '\' : '/') . hfile
try
let lines = readfile(filename, '', 100)
catch /E484/
continue
endtry
let lines = filter(lines, 'v:val =~# "#\s*include"')
for handler in s:handlers
if index(found, handler["regex"]) != -1
continue
endif
for line in lines
if line =~# handler["regex"]
let includes .= call(handler["func"], handler["args"])
call add(found, handler["regex"])
break
endif
endfor
endfor
endif
endfor
return includes
endfunction
" try to find library with 'pkg-config'
" search possible libraries from first to last given
" argument until one is found
function! syntastic#CheckPKG(name, ...)
if executable('pkg-config')
if !has_key(s:cflags, a:name)
for i in range(a:0)
let l:cflags = system('pkg-config --cflags '.a:000[i])
" since we cannot necessarily trust the pkg-config exit code
" we have to check for an error output as well
if v:shell_error == 0 && l:cflags !~? 'not found'
let l:cflags = ' '.substitute(l:cflags, "\n", '', '')
let s:cflags[a:name] = l:cflags
return l:cflags
endif
endfor
else
return s:cflags[a:name]
endif
endif
return ''
endfunction
" try to find PHP includes with 'php-config'
function! syntastic#CheckPhp()
if executable('php-config')
if !exists('s:php_flags')
let s:php_flags = system('php-config --includes')
let s:php_flags = ' ' . substitute(s:php_flags, "\n", '', '')
endif
return s:php_flags
endif
return ''
endfunction
" try to find the ruby headers with 'rbconfig'
function! syntastic#CheckRuby()
if executable('ruby')
if !exists('s:ruby_flags')
let s:ruby_flags = system('ruby -r rbconfig -e '
\ . '''puts Config::CONFIG["archdir"]''')
let s:ruby_flags = substitute(s:ruby_flags, "\n", '', '')
let s:ruby_flags = ' -I' . s:ruby_flags
endif
return s:ruby_flags
endif
return ''
endfunction
" try to find the python headers with distutils
function! syntastic#CheckPython()
if executable('python')
if !exists('s:python_flags')
let s:python_flags = system('python -c ''from distutils import '
\ . 'sysconfig; print sysconfig.get_python_inc()''')
let s:python_flags = substitute(s:python_flags, "\n", '', '')
let s:python_flags = ' -I' . s:python_flags
endif
return s:python_flags
endif
return ''
endfunction
" return a handler dictionary object
function! s:RegHandler(regex, function, args)
let handler = {}
let handler["regex"] = a:regex
let handler["func"] = function(a:function)
let handler["args"] = a:args
call add(s:handlers, handler)
endfunction
call s:Init()
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:

576
vim/autoload/tcomment.vim Normal file
View File

@ -0,0 +1,576 @@
" tcomment.vim
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2007-09-17.
" @Last Change: 2009-02-15.
" @Revision: 0.0.66
if &cp || exists("loaded_tcomment_autoload")
finish
endif
let loaded_tcomment_autoload = 1
function! s:DefaultValue(option)
exec 'let '. a:option .' = &'. a:option
exec 'set '. a:option .'&'
exec 'let default = &'. a:option
exec 'let &'. a:option .' = '. a:option
return default
endf
let s:defaultComments = s:DefaultValue('comments')
let s:defaultCommentString = s:DefaultValue('commentstring')
let s:nullCommentString = '%s'
" tcomment#Comment(line1, line2, ?commentMode, ?commentAnyway, ?commentBegin, ?commentEnd)
" commentMode:
" G ... guess
" B ... block
" i ... maybe inline, guess
" I ... inline
" R ... right
" v ... visual
" o ... operator
function! tcomment#Comment(beg, end, ...)
" save the cursor position
let co = col('.')
let li = line('.')
let s:pos_end = getpos("'>")
let commentMode = a:0 >= 1 ? a:1 : 'G'
let commentAnyway = a:0 >= 2 ? (a:2 == '!') : 0
" TLogVAR a:beg, a:end, a:1, commentMode, commentAnyway
if commentMode =~# 'i'
let commentMode = substitute(commentMode, '\Ci', line("'<") == line("'>") ? 'I' : 'G', 'g')
endif
if commentMode =~# 'R' || commentMode =~# 'I'
let cstart = col("'<")
if cstart == 0
let cstart = col('.')
endif
if commentMode =~# 'R'
let commentMode = substitute(commentMode, '\CR', 'G', 'g')
let cend = 0
else
let cend = col("'>")
if commentMode =~# 'o'
let cend += 1
endif
endif
else
let cstart = 0
let cend = 0
endif
" TLogVAR commentMode, cstart, cend
" get the correct commentstring
if a:0 >= 3 && a:3 != ''
let cms = s:EncodeCommentPart(a:3) .'%s'
if a:0 >= 4 && a:4 != ''
let cms = cms . s:EncodeCommentPart(a:4)
endif
else
let [cms, commentMode] = s:GetCommentString(a:beg, a:end, commentMode)
endif
let cms0 = s:BlockGetCommentString(cms)
let cms0 = escape(cms0, '\')
" make whitespace optional; this conflicts with comments that require some
" whitespace
let cmtCheck = substitute(cms0, '\([ ]\)', '\1\\?', 'g')
" turn commentstring into a search pattern
let cmtCheck = s:SPrintF(cmtCheck, '\(\_.\{-}\)')
" set commentMode and indentStr
let [indentStr, uncomment] = s:CommentDef(a:beg, a:end, cmtCheck, commentMode, cstart, cend)
" TLogVAR indentStr, uncomment
if commentAnyway
let uncomment = 0
endif
" go
if commentMode =~# 'B'
" We want a comment block
call s:CommentBlock(a:beg, a:end, uncomment, cmtCheck, cms, indentStr)
else
" call s:CommentLines(a:beg, a:end, cstart, cend, uncomment, cmtCheck, cms0, indentStr)
" We want commented lines
" final search pattern for uncommenting
let cmtCheck = escape('\V\^\(\s\{-}\)'. cmtCheck .'\$', '"/\')
" final pattern for commenting
let cmtReplace = escape(cms0, '"/')
silent exec a:beg .','. a:end .'s/\V'.
\ s:StartRx(cstart) . indentStr .'\zs\(\.\{-}\)'. s:EndRx(cend) .'/'.
\ '\=s:ProcessedLine('. uncomment .', submatch(0), "'. cmtCheck .'", "'. cmtReplace .'")/ge'
endif
" reposition cursor
" TLogVAR commentMode
if commentMode =~ '>'
call setpos('.', s:pos_end)
else
" TLogVAR li, co
call cursor(li, co)
endif
endf
function! tcomment#Operator(type, ...) "{{{3
let commentMode = a:0 >= 1 ? a:1 : ''
let bang = a:0 >= 2 ? a:2 : ''
if !exists('w:tcommentPos')
let w:tcommentPos = getpos(".")
endif
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
" let pos = getpos('.')
" TLogVAR a:type
try
if a:type == 'line'
silent exe "normal! '[V']"
let commentMode1 = 'G'
elseif a:type == 'block'
silent exe "normal! `[\<C-V>`]"
let commentMode1 = 'I'
else
silent exe "normal! `[v`]"
let commentMode1 = 'i'
endif
if empty(commentMode)
let commentMode = commentMode1
endif
let beg = line("'[")
let end = line("']")
norm! 
let commentMode .= g:tcommentOpModeExtra
call tcomment#Comment(beg, end, commentMode.'o', bang)
finally
let &selection = sel_save
let @@ = reg_save
if g:tcommentOpModeExtra !~ '>'
" TLogVAR pos
" call setpos('.', pos)
call setpos('.', w:tcommentPos)
unlet! w:tcommentPos
endif
endtry
endf
function! tcomment#OperatorLine(type) "{{{3
call tcomment#Operator(a:type, 'G')
endf
function! tcomment#OperatorAnyway(type) "{{{3
call tcomment#Operator(a:type, '', '!')
endf
function! tcomment#OperatorLineAnyway(type) "{{{3
call tcomment#Operator(a:type, 'G', '!')
endf
" comment text as if it were of a specific filetype
function! tcomment#CommentAs(beg, end, commentAnyway, filetype, ...)
let ccount = a:0 >= 1 ? a:1 : 1
" TLogVAR ccount
if a:filetype =~ '_block$'
let commentMode = 'B'
let ft = substitute(a:filetype, '_block$', '', '')
elseif a:filetype =~ '_inline$'
let commentMode = 'I'
let ft = substitute(a:filetype, '_inline$', '', '')
else
let commentMode = 'G'
let ft = a:filetype
endif
let [cms, commentMode] = s:GetCommentString(a:beg, a:end, commentMode, ft)
let pre = substitute(cms, '%s.*$', '', '')
let pre = substitute(pre, '%%', '%', 'g')
let post = substitute(cms, '^.\{-}%s', '', '')
let post = substitute(post, '%%', '%', 'g')
if ccount > 1
let pre_l = matchlist(pre, '^\(\S\+\)\(.*\)$')
" TLogVAR pre_l
if !empty(get(pre_l, 1))
let pre = repeat(pre_l[1], ccount) . pre_l[2]
endif
let post_l = matchlist(post, '^\(\s*\)\(.\+\)$')
" TLogVAR post_l
if !empty(get(post_l, 2))
let post = post_l[1] . repeat(post_l[2], ccount)
endif
endif
keepjumps call tcomment#Comment(a:beg, a:end, commentMode, a:commentAnyway, pre, post)
endf
" ----------------------------------------------------------------
" collect all variables matching ^tcomment_
function! tcomment#CollectFileTypes()
if g:tcommentFileTypesDirty
redir => vars
silent let
redir END
let g:tcommentFileTypes = split(vars, '\n')
call filter(g:tcommentFileTypes, 'v:val =~ "tcomment_"')
call map(g:tcommentFileTypes, 'matchstr(v:val, ''tcomment_\zs\S\+'')')
call sort(g:tcommentFileTypes)
let g:tcommentFileTypesRx = '\V\^\('. join(g:tcommentFileTypes, '\|') .'\)\(\u\.\*\)\?\$'
let g:tcommentFileTypesDirty = 0
endif
endf
call tcomment#CollectFileTypes()
" return a list of filetypes for which a tcomment_{&ft} is defined
function! tcomment#FileTypes(ArgLead, CmdLine, CursorPos)
" TLogVAR a:ArgLead, a:CmdLine, a:CursorPos
call tcomment#CollectFileTypes()
let types = copy(g:tcommentFileTypes)
if index(g:tcommentFileTypes, &filetype) != -1
" TLogVAR &filetype
call insert(types, &filetype)
endif
if empty(a:ArgLead)
return types
else
return filter(types, 'v:val =~ ''\V''.a:ArgLead')
endif
endf
function! s:EncodeCommentPart(string)
return substitute(a:string, '%', '%%', 'g')
endf
" s:GetCommentString(beg, end, commentMode, ?filetype="")
function! s:GetCommentString(beg, end, commentMode, ...)
let ft = a:0 >= 1 ? a:1 : ''
if ft != ''
let [cms, commentMode] = s:GetCustomCommentString(ft, a:commentMode)
else
let cms = ''
let commentMode = a:commentMode
endif
if empty(cms)
if exists('b:commentstring')
let cms = b:commentstring
return s:GetCustomCommentString(&filetype, a:commentMode, cms)
elseif exists('b:commentStart') && b:commentStart != ''
let cms = s:EncodeCommentPart(b:commentStart) .' %s'
if exists('b:commentEnd') && b:commentEnd != ''
let cms = cms .' '. s:EncodeCommentPart(b:commentEnd)
endif
return s:GetCustomCommentString(&filetype, a:commentMode, cms)
elseif g:tcommentGuessFileType || (exists('g:tcommentGuessFileType_'. &filetype)
\ && g:tcommentGuessFileType_{&filetype} =~ '[^0]')
if g:tcommentGuessFileType_{&filetype} == 1
let altFiletype = ''
else
let altFiletype = g:tcommentGuessFileType_{&filetype}
endif
return s:GuessFileType(a:beg, a:end, a:commentMode, &filetype, altFiletype)
else
return s:GetCustomCommentString(&filetype, a:commentMode, s:GuessCurrentCommentString(a:commentMode))
endif
endif
return [cms, commentMode]
endf
" s:SPrintF(formatstring, ?values ...)
" => string
function! s:SPrintF(string, ...)
let n = 1
let r = ''
let s = a:string
while 1
let i = match(s, '%\(.\)')
if i >= 0
let x = s[i + 1]
let r = r . strpart(s, 0, i)
let s = strpart(s, i + 2)
if x == '%'
let r = r.'%'
else
if a:0 >= n
let v = a:{n}
let n = n + 1
else
echoerr 'Malformed format string (too many arguments required): '. a:string
endif
if x ==# 's'
let r = r.v
elseif x ==# 'S'
let r = r.'"'.v.'"'
else
echoerr 'Malformed format string: '. a:string
endif
endif
else
return r.s
endif
endwh
endf
function! s:StartRx(pos)
if a:pos == 0
return '\^'
else
return '\%'. a:pos .'c'
endif
endf
function! s:EndRx(pos)
if a:pos == 0
return '\$'
else
return '\%'. a:pos .'c'
endif
endf
function! s:GetIndentString(line, start)
let start = a:start > 0 ? a:start - 1 : 0
return substitute(strpart(getline(a:line), start), '\V\^\s\*\zs\.\*\$', '', '')
endf
function! s:CommentDef(beg, end, checkRx, commentMode, cstart, cend)
let mdrx = '\V'. s:StartRx(a:cstart) .'\s\*'. a:checkRx .'\s\*'. s:EndRx(0)
let line = getline(a:beg)
if a:cstart != 0 && a:cend != 0
let line = strpart(line, 0, a:cend - 1)
endif
let uncomment = (line =~ mdrx)
let it = s:GetIndentString(a:beg, a:cstart)
let il = indent(a:beg)
let n = a:beg + 1
while n <= a:end
if getline(n) =~ '\S'
let jl = indent(n)
if jl < il
let it = s:GetIndentString(n, a:cstart)
let il = jl
endif
if a:commentMode =~# 'G'
if !(getline(n) =~ mdrx)
let uncomment = 0
endif
endif
endif
let n = n + 1
endwh
if a:commentMode =~# 'B'
let t = @t
try
silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"ty'
let uncomment = (@t =~ mdrx)
finally
let @t = t
endtry
endif
return [it, uncomment]
endf
function! s:ProcessedLine(uncomment, match, checkRx, replace)
if !(a:match =~ '\S' || g:tcommentBlankLines)
return a:match
endif
let ml = len(a:match)
if a:uncomment
let rv = substitute(a:match, a:checkRx, '\1\2', '')
else
let rv = s:SPrintF(a:replace, a:match)
endif
" let md = len(rv) - ml
let s:pos_end = getpos('.')
let s:pos_end[2] += len(rv)
" TLogVAR pe, md, a:match
let rv = escape(rv, '\ ')
let rv = substitute(rv, '\n', '\\\n', 'g')
return rv
endf
function! s:CommentLines(beg, end, cstart, cend, uncomment, cmtCheck, cms0, indentStr) "{{{3
" We want commented lines
" final search pattern for uncommenting
let cmtCheck = escape('\V\^\(\s\{-}\)'. a:cmtCheck .'\$', '"/\')
" final pattern for commenting
let cmtReplace = escape(a:cms0, '"/')
silent exec a:beg .','. a:end .'s/\V'.
\ s:StartRx(a:cstart) . a:indentStr .'\zs\(\.\{-}\)'. s:EndRx(a:cend) .'/'.
\ '\=s:ProcessedLine('. a:uncomment .', submatch(0), "'. a:cmtCheck .'", "'. cmtReplace .'")/ge'
endf
function! s:CommentBlock(beg, end, uncomment, checkRx, replace, indentStr)
let t = @t
try
silent exec 'norm! '. a:beg.'G1|v'.a:end.'G$"td'
let ms = s:BlockGetMiddleString(a:replace)
let mx = escape(ms, '\')
if a:uncomment
let @t = substitute(@t, '\V\^\s\*'. a:checkRx .'\$', '\1', '')
if ms != ''
let @t = substitute(@t, '\V\n'. a:indentStr . mx, '\n'. a:indentStr, 'g')
endif
let @t = substitute(@t, '^\n', '', '')
let @t = substitute(@t, '\n\s*$', '', '')
else
let cs = s:BlockGetCommentString(a:replace)
let cs = a:indentStr . substitute(cs, '%s', '%s'. a:indentStr, '')
if ms != ''
let ms = a:indentStr . ms
let mx = a:indentStr . mx
let @t = substitute(@t, '^'. a:indentStr, '', 'g')
let @t = ms . substitute(@t, '\n'. a:indentStr, '\n'. mx, 'g')
endif
let @t = s:SPrintF(cs, "\n". @t ."\n")
endif
silent norm! "tP
finally
let @t = t
endtry
endf
" inspired by Meikel Brandmeyer's EnhancedCommentify.vim
" this requires that a syntax names are prefixed by the filetype name
" s:GuessFileType(beg, end, commentMode, filetype, ?fallbackFiletype)
function! s:GuessFileType(beg, end, commentMode, filetype, ...)
if a:0 >= 1 && a:1 != ''
let [cms, commentMode] = s:GetCustomCommentString(a:1, a:commentMode)
if cms == ''
let cms = s:GuessCurrentCommentString(a:commentMode)
endif
else
let commentMode = s:CommentMode(a:commentMode, 'G')
let cms = s:GuessCurrentCommentString(0)
endif
let n = a:beg
" TLogVAR n, a:beg, a:end
while n <= a:end
let m = indent(n) + 1
let le = len(getline(n))
" TLogVAR m, le
while m < le
let syntaxName = synIDattr(synID(n, m, 1), 'name')
" TLogVAR syntaxName, n, m
let ftypeMap = get(g:tcommentSyntaxMap, syntaxName)
if !empty(ftypeMap)
" TLogVAR ftypeMap
return s:GetCustomCommentString(ftypeMap, a:commentMode, cms)
elseif syntaxName =~ g:tcommentFileTypesRx
let ft = substitute(syntaxName, g:tcommentFileTypesRx, '\1', '')
" TLogVAR ft
if exists('g:tcommentIgnoreTypes_'. a:filetype) && g:tcommentIgnoreTypes_{a:filetype} =~ '\<'.ft.'\>'
let m += 1
else
return s:GetCustomCommentString(ft, a:commentMode, cms)
endif
elseif syntaxName == '' || syntaxName == 'None' || syntaxName =~ '^\u\+$' || syntaxName =~ '^\u\U*$'
let m += 1
else
break
endif
endwh
let n += 1
endwh
return [cms, commentMode]
endf
function! s:CommentMode(commentMode, newmode) "{{{3
return substitute(a:commentMode, '\w\+', a:newmode, 'g')
endf
function! s:GuessCurrentCommentString(commentMode)
let valid_cms = (stridx(&commentstring, '%s') != -1)
if &commentstring != s:defaultCommentString && valid_cms
" The &commentstring appears to have been set and to be valid
return &commentstring
endif
if &comments != s:defaultComments
" the commentstring is the default one, so we assume that it wasn't
" explicitly set; we then try to reconstruct &cms from &comments
let cms = s:ConstructFromComments(a:commentMode)
if cms != s:nullCommentString
return cms
endif
endif
if valid_cms
" Before &commentstring appeared not to be set. As we don't know
" better we return it anyway if it is valid
return &commentstring
else
" &commentstring is invalid. So we return the identity string.
return s:nullCommentString
endif
endf
function! s:ConstructFromComments(commentMode)
exec s:ExtractCommentsPart('')
if a:commentMode =~# 'G' && line != ''
return line .' %s'
endif
exec s:ExtractCommentsPart('s')
if s != ''
exec s:ExtractCommentsPart('e')
" if a:commentMode
" exec s:ExtractCommentsPart("m")
" if m != ""
" let m = "\n". m
" endif
" return s.'%s'.e.m
" else
return s.' %s '.e
" endif
endif
if line != ''
return line .' %s'
else
return s:nullCommentString
endif
endf
function! s:ExtractCommentsPart(key)
" let key = a:key != "" ? a:key .'[^:]*' : ""
let key = a:key . '[bnflrxO0-9-]*'
let val = substitute(&comments, '^\(.\{-},\)\{-}'. key .':\([^,]\+\).*$', '\2', '')
if val == &comments
let val = ''
else
let val = substitute(val, '%', '%%', 'g')
endif
let var = a:key == '' ? 'line' : a:key
return 'let '. var .'="'. escape(val, '"') .'"'
endf
" s:GetCustomCommentString(ft, commentMode, ?default="")
function! s:GetCustomCommentString(ft, commentMode, ...)
let commentMode = a:commentMode
let customComment = exists('g:tcomment_'. a:ft)
if commentMode =~# 'B' && exists('g:tcomment_'. a:ft .'_block')
let cms = g:tcomment_{a:ft}_block
elseif commentMode =~? 'I' && exists('g:tcomment_'. a:ft .'_inline')
let cms = g:tcomment_{a:ft}_inline
elseif customComment
let cms = g:tcomment_{a:ft}
let commentMode = s:CommentMode(commentMode, 'G')
elseif a:0 >= 1
let cms = a:1
let commentMode = s:CommentMode(commentMode, 'G')
else
let cms = ''
let commentMode = s:CommentMode(commentMode, 'G')
endif
return [cms, commentMode]
endf
function! s:BlockGetCommentString(cms)
" return substitute(a:cms, '\n.*$', '', '')
return matchstr(a:cms, '^.\{-}\ze\(\n\|$\)')
endf
function! s:BlockGetMiddleString(cms)
" let rv = substitute(a:cms, '^.\{-}\n\([^\n]*\)', '\1', '')
let rv = matchstr(a:cms, '\n\zs.*')
return rv == a:cms ? '' : rv
endf
redraw

140
vim/bin/ruby_debugger.rb Normal file
View File

@ -0,0 +1,140 @@
require 'socket'
class VimRubyDebugger
def initialize(params)
@params = params
create_directory(@params[:messages_file])
@rdebug = wait_for_opened_socket(@params[:host], @params[:rdebug_port])
@vim_ruby_debugger = TCPServer.new(@params[:host], @params[:vim_ruby_debugger_port])
@queue = []
@result = []
@separator = "++vim-ruby-debugger separator++"
run
end
private
def wait_for_opened_socket(host, port, &block)
attempts = 0
begin
socket = TCPSocket.open(host, port)
yield if block_given?
rescue Errno::ECONNREFUSED => msg
attempts += 1
# If socket wasn't be opened for 20 seconds, exit
if attempts < 400
sleep 0.05
retry
else
raise Errno::ECONNREFUSED, "#{host}:#{port} wasn't be opened"
end
end
socket
end
def create_directory(file)
dir = File.dirname(file)
Dir.mkdir(dir) unless File.exist?(dir) && File.directory?(dir)
end
def run
t1 = Thread.new do
while(session = @vim_ruby_debugger.accept)
input = session.gets
@queue = input.split(@separator)
handle_queue
end
end
t2 = Thread.new do
loop do
response = select([@rdebug], nil, nil)
output = read_socket(response, @rdebug)
@result << output
# If we stop at breakpoint, add taking of local variables into queue
stop_commands = [ '<breakpoint ', '<suspended ', '<exception ' ]
if stop_commands.any? { |c| output.include?(c) }
@queue << "var local"
@queue << "where"
end
handle_queue
end
end
t1.join
@rdebug.puts('exit')
ensure
@rdebug.close if @rdebug
@vim_ruby_debugger.close if @vim_ruby_debugger
end
def read_socket(response, debugger, output = "")
if response && response[0] && response[0][0]
output += response[0][0].recv(10000)
if have_unclosed_tag?(output)
# If rdebug-ide doesn't send full message, we should wait for rest parts too.
# We can understand that this is just part of message by matching unclosed tags
another_response = select([debugger], nil, nil)
else
# Sometimes by some reason rdebug-ide sends blank strings just after main message.
# We need to remove these strings by receiving them
another_response = select([debugger], nil, nil, 0.01)
end
if another_response && another_response[0] && another_response[0][0]
output = read_socket(another_response, debugger, output)
end
end
output
end
def handle_queue
unless @queue.empty?
message = @queue.shift
@rdebug.puts(message)
# Start command doesn't return any response, so send message immediatly
send_message if message == 'start'
else
send_message
end
end
def send_message
message = @result.join(@separator)
@result = []
if message && !message.empty?
File.open(@params[:messages_file], 'w') { |f| f.puts(message) }
command = ":call RubyDebugger.receive_command()"
starter = (@params[:os] == 'win' ? "<C-\\>" : "<C-\\\\>")
system("#{@params[:vim_executable]} --servername #{@params[:vim_servername]} -u NONE -U NONE --remote-send \"#{starter}<C-N>#{command}<CR>\"");
end
end
def have_unclosed_tag?(output)
start_match = output.match(/^<([a-zA-Z0-9\-_]+)>/)
if start_match
end_match = output.match(/<\/#{start_match[1]}>$/)
return end_match ? false : true
else
return false
end
end
end
VimRubyDebugger.new(
:host => ARGV[0],
:rdebug_port => ARGV[1],
:vim_ruby_debugger_port => ARGV[2],
:vim_executable => ARGV[3],
:vim_servername => ARGV[4],
:messages_file => ARGV[5],
:os => ARGV[6]
)

View File

@ -0,0 +1,351 @@
" Display marks in the signs column
" Maintainer: A. Politz <cbyvgmn@su-gevre.qr>
" Last change: 2008-02-06
" v0.1
let s:marks = 'abcdefghijklmnopqrstuvwxyz' .'ABCDEFGHIJKLMNOPQRSTUVWXYZ' .'<>'
let s:all_marks = split(s:marks . '0123456789(){}''^."','\ze')
"Hlgroup for signs
:highlight default link hlShowMarks Question
"Which buffers have the plugin activated ?
let s:handled_buffers = []
"Prefix for the signname
let s:sign_prefix = 'showmarks-'
"Undef signs, if plugin is inactive
let s:have_signs_defined = 0
"Try to avoid id-conflicts
let s:sign_id_incr = 947380
"ids for top and bottom signs
let s:top_sign_id = s:sign_id_incr - 1
let s:bot_sign_id = s:sign_id_incr - 2
"public interface
func! showmarks#ShowMarks( cmd, ... )
let to = a:0 ? a:1 : 1
let to = to >= 0 ? to : 1
if a:cmd =~ 'once'
"Disable afterwards regardless of current state
let force_disable = a:0 > 1 && a:2
call s:EnableLocalOneTime(to,force_disable)
elseif a:cmd =~ 'preview'
:call s:PreviewMarks(to)
else
let enable = a:cmd =~ 'enable'
let global = a:cmd =~ 'global'
if enable
if global
call s:EnableGlobal()
else
call s:EnableLocal()
endif
else
if global
call s:DisableGlobal()
else
call s:DisableLocal()
endif
endif
endif
endfun
func! s:GetWantedMarks()
if !exists('g:showmarks_marks')
let g:showmarks_marks=s:marks
return g:showmarks_marks
elseif type(g:showmarks_marks) != type('string')
return s:marks
else
return g:showmarks_marks
endif
endfun
func! s:UpdateSigns( )
if !exists('b:showmarks')
"Remeber which id is displayed in which lnum.
let b:showmarks = {}
let b:showmarks.topline = 0
let b:showmarks.botline = 0
endif
"Find the first and last nonfolded line in the window.
let top = line('w0')
let bot = line('w$')
while foldclosed(top) >= 0 && top < bot
let top = foldclosedend(top)+1
endwhile
if top >= bot
let top = 0
let bot = 0
let b:showmarks.topline = 0
let b:showmarks.botline = 0
else
for l in range(top+1,bot)
if foldclosed(l) < 0
let bot=l
endif
endfor
endif
"Figure out if the windows top and bottom lines have changed. If
"not don't bother with updating the top/bot markers.
if b:showmarks.topline == top && b:showmarks.botline == bot
let do_bottop_signs = 0
else
let b:showmarks.topline = top
let b:showmarks.botline = bot
let do_bottop_signs = 1
endif
if do_bottop_signs
let topsign = { 'lnum' : 1, 'mark' : '' , 'ok' : 1}
let botsign = { 'lnum' : line('$') , 'mark' : '' , 'ok' : 1}
endif
for id in range(len(s:all_marks))
let mark = s:all_marks[id]
"At least try! to avoid id-conflicts
let id += s:sign_id_incr "Some random value
let [ bnr, lnum ] = getpos("'".mark)[0:1]
"Sort out file and global marks ( '0-9 'A-Z ) from another
"buffer
if bnr && bnr != bufnr('%')
continue
endif
let want_mark = s:GetWantedMarks() =~ '\V'.mark
if !lnum || !want_mark
"Mark not set, or don't want it anymore. Remove it from
"b:showmarks and undisplay the sign
if has_key(b:showmarks,id)
call remove(b:showmarks,id)
silent exec 'sign unplace '.id.' buffer='.bufnr('%')
endif
else "if lnum && want_mark
"Found a valid mark and want it.
if do_bottop_signs
"Check for a candidate for the bot and top marks
if lnum < top && lnum >= topsign.lnum
let topsign.mark = mark
let topsign.lnum = lnum
elseif lnum > bot && lnum <= botsign.lnum
let botsign.mark = mark
let botsign.lnum = lnum
elseif lnum == top
"Don't overrule real marks at this position.
let topsign.ok = 0
elseif lnum == bot
let botsign.ok = 0
endif
endif
if !has_key(b:showmarks,id)
let b:showmarks[id]= 0
endif
"Show the sign, if it's not already displayed where it
"belongs.
if b:showmarks[id] != lnum
silent! exec 'sign unplace '.id.' buffer='.bufnr('%')
silent! exec 'sign place '.id.' line='.lnum.' name='.s:sign_prefix.mark.' buffer='.bufnr('%')
let b:showmarks[id]=lnum
endif
endif
endfor
if do_bottop_signs
"Unplace,undef,def and place the top and bottom signs, if necessary.
silent! exec 'sign unplace '.s:top_sign_id.' buffer='.bufnr('%')
silent! exec 'sign undefine '.s:sign_prefix.'topline'
if topsign.ok && !empty(topsign.mark)
silent exec 'sign define '.s:sign_prefix.'topsign text=/'.(topsign.mark).' texthl=hlShowMarks'
silent exec 'sign place '.s:top_sign_id.' line='.top.' name='.s:sign_prefix.'topsign buffer='.bufnr('%')
endif
silent! exec 'sign unplace '.s:bot_sign_id.' buffer='.bufnr('%')
silent! exec 'sign undefine '.s:sign_prefix.'botline'
if botsign.ok && !empty(botsign.mark)
silent exec 'sign define '.s:sign_prefix.'botsign text=\'.(botsign.mark).' texthl=hlShowMarks'
silent exec 'sign place '.s:bot_sign_id.' line='.bot.' name='.s:sign_prefix.'botsign buffer='.bufnr('%')
endif
endif
endfun
func! s:PreviewMarks( ... ) " autoclose
if !exists('s:preview_tmp')
let s:preview_tmp = tempname()
endif
let curbuf_marks = []
let foreign_marks = []
for mark in s:all_marks
if s:GetWantedMarks() !~ '\V'.mark
continue
endif
let [ bnr, lnum ] = getpos("'".mark)[0:1]
if !lnum
continue
endif
if !bnr || bnr == bufnr('%')
let line = ' '.mark.' '
let line .= printf('%'.strlen(line('$')).'d',lnum).' '
let line .= getline(lnum)
call add(curbuf_marks,{ 'mark' : mark, 'line' : line, 'lnum' : lnum })
else
let line = ' '.mark.' '
let line .= repeat(' ',strlen(line('$'))-1).'> '
let line .= bufname(bnr)
call add(foreign_marks,line)
endif
endfor
if !empty(curbuf_marks) || !empty(foreign_marks)
if a:0 && a:1
let s:showmarks_pvw_timeout = a:1
"autoclose
augroup showmarks-PreviewMarks
au!
au CursorHold * let s:showmarks_pvw_timeout-=1 | if s:showmarks_pvw_timeout<=0| wincmd z | exec 'au! showmarks-PreviewMarks' | unlet s:showmarks_pvw_timeout | endif
augroup END
endif
let syntax=&syntax
silent! exec 'ped '.s:preview_tmp
wincmd P
if &previewwindow
silent %d _
"Better than no color at all ?
exec 'set syntax='.syntax
setl nobuflisted buftype=nofile nonu nofoldenable nowrap
setl noscrollbind stl=[Preview]ShowMarks nodiff
silent exec ':resize '.min([ &lines/2 , len(curbuf_marks)+len(foreign_marks) ])
call sort(curbuf_marks,'s:ComparePVWLines')
call setline(1,map(curbuf_marks,'v:val.line'))
call setline(line('$')+1,foreign_marks)
call matchadd('hlShowMarks','^\s\zs.')
call matchadd('LineNr','^\s.\s*\zs\d\+')
call matchadd('Special','^\s*\S\s*\zs>\s*.*')
wincmd p
else
echohl Error | echo "Can't open the previewwindow (ShowMarks) !" | echohl None
endif
endif
endfun
func! s:EnableLocal()
"echo 'EL in' string(s:handled_buffers)
if index(s:handled_buffers,bufnr('%')) < 0
call add(s:handled_buffers,bufnr('%'))
if !s:have_signs_defined
call s:DefSigns()
let s:have_signs_defined = 1
endif
augroup showmarks
au CursorHold <buffer> :call s:UpdateSigns()
augroup END
endif
call s:UpdateSigns()
"echo 'EL out' string(s:handled_buffers)
endfun
"Enable the plugin locally for the duration of timeout CursorHold
"events. Disable it, if it was not active or if force is 1.
func! s:EnableLocalOneTime( timeout, force )
let idx = index(s:handled_buffers,bufnr('%'))
call s:EnableLocal()
if a:force || idx < 0
let b:showmarks.timeout = a:timeout
augroup showmarks
au CursorHold <buffer> let b:showmarks.timeout-=1 | if b:showmarks.timeout<=0 | exec 'silent! au! showmarks CursorHold <buffer>'|call s:DisableLocal() | endif
augroup END
endif
endfun
func! s:DisableLocal()
"echo 'DL in' string(s:handled_buffers)
let idx = index(s:handled_buffers,bufnr('%'))
if idx >= 0
silent! au! showmarks CursorHold <buffer>
for id in filter(range(s:sign_id_incr,s:sign_id_incr+len(s:all_marks)-1),'has_key(b:showmarks,v:val)')
silent exec 'sign unplace '.id.' buffer='.bufnr('%')
endfor
silent! exec 'sign unplace '.s:bot_sign_id.' buffer='.bufnr('%')
silent! exec 'sign unplace '.s:top_sign_id.' buffer='.bufnr('%')
call remove(s:handled_buffers,idx)
unlet! b:showmarks
"if empty(s:handled_buffers)
" call s:DelSigns()
" let s:have_signs_defined = 0
"endif
endif
"echo 'DL out' string(s:handled_buffers)
endfun
func! s:EnableGlobal()
silent! au! showmarks-DisableGlobal
augroup showmarks-EnableGlobal
au!
au BufRead,BufNewFile * :call s:EnableLocal()
for b in range(1,bufnr('$'))
if index(tabpagebuflist(),b) < 0 && buflisted(b)
exec 'au BufEnter <buffer='.b.'> :call s:EnableLocal()|au! showmarks-EnableGlobal BufEnter <buffer='.b.'>'
endif
endfor
augroup END
let win = winnr()
silent windo call s:EnableLocal()
exec win.'wincmd w'
endfun
func! s:DisableGlobal()
silent! au! showmarks-EnableGlobal
augroup showmarks-DisableGlobal
au!
for b in range(1,bufnr('$'))
if index(tabpagebuflist(),b) < 0 && buflisted(b)
exec 'au BufEnter <buffer='.b.'> :call s:DisableLocal()|au! showmarks-DisableGlobal BufEnter <buffer='.b.'>'
endif
endfor
augroup END
let win = winnr()
silent windo call s:DisableLocal()
exec win.'wincmd w'
endfun
func! s:ComparePVWLines( i1, i2 )
"if a:i1.mark =~ '[A-Z0-9]' && a:i2.mark !~ '[A-Z0-9]'
" return 1
"elseif a:i1.mark !~ '[A-Z0-9]' && a:i2.mark =~ '[A-Z0-9]'
" return -1
"endif
return a:i1.lnum < a:i2.lnum ? -1 : a:i1.lnum > a:i2.lnum
endfun
func! s:DefSigns()
for m in s:all_marks
exec 'sign define '.s:sign_prefix.m.' text='.m.' texthl=hlShowMarks'
endfor
endfun
func! s:DelSigns()
for m in s:all_marks
exec 'sign undefine '.s:sign_prefix.m
endfor
silent! exec 'sign undefine '.s:sign_prefix.'topline'
silent! exec 'sign undefine '.s:sign_prefix.'botline'
endfun
finish
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <f5> :DoShowMarks<cr>
map <f6> :NoShowMarks<cr>
map <f7> :DoShowMarks!<cr>
map <f8> :NoShowMarks!<cr>

View File

@ -0,0 +1,73 @@
" Display marks in the signs column
" Maintainer: A. Politz <cbyvgmn@su-gevre.qr>
" Last change: 2008-02-06
" v0.1
"
"ShowMarks
"
"Give a visual aid to navigate marks, by displaying them as signs
"(obviously needs the +signs feature).
"
"commands
"--------
"
":DoShowMarks
" show marks for current buffer
":DoShowMarks!
" show marks for all buffers
":NoShowMarks
" disable it for current buffer
":NoShowMarks!
" disable it for all buffers
"
":[count]ShowMarksOnce
" Display marks for [count] Cursorhold
" events. Mostly for mapping it like :
" nnoremap ` :ShowMarksOnce<cr>`
"
":[count]PreviewMarks
" Display marks of current buffer in pvw.
" Like ':marks', but at the top of the window ;-).
" [count] is the same sa above.
"
"variables
"--------
"
"let g:showmarks_marks = "abcdef...."
" the marks you want to have displayed.
"hlShowMarks
" the highlight color
"I suggest to lower the value of 'updatetime'.
if exists('loaded_showmarks')
finish
endif
let s:cpo=&cpo
set cpo&vim
let loaded_showmarks = 1
if version < 700
com DoShowMarks echohl Error | echo "Sorry, you need vim7 for this plugin (Showmarks)." | echohl None | delc DoShowMarks
finish
endif
if !has('signs')
com DoShowMarks
\echohl Error
\| echo "Sorry, your version does not support signs (Showmarks). You may still use the PreviewMarks command."
\| echohl None | delc DoShowMarks
else
com -bar -bang DoShowMarks
\if <bang>0 | call showmarks#ShowMarks('global,enable') | else | call showmarks#ShowMarks('enable,local') | endif
com -bar -bang NoShowMarks
\if <bang>0 | call showmarks#ShowMarks('global') | else | call showmarks#ShowMarks('') | endif
com -bar -bang -count=1 ShowMarksOnce call showmarks#ShowMarks('once',<count>,<bang>0)
endif
com! -bar -bang -count=0 PreviewMarks call showmarks#ShowMarks('preview',<count>)
let &cpo=s:cpo
unlet s:cpo

@ -0,0 +1 @@
Subproject commit 1b7e4070f5f7b7522422f5b00a75b323cc314daf

101
vim/colors/.bashrc Normal file
View File

@ -0,0 +1,101 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
# ... or force ignoredups and ignorespace
export HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
#if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
#fi
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
#alias grep='grep --color=auto'
#alias fgrep='fgrep --color=auto'
#alias egrep='egrep --color=auto'
fi
# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

97
vim/colors/adrian.vim Normal file
View File

@ -0,0 +1,97 @@
" Vim colorscheme file
" Maintainer: Adrian Nagle <vim@naglenet.org>
" Last Change: 2001-09-25 07:48:15 Mountain Daylight Time
" URL: http://www.naglenet.org/vim/syntax/adrian.vim
" MAIN URL: http://www.naglenet.org/vim
" This is my custom syntax file to override the defaults provided with Vim.
" This file should be located in $HOME/vimfiles/colors.
" This file should automatically be sourced by $RUNTIMEPATH.
" NOTE(S):
" *(1)
" The color definitions assumes and is intended for a black or dark
" background.
" *(2)
" This file is specifically in Unix style EOL format so that I can simply
" copy this file between Windows and Unix systems. VIM can source files in
" with the UNIX EOL format (only <NL> instead of <CR><NR> for DOS) in any
" operating system if the 'fileformats' is not empty and there is no <CR>
" just before the <NL> on the first line. See ':help :source_crnl' and
" ':help fileformats'.
"
" *(3)
" Move this file to adrian.vim for vim6.0aw.
"
hi clear
set background=dark
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "adrian"
" Normal is for the normal (unhighlighted) text and background.
" NonText is below the last line (~ lines).
highlight Normal guibg=Black guifg=Green
highlight Cursor guibg=Grey70 guifg=White
highlight NonText guibg=Grey80
highlight StatusLine gui=bold guibg=DarkGrey guifg=Orange
highlight StatusLineNC guibg=DarkGrey guifg=Orange
highlight Comment term=bold ctermfg=LightGrey guifg=#d1ddff
highlight Constant term=underline ctermfg=White guifg=#ffa0a0
"highlight Number term=underline ctermfg=Yellow guifg=Yellow
highlight Identifier term=underline ctermfg=Cyan guifg=#40ffff
highlight Statement term=bold ctermfg=Yellow gui=bold guifg=#ffff60
highlight PreProc term=underline ctermfg=Blue guifg=#ff4500
highlight Type term=underline ctermfg=DarkGrey gui=bold guifg=#7d96ff
highlight Special term=bold ctermfg=Magenta guifg=Orange
highlight Ignore ctermfg=black guifg=bg
highlight Error ctermfg=White ctermbg=Red guifg=White guibg=Red
highlight Todo ctermfg=Blue ctermbg=Yellow guifg=Blue guibg=Yellow
" Change the highlight of search matches (for use with :set hls).
highlight Search ctermfg=Black ctermbg=Yellow guifg=Black guibg=Yellow
" Change the highlight of visual highlight.
highlight Visual cterm=NONE ctermfg=Black ctermbg=LightGrey gui=NONE guifg=Black guibg=Grey70
highlight Float ctermfg=Blue guifg=#88AAEE
highlight Exception ctermfg=Red ctermbg=White guifg=Red guibg=White
highlight Typedef ctermfg=White ctermbg=Blue gui=bold guifg=White guibg=Blue
highlight SpecialChar ctermfg=Black ctermbg=White guifg=Black guibg=White
highlight Delimiter ctermfg=White ctermbg=Black guifg=White guibg=Black
highlight SpecialComment ctermfg=Black ctermbg=Green guifg=Black guibg=Green
" Common groups that link to default highlighting.
" You can specify other highlighting easily.
highlight link String Constant
highlight link Character Constant
highlight link Number Constant
highlight link Boolean Statement
"highlight link Float Number
highlight link Function Identifier
highlight link Conditional Type
highlight link Repeat Type
highlight link Label Type
highlight link Operator Type
highlight link Keyword Type
"highlight link Exception Type
highlight link Include PreProc
highlight link Define PreProc
highlight link Macro PreProc
highlight link PreCondit PreProc
highlight link StorageClass Type
highlight link Structure Type
"highlight link Typedef Type
"highlight link SpecialChar Special
highlight link Tag Special
"highlight link Delimiter Special
"highlight link SpecialComment Special
highlight link Debug Special

37
vim/colors/aiseered.vim Normal file
View File

@ -0,0 +1,37 @@
" gVim color file for working with files in GDL/VCG format.
" Works nice in conjunction with gdl.vim
" (see www.vim.org or www.aisee.com)
" Works fine for C/C++, too.
" Author : Alexander A. Evstyugov-Babaev <alex@absint.com>
" Version: 0.2 for gVim/Linux,
" tested with gVim 6.3.25 under Ubuntu Linux (Warty)
" by Jo Vermeulen <jo@lumumba.luc.ac.be>
" Date : January 25th 2005
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name="aiseered"
hi Normal guifg=lightred guibg=#600000
hi Cursor guifg=bg guibg=fg
hi ErrorMsg guibg=red ctermfg=1
hi Search term=reverse ctermfg=darkred ctermbg=lightred guibg=lightred guifg=#060000
hi Comment guifg=#ffffff
hi Constant guifg=#88ddee
hi String guifg=#ffcc88
hi Character guifg=#ffaa00
hi Number guifg=#88ddee
hi Identifier guifg=#cfcfcf
hi Statement guifg=#eeff99 gui=bold
hi PreProc guifg=firebrick1 gui=italic
hi Type guifg=#88ffaa gui=none
hi Special guifg=#ffaa00
hi SpecialChar guifg=#ffaa00
hi StorageClass guifg=#ddaacc
hi Error guifg=red guibg=white

44
vim/colors/aqua.vim Normal file
View File

@ -0,0 +1,44 @@
" Vim color file
" Maintainer: tranquility@portugalmail.pt
" Last Change: 6 Apr 2002
" cool help screens
" :he group-name
" :he highlight-groups
" :he cterm-colors
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name="aqua"
hi Normal guibg=steelblue guifg=linen
hi Cursor guibg=lightblue3 guifg=black gui=bold
hi VertSplit guifg=white guibg=navyblue gui=none
hi Folded guibg=darkblue guifg=white
hi FoldColumn guibg=lightgray guifg=navyblue
hi ModeMsg guifg=black guibg=steelblue1
hi MoreMsg guifg=black guibg=steelblue1
hi NonText guifg=white guibg=steelblue4 gui=none
hi Question guifg=snow
hi Search guibg=#FFFFFF guifg=midnightblue gui=bold
hi SpecialKey guifg=navyblue
hi StatusLine guibg=skyblue3 guifg=black gui=none
hi StatusLineNC guibg=skyblue1 guifg=black gui=none
hi Title guifg=bisque3
hi Subtitle guifg=black
hi Visual guifg=white guibg=royalblue4 gui=none
hi WarningMsg guifg=salmon4 guibg=gray60 gui=bold
hi Comment guifg=lightskyblue
hi Constant guifg=turquoise gui=bold
hi Identifier guifg=lightcyan
hi Statement guifg=royalblue4
hi PreProc guifg=black gui=bold
hi Type guifg=lightgreen
hi Special guifg=navajowhite
hi Ignore guifg=grey29
hi Todo guibg=black guifg=white
hi WildMenu guibg=aquamarine

164
vim/colors/astronaut.vim Normal file
View File

@ -0,0 +1,164 @@
" astronaut.vim: a colorscheme
" Maintainer: Charles E. Campbell, Jr. <charles.e.campbell.1@gsfc.nasa.gov>
" Date: Feb 21, 2006
" Version: 7
"
" Usage:
" Put into your <.vimrc> file:
" color astronaut
"
" Optional Modifiers:
" let g:astronaut_bold=1 : term, cterm, and gui receive bold modifier
" let g:astronaut_dark=1 : dark colors used (otherwise some terminals
" make everything bold, which can be all one
" color)
" let g:astronaut_underline=1 : assume that underlining works on your terminal
" let g:astronaut_italic=1 : allows italic to be used in gui
" Examples:
" iris : let astronaut_dark=1
" Linux xterm: no modifiers needed
"
" GetLatestVimScripts: 122 1 :AutoInstall: astronaut.vim
set background=dark
hi clear
if exists( "syntax_on" )
syntax reset
endif
let g:colors_name = "astronaut"
let g:loaded_astronaut = "v7"
" ---------------------------------------------------------------------
" Default option values
if !exists("g:astronaut_bold")
" on some machines, notably SGIs, a bold qualifier means everything is
" one color (SGIs: yellow)
let g:astronaut_bold= 0
endif
if !exists("g:astronaut_dark")
" this option, if true, means darkcolor (ex. darkred, darkmagenta, etc)
" is understood and wanted
let g:astronaut_dark= 0
endif
if !exists("g:astronaut_underline")
let g:astronaut_underline= 1
endif
if !exists("g:astronaut_italic")
let g:astronaut_italic= 0
endif
" ---------------------------------------------------------------------
" Settings based on options
if g:astronaut_bold != 0
let s:bold=",bold"
else
let s:bold=""
endif
if g:astronaut_italic != 0
let s:italic= ",italic"
else
let s:italic= ""
endif
if g:astronaut_dark != 0
let s:black = "black"
let s:red = "darkred"
let s:green = "darkgreen"
let s:yellow = "darkyellow"
let s:blue = "darkblue"
let s:magenta = "darkmagenta"
let s:cyan = "darkcyan"
let s:white = "white"
else
let s:black = "black"
let s:red = "red"
let s:green = "green"
let s:yellow = "yellow"
let s:blue = "blue"
let s:magenta = "magenta"
let s:cyan = "cyan"
let s:white = "white"
endif
if g:astronaut_underline != 0
let s:underline= ",underline"
let s:ulbg = ""
else
let s:underline= "none"
if exists("g:astronaut_dark")
let s:ulbg = "ctermbg=darkmagenta guibg=magenta4"
else
let s:ulbg = "ctermbg=magenta guibg=magenta"
endif
endif
" ---------------------------------------------------------------------
exe "hi Blue start= stop= ctermfg=".s:blue." guifg=blue guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Comment start= stop= ctermfg=".s:white." guifg=white term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Conceal ctermfg=".s:blue." ctermbg=".s:black." guifg=Blue guibg=Black term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Constant start= stop= ctermfg=".s:yellow." guifg=yellow guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Cursor guifg=blue guibg=green term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Cyan start= stop= ctermfg=".s:cyan." guifg=cyan guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Debug start= stop= ctermfg=".s:magenta." ctermbg=".s:black." guifg=magenta guibg=black term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Delimiter start= stop= ctermfg=".s:white." guifg=white guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi DiffAdd ctermfg=".s:white." ctermbg=".s:magenta." guifg=White guibg=Magenta term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi DiffChange ctermfg=".s:yellow." ctermbg=".s:blue." guifg=Yellow guibg=Blue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi DiffDelete ctermfg=".s:white." ctermbg=".s:blue." guifg=White guibg=Blue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi DiffText ctermfg=".s:white." ctermbg=".s:red." guifg=White guibg=Red term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Directory start= stop= ctermfg=".s:white." guifg=white term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Error start= stop= ctermfg=".s:white." ctermbg=".s:red." guifg=white guibg=red term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi ErrorMsg ctermfg=".s:white." ctermbg=".s:red." guifg=White guibg=Red term=standout".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi FoldColumn start= stop= ctermfg=".s:cyan." ctermbg=".s:black." guifg=Cyan guibg=Brown term=standout".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Folded start= stop= ctermfg=".s:magenta." ctermbg=".s:black." guifg=magenta guibg=black term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Function start= stop= ctermfg=".s:cyan." guifg=cyan guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Green start= stop= ctermfg=".s:green." guifg=green guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Identifier start= stop= ctermfg=".s:magenta." guifg=magenta guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Ignore ctermfg=".s:black ." guifg=bg term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi IncSearch start= stop= ctermfg=".s:black ." ctermbg=".s:green." guifg=black guibg=green term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi LineNr ctermfg=".s:yellow." ".s:ulbg." guifg=Yellow term=none".s:underline.s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Magenta start= stop= ctermfg=".s:magenta." guifg=magenta guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Menu guifg=black guibg=gray75 term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi ModeMsg ctermfg=".s:green." guifg=SeaGreen term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi MoreMsg ctermfg=".s:green." guifg=SeaGreen term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi NonText ctermfg=".s:blue." guifg=Blue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Normal start= stop= ctermfg=".s:green." guifg=green guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi PreProc start= stop= ctermfg=".s:white." ctermbg=".s:blue." guifg=white guibg=blue3 term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Question start= stop= ctermfg=".s:yellow." guifg=yellow term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Red start= stop= ctermfg=".s:red." guifg=red guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Scrollbar guifg=gray80 guibg=gray70 term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Search start= stop= ctermfg=".s:yellow." ctermbg=".s:blue." guifg=yellow guibg=blue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Special start= stop= ctermfg=".s:green." ctermbg=".s:blue." guifg=green guibg=blue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi SpecialKey start= stop= ctermfg=".s:black." ctermbg=".s:magenta." guifg=black guibg=magenta term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Statement start= stop= ctermfg=".s:cyan." guifg=cyan guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi StatusLine start= stop= ctermfg=".s:black." ctermbg=".s:cyan." guifg=black guibg=cyan term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi StatusLineNC start= stop= ctermfg=".s:black." ctermbg=".s:green." guifg=black guibg=green term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi String start= stop= ctermfg=".s:yellow." guifg=yellow guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Subtitle start= stop= ctermfg=".s:magenta." guifg=magenta guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
if v:version >= 700
exe "hi TabLine start= stop= ctermfg=".s:black." ctermbg=".s:blue." guifg=black guibg=blue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold.s:underline.s:italic
exe "hi TabLineSel start= stop= ctermfg=".s:green." ctermbg=".s:blue." guifg=green guibg=blue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold.s:underline.s:italic
exe "hi TabLineFill start= stop= ctermfg=".s:blue." ctermbg=".s:blue." guifg=blue guibg=blue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
endif
exe "hi Tags start= stop= ctermfg=".s:yellow." ctermbg=".s:blue." guifg=yellow guibg=blue3 term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Title start= stop= ctermfg=".s:white." guifg=white term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Todo start= stop= ctermfg=".s:white." ctermbg=".s:magenta." guifg=white guibg=magenta term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Type start= stop= ctermfg=".s:green." ".s:ulbg." guifg=seagreen1 term=none".s:underline.s:bold." cterm=none".s:bold.s:underline." gui=none".s:bold.s:underline
exe "hi Underlined ctermfg=".s:green." ".s:ulbg." guifg=green term=none".s:underline.s:bold." cterm=none".s:bold.s:underline." gui=none".s:bold.s:underline
exe "hi Unique start= stop= ctermfg=".s:blue." ctermbg=".s:white." guifg=blue3 guibg=white term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi AltUnique start= stop= ctermfg=".s:magenta." ctermbg=".s:white." guifg=magenta guibg=white term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi AltAltUnique start= stop= ctermfg=".s:black." ctermbg=".s:white." guifg=black guibg=white term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi VertSplit start= stop= ctermfg=".s:black." ctermbg=".s:green." guifg=black guibg=green term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Visual start= stop= ctermfg=black ctermbg=green guifg=Grey guibg=fg term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi VisualNOS ".s:ulbg." term=none".s:underline.s:bold." cterm=none".s:bold.s:underline." gui=none".s:bold.s:underline
exe "hi WarningMsg start= stop= ctermfg=".s:black." ctermbg=".s:yellow." guifg=black guibg=yellow term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi White start= stop= ctermfg=".s:white." guifg=white guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi WildMenu ctermfg=".s:black." ctermbg=".s:yellow." guifg=Black guibg=Yellow term=standout".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi Yellow start= stop= ctermfg=".s:yellow." guifg=yellow guibg=navyblue term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi lCursor guifg=bg guibg=fg term=none".s:bold." cterm=none".s:bold." gui=none".s:bold
exe "hi AltConstant start= stop= ctermfg=".s:yellow." ctermbg=".s:black." guifg=yellow guibg=black term=none".s:bold." cterm=none".s:bold." gui=none".s:bold.s:italic
exe "hi AltFunction start= stop= ctermfg=".s:green." ctermbg=".s:black." guifg=green guibg=black term=none".s:bold." cterm=none".s:bold." gui=none".s:bold.s:italic
exe "hi AltType start= stop= ctermfg=".s:green." ctermbg=".s:black." guifg=seagreen1 guibg=black term=none".s:underline.s:bold." cterm=none".s:bold.s:underline." gui=none".s:bold.s:underline.s:italic
exe "hi User1 ctermfg=".s:white." ctermbg=".s:blue." guifg=white guibg=blue"
exe "hi User2 ctermfg=".s:cyan." ctermbg=".s:blue." guifg=cyan guibg=blue"
" vim: nowrap

59
vim/colors/asu1dark.vim Normal file
View File

@ -0,0 +1,59 @@
" Vim color file
" Maintainer: A. Sinan Unur
" Last Change: 2001/10/04
" Dark color scheme
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name="asu1dark"
" Console Color Scheme
hi Normal term=NONE cterm=NONE ctermfg=LightGray ctermbg=Black
hi NonText term=NONE cterm=NONE ctermfg=Brown ctermbg=Black
hi Function term=NONE cterm=NONE ctermfg=DarkCyan ctermbg=Black
hi Statement term=BOLD cterm=BOLD ctermfg=DarkBlue ctermbg=Black
hi Special term=NONE cterm=NONE ctermfg=DarkGreen ctermbg=Black
hi SpecialChar term=NONE cterm=NONE ctermfg=Cyan ctermbg=Black
hi Constant term=NONE cterm=NONE ctermfg=Blue ctermbg=Black
hi Comment term=NONE cterm=NONE ctermfg=DarkGray ctermbg=Black
hi Preproc term=NONE cterm=NONE ctermfg=DarkGreen ctermbg=Black
hi Type term=NONE cterm=NONE ctermfg=DarkMagenta ctermbg=Black
hi Identifier term=NONE cterm=NONE ctermfg=Cyan ctermbg=Black
hi StatusLine term=BOLD cterm=NONE ctermfg=Yellow ctermbg=DarkBlue
hi StatusLineNC term=NONE cterm=NONE ctermfg=Black ctermbg=Gray
hi Visual term=NONE cterm=NONE ctermfg=White ctermbg=DarkCyan
hi Search term=NONE cterm=NONE ctermbg=Yellow ctermfg=DarkBlue
hi VertSplit term=NONE cterm=NONE ctermfg=Black ctermbg=Gray
hi Directory term=NONE cterm=NONE ctermfg=Green ctermbg=Black
hi WarningMsg term=NONE cterm=NONE ctermfg=Blue ctermbg=Yellow
hi Error term=NONE cterm=NONE ctermfg=DarkRed ctermbg=Gray
hi Cursor ctermfg=Black ctermbg=Cyan
hi LineNr term=NONE cterm=NONE ctermfg=Red ctermbg=Black
" GUI Color Scheme
hi Normal gui=NONE guifg=White guibg=#110022
hi NonText gui=NONE guifg=#ff9999 guibg=#444444
hi Function gui=NONE guifg=#7788ff guibg=#110022
hi Statement gui=BOLD guifg=Yellow guibg=#110022
hi Special gui=NONE guifg=Cyan guibg=#110022
hi Constant gui=NONE guifg=#ff9900 guibg=#110022
hi Comment gui=NONE guifg=#99cc99 guibg=#110022
hi Preproc gui=NONE guifg=#33ff66 guibg=#110022
hi Type gui=NONE guifg=#ff5577 guibg=#110022
hi Identifier gui=NONE guifg=Cyan guibg=#110022
hi StatusLine gui=BOLD guifg=White guibg=#336600
hi StatusLineNC gui=NONE guifg=Black guibg=#cccccc
hi Visual gui=NONE guifg=White guibg=#00aa33
hi Search gui=BOLD guibg=Yellow guifg=DarkBlue
hi VertSplit gui=NONE guifg=White guibg=#666666
hi Directory gui=NONE guifg=Green guibg=#110022
hi WarningMsg gui=STANDOUT guifg=#0000cc guibg=Yellow
hi Error gui=NONE guifg=White guibg=Red
hi Cursor guifg=White guibg=#00ff33
hi LineNr gui=NONE guifg=#cccccc guibg=#334444
hi ModeMsg gui=NONE guifg=Blue guibg=White
hi Question gui=NONE guifg=#66ff99 guibg=#110022

59
vim/colors/automation.vim Normal file
View File

@ -0,0 +1,59 @@
" Vim color file (automation.vim)
" Maintainer: Ken McConnell <nacer@yahoo.com>
" Last Change: 2004 Jan 15
"
" This color scheme uses a light grey background. It was created to simulate
" the look of an IDE. It is named after the MFP Automation Team at HP Boise.
"
" First remove all existing highlighting.
set background=light
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "automation"
hi Normal ctermbg=Black ctermfg=LightGrey guifg=Black guibg=Grey96
" Groups used in the 'highlight' and 'guicursor' options default value.
hi ErrorMsg term=standout ctermbg=DarkRed ctermfg=White guibg=Red guifg=White
hi IncSearch term=reverse cterm=bold gui=bold
hi ModeMsg term=bold cterm=bold gui=bold
hi StatusLine term=bold cterm=bold gui=bold
hi StatusLineNC term=bold cterm=bold gui=bold
hi VertSplit term=bold cterm=bold gui=bold
hi Visual term=bold cterm=bold gui=bold guifg=Grey guibg=fg
hi VisualNOS term=underline,bold cterm=underline,bold gui=underline,bold
hi DiffText term=reverse cterm=bold ctermbg=Red gui=bold guibg=Red
hi Cursor guibg=Black guifg=Black
hi lCursor guibg=Cyan guifg=Black
hi Directory term=bold ctermfg=LightCyan guifg=DarkBlue
hi LineNr term=underline ctermfg=DarkGrey guifg=DarkGrey guibg=LightGrey
hi MoreMsg term=bold ctermfg=LightGreen gui=bold guifg=SeaGreen
hi NonText term=bold ctermfg=LightBlue gui=bold guifg=DarkGreen guibg=grey80
hi Question term=standout ctermfg=LightGreen gui=bold guifg=Green
hi Search term=reverse ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black
hi SpecialKey term=bold ctermfg=DarkBlue guifg=DarkBlue
hi Title term=bold ctermfg=LightMagenta gui=bold guifg=DarkBlue
hi WarningMsg term=standout ctermfg=LightRed guifg=Red
hi WildMenu term=standout ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black
hi Folded term=standout ctermbg=LightGrey ctermfg=DarkBlue guibg=LightGrey guifg=DarkBlue
hi FoldColumn term=standout ctermbg=LightGrey ctermfg=DarkBlue guibg=Grey guifg=DarkBlue
hi DiffAdd term=bold ctermbg=DarkBlue guibg=DarkBlue
hi DiffChange term=bold ctermbg=DarkMagenta guibg=DarkMagenta
hi DiffDelete term=bold ctermfg=Blue ctermbg=DarkCyan gui=bold guifg=Blue guibg=DarkCyan
hi Comment guifg=Blue guibg=Grey90 ctermfg=DarkGreen
hi String guifg=DarkGreen ctermfg=DarkGreen
hi Statement guifg=DarkBlue ctermfg=Blue
hi Label gui=bold guifg=DarkBlue
" Groups for syntax highlighting
hi Constant term=underline ctermfg=DarkBlue guifg=DarkBlue guibg=Grey96
hi Special term=bold ctermfg=LightRed guifg=DarkBlue guibg=Grey96
if &t_Co > 8
hi Statement term=bold cterm=bold ctermfg=DarkBlue guifg=DarkBlue
endif
hi Ignore ctermfg=LightGrey guifg=grey90
" vim: sw=2

88
vim/colors/autumn.vim Normal file
View File

@ -0,0 +1,88 @@
" Vim colour file
" Maintainer: Antony Scriven <ad_scriven@postmaster.co.uk>
" Last Change: 2003-06-12
"
set background=light
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "autumn"
hi Normal term=none cterm=none ctermfg=black ctermbg=White gui=none guifg=Black guibg=#f0f2f0
hi Cursor term=none cterm=none ctermfg=white ctermbg=darkgrey gui=none guifg=black guibg=red
hi DiffAdd term=bold cterm=none ctermfg=white ctermbg=DarkBlue gui=none guifg=#aaeeaa guibg=#447744
hi DiffChange term=bold cterm=none ctermfg=white ctermbg=DarkMagenta gui=none guifg=lightyellow guibg=#ddbb55
hi DiffDelete term=bold cterm=none ctermfg=blue ctermbg=darkcyan gui=none guifg=#336633 guibg=#aaccaa
hi difftext term=reverse cterm=bold ctermfg=white ctermbg=red gui=none guifg=lightyellow guibg=#cc7733
hi Directory term=none cterm=none ctermfg=Red ctermbg=white gui=none guifg=Red guibg=bg
hi ErrorMsg term=standout cterm=none ctermfg=white ctermbg=DarkRed gui=none guifg=white guibg=DarkRed
hi Folded term=reverse cterm=none ctermfg=darkblue ctermbg=lightgrey gui=none guifg=darkblue guibg=lightgrey
"8 col term
hi FoldColumn term=reverse cterm=none ctermfg=darkblue ctermbg=grey gui=none guifg=darkblue guibg=grey
hi IncSearch term=reverse cterm=none ctermfg=yellow ctermbg=darkgreen gui=none guifg=yellow guibg=#449944
hi lCursor term=reverse cterm=none ctermfg=black ctermbg=cyan gui=none guifg=black guibg=Cyan
hi LineNr term=reverse cterm=none ctermfg=darkred ctermbg=grey gui=none guifg=brown guibg=lightgrey
hi ModeMsg term=bold cterm=none ctermfg=green ctermbg=darkgreen gui=none guifg=#007700 guibg=#aaccaa
hi MoreMsg term=bold cterm=none ctermfg=darkGreen ctermbg=white gui=none guifg=darkgreen guibg=bg
hi Question term=bold cterm=none ctermfg=darkGreen ctermbg=white gui=none guifg=darkgreen guibg=bg
hi Search term=reverse cterm=none ctermfg=black ctermbg=yellow gui=none guifg=black guibg=yellow
hi SpecialKey term=italic cterm=none ctermfg=lightgrey ctermbg=white gui=none guifg=lightblue guibg=bg
hi NonText term=bold cterm=none ctermfg=lightgrey ctermbg=white gui=none guifg=#c6c6c6 guibg=bg
hi StatusLine term=reverse cterm=none ctermfg=white ctermbg=black gui=none guifg=#80624d guibg=#ddd9b8
hi Title term=bold cterm=none ctermfg=DarkMagenta ctermbg=white gui=none guifg=DarkMagenta guibg=bg
if has("gui_running") || &t_Co > 8
hi Visual term=reverse cterm=none ctermfg=black ctermbg=lightgrey gui=none guifg=black guibg=lightgreen
hi VertSplit term=reverse cterm=none ctermfg=darkgrey ctermbg=darkgrey gui=none guifg=#c7c7c2 guibg=#d7d7d2
hi StatusLineNC term=reverse cterm=none ctermfg=white ctermbg=darkgrey gui=none guifg=darkgrey guibg=#d7d7d2
hi Comment term=italic cterm=none ctermfg=grey ctermbg=white gui=none guifg=#ccaaaa guibg=bg
else
hi Visual term=reverse cterm=none ctermfg=green ctermbg=darkgreen gui=none guifg=black guibg=lightgreen
hi VertSplit term=reverse cterm=none ctermfg=darkcyan ctermbg=darkblue gui=none guifg=darkgrey guibg=darkgrey
hi StatusLineNC term=reverse cterm=none ctermfg=white ctermbg=darkblue gui=none guifg=white guibg=darkgrey
hi Comment term=italic cterm=none ctermfg=darkcyan ctermbg=white gui=none guifg=#ccaaaa guibg=bg
endif
hi VisualNOS term=bold cterm=none ctermfg=grey ctermbg=black gui=none guifg=grey guibg=black
hi WarningMsg term=standout cterm=none ctermfg=Red ctermbg=white gui=none guifg=Red guibg=bg
hi WildMenu term=bold cterm=none ctermfg=darkblue ctermbg=yellow gui=none guifg=black guibg=lightyellow
hi Constant term=underline cterm=none ctermfg=darkred ctermbg=bg gui=none guifg=#bb6666 guibg=bg
hi Special term=bold cterm=none ctermfg=darkcyan ctermbg=white gui=none guifg=darkcyan guibg=bg
hi identifier term=underline cterm=none ctermfg=darkmagenta ctermbg=white gui=none guifg=darkcyan guibg=bg
hi statement term=bold cterm=none ctermfg=darkgreen ctermbg=white gui=none guifg=#44aa44 guibg=bg
hi preproc term=underline cterm=none ctermfg=darkgrey ctermbg=white gui=none guifg=darkgrey guibg=bg
hi type term=none cterm=none ctermfg=brown ctermbg=white gui=none guifg=#bb9900 guibg=bg
hi underlined term=underline cterm=underline ctermfg=darkmagenta ctermbg=white gui=underline guifg=darkmagenta guibg=bg
hi Ignore term=italic cterm=none ctermfg=lightgrey ctermbg=white gui=none guifg=grey guibg=bg
"hi todo term=underline cterm=bold ctermfg=yellow ctermbg=brown gui=none guifg=#333333 guibg=#ddee33
hi todo term=bold cterm=none ctermfg=yellow ctermbg=brown gui=bold guifg=#229900 guibg=#ddd9b8
hi function term=bold cterm=none ctermfg=blue ctermbg=white gui=none guifg=#0055cc guibg=bg
hi link String Constant
hi link Character Constant
hi link Number Constant
hi link Boolean Constant
hi link Float Number
hi link Conditional Statement
hi link Repeat Statement
hi link Label Statement
hi link Operator Statement
hi link Keyword Statement
hi link Exception Statement
hi link Include PreProc
hi link Define PreProc
hi link Macro PreProc
hi link PreCondit PreProc
hi link StorageClass Type
hi link Structure Type
hi link Typedef Type
hi link Tag Special
hi link SpecialChar Special
hi link Delimiter Special
hi link SpecialComment Special
hi link Debug Special
hi link vimfunction function
" vim: set ts=8 sw=8 et sts=8 tw=72 fo-=t ff=unix :

69
vim/colors/autumn2.vim Normal file
View File

@ -0,0 +1,69 @@
" Vim color file
" Maintainer: Tiza
" Last Change: 2002/10/14 Mon 16:41.
" version: 1.0
" This color scheme uses a light background.
set background=light
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "autumn"
hi Normal guifg=#404040 guibg=#fff4e8
" Search
hi IncSearch gui=UNDERLINE guifg=#404040 guibg=#e0e040
hi Search gui=NONE guifg=#544060 guibg=#f0c0ff
" Messages
hi ErrorMsg gui=BOLD guifg=#f8f8f8 guibg=#4040ff
hi WarningMsg gui=BOLD guifg=#f8f8f8 guibg=#4040ff
hi ModeMsg gui=NONE guifg=#d06000 guibg=NONE
hi MoreMsg gui=NONE guifg=#0090a0 guibg=NONE
hi Question gui=NONE guifg=#8000ff guibg=NONE
" Split area
hi StatusLine gui=BOLD guifg=#f8f8f8 guibg=#904838
hi StatusLineNC gui=BOLD guifg=#c0b0a0 guibg=#904838
hi VertSplit gui=NONE guifg=#f8f8f8 guibg=#904838
hi WildMenu gui=BOLD guifg=#f8f8f8 guibg=#ff3030
" Diff
hi DiffText gui=NONE guifg=#2850a0 guibg=#c0d0f0
hi DiffChange gui=NONE guifg=#208040 guibg=#c0f0d0
hi DiffDelete gui=NONE guifg=#ff2020 guibg=#eaf2b0
hi DiffAdd gui=NONE guifg=#ff2020 guibg=#eaf2b0
" Cursor
hi Cursor gui=NONE guifg=#ffffff guibg=#0080f0
hi lCursor gui=NONE guifg=#ffffff guibg=#8040ff
hi CursorIM gui=NONE guifg=#ffffff guibg=#8040ff
" Fold
hi Folded gui=NONE guifg=#804030 guibg=#ffc0a0
hi FoldColumn gui=NONE guifg=#a05040 guibg=#f8d8c4
" Other
hi Directory gui=NONE guifg=#7050ff guibg=NONE
hi LineNr gui=NONE guifg=#e0b090 guibg=NONE
hi NonText gui=BOLD guifg=#a05040 guibg=#ffe4d4
hi SpecialKey gui=NONE guifg=#0080ff guibg=NONE
hi Title gui=BOLD guifg=fg guibg=NONE
hi Visual gui=NONE guifg=#804020 guibg=#ffc0a0
" hi VisualNOS gui=NONE guifg=#604040 guibg=#e8dddd
" Syntax group
hi Comment gui=NONE guifg=#ff5050 guibg=NONE
hi Constant gui=NONE guifg=#00884c guibg=NONE
hi Error gui=BOLD guifg=#f8f8f8 guibg=#4040ff
hi Identifier gui=NONE guifg=#b07800 guibg=NONE
hi Ignore gui=NONE guifg=bg guibg=NONE
hi PreProc gui=NONE guifg=#0090a0 guibg=NONE
hi Special gui=NONE guifg=#8040f0 guibg=NONE
hi Statement gui=BOLD guifg=#80a030 guibg=NONE
hi Todo gui=BOLD,UNDERLINE guifg=#0080f0 guibg=NONE
hi Type gui=BOLD guifg=#b06c58 guibg=NONE
hi Underlined gui=UNDERLINE guifg=blue guibg=NONE

154
vim/colors/autumnleaf.vim Normal file
View File

@ -0,0 +1,154 @@
" Vim color file
" Maintainer: Anders Korte
" Last Change: 17 Oct 2004
" AutumnLeaf color scheme 1.0
set background=light
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name="AutumnLeaf"
" Colors for the User Interface.
hi Cursor guibg=#aa7733 guifg=#ffeebb gui=bold
hi Normal guibg=#fffdfa guifg=black gui=none
hi NonText guibg=#eafaea guifg=#000099 gui=bold
hi Visual guibg=#fff8cc guifg=black gui=none
" hi VisualNOS
hi Linenr guibg=bg guifg=#999999 gui=none
" Uncomment these if you use Diff...??
" hi DiffText guibg=#cc0000 guifg=white gui=none
" hi DiffAdd guibg=#0000cc guifg=white gui=none
" hi DiffChange guibg=#990099 guifg=white gui=none
" hi DiffDelete guibg=#888888 guifg=#333333 gui=none
hi Directory guibg=bg guifg=#337700 gui=none
hi IncSearch guibg=#c8e8ff guifg=black gui=none
hi Search guibg=#c8e8ff guifg=black gui=none
hi SpecialKey guibg=bg guifg=fg gui=none
hi Titled guibg=bg guifg=fg gui=none
hi ErrorMsg guibg=bg guifg=#cc0000 gui=bold
hi ModeMsg guibg=bg guifg=#003399 gui=none
hi link MoreMsg ModeMsg
hi link Question ModeMsg
hi WarningMsg guibg=bg guifg=#cc0000 gui=bold
hi StatusLine guibg=#ffeebb guifg=black gui=bold
hi StatusLineNC guibg=#aa8866 guifg=#f8e8cc gui=none
hi VertSplit guibg=#aa8866 guifg=#ffe0bb gui=none
" hi Folded
" hi FoldColumn
" hi SignColumn
" Colors for Syntax Highlighting.
hi Comment guibg=#ddeedd guifg=#002200 gui=none
hi Constant guibg=bg guifg=#003399 gui=bold
hi String guibg=bg guifg=#003399 gui=italic
hi Character guibg=bg guifg=#003399 gui=italic
hi Number guibg=bg guifg=#003399 gui=bold
hi Boolean guibg=bg guifg=#003399 gui=bold
hi Float guibg=bg guifg=#003399 gui=bold
hi Identifier guibg=bg guifg=#003399 gui=none
hi Function guibg=bg guifg=#0055aa gui=bold
hi Statement guibg=bg guifg=#003399 gui=none
hi Conditional guibg=bg guifg=#aa7733 gui=bold
hi Repeat guibg=bg guifg=#aa5544 gui=bold
hi link Label Conditional
hi Operator guibg=bg guifg=#aa7733 gui=bold
hi link Keyword Statement
hi Exception guibg=bg guifg=#228877 gui=bold
hi PreProc guibg=bg guifg=#aa7733 gui=bold
hi Include guibg=bg guifg=#558811 gui=bold
hi link Define Include
hi link Macro Include
hi link PreCondit Include
hi Type guibg=bg guifg=#007700 gui=bold
hi link StorageClass Type
hi link Structure Type
hi Typedef guibg=bg guifg=#009900 gui=italic
hi Special guibg=bg guifg=fg gui=none
hi SpecialChar guibg=bg guifg=fg gui=bold
hi Tag guibg=bg guifg=#003399 gui=bold
hi link Delimiter Special
hi SpecialComment guibg=#dddddd guifg=#aa0000 gui=none
hi link Debug Special
hi Underlined guibg=bg guifg=blue gui=underline
hi Title guibg=bg guifg=fg gui=bold
hi Ignore guibg=bg guifg=#999999 gui=none
hi Error guibg=red guifg=white gui=none
hi Todo guibg=bg guifg=#aa0000 gui=none
" The same in cterm colors.
hi Cursor ctermbg=6 ctermfg=14
hi Normal ctermbg=15 ctermfg=0
hi NonText ctermbg=10 ctermfg=1
hi Visual ctermbg=14 ctermfg=0
" hi VisualNOS
hi Linenr ctermbg=bg ctermfg=7
" hi DiffText ctermbg=4 ctermfg=15
" hi DiffAdd ctermbg=1 ctermfg=15
" hi DiffChange ctermbg=5 ctermfg=15
" hi DiffDelete ctermbg=7 ctermfg=8
hi Directory ctermbg=bg ctermfg=2
hi IncSearch ctermbg=9 ctermfg=0
hi Search ctermbg=9 ctermfg=0
hi SpecialKey ctermbg=bg ctermfg=fg
hi Titled ctermbg=bg ctermfg=fg
hi ErrorMsg ctermbg=bg ctermfg=12
hi ModeMsg ctermbg=bg ctermfg=9
hi WarningMsg ctermbg=bg ctermfg=12
hi StatusLine ctermbg=14 ctermfg=0
hi StatusLineNC ctermbg=6 ctermfg=14
hi VertSplit ctermbg=6 ctermfg=14
" hi Folded
" hi FoldColumn
" hi SignColumn
hi Comment ctermbg=10 ctermfg=2
hi Constant ctermbg=bg ctermfg=9
hi String ctermbg=bg ctermfg=9 cterm=italic
hi Character ctermbg=bg ctermfg=9 cterm=italic
hi Number ctermbg=bg ctermfg=9 cterm=bold
hi Boolean ctermbg=bg ctermfg=9 cterm=bold
hi Float ctermbg=bg ctermfg=9 cterm=bold
hi Function ctermbg=bg ctermfg=9 cterm=bold
hi Statement ctermbg=bg ctermfg=9 cterm=bold
hi Conditional ctermbg=bg ctermfg=6 cterm=bold
hi Repeat ctermbg=bg ctermfg=6 cterm=bold
hi Operator ctermbg=bg ctermfg=6 cterm=bold
hi Exception ctermbg=bg ctermfg=2 cterm=bold
hi PreProc ctermbg=bg ctermfg=6
hi Include ctermbg=bg ctermfg=2 cterm=bold
hi Type ctermbg=bg ctermfg=2 cterm=bold
hi Typedef ctermbg=bg ctermfg=2 cterm=italic
hi Special ctermbg=bg ctermfg=fg cterm=bold
hi Tag ctermbg=bg ctermfg=9 cterm=bold
hi SpecialComment ctermbg=7 ctermfg=4
hi Underlined ctermbg=bg ctermfg=9 cterm=underline
hi Title ctermbg=bg ctermfg=fg cterm=bold
hi Ignore ctermbg=bg ctermfg=7
hi Error ctermbg=12 ctermfg=15
hi Todo ctermbg=bg ctermfg=15

319
vim/colors/baycomb.vim Normal file
View File

@ -0,0 +1,319 @@
" Vim color file
" baycomb v2.4
" http://www.vim.org/scripts/script.php?script_id=1454
"
" Maintainer: Shawn Axsom <axs221@gmail.com>
"
" * Place :colo baycomb in your VimRC/GVimRC file
" * Also add :set background=dark or :setbackground=light
" depending on your preference.
"
" - Thanks to Desert and OceanDeep for their color scheme
" file layouts
" - Thanks to Raimon Grau and Bob Lied for their feedback
if version > 580
" no guarantees for version 5.8 and below, but this makes it stop
" complaining
hi clear
if exists("syntax_on")
syntax reset
endif
endif
let g:colors_name="baycomb"
if &background == "dark"
hi Normal guifg=#a0b4e0 guibg=#11121a "1a1823
hi NonText guifg=#382920 guibg=bg
hi Folded guibg=#232235 guifg=grey
hi FoldColumn guibg=#0a0a18 guifg=#dbcaa5
hi LineNr guibg=#101124 guifg=#206aa9
hi StatusLine guibg=#354070 guifg=#6880ea gui=none
hi StatusLineNC guibg=#2c3054 guifg=#5c6dbe gui=none
hi VertSplit guibg=#22253c guifg=#223355 gui=none
hi tablinesel guibg=#515a71 guifg=#50aae5 gui=none
hi tabline guibg=#4d4d5f guifg=#5b7098 gui=none
hi tablinefill guibg=#2d2d3f guifg=#aaaaaa gui=none
"hi SpellBad
"hi SpellCap
"hi SpellLocal
"hi SpellRare
hi MatchParen guibg=#7b5a55 guifg=#001122
" syntax highlighting """"""""""""""""""""""""""""""""""""""""
hi Comment guifg=#349d58 guibg=bg
hi Title guifg=#e5e5ca gui=none
hi Underlined guifg=#bac5ba gui=none
hi Statement guifg=#fca8ad gui=none "a080aa
hi Type guifg=#0490e8 gui=bold
hi Constant guifg=#5c78f0 "guibg=#111a2a
hi Number guifg=#4580b4 "guibg=#111a2a
hi PreProc guifg=#ba75cf
hi Special guifg=#aaaaca
hi Ignore guifg=grey40
hi Todo guifg=orangered guibg=yellow2
hi Error guibg=#b03452
hi Function guifg=#bab588 guibg=bg gui=bold
hi Identifier guifg=#5094c4
"""""this section borrowed from OceanDeep/Midnight"""""
highlight Conditional gui=None guifg=#d0688d guibg=bg
highlight Repeat gui=None guifg=#e06070 guibg=bg
"hi Label gui=None guifg=LightGreen guibg=bg
highlight Operator gui=None guifg=#e8cdc0 guibg=bg
highlight Keyword gui=bold guifg=grey guibg=bg
highlight Exception gui=bold guifg=#d0a8ad guibg=bg
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
"end syntax highlighting """""""""""""""""""""""""""""""""""""
" highlight groups
"hi CursorIM
hi Directory guifg=#bbd0df
hi DiffText guibg=#004335
hi DiffChange guibg=#685b5c
hi DiffAdd guibg=#0a4b8c
hi DiffDelete guifg=#300845 guibg=#200845
hi ErrorMsg guibg=#ff4545
hi Cursor guibg=#cad5c0 guifg=#0000aa
hi Search guibg=darkyellow guifg=black
hi IncSearch guifg=#babeaa guibg=#3a4520
hi ModeMsg guifg=#00AACC
hi MoreMsg guifg=SeaGreen
hi Question guifg=#AABBCC
hi SpecialKey guifg=#90dcb0
hi Visual guifg=#102030 guibg=#80a0f0
hi VisualNOS guifg=#201a30 guibg=#a3a5FF
hi WarningMsg guifg=salmon
"hi WildMenu
"hi Menu
"hi Scrollbar guibg=grey30 guifg=tan
"hi Tooltip
" new Vim 7.0 items
hi Pmenu guibg=#3a6595 guifg=#9aadd5
hi PmenuSel guibg=#4a85ba guifg=#b0d0f0
" color terminal definitions
hi Cursor ctermfg=black ctermbg=white
hi Normal ctermfg=grey ctermbg=black
hi Number ctermfg=darkgreen
highlight Operator ctermfg=yellow
highlight Conditional ctermfg=darkred
highlight Repeat ctermfg=darkred
hi Exception ctermfg=darkred
hi SpecialKey ctermfg=darkgreen
hi NonText cterm=bold ctermfg=darkgrey
hi Directory ctermfg=darkcyan
hi ErrorMsg cterm=bold ctermfg=7 ctermbg=1
hi IncSearch ctermfg=yellow ctermbg=darkyellow cterm=NONE
hi Search ctermfg=black ctermbg=darkyellow cterm=NONE
hi MoreMsg ctermfg=darkgreen
hi ModeMsg cterm=NONE ctermfg=brown
hi LineNr ctermfg=darkcyan ctermbg=black
hi Question ctermfg=green
hi StatusLine ctermfg=yellow ctermbg=darkblue cterm=NONE
hi StatusLineNC ctermfg=grey ctermbg=darkblue cterm=NONE
hi VertSplit ctermfg=black ctermbg=darkgrey cterm=NONE
hi Title ctermfg=yellow cterm=NONE
hi Visual ctermbg=grey ctermfg=blue cterm=NONE
hi VisualNOS ctermbg=grey ctermfg=blue cterm=NONE
hi WarningMsg ctermfg=1
hi WildMenu ctermfg=0 ctermbg=3
hi Folded ctermfg=darkgreen ctermbg=darkblue cterm=NONE
hi FoldColumn ctermfg=yellow ctermbg=black
hi DiffAdd ctermbg=4
hi DiffChange ctermbg=5
hi DiffDelete cterm=bold ctermfg=4 ctermbg=6
hi DiffText cterm=bold ctermbg=1
hi Comment ctermfg=darkgreen ctermbg=black
hi Identifier ctermfg=cyan
"set comments to grey on non-Windows OS's to make sure
"it is readable
if &term == "builtin_gui" || &term == "win32"
hi function ctermfg=grey
hi Type ctermfg=darkyellow ctermbg=darkblue
hi IncSearch ctermfg=black ctermbg=grey cterm=NONE
hi Search ctermfg=black ctermbg=darkgrey cterm=NONE
else
hi function ctermfg=white
hi Type ctermfg=grey
hi IncSearch ctermfg=yellow ctermbg=darkyellow cterm=NONE
hi Search ctermfg=black ctermbg=darkyellow cterm=NONE
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""
hi Constant ctermfg=darkcyan
hi Special ctermfg=white
hi Statement ctermfg=yellow
hi PreProc ctermfg=darkred
hi Underlined ctermfg=cyan cterm=NONE
hi Ignore cterm=bold ctermfg=7
hi Ignore ctermfg=darkgrey
hi Error cterm=bold ctermfg=7 ctermbg=1
" new Vim 7.0 items
hi Pmenu ctermbg=darkblue ctermfg=lightgrey
hi PmenuSel ctermbg=lightblue ctermfg=white
hi tablinesel ctermfg=cyan ctermbg=blue
hi tabline ctermfg=black ctermbg=blue
hi tablinefill ctermfg=green ctermbg=darkblue
"vim: sw=4
"
hi MatchParen ctermfg=black ctermbg=green
elseif &background == "light"
hi Normal guifg=#003255 guibg=#e8ebf0 "greyish blue2
hi NonText guifg=#382920 guibg=#152555
" syntax highlighting """"""""""""""""""""""""""""""""""""""""
"set comments to grey on non-Windows OS's to make sure
"it is readable
if &term == "builtin_gui" || &term == "win32"
hi Comment guifg=#daddb8 guibg=#308ae5
else
hi Comment guifg=darkyellow guibg=#207ada
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""
hi Title guifg=#857540 gui=none
hi Underlined guifg=#8a758a
hi Statement guifg=#da302a gui=none
hi Type guifg=#307aca gui=none
hi Constant guifg=#3a40aa gui=none
hi PreProc guifg=#9570b5
hi Identifier guifg=#856075 "gui=bold
hi Special guifg=#652a7a
hi Ignore guifg=grey40
hi Todo guifg=orangered guibg=yellow2
hi Error guibg=#b03452
"""""this section borrowed from OceanDeep/Midnight"""""
hi Number guifg=#006bcd
hi Function gui=None guifg=#d06d50 "or green 50b3b0
highlight Conditional gui=None guifg=#a50a4a
highlight Repeat gui=None guifg=#700d8a
"hi Label gui=None guifg=LightGreen guibg=bg
highlight Operator gui=None guifg=#e0b045
highlight Keyword gui=bold guifg=grey guibg=bg
highlight Exception gui=none guifg=#ea5460
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
"end syntax highlighting """""""""""""""""""""""""""""""""""""
" highlight groups
"hi CursorIM
hi Directory guifg=#bbd0df
"hi DiffAdd
"hi DiffChange
"hi DiffDelete
"hi DiffText
hi ErrorMsg guibg=#ff4545
hi Cursor guibg=#cadaca guifg=#05293d
hi FoldColumn guibg=#409ae0 guifg=darkgrey
"hi FoldColumn guibg=#83a5cd guifg=#70459F
hi LineNr guibg=#409ae0 guifg=darkblue gui=bold
"hi LineNr guibg=#081c30 guifg=#80a0dA
hi StatusLine guibg=#20b5fd guifg=#0a150d gui=none
hi StatusLineNC guibg=#0580da guifg=#302d34 gui=none
hi Search guibg=#babdad guifg=#3a4520
hi IncSearch guifg=#dadeca guibg=#3a4520
hi VertSplit guibg=#525f95 guifg=grey50 gui=none
hi Folded guibg=#252f5d guifg=#BBDDCC
hi ModeMsg guifg=#00AACC
hi MoreMsg guifg=SeaGreen
hi Question guifg=#AABBCC
hi SpecialKey guifg=#308c70
hi Visual guifg=#008FBF guibg=#33DFEF
"hi VisualNOS
hi WarningMsg guifg=salmon
"hi WildMenu
"hi Menu
"hi Scrollbar guibg=grey30 guifg=tan
"hi Tooltip
" new Vim 7.0 items
hi Pmenu guibg=#3a6595 guifg=#9aadd5
hi PmenuSel guibg=#4a85ba guifg=#b0d0f0
" color terminal definitions
hi Normal ctermfg=black ctermbg=white
hi Number ctermfg=blue
highlight Operator ctermfg=yellow
highlight Conditional ctermfg=magenta
highlight Repeat ctermfg=magenta
hi Exception ctermfg=red
hi function ctermfg=darkyellow
hi SpecialKey ctermfg=darkgreen
hi NonText cterm=bold ctermfg=darkgrey ctermbg=grey
hi Directory ctermfg=darkcyan
hi ErrorMsg cterm=bold ctermfg=7 ctermbg=1
hi IncSearch ctermfg=yellow ctermbg=darkyellow cterm=NONE
hi Search ctermfg=white ctermbg=darkyellow cterm=NONE
hi MoreMsg ctermfg=darkgreen
hi ModeMsg cterm=NONE ctermfg=brown
hi LineNr ctermfg=black ctermbg=blue
hi Question ctermfg=green
hi StatusLine ctermfg=cyan ctermbg=blue cterm=NONE
hi StatusLineNC ctermfg=grey ctermbg=darkblue cterm=NONE
hi VertSplit ctermfg=black ctermbg=black cterm=NONE
hi Title ctermfg=darkyellow ctermbg=white
hi Visual ctermbg=darkcyan ctermfg=cyan cterm=NONE
hi VisualNOS ctermbg=darkcyan ctermfg=white cterm=NONE
hi WarningMsg ctermfg=1
hi WildMenu ctermfg=0 ctermbg=3
hi Folded ctermfg=black ctermbg=white cterm=NONE
hi FoldColumn ctermfg=green ctermbg=blue
hi DiffAdd ctermbg=4
hi DiffChange ctermbg=5
hi DiffDelete cterm=bold ctermfg=4 ctermbg=6
hi DiffText cterm=bold ctermbg=1
hi Comment ctermfg=grey ctermbg=blue
hi Constant ctermfg=darkblue
hi Special ctermfg=darkmagenta
hi Identifier ctermfg=darkyellow cterm=NONE
hi Statement ctermfg=red
hi PreProc ctermfg=magenta
hi Type ctermfg=darkcyan "or darkcyan
hi Underlined ctermfg=black ctermbg=white
hi Ignore cterm=bold ctermfg=7
hi Ignore ctermfg=darkgrey
hi Error cterm=bold ctermfg=7 ctermbg=1
" new Vim 7.0 items
hi Pmenu ctermbg=darkblue ctermfg=lightgrey
hi PmenuSel ctermbg=lightblue ctermfg=white
"vim: sw=4
endif

99
vim/colors/billw.vim Normal file
View File

@ -0,0 +1,99 @@
" vim: set tw=0 sw=4 sts=4 et:
" Vim color file
" Maintainer: Datila Carvalho <datila@saci.homeip.net>
" Last Change: November, 3, 2003
" Version: 0.1
" This is a VIM's version of the emacs color theme
" _Billw_ created by Bill White.
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "billw"
""" Colors
" GUI colors
hi Cursor guifg=fg guibg=cornsilk
hi CursorIM guifg=NONE guibg=cornsilk
"hi Directory
"hi DiffAdd
"hi DiffChange
"hi DiffDelete
"hi DiffText
hi ErrorMsg gui=bold guifg=White guibg=Red
"hi VertSplit
"hi Folded
"hi FoldColumn
"hi IncSearch
"hi LineNr
hi ModeMsg gui=bold
"hi MoreMsg
"hi NonText
hi Normal guibg=black guifg=cornsilk
"hi Question
hi Search gui=bold guifg=Black guibg=cornsilk
"hi SpecialKey
hi StatusLine guifg=orange1
hi StatusLineNC guifg=yellow4
"hi Title
hi Visual guifg=gray35 guibg=fg
hi VisualNOS gui=bold guifg=black guibg=fg
hi WarningMsg guifg=White guibg=Tomato
"hi WildMenu
" Colors for syntax highlighting
hi Comment guifg=gold
hi Constant guifg=mediumspringgreen
hi String guifg=orange
hi Character guifg=orange
hi Number guifg=mediumspringgreen
hi Boolean guifg=mediumspringgreen
hi Float guifg=mediumspringgreen
hi Identifier guifg=yellow
hi Function guifg=mediumspringgreen
hi Statement gui=bold guifg=cyan1
hi Conditional gui=bold guifg=cyan1
hi Repeat gui=bold guifg=cyan1
hi Label guifg=cyan1
hi Operator guifg=cyan1
"hi Keyword
"hi Exception
hi PreProc guifg=LightSteelBlue
hi Include guifg=LightSteelBlue
hi Define guifg=LightSteelBlue
hi Macro guifg=LightSteelBlue
hi PreCondit guifg=LightSteelBlue
hi Type guifg=yellow
hi StorageClass guifg=cyan1
hi Structure gui=bold guifg=cyan1
hi Typedef guifg=cyan1
"hi Special
""Underline Character
"hi SpecialChar gui=underline
"hi Tag gui=bold,underline
""Statement
"hi Delimiter gui=bold
""Bold comment (in Java at least)
"hi SpecialComment gui=bold
"hi Debug gui=bold
hi Underlined gui=underline
hi Ignore guifg=bg
hi Error gui=bold guifg=White guibg=Red
"hi Todo

115
vim/colors/biogoo.vim Normal file
View File

@ -0,0 +1,115 @@
" Vim color File
" Name: biogoo
" Maintainer: Benjamin Esham <bdesham@gmail.com>
" Last Change: 2006-11-20
" Version: 1.5
"
" Colorful text on a light gray background. It's pretty easy on the eyes in
" my opinion. Any feedback is greatly appreciated!
"
" Installation:
" Copy to ~/.vim/colors; do :color biogoo
"
" Customization Options:
" Use a 'normal' cursor color:
" let g:biogoo_normal_cursor = 1
"
" Props:
" Jani Nurminen's zenburn.vim as an example file.
" Scott F. and Matt F. for feature suggestions.
" Bill McCarthy for his Vim mailing list post about Vim 7 support.
"
" Version History:
" 1.5: should fully support Vim 7 now
" 1.4: more support for Vim 7: added the `MatchParen' group for ()[]{} matching
" 1.3: added support for Vim 7: added groups for the new spellchecking, and
" added a conditional to display Visual mode correctly in any version.
" 1.2: added `SpellErrors' group for use with vimspell.
" 1.1: added `IncSearch' group for improved visibility in incremental searches.
" 1.0: minor tweaks
" 0.95: initial release
"
" TODO: Add new groups as needed. E-mail me with any suggestions!
set background=light
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "biogoo"
hi Comment guifg=#0000c3
hi Constant guifg=#0000ff
hi CursorColumn guibg=#ffffff
hi CursorLine guibg=#ffffff
hi Delimiter guifg=#00007f
hi DiffAdd guifg=#007f00 guibg=#e5e5e5
hi DiffChange guifg=#00007f guibg=#e5e5e5
hi DiffDelete guifg=#7f0000 guibg=#e5e5e5
hi DiffText guifg=#ee0000 guibg=#e5e5e5
hi Directory guifg=#b85d00
hi Error guifg=#d6d6d6 guibg=#7f0000
hi ErrorMsg guifg=#ffffff guibg=#ff0000 gui=bold
hi Float guifg=#b85d00
hi FoldColumn guifg=#00007f guibg=#e5e5e5
hi Folded guifg=#00007f guibg=#e5e5e5
hi Function guifg=#7f0000
hi Identifier guifg=#004000
hi Include guifg=#295498 gui=bold
hi IncSearch guifg=#ffffff guibg=#0000ff gui=bold
hi LineNr guifg=#303030 guibg=#e5e5e5 gui=underline
hi Keyword guifg=#00007f
hi Macro guifg=#295498
hi MatchParen guifg=#ffffff guibg=#00a000
hi ModeMsg guifg=#00007f
hi MoreMsg guifg=#00007f
hi NonText guifg=#007f00
hi Normal guifg=#000000 guibg=#d6d6d6
hi Number guifg=#b85d00
hi Operator guifg=#00007f
hi Pmenu guifg=#000000 guibg=#cc9999
hi PmenuSel guifg=#ffffff guibg=#993333
hi PmenuSbar guibg=#99cc99
hi PmenuThumb guifg=#339933
hi PreCondit guifg=#295498 gui=bold
hi PreProc guifg=#0c3b6b gui=bold
hi Question guifg=#00007f
hi Search guibg=#ffff00
hi Special guifg=#007f00
hi SpecialKey guifg=#00007f
hi SpellBad guifg=#ffffff guibg=#7f0000 gui=undercurl guisp=#d6d6d6
hi SpellCap guifg=#ffffff guibg=#7f007f gui=undercurl guisp=#d6d6d6
hi SpellLocal guifg=#ffffff guibg=#007f7f gui=undercurl guisp=#d6d6d6
hi SpellRare guifg=#ffffff guibg=#b85d00 gui=undercurl guisp=#d6d6d6
hi Statement guifg=#00007f gui=none
hi StatusLine guifg=#00007f guibg=#ffffff
hi StatusLineNC guifg=#676767 guibg=#ffffff
hi String guifg=#d10000
hi TabLine guifg=#222222 guibg=#d6d6d6
hi TabLineFill guifg=#d6d6d6
hi TabLineSel guifg=#00007f guibg=#eeeeee gui=bold
hi Title guifg=#404040 gui=bold
hi Todo guifg=#00007f guibg=#e5e5e5 gui=underline
hi Type guifg=#540054 gui=bold
hi Underlined guifg=#b85d00
hi VertSplit guifg=#676767 guibg=#ffffff
if version < 700
hi Visual guifg=#7f7f7f guibg=#ffffff
else
hi Visual guifg=#ffffff guibg=#7f7f7f
endif
hi VisualNOS guifg=#007f00 guibg=#e5e5e5
hi WarningMsg guifg=#500000
hi WildMenu guifg=#540054
" Non-standard highlighting (e.g. for plugins)
" vimspell
hi SpellErrors guifg=#ffffff guibg=#7f0000 gui=undercurl guisp=#d6d6d6
if !exists("g:biogoo_normal_cursor")
" use a gray-on-blue cursor
hi Cursor guifg=#ffffff guibg=#00007f
endif
" vim:noet:ts=4 sw=4

115
vim/colors/black_angus.vim Normal file
View File

@ -0,0 +1,115 @@
" Vim color file
" Maintainer: Angus Salkeld
" Last Change: 14 September 2004
" Version: 1.0
" mainly green on black
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "black_angus"
" GUI
" -----------------------------------------------------------------------
highlight Normal guifg=Grey80 guibg=Black
highlight Search guifg=brown gui=reverse
highlight Visual guifg=Grey25 gui=bold
highlight Cursor guifg=Yellow guibg=DarkGreen gui=bold
highlight DiffAdd guibg=#000080 gui=NONE
highlight DiffChange guibg=#800080 gui=NONE
highlight DiffDelete guifg=#80c0e0 guibg=#404040 gui=NONE
highlight DiffText guifg=Black guibg=#c0e080 gui=NONE
" Console
" -----------------------------------------------------------------------
highlight Normal ctermfg=LightGrey ctermbg=Black
highlight Search ctermfg=Brown cterm=reverse
highlight Visual cterm=reverse
highlight Cursor ctermfg=Yellow ctermbg=Green cterm=bold
" both
" -----------------------------------------------------------------------
highlight StatusLine guifg=LightGreen guibg=#003300 gui=none ctermfg=LightGreen ctermbg=DarkGreen term=none
highlight VertSplit guifg=LightGreen guibg=#003300 gui=none ctermfg=LightGreen ctermbg=DarkGreen term=none
highlight Folded guifg=#aaDDaa guibg=#333333 gui=none ctermfg=LightGray ctermbg=DarkGray term=none
highlight FoldColumn guifg=LightGreen guibg=#003300 gui=none ctermfg=LightGreen ctermbg=DarkGreen term=none
highlight SignColumn guifg=LightGreen guibg=#003300 gui=none ctermfg=LightGreen ctermbg=DarkGreen term=none
highlight WildMenu guifg=LightGreen guibg=#003300 gui=none ctermfg=LightGreen ctermbg=DarkGreen term=none
highlight LineNr guifg=DarkGreen guibg=Black gui=none ctermfg=DarkGreen ctermbg=Black term=none
highlight Directory guifg=LightGreen ctermfg=LightGreen
highlight Comment guifg=DarkGrey ctermfg=DarkGray
highlight Special guifg=Orange ctermfg=Brown
highlight Title guifg=Orange ctermfg=Brown
highlight Tag guifg=DarkRed ctermfg=DarkRed
highlight link Delimiter Special
highlight link SpecialChar Special
highlight link SpecialComment Special
highlight link SpecialKey Special
highlight link NonText Special
highlight Error guifg=White guibg=DarkRed gui=none ctermfg=White ctermbg=DarkRed cterm=none
highlight Debug guifg=White guibg=DarkGreen gui=none ctermfg=White ctermbg=DarkRed cterm=none
highlight ErrorMsg guifg=White guibg=DarkBlue gui=none ctermfg=White ctermbg=DarkRed cterm=none
highlight WarningMsg guifg=White guibg=DarkBlue gui=none ctermfg=White ctermbg=DarkBlue cterm=none
highlight Todo guifg=White guibg=DarkYellow gui=none ctermfg=White ctermbg=DarkBlue cterm=none
highlight link cCommentStartError WarningMsg
highlight link cCommentError Debug
" Preprocesor
highlight PreCondit guifg=Cyan3 ctermfg=Cyan
highlight PreProc guifg=Magenta ctermfg=Magenta
highlight Include guifg=DarkCyan ctermfg=DarkCyan
highlight ifdefIfOut guifg=DarkGray ctermfg=DarkGray
highlight link Macro Include
highlight link Define Include
" lang
highlight Function guifg=#AAEEAA gui=none ctermfg=LightGreen
highlight Identifier guifg=#bbccbb gui=none ctermfg=Grey
highlight Statement guifg=LightGreen gui=underline ctermfg=LightGreen
highlight Operator guifg=Yellow gui=none ctermfg=Yellow
highlight Conditional guifg=lightslateblue gui=none ctermfg=LightBlue
highlight link Exception Statement
highlight link Label Statement
highlight link Repeat Conditional
highlight link Keyword Label
highlight Constant guifg=LightGreen ctermfg=LightGreen gui=none
highlight link Character Constant
highlight link Number Constant
highlight link Boolean Constant
highlight link String Constant
highlight link Float Constant
highlight Type guifg=DarkGreen ctermfg=DarkGreen gui=none
highlight link StorageClass Type
highlight link Structure Type
highlight link Typedef Type
" ------------------------------------------------------------------------------
" Common groups that link to other highlighting definitions.
highlight link Search IncSearch
highlight link Question Statement
highlight link VisualNOS Visual
" ------------------------------------------------------------------------------
" only for vim 5
if has("unix")
if v:version<600
highlight Normal ctermfg=Grey ctermbg=Black cterm=NONE guifg=Grey80 guibg=Black gui=NONE
highlight Search ctermfg=Black ctermbg=Red cterm=bold guifg=Black guibg=Red gui=bold
highlight Visual ctermfg=Black ctermbg=yellow cterm=bold guifg=Grey25 gui=bold
highlight Special ctermfg=LightBlue cterm=NONE guifg=LightBlue
highlight Comment ctermfg=Cyan cterm=NONE guifg=LightBlue
endif
endif

View File

@ -0,0 +1,66 @@
" Vim color file
" Maintainer: Surya
" Last Change: 12/23/2003 10:32:41 .
" version: 1.0
" This color scheme uses a dark background.
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "koehler"
hi Normal guifg=white guibg=black
hi Scrollbar guibg=darkgray guifg=darkgray
hi Menu guifg=black guibg=gray
hi SpecialKey term=bold cterm=bold ctermfg=darkred guifg=Blue
hi NonText term=bold cterm=bold ctermfg=darkred gui=bold guifg=Blue
hi Directory term=bold cterm=bold ctermfg=brown guifg=Blue
hi ErrorMsg term=standout cterm=bold ctermfg=grey ctermbg=blue gui=bold guifg=White guibg=brown
hi Search term=reverse ctermfg=white ctermbg=red gui=bold guifg=#000000 guibg=Magenta
hi MoreMsg term=bold cterm=bold ctermfg=darkgreen gui=bold guifg=SeaGreen
hi ModeMsg term=bold cterm=bold gui=bold guifg=White guibg=Blue
hi LineNr term=underline cterm=bold ctermfg=darkcyan guibg=brown guifg=white
hi Question term=standout cterm=bold ctermfg=darkgreen gui=bold guifg=Green
hi StatusLine term=bold,reverse cterm=bold ctermfg=lightblue ctermbg=white gui=bold guibg=white guifg=brown
hi StatusLineNC term=reverse ctermfg=white ctermbg=lightblue guifg=white guibg=blue
hi Title term=bold cterm=bold ctermfg=darkmagenta gui=bold guifg=Magenta
hi Visual term=reverse cterm=reverse gui=reverse
hi WarningMsg term=standout cterm=bold ctermfg=darkblue gui=bold guifg=cyan guibg=Black
hi Cursor guifg=bg guibg=cyan
hi Comment term=bold cterm=bold ctermfg=cyan guifg=#80a0ff
hi Constant term=underline cterm=bold ctermfg=magenta guifg=#ffa0a0
hi String term=underline cterm=bold ctermfg=magenta gui=bold guifg=brown guibg=darkgray
hi Number term=underline cterm=bold ctermfg=magenta guifg=#00ffff
hi Special term=bold gui=bold cterm=bold ctermfg=red guifg=Orange
hi Identifier term=underline ctermfg=brown guifg=#40ffff
hi Statement term=bold cterm=bold ctermfg=yellow gui=bold guifg=#ffff60
hi PreProc term=underline ctermfg=darkblue guifg=#ff80ff
hi Type term=underline cterm=bold ctermfg=lightgreen gui=bold guifg=#60ff60
hi Error gui=bold guifg=Yellow guibg=Black
hi Todo term=standout ctermfg=black ctermbg=darkcyan guifg=Blue guibg=Yellow
"hi VertSplit guifg=#00FFFF guibg=#000000 gui=bold
hi link IncSearch Visual
hi link Character Constant
hi link Boolean Constant
hi link Float Number
hi link Function Identifier
hi link Conditional Statement
hi link Repeat Statement
hi link Label Statement
hi link Operator Statement
hi link Keyword Statement
hi link Exception Statement
hi link Include PreProc
hi link Define PreProc
hi link Macro PreProc
hi link PreCondit PreProc
hi link StorageClass Type
hi link Structure Type
hi link Typedef Type
hi link Tag Special
hi link SpecialChar Special
hi link Delimiter Special
hi link SpecialComment Special
hi link Debug Special

62
vim/colors/blackdust.vim Normal file
View File

@ -0,0 +1,62 @@
set background=dark
hi clear
hi Boolean guifg=#dca3a3 gui=bold
hi Character guifg=#dca3a3 gui=bold
hi Comment guifg=#7f7f7f
hi Condtional guifg=#8fffff
hi Constant guifg=#dca3a3 gui=bold
hi Cursor guifg=#000000 guibg=#aeaeae
hi Debug guifg=#dca3a3 gui=bold
hi Define guifg=#ffcfaf gui=bold
hi Delimiter guifg=#8f8f8f
hi DiffAdd guibg=#613c46
hi DiffChange guibg=#333333
hi DiffDelete guifg=#333333 guibg=#464646 gui=none
hi DiffText guifg=#ffffff guibg=#1f1f1f gui=bold
hi Directory guifg=#ffffff gui=bold
hi Error guifg=#000000 guibg=#00ffff
hi ErrorMsg guifg=#000000 guibg=#00c0cf
hi Exception guifg=#8fffff gui=underline
hi Float guifg=#9c93b3
hi FoldColumn guifg=#dca3a3 guibg=#464646
hi Folded guifg=#dca3a3 guibg=#333333
hi Function guifg=#ffff8f
hi Identifier guifg=#ffffff
hi Include guifg=#ffcfaf gui=bold
hi IncSearch guifg=#000000 guibg=#c15c66
hi Keyword guifg=#ffffff gui=bold
hi Label guifg=#8fffff gui=underline
hi LineNr guifg=#7f7f7f guibg=#464646
hi Macro guifg=#ffcfaf gui=bold
hi ModeMsg guifg=#dca3a3 gui=bold
hi MoreMsg guifg=#ffffff gui=bold
hi NonText guifg=#1f1f1f
hi Normal guifg=#cccccc guibg=#3f3f3f
hi Number guifg=#aca0a3
hi Operator guifg=#ffffff
hi PreCondit guifg=#dfaf8f gui=bold
hi PreProc guifg=#ffcfaf gui=bold
hi Question guifg=#ffffff gui=bold
hi Repeat guifg=#8fffff gui=underline
hi Search guifg=#000000 guibg=#c15c66
hi SpecialChar guifg=#dca3a3 gui=bold
hi SpecialComment guifg=#dca3a3 gui=bold
hi Special guifg=#7f7f7f
hi SpecialKey guifg=#7e7e7e
hi Statement guifg=#8fffff
hi StatusLine guifg=#333333 guibg=#f18c96
hi StatusLineNC guifg=#333333 guibg=#cccccc
hi StorageClass guifg=#ffffff gui=bold
hi String guifg=#cc9393
hi Structure guifg=#ffffff gui=bold,underline
hi Tag guifg=#dca3a3 gui=bold
hi Title guifg=#ffffff guibg=#333333 gui=bold
hi Todo guifg=#ffffff guibg=#000000 gui=bold
hi Typedef guifg=#ffffff gui=bold,underline
hi Type guifg=#ffffff gui=bold
hi VertSplit guifg=#333333 guibg=#cccccc
hi Visual guifg=#333333 guibg=#f18c96 gui=reverse
hi VisualNOS guifg=#333333 guibg=#f18c96 gui=bold,underline
hi WarningMsg guifg=#ffffff guibg=#333333 gui=bold
hi WildMenu guifg=#000000 guibg=#dca3a3

32
vim/colors/blacksea.vim Normal file
View File

@ -0,0 +1,32 @@
" Vim color file
" Maintainer: Gerald S. Williams
" Last Change: 2003 Mar 20
" This is a dark version/opposite of "seashell". The cterm version of this is
" very similar to "evening".
"
" Only values that differ from defaults are specified.
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "BlackSea"
hi Normal guibg=Black guifg=seashell ctermfg=White
hi NonText guifg=LavenderBlush ctermfg=LightMagenta
hi DiffDelete guibg=DarkRed guifg=Black ctermbg=DarkRed ctermfg=White
hi DiffAdd guibg=DarkGreen ctermbg=DarkGreen ctermfg=White
hi DiffChange guibg=Gray30 ctermbg=DarkCyan ctermfg=White
hi DiffText gui=NONE guibg=DarkCyan ctermbg=DarkCyan ctermfg=Yellow
hi Comment guifg=LightBlue
hi Constant guifg=DeepPink
hi PreProc guifg=Magenta ctermfg=Magenta
hi StatusLine guibg=#1f001f guifg=DarkSeaGreen cterm=NONE ctermfg=White ctermbg=DarkGreen
hi StatusLineNC guifg=Gray
hi VertSplit guifg=Gray
hi Type gui=NONE
hi Identifier guifg=Cyan
hi Statement guifg=brown3 ctermfg=DarkRed
hi Search guibg=Gold3 ctermfg=White

41
vim/colors/blue.vim Normal file
View File

@ -0,0 +1,41 @@
" Vim color file
" Maintainer: TaQ <taq@taq.cjb.net>
" Last Change: 10 October 2001 - 0.2
" URL: http://taq.cjb.net
" cool help screens
" :he group-name
" :he highlight-groups
" :he cterm-colors
set background=dark " or light
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name="blue"
hi Normal ctermfg=Gray ctermbg=Black guifg=#CCCCCC guibg=#000040
hi NonText ctermfg=Gray ctermbg=Black guifg=#0050EE guibg=#000040
hi Statement ctermfg=White ctermbg=Black guifg=#007FFF guibg=#000040 gui=BOLD
hi Comment ctermfg=Blue ctermbg=Black guifg=#00A0FF guibg=#000090 gui=NONE
hi Constant ctermfg=White ctermbg=Black guifg=#0050EE guibg=#000040 gui=NONE
hi Identifier ctermfg=Cyan ctermbg=Black guifg=#FFFFFF guibg=#000040 gui=NONE
hi Type ctermfg=Cyan ctermbg=Black guifg=#5050FF guibg=#000040 gui=NONE
hi Folded ctermfg=White ctermbg=Blue guifg=#00A0FF guibg=#000050 gui=BOLD
hi Special ctermfg=Blue ctermbg=Black guifg=#00A0FF guibg=#000090 gui=NONE
hi PreProc ctermfg=Blue ctermbg=Black guifg=#00FF00 guibg=#000040 gui=BOLD
hi Scrollbar ctermfg=Blue ctermbg=Black guifg=#00C0FF guibg=#000040
hi Cursor ctermfg=white ctermbg=Black guifg=#FFFFFF guibg=#5050FF
hi ErrorMsg ctermfg=white ctermbg=Red guifg=#FFFFFF guibg=#FF0000
hi WarningMsg ctermfg=Black ctermbg=Yellow guifg=#000000 guibg=#FFFF00
hi VertSplit ctermfg=White ctermbg=Blue guifg=#000090 guibg=#000090
hi Directory ctermfg=Cyan ctermbg=DarkBlue guifg=#00A0F0 guibg=#000040
hi Visual ctermfg=Black ctermbg=Cyan guifg=#5050FF guibg=#FFFFFF
hi Title ctermfg=White ctermbg=Blue guifg=#FFFFFF guibg=#0050EE gui=NONE
hi StatusLine term=bold cterm=bold ctermfg=White ctermbg=Blue gui=bold guifg=#FFFFFF guibg=#0050EE
hi StatusLineNC term=bold cterm=bold ctermfg=Gray ctermbg=Blue gui=bold guifg=#AAAAAA guibg=#000090
hi LineNr term=bold cterm=bold ctermfg=White ctermbg=DarkBlue gui=bold guifg=#00A0FF guibg=#000050

52
vim/colors/bluegreen.vim Normal file
View File

@ -0,0 +1,52 @@
" Vim color file
" Maintainer:
" Last Change:
" URL:
" cool help screens
" :he group-name
" :he highlight-groups
" :he cterm-colors
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name="mine"
hi Normal guifg=White guibg=#061A3E
" highlight groups
hi Cursor guibg=#D74141 guifg=#e3e3e3
hi VertSplit guibg=#C0FFFF guifg=#075554 gui=none
hi Folded guibg=#FFC0C0 guifg=black
hi FoldColumn guibg=#800080 guifg=tan
"hi IncSearch cterm=none ctermbg=blue ctermfg=grey guifg=slategrey guibg=khaki
hi ModeMsg guifg=#404040 guibg=#C0C0C0
hi MoreMsg guifg=darkturquoise guibg=#188F90
hi NonText guibg=#334C75 guifg=#9FADC5
hi Question guifg=#F4BB7E
hi Search guibg=fg guifg=bg
hi SpecialKey guifg=#BF9261
hi StatusLine guibg=#004443 guifg=#c0ffff gui=none
hi StatusLineNC guibg=#067C7B guifg=#004443 gui=bold
hi Title guifg=#8DB8C3
hi Visual gui=bold guifg=black guibg=#C0FFC0
hi WarningMsg guifg=#F60000 gui=underline
" syntax highlighting groups
hi Comment guifg=#DABEA2
hi Constant guifg=#72A5E4 gui=bold
hi Identifier guifg=#ADCBF1
hi Statement guifg=#7E75B5
hi PreProc guifg=#14F07C
hi Type guifg=#A9EE8A
hi Special guifg=#EEBABA
hi Ignore guifg=grey60
hi Todo guibg=#9C8C84 guifg=#244C0A
"vim: ts=4

Some files were not shown because too many files have changed in this diff Show More