mirror of
https://github.com/ViViDboarder/vim-settings.git
synced 2024-12-22 20:07:37 +00:00
Initial commit
This commit is contained in:
commit
4c984098bf
4
README
Normal file
4
README
Normal file
@ -0,0 +1,4 @@
|
||||
These are just my Vim settings that I like to keep synced between my computers for convenience
|
||||
|
||||
I am not the original creators of many of the files included in the dot_vim directory and only re-host them out of convienince. If I am missing any licensing information I'd be happy to attach it.
|
||||
|
38
vim-sync-append.sh
Normal file
38
vim-sync-append.sh
Normal file
@ -0,0 +1,38 @@
|
||||
#! /bin/bash
|
||||
|
||||
# Get current directory for future use in links
|
||||
VIM_SYNC_DIR=${pwd}
|
||||
|
||||
# If a .vimrc_sync doesn't exist, link it
|
||||
if [[ ! ( -f ~/.vimrc_sync ) ]]; then
|
||||
ln -s $VIM_SYNC_DIR/vim/dot_vimrc ~/.vimrc_sync
|
||||
fi
|
||||
|
||||
# If a .vim_drpobox dir doesn't exist, link it
|
||||
if [[ ! ( -d ~/.vim_sync ) ]]; then
|
||||
ln -s $VIM_SYNC_DIR/vim/dot_vim ~/.vim_sync
|
||||
fi
|
||||
|
||||
# if there is no .vimrc file already, make a blank one
|
||||
if [[ ( ! -f ~/.vimrc ) ]]; then
|
||||
touch ~/.vimrc
|
||||
fi
|
||||
|
||||
# if not already sourcing the synced version, source it
|
||||
if ! ( grep -q 'source .vimrc_sync' ~/.vimrc ); then
|
||||
echo '' >> ~/.vimrc
|
||||
echo '"import vimrc from synced' >> ~/.vimrc
|
||||
echo 'source ~/.vimrc_sync' >> ~/.vimrc
|
||||
fi
|
||||
|
||||
if ! ( grep -q 'set runtimepath+=$HOME/.vim_sync' ~/.vimrc ); then
|
||||
echo '' >> ~/.vimrc
|
||||
echo '"add vim directory from synced' >> ~/.vimrc
|
||||
echo 'set runtimepath+=$HOME/.vim_sync' >> ~/.vimrc
|
||||
fi
|
||||
|
||||
# Execute vim's update of the helptags
|
||||
vim +"helptags ~/.vim_sync/doc" +"q"
|
||||
|
||||
echo "Should install ctags with sudo apt-get install ctags"
|
||||
|
7
vim/dot_vim/.netrwhist
Normal file
7
vim/dot_vim/.netrwhist
Normal file
@ -0,0 +1,7 @@
|
||||
let g:netrw_dirhistmax =10
|
||||
let g:netrw_dirhist_cnt =5
|
||||
let g:netrw_dirhist_1='/home/ianfijolek/Dropbox/linux_home/vim/vim/doc'
|
||||
let g:netrw_dirhist_2='/home/ianfijolek'
|
||||
let g:netrw_dirhist_3='/home'
|
||||
let g:netrw_dirhist_4='/'
|
||||
let g:netrw_dirhist_5='/home/ianfijolek'
|
177
vim/dot_vim/doc/alternate.txt
Normal file
177
vim/dot_vim/doc/alternate.txt
Normal file
@ -0,0 +1,177 @@
|
||||
|
||||
*alternate.txt* Alternate Plugin Sat May 13 15:35:38 CDT 2006
|
||||
|
||||
Author: Michael Sharpe <feline@irendi.com>
|
||||
Copyright: (c) 2000-2006 Michael Sharpe
|
||||
We grant permission to use, copy modify, distribute, and sell this
|
||||
software for any purpose without fee, provided that the above
|
||||
copyright notice and this text are not removed. We make no guarantee
|
||||
about the suitability of this software for any purpose and we are
|
||||
not liable for any damages resulting from its use. Further, we are
|
||||
under no obligation to maintain or extend this software. It is
|
||||
provided on an "as is" basis without any expressed or implied
|
||||
warranty.
|
||||
|
||||
==============================================================================
|
||||
1. Contents *AS* *AV* *AT* *AN* *IH* *IHS* *IHV* *IHT* *IHN* *alternate*
|
||||
|
||||
1. Contents...........................: |alternate|
|
||||
2. Purpose............................: |alternate-purpose|
|
||||
3. Commands...........................: |alternate-commands|
|
||||
4. Configuration......................: |alternate-config|
|
||||
5. Installation.......................: |alternate-installation|
|
||||
6. Bugs/Enhancements..................: |alternate-support|
|
||||
7. Acknowledgments....................: |alternate-acknowledgments|
|
||||
|
||||
==============================================================================
|
||||
2. Purpose *alternate-purpose*
|
||||
|
||||
The purpose of a.vim is to allow quick and easy switching between source files
|
||||
and corresponding header files. Many languages (C, C++, ada, ocaml, lex/yacc)
|
||||
have the concept of source/header files or the like. It is quite common during
|
||||
development or review to need to edit both files together. This plugin attempts
|
||||
to simplify that process. There are commands which while editing a source
|
||||
file allow for the quick switching to the corresponding header and vice versa.
|
||||
The only difference between the commands is how the switch occurs. More recent
|
||||
functionality allow the switching to a file under the cursor too. In the
|
||||
following sections the commands, configuration and installation procedures are
|
||||
described.
|
||||
|
||||
==============================================================================
|
||||
3. Commands *alternate-commands*
|
||||
|
||||
There are 4 commands provided by this plugin. They are
|
||||
|
||||
:A switches to the header file corresponding to the source file in the current
|
||||
buffer (or vice versa).
|
||||
|
||||
:AS similar to :A except the current buffer is split horizontally such that the
|
||||
source file is on one split and the header is in the other.
|
||||
|
||||
:AV similar to :AS except that the split is vertical
|
||||
|
||||
:AT similar to :AS and :AV except a new tab is opened instead of a split
|
||||
|
||||
:IH switches to the file under cursor (or the file specified with the
|
||||
command). This command uses the builtin a.vim search path support and the
|
||||
&path variable in conjunction.
|
||||
|
||||
:IHS similar to :IH execpt the current buffer is split horizontally first
|
||||
|
||||
:IHS similar to :IH execpt the current buffer is split vertically first
|
||||
|
||||
:IHS similar to :IH execpt a new tab is created for the file being switched to
|
||||
|
||||
:IHN switches to the next matching file for the original selection
|
||||
|
||||
In all cases if the corresponding alternate file is already loaded that buffer
|
||||
is preferred. That is this plugin will never load the same file twice.
|
||||
|
||||
Some maps are also provided for the IH command (mainly for example purposes)
|
||||
<Leader>ih - switches to the file under the cursor using the :IHS command
|
||||
<Leader>is - switches to the source file of the header file under the cursor
|
||||
using the :IHS command and the :A command
|
||||
<leader>ihn - switches to the next match in the sequence.
|
||||
|
||||
==============================================================================
|
||||
4. Configuration *alternate-config*
|
||||
|
||||
It is possible to configure three separate pieces of behaviour of this plugin.
|
||||
|
||||
a) Extensions: Each language has different extensions for identifying the
|
||||
source and header files. Many languages support multiple different but related
|
||||
extensions. As such this plugin allow for the complete specification of how
|
||||
source and header files correspond to each other via extension maps. There are
|
||||
a number of maps built in. For example, the following variable setting
|
||||
|
||||
g:alternateExtensions_CPP = "inc,h,H,HPP,hpp"
|
||||
|
||||
indicates that any file with a .CPP exetension can have a corresponding file
|
||||
with any of the .inc, .h, .H, .HPP, .hpp extension. The inverse is not
|
||||
specified by this map though. Typically each extension will have a mapping. So
|
||||
there would exist maps for .h, .inc, .H, .HPP, .hpp too. Extension maps should
|
||||
be specified before loading this plugin. Some of the builtin extension maps are
|
||||
as follows,
|
||||
|
||||
C and C++
|
||||
g:alternateExtensions_h = "c,cpp,cxx,cc,CC"
|
||||
g:alternateExtensions_H' = "C,CPP,CXX,CC"
|
||||
g:alternateExtensions_cpp' = "h,hpp"
|
||||
g:alternateExtensions_CPP' = "H,HPP"
|
||||
g:alternateExtensions_c' = "h"
|
||||
g:alternateExtensions_C' = "H"
|
||||
g:alternateExtensions_cxx' = "h"
|
||||
|
||||
Ada
|
||||
g:alternateExtensions_adb' = "ads"
|
||||
g:alternateExtensions_ads' = "adb"
|
||||
|
||||
Lex/Yacc
|
||||
g:alternateExtensions_l' = "y,yacc,ypp"
|
||||
g:alternateExtensions_lex' = "yacc,y,ypp"
|
||||
g:alternateExtensions_lpp' = "ypp,y,yacc"
|
||||
g:alternateExtensions_y' = "l,lex,lpp"
|
||||
g:alternateExtensions_yacc' = "lex,l,lpp"
|
||||
g:alternateExtensions_ypp' = "lpp,l,lex"
|
||||
|
||||
b) Search Paths: In many projects the location of the source files and the
|
||||
corresponding header files is not always the same directory. This plugin allows
|
||||
the search path it uses to locate source and header files to be configured.
|
||||
The search path is specified by setting the g:alternateSearchPath variable. The
|
||||
default setting is as follows,
|
||||
|
||||
g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,sfr:../inc'
|
||||
|
||||
This indicates that the corresponding file will be searched for in ../source,
|
||||
../src. ../include and ../inc all relative to the current file being switched
|
||||
from. The value of the g:alternateSearchPath variable is simply a comma
|
||||
separated list of prefixes and directories. The "sfr:" prefix indicates that
|
||||
the path is relative to the file. Other prefixes are "wdr:" which indicates
|
||||
that the directory is relative to the current working directory and "abs:"
|
||||
which indicates the path is absolute. If no prefix is specified "sfr:" is
|
||||
assumed.
|
||||
|
||||
c) Regex Paths: Another type of prefix which can appear in the
|
||||
g:alternateSearchPath variable is that of "reg:". It is used to apply a regex
|
||||
to the path of the file in the buffer being switched from to locate the
|
||||
alternate file. E.g. 'reg:/inc/src/g/' will replace every instance of 'inc'
|
||||
with 'src' in the source file path. It is possible to use match variables so
|
||||
you could do something like: 'reg:|src/\([^/]*\)|inc/\1||' (see |substitute|,
|
||||
|help pattern| and |sub-replace-special| for more details. The exact syntax of
|
||||
a "reg:" specification is
|
||||
reg:<sep><pattern><sep><subst><sep><flag><sep>
|
||||
|
||||
<sep> seperator character, we often use one of [/|%#]
|
||||
<pattern> is what you are looking for
|
||||
<subst> is the output pattern
|
||||
<flag> can be g for global replace or empty
|
||||
|
||||
d) No Alternate Behaviour: When attempting to alternate/switch from a
|
||||
source/header to its corresponding file it is possible that the corresponding
|
||||
file does not exist. In this case this plugin will create the missing alternate
|
||||
file in the same directory as the current file. Some users find this behaviour
|
||||
irritating. This behaviour can be disabled by setting
|
||||
g:alternateNoDefaultAlternate to 1. When this variable is not 0 a message will
|
||||
be displayed indicating that no alternate file exists.
|
||||
|
||||
==============================================================================
|
||||
5. Installation *alternate-installation*
|
||||
|
||||
To install this plugin simply drop the a.vim file in to $VIMRUNTIME/plugin
|
||||
(global or local) or simply source the file from the vimrc file. Ensure that
|
||||
any configuration occurs before the plugin is loaded/sourced.
|
||||
|
||||
==============================================================================
|
||||
6. Bugs/Enhancements *alternate-support*
|
||||
|
||||
Whilst no formal support is provided for this plugin the author is always happy
|
||||
to receive bug reports and enhancement requests. Please email all such
|
||||
reports/requests to feline@irendi.com.
|
||||
|
||||
==============================================================================
|
||||
7. Acknowledgments *alternate-acknowledgments*
|
||||
|
||||
The author would like to thank everyone who has submitted bug reports and
|
||||
feature enhancement requests in the past. In particular Bindu Wavell provided
|
||||
much of the original code implementing the search path and regex functionality.
|
||||
vim:tw=78:ts=8:ft=help
|
1501
vim/dot_vim/doc/taglist.txt
Normal file
1501
vim/dot_vim/doc/taglist.txt
Normal file
File diff suppressed because it is too large
Load Diff
79
vim/dot_vim/doc/tags
Normal file
79
vim/dot_vim/doc/tags
Normal file
@ -0,0 +1,79 @@
|
||||
'Tlist_Auto_Highlight_Tag' taglist.txt /*'Tlist_Auto_Highlight_Tag'*
|
||||
'Tlist_Auto_Open' taglist.txt /*'Tlist_Auto_Open'*
|
||||
'Tlist_Auto_Update' taglist.txt /*'Tlist_Auto_Update'*
|
||||
'Tlist_Close_On_Select' taglist.txt /*'Tlist_Close_On_Select'*
|
||||
'Tlist_Compact_Format' taglist.txt /*'Tlist_Compact_Format'*
|
||||
'Tlist_Ctags_Cmd' taglist.txt /*'Tlist_Ctags_Cmd'*
|
||||
'Tlist_Display_Prototype' taglist.txt /*'Tlist_Display_Prototype'*
|
||||
'Tlist_Display_Tag_Scope' taglist.txt /*'Tlist_Display_Tag_Scope'*
|
||||
'Tlist_Enable_Fold_Column' taglist.txt /*'Tlist_Enable_Fold_Column'*
|
||||
'Tlist_Exit_OnlyWindow' taglist.txt /*'Tlist_Exit_OnlyWindow'*
|
||||
'Tlist_File_Fold_Auto_Close' taglist.txt /*'Tlist_File_Fold_Auto_Close'*
|
||||
'Tlist_GainFocus_On_ToggleOpen' taglist.txt /*'Tlist_GainFocus_On_ToggleOpen'*
|
||||
'Tlist_Highlight_Tag_On_BufEnter' taglist.txt /*'Tlist_Highlight_Tag_On_BufEnter'*
|
||||
'Tlist_Inc_Winwidth' taglist.txt /*'Tlist_Inc_Winwidth'*
|
||||
'Tlist_Max_Submenu_Items' taglist.txt /*'Tlist_Max_Submenu_Items'*
|
||||
'Tlist_Max_Tag_Length' taglist.txt /*'Tlist_Max_Tag_Length'*
|
||||
'Tlist_Process_File_Always' taglist.txt /*'Tlist_Process_File_Always'*
|
||||
'Tlist_Show_Menu' taglist.txt /*'Tlist_Show_Menu'*
|
||||
'Tlist_Show_One_File' taglist.txt /*'Tlist_Show_One_File'*
|
||||
'Tlist_Sort_Type' taglist.txt /*'Tlist_Sort_Type'*
|
||||
'Tlist_Use_Horiz_Window' taglist.txt /*'Tlist_Use_Horiz_Window'*
|
||||
'Tlist_Use_Right_Window' taglist.txt /*'Tlist_Use_Right_Window'*
|
||||
'Tlist_Use_SingleClick' taglist.txt /*'Tlist_Use_SingleClick'*
|
||||
'Tlist_WinHeight' taglist.txt /*'Tlist_WinHeight'*
|
||||
'Tlist_WinWidth' taglist.txt /*'Tlist_WinWidth'*
|
||||
:TlistAddFiles taglist.txt /*:TlistAddFiles*
|
||||
:TlistAddFilesRecursive taglist.txt /*:TlistAddFilesRecursive*
|
||||
:TlistClose taglist.txt /*:TlistClose*
|
||||
:TlistDebug taglist.txt /*:TlistDebug*
|
||||
:TlistHighlightTag taglist.txt /*:TlistHighlightTag*
|
||||
:TlistLock taglist.txt /*:TlistLock*
|
||||
:TlistMessages taglist.txt /*:TlistMessages*
|
||||
:TlistOpen taglist.txt /*:TlistOpen*
|
||||
:TlistSessionLoad taglist.txt /*:TlistSessionLoad*
|
||||
:TlistSessionSave taglist.txt /*:TlistSessionSave*
|
||||
:TlistShowPrototype taglist.txt /*:TlistShowPrototype*
|
||||
:TlistShowTag taglist.txt /*:TlistShowTag*
|
||||
:TlistToggle taglist.txt /*:TlistToggle*
|
||||
:TlistUndebug taglist.txt /*:TlistUndebug*
|
||||
:TlistUnlock taglist.txt /*:TlistUnlock*
|
||||
:TlistUpdate taglist.txt /*:TlistUpdate*
|
||||
AN alternate.txt /*AN*
|
||||
AS alternate.txt /*AS*
|
||||
AT alternate.txt /*AT*
|
||||
AV alternate.txt /*AV*
|
||||
IH alternate.txt /*IH*
|
||||
IHN alternate.txt /*IHN*
|
||||
IHS alternate.txt /*IHS*
|
||||
IHT alternate.txt /*IHT*
|
||||
IHV alternate.txt /*IHV*
|
||||
Tlist_Get_Tag_Prototype_By_Line() taglist.txt /*Tlist_Get_Tag_Prototype_By_Line()*
|
||||
Tlist_Get_Tagname_By_Line() taglist.txt /*Tlist_Get_Tagname_By_Line()*
|
||||
Tlist_Set_App() taglist.txt /*Tlist_Set_App()*
|
||||
Tlist_Update_File_Tags() taglist.txt /*Tlist_Update_File_Tags()*
|
||||
alternate alternate.txt /*alternate*
|
||||
alternate-acknowledgments alternate.txt /*alternate-acknowledgments*
|
||||
alternate-commands alternate.txt /*alternate-commands*
|
||||
alternate-config alternate.txt /*alternate-config*
|
||||
alternate-installation alternate.txt /*alternate-installation*
|
||||
alternate-purpose alternate.txt /*alternate-purpose*
|
||||
alternate-support alternate.txt /*alternate-support*
|
||||
alternate.txt alternate.txt /*alternate.txt*
|
||||
taglist-commands taglist.txt /*taglist-commands*
|
||||
taglist-debug taglist.txt /*taglist-debug*
|
||||
taglist-extend taglist.txt /*taglist-extend*
|
||||
taglist-faq taglist.txt /*taglist-faq*
|
||||
taglist-functions taglist.txt /*taglist-functions*
|
||||
taglist-install taglist.txt /*taglist-install*
|
||||
taglist-internet taglist.txt /*taglist-internet*
|
||||
taglist-intro taglist.txt /*taglist-intro*
|
||||
taglist-keys taglist.txt /*taglist-keys*
|
||||
taglist-license taglist.txt /*taglist-license*
|
||||
taglist-menu taglist.txt /*taglist-menu*
|
||||
taglist-options taglist.txt /*taglist-options*
|
||||
taglist-requirements taglist.txt /*taglist-requirements*
|
||||
taglist-session taglist.txt /*taglist-session*
|
||||
taglist-todo taglist.txt /*taglist-todo*
|
||||
taglist-using taglist.txt /*taglist-using*
|
||||
taglist.txt taglist.txt /*taglist.txt*
|
254
vim/dot_vim/indent/html.vim
Normal file
254
vim/dot_vim/indent/html.vim
Normal file
@ -0,0 +1,254 @@
|
||||
|
||||
" Description: html indenter
|
||||
" Author: Johannes Zellner <johannes@zellner.org>
|
||||
" Last Change: Mo, 05 Jun 2006 22:32:41 CEST
|
||||
" Restoring 'cpo' and 'ic' added by Bram 2006 May 5
|
||||
" Globals: g:html_indent_tags -- indenting tags
|
||||
" g:html_indent_strict -- inhibit 'O O' elements
|
||||
" g:html_indent_strict_table -- inhibit 'O -' elements
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
"if exists("b:did_indent")
|
||||
"finish
|
||||
"endif
|
||||
"let b:did_indent = 1
|
||||
|
||||
if exists("g:js_indent")
|
||||
so g:js_indent
|
||||
else
|
||||
ru! indent/javascript.vim
|
||||
endif
|
||||
|
||||
echo "Sourcing html indent"
|
||||
|
||||
|
||||
" [-- local settings (must come before aborting the script) --]
|
||||
setlocal indentexpr=HtmlIndentGetter(v:lnum)
|
||||
setlocal indentkeys=o,O,*<Return>,<>>,{,}
|
||||
|
||||
|
||||
if exists('g:html_indent_tags')
|
||||
unlet g:html_indent_tags
|
||||
endif
|
||||
|
||||
" [-- helper function to assemble tag list --]
|
||||
fun! <SID>HtmlIndentPush(tag)
|
||||
if exists('g:html_indent_tags')
|
||||
let g:html_indent_tags = g:html_indent_tags.'\|'.a:tag
|
||||
else
|
||||
let g:html_indent_tags = a:tag
|
||||
endif
|
||||
endfun
|
||||
|
||||
|
||||
" [-- <ELEMENT ? - - ...> --]
|
||||
call <SID>HtmlIndentPush('a')
|
||||
call <SID>HtmlIndentPush('abbr')
|
||||
call <SID>HtmlIndentPush('acronym')
|
||||
call <SID>HtmlIndentPush('address')
|
||||
call <SID>HtmlIndentPush('b')
|
||||
call <SID>HtmlIndentPush('bdo')
|
||||
call <SID>HtmlIndentPush('big')
|
||||
call <SID>HtmlIndentPush('blockquote')
|
||||
call <SID>HtmlIndentPush('button')
|
||||
call <SID>HtmlIndentPush('caption')
|
||||
call <SID>HtmlIndentPush('center')
|
||||
call <SID>HtmlIndentPush('cite')
|
||||
call <SID>HtmlIndentPush('code')
|
||||
call <SID>HtmlIndentPush('colgroup')
|
||||
call <SID>HtmlIndentPush('del')
|
||||
call <SID>HtmlIndentPush('dfn')
|
||||
call <SID>HtmlIndentPush('dir')
|
||||
call <SID>HtmlIndentPush('div')
|
||||
call <SID>HtmlIndentPush('dl')
|
||||
call <SID>HtmlIndentPush('em')
|
||||
call <SID>HtmlIndentPush('fieldset')
|
||||
call <SID>HtmlIndentPush('font')
|
||||
call <SID>HtmlIndentPush('form')
|
||||
call <SID>HtmlIndentPush('frameset')
|
||||
call <SID>HtmlIndentPush('h1')
|
||||
call <SID>HtmlIndentPush('h2')
|
||||
call <SID>HtmlIndentPush('h3')
|
||||
call <SID>HtmlIndentPush('h4')
|
||||
call <SID>HtmlIndentPush('h5')
|
||||
call <SID>HtmlIndentPush('h6')
|
||||
call <SID>HtmlIndentPush('i')
|
||||
call <SID>HtmlIndentPush('iframe')
|
||||
call <SID>HtmlIndentPush('ins')
|
||||
call <SID>HtmlIndentPush('kbd')
|
||||
call <SID>HtmlIndentPush('label')
|
||||
call <SID>HtmlIndentPush('legend')
|
||||
call <SID>HtmlIndentPush('map')
|
||||
call <SID>HtmlIndentPush('menu')
|
||||
call <SID>HtmlIndentPush('noframes')
|
||||
call <SID>HtmlIndentPush('noscript')
|
||||
call <SID>HtmlIndentPush('object')
|
||||
call <SID>HtmlIndentPush('ol')
|
||||
call <SID>HtmlIndentPush('optgroup')
|
||||
" call <SID>HtmlIndentPush('pre')
|
||||
call <SID>HtmlIndentPush('q')
|
||||
call <SID>HtmlIndentPush('s')
|
||||
call <SID>HtmlIndentPush('samp')
|
||||
call <SID>HtmlIndentPush('script')
|
||||
call <SID>HtmlIndentPush('select')
|
||||
call <SID>HtmlIndentPush('small')
|
||||
call <SID>HtmlIndentPush('span')
|
||||
call <SID>HtmlIndentPush('strong')
|
||||
call <SID>HtmlIndentPush('style')
|
||||
call <SID>HtmlIndentPush('sub')
|
||||
call <SID>HtmlIndentPush('sup')
|
||||
call <SID>HtmlIndentPush('table')
|
||||
call <SID>HtmlIndentPush('textarea')
|
||||
call <SID>HtmlIndentPush('title')
|
||||
call <SID>HtmlIndentPush('tt')
|
||||
call <SID>HtmlIndentPush('u')
|
||||
call <SID>HtmlIndentPush('ul')
|
||||
call <SID>HtmlIndentPush('var')
|
||||
|
||||
|
||||
" [-- <ELEMENT ? O O ...> --]
|
||||
if !exists('g:html_indent_strict')
|
||||
call <SID>HtmlIndentPush('body')
|
||||
call <SID>HtmlIndentPush('head')
|
||||
call <SID>HtmlIndentPush('html')
|
||||
call <SID>HtmlIndentPush('tbody')
|
||||
endif
|
||||
|
||||
|
||||
" [-- <ELEMENT ? O - ...> --]
|
||||
if !exists('g:html_indent_strict_table')
|
||||
call <SID>HtmlIndentPush('th')
|
||||
call <SID>HtmlIndentPush('td')
|
||||
call <SID>HtmlIndentPush('tr')
|
||||
call <SID>HtmlIndentPush('tfoot')
|
||||
call <SID>HtmlIndentPush('thead')
|
||||
endif
|
||||
|
||||
delfun <SID>HtmlIndentPush
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo-=C
|
||||
|
||||
" [-- count indent-increasing tags of line a:lnum --]
|
||||
fun! <SID>HtmlIndentOpen(lnum, pattern)
|
||||
let s = substitute('x'.getline(a:lnum),
|
||||
\ '.\{-}\(\(<\)\('.a:pattern.'\)\>\)', "\1", 'g')
|
||||
let s = substitute(s, "[^\1].*$", '', '')
|
||||
return strlen(s)
|
||||
endfun
|
||||
|
||||
" [-- count indent-decreasing tags of line a:lnum --]
|
||||
fun! <SID>HtmlIndentClose(lnum, pattern)
|
||||
let s = substitute('x'.getline(a:lnum),
|
||||
\ '.\{-}\(\(<\)/\('.a:pattern.'\)\>>\)', "\1", 'g')
|
||||
let s = substitute(s, "[^\1].*$", '', '')
|
||||
return strlen(s)
|
||||
endfun
|
||||
|
||||
" [-- count indent-increasing '{' of (java|css) line a:lnum --]
|
||||
fun! <SID>HtmlIndentOpenAlt(lnum)
|
||||
return strlen(substitute(getline(a:lnum), '[^{]\+', '', 'g'))
|
||||
endfun
|
||||
|
||||
" [-- count indent-decreasing '}' of (java|css) line a:lnum --]
|
||||
fun! <SID>HtmlIndentCloseAlt(lnum)
|
||||
return strlen(substitute(getline(a:lnum), '[^}]\+', '', 'g'))
|
||||
endfun
|
||||
|
||||
" [-- return the sum of indents respecting the syntax of a:lnum --]
|
||||
fun! <SID>HtmlIndentSum(lnum, style)
|
||||
if a:style == match(getline(a:lnum), '^\s*</')
|
||||
if a:style == match(getline(a:lnum), '^\s*</\<\('.g:html_indent_tags.'\)\>')
|
||||
let open = <SID>HtmlIndentOpen(a:lnum, g:html_indent_tags)
|
||||
let close = <SID>HtmlIndentClose(a:lnum, g:html_indent_tags)
|
||||
if 0 != open || 0 != close
|
||||
return open - close
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if '' != &syntax &&
|
||||
\ synIDattr(synID(a:lnum, 1, 1), 'name') =~ '\(css\|java\).*' &&
|
||||
\ synIDattr(synID(a:lnum, strlen(getline(a:lnum)), 1), 'name')
|
||||
\ =~ '\(css\|java\).*'
|
||||
if a:style == match(getline(a:lnum), '^\s*}')
|
||||
return <SID>HtmlIndentOpenAlt(a:lnum) - <SID>HtmlIndentCloseAlt(a:lnum)
|
||||
endif
|
||||
endif
|
||||
return 0
|
||||
endfun
|
||||
|
||||
fun! HtmlIndentGetter(lnum)
|
||||
|
||||
echo "Grabbing html indent for line: " . a:lnum
|
||||
" Find a non-empty line above the current line.
|
||||
let lnum = prevnonblank(a:lnum - 1)
|
||||
|
||||
" Hit the start of the file, use zero indent.
|
||||
if lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let restore_ic = &ic
|
||||
setlocal ic " ignore case
|
||||
|
||||
" [-- special handling for <pre>: no indenting --]
|
||||
if getline(a:lnum) =~ '\c</pre>'
|
||||
\ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nWb')
|
||||
\ || 0 < searchpair('\c<pre>', '', '\c</pre>', 'nW')
|
||||
" we're in a line with </pre> or inside <pre> ... </pre>
|
||||
if restore_ic == 0
|
||||
setlocal noic
|
||||
endif
|
||||
return -1
|
||||
endif
|
||||
|
||||
" [-- special handling for <javascript>: use cindent --]
|
||||
let js = '<script.*type\s*=.*javascript'
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" by Tye Zdrojewski <zdro@yahoo.com>, 05 Jun 2006
|
||||
" ZDR: This needs to be an AND (we are 'after the start of the pair' AND
|
||||
" we are 'before the end of the pair'). Otherwise, indentation
|
||||
" before the start of the script block will be affected; the end of
|
||||
" the pair will still match if we are before the beginning of the
|
||||
" pair.
|
||||
"
|
||||
if 0 < searchpair(js, '', '</script>', 'nWb')
|
||||
\ && 0 < searchpair(js, '', '</script>', 'nW')
|
||||
" we're inside javascript
|
||||
|
||||
if getline(lnum) !~ js && getline(a:lnum) !~ '</script>'
|
||||
if restore_ic == 0
|
||||
setlocal noic
|
||||
endif
|
||||
return GetJsIndent(a:lnum)
|
||||
endif
|
||||
endif
|
||||
|
||||
if getline(lnum) =~ '\c</pre>'
|
||||
" line before the current line a:lnum contains
|
||||
" a closing </pre>. --> search for line before
|
||||
" starting <pre> to restore the indent.
|
||||
let preline = prevnonblank(search('\c<pre>', 'bW') - 1)
|
||||
if preline > 0
|
||||
if restore_ic == 0
|
||||
setlocal noic
|
||||
endif
|
||||
return indent(preline)
|
||||
endif
|
||||
endif
|
||||
|
||||
let ind = <SID>HtmlIndentSum(lnum, -1)
|
||||
let ind = ind + <SID>HtmlIndentSum(a:lnum, 0)
|
||||
|
||||
if restore_ic == 0
|
||||
setlocal noic
|
||||
endif
|
||||
|
||||
return indent(lnum) + (&sw * ind)
|
||||
endfun
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
||||
" [-- EOF <runtime>/indent/html.vim --]
|
407
vim/dot_vim/indent/javascript.vim
Normal file
407
vim/dot_vim/indent/javascript.vim
Normal file
@ -0,0 +1,407 @@
|
||||
" Vim indent file Language: JavaScript
|
||||
" Author: Preston Koprivica (pkopriv2@gmail.com)
|
||||
" URL:
|
||||
" Last Change: April 30, 2010
|
||||
|
||||
" 0. Standard Stuff
|
||||
" =================
|
||||
|
||||
" Only load one indent script per buffer
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:did_indent = 1
|
||||
|
||||
" Set the global log variable 1 = logging enabled, 0 = logging disabled
|
||||
if !exists("g:js_indent_log")
|
||||
let g:js_indent_log = 0
|
||||
endif
|
||||
|
||||
setlocal indentexpr=GetJsIndent(v:lnum)
|
||||
setlocal indentkeys=
|
||||
|
||||
|
||||
setlocal cindent
|
||||
setlocal autoindent
|
||||
|
||||
|
||||
" 1. Variables
|
||||
" ============
|
||||
|
||||
" Inline comments (for anchoring other statements)
|
||||
let s:js_mid_line_comment = '\s*\(\/\*.*\*\/\)*\s*'
|
||||
let s:js_end_line_comment = s:js_mid_line_comment . '\s*\(//.*\)*'
|
||||
let s:js_line_comment = s:js_end_line_comment
|
||||
|
||||
" Comment/String Syntax Key
|
||||
let s:syn_comment = '\(Comment\|String\|Regexp\)'
|
||||
|
||||
|
||||
" 2. Aux. Functions
|
||||
" =================
|
||||
|
||||
" = Method: IsInComment
|
||||
"
|
||||
" Determines whether the specified position is contained in a comment. "Note:
|
||||
" This depends on a
|
||||
function! s:IsInComment(lnum, cnum)
|
||||
return synIDattr(synID(a:lnum, a:cnum, 1), 'name') =~? s:syn_comment
|
||||
endfunction
|
||||
|
||||
|
||||
" = Method: IsComment
|
||||
"
|
||||
" Determines whether a line is a comment or not.
|
||||
function! s:IsComment(lnum)
|
||||
let line = getline(a:lnum)
|
||||
|
||||
return s:IsInComment(a:lnum, 1) && s:IsInComment(a:lnum, strlen(line)) "Doesn't absolutely work. Only Probably!
|
||||
endfunction
|
||||
|
||||
|
||||
" = Method: GetNonCommentLine
|
||||
"
|
||||
" Grabs the nearest non-commented line
|
||||
function! s:GetNonCommentLine(lnum)
|
||||
let lnum = prevnonblank(a:lnum)
|
||||
|
||||
while lnum > 0
|
||||
if s:IsComment(lnum)
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
else
|
||||
return lnum
|
||||
endif
|
||||
endwhile
|
||||
|
||||
return lnum
|
||||
endfunction
|
||||
|
||||
" = Method: SearchForPair
|
||||
"
|
||||
" Returns the beginning tag of a given pair starting from the given line.
|
||||
function! s:SearchForPair(lnum, beg, end)
|
||||
" Save the cursor position.
|
||||
let curpos = getpos(".")
|
||||
|
||||
" Set the cursor position to the beginning of the line (default
|
||||
" behavior when using ==)
|
||||
call cursor(a:lnum, 0)
|
||||
|
||||
" Search for the opening tag
|
||||
let mnum = searchpair(a:beg, '', a:end, 'bW',
|
||||
\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? s:syn_comment' )
|
||||
|
||||
"Restore the cursor position
|
||||
call cursor(curpos)
|
||||
|
||||
" Finally, return the matched line number
|
||||
return mnum
|
||||
endfunction
|
||||
|
||||
|
||||
" Object Helpers
|
||||
" ==============
|
||||
let s:object_beg = '{[^}]*' . s:js_end_line_comment . '$'
|
||||
let s:object_end = '^' . s:js_mid_line_comment . '}[;,]\='
|
||||
|
||||
|
||||
function! s:IsObjectBeg(line)
|
||||
return a:line =~ s:object_beg
|
||||
endfunction
|
||||
|
||||
function! s:IsObjectEnd(line)
|
||||
return a:line =~ s:object_end
|
||||
endfunction
|
||||
|
||||
function! s:GetObjectBeg(lnum)
|
||||
return s:SearchForPair(a:lnum, '{', '}')
|
||||
endfunction
|
||||
|
||||
|
||||
" Array Helpers
|
||||
" ==============
|
||||
let s:array_beg = '\[[^\]]*' . s:js_end_line_comment . '$'
|
||||
let s:array_end = '^' . s:js_mid_line_comment . '[^\[]*\][;,]*' . s:js_end_line_comment . '$'
|
||||
|
||||
|
||||
function! s:IsArrayBeg(line)
|
||||
return a:line =~ s:array_beg
|
||||
endfunction
|
||||
|
||||
function! s:IsArrayEnd(line)
|
||||
return a:line =~ s:array_end
|
||||
endfunction
|
||||
|
||||
function! s:GetArrayBeg(lnum)
|
||||
return s:SearchForPair(a:lnum, '\[', '\]')
|
||||
endfunction
|
||||
|
||||
|
||||
" MultiLine Declaration/Invocation Helpers
|
||||
" ========================================
|
||||
let s:paren_beg = '([^)]*' . s:js_end_line_comment . '$'
|
||||
let s:paren_end = '^' . s:js_mid_line_comment . '[^(]*)[;,]*'
|
||||
|
||||
function! s:IsParenBeg(line)
|
||||
return a:line =~ s:paren_beg
|
||||
endfunction
|
||||
|
||||
function! s:IsParenEnd(line)
|
||||
return a:line =~ s:paren_end
|
||||
endfunction
|
||||
|
||||
function! s:GetParenBeg(lnum)
|
||||
return s:SearchForPair(a:lnum, '(', ')')
|
||||
endfunction
|
||||
|
||||
|
||||
|
||||
" Continuation Helpers
|
||||
" ====================
|
||||
let s:continuation = '\(+\|\\\)\{1}' . s:js_line_comment . '$'
|
||||
|
||||
function! s:IsContinuationLine(line)
|
||||
return a:line =~ s:continuation
|
||||
endfunction
|
||||
|
||||
function! s:GetContinuationBegin(lnum)
|
||||
let cur = a:lnum
|
||||
|
||||
while s:IsContinuationLine(getline(cur))
|
||||
let cur -= 1
|
||||
endwhile
|
||||
|
||||
return cur + 1
|
||||
endfunction
|
||||
|
||||
|
||||
" Switch Helpers
|
||||
" ==============
|
||||
let s:switch_beg_next_line = 'switch\s*(.*)\s*' . s:js_mid_line_comment . s:js_end_line_comment . '$'
|
||||
let s:switch_beg_same_line = 'switch\s*(.*)\s*' . s:js_mid_line_comment . '{\s*' . s:js_line_comment . '$'
|
||||
let s:switch_mid = '^.*\(case.*\|default\)\s*:\s*'
|
||||
|
||||
function! s:IsSwitchBeginNextLine(line)
|
||||
return a:line =~ s:switch_beg_next_line
|
||||
endfunction
|
||||
|
||||
function! s:IsSwitchBeginSameLine(line)
|
||||
return a:line =~ s:switch_beg_same_line
|
||||
endfunction
|
||||
|
||||
function! s:IsSwitchMid(line)
|
||||
return a:line =~ s:switch_mid
|
||||
endfunction
|
||||
|
||||
|
||||
" Control Helpers
|
||||
" ===============
|
||||
let s:cntrl_beg_keys = '\(\(\(if\|for\|with\|while\)\s*(.*)\)\|\(try\|do\)\)\s*'
|
||||
let s:cntrl_mid_keys = '\(\(\(else\s*if\|catch\)\s*(.*)\)\|\(finally\|else\)\)\s*'
|
||||
|
||||
let s:cntrl_beg = s:cntrl_beg_keys . s:js_end_line_comment . '$'
|
||||
let s:cntrl_mid = s:cntrl_mid_keys . s:js_end_line_comment . '$'
|
||||
|
||||
let s:cntrl_end = '\(while\s*(.*)\)\s*;\=\s*' . s:js_end_line_comment . '$'
|
||||
|
||||
function! s:IsControlBeg(line)
|
||||
return a:line =~ s:cntrl_beg
|
||||
endfunction
|
||||
|
||||
function! s:IsControlMid(line)
|
||||
return a:line =~ s:cntrl_mid
|
||||
endfunction
|
||||
|
||||
function! s:IsControlMidStrict(line)
|
||||
return a:line =~ s:cntrl_mid
|
||||
endfunction
|
||||
|
||||
function! s:IsControlEnd(line)
|
||||
return a:line =~ s:cntrl_end
|
||||
endfunction
|
||||
|
||||
" = Method: Log
|
||||
"
|
||||
" Logs a message to the stdout.
|
||||
function! s:Log(msg)
|
||||
if g:js_indent_log
|
||||
echo "LOG: " . a:msg
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
" 3. Indenter
|
||||
" ===========
|
||||
function! GetJsIndent(lnum)
|
||||
" Grab the first non-comment line prior to this line
|
||||
let pnum = s:GetNonCommentLine(a:lnum-1)
|
||||
|
||||
" First line, start at indent = 0
|
||||
if pnum == 0
|
||||
call s:Log("No, noncomment lines prior to the current line.")
|
||||
return 0
|
||||
endif
|
||||
|
||||
" Grab the second non-comment line prior to this line
|
||||
let ppnum = s:GetNonCommentLine(pnum-1)
|
||||
|
||||
call s:Log("Line: " . a:lnum)
|
||||
call s:Log("PLine: " . pnum)
|
||||
call s:Log("PPLine: " . ppnum)
|
||||
|
||||
" Grab the lines themselves.
|
||||
let line = getline(a:lnum)
|
||||
let pline = getline(pnum)
|
||||
let ppline = getline(ppnum)
|
||||
|
||||
" Determine the current level of indentation
|
||||
let ind = indent(pnum)
|
||||
|
||||
|
||||
" Handle: Object Closers (ie })
|
||||
" =============================
|
||||
if s:IsObjectEnd(line) && !s:IsComment(a:lnum)
|
||||
call s:Log("Line matched object end")
|
||||
|
||||
let obeg = s:GetObjectBeg(a:lnum)
|
||||
let oind = indent(obeg)
|
||||
let oline = getline(obeg)
|
||||
|
||||
call s:Log("The object beg was found at: " . obeg)
|
||||
return oind
|
||||
endif
|
||||
|
||||
if s:IsObjectBeg(pline)
|
||||
call s:Log("Pline matched object beg")
|
||||
return ind + &sw
|
||||
endif
|
||||
|
||||
|
||||
" Handle: Array Closer (ie ])
|
||||
" ============================
|
||||
if s:IsArrayEnd(line) && !s:IsComment(a:lnum)
|
||||
call s:Log("Line matched array end")
|
||||
|
||||
let abeg = s:GetArrayBeg(a:lnum)
|
||||
let aind = indent(abeg)
|
||||
|
||||
call s:Log("The array beg was found at: " . abeg)
|
||||
return aind
|
||||
endif
|
||||
|
||||
if s:IsArrayBeg(pline)
|
||||
call s:Log("Pline matched array beg")
|
||||
return ind + &sw
|
||||
endif
|
||||
|
||||
" Handle: Parens
|
||||
" ==============
|
||||
if s:IsParenEnd(line) && !s:IsComment(a:lnum)
|
||||
call s:Log("Line matched paren end")
|
||||
|
||||
let abeg = s:GetParenBeg(a:lnum)
|
||||
let aind = indent(abeg)
|
||||
|
||||
call s:Log("The paren beg was found at: " . abeg)
|
||||
return aind
|
||||
endif
|
||||
|
||||
if s:IsParenBeg(pline)
|
||||
call s:Log("Pline matched paren beg")
|
||||
return ind + &sw
|
||||
endif
|
||||
|
||||
|
||||
" Handle: Continuation Lines.
|
||||
" ========================================================
|
||||
if s:IsContinuationLine(pline)
|
||||
call s:Log('Pline is a continuation line.')
|
||||
|
||||
let cbeg = s:GetContinuationBegin(pnum)
|
||||
let cind = indent(cbeg)
|
||||
|
||||
call s:Log('The continuation block begin found at: ' . cbeg)
|
||||
return cind + &sw
|
||||
endif
|
||||
|
||||
if s:IsContinuationLine(ppline)
|
||||
call s:Log('PPline was a continuation line but pline wasnt.')
|
||||
return ind - &sw
|
||||
endif
|
||||
|
||||
" Handle: Switch Control Blocks
|
||||
" =============================
|
||||
if s:IsSwitchMid(pline)
|
||||
call s:Log("PLine matched switch cntrl mid")
|
||||
if s:IsSwitchMid(line) || s:IsObjectEnd(line)
|
||||
call s:Log("Line matched a cntrl mid")
|
||||
return ind
|
||||
else
|
||||
call s:Log("Line didnt match a cntrl mid")
|
||||
return ind + &sw
|
||||
endif
|
||||
endif
|
||||
|
||||
if s:IsSwitchMid(line)
|
||||
call s:Log("Line matched switch cntrl mid")
|
||||
return ind - &sw
|
||||
endif
|
||||
|
||||
|
||||
" Handle: Single Line Control Blocks
|
||||
" ==================================
|
||||
if s:IsControlBeg(pline)
|
||||
call s:Log("Pline matched control beginning")
|
||||
|
||||
if s:IsControlMid(line)
|
||||
call s:Log("Line matched a control mid")
|
||||
return ind
|
||||
elseif line =~ '^\s*{\s*$'
|
||||
call s:Log("Line matched an object beg")
|
||||
return ind
|
||||
else
|
||||
return ind + &sw
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
if s:IsControlMid(pline)
|
||||
call s:Log("Pline matched a control mid")
|
||||
|
||||
if s:IsControlMid(line)
|
||||
call s:Log("Line matched a control mid")
|
||||
return ind
|
||||
elseif s:IsObjectBeg(line)
|
||||
call s:Log("Line matched an object beg")
|
||||
return ind
|
||||
else
|
||||
call s:Log("Line didn't match a control mid or object beg."
|
||||
return ind + &sw
|
||||
endif
|
||||
endif
|
||||
|
||||
if s:IsControlMid(line)
|
||||
call s:Log("Line matched a control mid.")
|
||||
|
||||
if s:IsControlEnd(pline) || s:IsObjectEnd(pline)
|
||||
call s:Log("PLine matched control end")
|
||||
return ind
|
||||
else
|
||||
call s:Log("Pline didn't match object end")
|
||||
return ind - &sw
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
if ( s:IsControlBeg(ppline) || s:IsControlMid(ppline) ) &&
|
||||
\ !s:IsObjectBeg(pline) && !s:IsObjectEnd(pline)
|
||||
call s:Log("PPLine matched single line control beg or mid")
|
||||
return ind - &sw
|
||||
endif
|
||||
|
||||
" Handle: No matches
|
||||
" ==================
|
||||
"call s:Log("Line didn't match anything. Retaining indent")
|
||||
return ind
|
||||
endfunction
|
840
vim/dot_vim/plugin/a.vim
Normal file
840
vim/dot_vim/plugin/a.vim
Normal file
@ -0,0 +1,840 @@
|
||||
" Copyright (c) 1998-2006
|
||||
" Michael Sharpe <feline@irendi.com>
|
||||
"
|
||||
" We grant permission to use, copy modify, distribute, and sell this
|
||||
" software for any purpose without fee, provided that the above copyright
|
||||
" notice and this text are not removed. We make no guarantee about the
|
||||
" suitability of this software for any purpose and we are not liable
|
||||
" for any damages resulting from its use. Further, we are under no
|
||||
" obligation to maintain or extend this software. It is provided on an
|
||||
" "as is" basis without any expressed or implied warranty.
|
||||
|
||||
" Directory & regex enhancements added by Bindu Wavell who is well known on
|
||||
" vim.sf.net
|
||||
"
|
||||
" Patch for spaces in files/directories from Nathan Stien (also reported by
|
||||
" Soeren Sonnenburg)
|
||||
|
||||
" Do not load a.vim if is has already been loaded.
|
||||
if exists("loaded_alternateFile")
|
||||
finish
|
||||
endif
|
||||
if (v:progname == "ex")
|
||||
finish
|
||||
endif
|
||||
let loaded_alternateFile = 1
|
||||
|
||||
let alternateExtensionsDict = {}
|
||||
|
||||
" setup the default set of alternate extensions. The user can override in thier
|
||||
" .vimrc if the defaults are not suitable. To override in a .vimrc simply set a
|
||||
" g:alternateExtensions_<EXT> variable to a comma separated list of alternates,
|
||||
" where <EXT> is the extension to map.
|
||||
" E.g. let g:alternateExtensions_CPP = "inc,h,H,HPP,hpp"
|
||||
" let g:alternateExtensions_{'aspx.cs'} = "aspx"
|
||||
|
||||
|
||||
" This variable will be increased when an extension with greater number of dots
|
||||
" is added by the AddAlternateExtensionMapping call.
|
||||
let s:maxDotsInExtension = 1
|
||||
|
||||
" Function : AddAlternateExtensionMapping (PRIVATE)
|
||||
" Purpose : simple helper function to add the default alternate extension
|
||||
" mappings.
|
||||
" Args : extension -- the extension to map
|
||||
" alternates -- comma separated list of alternates extensions
|
||||
" Returns : nothing
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
function! <SID>AddAlternateExtensionMapping(extension, alternates)
|
||||
" This code does not actually work for variables like foo{'a.b.c.d.e'}
|
||||
"let varName = "g:alternateExtensions_" . a:extension
|
||||
"if (!exists(varName))
|
||||
" let g:alternateExtensions_{a:extension} = a:alternates
|
||||
"endif
|
||||
|
||||
" This code handles extensions which contains a dot. exists() fails with
|
||||
" such names.
|
||||
"let v:errmsg = ""
|
||||
" FIXME this line causes ex to return 1 instead of 0 for some reason??
|
||||
"silent! echo g:alternateExtensions_{a:extension}
|
||||
"if (v:errmsg != "")
|
||||
"let g:alternateExtensions_{a:extension} = a:alternates
|
||||
"endif
|
||||
|
||||
let g:alternateExtensionsDict[a:extension] = a:alternates
|
||||
let dotsNumber = strlen(substitute(a:extension, "[^.]", "", "g"))
|
||||
if s:maxDotsInExtension < dotsNumber
|
||||
let s:maxDotsInExtension = dotsNumber
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
" Add all the default extensions
|
||||
" Mappings for C and C++
|
||||
call <SID>AddAlternateExtensionMapping('h',"c,cpp,cxx,cc,CC")
|
||||
call <SID>AddAlternateExtensionMapping('H',"C,CPP,CXX,CC")
|
||||
call <SID>AddAlternateExtensionMapping('hpp',"cpp,c")
|
||||
call <SID>AddAlternateExtensionMapping('HPP',"CPP,C")
|
||||
call <SID>AddAlternateExtensionMapping('c',"h")
|
||||
call <SID>AddAlternateExtensionMapping('C',"H")
|
||||
call <SID>AddAlternateExtensionMapping('cpp',"h,hpp")
|
||||
call <SID>AddAlternateExtensionMapping('CPP',"H,HPP")
|
||||
call <SID>AddAlternateExtensionMapping('cc',"h")
|
||||
call <SID>AddAlternateExtensionMapping('CC',"H,h")
|
||||
call <SID>AddAlternateExtensionMapping('cxx',"h")
|
||||
call <SID>AddAlternateExtensionMapping('CXX',"H")
|
||||
" Mappings for PSL7
|
||||
call <SID>AddAlternateExtensionMapping('psl',"ph")
|
||||
call <SID>AddAlternateExtensionMapping('ph',"psl")
|
||||
" Mappings for ADA
|
||||
call <SID>AddAlternateExtensionMapping('adb',"ads")
|
||||
call <SID>AddAlternateExtensionMapping('ads',"adb")
|
||||
" Mappings for lex and yacc files
|
||||
call <SID>AddAlternateExtensionMapping('l',"y,yacc,ypp")
|
||||
call <SID>AddAlternateExtensionMapping('lex',"yacc,y,ypp")
|
||||
call <SID>AddAlternateExtensionMapping('lpp',"ypp,y,yacc")
|
||||
call <SID>AddAlternateExtensionMapping('y',"l,lex,lpp")
|
||||
call <SID>AddAlternateExtensionMapping('yacc',"lex,l,lpp")
|
||||
call <SID>AddAlternateExtensionMapping('ypp',"lpp,l,lex")
|
||||
" Mappings for OCaml
|
||||
call <SID>AddAlternateExtensionMapping('ml',"mli")
|
||||
call <SID>AddAlternateExtensionMapping('mli',"ml")
|
||||
" ASP stuff
|
||||
call <SID>AddAlternateExtensionMapping('aspx.cs', 'aspx')
|
||||
call <SID>AddAlternateExtensionMapping('aspx.vb', 'aspx')
|
||||
call <SID>AddAlternateExtensionMapping('aspx', 'aspx.cs,aspx.vb')
|
||||
|
||||
" Setup default search path, unless the user has specified
|
||||
" a path in their [._]vimrc.
|
||||
if (!exists('g:alternateSearchPath'))
|
||||
let g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,sfr:../inc'
|
||||
endif
|
||||
|
||||
" If this variable is true then a.vim will not alternate to a file/buffer which
|
||||
" does not exist. E.g while editing a.c and the :A will not swtich to a.h
|
||||
" unless it exists.
|
||||
if (!exists('g:alternateNoDefaultAlternate'))
|
||||
" by default a.vim will alternate to a file which does not exist
|
||||
let g:alternateNoDefaultAlternate = 0
|
||||
endif
|
||||
|
||||
" If this variable is true then a.vim will convert the alternate filename to a
|
||||
" filename relative to the current working directory.
|
||||
" Feature by Nathan Huizinga
|
||||
if (!exists('g:alternateRelativeFiles'))
|
||||
" by default a.vim will not convert the filename to one relative to the
|
||||
" current working directory
|
||||
let g:alternateRelativeFiles = 0
|
||||
endif
|
||||
|
||||
|
||||
" Function : GetNthItemFromList (PRIVATE)
|
||||
" Purpose : Support reading items from a comma seperated list
|
||||
" Used to iterate all the extensions in an extension spec
|
||||
" Used to iterate all path prefixes
|
||||
" Args : list -- the list (extension spec, file paths) to iterate
|
||||
" n -- the extension to get
|
||||
" Returns : the nth item (extension, path) from the list (extension
|
||||
" spec), or "" for failure
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
" History : Renamed from GetNthExtensionFromSpec to GetNthItemFromList
|
||||
" to reflect a more generic use of this function. -- Bindu
|
||||
function! <SID>GetNthItemFromList(list, n)
|
||||
let itemStart = 0
|
||||
let itemEnd = -1
|
||||
let pos = 0
|
||||
let item = ""
|
||||
let i = 0
|
||||
while (i != a:n)
|
||||
let itemStart = itemEnd + 1
|
||||
let itemEnd = match(a:list, ",", itemStart)
|
||||
let i = i + 1
|
||||
if (itemEnd == -1)
|
||||
if (i == a:n)
|
||||
let itemEnd = strlen(a:list)
|
||||
endif
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
if (itemEnd != -1)
|
||||
let item = strpart(a:list, itemStart, itemEnd - itemStart)
|
||||
endif
|
||||
return item
|
||||
endfunction
|
||||
|
||||
" Function : ExpandAlternatePath (PRIVATE)
|
||||
" Purpose : Expand path info. A path with a prefix of "wdr:" will be
|
||||
" treated as relative to the working directory (i.e. the
|
||||
" directory where vim was started.) A path prefix of "abs:" will
|
||||
" be treated as absolute. No prefix or "sfr:" will result in the
|
||||
" path being treated as relative to the source file (see sfPath
|
||||
" argument).
|
||||
"
|
||||
" A prefix of "reg:" will treat the pathSpec as a regular
|
||||
" expression substitution that is applied to the source file
|
||||
" path. The format is:
|
||||
"
|
||||
" reg:<sep><pattern><sep><subst><sep><flag><sep>
|
||||
"
|
||||
" <sep> seperator character, we often use one of [/|%#]
|
||||
" <pattern> is what you are looking for
|
||||
" <subst> is the output pattern
|
||||
" <flag> can be g for global replace or empty
|
||||
"
|
||||
" EXAMPLE: 'reg:/inc/src/g/' will replace every instance
|
||||
" of 'inc' with 'src' in the source file path. It is possible
|
||||
" to use match variables so you could do something like:
|
||||
" 'reg:|src/\([^/]*\)|inc/\1||' (see 'help :substitute',
|
||||
" 'help pattern' and 'help sub-replace-special' for more details
|
||||
"
|
||||
" NOTE: a.vim uses ',' (comma) internally so DON'T use it
|
||||
" in your regular expressions or other pathSpecs unless you update
|
||||
" the rest of the a.vim code to use some other seperator.
|
||||
"
|
||||
" Args : pathSpec -- path component (or substitution patterns)
|
||||
" sfPath -- source file path
|
||||
" Returns : a path that can be used by AlternateFile()
|
||||
" Author : Bindu Wavell <bindu@wavell.net>
|
||||
function! <SID>ExpandAlternatePath(pathSpec, sfPath)
|
||||
let prfx = strpart(a:pathSpec, 0, 4)
|
||||
if (prfx == "wdr:" || prfx == "abs:")
|
||||
let path = strpart(a:pathSpec, 4)
|
||||
elseif (prfx == "reg:")
|
||||
let re = strpart(a:pathSpec, 4)
|
||||
let sep = strpart(re, 0, 1)
|
||||
let patend = match(re, sep, 1)
|
||||
let pat = strpart(re, 1, patend - 1)
|
||||
let subend = match(re, sep, patend + 1)
|
||||
let sub = strpart(re, patend+1, subend - patend - 1)
|
||||
let flag = strpart(re, strlen(re) - 2)
|
||||
if (flag == sep)
|
||||
let flag = ''
|
||||
endif
|
||||
let path = substitute(a:sfPath, pat, sub, flag)
|
||||
"call confirm('PAT: [' . pat . '] SUB: [' . sub . ']')
|
||||
"call confirm(a:sfPath . ' => ' . path)
|
||||
else
|
||||
let path = a:pathSpec
|
||||
if (prfx == "sfr:")
|
||||
let path = strpart(path, 4)
|
||||
endif
|
||||
let path = a:sfPath . "/" . path
|
||||
endif
|
||||
return path
|
||||
endfunction
|
||||
|
||||
" Function : FindFileInSearchPath (PRIVATE)
|
||||
" Purpose : Searches for a file in the search path list
|
||||
" Args : filename -- name of the file to search for
|
||||
" pathList -- the path list to search
|
||||
" relPathBase -- the path which relative paths are expanded from
|
||||
" Returns : An expanded filename if found, the empty string otherwise
|
||||
" Author : Michael Sharpe (feline@irendi.com)
|
||||
" History : inline code written by Bindu Wavell originally
|
||||
function! <SID>FindFileInSearchPath(fileName, pathList, relPathBase)
|
||||
let filepath = ""
|
||||
let m = 1
|
||||
let pathListLen = strlen(a:pathList)
|
||||
if (pathListLen > 0)
|
||||
while (1)
|
||||
let pathSpec = <SID>GetNthItemFromList(a:pathList, m)
|
||||
if (pathSpec != "")
|
||||
let path = <SID>ExpandAlternatePath(pathSpec, a:relPathBase)
|
||||
let fullname = path . "/" . a:fileName
|
||||
let foundMatch = <SID>BufferOrFileExists(fullname)
|
||||
if (foundMatch)
|
||||
let filepath = fullname
|
||||
break
|
||||
endif
|
||||
else
|
||||
break
|
||||
endif
|
||||
let m = m + 1
|
||||
endwhile
|
||||
endif
|
||||
return filepath
|
||||
endfunction
|
||||
|
||||
" Function : FindFileInSearchPathEx (PRIVATE)
|
||||
" Purpose : Searches for a file in the search path list
|
||||
" Args : filename -- name of the file to search for
|
||||
" pathList -- the path list to search
|
||||
" relPathBase -- the path which relative paths are expanded from
|
||||
" count -- find the count'th occurence of the file on the path
|
||||
" Returns : An expanded filename if found, the empty string otherwise
|
||||
" Author : Michael Sharpe (feline@irendi.com)
|
||||
" History : Based on <SID>FindFileInSearchPath() but with extensions
|
||||
function! <SID>FindFileInSearchPathEx(fileName, pathList, relPathBase, count)
|
||||
let filepath = ""
|
||||
let m = 1
|
||||
let spath = ""
|
||||
let pathListLen = strlen(a:pathList)
|
||||
if (pathListLen > 0)
|
||||
while (1)
|
||||
let pathSpec = <SID>GetNthItemFromList(a:pathList, m)
|
||||
if (pathSpec != "")
|
||||
let path = <SID>ExpandAlternatePath(pathSpec, a:relPathBase)
|
||||
if (spath != "")
|
||||
let spath = spath . ','
|
||||
endif
|
||||
let spath = spath . path
|
||||
else
|
||||
break
|
||||
endif
|
||||
let m = m + 1
|
||||
endwhile
|
||||
endif
|
||||
|
||||
if (&path != "")
|
||||
if (spath != "")
|
||||
let spath = spath . ','
|
||||
endif
|
||||
let spath = spath . &path
|
||||
endif
|
||||
|
||||
let filepath = findfile(a:fileName, spath, a:count)
|
||||
return filepath
|
||||
endfunction
|
||||
|
||||
" Function : EnumerateFilesByExtension (PRIVATE)
|
||||
" Purpose : enumerates all files by a particular list of alternate extensions.
|
||||
" Args : path -- path of a file (not including the file)
|
||||
" baseName -- base name of the file to be expanded
|
||||
" extension -- extension whose alternates are to be enumerated
|
||||
" Returns : comma separated list of files with extensions
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
function! EnumerateFilesByExtension(path, baseName, extension)
|
||||
let enumeration = ""
|
||||
let extSpec = ""
|
||||
let v:errmsg = ""
|
||||
silent! echo g:alternateExtensions_{a:extension}
|
||||
if (v:errmsg == "")
|
||||
let extSpec = g:alternateExtensions_{a:extension}
|
||||
endif
|
||||
if (extSpec == "")
|
||||
if (has_key(g:alternateExtensionsDict, a:extension))
|
||||
let extSpec = g:alternateExtensionsDict[a:extension]
|
||||
endif
|
||||
endif
|
||||
if (extSpec != "")
|
||||
let n = 1
|
||||
let done = 0
|
||||
while (!done)
|
||||
let ext = <SID>GetNthItemFromList(extSpec, n)
|
||||
if (ext != "")
|
||||
if (a:path != "")
|
||||
let newFilename = a:path . "/" . a:baseName . "." . ext
|
||||
else
|
||||
let newFilename = a:baseName . "." . ext
|
||||
endif
|
||||
if (enumeration == "")
|
||||
let enumeration = newFilename
|
||||
else
|
||||
let enumeration = enumeration . "," . newFilename
|
||||
endif
|
||||
else
|
||||
let done = 1
|
||||
endif
|
||||
let n = n + 1
|
||||
endwhile
|
||||
endif
|
||||
return enumeration
|
||||
endfunction
|
||||
|
||||
" Function : EnumerateFilesByExtensionInPath (PRIVATE)
|
||||
" Purpose : enumerates all files by expanding the path list and the extension
|
||||
" list.
|
||||
" Args : baseName -- base name of the file
|
||||
" extension -- extension whose alternates are to be enumerated
|
||||
" pathList -- the list of paths to enumerate
|
||||
" relPath -- the path of the current file for expansion of relative
|
||||
" paths in the path list.
|
||||
" Returns : A comma separated list of paths with extensions
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
function! EnumerateFilesByExtensionInPath(baseName, extension, pathList, relPathBase)
|
||||
let enumeration = ""
|
||||
let filepath = ""
|
||||
let m = 1
|
||||
let pathListLen = strlen(a:pathList)
|
||||
if (pathListLen > 0)
|
||||
while (1)
|
||||
let pathSpec = <SID>GetNthItemFromList(a:pathList, m)
|
||||
if (pathSpec != "")
|
||||
let path = <SID>ExpandAlternatePath(pathSpec, a:relPathBase)
|
||||
let pe = EnumerateFilesByExtension(path, a:baseName, a:extension)
|
||||
if (enumeration == "")
|
||||
let enumeration = pe
|
||||
else
|
||||
let enumeration = enumeration . "," . pe
|
||||
endif
|
||||
else
|
||||
break
|
||||
endif
|
||||
let m = m + 1
|
||||
endwhile
|
||||
endif
|
||||
return enumeration
|
||||
endfunction
|
||||
|
||||
" Function : DetermineExtension (PRIVATE)
|
||||
" Purpose : Determines the extension of a filename based on the register
|
||||
" alternate extension. This allow extension which contain dots to
|
||||
" be considered. E.g. foo.aspx.cs to foo.aspx where an alternate
|
||||
" exists for the aspx.cs extension. Note that this will only accept
|
||||
" extensions which contain less than 5 dots. This is only
|
||||
" implemented in this manner for simplicity...it is doubtful that
|
||||
" this will be a restriction in non-contrived situations.
|
||||
" Args : The path to the file to find the extension in
|
||||
" Returns : The matched extension if any
|
||||
" Author : Michael Sharpe (feline@irendi.com)
|
||||
" History : idea from Tom-Erik Duestad
|
||||
" Notes : there is some magic occuring here. The exists() function does not
|
||||
" work well when the curly brace variable has dots in it. And why
|
||||
" should it, dots are not valid in variable names. But the exists
|
||||
" function is wierd too. Lets say foo_c does exist. Then
|
||||
" exists("foo_c.e.f") will be true...even though the variable does
|
||||
" not exist. However the curly brace variables do work when the
|
||||
" variable has dots in it. E.g foo_{'c'} is different from
|
||||
" foo_{'c.d.e'}...and foo_{'c'} is identical to foo_c and
|
||||
" foo_{'c.d.e'} is identical to foo_c.d.e right? Yes in the current
|
||||
" implementation of vim. To trick vim to test for existence of such
|
||||
" variables echo the curly brace variable and look for an error
|
||||
" message.
|
||||
function! DetermineExtension(path)
|
||||
let mods = ":t"
|
||||
let i = 0
|
||||
while i <= s:maxDotsInExtension
|
||||
let mods = mods . ":e"
|
||||
let extension = fnamemodify(a:path, mods)
|
||||
if (has_key(g:alternateExtensionsDict, extension))
|
||||
return extension
|
||||
endif
|
||||
let v:errmsg = ""
|
||||
silent! echo g:alternateExtensions_{extension}
|
||||
if (v:errmsg == "")
|
||||
return extension
|
||||
endif
|
||||
let i = i + 1
|
||||
endwhile
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
" Function : AlternateFile (PUBLIC)
|
||||
" Purpose : Opens a new buffer by looking at the extension of the current
|
||||
" buffer and finding the corresponding file. E.g. foo.c <--> foo.h
|
||||
" Args : accepts one argument. If present it used the argument as the new
|
||||
" extension.
|
||||
" Returns : nothing
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
" History : + When an alternate can't be found in the same directory as the
|
||||
" source file, a search path will be traversed looking for the
|
||||
" alternates.
|
||||
" + Moved some code into a separate function, minor optimization
|
||||
" + rework to favor files in memory based on complete enumeration of
|
||||
" all files extensions and paths
|
||||
function! AlternateFile(splitWindow, ...)
|
||||
let extension = DetermineExtension(expand("%:p"))
|
||||
let baseName = substitute(expand("%:t"), "\." . extension . '$', "", "")
|
||||
let currentPath = expand("%:p:h")
|
||||
|
||||
if (a:0 != 0)
|
||||
let newFullname = currentPath . "/" . baseName . "." . a:1
|
||||
call <SID>FindOrCreateBuffer(newFullname, a:splitWindow, 0)
|
||||
else
|
||||
let allfiles = ""
|
||||
if (extension != "")
|
||||
let allfiles1 = EnumerateFilesByExtension(currentPath, baseName, extension)
|
||||
let allfiles2 = EnumerateFilesByExtensionInPath(baseName, extension, g:alternateSearchPath, currentPath)
|
||||
|
||||
if (allfiles1 != "")
|
||||
if (allfiles2 != "")
|
||||
let allfiles = allfiles1 . ',' . allfiles2
|
||||
else
|
||||
let allfiles = allfiles1
|
||||
endif
|
||||
else
|
||||
let allfiles = allfiles2
|
||||
endif
|
||||
endif
|
||||
|
||||
if (allfiles != "")
|
||||
let bestFile = ""
|
||||
let bestScore = 0
|
||||
let score = 0
|
||||
let n = 1
|
||||
|
||||
let onefile = <SID>GetNthItemFromList(allfiles, n)
|
||||
let bestFile = onefile
|
||||
while (onefile != "" && score < 2)
|
||||
let score = <SID>BufferOrFileExists(onefile)
|
||||
if (score > bestScore)
|
||||
let bestScore = score
|
||||
let bestFile = onefile
|
||||
endif
|
||||
let n = n + 1
|
||||
let onefile = <SID>GetNthItemFromList(allfiles, n)
|
||||
endwhile
|
||||
|
||||
if (bestScore == 0 && g:alternateNoDefaultAlternate == 1)
|
||||
echo "No existing alternate available"
|
||||
else
|
||||
call <SID>FindOrCreateBuffer(bestFile, a:splitWindow, 1)
|
||||
let b:AlternateAllFiles = allfiles
|
||||
endif
|
||||
else
|
||||
echo "No alternate file/buffer available"
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function : AlternateOpenFileUnderCursor (PUBLIC)
|
||||
" Purpose : Opens file under the cursor
|
||||
" Args : splitWindow -- indicates how to open the file
|
||||
" Returns : Nothing
|
||||
" Author : Michael Sharpe (feline@irendi.com) www.irendi.com
|
||||
function! AlternateOpenFileUnderCursor(splitWindow,...)
|
||||
let cursorFile = (a:0 > 0) ? a:1 : expand("<cfile>")
|
||||
let currentPath = expand("%:p:h")
|
||||
let openCount = 1
|
||||
|
||||
let fileName = <SID>FindFileInSearchPathEx(cursorFile, g:alternateSearchPath, currentPath, openCount)
|
||||
if (fileName != "")
|
||||
call <SID>FindOrCreateBuffer(fileName, a:splitWindow, 1)
|
||||
let b:openCount = openCount
|
||||
let b:cursorFile = cursorFile
|
||||
let b:currentPath = currentPath
|
||||
else
|
||||
echo "Can't find file"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function : AlternateOpenNextFile (PUBLIC)
|
||||
" Purpose : Opens the next file corresponding to the search which found the
|
||||
" current file
|
||||
" Args : bang -- indicates what to do if the current file has not been
|
||||
" saved
|
||||
" Returns : nothing
|
||||
" Author : Michael Sharpe (feline@irendi.com) www.irendi.com
|
||||
function! AlternateOpenNextFile(bang)
|
||||
let cursorFile = ""
|
||||
if (exists("b:cursorFile"))
|
||||
let cursorFile = b:cursorFile
|
||||
endif
|
||||
|
||||
let currentPath = ""
|
||||
if (exists("b:currentPath"))
|
||||
let currentPath = b:currentPath
|
||||
endif
|
||||
|
||||
let openCount = 0
|
||||
if (exists("b:openCount"))
|
||||
let openCount = b:openCount + 1
|
||||
endif
|
||||
|
||||
if (cursorFile != "" && currentPath != "" && openCount != 0)
|
||||
let fileName = <SID>FindFileInSearchPathEx(cursorFile, g:alternateSearchPath, currentPath, openCount)
|
||||
if (fileName != "")
|
||||
call <SID>FindOrCreateBuffer(fileName, "n".a:bang, 0)
|
||||
let b:openCount = openCount
|
||||
let b:cursorFile = cursorFile
|
||||
let b:currentPath = currentPath
|
||||
else
|
||||
let fileName = <SID>FindFileInSearchPathEx(cursorFile, g:alternateSearchPath, currentPath, 1)
|
||||
if (fileName != "")
|
||||
call <SID>FindOrCreateBuffer(fileName, "n".a:bang, 0)
|
||||
let b:openCount = 1
|
||||
let b:cursorFile = cursorFile
|
||||
let b:currentPath = currentPath
|
||||
else
|
||||
echo "Can't find next file"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
comm! -nargs=? -bang IH call AlternateOpenFileUnderCursor("n<bang>", <f-args>)
|
||||
comm! -nargs=? -bang IHS call AlternateOpenFileUnderCursor("h<bang>", <f-args>)
|
||||
comm! -nargs=? -bang IHV call AlternateOpenFileUnderCursor("v<bang>", <f-args>)
|
||||
comm! -nargs=? -bang IHT call AlternateOpenFileUnderCursor("t<bang>", <f-args>)
|
||||
comm! -nargs=? -bang IHN call AlternateOpenNextFile("<bang>")
|
||||
imap <Leader>ih <ESC>:IHS<CR>
|
||||
nmap <Leader>ih :IHS<CR>
|
||||
imap <Leader>is <ESC>:IHS<CR>:A<CR>
|
||||
nmap <Leader>is :IHS<CR>:A<CR>
|
||||
imap <Leader>ihn <ESC>:IHN<CR>
|
||||
nmap <Leader>ihn :IHN<CR>
|
||||
|
||||
"function! <SID>PrintList(theList)
|
||||
" let n = 1
|
||||
" let oneFile = <SID>GetNthItemFromList(a:theList, n)
|
||||
" while (oneFile != "")
|
||||
" let n = n + 1
|
||||
" let oneFile = <SID>GetNthItemFromList(a:theList, n)
|
||||
" endwhile
|
||||
"endfunction
|
||||
|
||||
" Function : NextAlternate (PUBLIC)
|
||||
" Purpose : Used to cycle through any other alternate file which existed on
|
||||
" the search path.
|
||||
" Args : bang (IN) - used to implement the AN vs AN! functionality
|
||||
" Returns : nothing
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
function! NextAlternate(bang)
|
||||
if (exists('b:AlternateAllFiles'))
|
||||
let currentFile = expand("%")
|
||||
let n = 1
|
||||
let onefile = <SID>GetNthItemFromList(b:AlternateAllFiles, n)
|
||||
while (onefile != "" && !<SID>EqualFilePaths(fnamemodify(onefile,":p"), fnamemodify(currentFile,":p")))
|
||||
let n = n + 1
|
||||
let onefile = <SID>GetNthItemFromList(b:AlternateAllFiles, n)
|
||||
endwhile
|
||||
|
||||
if (onefile != "")
|
||||
let stop = n
|
||||
let n = n + 1
|
||||
let foundAlternate = 0
|
||||
let nextAlternate = ""
|
||||
while (n != stop)
|
||||
let nextAlternate = <SID>GetNthItemFromList(b:AlternateAllFiles, n)
|
||||
if (nextAlternate == "")
|
||||
let n = 1
|
||||
continue
|
||||
endif
|
||||
let n = n + 1
|
||||
if (<SID>EqualFilePaths(fnamemodify(nextAlternate, ":p"), fnamemodify(currentFile, ":p")))
|
||||
continue
|
||||
endif
|
||||
if (filereadable(nextAlternate))
|
||||
" on cygwin filereadable("foo.H") returns true if "foo.h" exists
|
||||
if (has("unix") && $WINDIR != "" && fnamemodify(nextAlternate, ":p") ==? fnamemodify(currentFile, ":p"))
|
||||
continue
|
||||
endif
|
||||
let foundAlternate = 1
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
if (foundAlternate == 1)
|
||||
let s:AlternateAllFiles = b:AlternateAllFiles
|
||||
"silent! execute ":e".a:bang." " . nextAlternate
|
||||
call <SID>FindOrCreateBuffer(nextAlternate, "n".a:bang, 0)
|
||||
let b:AlternateAllFiles = s:AlternateAllFiles
|
||||
else
|
||||
echo "Only this alternate file exists"
|
||||
endif
|
||||
else
|
||||
echo "Could not find current file in alternates list"
|
||||
endif
|
||||
else
|
||||
echo "No other alternate files exist"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
comm! -nargs=? -bang A call AlternateFile("n<bang>", <f-args>)
|
||||
comm! -nargs=? -bang AS call AlternateFile("h<bang>", <f-args>)
|
||||
comm! -nargs=? -bang AV call AlternateFile("v<bang>", <f-args>)
|
||||
comm! -nargs=? -bang AT call AlternateFile("t<bang>", <f-args>)
|
||||
comm! -nargs=? -bang AN call NextAlternate("<bang>")
|
||||
|
||||
" Function : BufferOrFileExists (PRIVATE)
|
||||
" Purpose : determines if a buffer or a readable file exists
|
||||
" Args : fileName (IN) - name of the file to check
|
||||
" Returns : 2 if it exists in memory, 1 if it exists, 0 otherwise
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
" History : Updated code to handle buffernames using just the
|
||||
" filename and not the path.
|
||||
function! <SID>BufferOrFileExists(fileName)
|
||||
let result = 0
|
||||
|
||||
let lastBuffer = bufnr("$")
|
||||
let i = 1
|
||||
while i <= lastBuffer
|
||||
if <SID>EqualFilePaths(expand("#".i.":p"), a:fileName)
|
||||
let result = 2
|
||||
break
|
||||
endif
|
||||
let i = i + 1
|
||||
endwhile
|
||||
|
||||
if (!result)
|
||||
let bufName = fnamemodify(a:fileName,":t")
|
||||
let memBufName = bufname(bufName)
|
||||
if (memBufName != "")
|
||||
let memBufBasename = fnamemodify(memBufName, ":t")
|
||||
if (bufName == memBufBasename)
|
||||
let result = 2
|
||||
endif
|
||||
endif
|
||||
|
||||
if (!result)
|
||||
let result = bufexists(bufName) || bufexists(a:fileName) || filereadable(a:fileName)
|
||||
endif
|
||||
endif
|
||||
|
||||
if (!result)
|
||||
let result = filereadable(a:fileName)
|
||||
endif
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" Function : FindOrCreateBuffer (PRIVATE)
|
||||
" Purpose : searches the buffer list (:ls) for the specified filename. If
|
||||
" found, checks the window list for the buffer. If the buffer is in
|
||||
" an already open window, it switches to the window. If the buffer
|
||||
" was not in a window, it switches to that buffer. If the buffer did
|
||||
" not exist, it creates it.
|
||||
" Args : filename (IN) -- the name of the file
|
||||
" doSplit (IN) -- indicates whether the window should be split
|
||||
" ("v", "h", "n", "v!", "h!", "n!", "t", "t!")
|
||||
" findSimilar (IN) -- indicate weather existing buffers should be
|
||||
" prefered
|
||||
" Returns : nothing
|
||||
" Author : Michael Sharpe <feline@irendi.com>
|
||||
" History : + bufname() was not working very well with the possibly strange
|
||||
" paths that can abound with the search path so updated this
|
||||
" slightly. -- Bindu
|
||||
" + updated window switching code to make it more efficient -- Bindu
|
||||
" Allow ! to be applied to buffer/split/editing commands for more
|
||||
" vim/vi like consistency
|
||||
" + implemented fix from Matt Perry
|
||||
function! <SID>FindOrCreateBuffer(fileName, doSplit, findSimilar)
|
||||
" Check to see if the buffer is already open before re-opening it.
|
||||
let FILENAME = escape(a:fileName, ' ')
|
||||
let bufNr = -1
|
||||
let lastBuffer = bufnr("$")
|
||||
let i = 1
|
||||
if (a:findSimilar)
|
||||
while i <= lastBuffer
|
||||
if <SID>EqualFilePaths(expand("#".i.":p"), a:fileName)
|
||||
let bufNr = i
|
||||
break
|
||||
endif
|
||||
let i = i + 1
|
||||
endwhile
|
||||
|
||||
if (bufNr == -1)
|
||||
let bufName = bufname(a:fileName)
|
||||
let bufFilename = fnamemodify(a:fileName,":t")
|
||||
|
||||
if (bufName == "")
|
||||
let bufName = bufname(bufFilename)
|
||||
endif
|
||||
|
||||
if (bufName != "")
|
||||
let tail = fnamemodify(bufName, ":t")
|
||||
if (tail != bufFilename)
|
||||
let bufName = ""
|
||||
endif
|
||||
endif
|
||||
if (bufName != "")
|
||||
let bufNr = bufnr(bufName)
|
||||
let FILENAME = bufName
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if (g:alternateRelativeFiles == 1)
|
||||
let FILENAME = fnamemodify(FILENAME, ":p:.")
|
||||
endif
|
||||
|
||||
let splitType = a:doSplit[0]
|
||||
let bang = a:doSplit[1]
|
||||
if (bufNr == -1)
|
||||
" Buffer did not exist....create it
|
||||
let v:errmsg=""
|
||||
if (splitType == "h")
|
||||
silent! execute ":split".bang." " . FILENAME
|
||||
elseif (splitType == "v")
|
||||
silent! execute ":vsplit".bang." " . FILENAME
|
||||
elseif (splitType == "t")
|
||||
silent! execute ":tab split".bang." " . FILENAME
|
||||
else
|
||||
silent! execute ":e".bang." " . FILENAME
|
||||
endif
|
||||
if (v:errmsg != "")
|
||||
echo v:errmsg
|
||||
endif
|
||||
else
|
||||
|
||||
" Find the correct tab corresponding to the existing buffer
|
||||
let tabNr = -1
|
||||
" iterate tab pages
|
||||
for i in range(tabpagenr('$'))
|
||||
" get the list of buffers in the tab
|
||||
let tabList = tabpagebuflist(i + 1)
|
||||
let idx = 0
|
||||
" iterate each buffer in the list
|
||||
while idx < len(tabList)
|
||||
" if it matches the buffer we are looking for...
|
||||
if (tabList[idx] == bufNr)
|
||||
" ... save the number
|
||||
let tabNr = i + 1
|
||||
break
|
||||
endif
|
||||
let idx = idx + 1
|
||||
endwhile
|
||||
if (tabNr != -1)
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
" switch the the tab containing the buffer
|
||||
if (tabNr != -1)
|
||||
execute "tabn ".tabNr
|
||||
endif
|
||||
|
||||
" Buffer was already open......check to see if it is in a window
|
||||
let bufWindow = bufwinnr(bufNr)
|
||||
if (bufWindow == -1)
|
||||
" Buffer was not in a window so open one
|
||||
let v:errmsg=""
|
||||
if (splitType == "h")
|
||||
silent! execute ":sbuffer".bang." " . FILENAME
|
||||
elseif (splitType == "v")
|
||||
silent! execute ":vert sbuffer " . FILENAME
|
||||
elseif (splitType == "t")
|
||||
silent! execute ":tab sbuffer " . FILENAME
|
||||
else
|
||||
silent! execute ":buffer".bang." " . FILENAME
|
||||
endif
|
||||
if (v:errmsg != "")
|
||||
echo v:errmsg
|
||||
endif
|
||||
else
|
||||
" Buffer is already in a window so switch to the window
|
||||
execute bufWindow."wincmd w"
|
||||
if (bufWindow != winnr())
|
||||
" something wierd happened...open the buffer
|
||||
let v:errmsg=""
|
||||
if (splitType == "h")
|
||||
silent! execute ":split".bang." " . FILENAME
|
||||
elseif (splitType == "v")
|
||||
silent! execute ":vsplit".bang." " . FILENAME
|
||||
elseif (splitType == "t")
|
||||
silent! execute ":tab split".bang." " . FILENAME
|
||||
else
|
||||
silent! execute ":e".bang." " . FILENAME
|
||||
endif
|
||||
if (v:errmsg != "")
|
||||
echo v:errmsg
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Function : EqualFilePaths (PRIVATE)
|
||||
" Purpose : Compares two paths. Do simple string comparison anywhere but on
|
||||
" Windows. On Windows take into account that file paths could differ
|
||||
" in usage of separators and the fact that case does not matter.
|
||||
" "c:\WINDOWS" is the same path as "c:/windows". has("win32unix") Vim
|
||||
" version does not count as one having Windows path rules.
|
||||
" Args : path1 (IN) -- first path
|
||||
" path2 (IN) -- second path
|
||||
" Returns : 1 if path1 is equal to path2, 0 otherwise.
|
||||
" Author : Ilya Bobir <ilya@po4ta.com>
|
||||
function! <SID>EqualFilePaths(path1, path2)
|
||||
if has("win16") || has("win32") || has("win64") || has("win95")
|
||||
return substitute(a:path1, "\/", "\\", "g") ==? substitute(a:path2, "\/", "\\", "g")
|
||||
else
|
||||
return a:path1 == a:path2
|
||||
endif
|
||||
endfunction
|
28
vim/dot_vim/plugin/file:line.vim
Normal file
28
vim/dot_vim/plugin/file:line.vim
Normal file
@ -0,0 +1,28 @@
|
||||
" Avoid installing twice or when in unsupported Vim version.
|
||||
if exists('g:loaded_file_line') || (v:version < 700)
|
||||
finish
|
||||
endif
|
||||
let g:loaded_file_line = 1
|
||||
|
||||
function! s:gotoline()
|
||||
let file = bufname("%")
|
||||
" Accept file:line:column: or file:line:column and file:line also
|
||||
let names = matchlist( file, '\(.\{-1,}\):\(\d\+\)\(:\(\d*\):\?\)\?$')
|
||||
|
||||
if len(names) != 0 && filereadable(names[1])
|
||||
let l:bufn = bufnr("%")
|
||||
exec "keepalt edit " . names[1]
|
||||
exec ":" . names[2]
|
||||
exec ":bwipeout " l:bufn
|
||||
if foldlevel(names[2]) > 0
|
||||
exec ":foldopen!"
|
||||
endif
|
||||
|
||||
if (names[4] != '')
|
||||
exec "normal! " . names[4] . '|'
|
||||
endif
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
autocmd! BufNewFile *:* nested call s:gotoline()
|
4546
vim/dot_vim/plugin/taglist.vim
Normal file
4546
vim/dot_vim/plugin/taglist.vim
Normal file
File diff suppressed because it is too large
Load Diff
45
vim/dot_vimrc
Normal file
45
vim/dot_vimrc
Normal file
@ -0,0 +1,45 @@
|
||||
"tab functionality
|
||||
"tabs inserted as 4 spaces
|
||||
"backspace deletes all spaces
|
||||
"autoindent enabled
|
||||
set expandtab
|
||||
set tabstop=4
|
||||
set shiftwidth=4
|
||||
set softtabstop=4
|
||||
set autoindent
|
||||
filetype indent on
|
||||
|
||||
"enable line numbers
|
||||
set nu
|
||||
|
||||
"fixes arrow keys
|
||||
set nocompatible
|
||||
|
||||
"Allows filetype detection
|
||||
filetype on
|
||||
|
||||
"editing multiple files
|
||||
"Ctrl+j maximizes split below
|
||||
"Ctrl+k maximizes split above
|
||||
"allows size 0 splits
|
||||
"map <C-J> <C-W>j<C-W>_
|
||||
"map <C-K> <C-W>k<C-W>_
|
||||
"set wmh=0
|
||||
map <C-k> <C-w>k
|
||||
map <C-j> <C-w>j
|
||||
map <C-l> <C-w>l
|
||||
map <C-h> <C-w>h
|
||||
|
||||
"Class List
|
||||
nnoremap <silent> <F8> :TlistToggle<CR>
|
||||
let Tlist_Exit_OnlyWindow=1
|
||||
let Tlist_Winwidth=30
|
||||
|
||||
"Syntax Hightlighting
|
||||
syntax on
|
||||
|
||||
"Toggle Line numbers with Ctrl+N double tap
|
||||
nmap <C-N><C-N> :set invnumber<CR>
|
||||
|
||||
"Remap jk to esc
|
||||
inoremap jk <esc>
|
Loading…
Reference in New Issue
Block a user