diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..5a080d1 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: [tlhunter] +custom: https://www.paypal.me/phobosrising/5 diff --git a/.gitignore b/.gitignore index c82a3a8..0ce3f6c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ sessions/* .netrwhist +tags +tags-ja +local.vimrc +spell diff --git a/README.md b/README.md index 00f9b2c..91a35bc 100644 --- a/README.md +++ b/README.md @@ -1,83 +1,68 @@ -# Thomas Hunter's VIM Configuration +# /home/tlhunter/.vim/vimrc -This Vim configuration is meant to be used to make Vim act more like an IDE. I use it mostly under MacVIM, -so I make no guarantee for different environments. For now, I'm just planning on using github to make -managing my VIM configuraiton more easy, especially with deploying it to different environments. I'm not -sure if I will make this a community projects. +![Screenshot](./screenshot.png "Screenshot of this .vimrc in action") -I do use this configuration on Linux and OS X while running plain vim, and it works fine for the most part. +This Vim configuration is meant to make Vim feel more like an IDE than a simple console-based text editor. +This configuration is optimized for use with GVim though it certainly works in the terminal as well. -## Overview +## Installation -This configuration is primarily intended to be run with a MacVIM instance, used for editing -multiple files at the same time. On the left side of the screen will be the file browser, and on the right -will be the list of tags in the current file. On the bottom you will see a list of the currently opened -files (buffers) when switching between them, otherwise it will show status items. You will also see the name of the -current Git branch in parenthesis (if you are in one). +### Clone with GIT -When you want to edit a file, you can browse to it on the left side of the screen, or use _Ctrl p_ -to open up a quick/fuzzy search. If you want to edit another file, just browse to it and -open it just like before. When you want to move between open files, use the buffer movement keys mentioned -below. Feel free to open as many buffers as you want, as if this were a normal IDE. +Run these commands to get this Vim configuration working on your OS X or Linux machine. +You can run `git pull` inside of `~/.vim` if you'd ever like to grab the latest version. -## Features +```bash +cd ~ +git clone git@github.com:tlhunter/vimrc.git .vim +ln -s ~/.vim/vimrc ~/.vimrc # Optional, needed for some VIM installations +``` -* File Browser on left side of screen -* Functions, Variables, Classes on right -* Move between buffers in center screen -* View status of the current GIT repo (if applicable) -* Special features when running under MacVIM - -### Switching between files (Buffers) +### One Time Download -* Use _,q_ to close the current file (a different file will appear in its place) -* Use _Ctrl h Ctrl l_ to move between open files - * _Ctrl Left Ctrl Right_ also works for switching between files - * While in MacVim, you can swipe left and right to switch between open files +This method might be more sane. Simply downlaod the latest version, extract to `~/.vim`, and configure to your liking. -### Viewports (Windows) +```bash +wget https://github.com/tlhunter/vimrc/archive/master.zip +``` -* Use _,h ,j ,k ,l_ to navigate between viewports -* Use _,Q_ to close the current window (you probably won't ever need to do this) -* Use _,n_ to toggle the file browser -* Use _,y_ to toggle the tag browser -* Use _Ctrl+P_ to perform a recursive fuzzy filename search -* Use _,a_ and type a phrase to search to search based on content within your files (quote and escape if needed) -* Use _,A_ to close the open ack search results at the bottom of the screen (same going down, closing, going right, e.g. _,j ,Q ,l_) - -### File Browser (NERDTree) - -* Use _,n_ to toggle the file browser -* Use standard movement keys to move around -* Use _Ctrl j_ and _Ctrl k_ to move between siblings (aka skip over children in expanded folders) -* Use _C_ to make the highlighted node the current working directory -* Use _:Bookmark BookmarkName_ to bookmark the current selection -* Use _B_ to toggle the bookmark menu -* Use _?_ if you'd like some NERDTree documentation - -### Tag Browser (Tag List) - -* Use _y_ to toggle the tag browser viewport -* Use _s_ to reorder the items by alpha or occurance +## Features -### Copying and Pasting between OS +* Edit many files at the same time +* File Browser on left side of screen +* Move between files in center screen +* View status of the current GIT repo, if applicable +* Additional features when running under MacVIM +* Quickly navigate to files using a fuzzy finder -* Use _,c_ to copy the highlighted text into the OS clipboard -* Use _,v_ to paste the OS clipboard into the document +### Leader Key -## Requirements +- Space -* Install ctags and configure on your Mac: http://thomashunter.name/blog/installing-vim-taglist-with-macvim-in-os-x/ +### Switching between files (Buffers) -## Installation +* Use `q` to close the current file (a different file will appear in its place) +* Use `Ctrl h` `Ctrl l` to move between open files + * `Ctrl Left` `Ctrl Right` also works for switching between files + * While in MacVIM, you can swipe left and right to switch between open files +* Use `Cmd Shift N` (or `Alt n` in Linux GVim) to open a new empty buffer -Run these commands in your terminal to fully install this vim setup within OS X. It will probably require some -tweaking to get it working under Linux. +### Viewports (Windows/Splits) - cd ~ - git clone git://github.com/tlhunter/vimrc.git .vim - ln -s ~/.vim/vimrc ~/.vimrc && ln -s ~/.vim/gvimrc ~/.gvimrc +* Use `h` `j` `k` `l` to navigate between viewports +* Use `Q` to close the current window (you probably won't ever need to do this) +* Use `n` to toggle the file browser +* Use `Ctrl P` to perform a recursive fuzzy filename search +* Use `a` and type a phrase to search to search based on content within your files (quote and escape if needed) -## Screenshots +### File Browser (NERDTree) -![Screenshot](http://thomashunter.name/pictures/macvim.png "Screenshot of MacVIM") +* Use `n` to toggle the file browser +* Use standard movement keys to move around +* Use `Ctrl j` and `Ctrl k` to move between siblings (aka skip over children in expanded folders) +* Use `C` to make the highlighted node the current working directory +* Use `:Bookmark BookmarkName` to bookmark the current selection +* Use `B` to toggle the bookmark menu +* Use `?` if you'd like some NERDTree documentation +* Use `o` to open the selected file in a new buffer +* Use `t` to open the selected file in a new tab diff --git a/autoload/pathogen.vim b/autoload/pathogen.vim deleted file mode 100644 index be68389..0000000 --- a/autoload/pathogen.vim +++ /dev/null @@ -1,230 +0,0 @@ -" pathogen.vim - path option manipulation -" Maintainer: Tim Pope -" 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,'\\\@,'edit',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(,'edit',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(,'split',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(,'vsplit',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(,'tabedit',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(,'pedit',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(,'read',) -command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(,'edit',,'lcd') - -" vim:set ft=vim ts=8 sw=2 sts=2: diff --git a/bundle/NERD_tree/doc/NERD_tree.txt b/bundle/NERD_tree/doc/NERD_tree.txt deleted file mode 100644 index 2e2278c..0000000 --- a/bundle/NERD_tree/doc/NERD_tree.txt +++ /dev/null @@ -1,1222 +0,0 @@ -*NERD_tree.txt* A tree explorer plugin that owns your momma! - - - - omg its ... ~ - - ________ ________ _ ____________ ____ __________ ____________~ - /_ __/ / / / ____/ / | / / ____/ __ \/ __ \ /_ __/ __ \/ ____/ ____/~ - / / / /_/ / __/ / |/ / __/ / /_/ / / / / / / / /_/ / __/ / __/ ~ - / / / __ / /___ / /| / /___/ _, _/ /_/ / / / / _, _/ /___/ /___ ~ - /_/ /_/ /_/_____/ /_/ |_/_____/_/ |_/_____/ /_/ /_/ |_/_____/_____/ ~ - - - Reference Manual~ - - - - -============================================================================== -CONTENTS *NERDTree-contents* - - 1.Intro...................................|NERDTree| - 2.Functionality provided..................|NERDTreeFunctionality| - 2.1.Global commands...................|NERDTreeGlobalCommands| - 2.2.Bookmarks.........................|NERDTreeBookmarks| - 2.2.1.The bookmark table..........|NERDTreeBookmarkTable| - 2.2.2.Bookmark commands...........|NERDTreeBookmarkCommands| - 2.2.3.Invalid bookmarks...........|NERDTreeInvalidBookmarks| - 2.3.NERD tree mappings................|NERDTreeMappings| - 2.4.The NERD tree menu................|NERDTreeMenu| - 3.Options.................................|NERDTreeOptions| - 3.1.Option summary....................|NERDTreeOptionSummary| - 3.2.Option details....................|NERDTreeOptionDetails| - 4.The NERD tree API.......................|NERDTreeAPI| - 4.1.Key map API.......................|NERDTreeKeymapAPI| - 4.2.Menu API..........................|NERDTreeMenuAPI| - 5.About...................................|NERDTreeAbout| - 6.Changelog...............................|NERDTreeChangelog| - 7.Credits.................................|NERDTreeCredits| - 8.License.................................|NERDTreeLicense| - -============================================================================== -1. Intro *NERDTree* - -What is this "NERD tree"?? - -The NERD tree allows you to explore your filesystem and to open files and -directories. It presents the filesystem to you in the form of a tree which you -manipulate with the keyboard and/or mouse. It also allows you to perform -simple filesystem operations. - -The following features and functionality are provided by the NERD tree: - * Files and directories are displayed in a hierarchical tree structure - * Different highlighting is provided for the following types of nodes: - * files - * directories - * sym-links - * windows .lnk files - * read-only files - * executable files - * Many (customisable) mappings are provided to manipulate the tree: - * Mappings to open/close/explore directory nodes - * Mappings to open files in new/existing windows/tabs - * Mappings to change the current root of the tree - * Mappings to navigate around the tree - * ... - * Directories and files can be bookmarked. - * Most NERD tree navigation can also be done with the mouse - * Filtering of tree content (can be toggled at runtime) - * custom file filters to prevent e.g. vim backup files being displayed - * optional displaying of hidden files (. files) - * files can be "turned off" so that only directories are displayed - * The position and size of the NERD tree window can be customised - * The order in which the nodes in the tree are listed can be customised. - * A model of your filesystem is created/maintained as you explore it. This - has several advantages: - * All filesystem information is cached and is only re-read on demand - * If you revisit a part of the tree that you left earlier in your - session, the directory nodes will be opened/closed as you left them - * The script remembers the cursor position and window position in the NERD - tree so you can toggle it off (or just close the tree window) and then - reopen it (with NERDTreeToggle) the NERD tree window will appear exactly - as you left it - * You can have a separate NERD tree for each tab, share trees across tabs, - or a mix of both. - * By default the script overrides the default file browser (netw), so if - you :edit a directory a (slighly modified) NERD tree will appear in the - current window - * A programmable menu system is provided (simulates right clicking on a - node) - * one default menu plugin is provided to perform basic filesytem - operations (create/delete/move/copy files/directories) - * There's an API for adding your own keymappings - - -============================================================================== -2. Functionality provided *NERDTreeFunctionality* - ------------------------------------------------------------------------------- -2.1. Global Commands *NERDTreeGlobalCommands* - -:NERDTree [ | ] *:NERDTree* - Opens a fresh NERD tree. The root of the tree depends on the argument - given. There are 3 cases: If no argument is given, the current directory - will be used. If a directory is given, that will be used. If a bookmark - name is given, the corresponding directory will be used. For example: > - :NERDTree /home/marty/vim7/src - :NERDTree foo (foo is the name of a bookmark) -< -:NERDTreeFromBookmark *:NERDTreeFromBookmark* - Opens a fresh NERD tree with the root initialized to the dir for - . This only reason to use this command over :NERDTree is for - the completion (which is for bookmarks rather than directories). - -:NERDTreeToggle [ | ] *:NERDTreeToggle* - If a NERD tree already exists for this tab, it is reopened and rendered - again. If no NERD tree exists for this tab then this command acts the - same as the |:NERDTree| command. - -:NERDTreeMirror *:NERDTreeMirror* - Shares an existing NERD tree, from another tab, in the current tab. - Changes made to one tree are reflected in both as they are actually the - same buffer. - - If only one other NERD tree exists, that tree is automatically mirrored. If - more than one exists, the script will ask which tree to mirror. - -:NERDTreeClose *:NERDTreeClose* - Close the NERD tree in this tab. - -:NERDTreeFind *:NERDTreeFind* - Find the current file in the tree. If no tree exists for the current tab, - or the file is not under the current root, then initialize a new tree where - the root is the directory of the current file. - ------------------------------------------------------------------------------- -2.2. Bookmarks *NERDTreeBookmarks* - -Bookmarks in the NERD tree are a way to tag files or directories of interest. -For example, you could use bookmarks to tag all of your project directories. - ------------------------------------------------------------------------------- -2.2.1. The Bookmark Table *NERDTreeBookmarkTable* - -If the bookmark table is active (see |NERDTree-B| and -|'NERDTreeShowBookmarks'|), it will be rendered above the tree. You can double -click bookmarks or use the |NERDTree-o| mapping to activate them. See also, -|NERDTree-t| and |NERDTree-T| - ------------------------------------------------------------------------------- -2.2.2. Bookmark commands *NERDTreeBookmarkCommands* - -Note that the following commands are only available in the NERD tree buffer. - -:Bookmark - Bookmark the current node as . If there is already a - bookmark, it is overwritten. must not contain spaces. - -:BookmarkToRoot - Make the directory corresponding to the new root. If a treenode - corresponding to is already cached somewhere in the tree then - the current tree will be used, otherwise a fresh tree will be opened. - Note that if points to a file then its parent will be used - instead. - -:RevealBookmark - If the node is cached under the current root then it will be revealed - (i.e. directory nodes above it will be opened) and the cursor will be - placed on it. - -:OpenBookmark - must point to a file. The file is opened as though |NERDTree-o| - was applied. If the node is cached under the current root then it will be - revealed and the cursor will be placed on it. - -:ClearBookmarks [] - Remove all the given bookmarks. If no bookmarks are given then remove all - bookmarks on the current node. - -:ClearAllBookmarks - Remove all bookmarks. - -:ReadBookmarks - Re-read the bookmarks in the |'NERDTreeBookmarksFile'|. - -See also |:NERDTree| and |:NERDTreeFromBookmark|. - ------------------------------------------------------------------------------- -2.2.3. Invalid Bookmarks *NERDTreeInvalidBookmarks* - -If invalid bookmarks are detected, the script will issue an error message and -the invalid bookmarks will become unavailable for use. - -These bookmarks will still be stored in the bookmarks file (see -|'NERDTreeBookmarksFile'|), down the bottom. There will always be a blank line -after the valid bookmarks but before the invalid ones. - -Each line in the bookmarks file represents one bookmark. The proper format is: - - -After you have corrected any invalid bookmarks, either restart vim, or go -:ReadBookmarks from the NERD tree window. - ------------------------------------------------------------------------------- -2.3. NERD tree Mappings *NERDTreeMappings* - -Default Description~ help-tag~ -Key~ - -o.......Open files, directories and bookmarks....................|NERDTree-o| -go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go| -t.......Open selected node/bookmark in a new tab.................|NERDTree-t| -T.......Same as 't' but keep the focus on the current tab........|NERDTree-T| -i.......Open selected file in a split window.....................|NERDTree-i| -gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi| -s.......Open selected file in a new vsplit.......................|NERDTree-s| -gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs| -O.......Recursively open the selected directory..................|NERDTree-O| -x.......Close the current nodes parent...........................|NERDTree-x| -X.......Recursively close all children of the current node.......|NERDTree-X| -e.......Edit the current dif.....................................|NERDTree-e| - -...............same as |NERDTree-o|. -double-click.......same as the |NERDTree-o| map. -middle-click.......same as |NERDTree-i| for files, same as - |NERDTree-e| for dirs. - -D.......Delete the current bookmark .............................|NERDTree-D| - -P.......Jump to the root node....................................|NERDTree-P| -p.......Jump to current nodes parent.............................|NERDTree-p| -K.......Jump up inside directories at the current tree depth.....|NERDTree-K| -J.......Jump down inside directories at the current tree depth...|NERDTree-J| -...Jump down to the next sibling of the current directory...|NERDTree-C-J| -...Jump up to the previous sibling of the current directory.|NERDTree-C-K| - -C.......Change the tree root to the selected dir.................|NERDTree-C| -u.......Move the tree root up one directory......................|NERDTree-u| -U.......Same as 'u' except the old root node is left open........|NERDTree-U| -r.......Recursively refresh the current directory................|NERDTree-r| -R.......Recursively refresh the current root.....................|NERDTree-R| -m.......Display the NERD tree menu...............................|NERDTree-m| -cd......Change the CWD to the dir of the selected node...........|NERDTree-cd| - -I.......Toggle whether hidden files displayed....................|NERDTree-I| -f.......Toggle whether the file filters are used.................|NERDTree-f| -F.......Toggle whether files are displayed.......................|NERDTree-F| -B.......Toggle whether the bookmark table is displayed...........|NERDTree-B| - -q.......Close the NERDTree window................................|NERDTree-q| -A.......Zoom (maximize/minimize) the NERDTree window.............|NERDTree-A| -?.......Toggle the display of the quick help.....................|NERDTree-?| - ------------------------------------------------------------------------------- - *NERDTree-o* -Default key: o -Map option: NERDTreeMapActivateNode -Applies to: files and directories. - -If a file node is selected, it is opened in the previous window. - -If a directory is selected it is opened or closed depending on its current -state. - -If a bookmark that links to a directory is selected then that directory -becomes the new root. - -If a bookmark that links to a file is selected then that file is opened in the -previous window. - ------------------------------------------------------------------------------- - *NERDTree-go* -Default key: go -Map option: None -Applies to: files. - -If a file node is selected, it is opened in the previous window, but the -cursor does not move. - -The key combo for this mapping is always "g" + NERDTreeMapActivateNode (see -|NERDTree-o|). - ------------------------------------------------------------------------------- - *NERDTree-t* -Default key: t -Map option: NERDTreeMapOpenInTab -Applies to: files and directories. - -Opens the selected file in a new tab. If a directory is selected, a fresh -NERD Tree for that directory is opened in a new tab. - -If a bookmark which points to a directory is selected, open a NERD tree for -that directory in a new tab. If the bookmark points to a file, open that file -in a new tab. - ------------------------------------------------------------------------------- - *NERDTree-T* -Default key: T -Map option: NERDTreeMapOpenInTabSilent -Applies to: files and directories. - -The same as |NERDTree-t| except that the focus is kept in the current tab. - ------------------------------------------------------------------------------- - *NERDTree-i* -Default key: i -Map option: NERDTreeMapOpenSplit -Applies to: files. - -Opens the selected file in a new split window and puts the cursor in the new -window. - ------------------------------------------------------------------------------- - *NERDTree-gi* -Default key: gi -Map option: None -Applies to: files. - -The same as |NERDTree-i| except that the cursor is not moved. - -The key combo for this mapping is always "g" + NERDTreeMapOpenSplit (see -|NERDTree-i|). - ------------------------------------------------------------------------------- - *NERDTree-s* -Default key: s -Map option: NERDTreeMapOpenVSplit -Applies to: files. - -Opens the selected file in a new vertically split window and puts the cursor in -the new window. - ------------------------------------------------------------------------------- - *NERDTree-gs* -Default key: gs -Map option: None -Applies to: files. - -The same as |NERDTree-s| except that the cursor is not moved. - -The key combo for this mapping is always "g" + NERDTreeMapOpenVSplit (see -|NERDTree-s|). - ------------------------------------------------------------------------------- - *NERDTree-O* -Default key: O -Map option: NERDTreeMapOpenRecursively -Applies to: directories. - -Recursively opens the selelected directory. - -All files and directories are cached, but if a directory would not be -displayed due to file filters (see |'NERDTreeIgnore'| |NERDTree-f|) or the -hidden file filter (see |'NERDTreeShowHidden'|) then its contents are not -cached. This is handy, especially if you have .svn directories. - ------------------------------------------------------------------------------- - *NERDTree-x* -Default key: x -Map option: NERDTreeMapCloseDir -Applies to: files and directories. - -Closes the parent of the selected node. - ------------------------------------------------------------------------------- - *NERDTree-X* -Default key: X -Map option: NERDTreeMapCloseChildren -Applies to: directories. - -Recursively closes all children of the selected directory. - -Tip: To quickly "reset" the tree, use |NERDTree-P| with this mapping. - ------------------------------------------------------------------------------- - *NERDTree-e* -Default key: e -Map option: NERDTreeMapOpenExpl -Applies to: files and directories. - -|:edit|s the selected directory, or the selected file's directory. This could -result in a NERD tree or a netrw being opened, depending on -|'NERDTreeHijackNetrw'|. - ------------------------------------------------------------------------------- - *NERDTree-D* -Default key: D -Map option: NERDTreeMapDeleteBookmark -Applies to: lines in the bookmarks table - -Deletes the currently selected bookmark. - ------------------------------------------------------------------------------- - *NERDTree-P* -Default key: P -Map option: NERDTreeMapJumpRoot -Applies to: no restrictions. - -Jump to the tree root. - ------------------------------------------------------------------------------- - *NERDTree-p* -Default key: p -Map option: NERDTreeMapJumpParent -Applies to: files and directories. - -Jump to the parent node of the selected node. - ------------------------------------------------------------------------------- - *NERDTree-K* -Default key: K -Map option: NERDTreeMapJumpFirstChild -Applies to: files and directories. - -Jump to the first child of the current nodes parent. - -If the cursor is already on the first node then do the following: - * loop back thru the siblings of the current nodes parent until we find an - open dir with children - * go to the first child of that node - ------------------------------------------------------------------------------- - *NERDTree-J* -Default key: J -Map option: NERDTreeMapJumpLastChild -Applies to: files and directories. - -Jump to the last child of the current nodes parent. - -If the cursor is already on the last node then do the following: - * loop forward thru the siblings of the current nodes parent until we find - an open dir with children - * go to the last child of that node - ------------------------------------------------------------------------------- - *NERDTree-C-J* -Default key: -Map option: NERDTreeMapJumpNextSibling -Applies to: files and directories. - -Jump to the next sibling of the selected node. - ------------------------------------------------------------------------------- - *NERDTree-C-K* -Default key: -Map option: NERDTreeMapJumpPrevSibling -Applies to: files and directories. - -Jump to the previous sibling of the selected node. - ------------------------------------------------------------------------------- - *NERDTree-C* -Default key: C -Map option: NERDTreeMapChdir -Applies to: directories. - -Make the selected directory node the new tree root. If a file is selected, its -parent is used. - ------------------------------------------------------------------------------- - *NERDTree-u* -Default key: u -Map option: NERDTreeMapUpdir -Applies to: no restrictions. - -Move the tree root up a dir (like doing a "cd .."). - ------------------------------------------------------------------------------- - *NERDTree-U* -Default key: U -Map option: NERDTreeMapUpdirKeepOpen -Applies to: no restrictions. - -Like |NERDTree-u| except that the old tree root is kept open. - ------------------------------------------------------------------------------- - *NERDTree-r* -Default key: r -Map option: NERDTreeMapRefresh -Applies to: files and directories. - -If a dir is selected, recursively refresh that dir, i.e. scan the filesystem -for changes and represent them in the tree. - -If a file node is selected then the above is done on it's parent. - ------------------------------------------------------------------------------- - *NERDTree-R* -Default key: R -Map option: NERDTreeMapRefreshRoot -Applies to: no restrictions. - -Recursively refresh the tree root. - ------------------------------------------------------------------------------- - *NERDTree-m* -Default key: m -Map option: NERDTreeMapMenu -Applies to: files and directories. - -Display the NERD tree menu. See |NERDTreeMenu| for details. - ------------------------------------------------------------------------------- - *NERDTree-cd* -Default key: cd -Map option: NERDTreeMapChdir -Applies to: files and directories. - -Change vims current working directory to that of the selected node. - ------------------------------------------------------------------------------- - *NERDTree-I* -Default key: I -Map option: NERDTreeMapToggleHidden -Applies to: no restrictions. - -Toggles whether hidden files (i.e. "dot files") are displayed. - ------------------------------------------------------------------------------- - *NERDTree-f* -Default key: f -Map option: NERDTreeMapToggleFilters -Applies to: no restrictions. - -Toggles whether file filters are used. See |'NERDTreeIgnore'| for details. - ------------------------------------------------------------------------------- - *NERDTree-F* -Default key: F -Map option: NERDTreeMapToggleFiles -Applies to: no restrictions. - -Toggles whether file nodes are displayed. - ------------------------------------------------------------------------------- - *NERDTree-B* -Default key: B -Map option: NERDTreeMapToggleBookmarks -Applies to: no restrictions. - -Toggles whether the bookmarks table is displayed. - ------------------------------------------------------------------------------- - *NERDTree-q* -Default key: q -Map option: NERDTreeMapQuit -Applies to: no restrictions. - -Closes the NERDtree window. - ------------------------------------------------------------------------------- - *NERDTree-A* -Default key: A -Map option: NERDTreeMapToggleZoom -Applies to: no restrictions. - -Maximize (zoom) and minimize the NERDtree window. - ------------------------------------------------------------------------------- - *NERDTree-?* -Default key: ? -Map option: NERDTreeMapHelp -Applies to: no restrictions. - -Toggles whether the quickhelp is displayed. - ------------------------------------------------------------------------------- -2.3. The NERD tree menu *NERDTreeMenu* - -The NERD tree has a menu that can be programmed via the an API (see -|NERDTreeMenuAPI|). The idea is to simulate the "right click" menus that most -file explorers have. - -The script comes with two default menu plugins: exec_menuitem.vim and -fs_menu.vim. fs_menu.vim adds some basic filesystem operations to the menu for -creating/deleting/moving/copying files and dirs. exec_menuitem.vim provides a -menu item to execute executable files. - -Related tags: |NERDTree-m| |NERDTreeApi| - -============================================================================== -3. Customisation *NERDTreeOptions* - - ------------------------------------------------------------------------------- -3.1. Customisation summary *NERDTreeOptionSummary* - -The script provides the following options that can customise the behaviour the -NERD tree. These options should be set in your vimrc. - -|'loaded_nerd_tree'| Turns off the script. - -|'NERDChristmasTree'| Tells the NERD tree to make itself colourful - and pretty. - -|'NERDTreeAutoCenter'| Controls whether the NERD tree window centers - when the cursor moves within a specified - distance to the top/bottom of the window. -|'NERDTreeAutoCenterThreshold'| Controls the sensitivity of autocentering. - -|'NERDTreeCaseSensitiveSort'| Tells the NERD tree whether to be case - sensitive or not when sorting nodes. - -|'NERDTreeChDirMode'| Tells the NERD tree if/when it should change - vim's current working directory. - -|'NERDTreeHighlightCursorline'| Tell the NERD tree whether to highlight the - current cursor line. - -|'NERDTreeHijackNetrw'| Tell the NERD tree whether to replace the netrw - autocommands for exploring local directories. - -|'NERDTreeIgnore'| Tells the NERD tree which files to ignore. - -|'NERDTreeBookmarksFile'| Where the bookmarks are stored. - -|'NERDTreeMouseMode'| Tells the NERD tree how to handle mouse - clicks. - -|'NERDTreeQuitOnOpen'| Closes the tree window after opening a file. - -|'NERDTreeShowBookmarks'| Tells the NERD tree whether to display the - bookmarks table on startup. - -|'NERDTreeShowFiles'| Tells the NERD tree whether to display files - in the tree on startup. - -|'NERDTreeShowHidden'| Tells the NERD tree whether to display hidden - files on startup. - -|'NERDTreeShowLineNumbers'| Tells the NERD tree whether to display line - numbers in the tree window. - -|'NERDTreeSortOrder'| Tell the NERD tree how to sort the nodes in - the tree. - -|'NERDTreeStatusline'| Set a statusline for NERD tree windows. - -|'NERDTreeWinPos'| Tells the script where to put the NERD tree - window. - -|'NERDTreeWinSize'| Sets the window size when the NERD tree is - opened. - ------------------------------------------------------------------------------- -3.2. Customisation details *NERDTreeOptionDetails* - -To enable any of the below options you should put the given line in your -~/.vimrc - - *'loaded_nerd_tree'* -If this plugin is making you feel homicidal, it may be a good idea to turn it -off with this line in your vimrc: > - let loaded_nerd_tree=1 -< ------------------------------------------------------------------------------- - *'NERDChristmasTree'* -Values: 0 or 1. -Default: 1. - -If this option is set to 1 then some extra syntax highlighting elements are -added to the nerd tree to make it more colourful. - -Set it to 0 for a more vanilla looking tree. - ------------------------------------------------------------------------------- - *'NERDTreeAutoCenter'* -Values: 0 or 1. -Default: 1 - -If set to 1, the NERD tree window will center around the cursor if it moves to -within |'NERDTreeAutoCenterThreshold'| lines of the top/bottom of the window. - -This is ONLY done in response to tree navigation mappings, -i.e. |NERDTree-J| |NERDTree-K| |NERDTree-C-J| |NERDTree-C-K| |NERDTree-p| -|NERDTree-P| - -The centering is done with a |zz| operation. - ------------------------------------------------------------------------------- - *'NERDTreeAutoCenterThreshold'* -Values: Any natural number. -Default: 3 - -This option controls the "sensitivity" of the NERD tree auto centering. See -|'NERDTreeAutoCenter'| for details. - ------------------------------------------------------------------------------- - *'NERDTreeCaseSensitiveSort'* -Values: 0 or 1. -Default: 0. - -By default the NERD tree does not sort nodes case sensitively, i.e. nodes -could appear like this: > - bar.c - Baz.c - blarg.c - boner.c - Foo.c -< -But, if you set this option to 1 then the case of the nodes will be taken into -account. The above nodes would then be sorted like this: > - Baz.c - Foo.c - bar.c - blarg.c - boner.c -< ------------------------------------------------------------------------------- - *'NERDTreeChDirMode'* - -Values: 0, 1 or 2. -Default: 0. - -Use this option to tell the script when (if at all) to change the current -working directory (CWD) for vim. - -If it is set to 0 then the CWD is never changed by the NERD tree. - -If set to 1 then the CWD is changed when the NERD tree is first loaded to the -directory it is initialized in. For example, if you start the NERD tree with > - :NERDTree /home/marty/foobar -< -then the CWD will be changed to /home/marty/foobar and will not be changed -again unless you init another NERD tree with a similar command. - -If the option is set to 2 then it behaves the same as if set to 1 except that -the CWD is changed whenever the tree root is changed. For example, if the CWD -is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new -root then the CWD will become /home/marty/foobar/baz. - ------------------------------------------------------------------------------- - *'NERDTreeHighlightCursorline'* -Values: 0 or 1. -Default: 1. - -If set to 1, the current cursor line in the NERD tree buffer will be -highlighted. This is done using the |'cursorline'| option. - ------------------------------------------------------------------------------- - *'NERDTreeHijackNetrw'* -Values: 0 or 1. -Default: 1. - -If set to 1, doing a > - :edit -< -will open up a "secondary" NERD tree instead of a netrw in the target window. - -Secondary NERD trees behaves slighly different from a regular trees in the -following respects: - 1. 'o' will open the selected file in the same window as the tree, - replacing it. - 2. you can have as many secondary tree as you want in the same tab. - ------------------------------------------------------------------------------- - *'NERDTreeIgnore'* -Values: a list of regular expressions. -Default: ['\~$']. - -This option is used to specify which files the NERD tree should ignore. It -must be a list of regular expressions. When the NERD tree is rendered, any -files/dirs that match any of the regex's in 'NERDTreeIgnore' wont be -displayed. - -For example if you put the following line in your vimrc: > - let NERDTreeIgnore=['\.vim$', '\~$'] -< -then all files ending in .vim or ~ will be ignored. - -Note: to tell the NERD tree not to ignore any files you must use the following -line: > - let NERDTreeIgnore=[] -< - -The file filters can be turned on and off dynamically with the |NERDTree-f| -mapping. - ------------------------------------------------------------------------------- - *'NERDTreeBookmarksFile'* -Values: a path -Default: $HOME/.NERDTreeBookmarks - -This is where bookmarks are saved. See |NERDTreeBookmarkCommands|. - ------------------------------------------------------------------------------- - *'NERDTreeMouseMode'* -Values: 1, 2 or 3. -Default: 1. - -If set to 1 then a double click on a node is required to open it. -If set to 2 then a single click will open directory nodes, while a double -click will still be required for file nodes. -If set to 3 then a single click will open any node. - -Note: a double click anywhere on a line that a tree node is on will -activate it, but all single-click activations must be done on name of the node -itself. For example, if you have the following node: > - | | |-application.rb -< -then (to single click activate it) you must click somewhere in -'application.rb'. - ------------------------------------------------------------------------------- - *'NERDTreeQuitOnOpen'* - -Values: 0 or 1. -Default: 0 - -If set to 1, the NERD tree window will close after opening a file with the -|NERDTree-o|, |NERDTree-i|, |NERDTree-t| and |NERDTree-T| mappings. - ------------------------------------------------------------------------------- - *'NERDTreeShowBookmarks'* -Values: 0 or 1. -Default: 0. - -If this option is set to 1 then the bookmarks table will be displayed. - -This option can be toggled dynamically, per tree, with the |NERDTree-B| -mapping. - ------------------------------------------------------------------------------- - *'NERDTreeShowFiles'* -Values: 0 or 1. -Default: 1. - -If this option is set to 1 then files are displayed in the NERD tree. If it is -set to 0 then only directories are displayed. - -This option can be toggled dynamically, per tree, with the |NERDTree-F| -mapping and is useful for drastically shrinking the tree when you are -navigating to a different part of the tree. - ------------------------------------------------------------------------------- - *'NERDTreeShowHidden'* -Values: 0 or 1. -Default: 0. - -This option tells vim whether to display hidden files by default. This option -can be dynamically toggled, per tree, with the |NERDTree-I| mapping. Use one -of the follow lines to set this option: > - let NERDTreeShowHidden=0 - let NERDTreeShowHidden=1 -< - ------------------------------------------------------------------------------- - *'NERDTreeShowLineNumbers'* -Values: 0 or 1. -Default: 0. - -This option tells vim whether to display line numbers for the NERD tree -window. Use one of the follow lines to set this option: > - let NERDTreeShowLineNumbers=0 - let NERDTreeShowLineNumbers=1 -< - ------------------------------------------------------------------------------- - *'NERDTreeSortOrder'* -Values: a list of regular expressions. -Default: ['\/$', '*', '\.swp$', '\.bak$', '\~$'] - -This option is set to a list of regular expressions which are used to -specify the order of nodes under their parent. - -For example, if the option is set to: > - ['\.vim$', '\.c$', '\.h$', '*', 'foobar'] -< -then all .vim files will be placed at the top, followed by all .c files then -all .h files. All files containing the string 'foobar' will be placed at the -end. The star is a special flag: it tells the script that every node that -doesnt match any of the other regexps should be placed here. - -If no star is present in 'NERDTreeSortOrder' then one is automatically -appended to the array. - -The regex '\/$' should be used to match directory nodes. - -After this sorting is done, the files in each group are sorted alphabetically. - -Other examples: > - (1) ['*', '\/$'] - (2) [] - (3) ['\/$', '\.rb$', '\.php$', '*', '\.swp$', '\.bak$', '\~$'] -< -1. Directories will appear last, everything else will appear above. -2. Everything will simply appear in alphabetical order. -3. Dirs will appear first, then ruby and php. Swap files, bak files and vim - backup files will appear last with everything else preceding them. - ------------------------------------------------------------------------------- - *'NERDTreeStatusline'* -Values: Any valid statusline setting. -Default: %{b:NERDTreeRoot.path.strForOS(0)} - -Tells the script what to use as the |'statusline'| setting for NERD tree -windows. - -Note that the statusline is set using |:let-&| not |:set| so escaping spaces -isn't necessary. - -Setting this option to -1 will will deactivate it so that your global -statusline setting is used instead. - ------------------------------------------------------------------------------- - *'NERDTreeWinPos'* -Values: "left" or "right" -Default: "left". - -This option is used to determine where NERD tree window is placed on the -screen. - -This option makes it possible to use two different explorer plugins -simultaneously. For example, you could have the taglist plugin on the left of -the window and the NERD tree on the right. - ------------------------------------------------------------------------------- - *'NERDTreeWinSize'* -Values: a positive integer. -Default: 31. - -This option is used to change the size of the NERD tree when it is loaded. - -============================================================================== -4. The NERD tree API *NERDTreeAPI* - -The NERD tree script allows you to add custom key mappings and menu items via -a set of API calls. Any scripts that use this API should be placed in -~/.vim/nerdtree_plugin/ (*nix) or ~/vimfiles/nerdtree_plugin (windows). - -The script exposes some prototype objects that can be used to manipulate the -tree and/or get information from it: > - g:NERDTreePath - g:NERDTreeDirNode - g:NERDTreeFileNode - g:NERDTreeBookmark -< -See the code/comments in NERD_tree.vim to find how to use these objects. The -following code conventions are used: - * class members start with a capital letter - * instance members start with a lower case letter - * private members start with an underscore - -See this blog post for more details: - http://got-ravings.blogspot.com/2008/09/vim-pr0n-prototype-based-objects.html - ------------------------------------------------------------------------------- -4.1. Key map API *NERDTreeKeymapAPI* - -NERDTreeAddKeyMap({options}) *NERDTreeAddKeyMap()* - Adds a new keymapping for all NERD tree buffers. - {options} must be a dictionary, and must contain the following keys: - "key" - the trigger key for the new mapping - "callback" - the function the new mapping will be bound to - "quickhelpText" - the text that will appear in the quickhelp (see - |NERDTree-?|) - - Example: > - call NERDTreeAddKeyMap({ - \ 'key': 'b', - \ 'callback': 'NERDTreeEchoCurrentNode', - \ 'quickhelpText': 'echo full path of current node' }) - - function! NERDTreeEchoCurrentNode() - let n = g:NERDTreeFileNode.GetSelected() - if n != {} - echomsg 'Current node: ' . n.path.str() - endif - endfunction -< - This code should sit in a file like ~/.vim/nerdtree_plugin/mymapping.vim. - It adds a (rather useless) mapping on 'b' which echos the full path to the - current node. - ------------------------------------------------------------------------------- -4.2. Menu API *NERDTreeMenuAPI* - -NERDTreeAddSubmenu({options}) *NERDTreeAddSubmenu()* - Creates and returns a new submenu. - - {options} must be a dictionary and must contain the following keys: - "text" - the text of the submenu that the user will see - "shortcut" - a shortcut key for the submenu (need not be unique) - - The following keys are optional: - "isActiveCallback" - a function that will be called to determine whether - this submenu item will be displayed or not. The callback function must return - 0 or 1. - "parent" - the parent submenu of the new submenu (returned from a previous - invocation of NERDTreeAddSubmenu()). If this key is left out then the new - submenu will sit under the top level menu. - - See below for an example. - -NERDTreeAddMenuItem({options}) *NERDTreeAddMenuItem()* - Adds a new menu item to the NERD tree menu (see |NERDTreeMenu|). - - {options} must be a dictionary and must contain the - following keys: - "text" - the text of the menu item which the user will see - "shortcut" - a shortcut key for the menu item (need not be unique) - "callback" - the function that will be called when the user activates the - menu item. - - The following keys are optional: - "isActiveCallback" - a function that will be called to determine whether - this menu item will be displayed or not. The callback function must return - 0 or 1. - "parent" - if the menu item belongs under a submenu then this key must be - specified. This value for this key will be the object that - was returned when the submenu was created with |NERDTreeAddSubmenu()|. - - See below for an example. - -NERDTreeAddMenuSeparator([{options}]) *NERDTreeAddMenuSeparator()* - Adds a menu separator (a row of dashes). - - {options} is an optional dictionary that may contain the following keys: - "isActiveCallback" - see description in |NERDTreeAddMenuItem()|. - -Below is an example of the menu API in action. > - call NERDTreeAddMenuSeparator() - - call NERDTreeAddMenuItem({ - \ 'text': 'a (t)op level menu item', - \ 'shortcut': 't', - \ 'callback': 'SomeFunction' }) - - let submenu = NERDTreeAddSubmenu({ - \ 'text': 'a (s)ub menu', - \ 'shortcut': 's' }) - - call NERDTreeAddMenuItem({ - \ 'text': '(n)ested item 1', - \ 'shortcut': 'n', - \ 'callback': 'SomeFunction', - \ 'parent': submenu }) - - call NERDTreeAddMenuItem({ - \ 'text': '(n)ested item 2', - \ 'shortcut': 'n', - \ 'callback': 'SomeFunction', - \ 'parent': submenu }) -< -This will create the following menu: > - -------------------- - a (t)op level menu item - a (s)ub menu -< -Where selecting "a (s)ub menu" will lead to a second menu: > - (n)ested item 1 - (n)ested item 2 -< -When any of the 3 concrete menu items are selected the function "SomeFunction" -will be called. - ------------------------------------------------------------------------------- -NERDTreeRender() *NERDTreeRender()* - Re-renders the NERD tree buffer. Useful if you change the state of the - tree and you want to it to be reflected in the UI. - -============================================================================== -5. About *NERDTreeAbout* - -The author of the NERD tree is a terrible terrible monster called Martyzilla -who gobbles up small children with milk and sugar for breakfast. - -He can be reached at martin.grenfell at gmail dot com. He would love to hear -from you, so feel free to send him suggestions and/or comments about this -plugin. Don't be shy --- the worst he can do is slaughter you and stuff you in -the fridge for later ;) - -The latest stable versions can be found at - http://www.vim.org/scripts/script.php?script_id=1658 - -The latest dev versions are on github - http://github.com/scrooloose/nerdtree - - -============================================================================== -6. Changelog *NERDTreeChangelog* - -4.1.0 - features: - - NERDTreeFind to reveal the node for the current buffer in the tree, - see |NERDTreeFind|. This effectively merges the FindInNERDTree plugin (by - Doug McInnes) into the script. - - make NERDTreeQuitOnOpen apply to the t/T keymaps too. Thanks to Stefan - Ritter and Rémi Prévost. - - truncate the root node if wider than the tree window. Thanks to Victor - Gonzalez. - - bugfixes: - - really fix window state restoring - - fix some win32 path escaping issues. Thanks to Stephan Baumeister, Ricky, - jfilip1024, and Chris Chambers - -4.0.0 - - add a new programmable menu system (see :help NERDTreeMenu). - - add new APIs to add menus/menu-items to the menu system as well as - custom key mappings to the NERD tree buffer (see :help NERDTreeAPI). - - removed the old API functions - - added a mapping to maximize/restore the size of nerd tree window, thanks - to Guillaume Duranceau for the patch. See :help NERDTree-A for details. - - - fix a bug where secondary nerd trees (netrw hijacked trees) and - NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey. - - fix a bug where the script ignored directories whose name ended in a dot, - thanks to Aggelos Orfanakos for the patch. - - fix a bug when using the x mapping on the tree root, thanks to Bryan - Venteicher for the patch. - - fix a bug where the cursor position/window size of the nerd tree buffer - wasnt being stored on closing the window, thanks to Richard Hart. - - fix a bug where NERDTreeMirror would mirror the wrong tree - -3.1.1 - - fix a bug where a non-listed no-name buffer was getting created every - time the tree windows was created, thanks to Derek Wyatt and owen1 - - make behave the same as the 'o' mapping - - some helptag fixes in the doc, thanks strull - - fix a bug when using :set nohidden and opening a file where the previous - buf was modified. Thanks iElectric - - other minor fixes - -3.1.0 - New features: - - add mappings to open files in a vsplit, see :help NERDTree-s and :help - NERDTree-gs - - make the statusline for the nerd tree window default to something - hopefully more useful. See :help 'NERDTreeStatusline' - Bugfixes: - - make the hijack netrw functionality work when vim is started with "vim - " (thanks to Alf Mikula for the patch). - - fix a bug where the CWD wasnt being changed for some operations even when - NERDTreeChDirMode==2 (thanks to Lucas S. Buchala) - - add -bar to all the nerd tree :commands so they can chain with other - :commands (thanks to tpope) - - fix bugs when ignorecase was set (thanks to nach) - - fix a bug with the relative path code (thanks to nach) - - fix a bug where doing a :cd would cause :NERDTreeToggle to fail (thanks nach) - - -3.0.1 - Bugfixes: - - fix bugs with :NERDTreeToggle and :NERDTreeMirror when 'hidden - was not set - - fix a bug where :NERDTree would fail if was relative and - didnt start with a ./ or ../ Thanks to James Kanze. - - make the q mapping work with secondary (:e style) trees, - thanks to jamessan - - fix a bunch of small bugs with secondary trees - - More insane refactoring. - -3.0.0 - - hijack netrw so that doing an :edit will put a NERD tree in - the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw' - - allow sharing of trees across tabs, see :help :NERDTreeMirror - - remove "top" and "bottom" as valid settings for NERDTreeWinPos - - change the '' mapping to 'i' - - change the 'H' mapping to 'I' - - lots of refactoring - -============================================================================== -7. Credits *NERDTreeCredits* - -Thanks to the following people for testing, bug reports, ideas etc. Without -you I probably would have got bored of the hacking the NERD tree and -just downloaded pr0n instead. - - Tim Carey-Smith (halorgium) - Vigil - Nick Brettell - Thomas Scott Urban - Terrance Cohen - Yegappan Lakshmanan - Jason Mills - Michael Geddes (frogonwheels) - Yu Jun - Michael Madsen - AOYAMA Shotaro - Zhang Weiwu - Niels Aan de Brugh - Olivier Yiptong - Zhang Shuhan - Cory Echols - Piotr Czachur - Yuan Jiang - Matan Nassau - Maxim Kim - Charlton Wang - Matt Wozniski (godlygeek) - knekk - Sean Chou - Ryan Penn - Simon Peter Nicholls - Michael Foobar - Tomasz Chomiuk - Denis Pokataev - Tim Pope (tpope) - James Kanze - James Vega (jamessan) - Frederic Chanal (nach) - Alf Mikula - Lucas S. Buchala - Curtis Harvey - Guillaume Duranceau - Richard Hart (hates) - Doug McInnes - Stefan Ritter - Rémi Prévost - Victor Gonzalez - Stephan Baumeister - Ricky - jfilip1024 - Chris Chambers - -============================================================================== -8. License *NERDTreeLicense* - -The NERD tree is released under the wtfpl. -See http://sam.zoy.org/wtfpl/COPYING. diff --git a/bundle/NERD_tree/nerdtree_plugin/fs_menu.vim b/bundle/NERD_tree/nerdtree_plugin/fs_menu.vim deleted file mode 100644 index e25b38c..0000000 --- a/bundle/NERD_tree/nerdtree_plugin/fs_menu.vim +++ /dev/null @@ -1,194 +0,0 @@ -" ============================================================================ -" File: fs_menu.vim -" Description: plugin for the NERD Tree that provides a file system menu -" Maintainer: Martin Grenfell -" Last Change: 17 July, 2009 -" License: This program is free software. It comes without any warranty, -" to the extent permitted by applicable law. You can redistribute -" it and/or modify it under the terms of the Do What The Fuck You -" Want To Public License, Version 2, as published by Sam Hocevar. -" See http://sam.zoy.org/wtfpl/COPYING for more details. -" -" ============================================================================ -if exists("g:loaded_nerdtree_fs_menu") - finish -endif -let g:loaded_nerdtree_fs_menu = 1 - -call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'}) -call NERDTreeAddMenuItem({'text': '(m)ove the curent node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'}) -call NERDTreeAddMenuItem({'text': '(d)elete the curent node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'}) -if g:NERDTreePath.CopyingSupported() - call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'}) -endif - -"FUNCTION: s:echo(msg){{{1 -function! s:echo(msg) - redraw - echomsg "NERDTree: " . a:msg -endfunction - -"FUNCTION: s:echoWarning(msg){{{1 -function! s:echoWarning(msg) - echohl warningmsg - call s:echo(a:msg) - echohl normal -endfunction - -"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{1 -"prints out the given msg and, if the user responds by pushing 'y' then the -"buffer with the given bufnum is deleted -" -"Args: -"bufnum: the buffer that may be deleted -"msg: a message that will be echoed to the user asking them if they wish to -" del the buffer -function! s:promptToDelBuffer(bufnum, msg) - echo a:msg - if nr2char(getchar()) ==# 'y' - exec "silent bdelete! " . a:bufnum - endif -endfunction - -"FUNCTION: NERDTreeAddNode(){{{1 -function! NERDTreeAddNode() - let curDirNode = g:NERDTreeDirNode.GetSelected() - - let newNodeName = input("Add a childnode\n". - \ "==========================================================\n". - \ "Enter the dir/file name to be created. Dirs end with a '/'\n" . - \ "", curDirNode.path.str({'format': 'Glob'}) . g:NERDTreePath.Slash()) - - if newNodeName ==# '' - call s:echo("Node Creation Aborted.") - return - endif - - try - let newPath = g:NERDTreePath.Create(newNodeName) - let parentNode = b:NERDTreeRoot.findNode(newPath.getParent()) - - let newTreeNode = g:NERDTreeFileNode.New(newPath) - if parentNode.isOpen || !empty(parentNode.children) - call parentNode.addChild(newTreeNode, 1) - call NERDTreeRender() - call newTreeNode.putCursorHere(1, 0) - endif - catch /^NERDTree/ - call s:echoWarning("Node Not Created.") - endtry -endfunction - -"FUNCTION: NERDTreeMoveNode(){{{1 -function! NERDTreeMoveNode() - let curNode = g:NERDTreeFileNode.GetSelected() - let newNodePath = input("Rename the current node\n" . - \ "==========================================================\n" . - \ "Enter the new path for the node: \n" . - \ "", curNode.path.str()) - - if newNodePath ==# '' - call s:echo("Node Renaming Aborted.") - return - endif - - try - let bufnum = bufnr(curNode.path.str()) - - call curNode.rename(newNodePath) - call NERDTreeRender() - - "if the node is open in a buffer, ask the user if they want to - "close that buffer - if bufnum != -1 - let prompt = "\nNode renamed.\n\nThe old file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" - call s:promptToDelBuffer(bufnum, prompt) - endif - - call curNode.putCursorHere(1, 0) - - redraw - catch /^NERDTree/ - call s:echoWarning("Node Not Renamed.") - endtry -endfunction - -" FUNCTION: NERDTreeDeleteNode() {{{1 -function! NERDTreeDeleteNode() - let currentNode = g:NERDTreeFileNode.GetSelected() - let confirmed = 0 - - if currentNode.path.isDirectory - let choice =input("Delete the current node\n" . - \ "==========================================================\n" . - \ "STOP! To delete this entire directory, type 'yes'\n" . - \ "" . currentNode.path.str() . ": ") - let confirmed = choice ==# 'yes' - else - echo "Delete the current node\n" . - \ "==========================================================\n". - \ "Are you sure you wish to delete the node:\n" . - \ "" . currentNode.path.str() . " (yN):" - let choice = nr2char(getchar()) - let confirmed = choice ==# 'y' - endif - - - if confirmed - try - call currentNode.delete() - call NERDTreeRender() - - "if the node is open in a buffer, ask the user if they want to - "close that buffer - let bufnum = bufnr(currentNode.path.str()) - if buflisted(bufnum) - let prompt = "\nNode deleted.\n\nThe file is open in buffer ". bufnum . (bufwinnr(bufnum) ==# -1 ? " (hidden)" : "") .". Delete this buffer? (yN)" - call s:promptToDelBuffer(bufnum, prompt) - endif - - redraw - catch /^NERDTree/ - call s:echoWarning("Could not remove node") - endtry - else - call s:echo("delete aborted") - endif - -endfunction - -" FUNCTION: NERDTreeCopyNode() {{{1 -function! NERDTreeCopyNode() - let currentNode = g:NERDTreeFileNode.GetSelected() - let newNodePath = input("Copy the current node\n" . - \ "==========================================================\n" . - \ "Enter the new path to copy the node to: \n" . - \ "", currentNode.path.str()) - - if newNodePath != "" - "strip trailing slash - let newNodePath = substitute(newNodePath, '\/$', '', '') - - let confirmed = 1 - if currentNode.path.copyingWillOverwrite(newNodePath) - call s:echo("Warning: copying may overwrite files! Continue? (yN)") - let choice = nr2char(getchar()) - let confirmed = choice ==# 'y' - endif - - if confirmed - try - let newNode = currentNode.copy(newNodePath) - call NERDTreeRender() - call newNode.putCursorHere(0, 0) - catch /^NERDTree/ - call s:echoWarning("Could not copy node") - endtry - endif - else - call s:echo("Copy aborted.") - endif - redraw -endfunction - -" vim: set sw=4 sts=4 et fdm=marker: diff --git a/bundle/NERD_tree/plugin/NERD_tree.vim b/bundle/NERD_tree/plugin/NERD_tree.vim deleted file mode 100644 index 6411b1d..0000000 --- a/bundle/NERD_tree/plugin/NERD_tree.vim +++ /dev/null @@ -1,4059 +0,0 @@ -" ============================================================================ -" File: NERD_tree.vim -" Description: vim global plugin that provides a nice tree explorer -" Maintainer: Martin Grenfell -" Last Change: 1 December, 2009 -" License: This program is free software. It comes without any warranty, -" to the extent permitted by applicable law. You can redistribute -" it and/or modify it under the terms of the Do What The Fuck You -" Want To Public License, Version 2, as published by Sam Hocevar. -" See http://sam.zoy.org/wtfpl/COPYING for more details. -" -" ============================================================================ -let s:NERD_tree_version = '4.1.0' - -" SECTION: Script init stuff {{{1 -"============================================================ -if exists("loaded_nerd_tree") - finish -endif -if v:version < 700 - echoerr "NERDTree: this plugin requires vim >= 7. DOWNLOAD IT! You'll thank me later!" - finish -endif -let loaded_nerd_tree = 1 - -"for line continuation - i.e dont want C in &cpo -let s:old_cpo = &cpo -set cpo&vim - -"Function: s:initVariable() function {{{2 -"This function is used to initialise a given variable to a given value. The -"variable is only initialised if it does not exist prior -" -"Args: -"var: the name of the var to be initialised -"value: the value to initialise var to -" -"Returns: -"1 if the var is set, 0 otherwise -function! s:initVariable(var, value) - if !exists(a:var) - exec 'let ' . a:var . ' = ' . "'" . a:value . "'" - return 1 - endif - return 0 -endfunction - -"SECTION: Init variable calls and other random constants {{{2 -call s:initVariable("g:NERDChristmasTree", 1) -call s:initVariable("g:NERDTreeAutoCenter", 1) -call s:initVariable("g:NERDTreeAutoCenterThreshold", 3) -call s:initVariable("g:NERDTreeCaseSensitiveSort", 0) -call s:initVariable("g:NERDTreeChDirMode", 0) -if !exists("g:NERDTreeIgnore") - let g:NERDTreeIgnore = ['\~$'] -endif -call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks') -call s:initVariable("g:NERDTreeHighlightCursorline", 1) -call s:initVariable("g:NERDTreeHijackNetrw", 1) -call s:initVariable("g:NERDTreeMouseMode", 1) -call s:initVariable("g:NERDTreeNotificationThreshold", 100) -call s:initVariable("g:NERDTreeQuitOnOpen", 0) -call s:initVariable("g:NERDTreeShowBookmarks", 0) -call s:initVariable("g:NERDTreeShowFiles", 1) -call s:initVariable("g:NERDTreeShowHidden", 0) -call s:initVariable("g:NERDTreeShowLineNumbers", 0) -call s:initVariable("g:NERDTreeSortDirs", 1) - -if !exists("g:NERDTreeSortOrder") - let g:NERDTreeSortOrder = ['\/$', '*', '\.swp$', '\.bak$', '\~$'] -else - "if there isnt a * in the sort sequence then add one - if count(g:NERDTreeSortOrder, '*') < 1 - call add(g:NERDTreeSortOrder, '*') - endif -endif - -"we need to use this number many times for sorting... so we calculate it only -"once here -let s:NERDTreeSortStarIndex = index(g:NERDTreeSortOrder, '*') - -if !exists('g:NERDTreeStatusline') - - "the exists() crap here is a hack to stop vim spazzing out when - "loading a session that was created with an open nerd tree. It spazzes - "because it doesnt store b:NERDTreeRoot (its a b: var, and its a hash) - let g:NERDTreeStatusline = "%{exists('b:NERDTreeRoot')?b:NERDTreeRoot.path.str():''}" - -endif -call s:initVariable("g:NERDTreeWinPos", "left") -call s:initVariable("g:NERDTreeWinSize", 31) - -let s:running_windows = has("win16") || has("win32") || has("win64") - -"init the shell commands that will be used to copy nodes, and remove dir trees -" -"Note: the space after the command is important -if s:running_windows - call s:initVariable("g:NERDTreeRemoveDirCmd", 'rmdir /s /q ') -else - call s:initVariable("g:NERDTreeRemoveDirCmd", 'rm -rf ') - call s:initVariable("g:NERDTreeCopyCmd", 'cp -r ') -endif - - -"SECTION: Init variable calls for key mappings {{{2 -call s:initVariable("g:NERDTreeMapActivateNode", "o") -call s:initVariable("g:NERDTreeMapChangeRoot", "C") -call s:initVariable("g:NERDTreeMapChdir", "cd") -call s:initVariable("g:NERDTreeMapCloseChildren", "X") -call s:initVariable("g:NERDTreeMapCloseDir", "x") -call s:initVariable("g:NERDTreeMapDeleteBookmark", "D") -call s:initVariable("g:NERDTreeMapMenu", "m") -call s:initVariable("g:NERDTreeMapHelp", "?") -call s:initVariable("g:NERDTreeMapJumpFirstChild", "K") -call s:initVariable("g:NERDTreeMapJumpLastChild", "J") -call s:initVariable("g:NERDTreeMapJumpNextSibling", "") -call s:initVariable("g:NERDTreeMapJumpParent", "p") -call s:initVariable("g:NERDTreeMapJumpPrevSibling", "") -call s:initVariable("g:NERDTreeMapJumpRoot", "P") -call s:initVariable("g:NERDTreeMapOpenExpl", "e") -call s:initVariable("g:NERDTreeMapOpenInTab", "t") -call s:initVariable("g:NERDTreeMapOpenInTabSilent", "T") -call s:initVariable("g:NERDTreeMapOpenRecursively", "O") -call s:initVariable("g:NERDTreeMapOpenSplit", "i") -call s:initVariable("g:NERDTreeMapOpenVSplit", "s") -call s:initVariable("g:NERDTreeMapPreview", "g" . NERDTreeMapActivateNode) -call s:initVariable("g:NERDTreeMapPreviewSplit", "g" . NERDTreeMapOpenSplit) -call s:initVariable("g:NERDTreeMapPreviewVSplit", "g" . NERDTreeMapOpenVSplit) -call s:initVariable("g:NERDTreeMapQuit", "q") -call s:initVariable("g:NERDTreeMapRefresh", "r") -call s:initVariable("g:NERDTreeMapRefreshRoot", "R") -call s:initVariable("g:NERDTreeMapToggleBookmarks", "B") -call s:initVariable("g:NERDTreeMapToggleFiles", "F") -call s:initVariable("g:NERDTreeMapToggleFilters", "f") -call s:initVariable("g:NERDTreeMapToggleHidden", "I") -call s:initVariable("g:NERDTreeMapToggleZoom", "A") -call s:initVariable("g:NERDTreeMapUpdir", "u") -call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U") - -"SECTION: Script level variable declaration{{{2 -if s:running_windows - let s:escape_chars = " `\|\"#%&,?()\*^<>" -else - let s:escape_chars = " \\`\|\"#%&,?()\*^<>" -endif -let s:NERDTreeBufName = 'NERD_tree_' - -let s:tree_wid = 2 -let s:tree_markup_reg = '^[ `|]*[\-+~]' -let s:tree_up_dir_line = '.. (up a dir)' - -"the number to add to the nerd tree buffer name to make the buf name unique -let s:next_buffer_number = 1 - -" SECTION: Commands {{{1 -"============================================================ -"init the command that users start the nerd tree with -command! -n=? -complete=dir -bar NERDTree :call s:initNerdTree('') -command! -n=? -complete=dir -bar NERDTreeToggle :call s:toggle('') -command! -n=0 -bar NERDTreeClose :call s:closeTreeIfOpen() -command! -n=1 -complete=customlist,s:completeBookmarks -bar NERDTreeFromBookmark call s:initNerdTree('') -command! -n=0 -bar NERDTreeMirror call s:initNerdTreeMirror() -command! -n=0 -bar NERDTreeFind call s:findAndRevealPath() -" SECTION: Auto commands {{{1 -"============================================================ -augroup NERDTree - "Save the cursor position whenever we close the nerd tree - exec "autocmd BufWinLeave ". s:NERDTreeBufName ."* call saveScreenState()" - "cache bookmarks when vim loads - autocmd VimEnter * call s:Bookmark.CacheBookmarks(0) - - "load all nerdtree plugins after vim starts - autocmd VimEnter * runtime! nerdtree_plugin/**/*.vim -augroup END - -if g:NERDTreeHijackNetrw - augroup NERDTreeHijackNetrw - autocmd VimEnter * silent! autocmd! FileExplorer - au BufEnter,VimEnter * call s:checkForBrowse(expand("")) - augroup END -endif - -"SECTION: Classes {{{1 -"============================================================ -"CLASS: Bookmark {{{2 -"============================================================ -let s:Bookmark = {} -" FUNCTION: Bookmark.activate() {{{3 -function! s:Bookmark.activate() - if self.path.isDirectory - call self.toRoot() - else - if self.validate() - let n = s:TreeFileNode.New(self.path) - call n.open() - endif - endif -endfunction -" FUNCTION: Bookmark.AddBookmark(name, path) {{{3 -" Class method to add a new bookmark to the list, if a previous bookmark exists -" with the same name, just update the path for that bookmark -function! s:Bookmark.AddBookmark(name, path) - for i in s:Bookmark.Bookmarks() - if i.name ==# a:name - let i.path = a:path - return - endif - endfor - call add(s:Bookmark.Bookmarks(), s:Bookmark.New(a:name, a:path)) - call s:Bookmark.Sort() -endfunction -" Function: Bookmark.Bookmarks() {{{3 -" Class method to get all bookmarks. Lazily initializes the bookmarks global -" variable -function! s:Bookmark.Bookmarks() - if !exists("g:NERDTreeBookmarks") - let g:NERDTreeBookmarks = [] - endif - return g:NERDTreeBookmarks -endfunction -" Function: Bookmark.BookmarkExistsFor(name) {{{3 -" class method that returns 1 if a bookmark with the given name is found, 0 -" otherwise -function! s:Bookmark.BookmarkExistsFor(name) - try - call s:Bookmark.BookmarkFor(a:name) - return 1 - catch /^NERDTree.BookmarkNotFoundError/ - return 0 - endtry -endfunction -" Function: Bookmark.BookmarkFor(name) {{{3 -" Class method to get the bookmark that has the given name. {} is return if no -" bookmark is found -function! s:Bookmark.BookmarkFor(name) - for i in s:Bookmark.Bookmarks() - if i.name ==# a:name - return i - endif - endfor - throw "NERDTree.BookmarkNotFoundError: no bookmark found for name: \"". a:name .'"' -endfunction -" Function: Bookmark.BookmarkNames() {{{3 -" Class method to return an array of all bookmark names -function! s:Bookmark.BookmarkNames() - let names = [] - for i in s:Bookmark.Bookmarks() - call add(names, i.name) - endfor - return names -endfunction -" FUNCTION: Bookmark.CacheBookmarks(silent) {{{3 -" Class method to read all bookmarks from the bookmarks file intialize -" bookmark objects for each one. -" -" Args: -" silent - dont echo an error msg if invalid bookmarks are found -function! s:Bookmark.CacheBookmarks(silent) - if filereadable(g:NERDTreeBookmarksFile) - let g:NERDTreeBookmarks = [] - let g:NERDTreeInvalidBookmarks = [] - let bookmarkStrings = readfile(g:NERDTreeBookmarksFile) - let invalidBookmarksFound = 0 - for i in bookmarkStrings - - "ignore blank lines - if i != '' - - let name = substitute(i, '^\(.\{-}\) .*$', '\1', '') - let path = substitute(i, '^.\{-} \(.*\)$', '\1', '') - - try - let bookmark = s:Bookmark.New(name, s:Path.New(path)) - call add(g:NERDTreeBookmarks, bookmark) - catch /^NERDTree.InvalidArgumentsError/ - call add(g:NERDTreeInvalidBookmarks, i) - let invalidBookmarksFound += 1 - endtry - endif - endfor - if invalidBookmarksFound - call s:Bookmark.Write() - if !a:silent - call s:echo(invalidBookmarksFound . " invalid bookmarks were read. See :help NERDTreeInvalidBookmarks for info.") - endif - endif - call s:Bookmark.Sort() - endif -endfunction -" FUNCTION: Bookmark.compareTo(otherbookmark) {{{3 -" Compare these two bookmarks for sorting purposes -function! s:Bookmark.compareTo(otherbookmark) - return a:otherbookmark.name < self.name -endfunction -" FUNCTION: Bookmark.ClearAll() {{{3 -" Class method to delete all bookmarks. -function! s:Bookmark.ClearAll() - for i in s:Bookmark.Bookmarks() - call i.delete() - endfor - call s:Bookmark.Write() -endfunction -" FUNCTION: Bookmark.delete() {{{3 -" Delete this bookmark. If the node for this bookmark is under the current -" root, then recache bookmarks for its Path object -function! s:Bookmark.delete() - let node = {} - try - let node = self.getNode(1) - catch /^NERDTree.BookmarkedNodeNotFoundError/ - endtry - call remove(s:Bookmark.Bookmarks(), index(s:Bookmark.Bookmarks(), self)) - if !empty(node) - call node.path.cacheDisplayString() - endif - call s:Bookmark.Write() -endfunction -" FUNCTION: Bookmark.getNode(searchFromAbsoluteRoot) {{{3 -" Gets the treenode for this bookmark -" -" Args: -" searchFromAbsoluteRoot: specifies whether we should search from the current -" tree root, or the highest cached node -function! s:Bookmark.getNode(searchFromAbsoluteRoot) - let searchRoot = a:searchFromAbsoluteRoot ? s:TreeDirNode.AbsoluteTreeRoot() : b:NERDTreeRoot - let targetNode = searchRoot.findNode(self.path) - if empty(targetNode) - throw "NERDTree.BookmarkedNodeNotFoundError: no node was found for bookmark: " . self.name - endif - return targetNode -endfunction -" FUNCTION: Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) {{{3 -" Class method that finds the bookmark with the given name and returns the -" treenode for it. -function! s:Bookmark.GetNodeForName(name, searchFromAbsoluteRoot) - let bookmark = s:Bookmark.BookmarkFor(a:name) - return bookmark.getNode(a:searchFromAbsoluteRoot) -endfunction -" FUNCTION: Bookmark.GetSelected() {{{3 -" returns the Bookmark the cursor is over, or {} -function! s:Bookmark.GetSelected() - let line = getline(".") - let name = substitute(line, '^>\(.\{-}\) .\+$', '\1', '') - if name != line - try - return s:Bookmark.BookmarkFor(name) - catch /^NERDTree.BookmarkNotFoundError/ - return {} - endtry - endif - return {} -endfunction - -" Function: Bookmark.InvalidBookmarks() {{{3 -" Class method to get all invalid bookmark strings read from the bookmarks -" file -function! s:Bookmark.InvalidBookmarks() - if !exists("g:NERDTreeInvalidBookmarks") - let g:NERDTreeInvalidBookmarks = [] - endif - return g:NERDTreeInvalidBookmarks -endfunction -" FUNCTION: Bookmark.mustExist() {{{3 -function! s:Bookmark.mustExist() - if !self.path.exists() - call s:Bookmark.CacheBookmarks(1) - throw "NERDTree.BookmarkPointsToInvalidLocationError: the bookmark \"". - \ self.name ."\" points to a non existing location: \"". self.path.str() - endif -endfunction -" FUNCTION: Bookmark.New(name, path) {{{3 -" Create a new bookmark object with the given name and path object -function! s:Bookmark.New(name, path) - if a:name =~ ' ' - throw "NERDTree.IllegalBookmarkNameError: illegal name:" . a:name - endif - - let newBookmark = copy(self) - let newBookmark.name = a:name - let newBookmark.path = a:path - return newBookmark -endfunction -" FUNCTION: Bookmark.openInNewTab(options) {{{3 -" Create a new bookmark object with the given name and path object -function! s:Bookmark.openInNewTab(options) - let currentTab = tabpagenr() - if self.path.isDirectory - tabnew - call s:initNerdTree(self.name) - else - exec "tabedit " . bookmark.path.str({'format': 'Edit'}) - endif - - if has_key(a:options, 'stayInCurrentTab') - exec "tabnext " . currentTab - endif -endfunction -" Function: Bookmark.setPath(path) {{{3 -" makes this bookmark point to the given path -function! s:Bookmark.setPath(path) - let self.path = a:path -endfunction -" Function: Bookmark.Sort() {{{3 -" Class method that sorts all bookmarks -function! s:Bookmark.Sort() - let CompareFunc = function("s:compareBookmarks") - call sort(s:Bookmark.Bookmarks(), CompareFunc) -endfunction -" Function: Bookmark.str() {{{3 -" Get the string that should be rendered in the view for this bookmark -function! s:Bookmark.str() - let pathStrMaxLen = winwidth(s:getTreeWinNum()) - 4 - len(self.name) - if &nu - let pathStrMaxLen = pathStrMaxLen - &numberwidth - endif - - let pathStr = self.path.str({'format': 'UI'}) - if len(pathStr) > pathStrMaxLen - let pathStr = '<' . strpart(pathStr, len(pathStr) - pathStrMaxLen) - endif - return '>' . self.name . ' ' . pathStr -endfunction -" FUNCTION: Bookmark.toRoot() {{{3 -" Make the node for this bookmark the new tree root -function! s:Bookmark.toRoot() - if self.validate() - try - let targetNode = self.getNode(1) - catch /^NERDTree.BookmarkedNodeNotFoundError/ - let targetNode = s:TreeFileNode.New(s:Bookmark.BookmarkFor(self.name).path) - endtry - call targetNode.makeRoot() - call s:renderView() - call targetNode.putCursorHere(0, 0) - endif -endfunction -" FUNCTION: Bookmark.ToRoot(name) {{{3 -" Make the node for this bookmark the new tree root -function! s:Bookmark.ToRoot(name) - let bookmark = s:Bookmark.BookmarkFor(a:name) - call bookmark.toRoot() -endfunction - - -"FUNCTION: Bookmark.validate() {{{3 -function! s:Bookmark.validate() - if self.path.exists() - return 1 - else - call s:Bookmark.CacheBookmarks(1) - call s:renderView() - call s:echo(self.name . "now points to an invalid location. See :help NERDTreeInvalidBookmarks for info.") - return 0 - endif -endfunction - -" Function: Bookmark.Write() {{{3 -" Class method to write all bookmarks to the bookmarks file -function! s:Bookmark.Write() - let bookmarkStrings = [] - for i in s:Bookmark.Bookmarks() - call add(bookmarkStrings, i.name . ' ' . i.path.str()) - endfor - - "add a blank line before the invalid ones - call add(bookmarkStrings, "") - - for j in s:Bookmark.InvalidBookmarks() - call add(bookmarkStrings, j) - endfor - call writefile(bookmarkStrings, g:NERDTreeBookmarksFile) -endfunction -"CLASS: KeyMap {{{2 -"============================================================ -let s:KeyMap = {} -"FUNCTION: KeyMap.All() {{{3 -function! s:KeyMap.All() - if !exists("s:keyMaps") - let s:keyMaps = [] - endif - return s:keyMaps -endfunction - -"FUNCTION: KeyMap.BindAll() {{{3 -function! s:KeyMap.BindAll() - for i in s:KeyMap.All() - call i.bind() - endfor -endfunction - -"FUNCTION: KeyMap.bind() {{{3 -function! s:KeyMap.bind() - exec "nnoremap ". self.key ." :call ". self.callback ."()" -endfunction - -"FUNCTION: KeyMap.Create(options) {{{3 -function! s:KeyMap.Create(options) - let newKeyMap = copy(self) - let newKeyMap.key = a:options['key'] - let newKeyMap.quickhelpText = a:options['quickhelpText'] - let newKeyMap.callback = a:options['callback'] - call add(s:KeyMap.All(), newKeyMap) -endfunction -"CLASS: MenuController {{{2 -"============================================================ -let s:MenuController = {} -"FUNCTION: MenuController.New(menuItems) {{{3 -"create a new menu controller that operates on the given menu items -function! s:MenuController.New(menuItems) - let newMenuController = copy(self) - if a:menuItems[0].isSeparator() - let newMenuController.menuItems = a:menuItems[1:-1] - else - let newMenuController.menuItems = a:menuItems - endif - return newMenuController -endfunction - -"FUNCTION: MenuController.showMenu() {{{3 -"start the main loop of the menu and get the user to choose/execute a menu -"item -function! s:MenuController.showMenu() - call self._saveOptions() - - try - let self.selection = 0 - - let done = 0 - while !done - redraw! - call self._echoPrompt() - let key = nr2char(getchar()) - let done = self._handleKeypress(key) - endwhile - finally - call self._restoreOptions() - endtry - - if self.selection != -1 - let m = self._current() - call m.execute() - endif -endfunction - -"FUNCTION: MenuController._echoPrompt() {{{3 -function! s:MenuController._echoPrompt() - echo "NERDTree Menu. Use j/k/enter and the shortcuts indicated" - echo "==========================================================" - - for i in range(0, len(self.menuItems)-1) - if self.selection == i - echo "> " . self.menuItems[i].text - else - echo " " . self.menuItems[i].text - endif - endfor -endfunction - -"FUNCTION: MenuController._current(key) {{{3 -"get the MenuItem that is curently selected -function! s:MenuController._current() - return self.menuItems[self.selection] -endfunction - -"FUNCTION: MenuController._handleKeypress(key) {{{3 -"change the selection (if appropriate) and return 1 if the user has made -"their choice, 0 otherwise -function! s:MenuController._handleKeypress(key) - if a:key == 'j' - call self._cursorDown() - elseif a:key == 'k' - call self._cursorUp() - elseif a:key == nr2char(27) "escape - let self.selection = -1 - return 1 - elseif a:key == "\r" || a:key == "\n" "enter and ctrl-j - return 1 - else - let index = self._nextIndexFor(a:key) - if index != -1 - let self.selection = index - if len(self._allIndexesFor(a:key)) == 1 - return 1 - endif - endif - endif - - return 0 -endfunction - -"FUNCTION: MenuController._allIndexesFor(shortcut) {{{3 -"get indexes to all menu items with the given shortcut -function! s:MenuController._allIndexesFor(shortcut) - let toReturn = [] - - for i in range(0, len(self.menuItems)-1) - if self.menuItems[i].shortcut == a:shortcut - call add(toReturn, i) - endif - endfor - - return toReturn -endfunction - -"FUNCTION: MenuController._nextIndexFor(shortcut) {{{3 -"get the index to the next menu item with the given shortcut, starts from the -"current cursor location and wraps around to the top again if need be -function! s:MenuController._nextIndexFor(shortcut) - for i in range(self.selection+1, len(self.menuItems)-1) - if self.menuItems[i].shortcut == a:shortcut - return i - endif - endfor - - for i in range(0, self.selection) - if self.menuItems[i].shortcut == a:shortcut - return i - endif - endfor - - return -1 -endfunction - -"FUNCTION: MenuController._setCmdheight() {{{3 -"sets &cmdheight to whatever is needed to display the menu -function! s:MenuController._setCmdheight() - let &cmdheight = len(self.menuItems) + 3 -endfunction - -"FUNCTION: MenuController._saveOptions() {{{3 -"set any vim options that are required to make the menu work (saving their old -"values) -function! s:MenuController._saveOptions() - let self._oldLazyredraw = &lazyredraw - let self._oldCmdheight = &cmdheight - set nolazyredraw - call self._setCmdheight() -endfunction - -"FUNCTION: MenuController._restoreOptions() {{{3 -"restore the options we saved in _saveOptions() -function! s:MenuController._restoreOptions() - let &cmdheight = self._oldCmdheight - let &lazyredraw = self._oldLazyredraw -endfunction - -"FUNCTION: MenuController._cursorDown() {{{3 -"move the cursor to the next menu item, skipping separators -function! s:MenuController._cursorDown() - let done = 0 - while !done - if self.selection < len(self.menuItems)-1 - let self.selection += 1 - else - let self.selection = 0 - endif - - if !self._current().isSeparator() - let done = 1 - endif - endwhile -endfunction - -"FUNCTION: MenuController._cursorUp() {{{3 -"move the cursor to the previous menu item, skipping separators -function! s:MenuController._cursorUp() - let done = 0 - while !done - if self.selection > 0 - let self.selection -= 1 - else - let self.selection = len(self.menuItems)-1 - endif - - if !self._current().isSeparator() - let done = 1 - endif - endwhile -endfunction - -"CLASS: MenuItem {{{2 -"============================================================ -let s:MenuItem = {} -"FUNCTION: MenuItem.All() {{{3 -"get all top level menu items -function! s:MenuItem.All() - if !exists("s:menuItems") - let s:menuItems = [] - endif - return s:menuItems -endfunction - -"FUNCTION: MenuItem.AllEnabled() {{{3 -"get all top level menu items that are currently enabled -function! s:MenuItem.AllEnabled() - let toReturn = [] - for i in s:MenuItem.All() - if i.enabled() - call add(toReturn, i) - endif - endfor - return toReturn -endfunction - -"FUNCTION: MenuItem.Create(options) {{{3 -"make a new menu item and add it to the global list -function! s:MenuItem.Create(options) - let newMenuItem = copy(self) - - let newMenuItem.text = a:options['text'] - let newMenuItem.shortcut = a:options['shortcut'] - let newMenuItem.children = [] - - let newMenuItem.isActiveCallback = -1 - if has_key(a:options, 'isActiveCallback') - let newMenuItem.isActiveCallback = a:options['isActiveCallback'] - endif - - let newMenuItem.callback = -1 - if has_key(a:options, 'callback') - let newMenuItem.callback = a:options['callback'] - endif - - if has_key(a:options, 'parent') - call add(a:options['parent'].children, newMenuItem) - else - call add(s:MenuItem.All(), newMenuItem) - endif - - return newMenuItem -endfunction - -"FUNCTION: MenuItem.CreateSeparator(options) {{{3 -"make a new separator menu item and add it to the global list -function! s:MenuItem.CreateSeparator(options) - let standard_options = { 'text': '--------------------', - \ 'shortcut': -1, - \ 'callback': -1 } - let options = extend(a:options, standard_options, "force") - - return s:MenuItem.Create(options) -endfunction - -"FUNCTION: MenuItem.CreateSubmenu(options) {{{3 -"make a new submenu and add it to global list -function! s:MenuItem.CreateSubmenu(options) - let standard_options = { 'callback': -1 } - let options = extend(a:options, standard_options, "force") - - return s:MenuItem.Create(options) -endfunction - -"FUNCTION: MenuItem.enabled() {{{3 -"return 1 if this menu item should be displayed -" -"delegates off to the isActiveCallback, and defaults to 1 if no callback was -"specified -function! s:MenuItem.enabled() - if self.isActiveCallback != -1 - return {self.isActiveCallback}() - endif - return 1 -endfunction - -"FUNCTION: MenuItem.execute() {{{3 -"perform the action behind this menu item, if this menuitem has children then -"display a new menu for them, otherwise deletegate off to the menuitem's -"callback -function! s:MenuItem.execute() - if len(self.children) - let mc = s:MenuController.New(self.children) - call mc.showMenu() - else - if self.callback != -1 - call {self.callback}() - endif - endif -endfunction - -"FUNCTION: MenuItem.isSeparator() {{{3 -"return 1 if this menuitem is a separator -function! s:MenuItem.isSeparator() - return self.callback == -1 && self.children == [] -endfunction - -"FUNCTION: MenuItem.isSubmenu() {{{3 -"return 1 if this menuitem is a submenu -function! s:MenuItem.isSubmenu() - return self.callback == -1 && !empty(self.children) -endfunction - -"CLASS: TreeFileNode {{{2 -"This class is the parent of the TreeDirNode class and constitures the -"'Component' part of the composite design pattern between the treenode -"classes. -"============================================================ -let s:TreeFileNode = {} -"FUNCTION: TreeFileNode.activate(forceKeepWinOpen) {{{3 -function! s:TreeFileNode.activate(forceKeepWinOpen) - call self.open() - if !a:forceKeepWinOpen - call s:closeTreeIfQuitOnOpen() - end -endfunction -"FUNCTION: TreeFileNode.bookmark(name) {{{3 -"bookmark this node with a:name -function! s:TreeFileNode.bookmark(name) - try - let oldMarkedNode = s:Bookmark.GetNodeForName(a:name, 1) - call oldMarkedNode.path.cacheDisplayString() - catch /^NERDTree.BookmarkNotFoundError/ - endtry - - call s:Bookmark.AddBookmark(a:name, self.path) - call self.path.cacheDisplayString() - call s:Bookmark.Write() -endfunction -"FUNCTION: TreeFileNode.cacheParent() {{{3 -"initializes self.parent if it isnt already -function! s:TreeFileNode.cacheParent() - if empty(self.parent) - let parentPath = self.path.getParent() - if parentPath.equals(self.path) - throw "NERDTree.CannotCacheParentError: already at root" - endif - let self.parent = s:TreeFileNode.New(parentPath) - endif -endfunction -"FUNCTION: TreeFileNode.compareNodes {{{3 -"This is supposed to be a class level method but i cant figure out how to -"get func refs to work from a dict.. -" -"A class level method that compares two nodes -" -"Args: -"n1, n2: the 2 nodes to compare -function! s:compareNodes(n1, n2) - return a:n1.path.compareTo(a:n2.path) -endfunction - -"FUNCTION: TreeFileNode.clearBoomarks() {{{3 -function! s:TreeFileNode.clearBoomarks() - for i in s:Bookmark.Bookmarks() - if i.path.equals(self.path) - call i.delete() - end - endfor - call self.path.cacheDisplayString() -endfunction -"FUNCTION: TreeFileNode.copy(dest) {{{3 -function! s:TreeFileNode.copy(dest) - call self.path.copy(a:dest) - let newPath = s:Path.New(a:dest) - let parent = b:NERDTreeRoot.findNode(newPath.getParent()) - if !empty(parent) - call parent.refresh() - endif - return parent.findNode(newPath) -endfunction - -"FUNCTION: TreeFileNode.delete {{{3 -"Removes this node from the tree and calls the Delete method for its path obj -function! s:TreeFileNode.delete() - call self.path.delete() - call self.parent.removeChild(self) -endfunction - -"FUNCTION: TreeFileNode.displayString() {{{3 -" -"Returns a string that specifies how the node should be represented as a -"string -" -"Return: -"a string that can be used in the view to represent this node -function! s:TreeFileNode.displayString() - return self.path.displayString() -endfunction - -"FUNCTION: TreeFileNode.equals(treenode) {{{3 -" -"Compares this treenode to the input treenode and returns 1 if they are the -"same node. -" -"Use this method instead of == because sometimes when the treenodes contain -"many children, vim seg faults when doing == -" -"Args: -"treenode: the other treenode to compare to -function! s:TreeFileNode.equals(treenode) - return self.path.str() ==# a:treenode.path.str() -endfunction - -"FUNCTION: TreeFileNode.findNode(path) {{{3 -"Returns self if this node.path.Equals the given path. -"Returns {} if not equal. -" -"Args: -"path: the path object to compare against -function! s:TreeFileNode.findNode(path) - if a:path.equals(self.path) - return self - endif - return {} -endfunction -"FUNCTION: TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) {{{3 -" -"Finds the next sibling for this node in the indicated direction. This sibling -"must be a directory and may/may not have children as specified. -" -"Args: -"direction: 0 if you want to find the previous sibling, 1 for the next sibling -" -"Return: -"a treenode object or {} if no appropriate sibling could be found -function! s:TreeFileNode.findOpenDirSiblingWithVisibleChildren(direction) - "if we have no parent then we can have no siblings - if self.parent != {} - let nextSibling = self.findSibling(a:direction) - - while nextSibling != {} - if nextSibling.path.isDirectory && nextSibling.hasVisibleChildren() && nextSibling.isOpen - return nextSibling - endif - let nextSibling = nextSibling.findSibling(a:direction) - endwhile - endif - - return {} -endfunction -"FUNCTION: TreeFileNode.findSibling(direction) {{{3 -" -"Finds the next sibling for this node in the indicated direction -" -"Args: -"direction: 0 if you want to find the previous sibling, 1 for the next sibling -" -"Return: -"a treenode object or {} if no sibling could be found -function! s:TreeFileNode.findSibling(direction) - "if we have no parent then we can have no siblings - if self.parent != {} - - "get the index of this node in its parents children - let siblingIndx = self.parent.getChildIndex(self.path) - - if siblingIndx != -1 - "move a long to the next potential sibling node - let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1 - - "keep moving along to the next sibling till we find one that is valid - let numSiblings = self.parent.getChildCount() - while siblingIndx >= 0 && siblingIndx < numSiblings - - "if the next node is not an ignored node (i.e. wont show up in the - "view) then return it - if self.parent.children[siblingIndx].path.ignore() ==# 0 - return self.parent.children[siblingIndx] - endif - - "go to next node - let siblingIndx = a:direction ==# 1 ? siblingIndx+1 : siblingIndx-1 - endwhile - endif - endif - - return {} -endfunction - -"FUNCTION: TreeFileNode.getLineNum(){{{3 -"returns the line number this node is rendered on, or -1 if it isnt rendered -function! s:TreeFileNode.getLineNum() - "if the node is the root then return the root line no. - if self.isRoot() - return s:TreeFileNode.GetRootLineNum() - endif - - let totalLines = line("$") - - "the path components we have matched so far - let pathcomponents = [substitute(b:NERDTreeRoot.path.str({'format': 'UI'}), '/ *$', '', '')] - "the index of the component we are searching for - let curPathComponent = 1 - - let fullpath = self.path.str({'format': 'UI'}) - - - let lnum = s:TreeFileNode.GetRootLineNum() - while lnum > 0 - let lnum = lnum + 1 - "have we reached the bottom of the tree? - if lnum ==# totalLines+1 - return -1 - endif - - let curLine = getline(lnum) - - let indent = s:indentLevelFor(curLine) - if indent ==# curPathComponent - let curLine = s:stripMarkupFromLine(curLine, 1) - - let curPath = join(pathcomponents, '/') . '/' . curLine - if stridx(fullpath, curPath, 0) ==# 0 - if fullpath ==# curPath || strpart(fullpath, len(curPath)-1,1) ==# '/' - let curLine = substitute(curLine, '/ *$', '', '') - call add(pathcomponents, curLine) - let curPathComponent = curPathComponent + 1 - - if fullpath ==# curPath - return lnum - endif - endif - endif - endif - endwhile - return -1 -endfunction - -"FUNCTION: TreeFileNode.GetRootForTab(){{{3 -"get the root node for this tab -function! s:TreeFileNode.GetRootForTab() - if s:treeExistsForTab() - return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot') - end - return {} -endfunction -"FUNCTION: TreeFileNode.GetRootLineNum(){{{3 -"gets the line number of the root node -function! s:TreeFileNode.GetRootLineNum() - let rootLine = 1 - while getline(rootLine) !~ '^\(/\|<\)' - let rootLine = rootLine + 1 - endwhile - return rootLine -endfunction - -"FUNCTION: TreeFileNode.GetSelected() {{{3 -"gets the treenode that the cursor is currently over -function! s:TreeFileNode.GetSelected() - try - let path = s:getPath(line(".")) - if path ==# {} - return {} - endif - return b:NERDTreeRoot.findNode(path) - catch /NERDTree/ - return {} - endtry -endfunction -"FUNCTION: TreeFileNode.isVisible() {{{3 -"returns 1 if this node should be visible according to the tree filters and -"hidden file filters (and their on/off status) -function! s:TreeFileNode.isVisible() - return !self.path.ignore() -endfunction -"FUNCTION: TreeFileNode.isRoot() {{{3 -"returns 1 if this node is b:NERDTreeRoot -function! s:TreeFileNode.isRoot() - if !s:treeExistsForBuf() - throw "NERDTree.NoTreeError: No tree exists for the current buffer" - endif - - return self.equals(b:NERDTreeRoot) -endfunction - -"FUNCTION: TreeFileNode.makeRoot() {{{3 -"Make this node the root of the tree -function! s:TreeFileNode.makeRoot() - if self.path.isDirectory - let b:NERDTreeRoot = self - else - call self.cacheParent() - let b:NERDTreeRoot = self.parent - endif - - call b:NERDTreeRoot.open() - - "change dir to the dir of the new root if instructed to - if g:NERDTreeChDirMode ==# 2 - exec "cd " . b:NERDTreeRoot.path.str({'format': 'Edit'}) - endif -endfunction -"FUNCTION: TreeFileNode.New(path) {{{3 -"Returns a new TreeNode object with the given path and parent -" -"Args: -"path: a path object representing the full filesystem path to the file/dir that the node represents -function! s:TreeFileNode.New(path) - if a:path.isDirectory - return s:TreeDirNode.New(a:path) - else - let newTreeNode = copy(self) - let newTreeNode.path = a:path - let newTreeNode.parent = {} - return newTreeNode - endif -endfunction - -"FUNCTION: TreeFileNode.open() {{{3 -"Open the file represented by the given node in the current window, splitting -"the window if needed -" -"ARGS: -"treenode: file node to open -function! s:TreeFileNode.open() - if b:NERDTreeType ==# "secondary" - exec 'edit ' . self.path.str({'format': 'Edit'}) - return - endif - - "if the file is already open in this tab then just stick the cursor in it - let winnr = bufwinnr('^' . self.path.str() . '$') - if winnr != -1 - call s:exec(winnr . "wincmd w") - - else - if !s:isWindowUsable(winnr("#")) && s:firstUsableWindow() ==# -1 - call self.openSplit() - else - try - if !s:isWindowUsable(winnr("#")) - call s:exec(s:firstUsableWindow() . "wincmd w") - else - call s:exec('wincmd p') - endif - exec ("edit " . self.path.str({'format': 'Edit'})) - catch /^Vim\%((\a\+)\)\=:E37/ - call s:putCursorInTreeWin() - throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self.path.str() ." is already open and modified." - catch /^Vim\%((\a\+)\)\=:/ - echo v:exception - endtry - endif - endif -endfunction -"FUNCTION: TreeFileNode.openSplit() {{{3 -"Open this node in a new window -function! s:TreeFileNode.openSplit() - - if b:NERDTreeType ==# "secondary" - exec "split " . self.path.str({'format': 'Edit'}) - return - endif - - " Save the user's settings for splitbelow and splitright - let savesplitbelow=&splitbelow - let savesplitright=&splitright - - " 'there' will be set to a command to move from the split window - " back to the explorer window - " - " 'back' will be set to a command to move from the explorer window - " back to the newly split window - " - " 'right' and 'below' will be set to the settings needed for - " splitbelow and splitright IF the explorer is the only window. - " - let there= g:NERDTreeWinPos ==# "left" ? "wincmd h" : "wincmd l" - let back = g:NERDTreeWinPos ==# "left" ? "wincmd l" : "wincmd h" - let right= g:NERDTreeWinPos ==# "left" - let below=0 - - " Attempt to go to adjacent window - call s:exec(back) - - let onlyOneWin = (winnr("$") ==# 1) - - " If no adjacent window, set splitright and splitbelow appropriately - if onlyOneWin - let &splitright=right - let &splitbelow=below - else - " found adjacent window - invert split direction - let &splitright=!right - let &splitbelow=!below - endif - - let splitMode = onlyOneWin ? "vertical" : "" - - " Open the new window - try - exec(splitMode." sp " . self.path.str({'format': 'Edit'})) - catch /^Vim\%((\a\+)\)\=:E37/ - call s:putCursorInTreeWin() - throw "NERDTree.FileAlreadyOpenAndModifiedError: ". self.path.str() ." is already open and modified." - catch /^Vim\%((\a\+)\)\=:/ - "do nothing - endtry - - "resize the tree window if no other window was open before - if onlyOneWin - let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - call s:exec(there) - exec("silent ". splitMode ." resize ". size) - call s:exec('wincmd p') - endif - - " Restore splitmode settings - let &splitbelow=savesplitbelow - let &splitright=savesplitright -endfunction -"FUNCTION: TreeFileNode.openVSplit() {{{3 -"Open this node in a new vertical window -function! s:TreeFileNode.openVSplit() - if b:NERDTreeType ==# "secondary" - exec "vnew " . self.path.str({'format': 'Edit'}) - return - endif - - let winwidth = winwidth(".") - if winnr("$")==#1 - let winwidth = g:NERDTreeWinSize - endif - - call s:exec("wincmd p") - exec "vnew " . self.path.str({'format': 'Edit'}) - - "resize the nerd tree back to the original size - call s:putCursorInTreeWin() - exec("silent vertical resize ". winwidth) - call s:exec('wincmd p') -endfunction -"FUNCTION: TreeFileNode.openInNewTab(options) {{{3 -function! s:TreeFileNode.openInNewTab(options) - let currentTab = tabpagenr() - - if !has_key(a:options, 'keepTreeOpen') - call s:closeTreeIfQuitOnOpen() - endif - - exec "tabedit " . self.path.str({'format': 'Edit'}) - - if has_key(a:options, 'stayInCurrentTab') && a:options['stayInCurrentTab'] - exec "tabnext " . currentTab - endif - -endfunction -"FUNCTION: TreeFileNode.putCursorHere(isJump, recurseUpward){{{3 -"Places the cursor on the line number this node is rendered on -" -"Args: -"isJump: 1 if this cursor movement should be counted as a jump by vim -"recurseUpward: try to put the cursor on the parent if the this node isnt -"visible -function! s:TreeFileNode.putCursorHere(isJump, recurseUpward) - let ln = self.getLineNum() - if ln != -1 - if a:isJump - mark ' - endif - call cursor(ln, col(".")) - else - if a:recurseUpward - let node = self - while node != {} && node.getLineNum() ==# -1 - let node = node.parent - call node.open() - endwhile - call s:renderView() - call node.putCursorHere(a:isJump, 0) - endif - endif -endfunction - -"FUNCTION: TreeFileNode.refresh() {{{3 -function! s:TreeFileNode.refresh() - call self.path.refresh() -endfunction -"FUNCTION: TreeFileNode.rename() {{{3 -"Calls the rename method for this nodes path obj -function! s:TreeFileNode.rename(newName) - let newName = substitute(a:newName, '\(\\\|\/\)$', '', '') - call self.path.rename(newName) - call self.parent.removeChild(self) - - let parentPath = self.path.getParent() - let newParent = b:NERDTreeRoot.findNode(parentPath) - - if newParent != {} - call newParent.createChild(self.path, 1) - call newParent.refresh() - endif -endfunction -"FUNCTION: TreeFileNode.renderToString {{{3 -"returns a string representation for this tree to be rendered in the view -function! s:TreeFileNode.renderToString() - return self._renderToString(0, 0, [], self.getChildCount() ==# 1) -endfunction - - -"Args: -"depth: the current depth in the tree for this call -"drawText: 1 if we should actually draw the line for this node (if 0 then the -"child nodes are rendered only) -"vertMap: a binary array that indicates whether a vertical bar should be draw -"for each depth in the tree -"isLastChild:true if this curNode is the last child of its parent -function! s:TreeFileNode._renderToString(depth, drawText, vertMap, isLastChild) - let output = "" - if a:drawText ==# 1 - - let treeParts = '' - - "get all the leading spaces and vertical tree parts for this line - if a:depth > 1 - for j in a:vertMap[0:-2] - if j ==# 1 - let treeParts = treeParts . '| ' - else - let treeParts = treeParts . ' ' - endif - endfor - endif - - "get the last vertical tree part for this line which will be different - "if this node is the last child of its parent - if a:isLastChild - let treeParts = treeParts . '`' - else - let treeParts = treeParts . '|' - endif - - - "smack the appropriate dir/file symbol on the line before the file/dir - "name itself - if self.path.isDirectory - if self.isOpen - let treeParts = treeParts . '~' - else - let treeParts = treeParts . '+' - endif - else - let treeParts = treeParts . '-' - endif - let line = treeParts . self.displayString() - - let output = output . line . "\n" - endif - - "if the node is an open dir, draw its children - if self.path.isDirectory ==# 1 && self.isOpen ==# 1 - - let childNodesToDraw = self.getVisibleChildren() - if len(childNodesToDraw) > 0 - - "draw all the nodes children except the last - let lastIndx = len(childNodesToDraw)-1 - if lastIndx > 0 - for i in childNodesToDraw[0:lastIndx-1] - let output = output . i._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 1), 0) - endfor - endif - - "draw the last child, indicating that it IS the last - let output = output . childNodesToDraw[lastIndx]._renderToString(a:depth + 1, 1, add(copy(a:vertMap), 0), 1) - endif - endif - - return output -endfunction -"CLASS: TreeDirNode {{{2 -"This class is a child of the TreeFileNode class and constitutes the -"'Composite' part of the composite design pattern between the treenode -"classes. -"============================================================ -let s:TreeDirNode = copy(s:TreeFileNode) -"FUNCTION: TreeDirNode.AbsoluteTreeRoot(){{{3 -"class method that returns the highest cached ancestor of the current root -function! s:TreeDirNode.AbsoluteTreeRoot() - let currentNode = b:NERDTreeRoot - while currentNode.parent != {} - let currentNode = currentNode.parent - endwhile - return currentNode -endfunction -"FUNCTION: TreeDirNode.activate(forceKeepWinOpen) {{{3 -unlet s:TreeDirNode.activate -function! s:TreeDirNode.activate(forceKeepWinOpen) - call self.toggleOpen() - call s:renderView() - call self.putCursorHere(0, 0) -endfunction -"FUNCTION: TreeDirNode.addChild(treenode, inOrder) {{{3 -"Adds the given treenode to the list of children for this node -" -"Args: -"-treenode: the node to add -"-inOrder: 1 if the new node should be inserted in sorted order -function! s:TreeDirNode.addChild(treenode, inOrder) - call add(self.children, a:treenode) - let a:treenode.parent = self - - if a:inOrder - call self.sortChildren() - endif -endfunction - -"FUNCTION: TreeDirNode.close() {{{3 -"Closes this directory -function! s:TreeDirNode.close() - let self.isOpen = 0 -endfunction - -"FUNCTION: TreeDirNode.closeChildren() {{{3 -"Closes all the child dir nodes of this node -function! s:TreeDirNode.closeChildren() - for i in self.children - if i.path.isDirectory - call i.close() - call i.closeChildren() - endif - endfor -endfunction - -"FUNCTION: TreeDirNode.createChild(path, inOrder) {{{3 -"Instantiates a new child node for this node with the given path. The new -"nodes parent is set to this node. -" -"Args: -"path: a Path object that this node will represent/contain -"inOrder: 1 if the new node should be inserted in sorted order -" -"Returns: -"the newly created node -function! s:TreeDirNode.createChild(path, inOrder) - let newTreeNode = s:TreeFileNode.New(a:path) - call self.addChild(newTreeNode, a:inOrder) - return newTreeNode -endfunction - -"FUNCTION: TreeDirNode.findNode(path) {{{3 -"Will find one of the children (recursively) that has the given path -" -"Args: -"path: a path object -unlet s:TreeDirNode.findNode -function! s:TreeDirNode.findNode(path) - if a:path.equals(self.path) - return self - endif - if stridx(a:path.str(), self.path.str(), 0) ==# -1 - return {} - endif - - if self.path.isDirectory - for i in self.children - let retVal = i.findNode(a:path) - if retVal != {} - return retVal - endif - endfor - endif - return {} -endfunction -"FUNCTION: TreeDirNode.getChildCount() {{{3 -"Returns the number of children this node has -function! s:TreeDirNode.getChildCount() - return len(self.children) -endfunction - -"FUNCTION: TreeDirNode.getChild(path) {{{3 -"Returns child node of this node that has the given path or {} if no such node -"exists. -" -"This function doesnt not recurse into child dir nodes -" -"Args: -"path: a path object -function! s:TreeDirNode.getChild(path) - if stridx(a:path.str(), self.path.str(), 0) ==# -1 - return {} - endif - - let index = self.getChildIndex(a:path) - if index ==# -1 - return {} - else - return self.children[index] - endif - -endfunction - -"FUNCTION: TreeDirNode.getChildByIndex(indx, visible) {{{3 -"returns the child at the given index -"Args: -"indx: the index to get the child from -"visible: 1 if only the visible children array should be used, 0 if all the -"children should be searched. -function! s:TreeDirNode.getChildByIndex(indx, visible) - let array_to_search = a:visible? self.getVisibleChildren() : self.children - if a:indx > len(array_to_search) - throw "NERDTree.InvalidArgumentsError: Index is out of bounds." - endif - return array_to_search[a:indx] -endfunction - -"FUNCTION: TreeDirNode.getChildIndex(path) {{{3 -"Returns the index of the child node of this node that has the given path or -"-1 if no such node exists. -" -"This function doesnt not recurse into child dir nodes -" -"Args: -"path: a path object -function! s:TreeDirNode.getChildIndex(path) - if stridx(a:path.str(), self.path.str(), 0) ==# -1 - return -1 - endif - - "do a binary search for the child - let a = 0 - let z = self.getChildCount() - while a < z - let mid = (a+z)/2 - let diff = a:path.compareTo(self.children[mid].path) - - if diff ==# -1 - let z = mid - elseif diff ==# 1 - let a = mid+1 - else - return mid - endif - endwhile - return -1 -endfunction - -"FUNCTION: TreeDirNode.GetSelected() {{{3 -"Returns the current node if it is a dir node, or else returns the current -"nodes parent -unlet s:TreeDirNode.GetSelected -function! s:TreeDirNode.GetSelected() - let currentDir = s:TreeFileNode.GetSelected() - if currentDir != {} && !currentDir.isRoot() - if currentDir.path.isDirectory ==# 0 - let currentDir = currentDir.parent - endif - endif - return currentDir -endfunction -"FUNCTION: TreeDirNode.getVisibleChildCount() {{{3 -"Returns the number of visible children this node has -function! s:TreeDirNode.getVisibleChildCount() - return len(self.getVisibleChildren()) -endfunction - -"FUNCTION: TreeDirNode.getVisibleChildren() {{{3 -"Returns a list of children to display for this node, in the correct order -" -"Return: -"an array of treenodes -function! s:TreeDirNode.getVisibleChildren() - let toReturn = [] - for i in self.children - if i.path.ignore() ==# 0 - call add(toReturn, i) - endif - endfor - return toReturn -endfunction - -"FUNCTION: TreeDirNode.hasVisibleChildren() {{{3 -"returns 1 if this node has any childre, 0 otherwise.. -function! s:TreeDirNode.hasVisibleChildren() - return self.getVisibleChildCount() != 0 -endfunction - -"FUNCTION: TreeDirNode._initChildren() {{{3 -"Removes all childen from this node and re-reads them -" -"Args: -"silent: 1 if the function should not echo any "please wait" messages for -"large directories -" -"Return: the number of child nodes read -function! s:TreeDirNode._initChildren(silent) - "remove all the current child nodes - let self.children = [] - - "get an array of all the files in the nodes dir - let dir = self.path - let globDir = dir.str({'format': 'Glob'}) - let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') - let files = split(filesStr, "\n") - - if !a:silent && len(files) > g:NERDTreeNotificationThreshold - call s:echo("Please wait, caching a large dir ...") - endif - - let invalidFilesFound = 0 - for i in files - - "filter out the .. and . directories - "Note: we must match .. AND ../ cos sometimes the globpath returns - "../ for path with strange chars (eg $) - if i !~ '\/\.\.\/\?$' && i !~ '\/\.\/\?$' - - "put the next file in a new node and attach it - try - let path = s:Path.New(i) - call self.createChild(path, 0) - catch /^NERDTree.\(InvalidArguments\|InvalidFiletype\)Error/ - let invalidFilesFound += 1 - endtry - endif - endfor - - call self.sortChildren() - - if !a:silent && len(files) > g:NERDTreeNotificationThreshold - call s:echo("Please wait, caching a large dir ... DONE (". self.getChildCount() ." nodes cached).") - endif - - if invalidFilesFound - call s:echoWarning(invalidFilesFound . " file(s) could not be loaded into the NERD tree") - endif - return self.getChildCount() -endfunction -"FUNCTION: TreeDirNode.New(path) {{{3 -"Returns a new TreeNode object with the given path and parent -" -"Args: -"path: a path object representing the full filesystem path to the file/dir that the node represents -unlet s:TreeDirNode.New -function! s:TreeDirNode.New(path) - if a:path.isDirectory != 1 - throw "NERDTree.InvalidArgumentsError: A TreeDirNode object must be instantiated with a directory Path object." - endif - - let newTreeNode = copy(self) - let newTreeNode.path = a:path - - let newTreeNode.isOpen = 0 - let newTreeNode.children = [] - - let newTreeNode.parent = {} - - return newTreeNode -endfunction -"FUNCTION: TreeDirNode.open() {{{3 -"Reads in all this nodes children -" -"Return: the number of child nodes read -unlet s:TreeDirNode.open -function! s:TreeDirNode.open() - let self.isOpen = 1 - if self.children ==# [] - return self._initChildren(0) - else - return 0 - endif -endfunction - -" FUNCTION: TreeDirNode.openExplorer() {{{3 -" opens an explorer window for this node in the previous window (could be a -" nerd tree or a netrw) -function! s:TreeDirNode.openExplorer() - let oldwin = winnr() - call s:exec('wincmd p') - if oldwin ==# winnr() || (&modified && s:bufInWindows(winbufnr(winnr())) < 2) - call s:exec('wincmd p') - call self.openSplit() - else - exec ("silent edit " . self.path.str({'format': 'Edit'})) - endif -endfunction -"FUNCTION: TreeDirNode.openInNewTab(options) {{{3 -unlet s:TreeDirNode.openInNewTab -function! s:TreeDirNode.openInNewTab(options) - let currentTab = tabpagenr() - - if !has_key(a:options, 'keepTreeOpen') || !a:options['keepTreeOpen'] - call s:closeTreeIfQuitOnOpen() - endif - - tabnew - call s:initNerdTree(self.path.str()) - - if has_key(a:options, 'stayInCurrentTab') && a:options['stayInCurrentTab'] - exec "tabnext " . currentTab - endif -endfunction -"FUNCTION: TreeDirNode.openRecursively() {{{3 -"Opens this treenode and all of its children whose paths arent 'ignored' -"because of the file filters. -" -"This method is actually a wrapper for the OpenRecursively2 method which does -"the work. -function! s:TreeDirNode.openRecursively() - call self._openRecursively2(1) -endfunction - -"FUNCTION: TreeDirNode._openRecursively2() {{{3 -"Opens this all children of this treenode recursively if either: -" *they arent filtered by file filters -" *a:forceOpen is 1 -" -"Args: -"forceOpen: 1 if this node should be opened regardless of file filters -function! s:TreeDirNode._openRecursively2(forceOpen) - if self.path.ignore() ==# 0 || a:forceOpen - let self.isOpen = 1 - if self.children ==# [] - call self._initChildren(1) - endif - - for i in self.children - if i.path.isDirectory ==# 1 - call i._openRecursively2(0) - endif - endfor - endif -endfunction - -"FUNCTION: TreeDirNode.refresh() {{{3 -unlet s:TreeDirNode.refresh -function! s:TreeDirNode.refresh() - call self.path.refresh() - - "if this node was ever opened, refresh its children - if self.isOpen || !empty(self.children) - "go thru all the files/dirs under this node - let newChildNodes = [] - let invalidFilesFound = 0 - let dir = self.path - let globDir = dir.str({'format': 'Glob'}) - let filesStr = globpath(globDir, '*') . "\n" . globpath(globDir, '.*') - let files = split(filesStr, "\n") - for i in files - "filter out the .. and . directories - "Note: we must match .. AND ../ cos sometimes the globpath returns - "../ for path with strange chars (eg $) - if i !~ '\/\.\.\/\?$' && i !~ '\/\.\/\?$' - - try - "create a new path and see if it exists in this nodes children - let path = s:Path.New(i) - let newNode = self.getChild(path) - if newNode != {} - call newNode.refresh() - call add(newChildNodes, newNode) - - "the node doesnt exist so create it - else - let newNode = s:TreeFileNode.New(path) - let newNode.parent = self - call add(newChildNodes, newNode) - endif - - - catch /^NERDTree.InvalidArgumentsError/ - let invalidFilesFound = 1 - endtry - endif - endfor - - "swap this nodes children out for the children we just read/refreshed - let self.children = newChildNodes - call self.sortChildren() - - if invalidFilesFound - call s:echoWarning("some files could not be loaded into the NERD tree") - endif - endif -endfunction - -"FUNCTION: TreeDirNode.reveal(path) {{{3 -"reveal the given path, i.e. cache and open all treenodes needed to display it -"in the UI -function! s:TreeDirNode.reveal(path) - if !a:path.isUnder(self.path) - throw "NERDTree.InvalidArgumentsError: " . a:path.str() . " should be under " . self.path.str() - endif - - call self.open() - - if self.path.equals(a:path.getParent()) - let n = self.findNode(a:path) - call s:renderView() - call n.putCursorHere(1,0) - return - endif - - let p = a:path - while !p.getParent().equals(self.path) - let p = p.getParent() - endwhile - - let n = self.findNode(p) - call n.reveal(a:path) -endfunction -"FUNCTION: TreeDirNode.removeChild(treenode) {{{3 -" -"Removes the given treenode from this nodes set of children -" -"Args: -"treenode: the node to remove -" -"Throws a NERDTree.ChildNotFoundError if the given treenode is not found -function! s:TreeDirNode.removeChild(treenode) - for i in range(0, self.getChildCount()-1) - if self.children[i].equals(a:treenode) - call remove(self.children, i) - return - endif - endfor - - throw "NERDTree.ChildNotFoundError: child node was not found" -endfunction - -"FUNCTION: TreeDirNode.sortChildren() {{{3 -" -"Sorts the children of this node according to alphabetical order and the -"directory priority. -" -function! s:TreeDirNode.sortChildren() - let CompareFunc = function("s:compareNodes") - call sort(self.children, CompareFunc) -endfunction - -"FUNCTION: TreeDirNode.toggleOpen() {{{3 -"Opens this directory if it is closed and vice versa -function! s:TreeDirNode.toggleOpen() - if self.isOpen ==# 1 - call self.close() - else - call self.open() - endif -endfunction - -"FUNCTION: TreeDirNode.transplantChild(newNode) {{{3 -"Replaces the child of this with the given node (where the child node's full -"path matches a:newNode's fullpath). The search for the matching node is -"non-recursive -" -"Arg: -"newNode: the node to graft into the tree -function! s:TreeDirNode.transplantChild(newNode) - for i in range(0, self.getChildCount()-1) - if self.children[i].equals(a:newNode) - let self.children[i] = a:newNode - let a:newNode.parent = self - break - endif - endfor -endfunction -"============================================================ -"CLASS: Path {{{2 -"============================================================ -let s:Path = {} -"FUNCTION: Path.AbsolutePathFor(str) {{{3 -function! s:Path.AbsolutePathFor(str) - let prependCWD = 0 - if s:running_windows - let prependCWD = a:str !~ '^.:\(\\\|\/\)' - else - let prependCWD = a:str !~ '^/' - endif - - let toReturn = a:str - if prependCWD - let toReturn = getcwd() . s:Path.Slash() . a:str - endif - - return toReturn -endfunction -"FUNCTION: Path.bookmarkNames() {{{3 -function! s:Path.bookmarkNames() - if !exists("self._bookmarkNames") - call self.cacheDisplayString() - endif - return self._bookmarkNames -endfunction -"FUNCTION: Path.cacheDisplayString() {{{3 -function! s:Path.cacheDisplayString() - let self.cachedDisplayString = self.getLastPathComponent(1) - - if self.isExecutable - let self.cachedDisplayString = self.cachedDisplayString . '*' - endif - - let self._bookmarkNames = [] - for i in s:Bookmark.Bookmarks() - if i.path.equals(self) - call add(self._bookmarkNames, i.name) - endif - endfor - if !empty(self._bookmarkNames) - let self.cachedDisplayString .= ' {' . join(self._bookmarkNames) . '}' - endif - - if self.isSymLink - let self.cachedDisplayString .= ' -> ' . self.symLinkDest - endif - - if self.isReadOnly - let self.cachedDisplayString .= ' [RO]' - endif -endfunction -"FUNCTION: Path.changeToDir() {{{3 -function! s:Path.changeToDir() - let dir = self.str({'format': 'Cd'}) - if self.isDirectory ==# 0 - let dir = self.getParent().str({'format': 'Cd'}) - endif - - try - execute "cd " . dir - call s:echo("CWD is now: " . getcwd()) - catch - throw "NERDTree.PathChangeError: cannot change CWD to " . dir - endtry -endfunction - -"FUNCTION: Path.compareTo() {{{3 -" -"Compares this Path to the given path and returns 0 if they are equal, -1 if -"this Path is "less than" the given path, or 1 if it is "greater". -" -"Args: -"path: the path object to compare this to -" -"Return: -"1, -1 or 0 -function! s:Path.compareTo(path) - let thisPath = self.getLastPathComponent(1) - let thatPath = a:path.getLastPathComponent(1) - - "if the paths are the same then clearly we return 0 - if thisPath ==# thatPath - return 0 - endif - - let thisSS = self.getSortOrderIndex() - let thatSS = a:path.getSortOrderIndex() - - "compare the sort sequences, if they are different then the return - "value is easy - if thisSS < thatSS - return -1 - elseif thisSS > thatSS - return 1 - else - "if the sort sequences are the same then compare the paths - "alphabetically - let pathCompare = g:NERDTreeCaseSensitiveSort ? thisPath <# thatPath : thisPath limit - let toReturn = "<" . strpart(toReturn, len(toReturn) - limit + 1) - endif - endif - - return toReturn -endfunction - -"FUNCTION: Path._strForUI() {{{3 -function! s:Path._strForUI() - let toReturn = '/' . join(self.pathSegments, '/') - if self.isDirectory && toReturn != '/' - let toReturn = toReturn . '/' - endif - return toReturn -endfunction - -"FUNCTION: Path._strForCd() {{{3 -" -" returns a string that can be used with :cd -function! s:Path._strForCd() - return escape(self.str(), s:escape_chars) -endfunction -"FUNCTION: Path._strForEdit() {{{3 -" -"Return: the string for this path that is suitable to be used with the :edit -"command -function! s:Path._strForEdit() - let p = self.str({'format': 'UI'}) - let cwd = getcwd() - - if s:running_windows - let p = tolower(self.str()) - let cwd = tolower(getcwd()) - endif - - let p = escape(p, s:escape_chars) - - let cwd = cwd . s:Path.Slash() - - "return a relative path if we can - if stridx(p, cwd) ==# 0 - let p = strpart(p, strlen(cwd)) - endif - - if p ==# '' - let p = '.' - endif - - return p - -endfunction -"FUNCTION: Path._strForGlob() {{{3 -function! s:Path._strForGlob() - let lead = s:Path.Slash() - - "if we are running windows then slap a drive letter on the front - if s:running_windows - let lead = self.drive . '\' - endif - - let toReturn = lead . join(self.pathSegments, s:Path.Slash()) - - if !s:running_windows - let toReturn = escape(toReturn, s:escape_chars) - endif - return toReturn -endfunction -"FUNCTION: Path._str() {{{3 -" -"Gets the string path for this path object that is appropriate for the OS. -"EG, in windows c:\foo\bar -" in *nix /foo/bar -function! s:Path._str() - let lead = s:Path.Slash() - - "if we are running windows then slap a drive letter on the front - if s:running_windows - let lead = self.drive . '\' - endif - - return lead . join(self.pathSegments, s:Path.Slash()) -endfunction - -"FUNCTION: Path.strTrunk() {{{3 -"Gets the path without the last segment on the end. -function! s:Path.strTrunk() - return self.drive . '/' . join(self.pathSegments[0:-2], '/') -endfunction - -"FUNCTION: Path.WinToUnixPath(pathstr){{{3 -"Takes in a windows path and returns the unix equiv -" -"A class level method -" -"Args: -"pathstr: the windows path to convert -function! s:Path.WinToUnixPath(pathstr) - if !s:running_windows - return a:pathstr - endif - - let toReturn = a:pathstr - - "remove the x:\ of the front - let toReturn = substitute(toReturn, '^.*:\(\\\|/\)\?', '/', "") - - "convert all \ chars to / - let toReturn = substitute(toReturn, '\', '/', "g") - - return toReturn -endfunction - -" SECTION: General Functions {{{1 -"============================================================ -"FUNCTION: s:bufInWindows(bnum){{{2 -"[[STOLEN FROM VTREEEXPLORER.VIM]] -"Determine the number of windows open to this buffer number. -"Care of Yegappan Lakshman. Thanks! -" -"Args: -"bnum: the subject buffers buffer number -function! s:bufInWindows(bnum) - let cnt = 0 - let winnum = 1 - while 1 - let bufnum = winbufnr(winnum) - if bufnum < 0 - break - endif - if bufnum ==# a:bnum - let cnt = cnt + 1 - endif - let winnum = winnum + 1 - endwhile - - return cnt -endfunction " >>> -"FUNCTION: s:checkForBrowse(dir) {{{2 -"inits a secondary nerd tree in the current buffer if appropriate -function! s:checkForBrowse(dir) - if a:dir != '' && isdirectory(a:dir) - call s:initNerdTreeInPlace(a:dir) - endif -endfunction -"FUNCTION: s:compareBookmarks(first, second) {{{2 -"Compares two bookmarks -function! s:compareBookmarks(first, second) - return a:first.compareTo(a:second) -endfunction - -" FUNCTION: s:completeBookmarks(A,L,P) {{{2 -" completion function for the bookmark commands -function! s:completeBookmarks(A,L,P) - return filter(s:Bookmark.BookmarkNames(), 'v:val =~ "^' . a:A . '"') -endfunction -" FUNCTION: s:exec(cmd) {{{2 -" same as :exec cmd but eventignore=all is set for the duration -function! s:exec(cmd) - let old_ei = &ei - set ei=all - exec a:cmd - let &ei = old_ei -endfunction -" FUNCTION: s:findAndRevealPath() {{{2 -function! s:findAndRevealPath() - try - let p = s:Path.New(expand("%")) - catch /^NERDTree.InvalidArgumentsError/ - call s:echo("no file for the current buffer") - return - endtry - - if !s:treeExistsForTab() - call s:initNerdTree(p.getParent().str()) - else - if !p.isUnder(s:TreeFileNode.GetRootForTab().path) - call s:initNerdTree(p.getParent().str()) - else - if !s:isTreeOpen() - call s:toggle("") - endif - endif - endif - call s:putCursorInTreeWin() - call b:NERDTreeRoot.reveal(p) -endfunction -"FUNCTION: s:initNerdTree(name) {{{2 -"Initialise the nerd tree for this tab. The tree will start in either the -"given directory, or the directory associated with the given bookmark -" -"Args: -"name: the name of a bookmark or a directory -function! s:initNerdTree(name) - let path = {} - if s:Bookmark.BookmarkExistsFor(a:name) - let path = s:Bookmark.BookmarkFor(a:name).path - else - let dir = a:name ==# '' ? getcwd() : a:name - - "hack to get an absolute path if a relative path is given - if dir =~ '^\.' - let dir = getcwd() . s:Path.Slash() . dir - endif - let dir = resolve(dir) - - try - let path = s:Path.New(dir) - catch /^NERDTree.InvalidArgumentsError/ - call s:echo("No bookmark or directory found for: " . a:name) - return - endtry - endif - if !path.isDirectory - let path = path.getParent() - endif - - "if instructed to, then change the vim CWD to the dir the NERDTree is - "inited in - if g:NERDTreeChDirMode != 0 - call path.changeToDir() - endif - - if s:treeExistsForTab() - if s:isTreeOpen() - call s:closeTree() - endif - unlet t:NERDTreeBufName - endif - - let newRoot = s:TreeDirNode.New(path) - call newRoot.open() - - call s:createTreeWin() - let b:treeShowHelp = 0 - let b:NERDTreeIgnoreEnabled = 1 - let b:NERDTreeShowFiles = g:NERDTreeShowFiles - let b:NERDTreeShowHidden = g:NERDTreeShowHidden - let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks - let b:NERDTreeRoot = newRoot - - let b:NERDTreeType = "primary" - - call s:renderView() - call b:NERDTreeRoot.putCursorHere(0, 0) -endfunction - -"FUNCTION: s:initNerdTreeInPlace(dir) {{{2 -function! s:initNerdTreeInPlace(dir) - try - let path = s:Path.New(a:dir) - catch /^NERDTree.InvalidArgumentsError/ - call s:echo("Invalid directory name:" . a:name) - return - endtry - - "we want the directory buffer to disappear when we do the :edit below - setlocal bufhidden=wipe - - let previousBuf = expand("#") - - "we need a unique name for each secondary tree buffer to ensure they are - "all independent - exec "silent edit " . s:nextBufferName() - - let b:NERDTreePreviousBuf = bufnr(previousBuf) - - let b:NERDTreeRoot = s:TreeDirNode.New(path) - call b:NERDTreeRoot.open() - - "throwaway buffer options - setlocal noswapfile - setlocal buftype=nofile - setlocal bufhidden=hide - setlocal nowrap - setlocal foldcolumn=0 - setlocal nobuflisted - setlocal nospell - if g:NERDTreeShowLineNumbers - setlocal nu - else - setlocal nonu - endif - - iabc - - if g:NERDTreeHighlightCursorline - setlocal cursorline - endif - - call s:setupStatusline() - - let b:treeShowHelp = 0 - let b:NERDTreeIgnoreEnabled = 1 - let b:NERDTreeShowFiles = g:NERDTreeShowFiles - let b:NERDTreeShowHidden = g:NERDTreeShowHidden - let b:NERDTreeShowBookmarks = g:NERDTreeShowBookmarks - - let b:NERDTreeType = "secondary" - - call s:bindMappings() - setfiletype nerdtree - " syntax highlighting - if has("syntax") && exists("g:syntax_on") - call s:setupSyntaxHighlighting() - endif - - call s:renderView() -endfunction -" FUNCTION: s:initNerdTreeMirror() {{{2 -function! s:initNerdTreeMirror() - - "get the names off all the nerd tree buffers - let treeBufNames = [] - for i in range(1, tabpagenr("$")) - let nextName = s:tabpagevar(i, 'NERDTreeBufName') - if nextName != -1 && (!exists("t:NERDTreeBufName") || nextName != t:NERDTreeBufName) - call add(treeBufNames, nextName) - endif - endfor - let treeBufNames = s:unique(treeBufNames) - - "map the option names (that the user will be prompted with) to the nerd - "tree buffer names - let options = {} - let i = 0 - while i < len(treeBufNames) - let bufName = treeBufNames[i] - let treeRoot = getbufvar(bufName, "NERDTreeRoot") - let options[i+1 . '. ' . treeRoot.path.str() . ' (buf name: ' . bufName . ')'] = bufName - let i = i + 1 - endwhile - - "work out which tree to mirror, if there is more than 1 then ask the user - let bufferName = '' - if len(keys(options)) > 1 - let choices = ["Choose a tree to mirror"] - let choices = extend(choices, sort(keys(options))) - let choice = inputlist(choices) - if choice < 1 || choice > len(options) || choice ==# '' - return - endif - - let bufferName = options[sort(keys(options))[choice-1]] - elseif len(keys(options)) ==# 1 - let bufferName = values(options)[0] - else - call s:echo("No trees to mirror") - return - endif - - if s:treeExistsForTab() && s:isTreeOpen() - call s:closeTree() - endif - - let t:NERDTreeBufName = bufferName - call s:createTreeWin() - exec 'buffer ' . bufferName - if !&hidden - call s:renderView() - endif -endfunction -" FUNCTION: s:nextBufferName() {{{2 -" returns the buffer name for the next nerd tree -function! s:nextBufferName() - let name = s:NERDTreeBufName . s:next_buffer_number - let s:next_buffer_number += 1 - return name -endfunction -" FUNCTION: s:tabpagevar(tabnr, var) {{{2 -function! s:tabpagevar(tabnr, var) - let currentTab = tabpagenr() - let old_ei = &ei - set ei=all - - exec "tabnext " . a:tabnr - let v = -1 - if exists('t:' . a:var) - exec 'let v = t:' . a:var - endif - exec "tabnext " . currentTab - - let &ei = old_ei - - return v -endfunction -" Function: s:treeExistsForBuffer() {{{2 -" Returns 1 if a nerd tree root exists in the current buffer -function! s:treeExistsForBuf() - return exists("b:NERDTreeRoot") -endfunction -" Function: s:treeExistsForTab() {{{2 -" Returns 1 if a nerd tree root exists in the current tab -function! s:treeExistsForTab() - return exists("t:NERDTreeBufName") -endfunction -" Function: s:unique(list) {{{2 -" returns a:list without duplicates -function! s:unique(list) - let uniqlist = [] - for elem in a:list - if index(uniqlist, elem) ==# -1 - let uniqlist += [elem] - endif - endfor - return uniqlist -endfunction -" SECTION: Public API {{{1 -"============================================================ -let g:NERDTreePath = s:Path -let g:NERDTreeDirNode = s:TreeDirNode -let g:NERDTreeFileNode = s:TreeFileNode -let g:NERDTreeBookmark = s:Bookmark - -function! NERDTreeAddMenuItem(options) - call s:MenuItem.Create(a:options) -endfunction - -function! NERDTreeAddMenuSeparator(...) - let opts = a:0 ? a:1 : {} - call s:MenuItem.CreateSeparator(opts) -endfunction - -function! NERDTreeAddSubmenu(options) - return s:MenuItem.Create(a:options) -endfunction - -function! NERDTreeAddKeyMap(options) - call s:KeyMap.Create(a:options) -endfunction - -function! NERDTreeRender() - call s:renderView() -endfunction - -" SECTION: View Functions {{{1 -"============================================================ -"FUNCTION: s:centerView() {{{2 -"centers the nerd tree window around the cursor (provided the nerd tree -"options permit) -function! s:centerView() - if g:NERDTreeAutoCenter - let current_line = winline() - let lines_to_top = current_line - let lines_to_bottom = winheight(s:getTreeWinNum()) - current_line - if lines_to_top < g:NERDTreeAutoCenterThreshold || lines_to_bottom < g:NERDTreeAutoCenterThreshold - normal! zz - endif - endif -endfunction -"FUNCTION: s:closeTree() {{{2 -"Closes the primary NERD tree window for this tab -function! s:closeTree() - if !s:isTreeOpen() - throw "NERDTree.NoTreeFoundError: no NERDTree is open" - endif - - if winnr("$") != 1 - call s:exec(s:getTreeWinNum() . " wincmd w") - close - call s:exec("wincmd p") - else - close - endif -endfunction - -"FUNCTION: s:closeTreeIfOpen() {{{2 -"Closes the NERD tree window if it is open -function! s:closeTreeIfOpen() - if s:isTreeOpen() - call s:closeTree() - endif -endfunction -"FUNCTION: s:closeTreeIfQuitOnOpen() {{{2 -"Closes the NERD tree window if the close on open option is set -function! s:closeTreeIfQuitOnOpen() - if g:NERDTreeQuitOnOpen && s:isTreeOpen() - call s:closeTree() - endif -endfunction -"FUNCTION: s:createTreeWin() {{{2 -"Inits the NERD tree window. ie. opens it, sizes it, sets all the local -"options etc -function! s:createTreeWin() - "create the nerd tree window - let splitLocation = g:NERDTreeWinPos ==# "left" ? "topleft " : "botright " - let splitSize = g:NERDTreeWinSize - - if !exists('t:NERDTreeBufName') - let t:NERDTreeBufName = s:nextBufferName() - silent! exec splitLocation . 'vertical ' . splitSize . ' new' - silent! exec "edit " . t:NERDTreeBufName - else - silent! exec splitLocation . 'vertical ' . splitSize . ' split' - silent! exec "buffer " . t:NERDTreeBufName - endif - - setlocal winfixwidth - - "throwaway buffer options - setlocal noswapfile - setlocal buftype=nofile - setlocal nowrap - setlocal foldcolumn=0 - setlocal nobuflisted - setlocal nospell - if g:NERDTreeShowLineNumbers - setlocal nu - else - setlocal nonu - endif - - iabc - - if g:NERDTreeHighlightCursorline - setlocal cursorline - endif - - call s:setupStatusline() - - call s:bindMappings() - setfiletype nerdtree - " syntax highlighting - if has("syntax") && exists("g:syntax_on") - call s:setupSyntaxHighlighting() - endif -endfunction - -"FUNCTION: s:dumpHelp {{{2 -"prints out the quick help -function! s:dumpHelp() - let old_h = @h - if b:treeShowHelp ==# 1 - let @h= "\" NERD tree (" . s:NERD_tree_version . ") quickhelp~\n" - let @h=@h."\" ============================\n" - let @h=@h."\" File node mappings~\n" - let @h=@h."\" ". (g:NERDTreeMouseMode ==# 3 ? "single" : "double") ."-click,\n" - let @h=@h."\" ,\n" - if b:NERDTreeType ==# "primary" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in prev window\n" - else - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open in current window\n" - endif - if b:NERDTreeType ==# "primary" - let @h=@h."\" ". g:NERDTreeMapPreview .": preview\n" - endif - let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let @h=@h."\" middle-click,\n" - let @h=@h."\" ". g:NERDTreeMapOpenSplit .": open split\n" - let @h=@h."\" ". g:NERDTreeMapPreviewSplit .": preview split\n" - let @h=@h."\" ". g:NERDTreeMapOpenVSplit .": open vsplit\n" - let @h=@h."\" ". g:NERDTreeMapPreviewVSplit .": preview vsplit\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Directory node mappings~\n" - let @h=@h."\" ". (g:NERDTreeMouseMode ==# 1 ? "double" : "single") ."-click,\n" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open & close node\n" - let @h=@h."\" ". g:NERDTreeMapOpenRecursively .": recursively open node\n" - let @h=@h."\" ". g:NERDTreeMapCloseDir .": close parent of node\n" - let @h=@h."\" ". g:NERDTreeMapCloseChildren .": close all child nodes of\n" - let @h=@h."\" current node recursively\n" - let @h=@h."\" middle-click,\n" - let @h=@h."\" ". g:NERDTreeMapOpenExpl.": explore selected dir\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Bookmark table mappings~\n" - let @h=@h."\" double-click,\n" - let @h=@h."\" ". g:NERDTreeMapActivateNode .": open bookmark\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n" - let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n" - let @h=@h."\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Tree navigation mappings~\n" - let @h=@h."\" ". g:NERDTreeMapJumpRoot .": go to root\n" - let @h=@h."\" ". g:NERDTreeMapJumpParent .": go to parent\n" - let @h=@h."\" ". g:NERDTreeMapJumpFirstChild .": go to first child\n" - let @h=@h."\" ". g:NERDTreeMapJumpLastChild .": go to last child\n" - let @h=@h."\" ". g:NERDTreeMapJumpNextSibling .": go to next sibling\n" - let @h=@h."\" ". g:NERDTreeMapJumpPrevSibling .": go to prev sibling\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Filesystem mappings~\n" - let @h=@h."\" ". g:NERDTreeMapChangeRoot .": change tree root to the\n" - let @h=@h."\" selected dir\n" - let @h=@h."\" ". g:NERDTreeMapUpdir .": move tree root up a dir\n" - let @h=@h."\" ". g:NERDTreeMapUpdirKeepOpen .": move tree root up a dir\n" - let @h=@h."\" but leave old root open\n" - let @h=@h."\" ". g:NERDTreeMapRefresh .": refresh cursor dir\n" - let @h=@h."\" ". g:NERDTreeMapRefreshRoot .": refresh current root\n" - let @h=@h."\" ". g:NERDTreeMapMenu .": Show menu\n" - let @h=@h."\" ". g:NERDTreeMapChdir .":change the CWD to the\n" - let @h=@h."\" selected dir\n" - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Tree filtering mappings~\n" - let @h=@h."\" ". g:NERDTreeMapToggleHidden .": hidden files (" . (b:NERDTreeShowHidden ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleFilters .": file filters (" . (b:NERDTreeIgnoreEnabled ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleFiles .": files (" . (b:NERDTreeShowFiles ? "on" : "off") . ")\n" - let @h=@h."\" ". g:NERDTreeMapToggleBookmarks .": bookmarks (" . (b:NERDTreeShowBookmarks ? "on" : "off") . ")\n" - - "add quickhelp entries for each custom key map - if len(s:KeyMap.All()) - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Custom mappings~\n" - for i in s:KeyMap.All() - let @h=@h."\" ". i.key .": ". i.quickhelpText ."\n" - endfor - endif - - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Other mappings~\n" - let @h=@h."\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n" - let @h=@h."\" ". g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n" - let @h=@h."\" the NERDTree window\n" - let @h=@h."\" ". g:NERDTreeMapHelp .": toggle help\n" - let @h=@h."\"\n\" ----------------------------\n" - let @h=@h."\" Bookmark commands~\n" - let @h=@h."\" :Bookmark \n" - let @h=@h."\" :BookmarkToRoot \n" - let @h=@h."\" :RevealBookmark \n" - let @h=@h."\" :OpenBookmark \n" - let @h=@h."\" :ClearBookmarks []\n" - let @h=@h."\" :ClearAllBookmarks\n" - else - let @h="\" Press ". g:NERDTreeMapHelp ." for help\n" - endif - - silent! put h - - let @h = old_h -endfunction -"FUNCTION: s:echo {{{2 -"A wrapper for :echo. Appends 'NERDTree:' on the front of all messages -" -"Args: -"msg: the message to echo -function! s:echo(msg) - redraw - echomsg "NERDTree: " . a:msg -endfunction -"FUNCTION: s:echoWarning {{{2 -"Wrapper for s:echo, sets the message type to warningmsg for this message -"Args: -"msg: the message to echo -function! s:echoWarning(msg) - echohl warningmsg - call s:echo(a:msg) - echohl normal -endfunction -"FUNCTION: s:echoError {{{2 -"Wrapper for s:echo, sets the message type to errormsg for this message -"Args: -"msg: the message to echo -function! s:echoError(msg) - echohl errormsg - call s:echo(a:msg) - echohl normal -endfunction -"FUNCTION: s:firstUsableWindow(){{{2 -"find the window number of the first normal window -function! s:firstUsableWindow() - let i = 1 - while i <= winnr("$") - let bnum = winbufnr(i) - if bnum != -1 && getbufvar(bnum, '&buftype') ==# '' - \ && !getwinvar(i, '&previewwindow') - \ && (!getbufvar(bnum, '&modified') || &hidden) - return i - endif - - let i += 1 - endwhile - return -1 -endfunction -"FUNCTION: s:getPath(ln) {{{2 -"Gets the full path to the node that is rendered on the given line number -" -"Args: -"ln: the line number to get the path for -" -"Return: -"A path if a node was selected, {} if nothing is selected. -"If the 'up a dir' line was selected then the path to the parent of the -"current root is returned -function! s:getPath(ln) - let line = getline(a:ln) - - let rootLine = s:TreeFileNode.GetRootLineNum() - - "check to see if we have the root node - if a:ln == rootLine - return b:NERDTreeRoot.path - endif - - " in case called from outside the tree - if line !~ '^ *[|`]' || line =~ '^$' - return {} - endif - - if line ==# s:tree_up_dir_line - return b:NERDTreeRoot.path.getParent() - endif - - let indent = s:indentLevelFor(line) - - "remove the tree parts and the leading space - let curFile = s:stripMarkupFromLine(line, 0) - - let wasdir = 0 - if curFile =~ '/$' - let wasdir = 1 - let curFile = substitute(curFile, '/\?$', '/', "") - endif - - let dir = "" - let lnum = a:ln - while lnum > 0 - let lnum = lnum - 1 - let curLine = getline(lnum) - let curLineStripped = s:stripMarkupFromLine(curLine, 1) - - "have we reached the top of the tree? - if lnum == rootLine - let dir = b:NERDTreeRoot.path.str({'format': 'UI'}) . dir - break - endif - if curLineStripped =~ '/$' - let lpindent = s:indentLevelFor(curLine) - if lpindent < indent - let indent = indent - 1 - - let dir = substitute (curLineStripped,'^\\', "", "") . dir - continue - endif - endif - endwhile - let curFile = b:NERDTreeRoot.path.drive . dir . curFile - let toReturn = s:Path.New(curFile) - return toReturn -endfunction - -"FUNCTION: s:getTreeWinNum() {{{2 -"gets the nerd tree window number for this tab -function! s:getTreeWinNum() - if exists("t:NERDTreeBufName") - return bufwinnr(t:NERDTreeBufName) - else - return -1 - endif -endfunction -"FUNCTION: s:indentLevelFor(line) {{{2 -function! s:indentLevelFor(line) - return match(a:line, '[^ \-+~`|]') / s:tree_wid -endfunction -"FUNCTION: s:isTreeOpen() {{{2 -function! s:isTreeOpen() - return s:getTreeWinNum() != -1 -endfunction -"FUNCTION: s:isWindowUsable(winnumber) {{{2 -"Returns 0 if opening a file from the tree in the given window requires it to -"be split, 1 otherwise -" -"Args: -"winnumber: the number of the window in question -function! s:isWindowUsable(winnumber) - "gotta split if theres only one window (i.e. the NERD tree) - if winnr("$") ==# 1 - return 0 - endif - - let oldwinnr = winnr() - call s:exec(a:winnumber . "wincmd p") - let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow') - let modified = &modified - call s:exec(oldwinnr . "wincmd p") - - "if its a special window e.g. quickfix or another explorer plugin then we - "have to split - if specialWindow - return 0 - endif - - if &hidden - return 1 - endif - - return !modified || s:bufInWindows(winbufnr(a:winnumber)) >= 2 -endfunction - -" FUNCTION: s:jumpToChild(direction) {{{2 -" Args: -" direction: 0 if going to first child, 1 if going to last -function! s:jumpToChild(direction) - let currentNode = s:TreeFileNode.GetSelected() - if currentNode ==# {} || currentNode.isRoot() - call s:echo("cannot jump to " . (a:direction ? "last" : "first") . " child") - return - end - let dirNode = currentNode.parent - let childNodes = dirNode.getVisibleChildren() - - let targetNode = childNodes[0] - if a:direction - let targetNode = childNodes[len(childNodes) - 1] - endif - - if targetNode.equals(currentNode) - let siblingDir = currentNode.parent.findOpenDirSiblingWithVisibleChildren(a:direction) - if siblingDir != {} - let indx = a:direction ? siblingDir.getVisibleChildCount()-1 : 0 - let targetNode = siblingDir.getChildByIndex(indx, 1) - endif - endif - - call targetNode.putCursorHere(1, 0) - - call s:centerView() -endfunction - - -"FUNCTION: s:promptToDelBuffer(bufnum, msg){{{2 -"prints out the given msg and, if the user responds by pushing 'y' then the -"buffer with the given bufnum is deleted -" -"Args: -"bufnum: the buffer that may be deleted -"msg: a message that will be echoed to the user asking them if they wish to -" del the buffer -function! s:promptToDelBuffer(bufnum, msg) - echo a:msg - if nr2char(getchar()) ==# 'y' - exec "silent bdelete! " . a:bufnum - endif -endfunction - -"FUNCTION: s:putCursorOnBookmarkTable(){{{2 -"Places the cursor at the top of the bookmarks table -function! s:putCursorOnBookmarkTable() - if !b:NERDTreeShowBookmarks - throw "NERDTree.IllegalOperationError: cant find bookmark table, bookmarks arent active" - endif - - let rootNodeLine = s:TreeFileNode.GetRootLineNum() - - let line = 1 - while getline(line) !~ '^>-\+Bookmarks-\+$' - let line = line + 1 - if line >= rootNodeLine - throw "NERDTree.BookmarkTableNotFoundError: didnt find the bookmarks table" - endif - endwhile - call cursor(line, 0) -endfunction - -"FUNCTION: s:putCursorInTreeWin(){{{2 -"Places the cursor in the nerd tree window -function! s:putCursorInTreeWin() - if !s:isTreeOpen() - throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists" - endif - - call s:exec(s:getTreeWinNum() . "wincmd w") -endfunction - -"FUNCTION: s:renderBookmarks {{{2 -function! s:renderBookmarks() - - call setline(line(".")+1, ">----------Bookmarks----------") - call cursor(line(".")+1, col(".")) - - for i in s:Bookmark.Bookmarks() - call setline(line(".")+1, i.str()) - call cursor(line(".")+1, col(".")) - endfor - - call setline(line(".")+1, '') - call cursor(line(".")+1, col(".")) -endfunction -"FUNCTION: s:renderView {{{2 -"The entry function for rendering the tree -function! s:renderView() - setlocal modifiable - - "remember the top line of the buffer and the current line so we can - "restore the view exactly how it was - let curLine = line(".") - let curCol = col(".") - let topLine = line("w0") - - "delete all lines in the buffer (being careful not to clobber a register) - silent 1,$delete _ - - call s:dumpHelp() - - "delete the blank line before the help and add one after it - call setline(line(".")+1, "") - call cursor(line(".")+1, col(".")) - - if b:NERDTreeShowBookmarks - call s:renderBookmarks() - endif - - "add the 'up a dir' line - call setline(line(".")+1, s:tree_up_dir_line) - call cursor(line(".")+1, col(".")) - - "draw the header line - let header = b:NERDTreeRoot.path.str({'format': 'UI', 'truncateTo': winwidth(0)}) - call setline(line(".")+1, header) - call cursor(line(".")+1, col(".")) - - "draw the tree - let old_o = @o - let @o = b:NERDTreeRoot.renderToString() - silent put o - let @o = old_o - - "delete the blank line at the top of the buffer - silent 1,1delete _ - - "restore the view - let old_scrolloff=&scrolloff - let &scrolloff=0 - call cursor(topLine, 1) - normal! zt - call cursor(curLine, curCol) - let &scrolloff = old_scrolloff - - setlocal nomodifiable -endfunction - -"FUNCTION: s:renderViewSavingPosition {{{2 -"Renders the tree and ensures the cursor stays on the current node or the -"current nodes parent if it is no longer available upon re-rendering -function! s:renderViewSavingPosition() - let currentNode = s:TreeFileNode.GetSelected() - - "go up the tree till we find a node that will be visible or till we run - "out of nodes - while currentNode != {} && !currentNode.isVisible() && !currentNode.isRoot() - let currentNode = currentNode.parent - endwhile - - call s:renderView() - - if currentNode != {} - call currentNode.putCursorHere(0, 0) - endif -endfunction -"FUNCTION: s:restoreScreenState() {{{2 -" -"Sets the screen state back to what it was when s:saveScreenState was last -"called. -" -"Assumes the cursor is in the NERDTree window -function! s:restoreScreenState() - if !exists("b:NERDTreeOldTopLine") || !exists("b:NERDTreeOldPos") || !exists("b:NERDTreeOldWindowSize") - return - endif - exec("silent vertical resize ".b:NERDTreeOldWindowSize) - - let old_scrolloff=&scrolloff - let &scrolloff=0 - call cursor(b:NERDTreeOldTopLine, 0) - normal! zt - call setpos(".", b:NERDTreeOldPos) - let &scrolloff=old_scrolloff -endfunction - -"FUNCTION: s:saveScreenState() {{{2 -"Saves the current cursor position in the current buffer and the window -"scroll position -function! s:saveScreenState() - let win = winnr() - try - call s:putCursorInTreeWin() - let b:NERDTreeOldPos = getpos(".") - let b:NERDTreeOldTopLine = line("w0") - let b:NERDTreeOldWindowSize = winwidth("") - call s:exec(win . "wincmd w") - catch /^NERDTree.InvalidOperationError/ - endtry -endfunction - -"FUNCTION: s:setupStatusline() {{{2 -function! s:setupStatusline() - if g:NERDTreeStatusline != -1 - let &l:statusline = g:NERDTreeStatusline - endif -endfunction -"FUNCTION: s:setupSyntaxHighlighting() {{{2 -function! s:setupSyntaxHighlighting() - "treeFlags are syntax items that should be invisible, but give clues as to - "how things should be highlighted - syn match treeFlag #\~# - syn match treeFlag #\[RO\]# - - "highlighting for the .. (up dir) line at the top of the tree - execute "syn match treeUp #". s:tree_up_dir_line ."#" - - "highlighting for the ~/+ symbols for the directory nodes - syn match treeClosable #\~\<# - syn match treeClosable #\~\.# - syn match treeOpenable #+\<# - syn match treeOpenable #+\.#he=e-1 - - "highlighting for the tree structural parts - syn match treePart #|# - syn match treePart #`# - syn match treePartFile #[|`]-#hs=s+1 contains=treePart - - "quickhelp syntax elements - syn match treeHelpKey #" \{1,2\}[^ ]*:#hs=s+2,he=e-1 - syn match treeHelpKey #" \{1,2\}[^ ]*,#hs=s+2,he=e-1 - syn match treeHelpTitle #" .*\~#hs=s+2,he=e-1 contains=treeFlag - syn match treeToggleOn #".*(on)#hs=e-2,he=e-1 contains=treeHelpKey - syn match treeToggleOff #".*(off)#hs=e-3,he=e-1 contains=treeHelpKey - syn match treeHelpCommand #" :.\{-}\>#hs=s+3 - syn match treeHelp #^".*# contains=treeHelpKey,treeHelpTitle,treeFlag,treeToggleOff,treeToggleOn,treeHelpCommand - - "highlighting for readonly files - syn match treeRO #.*\[RO\]#hs=s+2 contains=treeFlag,treeBookmark,treePart,treePartFile - - "highlighting for sym links - syn match treeLink #[^-| `].* -> # contains=treeBookmark,treeOpenable,treeClosable,treeDirSlash - - "highlighing for directory nodes and file nodes - syn match treeDirSlash #/# - syn match treeDir #[^-| `].*/# contains=treeLink,treeDirSlash,treeOpenable,treeClosable - syn match treeExecFile #[|`]-.*\*\($\| \)# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark - syn match treeFile #|-.*# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark,treeExecFile - syn match treeFile #`-.*# contains=treeLink,treePart,treeRO,treePartFile,treeBookmark,treeExecFile - syn match treeCWD #^/.*$# - - "highlighting for bookmarks - syn match treeBookmark # {.*}#hs=s+1 - - "highlighting for the bookmarks table - syn match treeBookmarksLeader #^># - syn match treeBookmarksHeader #^>-\+Bookmarks-\+$# contains=treeBookmarksLeader - syn match treeBookmarkName #^>.\{-} #he=e-1 contains=treeBookmarksLeader - syn match treeBookmark #^>.*$# contains=treeBookmarksLeader,treeBookmarkName,treeBookmarksHeader - - if g:NERDChristmasTree - hi def link treePart Special - hi def link treePartFile Type - hi def link treeFile Normal - hi def link treeExecFile Title - hi def link treeDirSlash Identifier - hi def link treeClosable Type - else - hi def link treePart Normal - hi def link treePartFile Normal - hi def link treeFile Normal - hi def link treeClosable Title - endif - - hi def link treeBookmarksHeader statement - hi def link treeBookmarksLeader ignore - hi def link treeBookmarkName Identifier - hi def link treeBookmark normal - - hi def link treeHelp String - hi def link treeHelpKey Identifier - hi def link treeHelpCommand Identifier - hi def link treeHelpTitle Macro - hi def link treeToggleOn Question - hi def link treeToggleOff WarningMsg - - hi def link treeDir Directory - hi def link treeUp Directory - hi def link treeCWD Statement - hi def link treeLink Macro - hi def link treeOpenable Title - hi def link treeFlag ignore - hi def link treeRO WarningMsg - hi def link treeBookmark Statement - - hi def link NERDTreeCurrentNode Search -endfunction - -"FUNCTION: s:stripMarkupFromLine(line, removeLeadingSpaces){{{2 -"returns the given line with all the tree parts stripped off -" -"Args: -"line: the subject line -"removeLeadingSpaces: 1 if leading spaces are to be removed (leading spaces = -"any spaces before the actual text of the node) -function! s:stripMarkupFromLine(line, removeLeadingSpaces) - let line = a:line - "remove the tree parts and the leading space - let line = substitute (line, s:tree_markup_reg,"","") - - "strip off any read only flag - let line = substitute (line, ' \[RO\]', "","") - - "strip off any bookmark flags - let line = substitute (line, ' {[^}]*}', "","") - - "strip off any executable flags - let line = substitute (line, '*\ze\($\| \)', "","") - - let wasdir = 0 - if line =~ '/$' - let wasdir = 1 - endif - let line = substitute (line,' -> .*',"","") " remove link to - if wasdir ==# 1 - let line = substitute (line, '/\?$', '/', "") - endif - - if a:removeLeadingSpaces - let line = substitute (line, '^ *', '', '') - endif - - return line -endfunction - -"FUNCTION: s:toggle(dir) {{{2 -"Toggles the NERD tree. I.e the NERD tree is open, it is closed, if it is -"closed it is restored or initialized (if it doesnt exist) -" -"Args: -"dir: the full path for the root node (is only used if the NERD tree is being -"initialized. -function! s:toggle(dir) - if s:treeExistsForTab() - if !s:isTreeOpen() - call s:createTreeWin() - if !&hidden - call s:renderView() - endif - call s:restoreScreenState() - else - call s:closeTree() - endif - else - call s:initNerdTree(a:dir) - endif -endfunction -"SECTION: Interface bindings {{{1 -"============================================================ -"FUNCTION: s:activateNode(forceKeepWindowOpen) {{{2 -"If the current node is a file, open it in the previous window (or a new one -"if the previous is modified). If it is a directory then it is opened. -" -"args: -"forceKeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set -function! s:activateNode(forceKeepWindowOpen) - if getline(".") ==# s:tree_up_dir_line - return s:upDir(0) - endif - - let treenode = s:TreeFileNode.GetSelected() - if treenode != {} - call treenode.activate(a:forceKeepWindowOpen) - else - let bookmark = s:Bookmark.GetSelected() - if !empty(bookmark) - call bookmark.activate() - endif - endif -endfunction - -"FUNCTION: s:bindMappings() {{{2 -function! s:bindMappings() - " set up mappings and commands for this buffer - nnoremap :call handleMiddleMouse() - nnoremap :call checkForActivate() - nnoremap <2-leftmouse> :call activateNode(0) - - exec "nnoremap ". g:NERDTreeMapActivateNode . " :call activateNode(0)" - exec "nnoremap ". g:NERDTreeMapOpenSplit ." :call openEntrySplit(0,0)" - exec "nnoremap :call activateNode(0)" - - exec "nnoremap ". g:NERDTreeMapPreview ." :call previewNode(0)" - exec "nnoremap ". g:NERDTreeMapPreviewSplit ." :call previewNode(1)" - - exec "nnoremap ". g:NERDTreeMapOpenVSplit ." :call openEntrySplit(1,0)" - exec "nnoremap ". g:NERDTreeMapPreviewVSplit ." :call previewNode(2)" - - exec "nnoremap ". g:NERDTreeMapOpenRecursively ." :call openNodeRecursively()" - - exec "nnoremap ". g:NERDTreeMapUpdirKeepOpen ." :call upDir(1)" - exec "nnoremap ". g:NERDTreeMapUpdir ." :call upDir(0)" - exec "nnoremap ". g:NERDTreeMapChangeRoot ." :call chRoot()" - - exec "nnoremap ". g:NERDTreeMapChdir ." :call chCwd()" - - exec "nnoremap ". g:NERDTreeMapQuit ." :call closeTreeWindow()" - - exec "nnoremap ". g:NERDTreeMapRefreshRoot ." :call refreshRoot()" - exec "nnoremap ". g:NERDTreeMapRefresh ." :call refreshCurrent()" - - exec "nnoremap ". g:NERDTreeMapHelp ." :call displayHelp()" - exec "nnoremap ". g:NERDTreeMapToggleZoom ." :call toggleZoom()" - exec "nnoremap ". g:NERDTreeMapToggleHidden ." :call toggleShowHidden()" - exec "nnoremap ". g:NERDTreeMapToggleFilters ." :call toggleIgnoreFilter()" - exec "nnoremap ". g:NERDTreeMapToggleFiles ." :call toggleShowFiles()" - exec "nnoremap ". g:NERDTreeMapToggleBookmarks ." :call toggleShowBookmarks()" - - exec "nnoremap ". g:NERDTreeMapCloseDir ." :call closeCurrentDir()" - exec "nnoremap ". g:NERDTreeMapCloseChildren ." :call closeChildren()" - - exec "nnoremap ". g:NERDTreeMapMenu ." :call showMenu()" - - exec "nnoremap ". g:NERDTreeMapJumpParent ." :call jumpToParent()" - exec "nnoremap ". g:NERDTreeMapJumpNextSibling ." :call jumpToSibling(1)" - exec "nnoremap ". g:NERDTreeMapJumpPrevSibling ." :call jumpToSibling(0)" - exec "nnoremap ". g:NERDTreeMapJumpFirstChild ." :call jumpToFirstChild()" - exec "nnoremap ". g:NERDTreeMapJumpLastChild ." :call jumpToLastChild()" - exec "nnoremap ". g:NERDTreeMapJumpRoot ." :call jumpToRoot()" - - exec "nnoremap ". g:NERDTreeMapOpenInTab ." :call openInNewTab(0)" - exec "nnoremap ". g:NERDTreeMapOpenInTabSilent ." :call openInNewTab(1)" - - exec "nnoremap ". g:NERDTreeMapOpenExpl ." :call openExplorer()" - - exec "nnoremap ". g:NERDTreeMapDeleteBookmark ." :call deleteBookmark()" - - "bind all the user custom maps - call s:KeyMap.BindAll() - - command! -buffer -nargs=1 Bookmark :call bookmarkNode('') - command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 RevealBookmark :call revealBookmark('') - command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 OpenBookmark :call openBookmark('') - command! -buffer -complete=customlist,s:completeBookmarks -nargs=* ClearBookmarks call clearBookmarks('') - command! -buffer -complete=customlist,s:completeBookmarks -nargs=+ BookmarkToRoot call s:Bookmark.ToRoot('') - command! -buffer -nargs=0 ClearAllBookmarks call s:Bookmark.ClearAll() call renderView() - command! -buffer -nargs=0 ReadBookmarks call s:Bookmark.CacheBookmarks(0) call renderView() - command! -buffer -nargs=0 WriteBookmarks call s:Bookmark.Write() -endfunction - -" FUNCTION: s:bookmarkNode(name) {{{2 -" Associate the current node with the given name -function! s:bookmarkNode(name) - let currentNode = s:TreeFileNode.GetSelected() - if currentNode != {} - try - call currentNode.bookmark(a:name) - call s:renderView() - catch /^NERDTree.IllegalBookmarkNameError/ - call s:echo("bookmark names must not contain spaces") - endtry - else - call s:echo("select a node first") - endif -endfunction -"FUNCTION: s:checkForActivate() {{{2 -"Checks if the click should open the current node, if so then activate() is -"called (directories are automatically opened if the symbol beside them is -"clicked) -function! s:checkForActivate() - let currentNode = s:TreeFileNode.GetSelected() - if currentNode != {} - let startToCur = strpart(getline(line(".")), 0, col(".")) - let char = strpart(startToCur, strlen(startToCur)-1, 1) - - "if they clicked a dir, check if they clicked on the + or ~ sign - "beside it - if currentNode.path.isDirectory - if startToCur =~ s:tree_markup_reg . '$' && char =~ '[+~]' - call s:activateNode(0) - return - endif - endif - - if (g:NERDTreeMouseMode ==# 2 && currentNode.path.isDirectory) || g:NERDTreeMouseMode ==# 3 - if char !~ s:tree_markup_reg && startToCur !~ '\/$' - call s:activateNode(0) - return - endif - endif - endif -endfunction - -" FUNCTION: s:chCwd() {{{2 -function! s:chCwd() - let treenode = s:TreeFileNode.GetSelected() - if treenode ==# {} - call s:echo("Select a node first") - return - endif - - try - call treenode.path.changeToDir() - catch /^NERDTree.PathChangeError/ - call s:echoWarning("could not change cwd") - endtry -endfunction - -" FUNCTION: s:chRoot() {{{2 -" changes the current root to the selected one -function! s:chRoot() - let treenode = s:TreeFileNode.GetSelected() - if treenode ==# {} - call s:echo("Select a node first") - return - endif - - call treenode.makeRoot() - call s:renderView() - call b:NERDTreeRoot.putCursorHere(0, 0) -endfunction - -" FUNCTION: s:clearBookmarks(bookmarks) {{{2 -function! s:clearBookmarks(bookmarks) - if a:bookmarks ==# '' - let currentNode = s:TreeFileNode.GetSelected() - if currentNode != {} - call currentNode.clearBoomarks() - endif - else - for name in split(a:bookmarks, ' ') - let bookmark = s:Bookmark.BookmarkFor(name) - call bookmark.delete() - endfor - endif - call s:renderView() -endfunction -" FUNCTION: s:closeChildren() {{{2 -" closes all childnodes of the current node -function! s:closeChildren() - let currentNode = s:TreeDirNode.GetSelected() - if currentNode ==# {} - call s:echo("Select a node first") - return - endif - - call currentNode.closeChildren() - call s:renderView() - call currentNode.putCursorHere(0, 0) -endfunction -" FUNCTION: s:closeCurrentDir() {{{2 -" closes the parent dir of the current node -function! s:closeCurrentDir() - let treenode = s:TreeFileNode.GetSelected() - if treenode ==# {} - call s:echo("Select a node first") - return - endif - - let parent = treenode.parent - if parent ==# {} || parent.isRoot() - call s:echo("cannot close tree root") - else - call treenode.parent.close() - call s:renderView() - call treenode.parent.putCursorHere(0, 0) - endif -endfunction -" FUNCTION: s:closeTreeWindow() {{{2 -" close the tree window -function! s:closeTreeWindow() - if b:NERDTreeType ==# "secondary" && b:NERDTreePreviousBuf != -1 - exec "buffer " . b:NERDTreePreviousBuf - else - if winnr("$") > 1 - call s:closeTree() - else - call s:echo("Cannot close last window") - endif - endif -endfunction -" FUNCTION: s:deleteBookmark() {{{2 -" if the cursor is on a bookmark, prompt to delete -function! s:deleteBookmark() - let bookmark = s:Bookmark.GetSelected() - if bookmark ==# {} - call s:echo("Put the cursor on a bookmark") - return - endif - - echo "Are you sure you wish to delete the bookmark:\n\"" . bookmark.name . "\" (yN):" - - if nr2char(getchar()) ==# 'y' - try - call bookmark.delete() - call s:renderView() - redraw - catch /^NERDTree/ - call s:echoWarning("Could not remove bookmark") - endtry - else - call s:echo("delete aborted" ) - endif - -endfunction - -" FUNCTION: s:displayHelp() {{{2 -" toggles the help display -function! s:displayHelp() - let b:treeShowHelp = b:treeShowHelp ? 0 : 1 - call s:renderView() - call s:centerView() -endfunction - -" FUNCTION: s:handleMiddleMouse() {{{2 -function! s:handleMiddleMouse() - let curNode = s:TreeFileNode.GetSelected() - if curNode ==# {} - call s:echo("Put the cursor on a node first" ) - return - endif - - if curNode.path.isDirectory - call s:openExplorer() - else - call s:openEntrySplit(0,0) - endif -endfunction - - -" FUNCTION: s:jumpToFirstChild() {{{2 -" wrapper for the jump to child method -function! s:jumpToFirstChild() - call s:jumpToChild(0) -endfunction - -" FUNCTION: s:jumpToLastChild() {{{2 -" wrapper for the jump to child method -function! s:jumpToLastChild() - call s:jumpToChild(1) -endfunction - -" FUNCTION: s:jumpToParent() {{{2 -" moves the cursor to the parent of the current node -function! s:jumpToParent() - let currentNode = s:TreeFileNode.GetSelected() - if !empty(currentNode) - if !empty(currentNode.parent) - call currentNode.parent.putCursorHere(1, 0) - call s:centerView() - else - call s:echo("cannot jump to parent") - endif - else - call s:echo("put the cursor on a node first") - endif -endfunction - -" FUNCTION: s:jumpToRoot() {{{2 -" moves the cursor to the root node -function! s:jumpToRoot() - call b:NERDTreeRoot.putCursorHere(1, 0) - call s:centerView() -endfunction - -" FUNCTION: s:jumpToSibling() {{{2 -" moves the cursor to the sibling of the current node in the given direction -" -" Args: -" forward: 1 if the cursor should move to the next sibling, 0 if it should -" move back to the previous sibling -function! s:jumpToSibling(forward) - let currentNode = s:TreeFileNode.GetSelected() - if !empty(currentNode) - let sibling = currentNode.findSibling(a:forward) - - if !empty(sibling) - call sibling.putCursorHere(1, 0) - call s:centerView() - endif - else - call s:echo("put the cursor on a node first") - endif -endfunction - -" FUNCTION: s:openBookmark(name) {{{2 -" put the cursor on the given bookmark and, if its a file, open it -function! s:openBookmark(name) - try - let targetNode = s:Bookmark.GetNodeForName(a:name, 0) - call targetNode.putCursorHere(0, 1) - redraw! - catch /^NERDTree.BookmarkedNodeNotFoundError/ - call s:echo("note - target node is not cached") - let bookmark = s:Bookmark.BookmarkFor(a:name) - let targetNode = s:TreeFileNode.New(bookmark.path) - endtry - if targetNode.path.isDirectory - call targetNode.openExplorer() - else - call targetNode.open() - endif -endfunction -" FUNCTION: s:openEntrySplit(vertical, forceKeepWindowOpen) {{{2 -"Opens the currently selected file from the explorer in a -"new window -" -"args: -"forceKeepWindowOpen - dont close the window even if NERDTreeQuitOnOpen is set -function! s:openEntrySplit(vertical, forceKeepWindowOpen) - let treenode = s:TreeFileNode.GetSelected() - if treenode != {} - if a:vertical - call treenode.openVSplit() - else - call treenode.openSplit() - endif - if !a:forceKeepWindowOpen - call s:closeTreeIfQuitOnOpen() - endif - else - call s:echo("select a node first") - endif -endfunction - -" FUNCTION: s:openExplorer() {{{2 -function! s:openExplorer() - let treenode = s:TreeDirNode.GetSelected() - if treenode != {} - call treenode.openExplorer() - else - call s:echo("select a node first") - endif -endfunction - -" FUNCTION: s:openInNewTab(stayCurrentTab) {{{2 -" Opens the selected node or bookmark in a new tab -" Args: -" stayCurrentTab: if 1 then vim will stay in the current tab, if 0 then vim -" will go to the tab where the new file is opened -function! s:openInNewTab(stayCurrentTab) - let target = s:TreeFileNode.GetSelected() - if target == {} - let target = s:Bookmark.GetSelected() - endif - - if target != {} - call target.openInNewTab({'stayInCurrentTab': a:stayCurrentTab}) - endif -endfunction - -" FUNCTION: s:openNodeRecursively() {{{2 -function! s:openNodeRecursively() - let treenode = s:TreeFileNode.GetSelected() - if treenode ==# {} || treenode.path.isDirectory ==# 0 - call s:echo("Select a directory node first" ) - else - call s:echo("Recursively opening node. Please wait...") - call treenode.openRecursively() - call s:renderView() - redraw - call s:echo("Recursively opening node. Please wait... DONE") - endif - -endfunction - -"FUNCTION: s:previewNode() {{{2 -"Args: -" openNewWin: if 0, use the previous window, if 1 open in new split, if 2 -" open in a vsplit -function! s:previewNode(openNewWin) - let currentBuf = bufnr("") - if a:openNewWin > 0 - call s:openEntrySplit(a:openNewWin ==# 2,1) - else - call s:activateNode(1) - end - call s:exec(bufwinnr(currentBuf) . "wincmd w") -endfunction - -" FUNCTION: s:revealBookmark(name) {{{2 -" put the cursor on the node associate with the given name -function! s:revealBookmark(name) - try - let targetNode = s:Bookmark.GetNodeForName(a:name, 0) - call targetNode.putCursorHere(0, 1) - catch /^NERDTree.BookmarkNotFoundError/ - call s:echo("Bookmark isnt cached under the current root") - endtry -endfunction -" FUNCTION: s:refreshRoot() {{{2 -" Reloads the current root. All nodes below this will be lost and the root dir -" will be reloaded. -function! s:refreshRoot() - call s:echo("Refreshing the root node. This could take a while...") - call b:NERDTreeRoot.refresh() - call s:renderView() - redraw - call s:echo("Refreshing the root node. This could take a while... DONE") -endfunction - -" FUNCTION: s:refreshCurrent() {{{2 -" refreshes the root for the current node -function! s:refreshCurrent() - let treenode = s:TreeDirNode.GetSelected() - if treenode ==# {} - call s:echo("Refresh failed. Select a node first") - return - endif - - call s:echo("Refreshing node. This could take a while...") - call treenode.refresh() - call s:renderView() - redraw - call s:echo("Refreshing node. This could take a while... DONE") -endfunction -" FUNCTION: s:showMenu() {{{2 -function! s:showMenu() - let curNode = s:TreeFileNode.GetSelected() - if curNode ==# {} - call s:echo("Put the cursor on a node first" ) - return - endif - - let mc = s:MenuController.New(s:MenuItem.AllEnabled()) - call mc.showMenu() -endfunction - -" FUNCTION: s:toggleIgnoreFilter() {{{2 -" toggles the use of the NERDTreeIgnore option -function! s:toggleIgnoreFilter() - let b:NERDTreeIgnoreEnabled = !b:NERDTreeIgnoreEnabled - call s:renderViewSavingPosition() - call s:centerView() -endfunction - -" FUNCTION: s:toggleShowBookmarks() {{{2 -" toggles the display of bookmarks -function! s:toggleShowBookmarks() - let b:NERDTreeShowBookmarks = !b:NERDTreeShowBookmarks - if b:NERDTreeShowBookmarks - call s:renderView() - call s:putCursorOnBookmarkTable() - else - call s:renderViewSavingPosition() - endif - call s:centerView() -endfunction -" FUNCTION: s:toggleShowFiles() {{{2 -" toggles the display of hidden files -function! s:toggleShowFiles() - let b:NERDTreeShowFiles = !b:NERDTreeShowFiles - call s:renderViewSavingPosition() - call s:centerView() -endfunction - -" FUNCTION: s:toggleShowHidden() {{{2 -" toggles the display of hidden files -function! s:toggleShowHidden() - let b:NERDTreeShowHidden = !b:NERDTreeShowHidden - call s:renderViewSavingPosition() - call s:centerView() -endfunction - -" FUNCTION: s:toggleZoom() {{2 -" zoom (maximize/minimize) the NERDTree window -function! s:toggleZoom() - if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed - let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize - exec "silent vertical resize ". size - let b:NERDTreeZoomed = 0 - else - exec "vertical resize" - let b:NERDTreeZoomed = 1 - endif -endfunction - -"FUNCTION: s:upDir(keepState) {{{2 -"moves the tree up a level -" -"Args: -"keepState: 1 if the current root should be left open when the tree is -"re-rendered -function! s:upDir(keepState) - let cwd = b:NERDTreeRoot.path.str({'format': 'UI'}) - if cwd ==# "/" || cwd =~ '^[^/]..$' - call s:echo("already at top dir") - else - if !a:keepState - call b:NERDTreeRoot.close() - endif - - let oldRoot = b:NERDTreeRoot - - if empty(b:NERDTreeRoot.parent) - let path = b:NERDTreeRoot.path.getParent() - let newRoot = s:TreeDirNode.New(path) - call newRoot.open() - call newRoot.transplantChild(b:NERDTreeRoot) - let b:NERDTreeRoot = newRoot - else - let b:NERDTreeRoot = b:NERDTreeRoot.parent - endif - - if g:NERDTreeChDirMode ==# 2 - call b:NERDTreeRoot.path.changeToDir() - endif - - call s:renderView() - call oldRoot.putCursorHere(0, 0) - endif -endfunction - - -"reset &cpo back to users setting -let &cpo = s:old_cpo - -" vim: set sw=4 sts=4 et fdm=marker: diff --git a/bundle/ack/doc/ack.txt b/bundle/ack/doc/ack.txt deleted file mode 100644 index 4d57841..0000000 --- a/bundle/ack/doc/ack.txt +++ /dev/null @@ -1,38 +0,0 @@ -*ack.txt* Plugin that integrates ack with Vim - -============================================================================== -Author: Antoine Imbert *ack-author* -License: Same terms as Vim itself (see |license|) - -============================================================================== -INTRODUCTION *ack* - -This plugin is a front for the Perl module App::Ack. Ack can be used as a -replacement for grep. This plugin will allow you to run ack from vim, and -shows the results in a split window. - -:Ack [options] {pattern} [{directory}] *:Ack* - - Search recursively in {directory} (which defaults to the current - directory) for the {pattern}. Behaves just like the |:grep| command, but - will open the |Quickfix| window for you. - -:AckAdd [options] {pattern} [{directory}] *:AckAdd* - - Just like |:Ack| + |:grepadd|. Appends the |quickfix| with the results - -:LAck [options] {pattern} [{directory}] *:LAck* - - Just like |:Ack| + |:lgrep|. Searches, but opens in |location-list| - -:LAckAdd [options] {pattern} [{directory}] *:LAckAdd* - - Just like |:Ack| + |:lgrepadd|. Searches, but appends results to - |location-list| - -Files containing the search term will be listed in the split window, along -with the line number of the occurrence, once for each occurrence. on -a line in this window will open the file, and place the cursor on the matching -line. - -See http://search.cpan.org/~petdance/ack/ack for more information. diff --git a/bundle/ack/plugin/ack.vim b/bundle/ack/plugin/ack.vim deleted file mode 100644 index 1aecd51..0000000 --- a/bundle/ack/plugin/ack.vim +++ /dev/null @@ -1,50 +0,0 @@ -" NOTE: You must, of course, install the ack script -" in your path. -" On Ubuntu: -" sudo apt-get install ack-grep -" ln -s /usr/bin/ack-grep /usr/bin/ack -" With MacPorts: -" sudo port install p5-app-ack - -let g:ackprg="ack\\ -H\\ --nocolor\\ --nogroup" - -function! Ack(args) - let grepprg_bak=&grepprg - exec "set grepprg=" . g:ackprg - execute "silent! grep " . a:args - botright copen - let &grepprg=grepprg_bak - exec "redraw!" -endfunction - -function! AckAdd(args) - let grepprg_bak=&grepprg - exec "set grepprg=" . g:ackprg - execute "silent! grepadd " . a:args - botright copen - let &grepprg=grepprg_bak - exec "redraw!" -endfunction - -function! LAck(args) - let grepprg_bak=&grepprg - exec "set grepprg=" . g:ackprg - execute "silent! lgrep " . a:args - botright lopen - let &grepprg=grepprg_bak - exec "redraw!" -endfunction - -function! LAckAdd(args) - let grepprg_bak=&grepprg - exec "set grepprg=" . g:ackprg - execute "silent! lgrepadd " . a:args - botright lopen - let &grepprg=grepprg_bak - exec "redraw!" -endfunction - -command! -nargs=* -complete=file Ack call Ack() -command! -nargs=* -complete=file AckAdd call AckAdd() -command! -nargs=* -complete=file LAck call LAck() -command! -nargs=* -complete=file LAckAdd call LAckAdd() diff --git a/bundle/buftabs/plugin/buftabs.vim b/bundle/buftabs/plugin/buftabs.vim deleted file mode 100644 index f27ba24..0000000 --- a/bundle/buftabs/plugin/buftabs.vim +++ /dev/null @@ -1,350 +0,0 @@ -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" buftabs (C) 2006 Ico Doornekamp -" -" This program is free software; you can redistribute it and/or modify it -" under the terms of the GNU General Public License as published by the Free -" Software Foundation; either version 2 of the License, or (at your option) -" any later version. -" -" This program is distributed in the hope that it will be useful, but WITHOUT -" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -" more details. -" -" Introduction -" ------------ -" -" This is a simple script that shows a tabs-like list of buffers in the bottom -" of the window. The biggest advantage of this script over various others is -" that it does not take any lines away from your terminal, leaving more space -" for the document you're editing. The tabs are only visible when you need -" them - when you are switchin between buffers. -" -" Usage -" ----- -" -" This script draws buffer tabs on vim startup, when a new buffer is created -" and when switching between buffers. -" -" It might be handy to create a few maps for easy switching of buffers in your -" .vimrc file. For example, using F1 and F2 keys: -" -" noremap :bprev -" noremap :bnext -" -" or using control-left and control-right keys: -" -" :noremap :bprev -" :noremap :bnext -" -" -" The following extra configuration variables are availabe: -" -" * g:buftabs_only_basename -" -" Define this variable to make buftabs only print the filename of each buffer, -" omitting the preceding directory name. Add to your .vimrc: -" -" :let g:buftabs_only_basename=1 -" -" -" * g:buftabs_in_statusline -" -" Define this variable to make the plugin show the buftabs in the statusline -" instead of the command line. It is a good idea to configure vim to show -" the statusline as well when only one window is open. Add to your .vimrc: -" -" set laststatus=2 -" :let g:buftabs_in_statusline=1 -" -" By default buftabs will take up the whole of the left-aligned section of -" your statusline. You can alternatively specify precisely where it goes -" using %{buftabs#statusline()} e.g.: -" -" set statusline=%=buffers:\ %{buftabs#statusline()} -" -" -" * g:buftabs_active_highlight_group -" * g:buftabs_inactive_highlight_group -" -" The name of a highlight group (:help highligh-groups) which is used to -" show the name of the current active buffer and of all other inactive -" buffers. If these variables are not defined, no highlighting is used. -" (Highlighting is only functional when g:buftabs_in_statusline is enabled) -" -" :let g:buftabs_active_highlight_group="Visual" -" -" -" * g:buftabs_marker_start [ -" * g:buftabs_marker_end ] -" * g:buftabs_separator - -" * g:buftabs_marker_modified ! -" -" These strings are drawn around each tab as separators, the 'marker_modified' -" symbol is used to denote a modified (unsaved) buffer. -" -" :let g:buftabs_separator = "." -" :let g:buftabs_marker_start = "(" -" :let g:buftabs_marker_end = ")" -" :let g:buftabs_marker_modified = "*" -" -" -" Changelog -" --------- -" -" 0.1 2006-09-22 Initial version -" -" 0.2 2006-09-22 Better handling when the list of buffers is longer then the -" window width. -" -" 0.3 2006-09-27 Some cleanups, set 'hidden' mode by default -" -" 0.4 2007-02-26 Don't draw buftabs until VimEnter event to avoid clutter at -" startup in some circumstances -" -" 0.5 2007-02-26 Added option for showing only filenames without directories -" in tabs -" -" 0.6 2007-03-04 'only_basename' changed to a global variable. Removed -" functions and add event handlers instead. 'hidden' mode -" broke some things, so is disabled now. Fixed documentation -" -" 0.7 2007-03-07 Added configuration option to show tabs in statusline -" instead of cmdline -" -" 0.8 2007-04-02 Update buftabs when leaving insertmode -" -" 0.9 2007-08-22 Now compatible with older Vim versions < 7.0 -" -" 0.10 2008-01-26 Added GPL license -" -" 0.11 2008-02-29 Added optional syntax highlighting to active buffer name -" -" 0.12 2009-03-18 Fixed support for split windows -" -" 0.13 2009-05-07 Store and reuse right-aligned part of original statusline -" -" 0.14 2010-01-28 Fixed bug that caused buftabs in command line being -" overwritten when 'hidden' mode is enabled. -" -" 0.15 2010-02-16 Fixed window width handling bug which caused strange -" behaviour in combination with the bufferlist plugin. -" Fixed wrong buffer display when deleting last window. -" Added extra options for tabs style and highlighting. -" -" 0.16 2010-02-28 Fixed bug causing errors when using buftabs in vim -" diff mode. -" -" 0.17 2011-03-11 Changed persistent echo function to restore 'updatetime', -" leading to better behaviour when showing buftabs in the -" status line. (Thanks Alex Bradbury) -" -" 0.18 2011-03-12 Added marker for denoting modified buffers, provide -" function for including buftabs into status line descriptor -" instead of buftabs having to edit the status line directly. -" (Thanks Andrew Ho) -" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -let w:buftabs_enabled = 0 -let w:original_statusline = matchstr(&statusline, "%=.*") - -" -" Don't bother when in diff mode -" - -if &diff - finish -endif - - -" -" Called on VimEnter event -" - -function! Buftabs_enable() - let w:buftabs_enabled = 1 -endfunction - - -" -" Persistent echo to avoid overwriting of status line when 'hidden' is enabled -" - -let s:Pecho='' -function! s:Pecho(msg) - if &ut!=1|let s:hold_ut=&ut|let &ut=1|en - let s:Pecho=a:msg - aug Pecho - au CursorHold * if s:Pecho!=''|echo s:Pecho - \|let s:Pecho=''|let &ut=s:hold_ut|en - \|aug Pecho|exe 'au!'|aug END|aug! Pecho - aug END -endf - - -" -" Draw the buftabs -" - -function! Buftabs_show(deleted_buf) - - let l:i = 1 - let s:list = '' - let l:start = 0 - let l:end = 0 - if ! exists("w:from") - let w:from = 0 - endif - - if ! exists("w:buftabs_enabled") - return - endif - - let l:buftabs_marker_modified = "!" - if exists("g:buftabs_marker_modified") - let l:buftabs_marker_modified = g:buftabs_marker_modified - endif - - let l:buftabs_separator = "-" - if exists("g:buftabs_separator") - let l:buftabs_separator = g:buftabs_separator - endif - - let l:buftabs_marker_start = "[" - if exists("g:buftabs_marker_start") - let l:buftabs_marker_start = g:buftabs_marker_start - endif - - let l:buftabs_marker_end = "]" - if exists("g:buftabs_marker_end") - let l:buftabs_marker_end = g:buftabs_marker_end - endif - - " Walk the list of buffers - - while(l:i <= bufnr('$')) - - " Only show buffers in the list, and omit help screens - - if buflisted(l:i) && getbufvar(l:i, "&modifiable") && a:deleted_buf != l:i - - " Get the name of the current buffer, and escape characters that might - " mess up the statusline - - if exists("g:buftabs_only_basename") - let l:name = fnamemodify(bufname(l:i), ":t") - else - let l:name = bufname(l:i) - endif - let l:name = substitute(l:name, "%", "%%", "g") - - " Append the current buffer number and name to the list. If the buffer - " is the active buffer, enclose it in some magick characters which will - " be replaced by markers later. If it is modified, it is appended with - " an appropriate symbol (an exclamation mark by default) - - if winbufnr(winnr()) == l:i - let l:start = strlen(s:list) - let s:list = s:list . "\x01" - else - let s:list = s:list . ' ' - endif - - let s:list = s:list . l:i . l:buftabs_separator - let s:list = s:list . l:name - - if getbufvar(l:i, "&modified") == 1 - let s:list = s:list . l:buftabs_marker_modified - endif - - if winbufnr(winnr()) == l:i - let s:list = s:list . "\x02" - let l:end = strlen(s:list) - else - let s:list = s:list . ' ' - endif - end - - let l:i = l:i + 1 - endwhile - - " If the resulting list is too long to fit on the screen, chop - " out the appropriate part - - let l:width = winwidth(0) - 12 - - if(l:start < w:from) - let w:from = l:start - 1 - endif - if l:end > w:from + l:width - let w:from = l:end - l:width - endif - - let s:list = strpart(s:list, w:from, l:width) - - " Replace the magic characters by visible markers for highlighting the - " current buffer. The markers can be simple characters like square brackets, - " but can also be special codes with highlight groups - - if exists("g:buftabs_active_highlight_group") - if exists("g:buftabs_in_statusline") - let l:buftabs_marker_start = "%#" . g:buftabs_active_highlight_group . "#" . l:buftabs_marker_start - let l:buftabs_marker_end = l:buftabs_marker_end . "%##" - end - end - - if exists("g:buftabs_inactive_highlight_group") - if exists("g:buftabs_in_statusline") - let s:list = '%#' . g:buftabs_inactive_highlight_group . '#' . s:list - let s:list .= '%##' - let l:buftabs_marker_end = l:buftabs_marker_end . '%#' . g:buftabs_inactive_highlight_group . '#' - end - end - - let s:list = substitute(s:list, "\x01", l:buftabs_marker_start, 'g') - let s:list = substitute(s:list, "\x02", l:buftabs_marker_end, 'g') - - " Show the list. The buftabs_in_statusline variable determines of the list - " is displayed in the command line (volatile) or in the statusline - " (persistent) - - if exists("g:buftabs_in_statusline") - " Only overwrite the statusline if buftabs#statusline() has not been - " used to specify a location - if match(&statusline, "%{buftabs#statusline()}") == -1 - let &l:statusline = s:list . w:original_statusline - end - else - redraw - call s:Pecho(s:list) - end - -endfunction - - -" -" Optional function returning the current buftabs list string which can -" be used inside the statusline string using the %{buftabs#statusline()} -" syntax -" - -function! buftabs#statusline(...) - return s:list -endfunction - - -" -" Hook to events to show buftabs at startup, when creating and when switching -" buffers -" - -autocmd VimEnter * call Buftabs_enable() -autocmd VimEnter,BufNew,BufEnter,BufWritePost * call Buftabs_show(-1) -autocmd BufDelete * call Buftabs_show(expand('')) -if version >= 700 - autocmd InsertLeave,VimResized * call Buftabs_show(-1) -end - -" vi: ts=2 sw=2 - diff --git a/bundle/coffee-script/.gitignore b/bundle/coffee-script/.gitignore deleted file mode 100644 index 1ff7b05..0000000 --- a/bundle/coffee-script/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.*.sw[a-z] -.*.un~ -doc/tags - diff --git a/bundle/coffee-script/Copying.md b/bundle/coffee-script/Copying.md deleted file mode 100644 index 51cf8d1..0000000 --- a/bundle/coffee-script/Copying.md +++ /dev/null @@ -1,15 +0,0 @@ - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 - - Copyright (C) 2010 to 2012 Mick Koch - - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. You just DO WHAT THE FUCK YOU WANT TO. - - diff --git a/bundle/coffee-script/Makefile b/bundle/coffee-script/Makefile deleted file mode 100644 index e6ef409..0000000 --- a/bundle/coffee-script/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -REF = HEAD -VERSION = $(shell git describe --always $(REF)) - -ARCHIVE = vim-coffee-script-$(VERSION).zip -ARCHIVE_DIRS = after autoload compiler doc ftdetect ftplugin indent syntax - -# Don't do anything by default. -all: - -# Make vim.org zipball. -archive: - git archive $(REF) -o $(ARCHIVE) -- $(ARCHIVE_DIRS) - -# Remove zipball. -clean: - -rm -f $(ARCHIVE) - -# Build the list of syntaxes for @coffeeAll. -coffeeAll: - @grep -E 'syn (match|region)' syntax/coffee.vim |\ - grep -v 'contained' |\ - awk '{print $$3}' |\ - uniq - -.PHONY: all archive clean hash coffeeAll diff --git a/bundle/coffee-script/News.md b/bundle/coffee-script/News.md deleted file mode 100644 index 9706796..0000000 --- a/bundle/coffee-script/News.md +++ /dev/null @@ -1,18 +0,0 @@ -### Version 002 (December 5, 2011) - -Added binary numbers (0b0101) and fixed some bugs (#9, #62, #63, #65). - -### Version 001 (October 18, 2011) - -Removed deprecated `coffee_folding` option, added `coffee_compile_vert` option, -split out compiler, fixed indentation and syntax bugs, and added Haml support -and omnicompletion. - - - The coffee compiler is now a proper vim compiler that can be loaded with - `:compiler coffee`. - - The `coffee_compile_vert` option can now be set to split the CoffeeCompile - buffer vertically by default. - - CoffeeScript is now highlighted inside the `:coffeescript` filter in Haml. - - Omnicompletion (`:help compl-omni`) now uses JavaScript's dictionary to - complete words. - - We now have a fancy version number. diff --git a/bundle/coffee-script/Readme.md b/bundle/coffee-script/Readme.md deleted file mode 100644 index d557848..0000000 --- a/bundle/coffee-script/Readme.md +++ /dev/null @@ -1,599 +0,0 @@ -This project adds [CoffeeScript] support to vim. It covers syntax, indenting, -compiling, and more. - -![Screenshot](http://i.imgur.com/j1BhpZQ.png) - -[CoffeeScript]: http://coffeescript.org/ - -## Table of Contents - -- Installation - - [Requirements](#requirements) - - [Install using Pathogen](#install-using-pathogen) - - [Install using Vundle](#install-using-vundle) - - [Install from a Zip File](#install-from-a-zip-file) -- Coffee Commands - - [Compile to JavaScript](#compile-to-javascript) - - [Compile CoffeeScript Snippets](#coffeecompile-compile-coffeescript-snippets) - - [Live Preview Compiling](#coffeewatch-live-preview-compiling) - - [Run CoffeeScript Snippets](#coffeerun-run-coffeescript-snippets) - - [Lint your CoffeeScript](#coffeelint-lint-your-coffeescript) -- Extras - - [Literate CoffeeScript](#literate-coffeescript) - - [CoffeeScript in HTML](#coffeescript-in-html) - - [CoffeeScript in Haml](#coffeescript-in-haml) -- Configuration - - [Custom Autocmds](#custom-autocmds) - - [Configuration Variables](#configuration-variables) - - [Configure Syntax Highlighting](#configure-syntax-highlighting) - - [Tune Vim for CoffeeScript](#tune-vim-for-coffeescript) - -## Requirements - - - vim 7.4 or later - - coffee 1.2.0 or later - -## Install using Pathogen - -This project uses rolling releases based on git commits, so pathogen is a -natural fit for it. If you're already using pathogen, you can skip to step 4. - -1. Install [pathogen.vim] into `~/.vim/autoload/` (see [pathogen's - readme][install-pathogen] for more information.) - -[pathogen.vim]: http://www.vim.org/scripts/script.php?script_id=2332 -[install-pathogen]: https://github.com/tpope/vim-pathogen#installation - -2. Enable pathogen in your vimrc. Here's a bare-minimum vimrc that enables - all the features of `vim-coffee-script`: - - ```vim - call pathogen#infect() - syntax enable - filetype plugin indent on - ``` - - If you already have a vimrc built up, just make sure it contains these calls, - in this order. - -3. Create the directory `~/.vim/bundle/`: - - mkdir ~/.vim/bundle - -4. Clone the `vim-coffee-script` repo into `~/.vim/bundle/`: - - git clone https://github.com/kchmck/vim-coffee-script.git ~/.vim/bundle/vim-coffee-script/ - -Updating takes two steps: - -1. Change into `~/.vim/bundle/vim-coffee-script/`: - - cd ~/.vim/bundle/vim-coffee-script - -2. Pull in the latest changes: - - git pull - -## Install using Vundle - -1. [Install Vundle] into `~/.vim/bundle/`. - -[Install Vundle]: https://github.com/gmarik/vundle#quick-start - -2. Configure your vimrc for Vundle. Here's a bare-minimum vimrc that enables all - the features of `vim-coffee-script`: - - - ```vim - set nocompatible - filetype off - - set rtp+=~/.vim/bundle/vundle/ - call vundle#rc() - - Bundle 'kchmck/vim-coffee-script' - - syntax enable - filetype plugin indent on - ``` - - If you're adding Vundle to a built-up vimrc, just make sure all these calls - are in there and that they occur in this order. - -3. Open vim and run `:BundleInstall`. - -To update, open vim and run `:BundleInstall!` (notice the bang!) - -## Install from a Zip File - -1. Download the latest zip file from [vim.org][zip]. - -2. Extract the archive into `~/.vim/`: - - unzip -od ~/.vim/ ARCHIVE.zip - - This should create the files `~/.vim/autoload/coffee.vim`, - `~/.vim/compiler/coffee.vim`, etc. - -You can update the plugin using the same steps. - -[zip]: http://www.vim.org/scripts/script.php?script_id=3590 - -## Compile to JavaScript - -A `coffee` wrapper for use with `:make` is enabled automatically for coffee -files if no other compiler is loaded. To enable it manually, run - - :compiler coffee - -The `:make` command is then configured to use the `coffee` compiler and -recognize its errors. I've included a quick reference here but be sure to check -out [`:help :make`][make] for a full reference of the command. - - ![make](http://i.imgur.com/scUXmxR.png) - - ![make Result](http://i.imgur.com/eGIjEdn.png) - -[make]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make_makeprg - -Consider the full signature of a `:make` call as - - :[silent] make[!] [COFFEE-OPTIONS]... - -By default `:make` shows all compiler output and jumps to the first line -reported as an error. Compiler output can be hidden with a leading `:silent`: - - :silent make - -Line-jumping can be turned off by adding a bang: - - :make! - -`COFFEE-OPTIONS` given to `:make` are passed along to `coffee` (see also -[`coffee_make_options`](#coffee_make_options)): - - :make --bare --output /some/dir - -See the [full table of options](http://coffeescript.org/#usage) for a -list of all the options that `coffee` recognizes. - -*Configuration*: [`coffee_compiler`](#coffee_compiler), -[`coffee_make_options`](#coffee_make_options) - -#### The quickfix window - -Compiler errors are added to the [quickfix] list by `:make`, but the quickfix -window isn't automatically shown. The [`:cwindow`][cwindow] command will pop up -the quickfix window if there are any errors: - - :make - :cwindow - -This is usually the desired behavior, so you may want to add an autocmd to your -vimrc to do this automatically: - - autocmd QuickFixCmdPost * nested cwindow | redraw! - -The `redraw!` command is needed to fix a redrawing quirk in terminal vim, but -can removed for gVim. - -[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix -[cwindow]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:cwindow - -#### Recompile on write - -To recompile a file when it's written, add a `BufWritePost` autocmd to your -vimrc: - - autocmd BufWritePost *.coffee silent make! - -#### Cake and Cakefiles - -A `cake` compiler is also available with the call - - :compiler cake - -You can then use `:make` as above to run your Cakefile and capture any `coffee` -errors: - - :silent make build - -It runs within the current directory, so make sure you're in the directory of -your Cakefile before calling it. - -*Configuration*: [`coffee_cake`](#coffee_cake), -[`coffee_cake_options`](#coffee_cake_options) - -## CoffeeCompile: Compile CoffeeScript Snippets - -CoffeeCompile shows how the current file or a snippet of CoffeeScript is -compiled to JavaScript. - - :[RANGE] CoffeeCompile [vert[ical]] [WINDOW-SIZE] - -Calling `:CoffeeCompile` without a range compiles the whole file: - - ![CoffeeCompile](http://i.imgur.com/0zFG0l0.png) - - ![CoffeeCompile Result](http://i.imgur.com/bpiAxaa.png) - -Calling it with a range, like in visual mode, compiles only the selected snippet -of CoffeeScript: - - ![CoffeeCompile Snippet](http://i.imgur.com/x3OT3Ay.png) - - ![Compiled Snippet](http://i.imgur.com/J02j4T8.png) - -Each file gets its own CoffeeCompile buffer, and the same buffer is used for all -future calls of `:CoffeeCompile` on that file. It can be quickly closed by -hitting `q` in normal mode. - -Using `vert` opens the CoffeeCompile buffer vertically instead of horizontally -(see also [`coffee_compile_vert`](#coffee_compile_vert)): - - :CoffeeCompile vert - -By default the CoffeeCompile buffer splits the source buffer in half, but this -can be overridden by passing in a `WINDOW-SIZE`: - - :CoffeeCompile 4 - -*Configuration*: [`coffee_compiler`](#coffee_compiler`), -[`coffee_compile_vert`](#coffee_compile_vert) - -#### Quick syntax checking - -If compiling a snippet results in a compiler error, CoffeeCompile adds that -error to the [quickfix] list. - -[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix - - ![Syntax Checking](http://i.imgur.com/RC8accF.png) - - ![Syntax Checking Result](http://i.imgur.com/gi1ON75.png) - -You can use this to quickly check the syntax of a snippet. - -## CoffeeWatch: Live Preview Compiling - -CoffeeWatch emulates using the Try CoffeeScript preview box on the [CoffeeScript -homepage][CoffeeScript]. - - ![CoffeeWatch](http://i.imgur.com/TRHdIMG.png) - - ![CoffeeWatch Result](http://i.imgur.com/rJbOeeS.png) - -CoffeeWatch takes the same options as CoffeeCompile: - - :CoffeeWatch [vert[ical]] [WINDOW-SIZE] - -After a source buffer is watched, leaving insert mode or saving the file fires -off a recompile of the CoffeeScript: - - ![Insert Mode](http://i.imgur.com/SBVcf4k.png) - - ![Recompile](http://i.imgur.com/pbPMog7.png) - -You can force recompilation by calling `:CoffeeWatch`. - -To get synchronized scrolling of the source buffer and CoffeeWatch buffer, set -[`'scrollbind'`](http://vimdoc.sourceforge.net/htmldoc/options.html#'scrollbind') -on each: - - :setl scrollbind - -*Configuration*: [`coffee_compiler`](#coffee_compiler), -[`coffee_watch_vert`](#coffee_watch_vert) - -## CoffeeRun: Run CoffeeScript Snippets - -CoffeeRun compiles the current file or selected snippet and runs the resulting -JavaScript. - - ![CoffeeRun](http://i.imgur.com/YSkHUuQ.png) - - ![CoffeeRun Output](http://i.imgur.com/wZQbggN.png) - -The command has two forms: - - :CoffeeRun [PROGRAM-OPTIONS]... - -This form applies when no `RANGE` is given or when the given range is `1,$` -(first line to last line). It allows passing `PROGRAM-OPTIONS` to your compiled -program. The filename is passed directly to `coffee` so you must save the file -for your changes to take effect. - - :RANGE CoffeeRun [COFFEE-OPTIONS]... - -This form applies with all other ranges. It compiles and runs the lines within -the given `RANGE` and any extra `COFFEE-OPTIONS` are passed to `coffee`. - -*Configuration*: [`coffee_compiler`](#coffee_compiler), -[`coffee_run_vert`](#coffee_run_vert) - -## CoffeeLint: Lint your CoffeeScript - -CoffeeLint runs [coffeelint](http://www.coffeelint.org/) (version 0.5.7 or later -required) on the current file and adds any issues to the [quickfix] list. - - ![CoffeeLint](http://i.imgur.com/UN8Nr5N.png) - - ![CoffeeLint Result](http://i.imgur.com/9hSIj3W.png) - - :[RANGE] CoffeeLint[!] [COFFEELINT-OPTIONS]... [ | cwindow] - -If a `RANGE` is given, only those lines are piped to `coffeelint`. Options given -in `COFFEELINT-OPTIONS` are passed to `coffeelint` (see also -[`coffee_lint_options`](#coffee_lint_options)): - - :CoffeeLint -f lint.json - -It behaves very similar to `:make`, described [above](#compile-to-javascript). - - :CoffeeLint! | cwindow - -*Configuration*: [`coffee_linter`](#coffee_linter), -[`coffee_lint_options`](#coffee_lint_options) - -## Literate CoffeeScript - -Literate CoffeeScript syntax and indent support is provided by -[vim-literate-coffeescript]. The `Coffee` commands detect when they're running -on a litcoffee file and pass the `--literate` flag to their respective tools, -but at this time the commands are not automatically loaded when a litcoffee file -is opened. - -[vim-literate-coffeescript]: https://github.com/mintplant/vim-literate-coffeescript - -To load them, run - - runtime ftplugin/coffee.vim - -while inside a litcoffee buffer. To do this automatically, add - - autocmd FileType litcoffee runtime ftplugin/coffee.vim - -to your vimrc. - -## CoffeeScript in HTML - -CoffeeScript is highlighted and indented within - -```html - -``` - -blocks in html files. - -## CoffeeScript in Haml - -CoffeeScript is highlighted within the `:coffeescript` filter in haml files: - -```haml -:coffeescript - console.log "hullo" -``` - -At this time, coffee indenting doesn't work in these blocks. - -## Custom Autocmds - -You can [define commands][autocmd-explain] to be ran automatically on these -custom events. - -In all cases, the name of the command running the event (`CoffeeCompile`, -`CoffeeWatch`, or `CoffeeRun`) is matched by the [`{pat}`][autocmd] argument. -You can match all commands with a `*` or only specific commands by separating -them with a comma: `CoffeeCompile,CoffeeWatch`. - -[autocmd-explain]: http://vimdoc.sourceforge.net/htmldoc/usr_40.html#40.3 -[autocmd]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#:autocmd - -#### CoffeeBufNew - -CoffeeBufNew is ran when a new scratch buffer is created. It's called from the -new buffer, so it can be used to do additional set up. - -```vim -augroup CoffeeBufNew - autocmd User * set wrap -augroup END -``` - -*Used By*: CoffeeCompile, CoffeeWatch, CoffeeRun - -#### CoffeeBufUpdate - -CoffeeBufUpdate is ran when a scratch buffer is updated with output from -`coffee`. It's called from the scratch buffer, so it can be used to alter the -compiled output. - -```vim -" Switch back to the source buffer after updating. -augroup CoffeeBufUpdate - autocmd User CoffeeCompile,CoffeeRun exec bufwinnr(b:coffee_src_buf) 'wincmd w' -augroup END -``` - -For example, to strip off the "Generated by" comment on the first line, put this -in your vimrc: - -```vim -function! s:RemoveGeneratedBy() - " If there was an error compiling, there's no comment to remove. - if v:shell_error - return - endif - - " Save cursor position. - let pos = getpos('.') - - " Remove first line. - set modifiable - 1 delete _ - set nomodifiable - - " Restore cursor position. - call setpos('.', pos) -endfunction - -augroup CoffeeBufUpdate - autocmd User CoffeeCompile,CoffeeWatch call s:RemoveGeneratedBy() -augroup END -``` - -*Used By*: CoffeeCompile, CoffeeWatch, CoffeeRun - -## Configuration Variables - -This is the full list of configuration variables available, with example -settings and default values. Use these in your vimrc to control the default -behavior. - -#### coffee\_indent\_keep\_current - -By default, the indent function matches the indent of the previous line if it -doesn't find a reason to indent or outdent. To change this behavior so it -instead keeps the [current indent of the cursor][98], use - - let coffee_indent_keep_current = 1 - -[98]: https://github.com/kchmck/vim-coffee-script/pull/98 - -*Default*: `unlet coffee_indent_keep_current` - -Note that if you change this after a coffee file has been loaded, you'll have to -reload the indent script for the change to take effect: - - unlet b:did_indent | runtime indent/coffee.vim - -#### coffee\_compiler - -Path to the `coffee` executable used by the `Coffee` commands: - - let coffee_compiler = '/usr/bin/coffee' - -*Default*: `'coffee'` (search `$PATH` for executable) - -#### coffee\_make\_options - -Options to pass to `coffee` with `:make`: - - let coffee_make_options = '--bare' - -*Default*: `''` (nothing) - -Note that `coffee_make_options` is embedded into `'makeprg'`, so `:compiler -coffee` must be ran after changing `coffee_make_options` for the changes to take -effect. - -#### coffee\_cake - -Path to the `cake` executable: - - let coffee_cake = '/opt/bin/cake' - -*Default*: `'cake'` (search `$PATH` for executable) - -#### coffee\_cake\_options - -Options to pass to `cake` with `:make`: - - let coffee_cake_options = 'build' - -*Default*: `''` (nothing) - -#### coffee\_linter - -Path to the `coffeelint` executable: - - let coffee_linter = '/opt/bin/coffeelint' - -*Default*: `'coffeelint'` (search `$PATH` for executable) - -#### coffee\_lint\_options - -Options to pass to `coffeelint`: - - let coffee_lint_options = '-f lint.json' - -*Default*: `''` (nothing) - -#### coffee\_compile\_vert - -Open the CoffeeCompile buffer with a vertical split instead of a horizontal -one: - - let coffee_compile_vert = 1 - -*Default*: `unlet coffee_compile_vert` - -#### coffee\_watch\_vert - -Open the CoffeeWatch buffer with a vertical split instead of a horizontal -one: - - let coffee_watch_vert = 1 - -*Default*: `unlet coffee_watch_vert` - -#### coffee\_run\_vert - -Open the CoffeeRun buffer with a vertical split instead of a horizontal -one: - - let coffee_run_vert = 1 - -*Default*: `unlet coffee_run_vert` - -## Configure Syntax Highlighting - -Add these lines to your vimrc to disable the relevant syntax group. - -#### Disable trailing whitespace error - -Trailing whitespace is highlighted as an error by default. This can be disabled -with: - - hi link coffeeSpaceError NONE - -#### Disable trailing semicolon error - -Trailing semicolons are considered an error (for help transitioning from -JavaScript.) This can be disabled with: - - hi link coffeeSemicolonError NONE - -#### Disable reserved words error - -Reserved words like `function` and `var` are highlighted as an error where -they're not allowed in CoffeeScript. This can be disabled with: - - hi link coffeeReservedError NONE - -## Tune Vim for CoffeeScript - -Changing these core settings can make vim more CoffeeScript friendly. - -#### Fold by indentation - -Folding by indentation works well for CoffeeScript functions and classes: - - ![Folding](http://i.imgur.com/gDgUBdO.png) - -To fold by indentation in CoffeeScript files, add this line to your vimrc: - - autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable - -With this, folding is disabled by default but can be quickly toggled per-file -by hitting `zi`. To enable folding by default, remove `nofoldenable`: - - autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent - -#### Two-space indentation - -To get standard two-space indentation in CoffeeScript files, add this line to -your vimrc: - - autocmd BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab diff --git a/bundle/coffee-script/Thanks.md b/bundle/coffee-script/Thanks.md deleted file mode 100644 index 8ddcf23..0000000 --- a/bundle/coffee-script/Thanks.md +++ /dev/null @@ -1,44 +0,0 @@ -Thanks to all bug reporters, and special thanks to those who have contributed -code: - - Brian Egan (brianegan): - Initial compiling support - - Ches Martin (ches): - Initial vim docs - - Chris Hoffman (cehoffman): - Add new keywoards from, to, and do - Highlight the - in negative integers - Add here regex highlighting, increase fold level for here docs - - David Wilhelm (bigfish): - CoffeeRun command - - Jay Adkisson (jayferd): - Support for eco templates - - Karl Guertin (grayrest) - Cakefiles are coffeescript - - Maciej Konieczny (narfdotpl): - Fix funny typo - - Matt Sacks (mattsa): - Javascript omni-completion - coffee_compile_vert option - - Nick Stenning (nickstenning): - Fold by indentation for coffeescript - - Simon Lipp (sloonz): - Trailing spaces are not error on lines containing only spaces - - Stéphan Kochen (stephank): - Initial HTML CoffeeScript highlighting - - Sven Felix Oberquelle (Svelix): - Haml CoffeeScript highlighting - - Wei Dai (clvv): - Fix the use of Vim built-in make command. diff --git a/bundle/coffee-script/Todo.md b/bundle/coffee-script/Todo.md deleted file mode 100644 index 3d4ffaa..0000000 --- a/bundle/coffee-script/Todo.md +++ /dev/null @@ -1 +0,0 @@ -- Don't highlight bad operator combinations diff --git a/bundle/coffee-script/after/indent/html.vim b/bundle/coffee-script/after/indent/html.vim deleted file mode 100644 index 10ca6ce..0000000 --- a/bundle/coffee-script/after/indent/html.vim +++ /dev/null @@ -1,33 +0,0 @@ -" Language: CoffeeScript -" Maintainer: Mick Koch -" URL: http://github.com/kchmck/vim-coffee-script -" License: WTFPL - -" Load the coffee and html indent functions. -unlet b:did_indent -runtime indent/coffee.vim -let s:coffeeIndentExpr = &l:indentexpr - -" Load html last so it can overwrite coffee settings. -unlet b:did_indent -runtime indent/html.vim -let s:htmlIndentExpr = &l:indentexpr - -" Inject our wrapper indent function. -setlocal indentexpr=GetCoffeeHtmlIndent(v:lnum) - -function! GetCoffeeHtmlIndent(curlinenum) - " See if we're inside a coffeescript block. - let scriptlnum = searchpair('', 'bWn') - let prevlnum = prevnonblank(a:curlinenum) - - " If we're in the script block and the previous line isn't the script tag - " itself, use coffee indenting. - if scriptlnum && scriptlnum != prevlnum - exec 'return ' s:coffeeIndentExpr - endif - - " Otherwise use html indenting. - exec 'return ' s:htmlIndentExpr -endfunction diff --git a/bundle/coffee-script/after/syntax/haml.vim b/bundle/coffee-script/after/syntax/haml.vim deleted file mode 100644 index 4c517eb..0000000 --- a/bundle/coffee-script/after/syntax/haml.vim +++ /dev/null @@ -1,13 +0,0 @@ -" Language: CoffeeScript -" Maintainer: Sven Felix Oberquelle -" URL: http://github.com/kchmck/vim-coffee-script -" License: WTFPL - -" Inherit coffee from html so coffeeComment isn't redefined and given higher -" priority than hamlInterpolation. -syn cluster hamlCoffeescript contains=@htmlCoffeeScript -syn region hamlCoffeescriptFilter matchgroup=hamlFilter -\ start="^\z(\s*\):coffee\z(script\)\?\s*$" -\ end="^\%(\z1 \| *$\)\@!" -\ contains=@hamlCoffeeScript,hamlInterpolation -\ keepend diff --git a/bundle/coffee-script/after/syntax/html.vim b/bundle/coffee-script/after/syntax/html.vim deleted file mode 100644 index 9e2eb3a..0000000 --- a/bundle/coffee-script/after/syntax/html.vim +++ /dev/null @@ -1,11 +0,0 @@ -" Language: CoffeeScript -" Maintainer: Mick Koch -" URL: http://github.com/kchmck/vim-coffee-script -" License: WTFPL - -" Syntax highlighting for text/coffeescript script tags -syn include @htmlCoffeeScript syntax/coffee.vim -syn region coffeeScript start=##me=s-1 keepend -\ contains=@htmlCoffeeScript,htmlScriptTag,@htmlPreproc -\ containedin=htmlHead diff --git a/bundle/coffee-script/autoload/coffee.vim b/bundle/coffee-script/autoload/coffee.vim deleted file mode 100644 index 04d5efb..0000000 --- a/bundle/coffee-script/autoload/coffee.vim +++ /dev/null @@ -1,54 +0,0 @@ -" Language: CoffeeScript -" Maintainer: Mick Koch -" URL: http://github.com/kchmck/vim-coffee-script -" License: WTFPL - -" Set up some common global/buffer variables. -function! coffee#CoffeeSetUpVariables() - " Path to coffee executable - if !exists('g:coffee_compiler') - let g:coffee_compiler = 'coffee' - endif - - " Options passed to coffee with make - if !exists('g:coffee_make_options') - let g:coffee_make_options = '' - endif - - " Path to cake executable - if !exists('g:coffee_cake') - let g:coffee_cake = 'cake' - endif - - " Extra options passed to cake - if !exists('g:coffee_cake_options') - let g:coffee_cake_options = '' - endif - - " Path to coffeelint executable - if !exists('g:coffee_linter') - let g:coffee_linter = 'coffeelint' - endif - - " Options passed to CoffeeLint - if !exists('g:coffee_lint_options') - let g:coffee_lint_options = '' - endif - - " Pass the litcoffee flag to tools in this buffer if a litcoffee file is open. - " Let the variable be overwritten so it can be updated if a different filetype - " is set. - if &filetype == 'litcoffee' - let b:coffee_litcoffee = '--literate' - else - let b:coffee_litcoffee = '' - endif -endfunction - -function! coffee#CoffeeSetUpErrorFormat() - CompilerSet errorformat=Error:\ In\ %f\\,\ %m\ on\ line\ %l, - \Error:\ In\ %f\\,\ Parse\ error\ on\ line\ %l:\ %m, - \SyntaxError:\ In\ %f\\,\ %m, - \%f:%l:%c:\ error:\ %m, - \%-G%.%# -endfunction diff --git a/bundle/coffee-script/compiler/cake.vim b/bundle/coffee-script/compiler/cake.vim deleted file mode 100644 index 0a3c703..0000000 --- a/bundle/coffee-script/compiler/cake.vim +++ /dev/null @@ -1,15 +0,0 @@ -" Language: CoffeeScript -" Maintainer: Mick Koch -" URL: http://github.com/kchmck/vim-coffee-script -" License: WTFPL - -if exists('current_compiler') - finish -endif - -let current_compiler = 'cake' -call coffee#CoffeeSetUpVariables() - -exec 'CompilerSet makeprg=' . escape(g:coffee_cake . ' ' . -\ g:coffee_cake_options . ' $*', ' ') -call coffee#CoffeeSetUpErrorFormat() diff --git a/bundle/coffee-script/compiler/coffee.vim b/bundle/coffee-script/compiler/coffee.vim deleted file mode 100644 index a70fa64..0000000 --- a/bundle/coffee-script/compiler/coffee.vim +++ /dev/null @@ -1,82 +0,0 @@ -" Language: CoffeeScript -" Maintainer: Mick Koch -" URL: http://github.com/kchmck/vim-coffee-script -" License: WTFPL - -" All this is needed to support compiling filenames with spaces, quotes, and -" such. The filename is escaped and embedded into the `makeprg` setting. -" -" Because of this, `makeprg` must be updated on every file rename. And because -" of that, `CompilerSet` can't be used because it doesn't exist when the -" rename autocmd is ran. So, we have to do some checks to see whether `compiler` -" was called locally or globally, and respect that in the rest of the script. - -if exists('current_compiler') - finish -endif - -let current_compiler = 'coffee' -call coffee#CoffeeSetUpVariables() - -" Pattern to check if coffee is the compiler -let s:pat = '^' . current_compiler - -" Get a `makeprg` for the current filename. -function! s:GetMakePrg() - return g:coffee_compiler . - \ ' -c' . - \ ' ' . b:coffee_litcoffee . - \ ' ' . g:coffee_make_options . - \ ' $*' . - \ ' ' . fnameescape(expand('%')) -endfunction - -" Set `makeprg` and return 1 if coffee is still the compiler, else return 0. -function! s:SetMakePrg() - if &l:makeprg =~ s:pat - let &l:makeprg = s:GetMakePrg() - elseif &g:makeprg =~ s:pat - let &g:makeprg = s:GetMakePrg() - else - return 0 - endif - - return 1 -endfunction - -" Set a dummy compiler so we can check whether to set locally or globally. -exec 'CompilerSet makeprg=' . current_compiler -" Then actually set the compiler. -call s:SetMakePrg() -call coffee#CoffeeSetUpErrorFormat() - -function! s:CoffeeMakeDeprecated(bang, args) - echoerr 'CoffeeMake is deprecated! Please use :make instead, its behavior ' . - \ 'is identical.' - sleep 5 - exec 'make' . a:bang a:args -endfunction - -" Compile the current file. -command! -bang -bar -nargs=* CoffeeMake -\ call s:CoffeeMakeDeprecated(, ) - -" Set `makeprg` on rename since we embed the filename in the setting. -augroup CoffeeUpdateMakePrg - autocmd! - - " Update `makeprg` if coffee is still the compiler, else stop running this - " function. - function! s:UpdateMakePrg() - if !s:SetMakePrg() - autocmd! CoffeeUpdateMakePrg - endif - endfunction - - " Set autocmd locally if compiler was set locally. - if &l:makeprg =~ s:pat - autocmd BufFilePost,BufWritePost call s:UpdateMakePrg() - else - autocmd BufFilePost,BufWritePost call s:UpdateMakePrg() - endif -augroup END diff --git a/bundle/coffee-script/doc/coffee-script.txt b/bundle/coffee-script/doc/coffee-script.txt deleted file mode 100644 index 1b43cf3..0000000 --- a/bundle/coffee-script/doc/coffee-script.txt +++ /dev/null @@ -1,4 +0,0 @@ -Please see the project readme for up-to-date docs: -https://github.com/kchmck/vim-coffee-script - - vim:tw=78:ts=8:ft=help:norl: diff --git a/bundle/coffee-script/ftdetect/coffee.vim b/bundle/coffee-script/ftdetect/coffee.vim deleted file mode 100644 index 5056929..0000000 --- a/bundle/coffee-script/ftdetect/coffee.vim +++ /dev/null @@ -1,17 +0,0 @@ -" Language: CoffeeScript -" Maintainer: Mick Koch -" URL: http://github.com/kchmck/vim-coffee-script -" License: WTFPL - -autocmd BufNewFile,BufRead *.coffee set filetype=coffee -autocmd BufNewFile,BufRead *Cakefile set filetype=coffee -autocmd BufNewFile,BufRead *.coffeekup,*.ck set filetype=coffee -autocmd BufNewFile,BufRead *._coffee set filetype=coffee - -function! s:DetectCoffee() - if getline(1) =~ '^#!.*\' - set filetype=coffee - endif -endfunction - -autocmd BufNewFile,BufRead * call s:DetectCoffee() diff --git a/bundle/coffee-script/ftplugin/coffee.vim b/bundle/coffee-script/ftplugin/coffee.vim deleted file mode 100644 index c44fe97..0000000 --- a/bundle/coffee-script/ftplugin/coffee.vim +++ /dev/null @@ -1,404 +0,0 @@ -" Language: CoffeeScript -" Maintainer: Mick Koch -" URL: http://github.com/kchmck/vim-coffee-script -" License: WTFPL - -if exists('b:did_ftplugin') - finish -endif - -let b:did_ftplugin = 1 -call coffee#CoffeeSetUpVariables() - -setlocal formatoptions-=t formatoptions+=croql -setlocal comments=:# commentstring=#\ %s -setlocal omnifunc=javascriptcomplete#CompleteJS - -" Create custom augroups. -augroup CoffeeBufUpdate | augroup END -augroup CoffeeBufNew | augroup END - -" Enable coffee compiler if a compiler isn't set already. -if !len(&l:makeprg) - compiler coffee -endif - -" Switch to the window for buf. -function! s:SwitchWindow(buf) - exec bufwinnr(a:buf) 'wincmd w' -endfunction - -" Create a new scratch buffer and return the bufnr of it. After the function -" returns, vim remains in the scratch buffer so more set up can be done. -function! s:ScratchBufBuild(src, vert, size) - if a:size <= 0 - if a:vert - let size = winwidth(bufwinnr(a:src)) / 2 - else - let size = winheight(bufwinnr(a:src)) / 2 - endif - endif - - if a:vert - vertical belowright new - exec 'vertical resize' size - else - belowright new - exec 'resize' size - endif - - setlocal bufhidden=wipe buftype=nofile nobuflisted noswapfile nomodifiable - nnoremap q :hide - - return bufnr('%') -endfunction - -" Replace buffer contents with text and delete the last empty line. -function! s:ScratchBufUpdate(buf, text) - " Move to the scratch buffer. - call s:SwitchWindow(a:buf) - - " Double check we're in the scratch buffer before overwriting. - if bufnr('%') != a:buf - throw 'unable to change to scratch buffer' - endif - - setlocal modifiable - silent exec '% delete _' - silent put! =a:text - silent exec '$ delete _' - setlocal nomodifiable -endfunction - -" Parse the output of coffee into a qflist entry for src buffer. -function! s:ParseCoffeeError(output, src, startline) - " Coffee error is always on first line? - let match = matchlist(a:output, - \ '^\(\f\+\|\[stdin\]\):\(\d\):\(\d\): error: \(.\{-}\)' . "\n") - - if !len(match) - return - endif - - " Consider the line number from coffee as relative and add it to the beginning - " line number of the range the command was called on, then subtract one for - " zero-based relativity. - call setqflist([{'bufnr': a:src, 'lnum': a:startline + str2nr(match[2]) - 1, - \ 'type': 'E', 'col': str2nr(match[3]), 'text': match[4]}], 'r') -endfunction - -" Reset source buffer variables. -function! s:CoffeeCompileResetVars() - " Variables defined in source buffer: - " b:coffee_compile_buf: bufnr of output buffer - " Variables defined in output buffer: - " b:coffee_src_buf: bufnr of source buffer - " b:coffee_compile_pos: previous cursor position in output buffer - - let b:coffee_compile_buf = -1 -endfunction - -function! s:CoffeeWatchResetVars() - " Variables defined in source buffer: - " b:coffee_watch_buf: bufnr of output buffer - " Variables defined in output buffer: - " b:coffee_src_buf: bufnr of source buffer - " b:coffee_watch_pos: previous cursor position in output buffer - - let b:coffee_watch_buf = -1 -endfunction - -function! s:CoffeeRunResetVars() - " Variables defined in CoffeeRun source buffer: - " b:coffee_run_buf: bufnr of output buffer - " Variables defined in CoffeeRun output buffer: - " b:coffee_src_buf: bufnr of source buffer - " b:coffee_run_pos: previous cursor position in output buffer - - let b:coffee_run_buf = -1 -endfunction - -" Clean things up in the source buffers. -function! s:CoffeeCompileClose() - " Switch to the source buffer if not already in it. - silent! call s:SwitchWindow(b:coffee_src_buf) - call s:CoffeeCompileResetVars() -endfunction - -function! s:CoffeeWatchClose() - silent! call s:SwitchWindow(b:coffee_src_buf) - silent! autocmd! CoffeeAuWatch * - call s:CoffeeWatchResetVars() -endfunction - -function! s:CoffeeRunClose() - silent! call s:SwitchWindow(b:coffee_src_buf) - call s:CoffeeRunResetVars() -endfunction - -" Compile the lines between startline and endline and put the result into buf. -function! s:CoffeeCompileToBuf(buf, startline, endline) - let src = bufnr('%') - let input = join(getline(a:startline, a:endline), "\n") - - " Coffee doesn't like empty input. - if !len(input) - " Function should still return within output buffer. - call s:SwitchWindow(a:buf) - return - endif - - " Pipe lines into coffee. - let output = system(g:coffee_compiler . - \ ' -scb' . - \ ' ' . b:coffee_litcoffee . - \ ' 2>&1', input) - - " Paste output into output buffer. - call s:ScratchBufUpdate(a:buf, output) - - " Highlight as JavaScript if there were no compile errors. - if v:shell_error - call s:ParseCoffeeError(output, src, a:startline) - setlocal filetype= - else - " Clear the quickfix list. - call setqflist([], 'r') - setlocal filetype=javascript - endif -endfunction - -" Peek at compiled CoffeeScript in a scratch buffer. We handle ranges like this -" to prevent the cursor from being moved (and its position saved) before the -" function is called. -function! s:CoffeeCompile(startline, endline, args) - if a:args =~ '\' - echoerr 'CoffeeCompile watch is deprecated! Please use CoffeeWatch instead' - sleep 5 - call s:CoffeeWatch(a:args) - return - endif - - " Switch to the source buffer if not already in it. - silent! call s:SwitchWindow(b:coffee_src_buf) - - " Bail if not in source buffer. - if !exists('b:coffee_compile_buf') - return - endif - - " Build the output buffer if it doesn't exist. - if bufwinnr(b:coffee_compile_buf) == -1 - let src = bufnr('%') - - let vert = exists('g:coffee_compile_vert') || a:args =~ '\' - let size = str2nr(matchstr(a:args, '\<\d\+\>')) - - " Build the output buffer and save the source bufnr. - let buf = s:ScratchBufBuild(src, vert, size) - let b:coffee_src_buf = src - - " Set the buffer name. - exec 'silent! file [CoffeeCompile ' . src . ']' - - " Clean up the source buffer when the output buffer is closed. - autocmd BufWipeout call s:CoffeeCompileClose() - " Save the cursor when leaving the output buffer. - autocmd BufLeave let b:coffee_compile_pos = getpos('.') - - " Run user-defined commands on new buffer. - silent doautocmd CoffeeBufNew User CoffeeCompile - - " Switch back to the source buffer and save the output bufnr. This also - " triggers BufLeave above. - call s:SwitchWindow(src) - let b:coffee_compile_buf = buf - endif - - " Fill the scratch buffer. - call s:CoffeeCompileToBuf(b:coffee_compile_buf, a:startline, a:endline) - " Reset cursor to previous position. - call setpos('.', b:coffee_compile_pos) - - " Run any user-defined commands on the scratch buffer. - silent doautocmd CoffeeBufUpdate User CoffeeCompile -endfunction - -" Update the scratch buffer and switch back to the source buffer. -function! s:CoffeeWatchUpdate() - call s:CoffeeCompileToBuf(b:coffee_watch_buf, 1, '$') - call setpos('.', b:coffee_watch_pos) - silent doautocmd CoffeeBufUpdate User CoffeeWatch - call s:SwitchWindow(b:coffee_src_buf) -endfunction - -" Continually compile a source buffer. -function! s:CoffeeWatch(args) - silent! call s:SwitchWindow(b:coffee_src_buf) - - if !exists('b:coffee_watch_buf') - return - endif - - if bufwinnr(b:coffee_watch_buf) == -1 - let src = bufnr('%') - - let vert = exists('g:coffee_watch_vert') || a:args =~ '\' - let size = str2nr(matchstr(a:args, '\<\d\+\>')) - - let buf = s:ScratchBufBuild(src, vert, size) - let b:coffee_src_buf = src - - exec 'silent! file [CoffeeWatch ' . src . ']' - - autocmd BufWipeout call s:CoffeeWatchClose() - autocmd BufLeave let b:coffee_watch_pos = getpos('.') - - silent doautocmd CoffeeBufNew User CoffeeWatch - - call s:SwitchWindow(src) - let b:coffee_watch_buf = buf - endif - - " Make sure only one watch autocmd is defined on this buffer. - silent! autocmd! CoffeeAuWatch * - - augroup CoffeeAuWatch - autocmd InsertLeave call s:CoffeeWatchUpdate() - autocmd BufWritePost call s:CoffeeWatchUpdate() - augroup END - - call s:CoffeeWatchUpdate() -endfunction - -" Run a snippet of CoffeeScript between startline and endline. -function! s:CoffeeRun(startline, endline, args) - silent! call s:SwitchWindow(b:coffee_src_buf) - - if !exists('b:coffee_run_buf') - return - endif - - if bufwinnr(b:coffee_run_buf) == -1 - let src = bufnr('%') - - let buf = s:ScratchBufBuild(src, exists('g:coffee_run_vert'), 0) - let b:coffee_src_buf = src - - exec 'silent! file [CoffeeRun ' . src . ']' - - autocmd BufWipeout call s:CoffeeRunClose() - autocmd BufLeave let b:coffee_run_pos = getpos('.') - - silent doautocmd CoffeeBufNew User CoffeeRun - - call s:SwitchWindow(src) - let b:coffee_run_buf = buf - endif - - if a:startline == 1 && a:endline == line('$') - let output = system(g:coffee_compiler . - \ ' ' . b:coffee_litcoffee . - \ ' ' . fnameescape(expand('%')) . - \ ' ' . a:args) - else - let input = join(getline(a:startline, a:endline), "\n") - - if !len(input) - return - endif - - let output = system(g:coffee_compiler . - \ ' -s' . - \ ' ' . b:coffee_litcoffee . - \ ' ' . a:args, input) - endif - - call s:ScratchBufUpdate(b:coffee_run_buf, output) - call setpos('.', b:coffee_run_pos) - - silent doautocmd CoffeeBufUpdate User CoffeeRun -endfunction - -" Run coffeelint on a file, and add any errors between startline and endline -" to the quickfix list. -function! s:CoffeeLint(startline, endline, bang, args) - let input = join(getline(a:startline, a:endline), "\n") - - if !len(input) - return - endif - - let output = system(g:coffee_linter . - \ ' -s --csv' . - \ ' ' . b:coffee_litcoffee . - \ ' ' . g:coffee_lint_options . - \ ' ' . a:args . - \ ' 2>&1', input) - - " Convert output into an array and strip off the csv header. - let lines = split(output, "\n")[1:] - let buf = bufnr('%') - let qflist = [] - - for line in lines - let match = matchlist(line, '^stdin,\(\d\+\),\d*,\(error\|warn\),\(.\+\)$') - - " Ignore unmatched lines. - if !len(match) - continue - endif - - " The 'type' will result in either 'E' or 'W'. - call add(qflist, {'bufnr': buf, 'lnum': a:startline + str2nr(match[1]) - 1, - \ 'type': toupper(match[2][0]), 'text': match[3]}) - endfor - - " Replace the quicklist with our items. - call setqflist(qflist, 'r') - - " If not given a bang, jump to first error. - if !len(a:bang) - silent! cc 1 - endif -endfunction - -" Complete arguments for Coffee* commands. -function! s:CoffeeComplete(cmd, cmdline, cursor) - let args = ['vertical'] - - " If no partial command, return all possibilities. - if !len(a:cmd) - return args - endif - - let pat = '^' . a:cmd - - for arg in args - if arg =~ pat - return [arg] - endif - endfor -endfunction - -" Set initial state variables if they don't exist -if !exists('b:coffee_compile_buf') - call s:CoffeeCompileResetVars() -endif - -if !exists('b:coffee_watch_buf') - call s:CoffeeWatchResetVars() -endif - -if !exists('b:coffee_run_buf') - call s:CoffeeRunResetVars() -endif - -command! -range=% -bar -nargs=* -complete=customlist,s:CoffeeComplete -\ CoffeeCompile call s:CoffeeCompile(, , ) -command! -bar -nargs=* -complete=customlist,s:CoffeeComplete -\ CoffeeWatch call s:CoffeeWatch() -command! -range=% -bar -nargs=* CoffeeRun -\ call s:CoffeeRun(, , ) -command! -range=% -bang -bar -nargs=* CoffeeLint -\ call s:CoffeeLint(, , , ) diff --git a/bundle/coffee-script/indent/coffee.vim b/bundle/coffee-script/indent/coffee.vim deleted file mode 100644 index 7bd82e3..0000000 --- a/bundle/coffee-script/indent/coffee.vim +++ /dev/null @@ -1,428 +0,0 @@ -" Language: CoffeeScript -" Maintainer: Mick Koch -" URL: http://github.com/kchmck/vim-coffee-script -" License: WTFPL - -if exists('b:did_indent') - finish -endif - -let b:did_indent = 1 - -setlocal autoindent -setlocal indentexpr=GetCoffeeIndent(v:lnum) -" Make sure GetCoffeeIndent is run when these are typed so they can be -" indented or outdented. -setlocal indentkeys+=0],0),0.,=else,=when,=catch,=finally - -" If no indenting or outdenting is needed, either keep the indent of the cursor -" (use autoindent) or match the indent of the previous line. -if exists('g:coffee_indent_keep_current') - let s:DEFAULT_LEVEL = '-1' -else - let s:DEFAULT_LEVEL = 'indent(prevnlnum)' -endif - -" Only define the function once. -if exists('*GetCoffeeIndent') - finish -endif - -" Keywords that begin a block -let s:BEGIN_BLOCK_KEYWORD = '\C^\%(if\|unless\|else\|for\|while\|until\|' -\ . 'loop\|switch\|when\|try\|catch\|finally\|' -\ . 'class\)\>\%(\s*:\)\@!' - -" An expression that uses the result of a statement -let s:COMPOUND_EXPRESSION = '\C\%([^-]-\|[^+]+\|[^/]/\|[:=*%&|^<>]\)\s*' -\ . '\%(if\|unless\|for\|while\|until\|loop\|switch\|' -\ . 'try\|class\)\>' - -" Combine the two above -let s:BEGIN_BLOCK = s:BEGIN_BLOCK_KEYWORD . '\|' . s:COMPOUND_EXPRESSION - -" Operators that begin a block but also count as a continuation -let s:BEGIN_BLOCK_OP = '[([{:=]$' - -" Begins a function block -let s:FUNCTION = '[-=]>$' - -" Operators that continue a line onto the next line -let s:CONTINUATION_OP = '\C\%(\<\%(is\|isnt\|and\|or\)\>\|' -\ . '[^-]-\|[^+]+\|[^-=]>\|[^.]\.\|[<*/%&|^,]\)$' - -" Ancestor operators that prevent continuation indenting -let s:CONTINUATION = s:CONTINUATION_OP . '\|' . s:BEGIN_BLOCK_OP - -" A closing bracket by itself on a line followed by a continuation -let s:BRACKET_CONTINUATION = '^\s*[}\])]\s*' . s:CONTINUATION_OP - -" A continuation dot access -let s:DOT_ACCESS = '^\.' - -" Keywords that break out of a block -let s:BREAK_BLOCK_OP = '\C^\%(return\|break\|continue\|throw\)\>' - -" A condition attached to the end of a statement -let s:POSTFIX_CONDITION = '\C\S\s\+\zs\<\%(if\|unless\|when\|while\|until\)\>' - -" A then contained in brackets -let s:CONTAINED_THEN = '\C[(\[].\{-}\.\{-\}[)\]]' - -" An else with a condition attached -let s:ELSE_COND = '\C^\s*else\s\+\<\%(if\|unless\)\>' - -" A single-line else statement (without a condition attached) -let s:SINGLE_LINE_ELSE = '\C^else\s\+\%(\<\%(if\|unless\)\>\)\@!' - -" Pairs of starting and ending keywords, with an initial pattern to match -let s:KEYWORD_PAIRS = [ -\ ['\C^else\>', '\C\<\%(if\|unless\|when\|else\s\+\%(if\|unless\)\)\>', -\ '\C\'], -\ ['\C^catch\>', '\C\', '\C\'], -\ ['\C^finally\>', '\C\', '\C\'] -\] - -" Pairs of starting and ending brackets -let s:BRACKET_PAIRS = {']': '\[', '}': '{', ')': '('} - -" Max lines to look back for a match -let s:MAX_LOOKBACK = 50 - -" Syntax names for strings -let s:SYNTAX_STRING = 'coffee\%(String\|AssignString\|Embed\|Regex\|Heregex\|' -\ . 'Heredoc\)' - -" Syntax names for comments -let s:SYNTAX_COMMENT = 'coffee\%(Comment\|BlockComment\|HeregexComment\)' - -" Syntax names for strings and comments -let s:SYNTAX_STRING_COMMENT = s:SYNTAX_STRING . '\|' . s:SYNTAX_COMMENT - -" Compatibility code for shiftwidth() as recommended by the docs, but modified -" so there isn't as much of a penalty if shiftwidth() exists. -if exists('*shiftwidth') - let s:ShiftWidth = function('shiftwidth') -else - function! s:ShiftWidth() - return &shiftwidth - endfunction -endif - -" Get the linked syntax name of a character. -function! s:SyntaxName(lnum, col) - return synIDattr(synID(a:lnum, a:col, 1), 'name') -endfunction - -" Check if a character is in a comment. -function! s:IsComment(lnum, col) - return s:SyntaxName(a:lnum, a:col) =~ s:SYNTAX_COMMENT -endfunction - -" Check if a character is in a string. -function! s:IsString(lnum, col) - return s:SyntaxName(a:lnum, a:col) =~ s:SYNTAX_STRING -endfunction - -" Check if a character is in a comment or string. -function! s:IsCommentOrString(lnum, col) - return s:SyntaxName(a:lnum, a:col) =~ s:SYNTAX_STRING_COMMENT -endfunction - -" Search a line for a regex until one is found outside a string or comment. -function! s:SearchCode(lnum, regex) - " Start at the first column and look for an initial match (including at the - " cursor.) - call cursor(a:lnum, 1) - let pos = search(a:regex, 'c', a:lnum) - - while pos - if !s:IsCommentOrString(a:lnum, col('.')) - return 1 - endif - - " Move to the match and continue searching (don't accept matches at the - " cursor.) - let pos = search(a:regex, '', a:lnum) - endwhile - - return 0 -endfunction - -" Search for the nearest previous line that isn't a comment. -function! s:GetPrevNormalLine(startlnum) - let curlnum = a:startlnum - - while curlnum - let curlnum = prevnonblank(curlnum - 1) - - " Return the line if the first non-whitespace character isn't a comment. - if !s:IsComment(curlnum, indent(curlnum) + 1) - return curlnum - endif - endwhile - - return 0 -endfunction - -function! s:SearchPair(startlnum, lookback, skip, open, close) - " Go to the first column so a:close will be matched even if it's at the - " beginning of the line. - call cursor(a:startlnum, 1) - return searchpair(a:open, '', a:close, 'bnW', a:skip, max([1, a:lookback])) -endfunction - -" Skip if a match -" - is in a string or comment -" - is a single-line statement that isn't immediately -" adjacent -" - has a postfix condition and isn't an else statement or compound -" expression -function! s:ShouldSkip(startlnum, lnum, col) - return s:IsCommentOrString(a:lnum, a:col) || - \ s:SearchCode(a:lnum, '\C\') && a:startlnum - a:lnum > 1 || - \ s:SearchCode(a:lnum, s:POSTFIX_CONDITION) && - \ getline(a:lnum) !~ s:ELSE_COND && - \ !s:SearchCode(a:lnum, s:COMPOUND_EXPRESSION) -endfunction - -" Search for the nearest and farthest match for a keyword pair. -function! s:SearchMatchingKeyword(startlnum, open, close) - let skip = 's:ShouldSkip(' . a:startlnum . ", line('.'), line('.'))" - - " Search for the nearest match. - let nearestlnum = s:SearchPair(a:startlnum, a:startlnum - s:MAX_LOOKBACK, - \ skip, a:open, a:close) - - if !nearestlnum - return [] - endif - - " Find the nearest previous line with indent less than or equal to startlnum. - let ind = indent(a:startlnum) - let lookback = s:GetPrevNormalLine(a:startlnum) - - while lookback && indent(lookback) > ind - let lookback = s:GetPrevNormalLine(lookback) - endwhile - - " Search for the farthest match. If there are no other matches, then the - " nearest match is also the farthest one. - let matchlnum = nearestlnum - - while matchlnum - let lnum = matchlnum - let matchlnum = s:SearchPair(matchlnum, lookback, skip, a:open, a:close) - endwhile - - return [nearestlnum, lnum] -endfunction - -" Strip a line of a trailing comment and surrounding whitespace. -function! s:GetTrimmedLine(lnum) - " Try to find a comment starting at the first column. - call cursor(a:lnum, 1) - let pos = search('#', 'c', a:lnum) - - " Keep searching until a comment is found or search returns 0. - while pos - if s:IsComment(a:lnum, col('.')) - break - endif - - let pos = search('#', '', a:lnum) - endwhile - - if !pos - " No comment was found so use the whole line. - let line = getline(a:lnum) - else - " Subtract 1 to get to the column before the comment and another 1 for - " column indexing -> zero-based indexing. - let line = getline(a:lnum)[:col('.') - 2] - endif - - return substitute(substitute(line, '^\s\+', '', ''), - \ '\s\+$', '', '') -endfunction - -" Get the indent policy when no special rules are used. -function! s:GetDefaultPolicy(curlnum) - " Check whether equalprg is being ran on existing lines. - if strlen(getline(a:curlnum)) == indent(a:curlnum) - " If not indenting an existing line, use the default policy. - return s:DEFAULT_LEVEL - else - " Otherwise let autoindent determine what to do with an existing line. - return '-1' - endif -endfunction - -function! GetCoffeeIndent(curlnum) - " Get the previous non-blank line (may be a comment.) - let prevlnum = prevnonblank(a:curlnum - 1) - - " Bail if there's no code before. - if !prevlnum - return -1 - endif - - " Bail if inside a multiline string. - if s:IsString(a:curlnum, 1) - let prevnlnum = prevlnum - exec 'return' s:GetDefaultPolicy(a:curlnum) - endif - - " Get the code part of the current line. - let curline = s:GetTrimmedLine(a:curlnum) - " Get the previous non-comment line. - let prevnlnum = s:GetPrevNormalLine(a:curlnum) - - " Check if the current line is the closing bracket in a bracket pair. - if has_key(s:BRACKET_PAIRS, curline[0]) - " Search for a matching opening bracket. - let matchlnum = s:SearchPair(a:curlnum, a:curlnum - s:MAX_LOOKBACK, - \ "s:IsCommentOrString(line('.'), col('.'))", - \ s:BRACKET_PAIRS[curline[0]], curline[0]) - - if matchlnum - " Match the indent of the opening bracket. - return indent(matchlnum) - else - " No opening bracket found (bad syntax), so bail. - exec 'return' s:GetDefaultPolicy(a:curlnum) - endif - endif - - " Check if the current line is the closing keyword in a keyword pair. - for pair in s:KEYWORD_PAIRS - if curline =~ pair[0] - " Find the nearest and farthest matches within the same indent level. - let matches = s:SearchMatchingKeyword(a:curlnum, pair[1], pair[2]) - - if len(matches) - " Don't force indenting/outdenting as long as line is already lined up - " with a valid match - return max([min([indent(a:curlnum), indent(matches[0])]), - \ indent(matches[1])]) - else - " No starting keyword found (bad syntax), so bail. - exec 'return' s:GetDefaultPolicy(a:curlnum) - endif - endif - endfor - - " Check if the current line is a `when` and not the first in a switch block. - if curline =~ '\C^when\>' && !s:SearchCode(prevnlnum, '\C\') - " Look back for a `when`. - while prevnlnum - if getline(prevnlnum) =~ '\C^\s*when\>' - " Indent to match the found `when`, but don't force indenting (for when - " indenting nested switch blocks.) - return min([indent(a:curlnum), indent(prevnlnum)]) - endif - - let prevnlnum = s:GetPrevNormalLine(prevnlnum) - endwhile - - " No matching `when` found (bad syntax), so bail. - exec 'return' s:GetDefaultPolicy(a:curlnum) - endif - - " If the previous line is a comment, use its indentation, but don't force - " indenting. - if prevlnum != prevnlnum - return min([indent(a:curlnum), indent(prevlnum)]) - endif - - let prevline = s:GetTrimmedLine(prevnlnum) - - " Always indent after these operators. - if prevline =~ s:BEGIN_BLOCK_OP - return indent(prevnlnum) + s:ShiftWidth() - endif - - " Indent if the previous line starts a function block, but don't force - " indenting if the line is non-blank (for empty function bodies.) - if prevline =~ s:FUNCTION - if strlen(getline(a:curlnum)) > indent(a:curlnum) - return min([indent(prevnlnum) + s:ShiftWidth(), indent(a:curlnum)]) - else - return indent(prevnlnum) + s:ShiftWidth() - endif - endif - - " Check if continuation indenting is needed. If the line ends in a slash, make - " sure it isn't a regex. - if prevline =~ s:CONTINUATION_OP && - \ !(prevline =~ '/$' && s:IsString(prevnlnum, col([prevnlnum, '$']) - 1)) - " Don't indent if the continuation follows a closing bracket. - if prevline =~ s:BRACKET_CONTINUATION - exec 'return' s:GetDefaultPolicy(a:curlnum) - endif - - let prevprevnlnum = s:GetPrevNormalLine(prevnlnum) - - " Don't indent if not the first continuation. - if prevprevnlnum && s:GetTrimmedLine(prevprevnlnum) =~ s:CONTINUATION - exec 'return' s:GetDefaultPolicy(a:curlnum) - endif - - " Continuation indenting seems to vary between programmers, so if the line - " is non-blank, don't override the indentation - if strlen(getline(a:curlnum)) > indent(a:curlnum) - exec 'return' s:GetDefaultPolicy(a:curlnum) - endif - - " Otherwise indent a level. - return indent(prevnlnum) + s:ShiftWidth() - endif - - " Check if the previous line starts with a keyword that begins a block. - if prevline =~ s:BEGIN_BLOCK - " Indent if the current line doesn't start with `then` and the previous line - " isn't a single-line statement. - if curline !~ '\C^\' && !s:SearchCode(prevnlnum, '\C\') && - \ prevline !~ s:SINGLE_LINE_ELSE - return indent(prevnlnum) + s:ShiftWidth() - else - exec 'return' s:GetDefaultPolicy(a:curlnum) - endif - endif - - " Indent a dot access if it's the first. - if curline =~ s:DOT_ACCESS - if prevline !~ s:DOT_ACCESS - return indent(prevnlnum) + s:ShiftWidth() - else - exec 'return' s:GetDefaultPolicy(a:curlnum) - endif - endif - - " Outdent if a keyword breaks out of a block as long as it doesn't have a - " postfix condition (and the postfix condition isn't a single-line statement.) - if prevline =~ s:BREAK_BLOCK_OP - if !s:SearchCode(prevnlnum, s:POSTFIX_CONDITION) || - \ s:SearchCode(prevnlnum, '\C\') && - \ !s:SearchCode(prevnlnum, s:CONTAINED_THEN) - " Don't force indenting. - return min([indent(a:curlnum), indent(prevnlnum) - s:ShiftWidth()]) - else - exec 'return' s:GetDefaultPolicy(a:curlnum) - endif - endif - - " Check if inside brackets. - let matchlnum = s:SearchPair(a:curlnum, a:curlnum - s:MAX_LOOKBACK, - \ "s:IsCommentOrString(line('.'), col('.'))", - \ '\[\|(\|{', '\]\|)\|}') - - " If inside brackets, indent relative to the brackets, but don't outdent an - " already indented line. - if matchlnum - return max([indent(a:curlnum), indent(matchlnum) + s:ShiftWidth()]) - endif - - " No special rules applied, so use the default policy. - exec 'return' s:GetDefaultPolicy(a:curlnum) -endfunction diff --git a/bundle/coffee-script/syntax/coffee.vim b/bundle/coffee-script/syntax/coffee.vim deleted file mode 100755 index eea5084..0000000 --- a/bundle/coffee-script/syntax/coffee.vim +++ /dev/null @@ -1,223 +0,0 @@ -" Language: CoffeeScript -" Maintainer: Mick Koch -" URL: http://github.com/kchmck/vim-coffee-script -" License: WTFPL - -" Bail if our syntax is already loaded. -if exists('b:current_syntax') && b:current_syntax == 'coffee' - finish -endif - -" Include JavaScript for coffeeEmbed. -syn include @coffeeJS syntax/javascript.vim -silent! unlet b:current_syntax - -" Highlight long strings. -syntax sync fromstart - -" CoffeeScript identifiers can have dollar signs. -setlocal isident+=$ - -" These are `matches` instead of `keywords` because vim's highlighting -" priority for keywords is higher than matches. This causes keywords to be -" highlighted inside matches, even if a match says it shouldn't contain them -- -" like with coffeeAssign and coffeeDot. -syn match coffeeStatement /\<\%(return\|break\|continue\|throw\)\>/ display -hi def link coffeeStatement Statement - -syn match coffeeRepeat /\<\%(for\|while\|until\|loop\)\>/ display -hi def link coffeeRepeat Repeat - -syn match coffeeConditional /\<\%(if\|else\|unless\|switch\|when\|then\)\>/ -\ display -hi def link coffeeConditional Conditional - -syn match coffeeException /\<\%(try\|catch\|finally\)\>/ display -hi def link coffeeException Exception - -syn match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\)\>/ -\ display -" The `own` keyword is only a keyword after `for`. -syn match coffeeKeyword /\/ contained containedin=coffeeRepeat -\ display -hi def link coffeeKeyword Keyword - -syn match coffeeOperator /\<\%(instanceof\|typeof\|delete\)\>/ display -hi def link coffeeOperator Operator - -" The first case matches symbol operators only if they have an operand before. -syn match coffeeExtendedOp /\%(\S\s*\)\@<=[+\-*/%&|\^=!<>?.]\{-1,}\|[-=]>\|--\|++\|:/ -\ display -syn match coffeeExtendedOp /\<\%(and\|or\)=/ display -hi def link coffeeExtendedOp coffeeOperator - -" This is separate from `coffeeExtendedOp` to help differentiate commas from -" dots. -syn match coffeeSpecialOp /[,;]/ display -hi def link coffeeSpecialOp SpecialChar - -syn match coffeeBoolean /\<\%(true\|on\|yes\|false\|off\|no\)\>/ display -hi def link coffeeBoolean Boolean - -syn match coffeeGlobal /\<\%(null\|undefined\)\>/ display -hi def link coffeeGlobal Type - -" A special variable -syn match coffeeSpecialVar /\<\%(this\|prototype\|arguments\)\>/ display -hi def link coffeeSpecialVar Special - -" An @-variable -syn match coffeeSpecialIdent /@\%(\I\i*\)\?/ display -hi def link coffeeSpecialIdent Identifier - -" A class-like name that starts with a capital letter -syn match coffeeObject /\<\u\w*\>/ display -hi def link coffeeObject Structure - -" A constant-like name in SCREAMING_CAPS -syn match coffeeConstant /\<\u[A-Z0-9_]\+\>/ display -hi def link coffeeConstant Constant - -" A variable name -syn cluster coffeeIdentifier contains=coffeeSpecialVar,coffeeSpecialIdent, -\ coffeeObject,coffeeConstant - -" A non-interpolated string -syn cluster coffeeBasicString contains=@Spell,coffeeEscape -" An interpolated string -syn cluster coffeeInterpString contains=@coffeeBasicString,coffeeInterp - -" Regular strings -syn region coffeeString start=/"/ skip=/\\\\\|\\"/ end=/"/ -\ contains=@coffeeInterpString -syn region coffeeString start=/'/ skip=/\\\\\|\\'/ end=/'/ -\ contains=@coffeeBasicString -hi def link coffeeString String - -" A integer, including a leading plus or minus -syn match coffeeNumber /\i\@/ display -syn match coffeeNumber /\<0[bB][01]\+\>/ display -syn match coffeeNumber /\<0[oO][0-7]\+\>/ display -hi def link coffeeNumber Number - -" A floating-point number, including a leading plus or minus -syn match coffeeFloat /\i\@/ -\ display -hi def link coffeeReservedError Error - -" A normal object assignment -syn match coffeeObjAssign /@\?\I\i*\s*\ze::\@!/ contains=@coffeeIdentifier display -hi def link coffeeObjAssign Identifier - -syn keyword coffeeTodo TODO FIXME XXX contained -hi def link coffeeTodo Todo - -syn match coffeeComment /#.*/ contains=@Spell,coffeeTodo -hi def link coffeeComment Comment - -syn region coffeeBlockComment start=/####\@!/ end=/###/ -\ contains=@Spell,coffeeTodo -hi def link coffeeBlockComment coffeeComment - -" A comment in a heregex -syn region coffeeHeregexComment start=/#/ end=/\ze\/\/\/\|$/ contained -\ contains=@Spell,coffeeTodo -hi def link coffeeHeregexComment coffeeComment - -" Embedded JavaScript -syn region coffeeEmbed matchgroup=coffeeEmbedDelim -\ start=/`/ skip=/\\\\\|\\`/ end=/`/ keepend -\ contains=@coffeeJS -hi def link coffeeEmbedDelim Delimiter - -syn region coffeeInterp matchgroup=coffeeInterpDelim start=/#{/ end=/}/ contained -\ contains=@coffeeAll -hi def link coffeeInterpDelim PreProc - -" A string escape sequence -syn match coffeeEscape /\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\./ contained display -hi def link coffeeEscape SpecialChar - -" A regex -- must not follow a parenthesis, number, or identifier, and must not -" be followed by a number -syn region coffeeRegex start=#\%(\%()\|\i\@> #{ == { { { } } } == } << " -" >> #{ == { abc: { def: 42 } } == } << " diff --git a/bundle/coffee-script/test/test-ops.coffee b/bundle/coffee-script/test/test-ops.coffee deleted file mode 100644 index 54be8db..0000000 --- a/bundle/coffee-script/test/test-ops.coffee +++ /dev/null @@ -1,90 +0,0 @@ -# Various operators -abc instanceof def -typeof abc -delete abc -abc::def - -abc + def -abc - def -abc * def -abc / def -abc % def -abc & def -abc | def -abc ^ def -abc >> def -abc << def -abc >>> def -abc ? def -abc && def -abc and def -abc || def -abc or def - -abc += def -abc -= def -abc *= def -abc /= def -abc %= def -abc &= def -abc |= def -abc ^= def -abc >>= def -abc <<= def -abc >>>= def -abc ?= def -abc &&= def -abc ||= def - -abc and= def -abc or= def - -abc.def.ghi -abc?.def?.ghi - -abc < def -abc > def -abc = def -abc == def -abc != def -abc <= def -abc >= def - -abc++ -abc-- -++abc ---abc - -# Nested operators -abc[def] = ghi -abc[def[ghi: jkl]] = 42 -@abc[def] = ghi - -abc["#{def = 42}"] = 42 -abc["#{def.ghi = 42}"] = 42 -abc["#{def[ghi] = 42}"] = 42 -abc["#{def['ghi']}"] = 42 - -# Object assignments -abc = - def: 123 - DEF: 123 - @def: 123 - Def: 123 - 'def': 123 - 42: 123 - -# Operators shouldn't be highlighted -vector= -wand= - -abc+++ -abc--- -abc ** def -abc &&& def -abc ^^ def -abc ===== def -abc <==== def -abc >==== def -abc +== def -abc =^= def diff --git a/bundle/coffee-script/test/test-reserved.coffee b/bundle/coffee-script/test/test-reserved.coffee deleted file mode 100644 index b841760..0000000 --- a/bundle/coffee-script/test/test-reserved.coffee +++ /dev/null @@ -1,27 +0,0 @@ -# Should be an error -function = 42 -var = 42 - -# Shouldn't be an error -abc.with = 42 -function: 42 -var: 42 - -# Keywords shouldn't be highlighted -abc.function -abc.do -abc.break -abc.true - -abc::function -abc::do -abc::break -abc::true - -abc:: function -abc. function - -# Numbers should be highlighted -def.42 -def .42 -def::42 diff --git a/bundle/coffee-script/test/test.haml b/bundle/coffee-script/test/test.haml deleted file mode 100644 index ae19fba..0000000 --- a/bundle/coffee-script/test/test.haml +++ /dev/null @@ -1,3 +0,0 @@ -:coffeescript - class Hello - # test diff --git a/bundle/coffee-script/test/test.html b/bundle/coffee-script/test/test.html deleted file mode 100644 index 3479145..0000000 --- a/bundle/coffee-script/test/test.html +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/bundle/elixir/.travis.yml b/bundle/elixir/.travis.yml deleted file mode 100755 index 3e67b0c..0000000 --- a/bundle/elixir/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: ruby -rvm: - - 1.9.3 -before_install: sudo apt-get install vim-gtk -before_script: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" -script: "bundle exec rspec --color -f d" diff --git a/bundle/elixir/Gemfile b/bundle/elixir/Gemfile deleted file mode 100755 index c543a5d..0000000 --- a/bundle/elixir/Gemfile +++ /dev/null @@ -1,4 +0,0 @@ -source 'http://rubygems.org/' - -gem 'rspec' -gem 'vimrunner' diff --git a/bundle/elixir/Gemfile.lock b/bundle/elixir/Gemfile.lock deleted file mode 100755 index 8d4d64f..0000000 --- a/bundle/elixir/Gemfile.lock +++ /dev/null @@ -1,20 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - diff-lcs (1.2.4) - rspec (2.13.0) - rspec-core (~> 2.13.0) - rspec-expectations (~> 2.13.0) - rspec-mocks (~> 2.13.0) - rspec-core (2.13.1) - rspec-expectations (2.13.0) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.13.1) - vimrunner (0.3.0) - -PLATFORMS - ruby - -DEPENDENCIES - rspec - vimrunner diff --git a/bundle/elixir/README.md b/bundle/elixir/README.md deleted file mode 100755 index 7ed3b46..0000000 --- a/bundle/elixir/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# vim-elixir - -[![Build Status](https://travis-ci.org/elixir-lang/vim-elixir.png?branch=master)](https://travis-ci.org/elixir-lang/vim-elixir) - -This project contains some Vim configuration files to work with [Elixir](http://elixir-lang.org). - -So far it's included: - -* Syntax highlighting - -* Filetype detection - -* Auto indentation - -## Install - -* Copy the files to your `~/.vim` directory. - -* If you use vim-pathogen you can clone this repo into `~/.vim/bundle` - -## Snippets - -If you are looking for snipmate snippets take a look at: [elixir-snippets](https://github.com/carlosgaldino/elixir-snippets) diff --git a/bundle/elixir/compiler/exunit.vim b/bundle/elixir/compiler/exunit.vim deleted file mode 100755 index 2c9fb29..0000000 --- a/bundle/elixir/compiler/exunit.vim +++ /dev/null @@ -1,24 +0,0 @@ -" Vim compiler file -" Language: ExUnit -" Maintainer: Rein Henrichs -" URL: https://github.com/elixir-lang/vim-elixir - -if exists("current_compiler") - finish -endif -let current_compiler = "exunit" - -if exists(":CompilerSet") != 2 " older Vim always used :setlocal - command -nargs=* CompilerSet setlocal -endif - -let s:cpo_save = &cpo -set cpo-=C - -CompilerSet makeprg=mix\ test -CompilerSet errorformat=%A\ \ %.)\ %m(%.%#),%C\ \ \ \ \ **%m,%C\ \ \ \ \ \ \ %m,%Z\ \ \ \ \ at\ %f:%l,%-G%.%# - -let &cpo = s:cpo_save -unlet s:cpo_save - -" vim: nowrap sw=2 sts=2 ts=8: diff --git a/bundle/elixir/ftdetect/elixir.vim b/bundle/elixir/ftdetect/elixir.vim deleted file mode 100755 index df413e1..0000000 --- a/bundle/elixir/ftdetect/elixir.vim +++ /dev/null @@ -1,2 +0,0 @@ -au BufRead,BufNewFile *.ex,*.exs set filetype=elixir -au FileType elixir setl sw=2 sts=2 et iskeyword+=!,? diff --git a/bundle/elixir/ftplugin/elixir.vim b/bundle/elixir/ftplugin/elixir.vim deleted file mode 100755 index 5571fcf..0000000 --- a/bundle/elixir/ftplugin/elixir.vim +++ /dev/null @@ -1,25 +0,0 @@ -" Vim filetype plugin -" Language: Elixir -" Maintainer: Carlos Galdino -" URL: https://github.com/elixir-lang/vim-elixir - -if (exists("b:did_ftplugin")) - finish -endif -let b:did_ftplugin = 1 - - -" Matchit support -if exists("loaded_matchit") && !exists("b:match_words") - let b:match_ignorecase = 0 - - let b:match_words = '\<\%(do\|fn\)\:\@!\>' . - \ ':' . - \ '\<\%(else\|elsif\|catch\|after\|rescue\)\:\@!\>' . - \ ':' . - \ '\:\@' . - \ ',{:},\[:\],(:)' -endif - -setlocal comments=:# -setlocal commentstring=#\ %s diff --git a/bundle/elixir/indent/elixir.vim b/bundle/elixir/indent/elixir.vim deleted file mode 100755 index fababe4..0000000 --- a/bundle/elixir/indent/elixir.vim +++ /dev/null @@ -1,107 +0,0 @@ -" Vim indent file -" Language: Elixir -" Maintainer: Carlos Galdino -" Last Change: 2013 Apr 24 - -if exists("b:did_indent") - finish -endif -let b:did_indent = 1 - -setlocal nosmartindent - -setlocal indentexpr=GetElixirIndent() -setlocal indentkeys+==end,=else:,=match:,=elsif:,=catch:,=after:,=rescue: - -if exists("*GetElixirIndent") - finish -endif - -let s:cpo_save = &cpo -set cpo&vim - -let s:skip_syntax = '\%(Comment\|String\)$' -let s:block_skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '" . s:skip_syntax . "'" -let s:block_start = 'do\|fn' -let s:block_middle = 'else\|match\|elsif\|catch\|after\|rescue' -let s:block_end = 'end' -let s:arrow = '^.*->$' -let s:pipeline = '^\s*|>.*$' - -let s:indent_keywords = '\<\%(' . s:block_start . '\|' . s:block_middle . '\)$' . '\|' . s:arrow -let s:deindent_keywords = '^\s*\<\%(' . s:block_end . '\|' . s:block_middle . '\)\>' . '\|' . s:arrow - -function! GetElixirIndent() - let lnum = prevnonblank(v:lnum - 1) - let ind = indent(lnum) - - " At the start of the file use zero indent. - if lnum == 0 - return 0 - endif - - " TODO: Remove these 2 lines - " I don't know why, but for the test on spec/indent/lists_spec.rb:24. - " Vim is making some mess on parsing the syntax of 'end', it is being - " recognized as 'elixirString' when should be recognized as 'elixirBlock'. - " This forces vim to sync the syntax. - call synID(v:lnum, 1, 1) - syntax sync fromstart - - if synIDattr(synID(v:lnum, 1, 1), "name") !~ s:skip_syntax - let current_line = getline(v:lnum) - let last_line = getline(lnum) - - let splited_line = split(last_line, '\zs') - let opened_symbol = 0 - let opened_symbol += count(splited_line, '[') - count(splited_line, ']') - let opened_symbol += count(splited_line, '{') - count(splited_line, '}') - - let ind += opened_symbol * &sw - - if current_line =~ '^\s*\(\]\|}\)' - let ind -= &sw - endif - - if last_line =~ s:indent_keywords - let ind += &sw - endif - - " if line starts with pipeline - " and last line is an attribution - " indents pipeline in same level as attribution - if current_line =~ s:pipeline && - \ last_line =~ '^[^=]\+=.\+$' - let b:old_ind = ind - let ind = float2nr(matchend(last_line, '=\s*[^ ]') / &sw) * &sw - endif - - " if last line starts with pipeline - " and current line doesn't start with pipeline - " returns the indentation before the pipeline - if last_line =~ s:pipeline && - \ current_line !~ s:pipeline - let ind = b:old_ind - endif - - if current_line =~ s:deindent_keywords - let bslnum = searchpair( '\<\%(' . s:block_start . '\):\@!\>', - \ '\<\%(' . s:block_middle . '\):\@!\>\zs', - \ '\<:\@\zs', - \ 'nbW', - \ s:block_skip ) - - let ind = indent(bslnum) - endif - - " indent case statements '->' - if current_line =~ s:arrow - let ind += &sw - endif - endif - - return ind -endfunction - -let &cpo = s:cpo_save -unlet s:cpo_save diff --git a/bundle/elixir/spec/indent/anonymous_functions_spec.rb b/bundle/elixir/spec/indent/anonymous_functions_spec.rb deleted file mode 100755 index e3dd40f..0000000 --- a/bundle/elixir/spec/indent/anonymous_functions_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'spec_helper' - -describe "Indenting" do - context "single body functions inside do block" do - it "is declared with fn syntax" do - assert_correct_indenting <<-EOF - def do - some_func = fn x -> x end - end - EOF - end - - it "is declared with function syntax" do - assert_correct_indenting <<-EOF - def do - some_func = function do x -> x end - end - EOF - end - - it "spans in multiple lines" do - assert_correct_indenting <<-EOF - def test do - assert_raise Queue.Empty, fn -> - Q.new |> Q.deq! - end - end - EOF - end - - it "spans in multiple lines inside parentheses" do - assert_correct_indenting <<-EOF - defmodule Test do - def lol do - Enum.map([1,2,3], fn x -> - x * 3 - end) - end - end - EOF - end - end - - context "multiple body functions declaring" do - it "it with fn syntax" do - assert_correct_indenting <<-EOF - fizzbuzz = fn - 0, 0, _ -> "FizzBuzz" - 0, _, _ -> "Fizz" - _, 0, _ -> "Buzz" - _, _, x -> x - end - EOF - end - - it "it with function syntax" do - assert_correct_indenting <<-EOF - fizzbuzz = function do - 0, 0, _ -> "FizzBuzz" - 0, _, _ -> "Fizz" - _, 0, _ -> "Buzz" - _, _, x -> x - end - EOF - end - end -end diff --git a/bundle/elixir/spec/indent/blocks_spec.rb b/bundle/elixir/spec/indent/blocks_spec.rb deleted file mode 100755 index cbc0c82..0000000 --- a/bundle/elixir/spec/indent/blocks_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'spec_helper' - -describe "Indenting" do - specify "'do' indenting" do - assert_correct_indenting <<-EOF - do - something - end - EOF - end - - it "does not consider :end as end" do - assert_correct_indenting <<-EOF - defmodule Test do - def lol do - IO.inspect :end - end - end - EOF - end - - it "does not consider do: as the start of a block" do - assert_correct_indenting <<-EOF - def f do - if true do: 42 - end - EOF - end -end diff --git a/bundle/elixir/spec/indent/case_spec.rb b/bundle/elixir/spec/indent/case_spec.rb deleted file mode 100755 index e0df5d6..0000000 --- a/bundle/elixir/spec/indent/case_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'spec_helper' - -describe "Indenting" do - specify "case statements" do - assert_correct_indenting <<-EOF - case some_function do - :ok -> - :ok - { :error, :message } -> - { :error, :message } - end - EOF - end -end diff --git a/bundle/elixir/spec/indent/cond_spec.rb b/bundle/elixir/spec/indent/cond_spec.rb deleted file mode 100755 index d3534d1..0000000 --- a/bundle/elixir/spec/indent/cond_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'spec_helper' - -describe "Indenting" do - it "conditional" do - assert_correct_indenting <<-EOF - cond do - foo -> 1 - bar -> 2 - end - EOF - end -end diff --git a/bundle/elixir/spec/indent/documentation_spec.rb b/bundle/elixir/spec/indent/documentation_spec.rb deleted file mode 100755 index 72d0c7d..0000000 --- a/bundle/elixir/spec/indent/documentation_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -describe "Indenting" do - context "documentation" do - it "with end keyword" do - assert_correct_indenting <<-EOF - defmodule Test do - @doc """ - end - """ - end - EOF - end - end -end diff --git a/bundle/elixir/spec/indent/if_spec.rb b/bundle/elixir/spec/indent/if_spec.rb deleted file mode 100755 index 0d0970a..0000000 --- a/bundle/elixir/spec/indent/if_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe "Indenting" do - it "if-clauses" do - assert_correct_indenting <<-EOF - if foo do - bar - end - EOF - end - - it "if-else-clauses" do - assert_correct_indenting <<-EOF - if foo do - bar - else - baz - end - EOF - end -end diff --git a/bundle/elixir/spec/indent/lists_spec.rb b/bundle/elixir/spec/indent/lists_spec.rb deleted file mode 100755 index 895c07f..0000000 --- a/bundle/elixir/spec/indent/lists_spec.rb +++ /dev/null @@ -1,77 +0,0 @@ -require 'spec_helper' - -describe "Indenting" do - specify "lists" do - assert_correct_indenting <<-EOF - def example do - [ :foo, - :bar, - :baz ] - end - EOF - end - - specify "keyword list" do - assert_correct_indenting <<-EOF - def project do - [ name: "mix", - version: "0.1.0", - deps: deps ] - end - EOF - end - - specify "keyword" do - assert_correct_indenting <<-EOF - def config do - [ name: - "John" ] - end - EOF - end - - specify "list of tuples" do - assert_correct_indenting <<-EOF - def test do - [ { :cowboy, github: "extend/cowboy" }, - { :dynamo, "0.1.0-dev", github: "elixir-lang/dynamo" }, - { :ecto, github: "elixir-lang/ecto" }, - { :pgsql, github: "semiocast/pgsql" } ] - end - EOF - end - - specify "list of lists" do - assert_correct_indenting <<-EOF - def test do - [ [:a, :b, :c], - [:d, :e, :f] ] - end - EOF - end - - specify "complex list" do - assert_correct_indenting <<-EOF - def test do - [ app: :first, - version: "0.0.1", - dynamos: [First.Dynamo], - compilers: [:elixir, :dynamo, :ecto, :app], - env: [prod: [compile_path: "ebin"]], - compile_path: "tmp/first/ebin", - deps: deps ] - end - EOF - end - - specify "lists with break line after square brackets" do - assert_correct_indenting <<-EOF - def project do - deps: [ - { :bar, path: "deps/umbrella/apps/bar" }, - { :umbrella, path: "deps/umbrella" } - ] - end - EOF - end -end diff --git a/bundle/elixir/spec/indent/pipeline_spec.rb b/bundle/elixir/spec/indent/pipeline_spec.rb deleted file mode 100755 index 26db511..0000000 --- a/bundle/elixir/spec/indent/pipeline_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'spec_helper' - -describe "Indenting" do - it "using multiline pipeline" do - assert_correct_indenting <<-EOF - "a,b,c,d" - |> String.split(",") - |> Enum.reverse - EOF - end - - it "attribuition using multline pipeline operator" do - assert_correct_indenting <<-EOF - [ h | t ] = "a,b,c,d" - |> String.split(",") - |> Enum.reverse - EOF - end - - it "function with pipeline operator" do - assert_correct_indenting <<-EOF - def test do - [ h | t ] = "a,b,c,d" - |> String.split(",") - |> Enum.reverse - - { :ok, h } - end - EOF - end - - it "pipeline operator with block open" do - assert_correct_indenting <<-EOF - def test do - "a,b,c,d" - |> String.split(",") - |> Enum.first - |> case do - "a" -> "A" - _ -> "Z" - end - end - EOF - end - - it "using a record with pipeline" do - assert_correct_indenting <<-EOF - defrecord RECORD, field_a: nil, field_b: nil - - rec = RECORD.new - |> IO.inspect - EOF - end -end diff --git a/bundle/elixir/spec/indent/tuples_spec.rb b/bundle/elixir/spec/indent/tuples_spec.rb deleted file mode 100755 index 5464704..0000000 --- a/bundle/elixir/spec/indent/tuples_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'spec_helper' - -describe "Indenting" do - specify "multiline tuple" do - assert_correct_indenting <<-EOF - def xpto do - { :a, - :b, - :c } - end - EOF - end - - specify "tuples with break line after square brackets" do - assert_correct_indenting <<-EOF - def method do - { - :bar, - path: "deps/umbrella/apps/bar" - } - end - EOF - end -end diff --git a/bundle/elixir/spec/spec_helper.rb b/bundle/elixir/spec/spec_helper.rb deleted file mode 100755 index ab86908..0000000 --- a/bundle/elixir/spec/spec_helper.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'tmpdir' -require 'vimrunner' - -module Support - def assert_correct_indenting(string) - content = write_file(string) - - @vim.edit file - # remove all indentation - @vim.normal 'ggVG999<<' - # force vim to indent the file - @vim.normal 'gg=G' - @vim.write - - read_file.should eq(content) - end - - def assert_correct_syntax(syntax, cursor, string) - write_file(string) - - @vim.edit file - @vim.search cursor - - cursor_syntax_stack.should include(syntax) - end - - def assert_incorrect_syntax(type, cursor, string) - write_file(string) - - @vim.edit file - @vim.search cursor - - cursor_syntax_stack.should_not include(type) - end - - private - - def write_file(string) - content = file_content(string) - File.open file, 'w' do |f| - f.write content - end - - content - end - - def file_content(string) - whitespace = string.scan(/^\s*/).first - string.split("\n").map { |line| - line.gsub(/^#{whitespace}/, '') - }.join("\n").strip - end - - def cursor_syntax_stack - @vim.echo <<-EOF - map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') - EOF - end - - def read_file - IO.read(file).strip - end - - def file; 'test.exs'; end -end - -RSpec.configure do |config| - include Support - - config.before(:suite) do - VIM = Vimrunner.start_gvim - VIM.prepend_runtimepath(File.expand_path('../..', __FILE__)) - VIM.command('runtime ftdetect/elixir.vim') - end - - config.after(:suite) do - VIM.kill - end - - config.around(:each) do |example| - @vim = VIM - - # cd into a temporary directory for every example. - Dir.mktmpdir do |dir| - Dir.chdir(dir) do - @vim.command("cd #{dir}") - example.call - end - end - end -end diff --git a/bundle/elixir/spec/syntax/default_argument_spec.rb b/bundle/elixir/spec/syntax/default_argument_spec.rb deleted file mode 100755 index ec69a3e..0000000 --- a/bundle/elixir/spec/syntax/default_argument_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require 'spec_helper' - -describe "Default argument syntax" do - it "default argument" do - assert_correct_syntax 'elixirOperator', '\\', <<-'EOF' - def foo(bar \\ :baz) - EOF - - assert_correct_syntax 'elixirOperator', '\/', <<-EOF - def foo(bar // :baz) - EOF - end -end diff --git a/bundle/elixir/spec/syntax/heredoc_spec.rb b/bundle/elixir/spec/syntax/heredoc_spec.rb deleted file mode 100755 index eb50a4f..0000000 --- a/bundle/elixir/spec/syntax/heredoc_spec.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'spec_helper' - -describe "Heredoc syntax" do - describe "binary" do - it "with multiline content" do - assert_correct_syntax 'elixirDocString', 'foo', <<-EOF - @doc """ - foo - """ - EOF - end - - it "escapes quotes unless only preceded by whitespace" do - assert_correct_syntax 'elixirDocString', %q(^\s*\zs"""), <<-EOF - @doc """ - foo """ - """ - EOF - end - - it "does not include content on initial line", focus: true do - assert_correct_syntax 'elixirNumber', '0', <<-EOF - String.at """, 0 - foo - end - EOF - end - - it "with interpolation" do - assert_correct_syntax 'elixirInterpolation', 'bar', <<-EOF - @doc """ - foo \#{bar} - """ - EOF - end - end - - describe "character list" do - it "with multiline content" do - assert_correct_syntax 'elixirDocString', 'foo', <<-EOF - @doc """ - foo - """ - EOF - end - - it "escapes quotes unless only preceded by whitespace" do - assert_correct_syntax 'elixirDocString', %q(^\s*\zs'''), <<-EOF - @doc ''' - foo ''' - ''' - EOF - end - - it "with interpolation" do - assert_correct_syntax 'elixirInterpolation', 'bar', <<-EOF - @doc ''' - foo \#{bar} - ''' - EOF - end - end -end diff --git a/bundle/elixir/spec/syntax/records_spec.rb b/bundle/elixir/spec/syntax/records_spec.rb deleted file mode 100755 index b68814a..0000000 --- a/bundle/elixir/spec/syntax/records_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -# encoding: utf-8 -require 'spec_helper' - -describe "Record syntax" do - it "private record symbol" do - assert_correct_syntax 'elixirSymbol', ':user', <<-EOF - defrecordp :user, name: "José", age: 25 - EOF - end -end diff --git a/bundle/elixir/spec/syntax/sigil_spec.rb b/bundle/elixir/spec/syntax/sigil_spec.rb deleted file mode 100755 index ef68304..0000000 --- a/bundle/elixir/spec/syntax/sigil_spec.rb +++ /dev/null @@ -1,109 +0,0 @@ -require 'spec_helper' - -describe "Sigil syntax" do - describe "upper case" do - it "string" do - assert_correct_syntax 'elixirDelimiter', 'S', '~S(string)' - assert_correct_syntax 'elixirSigil', 'foo', '~S(string)' - end - - it "character list" do - assert_correct_syntax 'elixirDelimiter', 'C', '~C(charlist)' - assert_correct_syntax 'elixirSigil', 'charlist', '~C(charlist)' - end - - it "regular expression" do - assert_correct_syntax 'elixirDelimiter', 'R', '~R(regex)' - assert_correct_syntax 'elixirSigil', 'regex', '~R(regex)' - end - - it "list of words" do - assert_correct_syntax 'elixirDelimiter', 'W', '~W(list of words)' - assert_correct_syntax 'elixirSigil', 'list', '~W(list of words)' - end - - it "delimited with parans" do - assert_correct_syntax 'elixirDelimiter', '(', '~S(foo bar)' - assert_correct_syntax 'elixirDelimiter', ')', '~S(foo bar)' - end - - it "delimited with braces" do - assert_correct_syntax 'elixirDelimiter', '{', '~S{foo bar}' - assert_correct_syntax 'elixirDelimiter', '}', '~S{foo bar}' - end - - it "delimited with brackets" do - assert_correct_syntax 'elixirDelimiter', '[', '~S[foo bar]' - assert_correct_syntax 'elixirDelimiter', ']', '~S[foo bar]' - end - - it "escapes double quotes unless only preceded by whitespace" do - assert_correct_syntax 'elixirDelimiter', %q(^\s*\zs"""), <<-EOF - ~r""" - foo """ - """ - EOF - end - - it "escapes single quotes unless only preceded by whitespace" do - assert_correct_syntax 'elixirDelimiter', %q(^\s*\zs'''), <<-EOF - ~r''' - foo ''' - ''' - EOF - end - - it "without escapes" do - assert_incorrect_syntax 'elixirRegexEscape', '\\', '~S(foo \n bar)' - end - - it "without interpolation" do - assert_incorrect_syntax 'elixirInterpolation', 'bar', '~S(foo #{bar})' - end - - it "without escaped parans" do - assert_incorrect_syntax 'elixirRegexEscapePunctuation', '( ', '~S(\( )' - end - end - - describe "lower case" do - it "string" do - assert_correct_syntax 'elixirDelimiter', 's', '~s(string)' - assert_correct_syntax 'elixirSigil', 'foo', '~s(string)' - end - - it "character list" do - assert_correct_syntax 'elixirDelimiter', 'c', '~c(charlist)' - assert_correct_syntax 'elixirSigil', 'charlist', '~c(charlist)' - end - - it "regular expression" do - assert_correct_syntax 'elixirDelimiter', 'r', '~r(regex)' - assert_correct_syntax 'elixirSigil', 'regex', '~r(regex)' - end - - it "list of words" do - assert_correct_syntax 'elixirDelimiter', 'w', '~w(list of words)' - assert_correct_syntax 'elixirSigil', 'list', '~w(list of words)' - end - - it "with escapes" do - assert_correct_syntax 'elixirRegexEscape', '\\', '~s(foo \n bar)' - end - - it "with interpolation" do - assert_correct_syntax 'elixirInterpolation', 'bar', '~s(foo #{bar})' - end - - it "with escaped parans" do - assert_correct_syntax 'elixirRegexEscapePunctuation', '( ', '~s(\( )' - end - end - - describe "old syntax" do - it "string" do - assert_correct_syntax 'elixirDelimiter', 's', '%s(string)' - assert_correct_syntax 'elixirSigil', 'foo', '%s(string)' - end - end -end diff --git a/bundle/elixir/spec/syntax/variable_spec.rb b/bundle/elixir/spec/syntax/variable_spec.rb deleted file mode 100755 index 2877e7f..0000000 --- a/bundle/elixir/spec/syntax/variable_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require 'spec_helper' - -describe "Variable syntax" do - it "unused" do - assert_correct_syntax 'elixirUnusedVariable', '_from', <<-EOF - def handle_call(:pop, _from, [h|stack]) do - { :reply, h, stack } - end - EOF - end -end diff --git a/bundle/elixir/syntax/elixir.vim b/bundle/elixir/syntax/elixir.vim deleted file mode 100755 index ff58d55..0000000 --- a/bundle/elixir/syntax/elixir.vim +++ /dev/null @@ -1,166 +0,0 @@ -" Vim syntax file -" Language: Elixir -" Maintainer: Carlos Galdino -" Last Change: 2013 Apr 24 - -if exists("b:current_syntax") - finish -endif - -" syncing starts 2000 lines before top line so docstrings don't screw things up -syn sync minlines=2000 - -syn cluster elixirNotTop contains=@elixirRegexSpecial,@elixirStringContained,@elixirDeclaration,elixirTodo,elixirArguments - -syn match elixirComment '#.*' contains=elixirTodo -syn keyword elixirTodo FIXME NOTE TODO OPTIMIZE XXX HACK contained - -syn keyword elixirKeyword is_atom is_binary is_bitstring is_boolean is_float is_function is_integer is_list is_number is_pid is_port is_record is_reference is_tuple is_exception -syn keyword elixirKeyword case cond bc lc inlist inbits if unless try receive -syn keyword elixirKeyword exit raise throw after rescue catch else do end -syn keyword elixirKeyword quote unquote super -syn match elixirKeyword '\<\%(->\)\>\s*' - -syn keyword elixirInclude import require alias use - -syn keyword elixirOperator and not or when xor in -syn match elixirOperator '%=\|\*=\|\*\*=\|+=\|-=\|\^=\|||=' -syn match elixirOperator "\%(<=>\|<\%(<\|=\)\@!\|>\%(<\|=\|>\)\@!\|<=\|>=\|===\|==\|=\~\|!=\|!\~\|\s?[ \t]\@=\)" -syn match elixirOperator "!+[ \t]\@=\|&&\|||\|\^\|\*\|+\|-\|/" -syn match elixirOperator "|\|++\|--\|\*\*\|\/\/\|\\\\\|<-\|<>\|<<\|>>\|=\|\.\|::" - -syn match elixirSymbol '\(:\)\@=]\@!\)\?\|<>\|===\?\|>=\?\|<=\?\)' -syn match elixirSymbol '\(:\)\@\|&&\?\|%\(()\|\[\]\|{}\)\|++\?\|--\?\|||\?\|!\|//\|[%&`/|]\)' -syn match elixirSymbol "\%([a-zA-Z_]\w*\([?!]\)\?\):\(:\)\@!" - -syn keyword elixirName nil -syn match elixirName '\<[A-Z]\w*\>' - -syn match elixirUnusedVariable '\<_\w*\>' - -syn keyword elixirBoolean true false - -syn match elixirVariable '@[a-zA-Z_]\w*\|&\d' - -syn keyword elixirPseudoVariable __FILE__ __DIR__ __MODULE__ __ENV__ __CALLER__ - -syn match elixirNumber '\<\d\(_\?\d\)*\(\.[^[:space:][:digit:]]\@!\(_\?\d\)*\)\?\([eE][-+]\?\d\(_\?\d\)*\)\?\>' -syn match elixirNumber '\<0[xX][0-9A-Fa-f]\+\>' -syn match elixirNumber '\<0[bB][01]\+\>' - -syn match elixirRegexEscape "\\\\\|\\[aAbBcdDefGhHnrsStvVwW]\|\\\d\{3}\|\\x[0-9a-fA-F]\{2}" contained -syn match elixirRegexEscapePunctuation "?\|\\.\|*\|\\\[\|\\\]\|+\|\\^\|\\\$\|\\|\|\\(\|\\)\|\\{\|\\}" contained -syn match elixirRegexQuantifier "[*?+][?+]\=" contained display -syn match elixirRegexQuantifier "{\d\+\%(,\d*\)\=}?\=" contained display -syn match elixirRegexCharClass "\[:\(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|word\|xdigit\):\]" contained display - -syn region elixirRegex matchgroup=elixirDelimiter start="%r/" end="/[uiomxfr]*" skip="\\\\" contains=@elixirRegexSpecial - -syn cluster elixirRegexSpecial contains=elixirRegexEscape,elixirRegexCharClass,elixirRegexQuantifier,elixirRegexEscapePunctuation -syn cluster elixirStringContained contains=elixirInterpolation,elixirRegexEscape,elixirRegexCharClass - -syn region elixirString matchgroup=elixirDelimiter start="'" end="'" skip="\\'" -syn region elixirString matchgroup=elixirDelimiter start='"' end='"' skip='\\"' contains=@elixirStringContained -syn region elixirInterpolation matchgroup=elixirDelimiter start="#{" end="}" contained contains=ALLBUT,elixirComment,@elixirNotTop - -syn region elixirDocStringStart matchgroup=elixirDocString start=+"""+ end=+$+ oneline contains=ALLBUT,@elixirNotTop -syn region elixirDocStringStart matchgroup=elixirDocString start=+'''+ end=+$+ oneline contains=ALLBUT,@elixirNotTop -syn region elixirDocString start=+\z("""\)+ end=+^\s*\zs\z1+ contains=elixirDocStringStart,elixirTodo,elixirInterpolation fold keepend -syn region elixirDocString start=+\z('''\)+ end=+^\s*\zs\z1+ contains=elixirDocStringStart,elixirTodo,elixirInterpolation fold keepend - -syn match elixirSymbolInterpolated ':\("\)\@=' contains=elixirString -syn match elixirString "\(\w\)\@\|0[0-7]{0,2}[0-7]\@!\>\|[^x0MC]\)\|(\\[MC]-)+\w\|[^\s\\]\)" - -syn region elixirBlock matchgroup=elixirKeyword start="\\(:\)\@!" end="\" contains=ALLBUT,@elixirNotTop fold -syn region elixirAnonymousFunction matchgroup=elixirKeyword start="\" end="\" contains=ALLBUT,@elixirNotTop fold - -syn region elixirArguments start="(" end=")" contained contains=elixirOperator,elixirSymbol,elixirPseudoVariable,elixirName,elixirBoolean,elixirVariable,elixirUnusedVariable,elixirNumber,elixirDocString,elixirSymbolInterpolated,elixirRegex,elixirString,elixirDelimiter - -syn match elixirDelimEscape "\\[(<{\[)>}\]]" transparent display contained contains=NONE - -syn region elixirSigil matchgroup=elixirDelimiter start="[%~]\z([~`!@#$%^&*_\-+|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold -syn region elixirSigil matchgroup=elixirDelimiter start="[%~][SCRW]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold -syn region elixirSigil matchgroup=elixirDelimiter start="[%~][SCRW]\={" end="}" skip="\\\\\|\\}" contains=elixirDelimEscape fold -syn region elixirSigil matchgroup=elixirDelimiter start="[%~][SCRW]\=<" end=">" skip="\\\\\|\\>" contains=elixirDelimEscape fold -syn region elixirSigil matchgroup=elixirDelimiter start="[%~][SCRW]\=\[" end="\]" skip="\\\\\|\\\]" contains=elixirDelimEscape fold -syn region elixirSigil matchgroup=elixirDelimiter start="[%~][SCRW]\=(" end=")" skip="\\\\\|\\)" contains=elixirDelimEscape fold - -syn region elixirSigil matchgroup=elixirDelimiter start="[%~][scrw]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold -syn region elixirSigil matchgroup=elixirDelimiter start="[%~][scrw]{" end="}" skip="\\\\\|\\}" fold contains=@elixirStringContained,elixirRegexEscapePunctuation -syn region elixirSigil matchgroup=elixirDelimiter start="[%~][scrw]<" end=">" skip="\\\\\|\\>" fold contains=@elixirStringContained,elixirRegexEscapePunctuation -syn region elixirSigil matchgroup=elixirDelimiter start="[%~][scrw]\[" end="\]" skip="\\\\\|\\\]" fold contains=@elixirStringContained,elixirRegexEscapePunctuation -syn region elixirSigil matchgroup=elixirDelimiter start="[%~][scrw](" end=")" skip="\\\\\|\\)" fold contains=@elixirStringContained,elixirRegexEscapePunctuation - -" Sigils surrounded with docString -syn region elixirSigil matchgroup=elixirDelimiter start=+[%~][SCRWscrw]\z("""\)+ end=+^\s*\zs\z1+ skip=+\\"+ fold -syn region elixirSigil matchgroup=elixirDelimiter start=+[%~][SCRWscrw]\z('''\)+ end=+^\s*\zs\z1+ skip=+\\'+ fold - -" Defines -syn keyword elixirDefine def nextgroup=elixirFunctionDeclaration skipwhite skipnl -syn keyword elixirDefine def nextgroup=elixirFunctionDeclaration skipwhite skipnl -syn keyword elixirPrivateDefine defp nextgroup=elixirFunctionDeclaration skipwhite skipnl -syn keyword elixirModuleDefine defmodule nextgroup=elixirModuleDeclaration skipwhite skipnl -syn keyword elixirProtocolDefine defprotocol nextgroup=elixirProtocolDeclaration skipwhite skipnl -syn keyword elixirImplDefine defimpl nextgroup=elixirImplDeclaration skipwhite skipnl -syn keyword elixirRecordDefine defrecord nextgroup=elixirRecordDeclaration skipwhite skipnl -syn keyword elixirPrivateRecordDefine defrecordp nextgroup=elixirRecordDeclaration skipwhite skipnl -syn keyword elixirMacroDefine defmacro nextgroup=elixirMacroDeclaration skipwhite skipnl -syn keyword elixirPrivateMacroDefine defmacrop nextgroup=elixirMacroDeclaration skipwhite skipnl -syn keyword elixirDelegateDefine defdelegate nextgroup=elixirDelegateDeclaration skipwhite skipnl -syn keyword elixirOverridableDefine defoverridable nextgroup=elixirOverridableDeclaration skipwhite skipnl -syn keyword elixirExceptionDefine defexception nextgroup=elixirExceptionDeclaration skipwhite skipnl -syn keyword elixirCallbackDefine defcallback nextgroup=elixirCallbackDeclaration skipwhite skipnl - -" Declarations -syn match elixirModuleDeclaration "[^[:space:];#<]\+" contained contains=elixirName nextgroup=elixirBlock skipwhite skipnl -syn match elixirFunctionDeclaration "[^[:space:];#<,()\[\]]\+" contained nextgroup=elixirArguments skipwhite skipnl -syn match elixirProtocolDeclaration "[^[:space:];#<]\+" contained contains=elixirName skipwhite skipnl -syn match elixirImplDeclaration "[^[:space:];#<]\+" contained contains=elixirName skipwhite skipnl -syn match elixirRecordDeclaration "[^[:space:];#<]\+" contained contains=elixirName,elixirSymbol skipwhite skipnl -syn match elixirMacroDeclaration "[^[:space:];#<,()\[\]]\+" contained nextgroup=elixirArguments skipwhite skipnl -syn match elixirDelegateDeclaration "[^[:space:];#<,()\[\]]\+" contained contains=elixirFunctionDeclaration skipwhite skipnl -syn region elixirDelegateDeclaration start='\[' end='\]' contained contains=elixirFunctionDeclaration skipwhite skipnl -syn match elixirOverridableDeclaration "[^[:space:];#<]\+" contained contains=elixirName skipwhite skipnl -syn match elixirExceptionDeclaration "[^[:space:];#<]\+" contained contains=elixirName skipwhite skipnl -syn match elixirCallbackDeclaration "[^[:space:];#<,()\[\]]\+" contained contains=elixirFunctionDeclaration skipwhite skipnl - -syn cluster elixirDeclaration contains=elixirFunctionDeclaration,elixirModuleDeclaration,elixirProtocolDeclaration,elixirImplDeclaration,elixirRecordDeclaration,elixirMacroDeclaration,elixirDelegateDeclaration,elixirOverridableDeclaration,elixirExceptionDeclaration,elixirCallbackDeclaration - -hi def link elixirDefine Define -hi def link elixirPrivateDefine Define -hi def link elixirModuleDefine Define -hi def link elixirProtocolDefine Define -hi def link elixirImplDefine Define -hi def link elixirRecordDefine Define -hi def link elixirPrivateRecordDefine Define -hi def link elixirMacroDefine Define -hi def link elixirPrivateMacroDefine Define -hi def link elixirDelegateDefine Define -hi def link elixirOverridableDefine Define -hi def link elixirExceptionDefine Define -hi def link elixirCallbackDefine Define -hi def link elixirFunctionDeclaration Function -hi def link elixirMacroDeclaration Macro -hi def link elixirInclude Include -hi def link elixirComment Comment -hi def link elixirTodo Todo -hi def link elixirKeyword Keyword -hi def link elixirOperator Operator -hi def link elixirSymbol Constant -hi def link elixirPseudoVariable Constant -hi def link elixirName Type -hi def link elixirBoolean Boolean -hi def link elixirVariable Identifier -hi def link elixirUnusedVariable Comment -hi def link elixirNumber Number -hi def link elixirDocString String -hi def link elixirSymbolInterpolated elixirSymbol -hi def link elixirRegex elixirString -hi def link elixirRegexEscape elixirSpecial -hi def link elixirRegexEscapePunctuation elixirSpecial -hi def link elixirRegexCharClass elixirSpecial -hi def link elixirRegexQuantifier elixirSpecial -hi def link elixirSpecial Special -hi def link elixirString String -hi def link elixirSigil String -hi def link elixirDelimiter Delimiter diff --git a/bundle/fugitive/CONTRIBUTING.markdown b/bundle/fugitive/CONTRIBUTING.markdown deleted file mode 100755 index e651dca..0000000 --- a/bundle/fugitive/CONTRIBUTING.markdown +++ /dev/null @@ -1,18 +0,0 @@ -Before reporting a bug, you should try stripping down your Vim configuration -and removing other plugins. The sad truth about VimScript is that it is -fraught with incompatibilities waiting to happen. I'm happy to work around -them where I can, but it's up to you to isolate the conflict. - -Fugitive is particularly prone to regressions due to Git version issues, -platform issues, and interactions with other plugins. I end up bisecting a -lot more than other projects, and thus I'm especially meticulous here about -maintaining a clean, readable, history. Squash and force push any requested -changes to a pull request. And if your [commit message -sucks](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), -I'm not going to accept it. Period. - -Beyond that, don't be shy about asking before patching. What takes you hours -might take me minutes simply because I have both domain knowledge and a -perverse knowledge of VimScript so vast that many would consider it a symptom -of mental illness. On the flip side, some ideas I'll reject no matter how -good the implementation is. "Send a patch" is an edge case answer in my book. diff --git a/bundle/fugitive/README.markdown b/bundle/fugitive/README.markdown deleted file mode 100755 index 68a61e6..0000000 --- a/bundle/fugitive/README.markdown +++ /dev/null @@ -1,120 +0,0 @@ -# fugitive.vim - -I'm not going to lie to you; fugitive.vim may very well be the best -Git wrapper of all time. Check out these features: - -View any blob, tree, commit, or tag in the repository with `:Gedit` (and -`:Gsplit`, `:Gvsplit`, `:Gtabedit`, ...). Edit a file in the index and -write to it to stage the changes. Use `:Gdiff` to bring up the staged -version of the file side by side with the working tree version and use -Vim's diff handling capabilities to stage a subset of the file's -changes. - -Bring up the output of `git status` with `:Gstatus`. Press `-` to -`add`/`reset` a file's changes, or `p` to `add`/`reset` `--patch` that -mofo. And guess what `:Gcommit` does! - -`:Gblame` brings up an interactive vertical split with `git blame` -output. Press enter on a line to edit the commit where the line -changed, or `o` to open it in a split. When you're done, use `:Gedit` -in the historic buffer to go back to the work tree version. - -`:Gmove` does a `git mv` on a file and simultaneously renames the -buffer. `:Gremove` does a `git rm` on a file and simultaneously deletes -the buffer. - -Use `:Ggrep` to search the work tree (or any arbitrary commit) with -`git grep`, skipping over that which is not tracked in the repository. -`:Glog` loads all previous revisions of a file into the quickfix list so -you can iterate over them and watch the file evolve! - -`:Gread` is a variant of `git checkout -- filename` that operates on the -buffer rather than the filename. This means you can use `u` to undo it -and you never get any warnings about the file changing outside Vim. -`:Gwrite` writes to both the work tree and index versions of a file, -making it like `git add` when called from a work tree file and like -`git checkout` when called from the index or a blob in history. - -Use `:Gbrowse` to open the current file on GitHub, with optional line -range (try it in visual mode!). If your current repository isn't on -GitHub, `git instaweb` will be spun up instead. - -Add `%{fugitive#statusline()}` to `'statusline'` to get an indicator -with the current branch in (surprise!) your statusline. - -Last but not least, there's `:Git` for running any arbitrary command, -and `Git!` to open the output of a command in a temp file. - -## Screencasts - -* [A complement to command line git](http://vimcasts.org/e/31) -* [Working with the git index](http://vimcasts.org/e/32) -* [Resolving merge conflicts with vimdiff](http://vimcasts.org/e/33) -* [Browsing the git object database](http://vimcasts.org/e/34) -* [Exploring the history of a git repository](http://vimcasts.org/e/35) - -## Installation - -If you don't have a preferred installation method, I recommend -installing [pathogen.vim](https://github.com/tpope/vim-pathogen), and -then simply copy and paste: - - cd ~/.vim/bundle - git clone git://github.com/tpope/vim-fugitive.git - -Once help tags have been generated, you can view the manual with -`:help fugitive`. - -If your Vim version is below 7.2, I recommend also installing -[vim-git](https://github.com/tpope/vim-git) for syntax highlighting and -other Git niceties. - -## FAQ - -> I installed the plugin and started Vim. Why don't any of the commands -> exist? - -Fugitive cares about the current file, not the current working -directory. Edit a file from the repository. - -> I opened a new tab. Why don't any of the commands exist? - -Fugitive cares about the current file, not the current working -directory. Edit a file from the repository. - -> Why is `:Gbrowse` not using the right browser? - -`:Gbrowse` delegates to `git web--browse`, which is less than perfect -when it comes to finding the right browser. You can tell it the correct -browser to use with `git config --global web.browser ...`. On OS X, for -example, you might want to set this to `open`. See `git web--browse --help` -for details. - -> Here's a patch that automatically opens the quickfix window after -> `:Ggrep`. - -This is a great example of why I recommend asking before patching. -There are valid arguments to be made both for and against automatically -opening the quickfix window. Whenever I have to make an arbitrary -decision like this, I ask what Vim would do. And Vim does not open a -quickfix window after `:grep`. - -Luckily, it's easy to implement the desired behavior without changing -fugitive.vim. The following autocommand will cause the quickfix window -to open after any grep invocation: - - autocmd QuickFixCmdPost *grep* cwindow - -## Self-Promotion - -Like fugitive.vim? Follow the repository on -[GitHub](https://github.com/tpope/vim-fugitive) and vote for it on -[vim.org](http://www.vim.org/scripts/script.php?script_id=2975). And if -you're feeling especially charitable, follow [tpope](http://tpo.pe/) on -[Twitter](http://twitter.com/tpope) and -[GitHub](https://github.com/tpope). - -## License - -Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. -See `:help license`. diff --git a/bundle/fugitive/doc/fugitive.txt b/bundle/fugitive/doc/fugitive.txt deleted file mode 100755 index 5870837..0000000 --- a/bundle/fugitive/doc/fugitive.txt +++ /dev/null @@ -1,319 +0,0 @@ -*fugitive.txt* A Git wrapper so awesome, it should be illegal - -Author: Tim Pope -License: Same terms as Vim itself (see |license|) - -This plugin is only available if 'compatible' is not set. - -INTRODUCTION *fugitive* - -Whenever you edit a file from a Git repository, a set of commands is defined -that serve as a gateway to Git. - -COMMANDS *fugitive-commands* - -These commands are local to the buffers in which they work (generally, buffers -that are part of Git repositories). - - *fugitive-:Git* -:Git [args] Run an arbitrary git command. Similar to :!git [args] - but chdir to the repository tree first. - - *fugitive-:Git!* -:Git! [args] Like |:Git|, but capture the output into a temp file, - and edit that temp file. - - *fugitive-:Gcd* -:Gcd [directory] |:cd| relative to the repository. - - *fugitive-:Glcd* -:Glcd [directory] |:lcd| relative to the repository. - - *fugitive-:Gstatus* -:Gstatus Bring up the output of git-status in the preview - window. The following maps, which work on the cursor - line file where sensible, are provided: - - g? show this help - next file - previous file - |:Gedit| - - |:Git| add - - |:Git| reset (staged files) - cA |:Gcommit| --amend --reuse-message=HEAD - ca |:Gcommit| --amend - cc |:Gcommit| - cva |:Gcommit| --amend --verbose - cvc |:Gcommit| --verbose - D |:Gdiff| - ds |:Gsdiff| - dp |:Git!| diff (p for patch; use :Gw to apply) - dp |:Git| add --intent-to-add (untracked files) - dv |:Gvdiff| - O |:Gtabedit| - o |:Gsplit| - p |:Git| add --patch - p |:Git| reset --patch (staged files) - q close status - R reload status - S |:Gvsplit| - - *fugitive-:Gcommit* -:Gcommit [args] A wrapper around git-commit. If there is nothing - to commit, |:Gstatus| is called instead. Unless the - arguments given would skip the invocation of an editor - (e.g., -m), a split window will be used to obtain a - commit message. Write and close that window (:wq or - |:Gwrite|) to finish the commit. Unlike when running - the actual git-commit command, it is possible (but - unadvisable) to muck with the index with commands like - git-add and git-reset while a commit message is - pending. - - *fugitive-:Ggrep* -:Ggrep [args] |:grep| with git-grep as 'grepprg'. - - *fugitive-:Glgrep* -:Glgrep [args] |:lgrep| with git-grep as 'grepprg'. - - *fugitive-:Glog* -:Glog [args] Load all previous revisions of the current file into - the quickfix list. Additional git-log arguments can - be given (for example, --reverse). If "--" appears as - an argument, no file specific filtering is done, and - previous commits rather than previous file revisions - are loaded. - - *fugitive-:Gllog* -:Gllog [args] Like |:Glog|, but use the location list instead of the - quickfix list. - - *fugitive-:Gedit* *fugitive-:Ge* -:Gedit [revision] |:edit| a |fugitive-revision|. - - *fugitive-:Gsplit* -:Gsplit [revision] |:split| a |fugitive-revision|. - - *fugitive-:Gvsplit* -:Gvsplit [revision] |:vsplit| a |fugitive-revision|. - - *fugitive-:Gtabedit* -:Gtabedit [revision] |:tabedit| a |fugitive-revision|. - - *fugitive-:Gpedit* -:Gpedit [revision] |:pedit| a |fugitive-revision|. - -:Gsplit! [args] *fugitive-:Gsplit!* *fugitive-:Gvsplit!* -:Gvsplit! [args] *fugitive-:Gtabedit!* *fugitive-:Gpedit!* -:Gtabedit! [args] Like |:Git!|, but open the resulting temp file in a -:Gpedit! [args] split, tab, or preview window. - - *fugitive-:Gread* -:Gread [revision] Empty the buffer and |:read| a |fugitive-revision|. - When the argument is omitted, this is similar to - git-checkout on a work tree file or git-add on a stage - file, but without writing anything to disk. - -:{range}Gread [revision] - |:read| in a |fugitive-revision| after {range}. - - *fugitive-:Gread!* -:Gread! [args] Empty the buffer and |:read| the output of a Git - command. For example, :Gread! show HEAD:%. - -:{range}Gread! [args] |:read| the output of a Git command after {range}. - - *fugitive-:Gw* *fugitive-:Gwrite* -:Gwrite Write to the current file's path and stage the results. - When run in a work tree file, it is effectively git - add. Elsewhere, it is effectively git-checkout. A - great deal of effort is expended to behave sensibly - when the work tree or index version of the file is - open in another buffer. - -:Gwrite {path} You can give |:Gwrite| an explicit path of where in - the work tree to write. You can also give a path like - :0:foo.txt or even :0 to write to just that stage in - the index. - - *fugitive-:Gwq* -:Gwq [path] Like |:Gwrite| followed by |:quit| if the write - succeeded. - -:Gwq! [path] Like |:Gwrite|! followed by |:quit|! if the write - succeeded. - - *fugitive-:Gdiff* -:Gdiff [revision] Perform a |vimdiff| against the current file in the - given revision. With no argument, the version in the - index is used (which means a three-way diff during a - merge conflict, making it a git-mergetool - alternative). The newer of the two files is placed - to the right. Use |do| and |dp| and write to the - index file to simulate "git add --patch". - - *fugitive-:Gsdiff* -:Gsdiff [revision] Like |:Gdiff|, but split horizontally. - - *fugitive-:Gvdiff* -:Gvdiff [revision] Identical to |:Gdiff|. For symmetry with |:Gsdiff|. - - *fugitive-:Gmove* -:Gmove {destination} Wrapper around git-mv that renames the buffer - afterward. The destination is relative to the current - directory except when started with a /, in which case - it is relative to the work tree. Add a ! to pass -f. - - *fugitive-:Gremove* -:Gremove Wrapper around git-rm that deletes the buffer - afterward. When invoked in an index file, --cached is - passed. Add a ! to pass -f and forcefully discard the - buffer. - - *fugitive-:Gblame* -:Gblame [flags] Run git-blame on the file and open the results in a - scroll bound vertical split. Press enter on a line to - reblame the file as it was in that commit. You can - give any of ltfnsewMC as flags and they will be passed - along to git-blame. The following maps, which work on - the cursor line commit where sensible, are provided: - - g? show this help - A resize to end of author column - C resize to end of commit column - D resize to end of date/time column - q close blame and return to blamed window - gq q, then |:Gedit| to return to work tree version - q, then open commit - o open commit in horizontal split - O open commit in new tab - - reblame at commit - ~ reblame at [count]th first grandparent - P reblame at [count]th parent (like HEAD^[count]) - -:[range]Gblame [flags] Run git-blame on the given range. - - *fugitive-:Gbrowse* -:[range]Gbrowse If the remote for the current branch is on GitHub, - open the current file, blob, tree, commit, or tag - (with git-web--browse) on GitHub. Otherwise, open the - current file, blob, tree, commit, or tag in - git-instaweb (if you have issues, verify you can run - "git instaweb" from a terminal). If a range is given, - it is appropriately appended to the URL as an anchor. - - To use with GitHub FI, point g:fugitive_github_domains - at a list of domains: -> - let g:fugitive_github_domains = ['https://example.com/'] -~ -:[range]Gbrowse! Like :Gbrowse, but put the URL on the clipboard rather - than opening it. - -:[range]Gbrowse {revision} - Like :Gbrowse, but for a given |fugitive-revision|. A - useful value here is -, which ties the URL to the - latest commit rather than a volatile branch. - -:[range]Gbrowse [...]@{remote} - Force using the given remote rather than the remote - for the current branch. The remote is used to - determine which GitHub repository to link to. - -MAPPINGS *fugitive-mappings* - -These maps are available everywhere. - - *fugitive-c_CTRL-R_CTRL-G* - On the command line, recall the path to the current - object (that is, a representation of the object - recognized by |:Gedit|). - - *fugitive-y_CTRL-G* -["x]y Yank the commit SHA and path to the current object. - -These maps are available in Git objects. - - *fugitive-* - Jump to the revision under the cursor. - - *fugitive-o* -o Jump to the revision under the cursor in a new split. - - *fugitive-S* -S Jump to the revision under the cursor in a new - vertical split. - - *fugitive-O* -O Jump to the revision under the cursor in a new tab. - - *fugitive--* -- Go to the tree containing the current tree or blob. - - *fugitive-~* -~ Go to the current file in the [count]th first - ancestor. - - *fugitive-P* -P Go to the current file in the [count]th parent. - - *fugitive-C* -C Go to the commit containing the current file. - - *fugitive-.* -. Start a |:| command line with the current revision - prepopulated at the end of the line. - - *fugitive-a* -a Show the current tag, commit, or tree in an alternate - format. - -SPECIFYING REVISIONS *fugitive-revision* - -Fugitive revisions are similar to Git revisions as defined in the "SPECIFYING -REVISIONS" section in the git-rev-parse man page. For commands that accept an -optional revision, the default is the file in the index for work tree files -and the work tree file for everything else. Example revisions follow. - -Revision Meaning ~ -HEAD .git/HEAD -master .git/refs/heads/master -HEAD^{} The commit referenced by HEAD -HEAD^ The parent of the commit referenced by HEAD -HEAD: The tree referenced by HEAD -/HEAD The file named HEAD in the work tree -Makefile The file named Makefile in the work tree -HEAD^:Makefile The file named Makefile in the parent of HEAD -:Makefile The file named Makefile in the index (writable) -- The current file in HEAD -^ The current file in the previous commit -~3 The current file 3 commits ago -: .git/index (Same as |:Gstatus|) -:0 The current file in the index -:1 The current file's common ancestor during a conflict -:2 The current file in the target branch during a conflict -:3 The current file in the merged branch during a conflict -:/foo The most recent commit with "foo" in the message - -STATUSLINE *fugitive-statusline* - - *fugitive#statusline()* -Add %{fugitive#statusline()} to your statusline to get an indicator including -the current branch and the currently edited file's commit. If you don't have -a statusline, this one matches the default when 'ruler' is set: -> - set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P -< - *fugitive#head(...)* -Use fugitive#head() to return the name of the current branch. If the current -HEAD is detached, fugitive#head() will return the empty string, unless the -optional argument is given, in which case the hash of the current commit will -be truncated to the given number of characters. - -ABOUT *fugitive-about* - -Grab the latest version or report a bug on GitHub: - -http://github.com/tpope/vim-fugitive - - vim:tw=78:et:ft=help:norl: diff --git a/bundle/fugitive/plugin/fugitive.vim b/bundle/fugitive/plugin/fugitive.vim deleted file mode 100755 index 2043dfe..0000000 --- a/bundle/fugitive/plugin/fugitive.vim +++ /dev/null @@ -1,2624 +0,0 @@ -" fugitive.vim - A Git wrapper so awesome, it should be illegal -" Maintainer: Tim Pope -" Version: 2.0 -" GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim - -if exists('g:loaded_fugitive') || &cp - finish -endif -let g:loaded_fugitive = 1 - -if !exists('g:fugitive_git_executable') - let g:fugitive_git_executable = 'git' -endif - -" Utility {{{1 - -function! s:function(name) abort - return function(substitute(a:name,'^s:',matchstr(expand(''), '\d\+_'),'')) -endfunction - -function! s:sub(str,pat,rep) abort - return substitute(a:str,'\v\C'.a:pat,a:rep,'') -endfunction - -function! s:gsub(str,pat,rep) abort - return substitute(a:str,'\v\C'.a:pat,a:rep,'g') -endfunction - -function! s:shellesc(arg) abort - if a:arg =~ '^[A-Za-z0-9_/.-]\+$' - return a:arg - elseif &shell =~# 'cmd' || &shell =~# 'power' - return '"'.s:gsub(s:gsub(a:arg, '"', '""'), '\%', '"%"').'"' - else - return shellescape(a:arg) - endif -endfunction - -function! s:fnameescape(file) abort - if exists('*fnameescape') - return fnameescape(a:file) - else - return escape(a:file," \t\n*?[{`$\\%#'\"|!<") - endif -endfunction - -function! s:throw(string) abort - let v:errmsg = 'fugitive: '.a:string - throw v:errmsg -endfunction - -function! s:warn(str) abort - echohl WarningMsg - echomsg a:str - echohl None - let v:warningmsg = a:str -endfunction - -function! s:shellslash(path) abort - if exists('+shellslash') && !&shellslash - return s:gsub(a:path,'\\','/') - else - return a:path - endif -endfunction - -let s:git_versions = {} - -function! fugitive#git_version(...) abort - if !has_key(s:git_versions, g:fugitive_git_executable) - let s:git_versions[g:fugitive_git_executable] = matchstr(system(g:fugitive_git_executable.' --version'), "\\S\\+\n") - endif - return s:git_versions[g:fugitive_git_executable] -endfunction - -function! s:recall() abort - let rev = s:sub(s:buffer().rev(), '^/', '') - if rev ==# ':' - return matchstr(getline('.'),'^#\t\%([[:alpha:] ]\+: *\)\=\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$\|^\d\{6} \x\{40\} \d\t\zs.*') - elseif s:buffer().type('tree') - let file = matchstr(getline('.'), '\t\zs.*') - if empty(file) && line('.') > 2 - let file = s:sub(getline('.'), '/$', '') - endif - if !empty(file) && rev !~# ':$' - return rev . '/' . file - else - return rev . file - endif - endif - return rev -endfunction - -function! s:add_methods(namespace, method_names) abort - for name in a:method_names - let s:{a:namespace}_prototype[name] = s:function('s:'.a:namespace.'_'.name) - endfor -endfunction - -let s:commands = [] -function! s:command(definition) abort - let s:commands += [a:definition] -endfunction - -function! s:define_commands() abort - for command in s:commands - exe 'command! -buffer '.command - endfor -endfunction - -augroup fugitive_utility - autocmd! - autocmd User Fugitive call s:define_commands() -augroup END - -let s:abstract_prototype = {} - -" }}}1 -" Initialization {{{1 - -function! fugitive#is_git_dir(path) abort - let path = s:sub(a:path, '[\/]$', '') . '/' - return isdirectory(path.'objects') && isdirectory(path.'refs') && getfsize(path.'HEAD') > 10 -endfunction - -function! fugitive#extract_git_dir(path) abort - if s:shellslash(a:path) =~# '^fugitive://.*//' - return matchstr(s:shellslash(a:path), '\C^fugitive://\zs.\{-\}\ze//') - endif - let root = s:shellslash(simplify(fnamemodify(a:path, ':p:s?[\/]$??'))) - let previous = "" - while root !=# previous - if root =~# '\v^//%([^/]+/?)?$' - " This is for accessing network shares from Cygwin Vim. There won't be - " any git directory called //.git or //serverName/.git so let's avoid - " checking for them since such checks are extremely slow. - break - endif - if index(split($GIT_CEILING_DIRECTORIES, ':'), root) >= 0 - break - endif - if root ==# $GIT_WORK_TREE && fugitive#is_git_dir($GIT_DIR) - return $GIT_DIR - endif - let dir = s:sub(root, '[\/]$', '') . '/.git' - let type = getftype(dir) - if type ==# 'dir' && fugitive#is_git_dir(dir) - return dir - elseif type ==# 'link' && fugitive#is_git_dir(dir) - return resolve(dir) - elseif type !=# '' && filereadable(dir) - let line = get(readfile(dir, '', 1), 0, '') - if line =~# '^gitdir: \.' && fugitive#is_git_dir(root.'/'.line[8:-1]) - return simplify(root.'/'.line[8:-1]) - elseif line =~# '^gitdir: ' && fugitive#is_git_dir(line[8:-1]) - return line[8:-1] - endif - elseif fugitive#is_git_dir(root) - return root - endif - let previous = root - let root = fnamemodify(root, ':h') - endwhile - return '' -endfunction - -function! fugitive#detect(path) abort - if exists('b:git_dir') && (b:git_dir ==# '' || b:git_dir =~# '/$') - unlet b:git_dir - endif - if !exists('b:git_dir') - let dir = fugitive#extract_git_dir(a:path) - if dir !=# '' - let b:git_dir = dir - endif - endif - if exists('b:git_dir') - silent doautocmd User FugitiveBoot - cnoremap fnameescape(recall()) - nnoremap y :call setreg(v:register, recall()) - let buffer = fugitive#buffer() - if expand('%:p') =~# '//' - call buffer.setvar('&path', s:sub(buffer.getvar('&path'), '^\.%(,|$)', '')) - endif - if stridx(buffer.getvar('&tags'), escape(b:git_dir.'/tags', ', ')) == -1 - call buffer.setvar('&tags', escape(b:git_dir.'/tags', ', ').','.buffer.getvar('&tags')) - if &filetype !=# '' - call buffer.setvar('&tags', escape(b:git_dir.'/'.&filetype.'.tags', ', ').','.buffer.getvar('&tags')) - endif - endif - silent doautocmd User Fugitive - endif -endfunction - -augroup fugitive - autocmd! - autocmd BufNewFile,BufReadPost * call fugitive#detect(expand(':p')) - autocmd FileType netrw call fugitive#detect(expand('%:p')) - autocmd User NERDTreeInit,NERDTreeNewRoot call fugitive#detect(b:NERDTreeRoot.path.str()) - autocmd VimEnter * if expand('')==''|call fugitive#detect(getcwd())|endif - autocmd CmdWinEnter * call fugitive#detect(expand('#:p')) - autocmd BufWinLeave * execute getwinvar(+bufwinnr(+expand('')), 'fugitive_leave') -augroup END - -" }}}1 -" Repository {{{1 - -let s:repo_prototype = {} -let s:repos = {} - -function! s:repo(...) abort - let dir = a:0 ? a:1 : (exists('b:git_dir') && b:git_dir !=# '' ? b:git_dir : fugitive#extract_git_dir(expand('%:p'))) - if dir !=# '' - if has_key(s:repos, dir) - let repo = get(s:repos, dir) - else - let repo = {'git_dir': dir} - let s:repos[dir] = repo - endif - return extend(extend(repo, s:repo_prototype, 'keep'), s:abstract_prototype, 'keep') - endif - call s:throw('not a git repository: '.expand('%:p')) -endfunction - -function! fugitive#repo(...) abort - return call('s:repo', a:000) -endfunction - -function! s:repo_dir(...) dict abort - return join([self.git_dir]+a:000,'/') -endfunction - -function! s:repo_configured_tree() dict abort - if !has_key(self,'_tree') - let self._tree = '' - if filereadable(self.dir('config')) - let config = readfile(self.dir('config'),'',10) - call filter(config,'v:val =~# "^\\s*worktree *="') - if len(config) == 1 - let self._tree = matchstr(config[0], '= *\zs.*') - endif - endif - endif - if self._tree =~# '^\.' - return simplify(self.dir(self._tree)) - else - return self._tree - endif -endfunction - -function! s:repo_tree(...) dict abort - if self.dir() =~# '/\.git$' - let dir = self.dir()[0:-6] - else - let dir = self.configured_tree() - endif - if dir ==# '' - call s:throw('no work tree') - else - return join([dir]+a:000,'/') - endif -endfunction - -function! s:repo_bare() dict abort - if self.dir() =~# '/\.git$' - return 0 - else - return self.configured_tree() ==# '' - endif -endfunction - -function! s:repo_translate(spec) dict abort - if a:spec ==# '.' || a:spec ==# '/.' - return self.bare() ? self.dir() : self.tree() - elseif a:spec =~# '^/\=\.git$' && self.bare() - return self.dir() - elseif a:spec =~# '^/\=\.git/' - return self.dir(s:sub(a:spec, '^/=\.git/', '')) - elseif a:spec =~# '^/' - return self.tree().a:spec - elseif a:spec =~# '^:[0-3]:' - return 'fugitive://'.self.dir().'//'.a:spec[1].'/'.a:spec[3:-1] - elseif a:spec ==# ':' - if $GIT_INDEX_FILE =~# '/[^/]*index[^/]*\.lock$' && fnamemodify($GIT_INDEX_FILE,':p')[0:strlen(self.dir())] ==# self.dir('') && filereadable($GIT_INDEX_FILE) - return fnamemodify($GIT_INDEX_FILE,':p') - else - return self.dir('index') - endif - elseif a:spec =~# '^:/' - let ref = self.rev_parse(matchstr(a:spec,'.[^:]*')) - return 'fugitive://'.self.dir().'//'.ref - elseif a:spec =~# '^:' - return 'fugitive://'.self.dir().'//0/'.a:spec[1:-1] - elseif a:spec =~# 'HEAD\|^refs/' && a:spec !~ ':' && filereadable(self.dir(a:spec)) - return self.dir(a:spec) - elseif filereadable(self.dir('refs/'.a:spec)) - return self.dir('refs/'.a:spec) - elseif filereadable(self.dir('refs/tags/'.a:spec)) - return self.dir('refs/tags/'.a:spec) - elseif filereadable(self.dir('refs/heads/'.a:spec)) - return self.dir('refs/heads/'.a:spec) - elseif filereadable(self.dir('refs/remotes/'.a:spec)) - return self.dir('refs/remotes/'.a:spec) - elseif filereadable(self.dir('refs/remotes/'.a:spec.'/HEAD')) - return self.dir('refs/remotes/'.a:spec,'/HEAD') - else - try - let ref = self.rev_parse(matchstr(a:spec,'[^:]*')) - let path = s:sub(matchstr(a:spec,':.*'),'^:','/') - return 'fugitive://'.self.dir().'//'.ref.path - catch /^fugitive:/ - return self.tree(a:spec) - endtry - endif -endfunction - -function! s:repo_head(...) dict abort - let head = s:repo().head_ref() - - if head =~# '^ref: ' - let branch = s:sub(head,'^ref: %(refs/%(heads/|remotes/|tags/)=)=','') - elseif head =~# '^\x\{40\}$' - " truncate hash to a:1 characters if we're in detached head mode - let len = a:0 ? a:1 : 0 - let branch = len ? head[0:len-1] : '' - else - return '' - endif - - return branch -endfunction - -call s:add_methods('repo',['dir','configured_tree','tree','bare','translate','head']) - -function! s:repo_git_command(...) dict abort - let git = g:fugitive_git_executable . ' --git-dir='.s:shellesc(self.git_dir) - return git.join(map(copy(a:000),'" ".s:shellesc(v:val)'),'') -endfunction - -function! s:repo_git_chomp(...) dict abort - return s:sub(system(call(self.git_command,a:000,self)),'\n$','') -endfunction - -function! s:repo_git_chomp_in_tree(...) dict abort - let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' - let dir = getcwd() - try - execute cd.'`=s:repo().tree()`' - return call(s:repo().git_chomp, a:000, s:repo()) - finally - execute cd.'`=dir`' - endtry -endfunction - -function! s:repo_rev_parse(rev) dict abort - let hash = self.git_chomp('rev-parse','--verify',a:rev) - if hash =~ '\<\x\{40\}$' - return matchstr(hash,'\<\x\{40\}$') - endif - call s:throw('rev-parse '.a:rev.': '.hash) -endfunction - -call s:add_methods('repo',['git_command','git_chomp','git_chomp_in_tree','rev_parse']) - -function! s:repo_dirglob(base) dict abort - let base = s:sub(a:base,'^/','') - let matches = split(glob(self.tree(s:gsub(base,'/','*&').'*/')),"\n") - call map(matches,'v:val[ strlen(self.tree())+(a:base !~ "^/") : -1 ]') - return matches -endfunction - -function! s:repo_superglob(base) dict abort - if a:base =~# '^/' || a:base !~# ':' - let results = [] - if a:base !~# '^/' - let heads = ["HEAD","ORIG_HEAD","FETCH_HEAD","MERGE_HEAD"] - let heads += sort(split(s:repo().git_chomp("rev-parse","--symbolic","--branches","--tags","--remotes"),"\n")) - call filter(heads,'v:val[ 0 : strlen(a:base)-1 ] ==# a:base') - let results += heads - endif - if !self.bare() - let base = s:sub(a:base,'^/','') - let matches = split(glob(self.tree(s:gsub(base,'/','*&').'*')),"\n") - call map(matches,'s:shellslash(v:val)') - call map(matches,'v:val !~ "/$" && isdirectory(v:val) ? v:val."/" : v:val') - call map(matches,'v:val[ strlen(self.tree())+(a:base !~ "^/") : -1 ]') - let results += matches - endif - return results - - elseif a:base =~# '^:' - let entries = split(self.git_chomp('ls-files','--stage'),"\n") - call map(entries,'s:sub(v:val,".*(\\d)\\t(.*)",":\\1:\\2")') - if a:base !~# '^:[0-3]\%(:\|$\)' - call filter(entries,'v:val[1] == "0"') - call map(entries,'v:val[2:-1]') - endif - call filter(entries,'v:val[ 0 : strlen(a:base)-1 ] ==# a:base') - return entries - - else - let tree = matchstr(a:base,'.*[:/]') - let entries = split(self.git_chomp('ls-tree',tree),"\n") - call map(entries,'s:sub(v:val,"^04.*\\zs$","/")') - call map(entries,'tree.s:sub(v:val,".*\t","")') - return filter(entries,'v:val[ 0 : strlen(a:base)-1 ] ==# a:base') - endif -endfunction - -call s:add_methods('repo',['dirglob','superglob']) - -function! s:repo_config(conf) dict abort - return matchstr(system(s:repo().git_command('config').' '.a:conf),"[^\r\n]*") -endfun - -function! s:repo_user() dict abort - let username = s:repo().config('user.name') - let useremail = s:repo().config('user.email') - return username.' <'.useremail.'>' -endfun - -function! s:repo_aliases() dict abort - if !has_key(self,'_aliases') - let self._aliases = {} - for line in split(self.git_chomp('config','--get-regexp','^alias[.]'),"\n") - let self._aliases[matchstr(line,'\.\zs\S\+')] = matchstr(line,' \zs.*') - endfor - endif - return self._aliases -endfunction - -call s:add_methods('repo',['config', 'user', 'aliases']) - -function! s:repo_keywordprg() dict abort - let args = ' --git-dir='.escape(self.dir(),"\\\"' ") - if has('gui_running') && !has('win32') - return g:fugitive_git_executable . ' --no-pager' . args . ' log -1' - else - return g:fugitive_git_executable . args . ' show' - endif -endfunction - -call s:add_methods('repo',['keywordprg']) - -" }}}1 -" Buffer {{{1 - -let s:buffer_prototype = {} - -function! s:buffer(...) abort - let buffer = {'#': bufnr(a:0 ? a:1 : '%')} - call extend(extend(buffer,s:buffer_prototype,'keep'),s:abstract_prototype,'keep') - if buffer.getvar('git_dir') !=# '' - return buffer - endif - call s:throw('not a git repository: '.expand('%:p')) -endfunction - -function! fugitive#buffer(...) abort - return s:buffer(a:0 ? a:1 : '%') -endfunction - -function! s:buffer_getvar(var) dict abort - return getbufvar(self['#'],a:var) -endfunction - -function! s:buffer_setvar(var,value) dict abort - return setbufvar(self['#'],a:var,a:value) -endfunction - -function! s:buffer_getline(lnum) dict abort - return get(getbufline(self['#'], a:lnum), 0, '') -endfunction - -function! s:buffer_repo() dict abort - return s:repo(self.getvar('git_dir')) -endfunction - -function! s:buffer_type(...) dict abort - if self.getvar('fugitive_type') != '' - let type = self.getvar('fugitive_type') - elseif fnamemodify(self.spec(),':p') =~# '.\git/refs/\|\.git/\w*HEAD$' - let type = 'head' - elseif self.getline(1) =~ '^tree \x\{40\}$' && self.getline(2) == '' - let type = 'tree' - elseif self.getline(1) =~ '^\d\{6\} \w\{4\} \x\{40\}\>\t' - let type = 'tree' - elseif self.getline(1) =~ '^\d\{6\} \x\{40\}\> \d\t' - let type = 'index' - elseif isdirectory(self.spec()) - let type = 'directory' - elseif self.spec() == '' - let type = 'null' - else - let type = 'file' - endif - if a:0 - return !empty(filter(copy(a:000),'v:val ==# type')) - else - return type - endif -endfunction - -if has('win32') - - function! s:buffer_spec() dict abort - let bufname = bufname(self['#']) - let retval = '' - for i in split(bufname,'[^:]\zs\\') - let retval = fnamemodify((retval==''?'':retval.'\').i,':.') - endfor - return s:shellslash(fnamemodify(retval,':p')) - endfunction - -else - - function! s:buffer_spec() dict abort - let bufname = bufname(self['#']) - return s:shellslash(bufname == '' ? '' : fnamemodify(bufname,':p')) - endfunction - -endif - -function! s:buffer_name() dict abort - return self.spec() -endfunction - -function! s:buffer_commit() dict abort - return matchstr(self.spec(),'^fugitive://.\{-\}//\zs\w*') -endfunction - -function! s:buffer_path(...) dict abort - let rev = matchstr(self.spec(),'^fugitive://.\{-\}//\zs.*') - if rev != '' - let rev = s:sub(rev,'\w*','') - elseif self.spec()[0 : len(self.repo().dir())] ==# self.repo().dir() . '/' - let rev = '/.git'.self.spec()[strlen(self.repo().dir()) : -1] - elseif !self.repo().bare() && self.spec()[0 : len(self.repo().tree())] ==# self.repo().tree() . '/' - let rev = self.spec()[strlen(self.repo().tree()) : -1] - endif - return s:sub(s:sub(rev,'.\zs/$',''),'^/',a:0 ? a:1 : '') -endfunction - -function! s:buffer_rev() dict abort - let rev = matchstr(self.spec(),'^fugitive://.\{-\}//\zs.*') - if rev =~ '^\x/' - return ':'.rev[0].':'.rev[2:-1] - elseif rev =~ '.' - return s:sub(rev,'/',':') - elseif self.spec() =~ '\.git/index$' - return ':' - elseif self.spec() =~ '\.git/refs/\|\.git/.*HEAD$' - return self.spec()[strlen(self.repo().dir())+1 : -1] - else - return self.path('/') - endif -endfunction - -function! s:buffer_sha1() dict abort - if self.spec() =~ '^fugitive://' || self.spec() =~ '\.git/refs/\|\.git/.*HEAD$' - return self.repo().rev_parse(self.rev()) - else - return '' - endif -endfunction - -function! s:buffer_expand(rev) dict abort - if a:rev =~# '^:[0-3]$' - let file = a:rev.self.path(':') - elseif a:rev =~# '^[-:]/$' - let file = '/'.self.path() - elseif a:rev =~# '^-' - let file = 'HEAD^{}'.a:rev[1:-1].self.path(':') - elseif a:rev =~# '^@{' - let file = 'HEAD'.a:rev.self.path(':') - elseif a:rev =~# '^[~^]' - let commit = s:sub(self.commit(),'^\d=$','HEAD') - let file = commit.a:rev.self.path(':') - else - let file = a:rev - endif - return s:sub(s:sub(file,'\%$',self.path()),'\.\@<=/$','') -endfunction - -function! s:buffer_containing_commit() dict abort - if self.commit() =~# '^\d$' - return ':' - elseif self.commit() =~# '.' - return self.commit() - else - return 'HEAD' - endif -endfunction - -function! s:buffer_up(...) dict abort - let rev = self.rev() - let c = a:0 ? a:1 : 1 - while c - if rev =~# '^[/:]$' - let rev = 'HEAD' - elseif rev =~# '^:' - let rev = ':' - elseif rev =~# '^refs/[^^~:]*$\|^[^^~:]*HEAD$' - let rev .= '^{}' - elseif rev =~# '^/\|:.*/' - let rev = s:sub(rev, '.*\zs/.*', '') - elseif rev =~# ':.' - let rev = matchstr(rev, '^[^:]*:') - elseif rev =~# ':$' - let rev = rev[0:-2] - else - return rev.'~'.c - endif - let c -= 1 - endwhile - return rev -endfunction - -call s:add_methods('buffer',['getvar','setvar','getline','repo','type','spec','name','commit','path','rev','sha1','expand','containing_commit','up']) - -" }}}1 -" Git {{{1 - -call s:command("-bang -nargs=? -complete=customlist,s:GitComplete Git :execute s:Git(0,)") - -function! s:ExecuteInTree(cmd) abort - let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' - let dir = getcwd() - try - execute cd.'`=s:repo().tree()`' - execute a:cmd - finally - execute cd.'`=dir`' - endtry -endfunction - -function! s:Git(bang,cmd) abort - if a:bang - return s:Edit('edit',1,a:cmd) - endif - let git = s:repo().git_command() - if has('gui_running') && !has('win32') - let git .= ' --no-pager' - endif - let cmd = matchstr(a:cmd,'\v\C.{-}%($|\\@ `=s:repo().bare() ? s:repo().dir() : s:repo().tree()`") -call s:command("-bar -bang -nargs=? -complete=customlist,s:DirComplete Glcd :lcd `=s:repo().bare() ? s:repo().dir() : s:repo().tree()`") - -" }}}1 -" Gstatus {{{1 - -call s:command("-bar Gstatus :execute s:Status()") -augroup fugitive_status - autocmd! - if !has('win32') - autocmd FocusGained,ShellCmdPost * call fugitive#reload_status() - endif -augroup END - -function! s:Status() abort - try - Gpedit : - wincmd P - setlocal foldmethod=syntax foldlevel=1 - nnoremap q :bdelete - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry - return '' -endfunction - -function! fugitive#reload_status() abort - if exists('s:reloading_status') - return - endif - try - let s:reloading_status = 1 - let mytab = tabpagenr() - for tab in [mytab] + range(1,tabpagenr('$')) - for winnr in range(1,tabpagewinnr(tab,'$')) - if getbufvar(tabpagebuflist(tab)[winnr-1],'fugitive_type') ==# 'index' - execute 'tabnext '.tab - if winnr != winnr() - execute winnr.'wincmd w' - let restorewinnr = 1 - endif - try - if !&modified - call s:BufReadIndex() - endif - finally - if exists('restorewinnr') - wincmd p - endif - execute 'tabnext '.mytab - endtry - endif - endfor - endfor - finally - unlet! s:reloading_status - endtry -endfunction - -function! s:stage_info(lnum) abort - let filename = matchstr(getline(a:lnum),'^#\t\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$') - let lnum = a:lnum - if has('multi_byte_encoding') - let colon = '\%(:\|\%uff1a\)' - else - let colon = ':' - endif - while lnum && getline(lnum) !~# colon.'$' - let lnum -= 1 - endwhile - if !lnum - return ['', ''] - elseif (getline(lnum+1) =~# '^# .*\$' - return 'CtrlP '.fnameescape(s:repo().tree()) - else - for i in range(a:count) - call search('^#\t.*','Wbe') - endfor - return '.' - endif -endfunction - -function! s:StageReloadSeek(target,lnum1,lnum2) abort - let jump = a:target - let f = matchstr(getline(a:lnum1-1),'^#\t\%([[:alpha:] ]\+: *\|.*\%uff1a *\)\=\zs.*') - if f !=# '' | let jump = f | endif - let f = matchstr(getline(a:lnum2+1),'^#\t\%([[:alpha:] ]\+: *\|.*\%uff1a *\)\=\zs.*') - if f !=# '' | let jump = f | endif - silent! edit! - 1 - redraw - call search('^#\t\%([[:alpha:] ]\+: *\|.*\%uff1a *\)\=\V'.jump.'\%( ([^()[:digit:]]\+)\)\=\$','W') -endfunction - -function! s:StageDiff(diff) abort - let [filename, section] = s:stage_info(line('.')) - if filename ==# '' && section ==# 'staged' - return 'Git! diff --no-ext-diff --cached' - elseif filename ==# '' - return 'Git! diff --no-ext-diff' - elseif filename =~# ' -> ' - let [old, new] = split(filename,' -> ') - execute 'Gedit '.s:fnameescape(':0:'.new) - return a:diff.' HEAD:'.s:fnameescape(old) - elseif section ==# 'staged' - execute 'Gedit '.s:fnameescape(':0:'.filename) - return a:diff.' -' - else - execute 'Gedit '.s:fnameescape('/'.filename) - return a:diff - endif -endfunction - -function! s:StageDiffEdit() abort - let [filename, section] = s:stage_info(line('.')) - let arg = (filename ==# '' ? '.' : filename) - if section ==# 'staged' - return 'Git! diff --no-ext-diff --cached '.s:shellesc(arg) - elseif section ==# 'untracked' - let repo = s:repo() - call repo.git_chomp_in_tree('add','--intent-to-add',arg) - if arg ==# '.' - silent! edit! - 1 - if !search('^# .*:\n#.*\n# .*"git checkout \|^# Changes not staged for commit:$','W') - call search('^# .*:$','W') - endif - else - call s:StageReloadSeek(arg,line('.'),line('.')) - endif - return '' - else - return 'Git! diff --no-ext-diff '.s:shellesc(arg) - endif -endfunction - -function! s:StageToggle(lnum1,lnum2) abort - if a:lnum1 == 1 && a:lnum2 == 1 - return 'Gedit /.git|call search("^index$", "wc")' - endif - try - let output = '' - for lnum in range(a:lnum1,a:lnum2) - let [filename, section] = s:stage_info(lnum) - let repo = s:repo() - if getline('.') =~# '^# .*:$' - if section ==# 'staged' - call repo.git_chomp_in_tree('reset','-q') - silent! edit! - 1 - if !search('^# .*:\n# .*"git add .*\n#\n\|^# Untracked files:$','W') - call search('^# .*:$','W') - endif - return '' - elseif section ==# 'unstaged' - call repo.git_chomp_in_tree('add','-u') - silent! edit! - 1 - if !search('^# .*:\n# .*"git add .*\n#\n\|^# Untracked files:$','W') - call search('^# .*:$','W') - endif - return '' - else - call repo.git_chomp_in_tree('add','.') - silent! edit! - 1 - call search('^# .*:$','W') - return '' - endif - endif - if filename ==# '' - continue - endif - if !exists('first_filename') - let first_filename = filename - endif - execute lnum - if filename =~ ' -> ' - let cmd = ['mv','--'] + reverse(split(filename,' -> ')) - let filename = cmd[-1] - elseif section ==# 'staged' - let cmd = ['reset','-q','--',filename] - elseif getline(lnum) =~# '^#\tdeleted:' - let cmd = ['rm','--',filename] - elseif getline(lnum) =~# '^#\tmodified:' - let cmd = ['add','--',filename] - else - let cmd = ['add','-A','--',filename] - endif - let output .= call(repo.git_chomp_in_tree,cmd,s:repo())."\n" - endfor - if exists('first_filename') - call s:StageReloadSeek(first_filename,a:lnum1,a:lnum2) - endif - echo s:sub(s:gsub(output,'\n+','\n'),'\n$','') - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry - return 'checktime' -endfunction - -function! s:StagePatch(lnum1,lnum2) abort - let add = [] - let reset = [] - - for lnum in range(a:lnum1,a:lnum2) - let [filename, section] = s:stage_info(lnum) - if getline('.') =~# '^# .*:$' && section ==# 'staged' - return 'Git reset --patch' - elseif getline('.') =~# '^# .*:$' && section ==# 'unstaged' - return 'Git add --patch' - elseif getline('.') =~# '^# .*:$' && section ==# 'untracked' - return 'Git add -N .' - elseif filename ==# '' - continue - endif - if !exists('first_filename') - let first_filename = filename - endif - execute lnum - if filename =~ ' -> ' - let reset += [split(filename,' -> ')[1]] - elseif section ==# 'staged' - let reset += [filename] - elseif getline(lnum) !~# '^#\tdeleted:' - let add += [filename] - endif - endfor - try - if !empty(add) - execute "Git add --patch -- ".join(map(add,'s:shellesc(v:val)')) - endif - if !empty(reset) - execute "Git reset --patch -- ".join(map(add,'s:shellesc(v:val)')) - endif - if exists('first_filename') - silent! edit! - 1 - redraw - call search('^#\t\%([[:alpha:] ]\+: *\)\=\V'.first_filename.'\%( ([^()[:digit:]]\+)\)\=\$','W') - endif - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry - return 'checktime' -endfunction - -" }}}1 -" Gcommit {{{1 - -call s:command("-nargs=? -complete=customlist,s:CommitComplete Gcommit :execute s:Commit()") - -function! s:Commit(args) abort - let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' - let dir = getcwd() - let msgfile = s:repo().dir('COMMIT_EDITMSG') - let outfile = tempname() - let errorfile = tempname() - try - try - execute cd.s:fnameescape(s:repo().tree()) - if &shell =~# 'cmd' || &shell =~# 'power' - let command = '' - let old_editor = $GIT_EDITOR - let $GIT_EDITOR = 'false' - else - let command = 'env GIT_EDITOR=false ' - endif - let command .= s:repo().git_command('commit').' '.a:args - if &shell =~# 'csh' - noautocmd silent execute '!('.command.' > '.outfile.') >& '.errorfile - elseif a:args =~# '\%(^\| \)-\%(-interactive\|p\|-patch\)\>' - noautocmd execute '!'.command.' 2> '.errorfile - else - noautocmd silent execute '!'.command.' > '.outfile.' 2> '.errorfile - endif - finally - execute cd.'`=dir`' - endtry - if !has('gui_running') - redraw! - endif - if !v:shell_error - if filereadable(outfile) - for line in readfile(outfile) - echo line - endfor - endif - return '' - else - let errors = readfile(errorfile) - let error = get(errors,-2,get(errors,-1,'!')) - if error =~# 'false''\=\.$' - let args = a:args - let args = s:gsub(args,'%(%(^| )-- )@' - let args = '--cleanup=strip '.args - endif - if bufname('%') == '' && line('$') == 1 && getline(1) == '' && !&mod - execute 'keepalt edit '.s:fnameescape(msgfile) - elseif s:buffer().type() ==# 'index' - execute 'keepalt edit '.s:fnameescape(msgfile) - execute (search('^#','n')+1).'wincmd+' - setlocal nopreviewwindow - else - execute 'keepalt split '.s:fnameescape(msgfile) - endif - let b:fugitive_commit_arguments = args - setlocal bufhidden=wipe filetype=gitcommit - return '1' - elseif error ==# '!' - return s:Status() - else - call s:throw(error) - endif - endif - catch /^fugitive:/ - return 'echoerr v:errmsg' - finally - if exists('old_editor') - let $GIT_EDITOR = old_editor - endif - call delete(outfile) - call delete(errorfile) - call fugitive#reload_status() - endtry -endfunction - -function! s:CommitComplete(A,L,P) abort - if a:A =~ '^-' || type(a:A) == type(0) " a:A is 0 on :Gcommit - - let args = ['-C', '-F', '-a', '-c', '-e', '-i', '-m', '-n', '-o', '-q', '-s', '-t', '-u', '-v', '--all', '--allow-empty', '--amend', '--author=', '--cleanup=', '--dry-run', '--edit', '--file=', '--include', '--interactive', '--message=', '--no-verify', '--only', '--quiet', '--reedit-message=', '--reuse-message=', '--signoff', '--template=', '--untracked-files', '--verbose'] - return filter(args,'v:val[0 : strlen(a:A)-1] ==# a:A') - else - return s:repo().superglob(a:A) - endif -endfunction - -function! s:FinishCommit() abort - let args = getbufvar(+expand(''),'fugitive_commit_arguments') - if !empty(args) - call setbufvar(+expand(''),'fugitive_commit_arguments','') - return s:Commit(args) - endif - return '' -endfunction - -augroup fugitive_commit - autocmd! - autocmd VimLeavePre,BufDelete COMMIT_EDITMSG execute s:sub(s:FinishCommit(), '^echoerr (.*)', 'echohl ErrorMsg|echo \1|echohl NONE') -augroup END - -" }}}1 -" Ggrep, Glog {{{1 - -if !exists('g:fugitive_summary_format') - let g:fugitive_summary_format = '%s' -endif - -call s:command("-bang -nargs=? -complete=customlist,s:EditComplete Ggrep :execute s:Grep('grep',0,)") -call s:command("-bang -nargs=? -complete=customlist,s:EditComplete Glgrep :execute s:Grep('lgrep',0,)") -call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Glog :execute s:Log('grep',)") -call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Gllog :execute s:Log('lgrep',)") - -function! s:Grep(cmd,bang,arg) abort - let grepprg = &grepprg - let grepformat = &grepformat - let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' - let dir = getcwd() - try - execute cd.'`=s:repo().tree()`' - let &grepprg = s:repo().git_command('--no-pager', 'grep', '-n') - let &grepformat = '%f:%l:%m' - exe a:cmd.'! '.escape(matchstr(a:arg,'\v\C.{-}%($|[''" ]\@=\|)@='),'|') - let list = a:cmd =~# '^l' ? getloclist(0) : getqflist() - for entry in list - if bufname(entry.bufnr) =~ ':' - let entry.filename = s:repo().translate(bufname(entry.bufnr)) - unlet! entry.bufnr - elseif a:arg =~# '\%(^\| \)--cached\>' - let entry.filename = s:repo().translate(':0:'.bufname(entry.bufnr)) - unlet! entry.bufnr - endif - endfor - if a:cmd =~# '^l' - call setloclist(0, list, 'r') - else - call setqflist(list, 'r') - endif - if !a:bang && !empty(list) - return (a:cmd =~# '^l' ? 'l' : 'c').'first'.matchstr(a:arg,'\v\C[''" ]\zs\|.*') - else - return matchstr(a:arg,'\v\C[''" ]\|\zs.*') - endif - finally - let &grepprg = grepprg - let &grepformat = grepformat - execute cd.'`=dir`' - endtry -endfunction - -function! s:Log(cmd,...) abort - let path = s:buffer().path('/') - if path =~# '^/\.git\%(/\|$\)' || index(a:000,'--') != -1 - let path = '' - endif - let cmd = ['--no-pager', 'log', '--no-color'] - let cmd += ['--pretty=format:fugitive://'.s:repo().dir().'//%H'.path.'::'.g:fugitive_summary_format] - if empty(filter(a:000[0 : index(a:000,'--')],'v:val !~# "^-"')) - if s:buffer().commit() =~# '\x\{40\}' - let cmd += [s:buffer().commit()] - elseif s:buffer().path() =~# '^\.git/refs/\|^\.git/.*HEAD$' - let cmd += [s:buffer().path()[5:-1]] - endif - end - let cmd += map(copy(a:000),'s:sub(v:val,"^\\%(%(:\\w)*)","\\=fnamemodify(s:buffer().path(),submatch(1))")') - if path =~# '/.' - let cmd += ['--',path[1:-1]] - endif - let grepformat = &grepformat - let grepprg = &grepprg - let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' - let dir = getcwd() - try - execute cd.'`=s:repo().tree()`' - let &grepprg = escape(call(s:repo().git_command,cmd,s:repo()),'%#') - let &grepformat = '%f::%m' - exe a:cmd - finally - let &grepformat = grepformat - let &grepprg = grepprg - execute cd.'`=dir`' - endtry -endfunction - -" }}}1 -" Gedit, Gpedit, Gsplit, Gvsplit, Gtabedit, Gread {{{1 - -function! s:Edit(cmd,bang,...) abort - let buffer = s:buffer() - if a:cmd !~# 'read' - if &previewwindow && getbufvar('','fugitive_type') ==# 'index' - wincmd p - if &diff - let mywinnr = winnr() - for winnr in range(winnr('$'),1,-1) - if winnr != mywinnr && getwinvar(winnr,'&diff') - execute winnr.'wincmd w' - close - wincmd p - endif - endfor - endif - endif - endif - - if a:bang - let arglist = map(copy(a:000), 's:gsub(v:val, ''\\@>>>>>> - if getline(1) !~# '^diff ' - setlocal readonly nomodifiable - endif - if a:cmd =~# 'pedit' - wincmd p - endif - return echo - endif - return '' - endif - - if a:0 && a:1 == '' - return '' - elseif a:0 - let file = buffer.expand(join(a:000, ' ')) - elseif expand('%') ==# '' - let file = ':' - elseif buffer.commit() ==# '' && buffer.path('/') !~# '^/.git\>' - let file = buffer.path(':') - else - let file = buffer.path('/') - endif - try - let file = buffer.repo().translate(file) - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry - if a:cmd ==# 'read' - return 'silent %delete_|read '.s:fnameescape(file).'|silent 1delete_|diffupdate|'.line('.') - else - return a:cmd.' '.s:fnameescape(file) - endif -endfunction - -function! s:EditComplete(A,L,P) abort - return map(s:repo().superglob(a:A), 'fnameescape(v:val)') -endfunction - -function! s:EditRunComplete(A,L,P) abort - if a:L =~# '^\w\+!' - return s:GitComplete(a:A,a:L,a:P) - else - return s:repo().superglob(a:A) - endif -endfunction - -call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Ge :execute s:Edit('edit',0,)") -call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Gedit :execute s:Edit('edit',0,)") -call s:command("-bar -bang -nargs=* -complete=customlist,s:EditRunComplete Gpedit :execute s:Edit('pedit',0,)") -call s:command("-bar -bang -nargs=* -complete=customlist,s:EditRunComplete Gsplit :execute s:Edit('split',0,)") -call s:command("-bar -bang -nargs=* -complete=customlist,s:EditRunComplete Gvsplit :execute s:Edit('vsplit',0,)") -call s:command("-bar -bang -nargs=* -complete=customlist,s:EditRunComplete Gtabedit :execute s:Edit('tabedit',0,)") -call s:command("-bar -bang -nargs=* -count -complete=customlist,s:EditRunComplete Gread :execute s:Edit((! && ? '' : ).'read',0,)") - -" }}}1 -" Gwrite, Gwq {{{1 - -call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Gwrite :execute s:Write(0,)") -call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Gw :execute s:Write(0,)") -call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Gwq :execute s:Wq(0,)") - -function! s:Write(force,...) abort - if exists('b:fugitive_commit_arguments') - return 'write|bdelete' - elseif expand('%:t') == 'COMMIT_EDITMSG' && $GIT_INDEX_FILE != '' - return 'wq' - elseif s:buffer().type() == 'index' - return 'Gcommit' - elseif s:buffer().path() ==# '' && getline(4) =~# '^+++ ' - let filename = getline(4)[6:-1] - setlocal buftype= - silent write - setlocal buftype=nowrite - if matchstr(getline(2),'index [[:xdigit:]]\+\.\.\zs[[:xdigit:]]\{7\}') ==# s:repo().rev_parse(':0:'.filename)[0:6] - let err = s:repo().git_chomp('apply','--cached','--reverse',s:buffer().spec()) - else - let err = s:repo().git_chomp('apply','--cached',s:buffer().spec()) - endif - if err !=# '' - let v:errmsg = split(err,"\n")[0] - return 'echoerr v:errmsg' - elseif a:force - return 'bdelete' - else - return 'Gedit '.fnameescape(filename) - endif - endif - let mytab = tabpagenr() - let mybufnr = bufnr('') - let path = a:0 ? join(a:000, ' ') : s:buffer().path() - if path =~# '^:\d\>' - return 'write'.(a:force ? '! ' : ' ').s:fnameescape(s:repo().translate(s:buffer().expand(path))) - endif - let always_permitted = (s:buffer().path() ==# path && s:buffer().commit() =~# '^0\=$') - if !always_permitted && !a:force && s:repo().git_chomp_in_tree('diff','--name-status','HEAD','--',path) . s:repo().git_chomp_in_tree('ls-files','--others','--',path) !=# '' - let v:errmsg = 'fugitive: file has uncommitted changes (use ! to override)' - return 'echoerr v:errmsg' - endif - let file = s:repo().translate(path) - let treebufnr = 0 - for nr in range(1,bufnr('$')) - if fnamemodify(bufname(nr),':p') ==# file - let treebufnr = nr - endif - endfor - - if treebufnr > 0 && treebufnr != bufnr('') - let temp = tempname() - silent execute '%write '.temp - for tab in [mytab] + range(1,tabpagenr('$')) - for winnr in range(1,tabpagewinnr(tab,'$')) - if tabpagebuflist(tab)[winnr-1] == treebufnr - execute 'tabnext '.tab - if winnr != winnr() - execute winnr.'wincmd w' - let restorewinnr = 1 - endif - try - let lnum = line('.') - let last = line('$') - silent execute '$read '.temp - silent execute '1,'.last.'delete_' - silent write! - silent execute lnum - let did = 1 - finally - if exists('restorewinnr') - wincmd p - endif - execute 'tabnext '.mytab - endtry - endif - endfor - endfor - if !exists('did') - call writefile(readfile(temp,'b'),file,'b') - endif - else - execute 'write! '.s:fnameescape(s:repo().translate(path)) - endif - - if a:force - let error = s:repo().git_chomp_in_tree('add', '--force', file) - else - let error = s:repo().git_chomp_in_tree('add', file) - endif - if v:shell_error - let v:errmsg = 'fugitive: '.error - return 'echoerr v:errmsg' - endif - if s:buffer().path() ==# path && s:buffer().commit() =~# '^\d$' - set nomodified - endif - - let one = s:repo().translate(':1:'.path) - let two = s:repo().translate(':2:'.path) - let three = s:repo().translate(':3:'.path) - for nr in range(1,bufnr('$')) - let name = fnamemodify(bufname(nr), ':p') - if bufloaded(nr) && !getbufvar(nr,'&modified') && (name ==# one || name ==# two || name ==# three) - execute nr.'bdelete' - endif - endfor - - unlet! restorewinnr - let zero = s:repo().translate(':0:'.path) - for tab in range(1,tabpagenr('$')) - for winnr in range(1,tabpagewinnr(tab,'$')) - let bufnr = tabpagebuflist(tab)[winnr-1] - let bufname = fnamemodify(bufname(bufnr), ':p') - if bufname ==# zero && bufnr != mybufnr - execute 'tabnext '.tab - if winnr != winnr() - execute winnr.'wincmd w' - let restorewinnr = 1 - endif - try - let lnum = line('.') - let last = line('$') - silent execute '$read '.s:fnameescape(file) - silent execute '1,'.last.'delete_' - silent execute lnum - set nomodified - diffupdate - finally - if exists('restorewinnr') - wincmd p - endif - execute 'tabnext '.mytab - endtry - break - endif - endfor - endfor - call fugitive#reload_status() - return 'checktime' -endfunction - -function! s:Wq(force,...) abort - let bang = a:force ? '!' : '' - if exists('b:fugitive_commit_arguments') - return 'wq'.bang - endif - let result = call(s:function('s:Write'),[a:force]+a:000) - if result =~# '^\%(write\|wq\|echoerr\)' - return s:sub(result,'^write','wq') - else - return result.'|quit'.bang - endif -endfunction - -" }}}1 -" Gdiff {{{1 - -call s:command("-bang -bar -nargs=* -complete=customlist,s:EditComplete Gdiff :execute s:Diff(0,)") -call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gvdiff :execute s:Diff(0,)") -call s:command("-bar -nargs=* -complete=customlist,s:EditComplete Gsdiff :execute s:Diff(1,)") - -augroup fugitive_diff - autocmd! - autocmd BufWinLeave * if &diff && s:diff_window_count() == 2 && getbufvar(+expand(''), 'git_dir') !=# '' | call s:diffoff_all(getbufvar(+expand(''), 'git_dir')) | endif - autocmd BufWinEnter * if &diff && s:diff_window_count() == 1 && getbufvar(+expand(''), 'git_dir') !=# '' | call s:diffoff() | endif -augroup END - -function! s:diff_window_count() abort - let c = 0 - for nr in range(1,winnr('$')) - let c += getwinvar(nr,'&diff') - endfor - return c -endfunction - -function! s:diff_restore() abort - let restore = 'setlocal nodiff noscrollbind' - \ . ' scrollopt=' . &l:scrollopt - \ . (&l:wrap ? ' wrap' : ' nowrap') - \ . ' foldlevel=999' - \ . ' foldmethod=' . &l:foldmethod - \ . ' foldcolumn=' . &l:foldcolumn - \ . ' foldlevel=' . &l:foldlevel - if has('cursorbind') - let restore .= (&l:cursorbind ? ' ' : ' no') . 'cursorbind' - endif - return restore -endfunction - -function! s:diffthis() abort - if !&diff - let w:fugitive_diff_restore = s:diff_restore() - diffthis - endif -endfunction - -function! s:diffoff() abort - if exists('w:fugitive_diff_restore') - execute w:fugitive_diff_restore - unlet w:fugitive_diff_restore - else - diffoff - endif -endfunction - -function! s:diffoff_all(dir) abort - for nr in range(1,winnr('$')) - if getwinvar(nr,'&diff') - if nr != winnr() - execute nr.'wincmd w' - let restorewinnr = 1 - endif - if exists('b:git_dir') && b:git_dir ==# a:dir - call s:diffoff() - endif - endif - endfor -endfunction - -function! s:buffer_compare_age(commit) dict abort - let scores = {':0': 1, ':1': 2, ':2': 3, ':': 4, ':3': 5} - let my_score = get(scores,':'.self.commit(),0) - let their_score = get(scores,':'.a:commit,0) - if my_score || their_score - return my_score < their_score ? -1 : my_score != their_score - elseif self.commit() ==# a:commit - return 0 - endif - let base = self.repo().git_chomp('merge-base',self.commit(),a:commit) - if base ==# self.commit() - return -1 - elseif base ==# a:commit - return 1 - endif - let my_time = +self.repo().git_chomp('log','--max-count=1','--pretty=format:%at',self.commit()) - let their_time = +self.repo().git_chomp('log','--max-count=1','--pretty=format:%at',a:commit) - return my_time < their_time ? -1 : my_time != their_time -endfunction - -call s:add_methods('buffer',['compare_age']) - -function! s:Diff(bang,...) abort - let vert = a:bang ? '' : 'vertical ' - if exists(':DiffGitCached') - return 'DiffGitCached' - elseif (!a:0 || a:1 == ':') && s:buffer().commit() =~# '^[0-1]\=$' && s:repo().git_chomp_in_tree('ls-files', '--unmerged', '--', s:buffer().path()) !=# '' - let nr = bufnr('') - execute 'leftabove '.vert.'split `=fugitive#buffer().repo().translate(s:buffer().expand('':2''))`' - execute 'nnoremap dp :diffput '.nr.'diffupdate' - call s:diffthis() - wincmd p - execute 'rightbelow '.vert.'split `=fugitive#buffer().repo().translate(s:buffer().expand('':3''))`' - execute 'nnoremap dp :diffput '.nr.'diffupdate' - call s:diffthis() - wincmd p - call s:diffthis() - return '' - elseif a:0 - let arg = join(a:000, ' ') - if arg ==# '' - return '' - elseif arg ==# '/' - let file = s:buffer().path('/') - elseif arg ==# ':' - let file = s:buffer().path(':0:') - elseif arg =~# '^:/.' - try - let file = s:repo().rev_parse(arg).s:buffer().path(':') - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry - else - let file = s:buffer().expand(arg) - endif - if file !~# ':' && file !~# '^/' && s:repo().git_chomp('cat-file','-t',file) =~# '^\%(tag\|commit\)$' - let file = file.s:buffer().path(':') - endif - else - let file = s:buffer().path(s:buffer().commit() == '' ? ':0:' : '/') - endif - try - let spec = s:repo().translate(file) - let commit = matchstr(spec,'\C[^:/]//\zs\x\+') - let restore = s:diff_restore() - if exists('+cursorbind') - setlocal cursorbind - endif - let w:fugitive_diff_restore = restore - if s:buffer().compare_age(commit) < 0 - execute 'rightbelow '.vert.'diffsplit '.s:fnameescape(spec) - else - execute 'leftabove '.vert.'diffsplit '.s:fnameescape(spec) - endif - let w:fugitive_diff_restore = restore - let winnr = winnr() - if getwinvar('#', '&diff') - wincmd p - call feedkeys("\p", 'n') - endif - return '' - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry -endfunction - -" }}}1 -" Gmove, Gremove {{{1 - -function! s:Move(force,destination) abort - if a:destination =~# '^/' - let destination = a:destination[1:-1] - else - let destination = s:shellslash(fnamemodify(s:sub(a:destination,'[%#]%(:\w)*','\=expand(submatch(0))'),':p')) - if destination[0:strlen(s:repo().tree())] ==# s:repo().tree('') - let destination = destination[strlen(s:repo().tree('')):-1] - endif - endif - if isdirectory(s:buffer().spec()) - " Work around Vim parser idiosyncrasy - let discarded = s:buffer().setvar('&swapfile',0) - endif - let message = call(s:repo().git_chomp_in_tree,['mv']+(a:force ? ['-f'] : [])+['--', s:buffer().path(), destination], s:repo()) - if v:shell_error - let v:errmsg = 'fugitive: '.message - return 'echoerr v:errmsg' - endif - let destination = s:repo().tree(destination) - if isdirectory(destination) - let destination = fnamemodify(s:sub(destination,'/$','').'/'.expand('%:t'),':.') - endif - call fugitive#reload_status() - if s:buffer().commit() == '' - if isdirectory(destination) - return 'keepalt edit '.s:fnameescape(destination) - else - return 'keepalt saveas! '.s:fnameescape(destination) - endif - else - return 'file '.s:fnameescape(s:repo().translate(':0:'.destination)) - endif -endfunction - -function! s:MoveComplete(A,L,P) abort - if a:A =~ '^/' - return s:repo().superglob(a:A) - else - let matches = split(glob(a:A.'*'),"\n") - call map(matches,'v:val !~ "/$" && isdirectory(v:val) ? v:val."/" : v:val') - return matches - endif -endfunction - -function! s:Remove(force) abort - if s:buffer().commit() ==# '' - let cmd = ['rm'] - elseif s:buffer().commit() ==# '0' - let cmd = ['rm','--cached'] - else - let v:errmsg = 'fugitive: rm not supported here' - return 'echoerr v:errmsg' - endif - if a:force - let cmd += ['--force'] - endif - let message = call(s:repo().git_chomp_in_tree,cmd+['--',s:buffer().path()],s:repo()) - if v:shell_error - let v:errmsg = 'fugitive: '.s:sub(message,'error:.*\zs\n\(.*-f.*',' (add ! to force)') - return 'echoerr '.string(v:errmsg) - else - call fugitive#reload_status() - return 'bdelete'.(a:force ? '!' : '') - endif -endfunction - -augroup fugitive_remove - autocmd! - autocmd User Fugitive if s:buffer().commit() =~# '^0\=$' | - \ exe "command! -buffer -bar -bang -nargs=1 -complete=customlist,s:MoveComplete Gmove :execute s:Move(0,)" | - \ exe "command! -buffer -bar -bang Gremove :execute s:Remove(0)" | - \ endif -augroup END - -" }}}1 -" Gblame {{{1 - -augroup fugitive_blame - autocmd! - autocmd BufReadPost *.fugitiveblame setfiletype fugitiveblame - autocmd FileType fugitiveblame setlocal nomodeline | if exists('b:git_dir') | let &l:keywordprg = s:repo().keywordprg() | endif - autocmd Syntax fugitiveblame call s:BlameSyntax() - autocmd User Fugitive if s:buffer().type('file', 'blob') | exe "command! -buffer -bar -bang -range=0 -nargs=* Gblame :execute s:Blame(0,,,,[])" | endif -augroup END - -function! s:linechars(pattern) abort - let chars = strlen(s:gsub(matchstr(getline('.'), a:pattern), '.', '.')) - if exists('*synconcealed') && &conceallevel > 1 - for col in range(1, chars) - let chars -= synconcealed(line('.'), col)[0] - endfor - endif - return chars -endfunction - -function! s:Blame(bang,line1,line2,count,args) abort - try - if s:buffer().path() == '' - call s:throw('file or blob required') - endif - if filter(copy(a:args),'v:val !~# "^\\%(--root\|--show-name\\|-\\=\\%([ltfnsew]\\|[MC]\\d*\\)\\+\\)$"') != [] - call s:throw('unsupported option') - endif - call map(a:args,'s:sub(v:val,"^\\ze[^-]","-")') - let cmd = ['--no-pager', 'blame', '--show-number'] + a:args - if s:buffer().commit() =~# '\D\|..' - let cmd += [s:buffer().commit()] - else - let cmd += ['--contents', '-'] - endif - let cmd += ['--', s:buffer().path()] - let basecmd = escape(call(s:repo().git_command,cmd,s:repo()),'!') - try - let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' - if !s:repo().bare() - let dir = getcwd() - execute cd.'`=s:repo().tree()`' - endif - if a:count - execute 'write !'.substitute(basecmd,' blame ',' blame -L '.a:line1.','.a:line2.' ','g') - else - let error = resolve(tempname()) - let temp = error.'.fugitiveblame' - if &shell =~# 'csh' - silent! execute '%write !('.basecmd.' > '.temp.') >& '.error - else - silent! execute '%write !'.basecmd.' > '.temp.' 2> '.error - endif - if exists('l:dir') - execute cd.'`=dir`' - unlet dir - endif - if v:shell_error - call s:throw(join(readfile(error),"\n")) - endif - for winnr in range(winnr('$'),1,-1) - call setwinvar(winnr, '&scrollbind', 0) - if getbufvar(winbufnr(winnr), 'fugitive_blamed_bufnr') - execute winbufnr(winnr).'bdelete' - endif - endfor - let bufnr = bufnr('') - let restore = 'call setwinvar(bufwinnr('.bufnr.'),"&scrollbind",0)' - if &l:wrap - let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&wrap",1)' - endif - if &l:foldenable - let restore .= '|call setwinvar(bufwinnr('.bufnr.'),"&foldenable",1)' - endif - setlocal scrollbind nowrap nofoldenable - let top = line('w0') + &scrolloff - let current = line('.') - let s:temp_files[temp] = { 'dir': s:repo().dir(), 'args': cmd } - exe 'keepalt leftabove vsplit '.temp - let b:fugitive_blamed_bufnr = bufnr - let w:fugitive_leave = restore - let b:fugitive_blame_arguments = join(a:args,' ') - execute top - normal! zt - execute current - setlocal nomodified nomodifiable nonumber scrollbind nowrap foldcolumn=0 nofoldenable winfixwidth filetype=fugitiveblame - if exists('+concealcursor') - setlocal concealcursor=nc conceallevel=2 - endif - if exists('+relativenumber') - setlocal norelativenumber - endif - execute "vertical resize ".(s:linechars('.\{-\}\ze\s\+\d\+)')+1) - nnoremap :help fugitive-:Gblame - nnoremap g? :help fugitive-:Gblame - nnoremap q :exe substitute(bufwinnr(b:fugitive_blamed_bufnr).' wincmd w'.bufnr('').'bdelete','^-1','','') - nnoremap gq :exe substitute(bufwinnr(b:fugitive_blamed_bufnr).' wincmd w'.bufnr('').'bdeleteif expand("%:p") =~# "^fugitive:[\\/][\\/]"Geditendif','^-1','','') - nnoremap :exe BlameCommit("exe 'norm q'edit") - nnoremap - :exe BlameJump('') - nnoremap P :exe BlameJump('^'.v:count1) - nnoremap ~ :exe BlameJump('~'.v:count1) - nnoremap i :exe BlameCommit("exe 'norm q'edit") - nnoremap o :exe BlameCommit((&splitbelow ? "botright" : "topleft")." split") - nnoremap O :exe BlameCommit("tabedit") - nnoremap A :exe "vertical resize ".(linechars('.\{-\}\ze [0-9:/+-][0-9:/+ -]* \d\+)')+1+v:count) - nnoremap C :exe "vertical resize ".(linechars('^\S\+')+1+v:count) - nnoremap D :exe "vertical resize ".(linechars('.\{-\}\ze\d\ze\s\+\d\+)')+1-v:count) - redraw - syncbind - endif - finally - if exists('l:dir') - execute cd.'`=dir`' - endif - endtry - return '' - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry -endfunction - -function! s:BlameCommit(cmd) abort - let cmd = s:Edit(a:cmd, 0, matchstr(getline('.'),'\x\+')) - if cmd =~# '^echoerr' - return cmd - endif - let lnum = matchstr(getline('.'),' \zs\d\+\ze\s\+[([:digit:]]') - let path = matchstr(getline('.'),'^\^\=\x\+\s\+\zs.\{-\}\ze\s*\d\+ ') - if path ==# '' - let path = s:buffer(b:fugitive_blamed_bufnr).path() - endif - execute cmd - if search('^diff .* b/\M'.escape(path,'\').'$','W') - call search('^+++') - let head = line('.') - while search('^@@ \|^diff ') && getline('.') =~# '^@@ ' - let top = +matchstr(getline('.'),' +\zs\d\+') - let len = +matchstr(getline('.'),' +\d\+,\zs\d\+') - if lnum >= top && lnum <= top + len - let offset = lnum - top - if &scrolloff - + - normal! zt - else - normal! zt - + - endif - while offset > 0 && line('.') < line('$') - + - if getline('.') =~# '^[ +]' - let offset -= 1 - endif - endwhile - return 'if foldlevel(".")|foldopen!|endif' - endif - endwhile - execute head - normal! zt - endif - return '' -endfunction - -function! s:BlameJump(suffix) abort - let commit = matchstr(getline('.'),'^\^\=\zs\x\+') - if commit =~# '^0\+$' - let commit = ':0' - endif - let lnum = matchstr(getline('.'),' \zs\d\+\ze\s\+[([:digit:]]') - let path = matchstr(getline('.'),'^\^\=\x\+\s\+\zs.\{-\}\ze\s*\d\+ ') - if path ==# '' - let path = s:buffer(b:fugitive_blamed_bufnr).path() - endif - let args = b:fugitive_blame_arguments - let offset = line('.') - line('w0') - let bufnr = bufnr('%') - let winnr = bufwinnr(b:fugitive_blamed_bufnr) - if winnr > 0 - exe winnr.'wincmd w' - endif - execute s:Edit('edit', 0, commit.a:suffix.':'.path) - execute lnum - if winnr > 0 - exe bufnr.'bdelete' - endif - execute 'Gblame '.args - execute lnum - let delta = line('.') - line('w0') - offset - if delta > 0 - execute 'normal! '.delta."\" - elseif delta < 0 - execute 'normal! '.(-delta)."\" - endif - syncbind - return '' -endfunction - -function! s:BlameSyntax() abort - let b:current_syntax = 'fugitiveblame' - let conceal = has('conceal') ? ' conceal' : '' - let arg = exists('b:fugitive_blame_arguments') ? b:fugitive_blame_arguments : '' - syn match FugitiveblameBoundary "^\^" - syn match FugitiveblameBlank "^\s\+\s\@=" nextgroup=FugitiveblameAnnotation,fugitiveblameOriginalFile,FugitiveblameOriginalLineNumber skipwhite - syn match FugitiveblameHash "\%(^\^\=\)\@<=\x\{7,40\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite - syn match FugitiveblameUncommitted "\%(^\^\=\)\@<=0\{7,40\}\>" nextgroup=FugitiveblameAnnotation,FugitiveblameOriginalLineNumber,fugitiveblameOriginalFile skipwhite - syn region FugitiveblameAnnotation matchgroup=FugitiveblameDelimiter start="(" end="\%( \d\+\)\@<=)" contained keepend oneline - syn match FugitiveblameTime "[0-9:/+-][0-9:/+ -]*[0-9:/+-]\%( \+\d\+)\)\@=" contained containedin=FugitiveblameAnnotation - exec 'syn match FugitiveblameLineNumber " *\d\+)\@=" contained containedin=FugitiveblameAnnotation'.conceal - exec 'syn match FugitiveblameOriginalFile " \%(\f\+\D\@<=\|\D\@=\f\+\)\%(\%(\s\+\d\+\)\=\s\%((\|\s*\d\+)\)\)\@=" contained nextgroup=FugitiveblameOriginalLineNumber,FugitiveblameAnnotation skipwhite'.(arg =~# 'f' ? '' : conceal) - exec 'syn match FugitiveblameOriginalLineNumber " *\d\+\%(\s(\)\@=" contained nextgroup=FugitiveblameAnnotation skipwhite'.(arg =~# 'n' ? '' : conceal) - exec 'syn match FugitiveblameOriginalLineNumber " *\d\+\%(\s\+\d\+)\)\@=" contained nextgroup=FugitiveblameShort skipwhite'.(arg =~# 'n' ? '' : conceal) - syn match FugitiveblameShort " \d\+)" contained contains=FugitiveblameLineNumber - syn match FugitiveblameNotCommittedYet "(\@<=Not Committed Yet\>" contained containedin=FugitiveblameAnnotation - hi def link FugitiveblameBoundary Keyword - hi def link FugitiveblameHash Identifier - hi def link FugitiveblameUncommitted Function - hi def link FugitiveblameTime PreProc - hi def link FugitiveblameLineNumber Number - hi def link FugitiveblameOriginalFile String - hi def link FugitiveblameOriginalLineNumber Float - hi def link FugitiveblameShort FugitiveblameDelimiter - hi def link FugitiveblameDelimiter Delimiter - hi def link FugitiveblameNotCommittedYet Comment -endfunction - -" }}}1 -" Gbrowse {{{1 - -call s:command("-bar -bang -range -nargs=* -complete=customlist,s:EditComplete Gbrowse :execute s:Browse(0,,,)") - -function! s:Browse(bang,line1,count,...) abort - try - let rev = a:0 ? substitute(join(a:000, ' '),'@[[:alnum:]_-]*\%(://.\{-\}\)\=$','','') : '' - if rev ==# '' - let expanded = s:buffer().rev() - elseif rev ==# ':' - let expanded = s:buffer().path('/') - else - let expanded = s:buffer().expand(rev) - endif - let full = s:repo().translate(expanded) - let commit = '' - if full =~# '^fugitive://' - let commit = matchstr(full,'://.*//\zs\w\+') - let path = matchstr(full,'://.*//\w\+\zs/.*') - if commit =~ '..' - let type = s:repo().git_chomp('cat-file','-t',commit.s:sub(path,'^/',':')) - else - let type = 'blob' - endif - let path = path[1:-1] - elseif s:repo().bare() - let path = '.git/' . full[strlen(s:repo().dir())+1:-1] - let type = '' - else - let path = full[strlen(s:repo().tree())+1:-1] - if path =~# '^\.git/' - let type = '' - elseif isdirectory(full) - let type = 'tree' - else - let type = 'blob' - endif - endif - if path =~# '^\.git/.*HEAD' && filereadable(s:repo().dir(path[5:-1])) - let body = readfile(s:repo().dir(path[5:-1]))[0] - if body =~# '^\x\{40\}$' - let commit = body - let type = 'commit' - let path = '' - elseif body =~# '^ref: refs/' - let path = '.git/' . matchstr(body,'ref: \zs.*') - endif - endif - - if a:0 && join(a:000, ' ') =~# '@[[:alnum:]_-]*\%(://.\{-\}\)\=$' - let remote = matchstr(join(a:000, ' '),'@\zs[[:alnum:]_-]\+\%(://.\{-\}\)\=$') - elseif path =~# '^\.git/refs/remotes/.' - let remote = matchstr(path,'^\.git/refs/remotes/\zs[^/]\+') - else - let remote = 'origin' - let branch = matchstr(rev,'^[[:alnum:]/._-]\+\ze[:^~@]') - if branch ==# '' && path =~# '^\.git/refs/\w\+/' - let branch = s:sub(path,'^\.git/refs/\w+/','') - endif - if filereadable(s:repo().dir('refs/remotes/'.branch)) - let remote = matchstr(branch,'[^/]\+') - let rev = rev[strlen(remote)+1:-1] - else - if branch ==# '' - let branch = matchstr(s:repo().head_ref(),'\ 0 ? a:line1 : 0) - endif - - if url == '' - call s:throw("Instaweb failed to start and '".remote."' is not a GitHub remote") - endif - - if a:bang - let @* = url - return 'echomsg '.string(url) - else - return 'echomsg '.string(url).'|call fugitive#buffer().repo().git_chomp("web--browse",'.string(url).')' - endif - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry -endfunction - -function! s:github_url(http://github.com/repo,url,rev,commit,path,type,line1,line2) abort - let path = a:path - let domain_pattern = 'github\.com' - let domains = exists('g:fugitive_github_domains') ? g:fugitive_github_domains : [] - for domain in domains - let domain_pattern .= '\|' . escape(split(domain, '://')[-1], '.') - endfor - let repo = matchstr(a:url,'^\%(https\=://\|git://\|git@\)\=\zs\('.domain_pattern.'\)[/:].\{-\}\ze\%(\.git\)\=$') - if repo ==# '' - return '' - endif - if index(domains, 'http://' . matchstr(repo, '^[^:/]*')) >= 0 - let root = 'http://' . s:sub(repo,':','/') - else - let root = 'https://' . s:sub(repo,':','/') - endif - if path =~# '^\.git/refs/heads/' - let branch = a:repo.git_chomp('config','branch.'.path[16:-1].'.merge')[11:-1] - if branch ==# '' - return root . '/commits/' . path[16:-1] - else - return root . '/commits/' . branch - endif - elseif path =~# '^\.git/refs/.' - return root . '/commits/' . matchstr(path,'[^/]\+$') - elseif path =~# '.git/\%(config$\|hooks\>\)' - return root . '/admin' - elseif path =~# '^\.git\>' - return root - endif - if a:rev =~# '^[[:alnum:]._-]\+:' - let commit = matchstr(a:rev,'^[^:]*') - elseif a:commit =~# '^\d\=$' - let local = matchstr(a:repo.head_ref(),'\ 0 && a:line1 == a:line2 - let url .= '#L' . a:line1 - elseif a:line2 > 0 - let url .= '#L' . a:line1 . '-' . a:line2 - endif - elseif a:type == 'tag' - let commit = matchstr(getline(3),'^tag \zs.*') - let url = root . '/tree/' . commit - else - let url = root . '/commit/' . commit - endif - return url -endfunction - -function! s:instaweb_url(http://github.com/repo,rev,commit,path,type,...) abort - let output = a:repo.git_chomp('instaweb','-b','unknown') - if output =~# 'http://' - let root = matchstr(output,'http://.*/').'/?p='.fnamemodify(a:repo.dir(),':t') - else - return '' - endif - if a:path =~# '^\.git/refs/.' - return root . ';a=shortlog;h=' . matchstr(a:path,'^\.git/\zs.*') - elseif a:path =~# '^\.git\>' - return root - endif - let url = root - if a:commit =~# '^\x\{40\}$' - if a:type ==# 'commit' - let url .= ';a=commit' - endif - let url .= ';h=' . a:repo.rev_parse(a:commit . (a:path == '' ? '' : ':' . a:path)) - else - if a:type ==# 'blob' - let tmp = tempname() - silent execute 'write !'.a:repo.git_command('hash-object','-w','--stdin').' > '.tmp - let url .= ';h=' . readfile(tmp)[0] - else - try - let url .= ';h=' . a:repo.rev_parse((a:commit == '' ? 'HEAD' : ':' . a:commit) . ':' . a:path) - catch /^fugitive:/ - call s:throw('fugitive: cannot browse uncommitted file') - endtry - endif - let root .= ';hb=' . matchstr(a:repo.head_ref(),'[^ ]\+$') - endif - if a:path !=# '' - let url .= ';f=' . a:path - endif - if a:0 && a:1 - let url .= '#l' . a:1 - endif - return url -endfunction - -" }}}1 -" File access {{{1 - -function! s:ReplaceCmd(cmd,...) abort - let fn = expand('%:p') - let tmp = tempname() - let prefix = '' - try - if a:0 && a:1 != '' - if &shell =~# 'cmd' || &shell =~# 'power' - let old_index = $GIT_INDEX_FILE - let $GIT_INDEX_FILE = a:1 - else - let prefix = 'env GIT_INDEX_FILE='.s:shellesc(a:1).' ' - endif - endif - if &shell =~# 'cmd' || &shell =~# 'power' - let cmd_escape_char = &shellxquote == '(' ? '^' : '^^^' - call system('cmd /c "'.prefix.s:gsub(a:cmd,'[<>]', cmd_escape_char.'&').' > '.tmp.'"') - else - call system(' ('.prefix.a:cmd.' > '.tmp.') ') - endif - finally - if exists('old_index') - let $GIT_INDEX_FILE = old_index - endif - endtry - silent exe 'keepalt file '.tmp - try - silent edit! - finally - silent exe 'keepalt file '.s:fnameescape(fn) - call delete(tmp) - if fnamemodify(bufname('$'), ':p') ==# tmp - silent execute 'bwipeout '.bufnr('$') - endif - silent exe 'doau BufReadPost '.s:fnameescape(fn) - endtry -endfunction - -function! s:BufReadIndex() abort - if !exists('b:fugitive_display_format') - let b:fugitive_display_format = filereadable(expand('%').'.lock') - endif - let b:fugitive_display_format = b:fugitive_display_format % 2 - let b:fugitive_type = 'index' - try - let b:git_dir = s:repo().dir() - setlocal noro ma nomodeline - if fnamemodify($GIT_INDEX_FILE !=# '' ? $GIT_INDEX_FILE : b:git_dir . '/index', ':p') ==# expand('%:p') - let index = '' - else - let index = expand('%:p') - endif - if b:fugitive_display_format - call s:ReplaceCmd(s:repo().git_command('ls-files','--stage'),index) - set ft=git nospell - else - let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' - let dir = getcwd() - if fugitive#git_version() =~# '^0\|^1\.[1-7]\.' - let cmd = s:repo().git_command('status') - else - let cmd = s:repo().git_command( - \ '-c', 'status.displayCommentPrefix=true', - \ '-c', 'color.status=false', - \ 'status') - endif - try - execute cd.'`=s:repo().tree()`' - call s:ReplaceCmd(cmd, index) - finally - execute cd.'`=dir`' - endtry - set ft=gitcommit - set foldtext=fugitive#foldtext() - endif - setlocal ro noma nomod noswapfile - if &bufhidden ==# '' - setlocal bufhidden=delete - endif - call s:JumpInit() - nunmap P - nunmap ~ - nnoremap :execute StageNext(v:count1) - nnoremap :execute StagePrevious(v:count1) - nnoremap - :silent execute StageToggle(line('.'),line('.')+v:count1-1) - xnoremap - :silent execute StageToggle(line("'<"),line("'>")) - nnoremap a :let b:fugitive_display_format += 1exe BufReadIndex() - nnoremap i :let b:fugitive_display_format -= 1exe BufReadIndex() - nnoremap C :Gcommit - nnoremap cA :Gcommit --amend --reuse-message=HEAD - nnoremap ca :Gcommit --amend - nnoremap cc :Gcommit - nnoremap cva :Gcommit --amend --verbose - nnoremap cvc :Gcommit --verbose - nnoremap D :execute StageDiff('Gvdiff') - nnoremap dd :execute StageDiff('Gvdiff') - nnoremap dh :execute StageDiff('Gsdiff') - nnoremap ds :execute StageDiff('Gsdiff') - nnoremap dp :execute StageDiffEdit() - nnoremap dv :execute StageDiff('Gvdiff') - nnoremap p :execute StagePatch(line('.'),line('.')+v:count1-1) - xnoremap p :execute StagePatch(line("'<"),line("'>")) - nnoremap q :if bufnr('$') == 1quitelsebdeleteendif - nnoremap R :edit - nnoremap g? :help fugitive-:Gstatus - nnoremap :help fugitive-:Gstatus - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry -endfunction - -function! s:FileRead() abort - try - let repo = s:repo(fugitive#extract_git_dir(expand(''))) - let path = s:sub(s:sub(matchstr(expand(''),'fugitive://.\{-\}//\zs.*'),'/',':'),'^\d:',':&') - let hash = repo.rev_parse(path) - if path =~ '^:' - let type = 'blob' - else - let type = repo.git_chomp('cat-file','-t',hash) - endif - " TODO: use count, if possible - return "read !".escape(repo.git_command('cat-file',type,hash),'%#\') - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry -endfunction - -function! s:BufReadIndexFile() abort - try - let b:fugitive_type = 'blob' - let b:git_dir = s:repo().dir() - try - call s:ReplaceCmd(s:repo().git_command('cat-file','blob',s:buffer().sha1())) - finally - if &bufhidden ==# '' - setlocal bufhidden=delete - endif - setlocal noswapfile - endtry - return '' - catch /^fugitive: rev-parse/ - silent exe 'doau BufNewFile '.s:fnameescape(expand('%:p')) - return '' - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry -endfunction - -function! s:BufWriteIndexFile() abort - let tmp = tempname() - try - let path = matchstr(expand(''),'//\d/\zs.*') - let stage = matchstr(expand(''),'//\zs\d') - silent execute 'write !'.s:repo().git_command('hash-object','-w','--stdin').' > '.tmp - let sha1 = readfile(tmp)[0] - let old_mode = matchstr(s:repo().git_chomp('ls-files','--stage',path),'^\d\+') - if old_mode == '' - let old_mode = executable(s:repo().tree(path)) ? '100755' : '100644' - endif - let info = old_mode.' '.sha1.' '.stage."\t".path - call writefile([info],tmp) - if &shell =~# 'cmd' || &shell =~# 'power' - let error = system('type '.s:gsub(tmp,'/','\\').'|'.s:repo().git_command('update-index','--index-info')) - else - let error = system(s:repo().git_command('update-index','--index-info').' < '.tmp) - endif - if v:shell_error == 0 - setlocal nomodified - silent execute 'doautocmd BufWritePost '.s:fnameescape(expand('%:p')) - call fugitive#reload_status() - return '' - else - return 'echoerr '.string('fugitive: '.error) - endif - finally - call delete(tmp) - endtry -endfunction - -function! s:BufReadObject() abort - try - setlocal noro ma - let b:git_dir = s:repo().dir() - let hash = s:buffer().sha1() - if !exists("b:fugitive_type") - let b:fugitive_type = s:repo().git_chomp('cat-file','-t',hash) - endif - if b:fugitive_type !~# '^\%(tag\|commit\|tree\|blob\)$' - return "echoerr 'fugitive: unrecognized git type'" - endif - let firstline = getline('.') - if !exists('b:fugitive_display_format') && b:fugitive_type != 'blob' - let b:fugitive_display_format = +getbufvar('#','fugitive_display_format') - endif - - if b:fugitive_type !=# 'blob' - setlocal nomodeline - endif - - let pos = getpos('.') - silent keepjumps %delete_ - setlocal endofline - - try - if b:fugitive_type ==# 'tree' - let b:fugitive_display_format = b:fugitive_display_format % 2 - if b:fugitive_display_format - call s:ReplaceCmd(s:repo().git_command('ls-tree',hash)) - else - call s:ReplaceCmd(s:repo().git_command('show','--no-color',hash)) - endif - elseif b:fugitive_type ==# 'tag' - let b:fugitive_display_format = b:fugitive_display_format % 2 - if b:fugitive_display_format - call s:ReplaceCmd(s:repo().git_command('cat-file',b:fugitive_type,hash)) - else - call s:ReplaceCmd(s:repo().git_command('cat-file','-p',hash)) - endif - elseif b:fugitive_type ==# 'commit' - let b:fugitive_display_format = b:fugitive_display_format % 2 - if b:fugitive_display_format - call s:ReplaceCmd(s:repo().git_command('cat-file',b:fugitive_type,hash)) - else - call s:ReplaceCmd(s:repo().git_command('show','--no-color','--pretty=format:tree %T%nparent %P%nauthor %an <%ae> %ad%ncommitter %cn <%ce> %cd%nencoding %e%n%n%s%n%n%b',hash)) - keepjumps call search('^parent ') - if getline('.') ==# 'parent ' - silent keepjumps delete_ - else - silent keepjumps s/\%(^parent\)\@\)\=$','W',line('.')+3) - if lnum - silent keepjumps delete_ - end - keepjumps 1 - endif - elseif b:fugitive_type ==# 'blob' - call s:ReplaceCmd(s:repo().git_command('cat-file',b:fugitive_type,hash)) - setlocal nomodeline - endif - finally - keepjumps call setpos('.',pos) - setlocal ro noma nomod noswapfile - if &bufhidden ==# '' - setlocal bufhidden=delete - endif - if b:fugitive_type !=# 'blob' - set filetype=git - nnoremap a :let b:fugitive_display_format += v:count1exe BufReadObject() - nnoremap i :let b:fugitive_display_format -= v:count1exe BufReadObject() - else - call s:JumpInit() - endif - endtry - - return '' - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry -endfunction - -augroup fugitive_files - autocmd! - autocmd BufReadCmd index{,.lock} - \ if fugitive#is_git_dir(expand(':p:h')) | - \ exe s:BufReadIndex() | - \ elseif filereadable(expand('')) | - \ read | - \ 1delete | - \ endif - autocmd FileReadCmd fugitive://**//[0-3]/** exe s:FileRead() - autocmd BufReadCmd fugitive://**//[0-3]/** exe s:BufReadIndexFile() - autocmd BufWriteCmd fugitive://**//[0-3]/** exe s:BufWriteIndexFile() - autocmd BufReadCmd fugitive://**//[0-9a-f][0-9a-f]* exe s:BufReadObject() - autocmd FileReadCmd fugitive://**//[0-9a-f][0-9a-f]* exe s:FileRead() - autocmd FileType git - \ if exists('b:git_dir') | - \ call s:JumpInit() | - \ endif -augroup END - -" }}}1 -" Temp files {{{1 - -if !exists('s:temp_files') - let s:temp_files = {} -endif - -augroup fugitive_temp - autocmd! - autocmd BufNewFile,BufReadPost * - \ if has_key(s:temp_files,expand(':p')) | - \ let b:git_dir = s:temp_files[expand(':p')].dir | - \ let b:git_type = 'temp' | - \ let b:git_args = s:temp_files[expand(':p')].args | - \ call fugitive#detect(expand(':p')) | - \ setlocal bufhidden=delete | - \ nnoremap q :bdelete| - \ endif -augroup END - -" }}}1 -" Go to file {{{1 - -function! s:JumpInit() abort - nnoremap :exe GF("edit") - if !&modifiable - nnoremap o :exe GF("split") - nnoremap S :exe GF("vsplit") - nnoremap O :exe GF("tabedit") - nnoremap - :exe Edit('edit',0,buffer().up(v:count1)) if fugitive#buffer().type('tree')call search('^'.escape(expand('#:t'),'.*[]~\').'/\=$','wc')endif - nnoremap P :exe Edit('edit',0,buffer().commit().'^'.v:count1.buffer().path(':')) - nnoremap ~ :exe Edit('edit',0,buffer().commit().'~'.v:count1.buffer().path(':')) - nnoremap C :exe Edit('edit',0,buffer().containing_commit()) - nnoremap cc :exe Edit('edit',0,buffer().containing_commit()) - nnoremap co :exe Edit('split',0,buffer().containing_commit()) - nnoremap cS :exe Edit('vsplit',0,buffer().containing_commit()) - nnoremap cO :exe Edit('tabedit',0,buffer().containing_commit()) - nnoremap cP :exe Edit('pedit',0,buffer().containing_commit()) - nnoremap . : =fnameescape(recall()) - endif -endfunction - -function! s:GF(mode) abort - try - let buffer = s:buffer() - let myhash = buffer.sha1() - if myhash ==# '' && getline(1) =~# '^\%(commit\|tag\) \w' - let myhash = matchstr(getline(1),'^\w\+ \zs\S\+') - endif - - if buffer.type('tree') - let showtree = (getline(1) =~# '^tree ' && getline(2) == "") - if showtree && line('.') == 1 - return "" - elseif showtree && line('.') > 2 - return s:Edit(a:mode,0,buffer.commit().':'.s:buffer().path().(buffer.path() =~# '^$\|/$' ? '' : '/').s:sub(getline('.'),'/$','')) - elseif getline('.') =~# '^\d\{6\} \l\{3,8\} \x\{40\}\t' - return s:Edit(a:mode,0,buffer.commit().':'.s:buffer().path().(buffer.path() =~# '^$\|/$' ? '' : '/').s:sub(matchstr(getline('.'),'\t\zs.*'),'/$','')) - endif - - elseif buffer.type('blob') - let ref = expand("") - try - let sha1 = buffer.repo().rev_parse(ref) - catch /^fugitive:/ - endtry - if exists('sha1') - return s:Edit(a:mode,0,ref) - endif - - else - - " Index - if getline('.') =~# '^\d\{6\} \x\{40\} \d\t' - let ref = matchstr(getline('.'),'\x\{40\}') - let file = ':'.s:sub(matchstr(getline('.'),'\d\t.*'),'\t',':') - return s:Edit(a:mode,0,file) - - elseif getline('.') =~# '^#\trenamed:.* -> ' - let file = '/'.matchstr(getline('.'),' -> \zs.*') - return s:Edit(a:mode,0,file) - elseif getline('.') =~# '^#\t[[:alpha:] ]\+: *.' - let file = '/'.matchstr(getline('.'),': *\zs.\{-\}\ze\%( ([^()[:digit:]]\+)\)\=$') - return s:Edit(a:mode,0,file) - elseif getline('.') =~# '^#\t.' - let file = '/'.matchstr(getline('.'),'#\t\zs.*') - return s:Edit(a:mode,0,file) - elseif getline('.') =~# ': needs merge$' - let file = '/'.matchstr(getline('.'),'.*\ze: needs merge$') - return s:Edit(a:mode,0,file).'|Gdiff' - - elseif getline('.') ==# '# Not currently on any branch.' - return s:Edit(a:mode,0,'HEAD') - elseif getline('.') =~# '^# On branch ' - let file = 'refs/heads/'.getline('.')[12:] - return s:Edit(a:mode,0,file) - elseif getline('.') =~# "^# Your branch .*'" - let file = matchstr(getline('.'),"'\\zs\\S\\+\\ze'") - return s:Edit(a:mode,0,file) - endif - - let showtree = (getline(1) =~# '^tree ' && getline(2) == "") - - if getline('.') =~# '^ref: ' - let ref = strpart(getline('.'),5) - - elseif getline('.') =~# '^commit \x\{40\}\>' - let ref = matchstr(getline('.'),'\x\{40\}') - return s:Edit(a:mode,0,ref) - - elseif getline('.') =~# '^parent \x\{40\}\>' - let ref = matchstr(getline('.'),'\x\{40\}') - let line = line('.') - let parent = 0 - while getline(line) =~# '^parent ' - let parent += 1 - let line -= 1 - endwhile - return s:Edit(a:mode,0,ref) - - elseif getline('.') =~ '^tree \x\{40\}$' - let ref = matchstr(getline('.'),'\x\{40\}') - if s:repo().rev_parse(myhash.':') == ref - let ref = myhash.':' - endif - return s:Edit(a:mode,0,ref) - - elseif getline('.') =~# '^object \x\{40\}$' && getline(line('.')+1) =~ '^type \%(commit\|tree\|blob\)$' - let ref = matchstr(getline('.'),'\x\{40\}') - let type = matchstr(getline(line('.')+1),'type \zs.*') - - elseif getline('.') =~# '^\l\{3,8\} '.myhash.'$' - return '' - - elseif getline('.') =~# '^\l\{3,8\} \x\{40\}\>' - let ref = matchstr(getline('.'),'\x\{40\}') - echoerr "warning: unknown context ".matchstr(getline('.'),'^\l*') - - elseif getline('.') =~# '^[+-]\{3\} [ab/]' - let ref = getline('.')[4:] - - elseif getline('.') =~# '^[+-]' && search('^@@ -\d\+,\d\+ +\d\+,','bnW') - let type = getline('.')[0] - let lnum = line('.') - 1 - let offset = -1 - while getline(lnum) !~# '^@@ -\d\+,\d\+ +\d\+,' - if getline(lnum) =~# '^[ '.type.']' - let offset += 1 - endif - let lnum -= 1 - endwhile - let offset += matchstr(getline(lnum), type.'\zs\d\+') - let ref = getline(search('^'.type.'\{3\} [ab]/','bnW'))[4:-1] - let dcmd = '+'.offset.'|if foldlevel(".")|foldopen!|endif' - let dref = '' - - elseif getline('.') =~# '^rename from ' - let ref = 'a/'.getline('.')[12:] - elseif getline('.') =~# '^rename to ' - let ref = 'b/'.getline('.')[10:] - - elseif getline('.') =~# '^diff --git \%(a/.*\|/dev/null\) \%(b/.*\|/dev/null\)' - let dref = matchstr(getline('.'),'\Cdiff --git \zs\%(a/.*\|/dev/null\)\ze \%(b/.*\|/dev/null\)') - let ref = matchstr(getline('.'),'\Cdiff --git \%(a/.*\|/dev/null\) \zs\%(b/.*\|/dev/null\)') - let dcmd = 'Gdiff' - - elseif getline('.') =~# '^index ' && getline(line('.')-1) =~# '^diff --git \%(a/.*\|/dev/null\) \%(b/.*\|/dev/null\)' - let line = getline(line('.')-1) - let dref = matchstr(line,'\Cdiff --git \zs\%(a/.*\|/dev/null\)\ze \%(b/.*\|/dev/null\)') - let ref = matchstr(line,'\Cdiff --git \%(a/.*\|/dev/null\) \zs\%(b/.*\|/dev/null\)') - let dcmd = 'Gdiff!' - - elseif line('$') == 1 && getline('.') =~ '^\x\{40\}$' - let ref = getline('.') - else - let ref = '' - endif - - if myhash ==# '' - let ref = s:sub(ref,'^a/','HEAD:') - let ref = s:sub(ref,'^b/',':0:') - if exists('dref') - let dref = s:sub(dref,'^a/','HEAD:') - endif - else - let ref = s:sub(ref,'^a/',myhash.'^:') - let ref = s:sub(ref,'^b/',myhash.':') - if exists('dref') - let dref = s:sub(dref,'^a/',myhash.'^:') - endif - endif - - if ref ==# '/dev/null' - " Empty blob - let ref = 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391' - endif - - if exists('dref') - return s:Edit(a:mode,0,ref) . '|'.dcmd.' '.s:fnameescape(dref) - elseif ref != "" - return s:Edit(a:mode,0,ref) - endif - - endif - return '' - catch /^fugitive:/ - return 'echoerr v:errmsg' - endtry -endfunction - -" }}}1 -" Statusline {{{1 - -function! s:repo_head_ref() dict abort - if !filereadable(self.dir('HEAD')) - return '' - endif - return readfile(self.dir('HEAD'))[0] -endfunction - -call s:add_methods('repo',['head_ref']) - -function! fugitive#statusline(...) abort - if !exists('b:git_dir') - return '' - endif - let status = '' - if s:buffer().commit() != '' - let status .= ':' . s:buffer().commit()[0:7] - endif - let status .= '('.fugitive#head(7).')' - if &statusline =~# '%[MRHWY]' && &statusline !~# '%[mrhwy]' - return ',GIT'.status - else - return '[Git'.status.']' - endif -endfunction - -function! fugitive#head(...) abort - if !exists('b:git_dir') - return '' - endif - - return s:repo().head(a:0 ? a:1 : 0) -endfunction - -" }}}1 -" Folding {{{1 - -function! fugitive#foldtext() abort - if &foldmethod !=# 'syntax' - return foldtext() - elseif getline(v:foldstart) =~# '^diff ' - let [add, remove] = [-1, -1] - let filename = '' - for lnum in range(v:foldstart, v:foldend) - if filename ==# '' && getline(lnum) =~# '^[+-]\{3\} [abciow12]/' - let filename = getline(lnum)[6:-1] - endif - if getline(lnum) =~# '^+' - let add += 1 - elseif getline(lnum) =~# '^-' - let remove += 1 - elseif getline(lnum) =~# '^Binary ' - let binary = 1 - endif - endfor - if filename ==# '' - let filename = matchstr(getline(v:foldstart), '^diff .\{-\} a/\zs.*\ze b/') - endif - if filename ==# '' - let filename = getline(v:foldstart)[5:-1] - endif - if exists('binary') - return 'Binary: '.filename - else - return (add<10&&remove<100?' ':'') . add . '+ ' . (remove<10&&add<100?' ':'') . remove . '- ' . filename - endif - elseif getline(v:foldstart) =~# '^# .*:$' - let lines = getline(v:foldstart, v:foldend) - call filter(lines, 'v:val =~# "^#\t"') - cal map(lines,'s:sub(v:val, "^#\t%(modified: +|renamed: +)=", "")') - cal map(lines,'s:sub(v:val, "^([[:alpha:] ]+): +(.*)", "\\2 (\\1)")') - return getline(v:foldstart).' '.join(lines, ', ') - endif - return foldtext() -endfunction - -augroup fugitive_foldtext - autocmd! - autocmd User Fugitive - \ if &filetype =~# '^git\%(commit\)\=$' && &foldtext ==# 'foldtext()' | - \ set foldtext=fugitive#foldtext() | - \ endif -augroup END - -" }}}1 - -" vim:set et sw=2: diff --git a/bundle/less/.gitignore b/bundle/less/.gitignore deleted file mode 100644 index 1377554..0000000 --- a/bundle/less/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.swp diff --git a/bundle/less/README.md b/bundle/less/README.md deleted file mode 100644 index 697ad12..0000000 --- a/bundle/less/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# VIM-LESS - -This vim bundle adds syntax highlighting, indenting and autocompletion for the dynamic stylesheet language [LESS](http://lesscss.org). - -This bundle is compatible with [vim-css-color](https://github.com/skammer/vim-css-color), -[vim-css3-syntax](https://github.com/hail2u/vim-css3-syntax) and possibly other plugins that place code -in `after/syntax/css.vim` or `after/syntax/css/*.vim`. - -![vim-less with vim-css-color and vim-css3-syntax (colorscheme solarized)](https://github.com/lenniboy/vim-less/raw/master/screenshot.png) - - -## Installing and Using - -- Install [pathogen](http://www.vim.org/scripts/script.php?script_id=2332) into `~/.vim/autoload/` and add the - following line to your `~/.vimrc`: - - call pathogen#infect() - -- Make a clone of the `vim-less` repository: - - $ mkdir -p ~/.vim/bundle - $ cd ~/.vim/bundle - $ git clone https://github.com/groenewege/vim-less - -- OR use [vundle](https://github.com/gmarik/vundle), adding this line to your `~/.vimrc`: - - Bundle 'groenewege/vim-less' - -- OR use git submodules: - - $ git submodule add https://github.com/groenewege/vim-less.git bundle/vim-less - $ git submodule init - - -### Map -.less to .css , lessc is required. - - nnoremap ,m :w !lessc % > %:t:r.css - - -## Credits - -Inspiration from [vim-haml](https://github.com/tpope/vim-haml), -[scss-syntax.vim](https://github.com/cakebaker/scss-syntax.vim) and -[vim-less](https://github.com/lunaru/vim-less) - -## License ## - -MIT : [groenewege.mit-license.org](http://groenewege.mit-license.org/) diff --git a/bundle/less/ftdetect/less.vim b/bundle/less/ftdetect/less.vim deleted file mode 100644 index f1cb1d7..0000000 --- a/bundle/less/ftdetect/less.vim +++ /dev/null @@ -1 +0,0 @@ -autocmd BufNewFile,BufRead *.less setf less diff --git a/bundle/less/ftplugin/less.vim b/bundle/less/ftplugin/less.vim deleted file mode 100644 index b6eaf6a..0000000 --- a/bundle/less/ftplugin/less.vim +++ /dev/null @@ -1,25 +0,0 @@ -" Vim filetype plugin -" Language: LessCSS -" Author: Tim Pope -" Maintainer: Leonard Ehrenfried -" Last Change: 2011 Sep 30 - -" Only do this when not done yet for this buffer -if exists("b:did_ftplugin") - finish -endif -let b:did_ftplugin = 1 - -let b:undo_ftplugin = "setl cms< def< inc< inex< ofu< sua<" - -setlocal iskeyword+=- -setlocal commentstring=//\ %s -setlocal define=^\\s*\\%(@mixin\\\|=\\) -setlocal includeexpr=substitute(v:fname,'\\%(.*/\\\|^\\)\\zs','_','') -setlocal omnifunc=csscomplete#CompleteCSS -setlocal suffixesadd=.less -setlocal comments=s1:/*,mb:*,ex:*/ - -let &l:include = '^\s*@import\s\+\%(url(http://github.com/)\=["'']\=' - -" vim:set sw=2: diff --git a/bundle/less/indent/less.vim b/bundle/less/indent/less.vim deleted file mode 100644 index fea8846..0000000 --- a/bundle/less/indent/less.vim +++ /dev/null @@ -1,11 +0,0 @@ -" Vim indent file -" Language: LessCSS -" Maintainer: Leonard Ehrenfried -" Last Change: 2011 Sep 26 - -if exists("b:did_indent") - finish -endif - -runtime! indent/css.vim - diff --git a/bundle/less/screenshot.png b/bundle/less/screenshot.png deleted file mode 100644 index ce25624..0000000 Binary files a/bundle/less/screenshot.png and /dev/null differ diff --git a/bundle/less/syntax/less.vim b/bundle/less/syntax/less.vim deleted file mode 100644 index fa5a247..0000000 --- a/bundle/less/syntax/less.vim +++ /dev/null @@ -1,64 +0,0 @@ -if exists("b:current_syntax") - finish -endif - -runtime! syntax/css.vim -runtime! after/syntax/css.vim -" load files from vim-css3-syntax plugin (https://github.com/hail2u/vim-css3-syntax) -runtime! after/syntax/css/*.vim - -syn case ignore - -syn region lessDefinition transparent matchgroup=cssBraces start='{' end='}' contains=css.*Attr,css.*Prop,cssComment,cssValue.*,cssColor,cssTagName,cssPseudoClass,cssUrl,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,lessDefinition,lessComment,lessClassChar,lessVariable,lessMixinChar,lessAmpersandChar,lessFunction,lessNestedSelector,@cssColors fold - -syn match lessVariable "@[[:alnum:]_-]\+" contained -syn match lessVariable "@[[:alnum:]_-]\+" nextgroup=lessVariableAssignment skipwhite -syn match lessVariableAssignment ":" contained nextgroup=lessVariableValue skipwhite -syn match lessVariableValue ".*;"me=e-1 contained contains=lessVariable,lessOperator,lessDefault,cssValue.*,@cssColors "me=e-1 means that the last char of the pattern is not highlighted - -syn match lessOperator "+" contained -syn match lessOperator "-" contained -syn match lessOperator "/" contained -syn match lessOperator "*" contained - -syn match lessNestedSelector "[^/]* {"me=e-1 contained contains=cssTagName,cssAttributeSelector,lessAmpersandChar,lessVariable,lessMixinChar,lessFunction,lessNestedProperty -syn match lessNestedProperty "[[:alnum:]]\+:"me=e-1 contained - -syn match lessDefault "!default" contained - -syn match lessMixinChar "\.[[:alnum:]_-]\@=" contained nextgroup=lessClass -syn match lessAmpersandChar "&" contained nextgroup=lessClass,cssPseudoClass -syn match lessClass "[[:alnum:]_-]\+" contained - -" functions {{{ - -" string functions -syn keyword lessFunction escape e % containedin=cssDefinition contained -" misc functions -syn keyword lessFunction color unit containedin=cssDefinition contained -" math functions -syn keyword lessFunction ceil floor percentage round containedin=cssDefinition contained -" color definition -syn keyword lessFunction rgb rgba argb hsl hsla hsv hsva containedin=cssDefinition contained -" color channel information -syn keyword lessFunction hue saturation lightness red green blue alpha luma containedin=cssDefinition contained -" color operations -syn keyword lessFunction saturate desaturate lighten darken fadein fadeout fade spin mix greyscale contrast containedin=cssDefinition contained -" color blending -syn keyword lessFunction multiply screen overlay softlight hardlight difference exclusion average negation containedin=cssDefinition contained - -" }}} - -syn match lessComment "//.*$" contains=@Spell - -hi def link lessVariable Special -hi def link lessVariableValue Constant -hi def link lessDefault Special -hi def link lessComment Comment -hi def link lessFunction Function -hi def link lessMixinChar Special -hi def link lessAmpersandChar Special -hi def link lessNestedProperty Type -hi def link lessClass PreProc - -let b:current_syntax = "less" diff --git a/bundle/powerline/README.rst b/bundle/powerline/README.rst deleted file mode 100644 index 9c71440..0000000 --- a/bundle/powerline/README.rst +++ /dev/null @@ -1,114 +0,0 @@ -=================== -DEPRECATION WARNING -=================== - -Plugin is currently in maintenance mode, no feature requests will be accepted. -Vim-powerline will be deprecated in favour of https://github.com/Lokaltog/powerline once it is ready. - -================= -Powerline for vim -================= - -:Author: Kim Silkebækken (kim.silkebaekken+vim@gmail.com) -:Source: https://github.com/Lokaltog/vim-powerline -:Version: β - -Introduction ------------- - -Powerline is a utility plugin which allows you to create better-looking, -more functional vim statuslines. See the screenshots below for -a demonstration of the plugin's capabilities. - -It's recommended that you install the plugin using Pathogen_ or Vundle_. -After the plugin is installed update your help tags and see ``:help -Powerline`` for instructions on how to enable and configure the plugin. - -See the `Troubleshooting`_ section below if you're having any issues with -the plugin or the font patcher. - -**Note:** You need a patched font to be able to use the symbols in the -statusline. An experimental Python/fontforge-based font patcher is included -in the ``fontpatcher`` directory. See ``fontpatcher/README.rst`` for usage -instructions. - -.. _Pathogen: https://github.com/tpope/vim-pathogen -.. _Vundle: https://github.com/gmarik/vundle - -Screenshots ------------ - -.. image:: http://i.imgur.com/MsuIB.png - -Troubleshooting ---------------- - -I can't see the fancy symbols, what's wrong? - Make sure that you have ``let g:Powerline_symbols = 'fancy'`` in your - ``vimrc`` file. The settings may be loaded too late if you have this in - ``gvimrc``, so always put this in your ``vimrc``. - - Clear the cache using ``:PowerlineClearCache`` and restart vim. - - Make sure that you've configured gvim or your terminal emulator to use - a patched font. - - Make sure that vim is compiled with the ``--with-features=big`` flag. - -The fancy symbols look a bit blurry or "off"! - Make sure that you have patched all variants of your font (i.e. both the - regular and the bold font files). - -I'm unable to patch my font, what should I do? - Font patching is only known to work on most Linux and OS X machines. If - you have followed the instructions in the fontpatcher README and still - have problems, please submit an issue on GitHub. - - You can download some community-contributed patched fonts from the - `Powerline wiki`_ if you don't want to mess around with the font - patcher. - -The Syntastic/Fugitive statusline flags don't work! - These flags should work without any configuration. If you installed - either plugin after Powerline, you'll have to clear the cache using - ``:PowerlineClearCache`` and restart vim. - -The colors are weird in the default OS X Terminal app! - The default OS X Terminal app is known to have some issues with the - Powerline colors. Please use another terminal emulator. iTerm2 should - work fine. - - The arrows may have the wrong colors if you have changed the "minimum - contrast" slider in the color tab of your OS X settings. - -The statusline has strange characters like ``^B`` in it! - Please add ``set encoding=utf-8`` to your ``vimrc``. - - You may also need to set your ``LANG`` and ``LC_*`` environment - variables to a UTF-8 locale (e.g. ``LANG=en_US.utf8``). Consult your - Linux distro's documentation for information about setting these - variables correctly. - -The statusline has a lot of ``^`` or underline characters in it! - You need to configure the ``fillchars`` setting to disable statusline - fillchars (see ``:h fillchars`` for details). Add this to your - ``vimrc`` to solve this issue:: - - set fillchars+=stl:\ ,stlnc:\ - -The statusline is hidden/only appears in split windows! - Make sure that you have ``set laststatus=2`` in your ``vimrc``. - -I'm using tmux and Powerline looks like crap, what's wrong? - You need to tell tmux that it has 256-color capabilities. Add this to - your ``.tmux.conf`` to solve this issue:: - - set -g default-terminal "screen-256color" - - If you use iTerm2, make sure that you have enabled the setting 'Set - locale variables automatically' in Profiles > Terminal > Environment. - -If you have any other issues and you can't find the answer in the docs, -please submit an issue on GitHub. - -.. _`Powerline wiki`: https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts diff --git a/bundle/powerline/autoload/Pl.vim b/bundle/powerline/autoload/Pl.vim deleted file mode 100644 index 83edf6c..0000000 --- a/bundle/powerline/autoload/Pl.vim +++ /dev/null @@ -1,184 +0,0 @@ -" Powerline - The ultimate statusline utility -" -" Author: Kim Silkebækken -" Source repository: https://github.com/Lokaltog/vim-powerline - -" Script variables {{{ - let g:Pl#OLD_STL = '' - let g:Pl#THEME = [] - let g:Pl#THEME_CALLBACKS = [] - let g:Pl#HL = [] - - " Cache revision, this must be incremented whenever the cache format is changed - let s:CACHE_REVISION = 7 -" }}} -" Script initialization {{{ - function! Pl#LoadCache() " {{{ - if filereadable(g:Powerline_cache_file) && g:Powerline_cache_enabled - exec 'source' escape(g:Powerline_cache_file, ' \') - - if ! exists('g:Powerline_cache_revision') || g:Powerline_cache_revision != s:CACHE_REVISION - " Cache revision differs, cache is invalid - unlet! g:Powerline_cache_revision - - return 0 - endif - - " Create highlighting groups - for hi_cmd in g:Pl#HL - exec hi_cmd - endfor - - " Run theme callbacks - for callback in g:Pl#THEME_CALLBACKS - " Substitute {{NEWLINE}} with newlines (strings must be - " stored without newlines characters to avoid vim errors) - exec substitute(callback[0], "{{NEWLINE}}", "\n", 'g') - exec substitute(callback[1], "{{NEWLINE}}", "\n", 'g') - endfor - - return 1 - endif - - return 0 - endfunction " }}} - function! Pl#ClearCache() " {{{ - if filereadable(g:Powerline_cache_file) - " Delete the cache file - call delete(g:Powerline_cache_file) - endif - - echo 'Powerline cache cleared. Please restart vim for the changes to take effect.' - endfunction " }}} - function! Pl#ReloadColorscheme() " {{{ - call Pl#ClearCache() - - " The colorscheme and theme files must be manually sourced because - " vim won't reload previously autoloaded files - " - " This is a bit hackish, but it works - unlet! g:Powerline#Colorschemes#{g:Powerline_colorscheme}#colorscheme - exec "source" split(globpath(&rtp, 'autoload/Powerline/Colorschemes/'. g:Powerline_colorscheme .'.vim', 1), '\n')[0] - - unlet! g:Powerline#Themes#{g:Powerline_theme}#theme - exec "source" split(globpath(&rtp, 'autoload/Powerline/Themes/'. g:Powerline_theme .'.vim', 1), '\n')[0] - - let g:Pl#THEME = [] - - call Pl#Load() - endfunction " }}} - function! Pl#Load() " {{{ - if empty(g:Pl#OLD_STL) - " Store old statusline - let g:Pl#OLD_STL = &statusline - endif - - if ! Pl#LoadCache() - try - " Autoload the theme dict first - let raw_theme = g:Powerline#Themes#{g:Powerline_theme}#theme - catch - echom 'Invalid Powerline theme! Please check your theme and colorscheme settings.' - - return - endtry - - " Create list with parsed statuslines - for buffer_statusline in raw_theme - unlet! mode_statuslines - let mode_statuslines = Pl#Parser#GetStatusline(buffer_statusline.segments) - - if ! empty(buffer_statusline.callback) - " The callback function passes its arguments on to - " Pl#StatuslineCallback along with the normal/current mode - " statusline. - let s:cb_func = "function! PowerlineStatuslineCallback_". buffer_statusline.callback[1] ."(...)\n" - let s:cb_func .= "return Pl#StatuslineCallback(". string(mode_statuslines['n']) .", a:000)\n" - let s:cb_func .= "endfunction" - - " The callback expression should be used to initialize any - " variables that will use the callback function. The - " expression requires a %s which will be replaced by the - " callback function name. - let s:cb_expr = printf(buffer_statusline.callback[2], 'PowerlineStatuslineCallback_'. buffer_statusline.callback[1]) - - exec s:cb_func - exec s:cb_expr - - " Newlines must be substituted with another character - " because vim doesn't like newlines in strings - call add(g:Pl#THEME_CALLBACKS, [substitute(s:cb_func, "\n", "{{NEWLINE}}", 'g'), substitute(s:cb_expr, "\n", "{{NEWLINE}}", 'g')]) - - unlet! s:cb_func s:cb_expr - - continue - endif - - " Store the statuslines for matching specific buffers - call add(g:Pl#THEME, { - \ 'matches': buffer_statusline.matches, - \ 'mode_statuslines': mode_statuslines - \ }) - endfor - - if ! g:Powerline_cache_enabled - " Don't cache anything if caching is disabled or cache file isn't writeable - return - endif - - " Prepare commands and statuslines for caching - let cache = [ - \ 'let g:Powerline_cache_revision = '. string(s:CACHE_REVISION), - \ 'let g:Pl#HL = '. string(g:Pl#HL), - \ 'let g:Pl#THEME = '. string(g:Pl#THEME), - \ 'let g:Pl#THEME_CALLBACKS = '. string(g:Pl#THEME_CALLBACKS), - \ ] - - call writefile(cache, g:Powerline_cache_file) - endif - endfunction " }}} -" }}} -" Statusline updater {{{ - function! Pl#Statusline(statusline, current) " {{{ - let mode = mode() - - if ! a:current - let mode = 'N' " Normal (non-current) - elseif mode =~# '\v(v|V|)' - let mode = 'v' " Visual mode - elseif mode =~# '\v(s|S|)' - let mode = 's' " Select mode - elseif mode =~# '\vi' - let mode = 'i' " Insert mode - elseif mode =~# '\v(R|Rv)' - let mode = 'r' " Replace mode - else - " Fallback to normal mode - let mode = 'n' " Normal (current) - endif - - return g:Pl#THEME[a:statusline].mode_statuslines[mode] - endfunction " }}} - function! Pl#StatuslineCallback(statusline, args) " {{{ - " Replace %1, %2, etc. in the statusline with the callback args - return substitute( - \ a:statusline, - \ '\v\%(\d+)', - \ '\=a:args[submatch(1)]', - \ 'g') - endfunction " }}} - function! Pl#UpdateStatusline(current, ...) " {{{ - if empty(g:Pl#THEME) - " Load statuslines if they aren't loaded yet - call Pl#Load() - endif - - for i in range(len(g:Pl#THEME)) - if Pl#Match#Validate(g:Pl#THEME[i], a:0 ? a:1 : 0) - " Update window-local statusline - call setwinvar(a:0 ? a:1 : 0, '&statusline', - \ '%!Pl#Statusline('. i .','. a:current .')') - endif - endfor - endfunction " }}} -" }}} diff --git a/bundle/powerline/autoload/Pl/Colorscheme.vim b/bundle/powerline/autoload/Pl/Colorscheme.vim deleted file mode 100644 index ec15e46..0000000 --- a/bundle/powerline/autoload/Pl/Colorscheme.vim +++ /dev/null @@ -1,145 +0,0 @@ -function! Pl#Colorscheme#Init(hi) " {{{ - let colorscheme = {} - - for hi in a:hi - " Ensure that the segments are a list - let segments = type(hi[0]) == type('') ? [ hi[0] ] : hi[0] - let mode_hi_dict = hi[1] - - for segment in segments - let colorscheme[segment] = mode_hi_dict - endfor - endfor - - return colorscheme -endfunction " }}} -function! Pl#Colorscheme#Apply(colorscheme, buffer_segments) " {{{ - " Set color parameters for all segments in a:buffer_segments - - " TODO This function should be recursive and work on both segments and groups - " TODO We could probably handle the NS stuff here... - - try - let colorscheme = g:Powerline#Colorschemes#{a:colorscheme}#colorscheme - catch - echom 'Color scheme "'. a:colorscheme .'" doesn''t exist!' - - return - endtry - - let buffer_segments = a:buffer_segments - - " This is a bit complex, I'll walk you through exactly what happens here... - " - " First of all we loop through the buffer_segments, which are the segments that - " this specific buffer will have. - for buffer_segment in buffer_segments - " The buffer_segment consists of a 'matches' list and a 'segments' list. - " The 'matches' list has conditions to limit this statusline to specific buffers/windows. - " The 'segments' list has each segment and segment group for this buffer - for segment in buffer_segment.segments - let type = get(segment, 'type', '') - - if type == 'segment_group' - " We're going to handle segment groups different from single segments. Segment groups - " have child segments which may have their own highlighting (e.g. fileinfo.flags), - " and these child segments may be grouped (e.g. fileinfo.flags.ro) to provide very - " specific highlighting. So here we'll handle all that: - - " Set the default/fallback colors for this group - for i in range(len(segment.variants), 0, -1) - " Check for available highlighting for the main group segment - " - " This works like the segment highlighting below - " TODO Create a function for this - let seg_variants = join(segment.variants[0:i], '.') - - let seg_name = i > 0 ? segment.name .'.'. seg_variants : segment.name - let seg_ns_name = len(segment.ns) > 0 ? segment.ns .':'. seg_name : seg_name - - if has_key(colorscheme, seg_ns_name) - " We have a namespaced highlight group - let segment.colors = colorscheme[seg_ns_name] - break - elseif has_key(colorscheme, seg_name) - " We have a non-namespaced group - let segment.colors = colorscheme[seg_name] - break - endif - endfor - - " The reason why we need to deepcopy the group's segments is that the child segments - " all point to the same base segments and that screws up highlighting if we highlight - " some child segments with different namespaced colors - let segment.segments = deepcopy(segment.segments) - - " Apply colors to each child segment - for child_segment in segment.segments - " Check if this child segment is grouped (e.g. fileinfo.flags.group.subgroup) - " We're going to prioritize the most specific grouping and then work back to the - " most common group (e.g. fileinfo.flags) - - " FIXME We don't have the variants from before because group children aren't run through Pl#Segment#Get - let child_segment.variants = [seg_name] + split(child_segment.name, '\.') - - " Use the parent group's namespace - let child_segment.ns = segment.ns - - for i in range(len(child_segment.variants), 0, -1) - " Check for available highlighting for the main group segment - let child_seg_name = join(child_segment.variants[0:i], '.') - - let child_seg_ns_name = len(child_segment.ns) > 0 ? child_segment.ns .':'. child_seg_name : child_seg_name - - if has_key(colorscheme, child_seg_ns_name) - " We have a namespaced highlight group - let child_segment.colors = colorscheme[child_seg_ns_name] - break - elseif has_key(colorscheme, child_seg_name) - " We have a non-namespaced group - let child_segment.colors = colorscheme[child_seg_name] - break - endif - endfor - endfor - elseif type == 'segment' - for i in range(len(segment.variants), 0, -1) - " Check for available highlighting - " - " This is done in the following manner, using the segment gundo:static_filename.text.buffer as an example: - " - " * Look for the hl group: gundo:static_filename.text.buffer - " * Look for the hl group: static_filename.text.buffer - " * Look for the hl group: gundo:static_filename.text - " * Look for the hl group: static_filename.text - " * Look for the hl group: gundo:static_filename - " * Look for the hl group: static_filename - " * Return the segment without highlighting, causing an error in the parser - let seg_variants = join(segment.variants[0:i], '.') - - let seg_name = i > 0 ? segment.name .'.'. seg_variants : segment.name - let seg_ns_name = len(segment.ns) > 0 ? segment.ns .':'. seg_name : seg_name - - if has_key(colorscheme, seg_ns_name) - " We have a namespaced highlight group - let segment.colors = colorscheme[seg_ns_name] - break - elseif has_key(colorscheme, seg_name) - " We have a non-namespaced group - let segment.colors = colorscheme[seg_name] - break - endif - endfor - endif - - unlet! segment - endfor - endfor - - " Good luck parsing this return value - " - " It's a huge dict with all segments for all buffers with their respective syntax highlighting. - " It will be parsed by the main Powerline code, where all the data will be shortened to a simple - " array consiting of a statusline for each mode, with generated highlighting groups and dividers. - return buffer_segments -endfunction " }}} diff --git a/bundle/powerline/autoload/Pl/Hi.vim b/bundle/powerline/autoload/Pl/Hi.vim deleted file mode 100644 index f6b3eea..0000000 --- a/bundle/powerline/autoload/Pl/Hi.vim +++ /dev/null @@ -1,140 +0,0 @@ -" cterm -> gui color dict {{{ -let s:cterm2gui_dict = { - \ 16: 0x000000, 17: 0x00005f, 18: 0x000087, 19: 0x0000af, 20: 0x0000d7, 21: 0x0000ff, - \ 22: 0x005f00, 23: 0x005f5f, 24: 0x005f87, 25: 0x005faf, 26: 0x005fd7, 27: 0x005fff, - \ 28: 0x008700, 29: 0x00875f, 30: 0x008787, 31: 0x0087af, 32: 0x0087d7, 33: 0x0087ff, - \ 34: 0x00af00, 35: 0x00af5f, 36: 0x00af87, 37: 0x00afaf, 38: 0x00afd7, 39: 0x00afff, - \ 40: 0x00d700, 41: 0x00d75f, 42: 0x00d787, 43: 0x00d7af, 44: 0x00d7d7, 45: 0x00d7ff, - \ 46: 0x00ff00, 47: 0x00ff5f, 48: 0x00ff87, 49: 0x00ffaf, 50: 0x00ffd7, 51: 0x00ffff, - \ 52: 0x5f0000, 53: 0x5f005f, 54: 0x5f0087, 55: 0x5f00af, 56: 0x5f00d7, 57: 0x5f00ff, - \ 58: 0x5f5f00, 59: 0x5f5f5f, 60: 0x5f5f87, 61: 0x5f5faf, 62: 0x5f5fd7, 63: 0x5f5fff, - \ 64: 0x5f8700, 65: 0x5f875f, 66: 0x5f8787, 67: 0x5f87af, 68: 0x5f87d7, 69: 0x5f87ff, - \ 70: 0x5faf00, 71: 0x5faf5f, 72: 0x5faf87, 73: 0x5fafaf, 74: 0x5fafd7, 75: 0x5fafff, - \ 76: 0x5fd700, 77: 0x5fd75f, 78: 0x5fd787, 79: 0x5fd7af, 80: 0x5fd7d7, 81: 0x5fd7ff, - \ 82: 0x5fff00, 83: 0x5fff5f, 84: 0x5fff87, 85: 0x5fffaf, 86: 0x5fffd7, 87: 0x5fffff, - \ 88: 0x870000, 89: 0x87005f, 90: 0x870087, 91: 0x8700af, 92: 0x8700d7, 93: 0x8700ff, - \ 94: 0x875f00, 95: 0x875f5f, 96: 0x875f87, 97: 0x875faf, 98: 0x875fd7, 99: 0x875fff, - \ 100: 0x878700, 101: 0x87875f, 102: 0x878787, 103: 0x8787af, 104: 0x8787d7, 105: 0x8787ff, - \ 106: 0x87af00, 107: 0x87af5f, 108: 0x87af87, 109: 0x87afaf, 110: 0x87afd7, 111: 0x87afff, - \ 112: 0x87d700, 113: 0x87d75f, 114: 0x87d787, 115: 0x87d7af, 116: 0x87d7d7, 117: 0x87d7ff, - \ 118: 0x87ff00, 119: 0x87ff5f, 120: 0x87ff87, 121: 0x87ffaf, 122: 0x87ffd7, 123: 0x87ffff, - \ 124: 0xaf0000, 125: 0xaf005f, 126: 0xaf0087, 127: 0xaf00af, 128: 0xaf00d7, 129: 0xaf00ff, - \ 130: 0xaf5f00, 131: 0xaf5f5f, 132: 0xaf5f87, 133: 0xaf5faf, 134: 0xaf5fd7, 135: 0xaf5fff, - \ 136: 0xaf8700, 137: 0xaf875f, 138: 0xaf8787, 139: 0xaf87af, 140: 0xaf87d7, 141: 0xaf87ff, - \ 142: 0xafaf00, 143: 0xafaf5f, 144: 0xafaf87, 145: 0xafafaf, 146: 0xafafd7, 147: 0xafafff, - \ 148: 0xafd700, 149: 0xafd75f, 150: 0xafd787, 151: 0xafd7af, 152: 0xafd7d7, 153: 0xafd7ff, - \ 154: 0xafff00, 155: 0xafff5f, 156: 0xafff87, 157: 0xafffaf, 158: 0xafffd7, 159: 0xafffff, - \ 160: 0xd70000, 161: 0xd7005f, 162: 0xd70087, 163: 0xd700af, 164: 0xd700d7, 165: 0xd700ff, - \ 166: 0xd75f00, 167: 0xd75f5f, 168: 0xd75f87, 169: 0xd75faf, 170: 0xd75fd7, 171: 0xd75fff, - \ 172: 0xd78700, 173: 0xd7875f, 174: 0xd78787, 175: 0xd787af, 176: 0xd787d7, 177: 0xd787ff, - \ 178: 0xd7af00, 179: 0xd7af5f, 180: 0xd7af87, 181: 0xd7afaf, 182: 0xd7afd7, 183: 0xd7afff, - \ 184: 0xd7d700, 185: 0xd7d75f, 186: 0xd7d787, 187: 0xd7d7af, 188: 0xd7d7d7, 189: 0xd7d7ff, - \ 190: 0xd7ff00, 191: 0xd7ff5f, 192: 0xd7ff87, 193: 0xd7ffaf, 194: 0xd7ffd7, 195: 0xd7ffff, - \ 196: 0xff0000, 197: 0xff005f, 198: 0xff0087, 199: 0xff00af, 200: 0xff00d7, 201: 0xff00ff, - \ 202: 0xff5f00, 203: 0xff5f5f, 204: 0xff5f87, 205: 0xff5faf, 206: 0xff5fd7, 207: 0xff5fff, - \ 208: 0xff8700, 209: 0xff875f, 210: 0xff8787, 211: 0xff87af, 212: 0xff87d7, 213: 0xff87ff, - \ 214: 0xffaf00, 215: 0xffaf5f, 216: 0xffaf87, 217: 0xffafaf, 218: 0xffafd7, 219: 0xffafff, - \ 220: 0xffd700, 221: 0xffd75f, 222: 0xffd787, 223: 0xffd7af, 224: 0xffd7d7, 225: 0xffd7ff, - \ 226: 0xffff00, 227: 0xffff5f, 228: 0xffff87, 229: 0xffffaf, 230: 0xffffd7, 231: 0xffffff, - \ 232: 0x080808, 233: 0x121212, 234: 0x1c1c1c, 235: 0x262626, 236: 0x303030, 237: 0x3a3a3a, - \ 238: 0x444444, 239: 0x4e4e4e, 240: 0x585858, 241: 0x626262, 242: 0x6c6c6c, 243: 0x767676, - \ 244: 0x808080, 245: 0x8a8a8a, 246: 0x949494, 247: 0x9e9e9e, 248: 0xa8a8a8, 249: 0xb2b2b2, - \ 250: 0xbcbcbc, 251: 0xc6c6c6, 252: 0xd0d0d0, 253: 0xdadada, 254: 0xe4e4e4, 255: 0xeeeeee -\ } -" }}} -" Allocated color dict {{{ -let s:allocated_colors = { - \ 'NONE': 'NONE', - \ } -" }}} -function! s:Cterm2GUI(cterm) " {{{ - if toupper(a:cterm) == 'NONE' - return 'NONE' - endif - - if ! has_key(s:cterm2gui_dict, a:cterm) - return 0xff0000 - endif - - return s:cterm2gui_dict[a:cterm] -endfunction " }}} -function! Pl#Hi#Segments(segments, mode_colors) " {{{ - let mode_translate = { - \ 'normal': 'n', - \ 'noncurrent': 'N', - \ 'insert': 'i', - \ 'visual': 'v', - \ 'replace': 'r', - \ 'select': 's', - \ } - - let attributes = ['bold', 'italic', 'underline'] - - let segments = a:segments - let mode_hi_dict = {} - - " Mode dict - for [mode, colors] in items(a:mode_colors) - if has_key(mode_translate, mode) - let mode = mode_translate[mode] - endif - - unlet! fg - let fg = s:allocated_colors[colors[0]] - - let hi = { - \ 'cterm': [fg['cterm'], ''], - \ 'gui' : [fg['gui'], ''], - \ 'attr' : [] - \ } - - if exists('colors[1]') - if type(colors[1]) == type([]) - " We don't have a BG color, but we have attributes - let hi.attr = colors[1] - else - " The second parameter is the background color - unlet! bg - let bg = s:allocated_colors[colors[1]] - - let hi.cterm[1] = bg['cterm'] - let hi.gui[1] = bg['gui'] - endif - endif - - if exists('colors[2]') && type(colors[2]) == type([]) - " The third parameter is always an attribute list - let hi.attr = colors[2] - endif - - let mode_hi_dict[mode] = { - \ 'ctermfg': (empty(hi['cterm'][0]) ? '' : (string(hi['cterm'][0]) == 'NONE' ? 'NONE' : hi['cterm'][0])), - \ 'ctermbg': (empty(hi['cterm'][1]) ? '' : (string(hi['cterm'][1]) == 'NONE' ? 'NONE' : hi['cterm'][1])), - \ 'guifg' : (empty(hi['gui'][0]) ? '' : (string(hi['gui'][0]) == 'NONE' ? 'NONE' : hi['gui'][0])), - \ 'guibg' : (empty(hi['gui'][1]) ? '' : (string(hi['gui'][1]) == 'NONE' ? 'NONE' : hi['gui'][1])), - \ 'attr' : (! len(hi['attr']) ? 'NONE' : join(hi['attr'], ',')) - \ } - endfor - - return [segments, mode_hi_dict] -endfunction " }}} -function! Pl#Hi#Allocate(colors) " {{{ - for [key, color] in items(a:colors) - if type(color) == type(0) - " Only terminal color - let cterm = color - let gui = s:Cterm2GUI(color) - elseif type(color) == type([]) && len(color) == 2 - " Terminal and GUI colors - let cterm = color[0] - let gui = color[1] - endif - - let s:allocated_colors[key] = { - \ 'cterm': cterm, - \ 'gui': gui, - \ } - - unlet! color - endfor -endfunction " }}} diff --git a/bundle/powerline/autoload/Pl/Match.vim b/bundle/powerline/autoload/Pl/Match.vim deleted file mode 100644 index 93aa6d0..0000000 --- a/bundle/powerline/autoload/Pl/Match.vim +++ /dev/null @@ -1,43 +0,0 @@ -function! Pl#Match#Add(pat, expr) " {{{ - return [a:pat, a:expr] -endfunction " }}} -function! Pl#Match#Any(...) " {{{ - let matches = [] - - for match_name in a:000 - if empty(match_name) - " Skip empty match parameters - continue - endif - - if has_key(g:Powerline#Matches#matches, match_name) - call add(matches, g:Powerline#Matches#matches[match_name]) - endif - - unlet! match_name - endfor - - return ['match', 'any', matches] -endfunction " }}} -function! Pl#Match#Validate(theme, window) " {{{ - let match = a:theme.matches[1] - - if match == 'none' - return 0 - elseif match == 'any' - let matches = a:theme.matches[2] - - if ! len(matches) - " Empty match array matches everything - return 1 - endif - - for [eval, re] in matches - if match(eval(eval), '\v\C'. re) != -1 - return 1 - endif - endfor - - return 0 - endif -endfunction " }}} diff --git a/bundle/powerline/autoload/Pl/Mod.vim b/bundle/powerline/autoload/Pl/Mod.vim deleted file mode 100644 index fdfb571..0000000 --- a/bundle/powerline/autoload/Pl/Mod.vim +++ /dev/null @@ -1,40 +0,0 @@ -let s:segment_mods = [] - -function! Pl#Mod#AddSegmentMod(action, properties) " {{{ - call add(s:segment_mods, [a:action, a:properties]) -endfunction " }}} -function! Pl#Mod#ApplySegmentMods(theme) " {{{ - let theme = deepcopy(a:theme) - - for mod in s:segment_mods - let [action, properties] = mod - - " We have to loop through the segments instead of using index() because some - " segments are lists! - let target_seg_idx = -1 - - for i in range(0, len(theme) - 1) - unlet! segment - let segment = theme[i] - - if type(segment) == type(properties.target_segment) && segment == properties.target_segment - let target_seg_idx = i - break - endif - endfor - - if action == 'insert_segment' - " Insert segment - if target_seg_idx != -1 - call insert(theme, properties.new_segment, (properties.where == 'before' ? target_seg_idx : target_seg_idx + 1)) - endif - elseif action == 'remove_segment' - " Remove segment - if target_seg_idx != -1 - call remove(theme, target_seg_idx) - endif - endif - endfor - - return theme -endfunction " }}} diff --git a/bundle/powerline/autoload/Pl/Parser.vim b/bundle/powerline/autoload/Pl/Parser.vim deleted file mode 100644 index a6f3428..0000000 --- a/bundle/powerline/autoload/Pl/Parser.vim +++ /dev/null @@ -1,371 +0,0 @@ -let g:Pl#Parser#Symbols = { - \ 'compatible': { - \ 'dividers': [ '', [0x2502], '', [0x2502] ] - \ , 'symbols' : { - \ 'BRANCH': 'BR:' - \ , 'RO' : 'RO' - \ , 'FT' : 'FT' - \ , 'LINE' : 'LN' - \ } - \ }, - \ 'unicode': { - \ 'dividers': [ [0x25b6], [0x276f], [0x25c0], [0x276e] ] - \ , 'symbols' : { - \ 'BRANCH': [0x26a1] - \ , 'RO' : [0x2613] - \ , 'FT' : [0x2691] - \ , 'LINE' : [0x204b] - \ }, - \ }, - \ 'fancy': { - \ 'dividers': [ [0x2b80], [0x2b81], [0x2b82], [0x2b83] ] - \ , 'symbols' : { - \ 'BRANCH': [0x2b60] - \ , 'RO' : [0x2b64] - \ , 'FT' : [0x2b62, 0x2b63] - \ , 'LINE' : [0x2b61] - \ } - \ } -\ } - -" Handle symbol overrides -for [s:key, s:value] in items(g:Powerline_symbols_override) - let g:Pl#Parser#Symbols[g:Powerline_symbols].symbols[s:key] = s:value - - unlet! s:key s:value -endfor - -" Handle divider overrides -if len(g:Powerline_dividers_override) == 4 - let g:Pl#Parser#Symbols[g:Powerline_symbols].dividers = g:Powerline_dividers_override -endif - -let s:LEFT_SIDE = 0 -let s:RIGHT_SIDE = 2 - -let s:PADDING = 1 - -let s:EMPTY_SEGMENT = { 'type': 'empty' } - -let s:HARD_DIVIDER = 0 -let s:SOFT_DIVIDER = 1 - -function! Pl#Parser#GetStatusline(segments) " {{{ - let statusline = { - \ 'n': '' - \ , 'N': '' - \ , 'v': '' - \ , 'i': '' - \ , 'r': '' - \ , 's': '' - \ } - - " Run through the different modes and create the statuslines - for mode in keys(statusline) - " Create an empty statusline list - let stl = [] - - call extend(stl, s:ParseSegments(mode, s:LEFT_SIDE, a:segments)) - - let statusline[mode] .= join(stl, '') - endfor - - return statusline -endfunction " }}} -function! Pl#Parser#ParseChars(arg) " {{{ - " Handles symbol arrays which can be either an array of hex values, - " or a string. Will convert the hex array to a string, or return the - " string as-is. - let arg = a:arg - - if type(arg) == type([]) - " Hex array - call map(arg, 'nr2char(v:val)') - - return join(arg, '') - endif - - " Anything else, just return it as it is - return arg -endfunction " }}} -function! s:ParseSegments(mode, side, segments, ...) " {{{ - let mode = a:mode - let side = a:side - let segments = a:segments - - let level = exists('a:1') ? a:1 : 0 - let base_color = exists('a:2') ? a:2 : {} - - let ret = [] - - for i in range(0, len(segments) - 1) - unlet! seg_prev seg_curr seg_next - - " Prepare some resources (fetch previous, current and next segment) - let seg_curr = deepcopy(get(segments, i)) - - " Find previous segment - let seg_prev = s:EMPTY_SEGMENT - - " If we're currently at i = 0 we have to start on 0 or else we will start on the last segment (list[-1]) - let range_start = (i == 0 ? i : i - 1) - for j in range(range_start, 0, -1) - let seg = deepcopy(get(segments, j)) - if get(seg, 'name') ==# 'TRUNCATE' - " Skip truncate segments - continue - endif - - " Look ahead for another segment that's visible in this mode - if index(get(seg, 'modes'), mode) != -1 - " Use this segment - let seg_prev = seg - - break - endif - endfor - - "" Find next segment - let seg_next = s:EMPTY_SEGMENT - - " If we're currently at i = len(segments) - 1 we have to start on i or else we will get an error because the index doesn't exist - let range_start = (i == len(segments) - 1 ? i : i + 1) - for j in range(range_start, len(segments) - 1, 1) - let seg = deepcopy(get(segments, j)) - if get(seg, 'name') ==# 'TRUNCATE' - " Skip truncate segments - continue - endif - - " Look ahead for another segment that's visible in this mode - if index(get(seg, 'modes'), mode) != -1 - " Use this segment - let seg_next = seg - - break - endif - endfor - - if index(get(seg_curr, 'modes', []), mode) == -1 - " The segment is invisible in this mode, skip it - " FIXME When two segments after each other are hidden, a gap appears where the segments would be, this is probably due to segment padding - continue - endif - - " Handle the different segment types - if seg_curr.type == 'segment' - if seg_curr.name ==# 'TRUNCATE' - " Truncate statusline - call add(ret, '%<') - elseif seg_curr.name ==# 'SPLIT' - " Split statusline - - " Switch sides - let side = s:RIGHT_SIDE - - " Handle highlighting - let mode_colors = get(seg_curr.colors, mode, seg_curr.colors['n']) - let hl_group = s:HlCreate(mode_colors) - - " Add segment text - call add(ret, '%#'. hl_group .'#%=') - else - " Add segment text - let text = seg_curr.text - - " Decide on whether to use the group's colors or the segment's colors - let colors = get(seg_curr, 'colors', base_color) - - " Fallback to normal (current) highlighting if we don't have mode-specific highlighting - let mode_colors = get(colors, mode, get(colors, 'n', {})) - - if empty(mode_colors) - echom 'Segment doesn''t have any colors! NS: "'. seg_curr.ns .'" SEG: "'. seg_curr.name .'"' - - continue - endif - - " Check if we're in a group (level > 0) - if level > 0 - " If we're in a group we don't have dividers between - " segments, so we should only pad one side, but only pad - " if the segment doesn't have Pl#Segment#NoPadding() set - let padding_right = (seg_curr.padding && side == s:LEFT_SIDE ? repeat(' ', s:PADDING) : '') - let padding_left = (seg_curr.padding && side == s:RIGHT_SIDE ? repeat(' ', s:PADDING) : '') - - " Check if we lack a bg/fg color for this segment - " If we do, use the bg/fg color from base_color - let base_color_mode = ! has_key(base_color, mode) ? base_color['n'] : base_color[mode] - - for col in ['ctermbg', 'ctermfg', 'guibg', 'guifg'] - if empty(mode_colors[col]) - let mode_colors[col] = base_color_mode[col] - endif - endfor - else - "" If we're outside a group we have dividers and must pad both sides - let padding_left = repeat(' ', s:PADDING) - let padding_right = repeat(' ', s:PADDING) - endif - - " Get main hl group for segment - let hl_group = s:HlCreate(mode_colors) - - " Prepare segment text - let text = '%(%#'. hl_group .'#'. padding_left . text . padding_right . '%)' - - if level == 0 - " Add divider to single segments - let text = s:AddDivider(text, side, mode, colors, seg_prev, seg_curr, seg_next) - endif - - call add(ret, text) - endif - elseif seg_curr.type == 'segment_group' - " Recursively parse segment group - let func_params = [mode, side, seg_curr.segments, level + 1] - - if has_key(seg_curr, 'colors') - " Pass the base colors on to the child segments - call add(func_params, seg_curr.colors) - endif - - " Get segment group string - let text = join(call('s:ParseSegments', func_params), '') - - " Pad on the opposite side of the divider - let padding_right = (side == s:RIGHT_SIDE ? repeat(' ', s:PADDING) : '') - let padding_left = (side == s:LEFT_SIDE ? repeat(' ', s:PADDING) : '') - - let text = s:AddDivider(padding_left . text . padding_right, side, mode, seg_curr.colors, seg_prev, seg_curr, seg_next) - - call add(ret, text) - endif - endfor - - return ret -endfunction " }}} -function! s:HlCreate(hl) " {{{ - " Create a short and unique highlighting group name - " It uses the hex values of all the color properties and an attribute flag at the end - " NONE colors are translated to NN for cterm and NNNNNN for gui colors - let hi_group = printf('Pl%s%s%s%s%s' - \ , (a:hl['ctermfg'] == 'NONE' ? 'NN' : printf('%02x', a:hl['ctermfg'])) - \ , (a:hl['guifg'] == 'NONE' ? 'NNNNNN' : printf('%06x', a:hl['guifg'] )) - \ , (a:hl['ctermbg'] == 'NONE' ? 'NN' : printf('%02x', a:hl['ctermbg'])) - \ , (a:hl['guibg'] == 'NONE' ? 'NNNNNN' : printf('%06x', a:hl['guibg'] )) - \ , substitute(a:hl['attr'], '\v([a-zA-Z])[a-zA-Z]*,?', '\1', 'g') - \ ) - - if ! s:HlExists(hi_group) - let ctermbg = a:hl['ctermbg'] == 'NONE' ? 'NONE' : printf('%d', a:hl['ctermbg']) - if (has('win32') || has('win64')) && !has('gui_running') && ctermbg != 'NONE' && ctermbg > 128 - let ctermbg -= 128 - endif - let hi_cmd = printf('hi %s ctermfg=%s ctermbg=%s cterm=%s guifg=%s guibg=%s gui=%s' - \ , hi_group - \ , a:hl['ctermfg'] == 'NONE' ? 'NONE' : printf('%d', a:hl['ctermfg']) - \ , ctermbg - \ , a:hl['attr'] - \ , (a:hl['guifg'] == 'NONE' ? 'NONE' : printf('#%06x', a:hl['guifg'])) - \ , (a:hl['guibg'] == 'NONE' ? 'NONE' : printf('#%06x', a:hl['guibg'])) - \ , a:hl['attr'] - \ ) - - exec hi_cmd - - " Add command to Pl#HL list for caching - call add(g:Pl#HL, hi_cmd) - endif - - " Return only the highlighting group name - return hi_group -endfunction " }}} -function! s:HlExists(hl) " {{{ - if ! hlexists(a:hl) - return 0 - endif - - redir => hlstatus - silent exec 'hi' a:hl - redir END - - return (hlstatus !~ 'cleared') -endfunction " }}} -function! s:AddDivider(text, side, mode, colors, prev, curr, next) " {{{ - let seg_prev = a:prev - let seg_curr = a:curr - let seg_next = a:next - - " Set default color/type for the divider - let div_colors = get(a:colors, a:mode, a:colors['n']) - let div_type = s:SOFT_DIVIDER - - " Define segment to compare - let cmp_seg = a:side == s:LEFT_SIDE ? seg_next : seg_prev - - let cmp_all_colors = get(cmp_seg, 'colors', {}) - let cmp_colors = get(cmp_all_colors, a:mode, get(cmp_all_colors, 'n', {})) - - if ! empty(cmp_colors) - " Compare the highlighting groups - " - " If the background color for cterm is equal, use soft divider with the current segment's highlighting - " If not, use hard divider with a new highlighting group - " - " Note that if the previous/next segment is the split, a hard divider is always used - if get(div_colors, 'ctermbg') != get(cmp_colors, 'ctermbg') || get(seg_next, 'name') ==# 'SPLIT' || get(seg_prev, 'name') ==# 'SPLIT' - let div_type = s:HARD_DIVIDER - - " Create new highlighting group - if div_colors['attr'] =~ 'reverse' && cmp_colors['attr'] =~ 'reverse' - " Use FG = CURRENT FG, BG = CMP FG - let div_colors['ctermbg'] = get(cmp_colors, 'ctermfg') - let div_colors['guibg'] = get(cmp_colors, 'guifg') - - let div_colors['attr'] = div_colors['attr'] =~ 'bold' ? 'bold' : 'NONE' - elseif div_colors['attr'] =~ 'reverse' - " Use FG = CURRENT FG, BG = CMP BG - let div_colors['ctermbg'] = get(cmp_colors, 'ctermbg') - let div_colors['guibg'] = get(cmp_colors, 'guibg') - - let div_colors['attr'] = div_colors['attr'] =~ 'bold' ? 'bold' : 'NONE' - elseif cmp_colors['attr'] =~ 'reverse' - " Use FG = CMP FG, BG = CURRENT BG : reversed - let div_colors['ctermfg'] = get(cmp_colors, 'ctermfg') - let div_colors['guifg'] = get(cmp_colors, 'guifg') - - let div_colors['attr'] = 'reverse' - - else - " Use FG = CURRENT BG, BG = CMP BG - let div_colors['ctermfg'] = get(div_colors, 'ctermbg') - let div_colors['guifg'] = get(div_colors, 'guibg') - - let div_colors['ctermbg'] = get(cmp_colors, 'ctermbg') - let div_colors['guibg'] = get(cmp_colors, 'guibg') - - let div_colors['attr'] = 'NONE' - endif - endif - endif - - " Prepare divider - let divider_raw = deepcopy(g:Pl#Parser#Symbols[g:Powerline_symbols].dividers[a:side + div_type]) - let divider = Pl#Parser#ParseChars(divider_raw) - - " Don't add dividers for segments adjacent to split (unless it's a hard divider) - if ((get(seg_next, 'name') ==# 'SPLIT' || get(seg_prev, 'name') ==# 'SPLIT') && div_type != s:HARD_DIVIDER) - return '' - endif - - if a:side == s:LEFT_SIDE - " Left side - " Divider to the right - return printf('%%(%s%%#%s#%s%%)', a:text, s:HlCreate(div_colors), divider) - else - " Right side - " Divider to the left - return printf('%%(%%#%s#%s%s%%)', s:HlCreate(div_colors), divider, a:text) - endif -endfunction " }}} diff --git a/bundle/powerline/autoload/Pl/Segment.vim b/bundle/powerline/autoload/Pl/Segment.vim deleted file mode 100644 index bb09438..0000000 --- a/bundle/powerline/autoload/Pl/Segment.vim +++ /dev/null @@ -1,188 +0,0 @@ -let s:default_modes = ['n', 'N', 'v', 'i', 'r', 's'] - -function! s:CheckConditions(params) " {{{ - " Check conditions for a segment/group - " Integer parameters are always conditions - for param in a:params - if type(param) == type(0) && param == 0 - " Break here if it's an integer parameter and it's false (0) - return 0 - endif - unlet! param - endfor - - return 1 -endfunction " }}} -function! Pl#Segment#Create(name, ...) " {{{ - " Check condition parameters - if ! s:CheckConditions(a:000) - return {} - endif - - let name = a:name - let modes = s:default_modes - let padding = 1 - let segments = [] - - for param in a:000 - " Lookup modes for this segment/group - if type(param) == type([]) && param[0] == 'modes' - let modes = param[1] - elseif type(param) == type([]) && param[0] == 'nopadding' - let padding = 0 - elseif type(a:1) == type([]) && a:1[0] == 'segment' - call add(segments, param[1]) - endif - - unlet! param - endfor - - if type(a:1) == type([]) && a:1[0] == 'segment' - " This is a segment group - return ['segment_group', { - \ 'type': 'segment_group' - \ , 'name': name - \ , 'segments': segments - \ , 'modes': modes - \ , 'padding': padding - \ }] - else - " This is a single segment - let text = a:1 - - " Search/replace symbols - for [key, symbol] in items(g:Pl#Parser#Symbols[g:Powerline_symbols].symbols) - let text = substitute( - \ text, - \ '\v\$('. key .')', - \ '\=Pl#Parser#ParseChars(g:Pl#Parser#Symbols[g:Powerline_symbols].symbols[submatch(1)])', - \ 'g') - - unlet! key symbol - endfor - - return ['segment', { - \ 'type': 'segment' - \ , 'name': name - \ , 'text': text - \ , 'modes': modes - \ , 'padding': padding - \ }] - endif - -endfunction " }}} -function! Pl#Segment#Init(params) " {{{ - " Check condition parameters - if ! s:CheckConditions(a:params) - return {} - endif - - let segments = {} - let ns = '' - - for param in a:params - if type(param) == type('') - " String parameters is the namespace - let ns = param - elseif type(param) == type([]) - " The data dict is in param[1] - " By default we don't have a namespace for the segment - let segment = param[1] - - if ! empty(ns) - " Update segment so that it includes the namespace - " Add the namespace to the segment dict key - let segment.ns = ns - let segment.name = join([segment.ns, segment.name], ':') - endif - - let key = segment.name - - let segments[key] = segment - endif - - unlet! param - endfor - - return segments -endfunction " }}} -function! Pl#Segment#Modes(modes) " {{{ - " Handle modes for both segments and groups - let modes = split(a:modes, '\zs') - - if modes[0] == '!' - " Filter modes (e.g. "!nr" will ignore the segment in normal and replace modes) - let modes = filter(deepcopy(s:default_modes), 'v:val !~# "['. join(modes[1:]) .']"') - endif - - return ['modes', modes] -endfunction " }}} -function! Pl#Segment#NoPadding() " {{{ - return ['nopadding'] -endfunction " }}} -function! Pl#Segment#Split(...) " {{{ - return a:0 ? a:1 .':SPLIT' : 'SPLIT' -endfunction " }}} -function! Pl#Segment#Truncate() " {{{ - return 'TRUNCATE' -endfunction " }}} -function! Pl#Segment#Get(name) " {{{ - " Return a segment data dict - let args = [] - - " Check for printf segments (lists) - if type(a:name) == type([]) - " We're dealing with a segment with printf arguments - let seg_orig_name = a:name[0] - let args = a:name[1:] - else - let seg_orig_name = a:name - endif - - " Fetch namespace and variants for storing in the segment dict - let seg_ns = '' - let seg_variants = [] - - " Retrieve color scheme variants - let seg_name_split = split(seg_orig_name, '\v\.') - if len(seg_name_split) > 1 - let seg_variants = seg_name_split[1:] - endif - - " Retrieve segment name and namespace - " Use the first piece of the split string, we can't have variants in the final segment name - let seg_name_split = split(seg_name_split[0], '\v:') - let seg_name = seg_name_split[0] - - if len(seg_name_split) > 1 - let seg_ns = seg_name_split[0] - let seg_name = seg_name_split[-1] - endif - - try - " If we have a namespace, try to use the namespaced segment first (i.e. search for the segment in the namespaced file first) - let return_segment = deepcopy(g:Powerline#Segments#{seg_ns}#segments[seg_ns .':'. seg_name]) - catch - try - " We didn't find a namespaced segment, fall back to common segments - let return_segment = deepcopy(g:Powerline#Segments#segments[seg_name]) - catch - " Didn't find the segment among the common segments either, just skip it - return {} - endtry - endtry - - if len(args) && has_key(return_segment, 'text') - " Handle segment printf arguments - " printf doesn't accept lists as its second argument, so we have to work around that - let return_segment.text = call('printf', [ return_segment.text ] + args) - endif - - " Assign namespace, name and variants - let return_segment.ns = seg_ns - let return_segment.name = seg_name - let return_segment.orig_name = seg_orig_name - let return_segment.variants = seg_variants - - return return_segment -endfunction " }}} diff --git a/bundle/powerline/autoload/Pl/Theme.vim b/bundle/powerline/autoload/Pl/Theme.vim deleted file mode 100644 index da1581e..0000000 --- a/bundle/powerline/autoload/Pl/Theme.vim +++ /dev/null @@ -1,100 +0,0 @@ -function! Pl#Theme#Create(...) " {{{ - let buffer_segments = [] - - for buffer_segment in a:000 - " Remove empty segments (e.g. 'Pl#Theme#Function's) - if empty(buffer_segment) - continue - endif - - call add(buffer_segments, buffer_segment) - endfor - - let buffer_segments = Pl#Colorscheme#Apply(g:Powerline_colorscheme, buffer_segments) - - return buffer_segments -endfunction " }}} -function! Pl#Theme#Callback(name, expr) " {{{ - return ['callback', a:name, a:expr] -endfunction " }}} -function! Pl#Theme#Buffer(ns, ...) " {{{ - let segments = [] - let ns = ! empty(a:ns) ? a:ns .':' : '' - - " Match namespace parameter by default - let matches = Pl#Match#Any(a:ns) - let callback = [] - - let args = a:000 - let args = Pl#Mod#ApplySegmentMods(args) - - " Fetch segment data dicts - for item in args - if type(item) == type([]) - if item[0] == 'match' - " Match item, overrides default namespace match - let matches = item - - unlet! item - continue - elseif item[0] == 'callback' - " Store the item as a callback expression - let matches = ['match', 'none'] - let callback = [a:ns, item[1], item[2]] - - unlet! item - continue - endif - - " printf segment, append ns to first item in list - let item[0] = ns . item[0] - else - let item = ns . item - endif - - let segment = Pl#Segment#Get(item) - - if ! empty(segment) - " Skip empty (possible disabled) segments - call add(segments, segment) - endif - - unlet! item - endfor - - return { - \ 'matches': matches - \ , 'callback': callback - \ , 'segments': segments - \ } -endfunction " }}} -function! Pl#Theme#InsertSegment(new_segment, where, target_segment) " {{{ - " It's very important to NOT refer to the theme dict until everything's loaded! - " - " Because these functions are called from the vimrc, we need to put the - " actions in a list which will be parsed later. - " - " These functions don't accept a name parameter, because they work on the - " currently selected theme (will change any selected theme) - call Pl#Mod#AddSegmentMod('insert_segment', { - \ 'new_segment': a:new_segment, - \ 'where': a:where, - \ 'target_segment': a:target_segment - \ }) -endfunction " }}} -function! Pl#Theme#RemoveSegment(target_segment) " {{{ - " It's very important to NOT refer to the theme dict until everything's loaded! - " - " Because these functions are called from the vimrc, we need to put the - " actions in a list which will be parsed later. - " - " These functions don't accept a name parameter, because they work on the - " currently selected theme (will change any selected theme) - call Pl#Mod#AddSegmentMod('remove_segment', { - \ 'target_segment': a:target_segment - \ }) -endfunction " }}} -function! Pl#Theme#ReplaceSegment(old_segment, new_segment) " {{{ - call Pl#Theme#InsertSegment(a:new_segment, 'after', a:old_segment) - call Pl#Theme#RemoveSegment(a:old_segment) -endfunction " }}} diff --git a/bundle/powerline/autoload/Powerline/Colorschemes/default.vim b/bundle/powerline/autoload/Powerline/Colorschemes/default.vim deleted file mode 100644 index 4d4c7fa..0000000 --- a/bundle/powerline/autoload/Powerline/Colorschemes/default.vim +++ /dev/null @@ -1,166 +0,0 @@ -call Pl#Hi#Allocate({ - \ 'black' : 16, - \ 'white' : 231, - \ - \ 'darkestgreen' : 22, - \ 'darkgreen' : 28, - \ 'mediumgreen' : 70, - \ 'brightgreen' : 148, - \ - \ 'darkestcyan' : 23, - \ 'mediumcyan' : 117, - \ - \ 'darkestblue' : 24, - \ 'darkblue' : 31, - \ - \ 'darkestred' : 52, - \ 'darkred' : 88, - \ 'mediumred' : 124, - \ 'brightred' : 160, - \ 'brightestred' : 196, - \ - \ 'darkestpurple' : 55, - \ 'mediumpurple' : 98, - \ 'brightpurple' : 189, - \ - \ 'brightorange' : 208, - \ 'brightestorange': 214, - \ - \ 'gray0' : 233, - \ 'gray1' : 235, - \ 'gray2' : 236, - \ 'gray3' : 239, - \ 'gray4' : 240, - \ 'gray5' : 241, - \ 'gray6' : 244, - \ 'gray7' : 245, - \ 'gray8' : 247, - \ 'gray9' : 250, - \ 'gray10' : 252, - \ }) - -let g:Powerline#Colorschemes#default#colorscheme = Pl#Colorscheme#Init([ - \ Pl#Hi#Segments(['SPLIT'], { - \ 'n': ['white', 'gray2'], - \ 'N': ['white', 'gray0'], - \ 'i': ['white', 'darkestblue'], - \ }), - \ - \ Pl#Hi#Segments(['mode_indicator'], { - \ 'n': ['darkestgreen', 'brightgreen', ['bold']], - \ 'i': ['darkestcyan', 'white', ['bold']], - \ 'v': ['darkred', 'brightorange', ['bold']], - \ 'r': ['white', 'brightred', ['bold']], - \ 's': ['white', 'gray5', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['branch', 'scrollpercent', 'raw', 'filesize'], { - \ 'n': ['gray9', 'gray4'], - \ 'N': ['gray4', 'gray1'], - \ 'i': ['mediumcyan', 'darkblue'], - \ }), - \ - \ Pl#Hi#Segments(['fileinfo', 'filename'], { - \ 'n': ['white', 'gray4', ['bold']], - \ 'N': ['gray7', 'gray0', ['bold']], - \ 'i': ['white', 'darkblue', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['fileinfo.filepath'], { - \ 'n': ['gray10'], - \ 'N': ['gray5'], - \ 'i': ['mediumcyan'], - \ }), - \ - \ Pl#Hi#Segments(['static_str'], { - \ 'n': ['white', 'gray4'], - \ 'N': ['gray7', 'gray1'], - \ 'i': ['white', 'darkblue'], - \ }), - \ - \ Pl#Hi#Segments(['fileinfo.flags'], { - \ 'n': ['brightestred', ['bold']], - \ 'N': ['darkred'], - \ 'i': ['brightestred', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['currenttag', 'fullcurrenttag', 'fileformat', 'fileencoding', 'pwd', 'filetype', 'rvm:string', 'rvm:statusline', 'virtualenv:statusline', 'charcode', 'currhigroup'], { - \ 'n': ['gray8', 'gray2'], - \ 'i': ['mediumcyan', 'darkestblue'], - \ }), - \ - \ Pl#Hi#Segments(['lineinfo'], { - \ 'n': ['gray2', 'gray10', ['bold']], - \ 'N': ['gray7', 'gray1', ['bold']], - \ 'i': ['darkestcyan', 'mediumcyan', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['errors'], { - \ 'n': ['brightestorange', 'gray2', ['bold']], - \ 'i': ['brightestorange', 'darkestblue', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['lineinfo.line.tot'], { - \ 'n': ['gray6'], - \ 'N': ['gray5'], - \ 'i': ['darkestcyan'], - \ }), - \ - \ Pl#Hi#Segments(['paste_indicator', 'ws_marker'], { - \ 'n': ['white', 'brightred', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['gundo:static_str.name', 'command_t:static_str.name'], { - \ 'n': ['white', 'mediumred', ['bold']], - \ 'N': ['brightred', 'darkestred', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['gundo:static_str.buffer', 'command_t:raw.line'], { - \ 'n': ['white', 'darkred'], - \ 'N': ['brightred', 'darkestred'], - \ }), - \ - \ Pl#Hi#Segments(['gundo:SPLIT', 'command_t:SPLIT'], { - \ 'n': ['white', 'darkred'], - \ 'N': ['white', 'darkestred'], - \ }), - \ - \ Pl#Hi#Segments(['lustyexplorer:static_str.name', 'minibufexplorer:static_str.name', 'nerdtree:raw.name', 'tagbar:static_str.name'], { - \ 'n': ['white', 'mediumgreen', ['bold']], - \ 'N': ['mediumgreen', 'darkestgreen', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['lustyexplorer:static_str.buffer', 'tagbar:static_str.buffer'], { - \ 'n': ['brightgreen', 'darkgreen'], - \ 'N': ['mediumgreen', 'darkestgreen'], - \ }), - \ - \ Pl#Hi#Segments(['lustyexplorer:SPLIT', 'minibufexplorer:SPLIT', 'nerdtree:SPLIT', 'tagbar:SPLIT'], { - \ 'n': ['white', 'darkgreen'], - \ 'N': ['white', 'darkestgreen'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:focus', 'ctrlp:byfname'], { - \ 'n': ['brightpurple', 'darkestpurple'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:prev', 'ctrlp:next', 'ctrlp:pwd'], { - \ 'n': ['white', 'mediumpurple'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:item'], { - \ 'n': ['darkestpurple', 'white', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:marked'], { - \ 'n': ['brightestred', 'darkestpurple', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:count'], { - \ 'n': ['darkestpurple', 'white'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:SPLIT'], { - \ 'n': ['white', 'darkestpurple'], - \ }), - \ ]) diff --git a/bundle/powerline/autoload/Powerline/Colorschemes/solarized.vim b/bundle/powerline/autoload/Powerline/Colorschemes/solarized.vim deleted file mode 100644 index c4bf42c..0000000 --- a/bundle/powerline/autoload/Powerline/Colorschemes/solarized.vim +++ /dev/null @@ -1,154 +0,0 @@ - -" Solarized color scheme for Powerline -" N = no focus -" 16 hex colors as defined on http://ethanschoonover.com/solarized -call Pl#Hi#Allocate({ - \ 'base03' : [8, 0x002b36], - \ 'base02' : [0, 0x073642], - \ 'base01' : [10, 0x586e75], - \ 'base00' : [11, 0x657b83], - \ 'base0' : [12, 0x839496], - \ 'base1' : [14, 0x93a1a1], - \ 'base2' : [7, 0xeee8d5], - \ 'base3' : [15, 0xfdf6e3], - \ 'yellow' : [3, 0xb58900], - \ 'orange' : [9, 0xcb4b16], - \ 'red' : [1, 0xdc322f], - \ 'magenta' : [5, 0xd33682], - \ 'violet' : [13, 0x6c71c4], - \ 'blue' : [4, 0x268bd2], - \ 'cyan' : [6, 0x2aa198], - \ 'green' : [2, 0x859900], - \ }) - -let g:Powerline#Colorschemes#solarized#colorscheme = Pl#Colorscheme#Init([ - \ Pl#Hi#Segments(['SPLIT'], { - \ 'n': ['base3', 'base2'], - \ 'N': ['base3', 'base2'], - \ 'i': ['base3', 'base2'], - \ }), - \ - \ Pl#Hi#Segments(['mode_indicator'], { - \ 'n': ['base2', 'blue', ['bold']], - \ 'i': ['base3', 'orange', ['bold']], - \ 'v': ['base3', 'magenta', ['bold']], - \ 'r': ['base3', 'violet', ['bold']], - \ 's': ['base3', 'yellow', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['branch'], { - \ 'n': ['base2', 'base02'], - \ 'N': ['base02', 'base1'], - \ 'i': ['base2', 'base00'], - \ }), - \ - \ Pl#Hi#Segments(['scrollpercent', 'raw', 'filesize'], { - \ 'n': ['base2', 'base0'], - \ 'N': ['base00', 'base2'], - \ 'i': ['base2', 'base1'], - \ }), - \ - \ Pl#Hi#Segments(['fileinfo', 'filename'], { - \ 'n': ['base2', 'base01', ['bold']], - \ 'N': ['base01', 'base2' ], - \ 'i': ['base3', 'base1', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['fileinfo.filepath'], { - \ 'n': ['base1'], - \ 'N': ['base1'], - \ 'i': ['base01'], - \ }), - \ - \ Pl#Hi#Segments(['static_str'], { - \ 'n': ['base3', 'green'], - \ 'N': ['base02', 'base01'], - \ 'i': ['base3', 'blue'], - \ }), - \ - \ Pl#Hi#Segments(['fileinfo.flags'], { - \ 'n': ['base3'], - \ 'N': ['base00'], - \ 'i': ['base3'], - \ }), - \ - \ Pl#Hi#Segments(['currenttag', 'fileformat', 'fileencoding', 'pwd', 'filetype', 'rvm:string', 'rvm:statusline', 'virtualenv:statusline', 'charcode', 'currhigroup'], { - \ 'n': ['base00', 'base2'], - \ 'i': ['base0', 'base2'], - \ }), - \ - \ Pl#Hi#Segments(['lineinfo'], { - \ 'n': ['base2', 'base01', ['bold']], - \ 'N': ['base02', 'base0'], - \ 'i': ['base2', 'base00', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['errors'], { - \ 'n': ['red', 'base2', ['bold']], - \ 'i': ['red', 'base2', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['lineinfo.line.tot'], { - \ 'n': ['base3'], - \ 'N': ['base02'], - \ 'i': ['base3'], - \ }), - \ - \ Pl#Hi#Segments(['paste_indicator', 'ws_marker'], { - \ 'n': ['base3', 'red', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['gundo:static_str.name', 'command_t:static_str.name'], { - \ 'n': ['base3', 'red', ['bold']], - \ 'N': ['base02', 'base01', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['gundo:static_str.buffer', 'command_t:raw.line'], { - \ 'n': ['base3', 'base00'], - \ 'N': ['base0', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['gundo:SPLIT', 'command_t:SPLIT'], { - \ 'n': ['base3', 'base02'], - \ 'N': ['base0', 'base03'], - \ }), - \ - \ Pl#Hi#Segments(['lustyexplorer:static_str.name', 'minibufexplorer:static_str.name', 'nerdtree:raw.name', 'tagbar:static_str.name'], { - \ 'n': ['base2', 'green', ['bold']], - \ 'N': ['base02', 'base1'], - \ }), - \ - \ Pl#Hi#Segments(['lustyexplorer:static_str.buffer', 'tagbar:static_str.buffer'], { - \ 'n': ['base3', 'base01'], - \ 'N': ['base02', 'base01'], - \ }), - \ - \ Pl#Hi#Segments(['lustyexplorer:SPLIT', 'minibufexplorer:SPLIT', 'nerdtree:SPLIT', 'tagbar:SPLIT'], { - \ 'n': ['base2', 'base2'], - \ 'N': ['base2', 'base2'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:focus', 'ctrlp:byfname'], { - \ 'n': ['base03', 'base01'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:prev', 'ctrlp:next', 'ctrlp:pwd'], { - \ 'n': ['base3', 'base00'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:item'], { - \ 'n': ['base3', 'violet', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:marked'], { - \ 'n': ['base1', 'base01', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:count'], { - \ 'n': ['base3', 'violet'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:SPLIT'], { - \ 'n': ['base3', 'base03'], - \ }), - \ ]) diff --git a/bundle/powerline/autoload/Powerline/Colorschemes/solarized16.vim b/bundle/powerline/autoload/Powerline/Colorschemes/solarized16.vim deleted file mode 100644 index 44d0687..0000000 --- a/bundle/powerline/autoload/Powerline/Colorschemes/solarized16.vim +++ /dev/null @@ -1,195 +0,0 @@ -" Authors: -" @stephenmckinney -" -" This colorscheme is based on Solarized-dark colors, setting the specific -" values for the Solarized palette, using the terminal's 16 ansi -" color values. It combines Solarized with Powerline native colors. -call Pl#Hi#Allocate({ - \ 'black' : 16, - \ 'white' : 231, - \ - \ 'darkestgreen' : 22, - \ 'darkgreen' : 28, - \ 'mediumgreen' : 70, - \ 'brightgreen' : 148, - \ - \ 'darkestcyan' : 23, - \ 'mediumcyan' : 117, - \ - \ 'darkestblue' : 24, - \ 'darkblue' : 31, - \ - \ 'darkestred' : 52, - \ 'darkred' : 88, - \ 'mediumred' : 124, - \ 'brightred' : 160, - \ 'brightestred' : 196, - \ - \ 'darkestpurple' : 55, - \ 'mediumpurple' : 98, - \ 'brightpurple' : 189, - \ - \ 'brightorange' : 208, - \ 'brightestorange': 214, - \ - \ 'gray0' : 233, - \ 'gray1' : 235, - \ 'gray2' : 236, - \ 'gray3' : 239, - \ 'gray4' : 240, - \ 'gray5' : 241, - \ 'gray6' : 244, - \ 'gray7' : 245, - \ 'gray8' : 247, - \ 'gray9' : 250, - \ 'gray10' : 252, - \ - \ 'base03' : [8, 0x002b36], - \ 'base02' : [0, 0x073642], - \ 'base01' : [10, 0x586e75], - \ 'base00' : [11, 0x657b83], - \ 'base0' : [12, 0x839496], - \ 'base1' : [14, 0x93a1a1], - \ 'base2' : [7, 0xeee8d5], - \ 'base3' : [15, 0xfdf6e3], - \ 'yellow' : [3, 0xb58900], - \ 'orange' : [9, 0xcb4b16], - \ 'red' : [1, 0xdc322f], - \ 'magenta' : [5, 0xd33682], - \ 'violet' : [13, 0x6c71c4], - \ 'blue' : [4, 0x268bd2], - \ 'cyan' : [6, 0x2aa198], - \ 'green' : [2, 0x859900], - \ }) - -let g:Powerline#Colorschemes#solarized16#colorscheme= Pl#Colorscheme#Init([ - \ Pl#Hi#Segments(['SPLIT'], { - \ 'n': ['white', 'base02'], - \ 'N': ['white', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['mode_indicator'], { - \ 'n': ['darkestgreen', 'brightgreen', ['bold']], - \ 'i': ['darkestcyan', 'white', ['bold']], - \ 'v': ['red', 'brightorange', ['bold']], - \ 'r': ['white', 'violet', ['bold']], - \ 's': ['white', 'gray5', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['branch', 'raw', 'filesize'], { - \ 'n': ['base03', 'blue'], - \ 'N': ['base00', 'base03'], - \ }), - \ - \ Pl#Hi#Segments(['fileinfo', 'filename', 'filepath'], { - \ 'n': ['base3', 'darkestblue', ['bold']], - \ 'N': ['base0', 'base02', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['fileinfo.filepath'], { - \ 'n': ['base2'], - \ 'N': ['base00'], - \ }), - \ - \ Pl#Hi#Segments(['static_str'], { - \ 'n': ['base3', 'violet'], - \ 'N': ['base1', 'base02'], - \ 'i': ['white', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['fileinfo.flags'], { - \ 'n': ['base03', ['bold']], - \ 'N': ['gray5'], - \ 'i': ['base03', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['currenttag', 'fullcurrenttag', 'fileformat', 'fileencoding', 'pwd', 'filetype', 'rvm:string', 'rvm:statusline', 'virtualenv:statusline', 'charcode', 'currhigroup'], { - \ 'n': ['base1', 'base02'], - \ 'N': ['base00', 'base03'], - \ }), - \ - \ Pl#Hi#Segments(['scrollpercent'], { - \ 'n': ['base1', 'base02', ['bold']], - \ 'N': ['base00', 'base03'], - \ }), - \ - \ Pl#Hi#Segments(['lineinfo'], { - \ 'n': ['gray2', 'gray10', ['bold']], - \ 'N': ['gray7', 'gray1', ['bold']], - \ 'i': ['darkestcyan', 'mediumcyan', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['errors'], { - \ 'n': ['orange', 'base02', ['bold']], - \ 'N': ['gray5', 'base03', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['lineinfo.line.tot'], { - \ 'n': ['gray6'], - \ 'N': ['gray5'], - \ 'i': ['darkestcyan'], - \ }), - \ - \ Pl#Hi#Segments(['paste_indicator', 'ws_marker'], { - \ 'n': ['base3', 'red', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['gundo:static_str.name', 'command_t:static_str.name'], { - \ 'n': ['base3', 'darkblue', ['bold']], - \ 'N': ['base1', 'base03', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['gundo:static_str.buffer', 'command_t:raw.line'], { - \ 'n': ['white', 'base02'], - \ 'N': ['gray5', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['gundo:SPLIT', 'command_t:SPLIT'], { - \ 'n': ['white', 'base02'], - \ 'N': ['white', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['lustyexplorer:static_str.name', 'minibufexplorer:static_str.name', 'nerdtree:raw.name', 'tagbar:static_str.name'], { - \ 'n': ['base3', 'darkestblue', ['bold']], - \ 'N': ['base01', 'base02', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['lustyexplorer:static_str.buffer', 'tagbar:static_str.buffer'], { - \ 'n': ['base3', 'blue'], - \ 'N': ['gray5', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['lustyexplorer:SPLIT', 'minibufexplorer:SPLIT', 'nerdtree:SPLIT', 'tagbar:SPLIT'], { - \ 'n': ['gray3', 'base02'], - \ 'N': ['gray3', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:focus', 'ctrlp:byfname'], { - \ 'n': ['green', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:prev', 'ctrlp:next'], { - \ 'n': ['green', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:item', 'ctrlp:pwd'], { - \ 'n': ['base2', 'darkestblue', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:marked'], { - \ 'n': ['green', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:count'], { - \ 'n': ['base0', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:SPLIT'], { - \ 'n': ['white', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['status'], { - \ 'n': ['green', 'base02'], - \ 'N': ['gray5', 'base02'], - \ }), -\ ]) diff --git a/bundle/powerline/autoload/Powerline/Colorschemes/solarized256.vim b/bundle/powerline/autoload/Powerline/Colorschemes/solarized256.vim deleted file mode 100644 index ea5cab0..0000000 --- a/bundle/powerline/autoload/Powerline/Colorschemes/solarized256.vim +++ /dev/null @@ -1,195 +0,0 @@ -" Authors: -" @skwp -" -" This colorscheme is based on Solarized-dark colors, combined -" with Powerline native colors -call Pl#Hi#Allocate({ - \ 'black' : 16, - \ 'white' : 231, - \ - \ 'darkestgreen' : 22, - \ 'darkgreen' : 28, - \ 'mediumgreen' : 70, - \ 'brightgreen' : 148, - \ - \ 'darkestcyan' : 23, - \ 'mediumcyan' : 117, - \ - \ 'darkestblue' : 24, - \ 'darkblue' : 31, - \ - \ 'darkestred' : 52, - \ 'darkred' : 88, - \ 'mediumred' : 124, - \ 'brightred' : 160, - \ 'brightestred' : 196, - \ - \ 'darkestpurple' : 55, - \ 'mediumpurple' : 98, - \ 'brightpurple' : 189, - \ - \ 'brightorange' : 208, - \ 'brightestorange': 214, - \ - \ 'gray0' : 233, - \ 'gray1' : 235, - \ 'gray2' : 236, - \ 'gray3' : 239, - \ 'gray4' : 240, - \ 'gray5' : 241, - \ 'gray6' : 244, - \ 'gray7' : 245, - \ 'gray8' : 247, - \ 'gray9' : 250, - \ 'gray10' : 252, - \ - \ 'base03' : [234, 0x002b36], - \ 'base02' : [235, 0x073642], - \ 'base01' : [240, 0x586e75], - \ 'base00' : [241, 0x657b83], - \ 'base0' : [244, 0x839496], - \ 'base1' : [245, 0x93a1a1], - \ 'base2' : [254, 0xeee8d5], - \ 'base3' : [230, 0xfdf6e3], - \ 'yellow' : [136, 0xb58900], - \ 'orange' : [166, 0xcb4b16], - \ 'red' : [160, 0xdc322f], - \ 'magenta' : [125, 0xd33682], - \ 'violet' : [61, 0x6c71c4], - \ 'blue' : [33, 0x268bd2], - \ 'cyan' : [37, 0x2aa198], - \ 'green' : [64, 0x859900], - \ }) - -let g:Powerline#Colorschemes#solarized256#colorscheme = Pl#Colorscheme#Init([ - \ Pl#Hi#Segments(['SPLIT'], { - \ 'n': ['white', 'base02'], - \ 'N': ['white', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['mode_indicator'], { - \ 'n': ['darkestgreen', 'brightgreen', ['bold']], - \ 'i': ['darkestcyan', 'white', ['bold']], - \ 'v': ['red', 'brightorange', ['bold']], - \ 'r': ['white', 'violet', ['bold']], - \ 's': ['white', 'gray5', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['branch', 'raw', 'filesize'], { - \ 'n': ['base03', 'blue'], - \ 'N': ['gray5', 'base03'], - \ }), - \ - \ Pl#Hi#Segments(['scrollpercent'], { - \ 'n': ['gray7', 'gray2'], - \ 'N': ['base2', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['fileinfo', 'filename', 'filepath'], { - \ 'n': ['base2', 'darkestblue', ['bold']], - \ 'N': ['base1', 'base02', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['fileinfo.filepath'], { - \ 'n': ['gray10'], - \ 'N': ['gray5'], - \ 'i': ['mediumcyan'], - \ }), - \ - \ Pl#Hi#Segments(['static_str'], { - \ 'n': ['base3', 'violet'], - \ 'N': ['base1', 'base02'], - \ 'i': ['white', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['fileinfo.flags'], { - \ 'n': ['base03', ['bold']], - \ 'N': ['gray5'], - \ 'i': ['base03', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['currenttag', 'fullcurrenttag', 'fileformat', 'fileencoding', 'pwd', 'filetype', 'rvm:string', 'rvm:statusline', 'virtualenv:statusline', 'charcode', 'currhigroup'], { - \ 'n': ['gray5', 'gray2'], - \ 'i': ['mediumcyan', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['lineinfo'], { - \ 'n': ['gray2', 'gray10', ['bold']], - \ 'N': ['gray7', 'gray1', ['bold']], - \ 'i': ['darkestcyan', 'mediumcyan', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['errors'], { - \ 'n': ['orange', 'base02', ['bold']], - \ 'N': ['gray5', 'base03', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['lineinfo.line.tot'], { - \ 'n': ['gray6'], - \ 'N': ['gray5'], - \ 'i': ['darkestcyan'], - \ }), - \ - \ Pl#Hi#Segments(['paste_indicator', 'ws_marker'], { - \ 'n': ['base3', 'red', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['gundo:static_str.name', 'command_t:static_str.name'], { - \ 'n': ['base3', 'darkblue', ['bold']], - \ 'N': ['base1', 'base03', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['gundo:static_str.buffer', 'command_t:raw.line'], { - \ 'n': ['white', 'base02'], - \ 'N': ['gray5', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['gundo:SPLIT', 'command_t:SPLIT'], { - \ 'n': ['white', 'base02'], - \ 'N': ['white', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['lustyexplorer:static_str.name', 'minibufexplorer:static_str.name', 'nerdtree:raw.name', 'tagbar:static_str.name'], { - \ 'n': ['gray10', 'darkestblue', ['bold']], - \ 'N': ['gray3', 'base02', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['lustyexplorer:static_str.buffer', 'tagbar:static_str.buffer'], { - \ 'n': ['base3', 'blue'], - \ 'N': ['gray5', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['lustyexplorer:SPLIT', 'minibufexplorer:SPLIT', 'nerdtree:SPLIT', 'tagbar:SPLIT'], { - \ 'n': ['gray3', 'base02'], - \ 'N': ['gray3', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:focus', 'ctrlp:byfname'], { - \ 'n': ['green', 'base03'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:prev', 'ctrlp:next', 'ctrlp:pwd'], { - \ 'n': ['green', 'base02'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:item'], { - \ 'n': ['base2', 'darkestblue', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:marked'], { - \ 'n': ['brightgreen', 'base03', ['bold']], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:count'], { - \ 'n': ['base0', 'base03'], - \ }), - \ - \ Pl#Hi#Segments(['ctrlp:SPLIT'], { - \ 'n': ['white', 'base03'], - \ }), - \ - \ Pl#Hi#Segments(['status'], { - \ 'n': ['green', 'base02'], - \ 'N': ['gray5', 'base02'], - \ }), -\ ]) diff --git a/bundle/powerline/autoload/Powerline/Functions.vim b/bundle/powerline/autoload/Powerline/Functions.vim deleted file mode 100644 index 4f327eb..0000000 --- a/bundle/powerline/autoload/Powerline/Functions.vim +++ /dev/null @@ -1,141 +0,0 @@ -" Recalculate the trailing whitespace warning when idle, and after saving -autocmd CursorHold,BufWritePost,InsertLeave * unlet! b:statusline_trailing_space_warning - -function! Powerline#Functions#GetFilepath() " {{{ - " Recalculate the filepath when cwd changes. - let cwd = getcwd() - if exists("b:Powerline_cwd") && cwd != b:Powerline_cwd - unlet! b:Powerline_filepath - endif - let b:Powerline_cwd = cwd - - if exists('b:Powerline_filepath') - return b:Powerline_filepath - endif - - let dirsep = has('win32') && ! &shellslash ? '\' : '/' - let filepath = expand('%:p') - - if empty(filepath) - return '' - endif - - let ret = '' - - if g:Powerline_stl_path_style == 'short' - " Display a short path where the first directory is displayed with its - " full name, and the subsequent directories are shortened to their - " first letter, i.e. "/home/user/foo/foo/bar/baz.vim" becomes - " "~/foo/f/b/baz.vim" - " - " This displays the shortest possible path, relative to ~ or the - " current directory. - let mod = (exists('+acd') && &acd) ? ':~:h' : ':~:.:h' - let fpath = split(fnamemodify(filepath, mod), dirsep) - let fpath_shortparts = map(fpath[1:], 'v:val[0]') - let ret = join(extend([fpath[0]], fpath_shortparts), dirsep) . dirsep - elseif g:Powerline_stl_path_style == 'relative' - " Display a relative path, similar to the %f statusline item - let ret = fnamemodify(filepath, ':~:.:h') . dirsep - elseif g:Powerline_stl_path_style == 'full' - " Display the full path, similar to the %F statusline item - let ret = fnamemodify(filepath, ':h') . dirsep - endif - - if ret == ('.' . dirsep) - let ret = '' - endif - - let b:Powerline_filepath = ret - return ret -endfunction " }}} -function! Powerline#Functions#GetShortPath(threshold) " {{{ - let fullpath = split(expand('%:~'), '[/\\]') - - if len(fullpath) > a:threshold - let fullpath = [fullpath[0], '…'] + fullpath[-a:threshold + 1 :] - endif - - return join(fullpath, '/') -endfunction " }}} -function! Powerline#Functions#GetMode() " {{{ - let mode = mode() - - if mode ==# 'v' - let mode = get(g:, "Powerline_mode_v", "VISUAL") - elseif mode ==# 'V' - let mode = get(g:, "Powerline_mode_V", "V⋅LINE") - elseif mode ==# '' - let mode = get(g:, "Powerline_mode_cv", "V⋅BLOCK") - elseif mode ==# 's' - let mode = get(g:, "Powerline_mode_s", "SELECT") - elseif mode ==# 'S' - let mode = get(g:, "Powerline_mode_S", "S⋅LINE") - elseif mode ==# '' - let mode = get(g:, "Powerline_mode_cs", "S⋅BLOCK") - elseif mode =~# '\vi' - let mode = get(g:, "Powerline_mode_i", "INSERT") - elseif mode =~# '\v(R|Rv)' - let mode = get(g:, "Powerline_mode_R", "REPLACE") - else - " Fallback to normal mode - let mode = get(g:, "Powerline_mode_n", "NORMAL") - endif - - return mode -endfunction " }}} -function! Powerline#Functions#GetFilesize() " {{{ - let bytes = getfsize(expand("%:p")) - - if bytes <= 0 - return '' - endif - - if bytes < 1024 - return bytes . 'B' - else - return (bytes / 1024) . 'kB' - endif -endfunction "}}} -function! Powerline#Functions#GetCharCode() " {{{ - " Get the output of :ascii - redir => ascii - silent! ascii - redir END - - if match(ascii, 'NUL') != -1 - return 'NUL' - endif - - " Zero pad hex values - let nrformat = '0x%02x' - - let encoding = (&fenc == '' ? &enc : &fenc) - - if encoding == 'utf-8' - " Zero pad with 4 zeroes in unicode files - let nrformat = '0x%04x' - endif - - " Get the character and the numeric value from the return value of :ascii - " This matches the two first pieces of the return value, e.g. - " " 70" => char: 'F', nr: '70' - let [str, char, nr; rest] = matchlist(ascii, '\v\<(.{-1,})\>\s*([0-9]+)') - - " Format the numeric value - let nr = printf(nrformat, nr) - - return "'". char ."' ". nr -endfunction "}}} -function! Powerline#Functions#GetWSMarker() " {{{ - " Return '...' if trailing white space is detected - " Return '' otherwise - if ! exists("b:statusline_trailing_space_warning") - if search('\s$', 'nw') != 0 - let b:statusline_trailing_space_warning = ' … ' - else - let b:statusline_trailing_space_warning = '' - endif - endif - return b:statusline_trailing_space_warning -endfunction " }}} diff --git a/bundle/powerline/autoload/Powerline/Functions/ft_man.vim b/bundle/powerline/autoload/Powerline/Functions/ft_man.vim deleted file mode 100644 index 29135e4..0000000 --- a/bundle/powerline/autoload/Powerline/Functions/ft_man.vim +++ /dev/null @@ -1,12 +0,0 @@ -function! Powerline#Functions#ft_man#GetName() " {{{ - let matches = matchlist(getline(1), '\v^([a-zA-Z_\.\-]+)\((\d+)\)') - - if ! len(matches) - return 'n/a' - endif - - let file = tolower(matches[1]) - let num = matches[2] - - return file -endfunction " }}} diff --git a/bundle/powerline/autoload/Powerline/Functions/fugitive.vim b/bundle/powerline/autoload/Powerline/Functions/fugitive.vim deleted file mode 100644 index bb00131..0000000 --- a/bundle/powerline/autoload/Powerline/Functions/fugitive.vim +++ /dev/null @@ -1,7 +0,0 @@ -function! Powerline#Functions#fugitive#GetBranch(symbol) " {{{ - let ret = fugitive#statusline() - - let ret = substitute(ret, '\c\v\[?GIT\(([a-z0-9\-_\./:]+)\)\]?', a:symbol .' \1', 'g') - - return ret -endfunction " }}} diff --git a/bundle/powerline/autoload/Powerline/Functions/hgrev.vim b/bundle/powerline/autoload/Powerline/Functions/hgrev.vim deleted file mode 100644 index 61d94ad..0000000 --- a/bundle/powerline/autoload/Powerline/Functions/hgrev.vim +++ /dev/null @@ -1,17 +0,0 @@ -function! Powerline#Functions#hgrev#Status(symbol) " {{{ - if ! exists('*HGRev') - " HGRev hasn't been loaded yet - return '' - endif - if !exists("b:statusline_hg_status") - silent execute "RefreshMercurialRev" - endif - let b:statusline_hg_status=HGRev() - if b:statusline_hg_status != '-' - let ret = "\u26A1". '' . substitute(b:statusline_hg_status, '^[^ ]*', '\1', 'g') - let ret=substitute(ret,' M$','+','g') - else - let ret='' - endif - return ret -endfunction " }}} diff --git a/bundle/powerline/autoload/Powerline/Functions/syntastic.vim b/bundle/powerline/autoload/Powerline/Functions/syntastic.vim deleted file mode 100644 index 70c8849..0000000 --- a/bundle/powerline/autoload/Powerline/Functions/syntastic.vim +++ /dev/null @@ -1,16 +0,0 @@ -function! Powerline#Functions#syntastic#GetErrors(line_symbol) " {{{ - if ! exists('g:syntastic_stl_format') - " Syntastic hasn't been loaded yet - return '' - endif - - " Temporarily change syntastic output format - let old_stl_format = g:syntastic_stl_format - let g:syntastic_stl_format = '%E{ ERRORS (%e) '. a:line_symbol .' %fe }%W{ WARNINGS (%w) '. a:line_symbol .' %fw }' - - let ret = SyntasticStatuslineFlag() - - let g:syntastic_stl_format = old_stl_format - - return ret -endfunction " }}} diff --git a/bundle/powerline/autoload/Powerline/Matches.vim b/bundle/powerline/autoload/Powerline/Matches.vim deleted file mode 100644 index 033c4be..0000000 --- a/bundle/powerline/autoload/Powerline/Matches.vim +++ /dev/null @@ -1,13 +0,0 @@ -let g:Powerline#Matches#matches = { - \ 'command_t' : Pl#Match#Add('bufname(winbufnr(a:window))', '^GoToFile$'), - \ 'bt_help' : Pl#Match#Add('getwinvar(a:window, "&bt")' , '^help$'), - \ 'ft_man' : Pl#Match#Add('getwinvar(a:window, "&ft")' , '^man$'), - \ 'ft_qf' : Pl#Match#Add('getwinvar(a:window, "&ft")' , '^qf$'), - \ 'ft_vimpager' : Pl#Match#Add('getwinvar(a:window, "&ft")' , 'vimpager'), - \ 'gundo_preview' : Pl#Match#Add('bufname(winbufnr(a:window))', '^__Gundo_Preview__$'), - \ 'gundo_tree' : Pl#Match#Add('bufname(winbufnr(a:window))', '^__Gundo__$'), - \ 'lustyexplorer' : Pl#Match#Add('bufname(winbufnr(a:window))', '\[LustyExplorer\-Buffers\]'), - \ 'minibufexplorer' : Pl#Match#Add('bufname(winbufnr(a:window))', '^\-MiniBufExplorer\-$'), - \ 'tagbar' : Pl#Match#Add('getwinvar(a:window, "&ft")' , '^tagbar$'), - \ 'nerdtree' : Pl#Match#Add('getwinvar(a:window, "&ft")' , '^nerdtree$'), -\ } diff --git a/bundle/powerline/autoload/Powerline/Segments.vim b/bundle/powerline/autoload/Powerline/Segments.vim deleted file mode 100644 index c74c34f..0000000 --- a/bundle/powerline/autoload/Powerline/Segments.vim +++ /dev/null @@ -1,30 +0,0 @@ -let g:Powerline#Segments#segments = Pl#Segment#Init([ - \ Pl#Segment#Create('SPLIT' , '__split__'), - \ Pl#Segment#Create('TRUNCATE', '__truncate__'), - \ - \ Pl#Segment#Create('paste_indicator' , '%{&paste ? "PASTE" : ""}', Pl#Segment#Modes('!N')), - \ Pl#Segment#Create('mode_indicator' , '%{Powerline#Functions#GetMode()}', Pl#Segment#Modes('!N')), - \ Pl#Segment#Create('fileinfo', - \ Pl#Segment#Create('flags.ro' , '%{&readonly ? "$RO" : ""}'), - \ Pl#Segment#Create('filepath' , '%{Powerline#Functions#GetFilepath()}', Pl#Segment#NoPadding()), - \ Pl#Segment#Create('filename' , '%t'), - \ Pl#Segment#Create('flags.mod' , '%M'), - \ Pl#Segment#Create('flags.type' , '%H%W'), - \ ), - \ Pl#Segment#Create('filename' , '%t'), - \ Pl#Segment#Create('filesize' , '%{Powerline#Functions#GetFilesize()}', Pl#Segment#Modes('!N')), - \ Pl#Segment#Create('pwd' , '%{substitute(getcwd(), expand("$HOME"), "~", "g")}'), - \ Pl#Segment#Create('static_str' , '%%{"%s"}'), - \ Pl#Segment#Create('raw' , '%s'), - \ Pl#Segment#Create('fileformat' , '%{&fileformat}', Pl#Segment#Modes('!N')), - \ Pl#Segment#Create('fileencoding' , '%{(&fenc == "" ? &enc : &fenc)}', Pl#Segment#Modes('!N')), - \ Pl#Segment#Create('filetype' , '%{strlen(&ft) ? &ft : "no ft"}', Pl#Segment#Modes('!N')), - \ Pl#Segment#Create('scrollpercent' , '%3p%%'), - \ Pl#Segment#Create('lineinfo', - \ Pl#Segment#Create('line.cur' , '$LINE %3l'), - \ Pl#Segment#Create('line.tot' , ':%-2v', Pl#Segment#NoPadding()), - \ ), - \ Pl#Segment#Create('charcode' , '%{Powerline#Functions#GetCharCode()}', Pl#Segment#Modes('!N')), - \ Pl#Segment#Create('currhigroup' , '%{synIDattr(synID(line("."), col("."), 1), "name")}', Pl#Segment#Modes('!N')), - \ Pl#Segment#Create('ws_marker' , '%{Powerline#Functions#GetWSMarker()}', Pl#Segment#Modes('!N')), -\ ]) diff --git a/bundle/powerline/autoload/Powerline/Segments/ctrlp.vim b/bundle/powerline/autoload/Powerline/Segments/ctrlp.vim deleted file mode 100755 index 41c5ebf..0000000 --- a/bundle/powerline/autoload/Powerline/Segments/ctrlp.vim +++ /dev/null @@ -1,20 +0,0 @@ -if !exists("g:Powerline#Segments#ctrlp#segments#focus ") - let g:Powerline#Segments#ctrlp#segments#focus = '%{"%0"}' -endif -if !exists("g:Powerline#Segments#ctrlp#segments#prev ") - let g:Powerline#Segments#ctrlp#segments#prev = '%-3{"%3"}' -endif -if !exists("g:Powerline#Segments#ctrlp#segments#next ") - let g:Powerline#Segments#ctrlp#segments#next = '%-3{"%5"}' -endif - -let g:Powerline#Segments#ctrlp#segments = Pl#Segment#Init(['ctrlp' - \ , Pl#Segment#Create('focus', g:Powerline#Segments#ctrlp#segments#focus) - \ , Pl#Segment#Create('byfname', '%{"%1"}') - \ , Pl#Segment#Create('prev', g:Powerline#Segments#ctrlp#segments#prev) - \ , Pl#Segment#Create('item', '%-9{"%4"}') - \ , Pl#Segment#Create('next', g:Powerline#Segments#ctrlp#segments#next) - \ , Pl#Segment#Create('marked', '%{"%6" == " <+>" ? "" : strpart("%6", 2, len("%6") - 3)}') - \ - \ , Pl#Segment#Create('count', '%-6{"%0"}') -\ ]) diff --git a/bundle/powerline/autoload/Powerline/Segments/ft_man.vim b/bundle/powerline/autoload/Powerline/Segments/ft_man.vim deleted file mode 100644 index 6ed0cc3..0000000 --- a/bundle/powerline/autoload/Powerline/Segments/ft_man.vim +++ /dev/null @@ -1,3 +0,0 @@ -let g:Powerline#Segments#ft_man#segments = Pl#Segment#Init(['ft_man', - \ Pl#Segment#Create('filename', '%{Powerline#Functions#ft_man#GetName()}') -\ ]) diff --git a/bundle/powerline/autoload/Powerline/Segments/fugitive.vim b/bundle/powerline/autoload/Powerline/Segments/fugitive.vim deleted file mode 100644 index bb46eec..0000000 --- a/bundle/powerline/autoload/Powerline/Segments/fugitive.vim +++ /dev/null @@ -1,5 +0,0 @@ -let g:Powerline#Segments#fugitive#segments = Pl#Segment#Init(['fugitive', - \ (exists('g:loaded_fugitive') && g:loaded_fugitive == 1), - \ - \ Pl#Segment#Create('branch', '%{Powerline#Functions#fugitive#GetBranch("$BRANCH")}') -\ ]) diff --git a/bundle/powerline/autoload/Powerline/Segments/hgrev.vim b/bundle/powerline/autoload/Powerline/Segments/hgrev.vim deleted file mode 100644 index 3e651d1..0000000 --- a/bundle/powerline/autoload/Powerline/Segments/hgrev.vim +++ /dev/null @@ -1,4 +0,0 @@ -let g:Powerline#Segments#hgrev#segments = Pl#Segment#Init(['hgrev', - \ (exists('hgrev_loaded')), - \ Pl#Segment#Create('branch', '%{Powerline#Functions#hgrev#Status("$BRANCH")}') - \ ]) diff --git a/bundle/powerline/autoload/Powerline/Segments/rvm.vim b/bundle/powerline/autoload/Powerline/Segments/rvm.vim deleted file mode 100644 index c840632..0000000 --- a/bundle/powerline/autoload/Powerline/Segments/rvm.vim +++ /dev/null @@ -1,6 +0,0 @@ -let g:Powerline#Segments#rvm#segments = Pl#Segment#Init(['rvm', - \ (exists('g:loaded_rvm') && g:loaded_rvm == 1), - \ - \ Pl#Segment#Create('string', '%{rvm#string()}'), - \ Pl#Segment#Create('statusline', '%{rvm#statusline()}') -\ ]) diff --git a/bundle/powerline/autoload/Powerline/Segments/syntastic.vim b/bundle/powerline/autoload/Powerline/Segments/syntastic.vim deleted file mode 100644 index 5a893d6..0000000 --- a/bundle/powerline/autoload/Powerline/Segments/syntastic.vim +++ /dev/null @@ -1,5 +0,0 @@ -let g:Powerline#Segments#syntastic#segments = Pl#Segment#Init(['syntastic', - \ (exists('g:loaded_syntastic_plugin') && g:loaded_syntastic_plugin == 1), - \ - \ Pl#Segment#Create('errors', '%{Powerline#Functions#syntastic#GetErrors("$LINE")}', Pl#Segment#Modes('!N')) -\ ]) diff --git a/bundle/powerline/autoload/Powerline/Segments/tagbar.vim b/bundle/powerline/autoload/Powerline/Segments/tagbar.vim deleted file mode 100644 index 5db8cd9..0000000 --- a/bundle/powerline/autoload/Powerline/Segments/tagbar.vim +++ /dev/null @@ -1,6 +0,0 @@ -let g:Powerline#Segments#tagbar#segments = Pl#Segment#Init(['tagbar', - \ (exists(':Tagbar') > 0), - \ - \ Pl#Segment#Create('currenttag', '%{tagbar#currenttag("%s", "")}', Pl#Segment#Modes('!N')), - \ Pl#Segment#Create('fullcurrenttag', '%{tagbar#currenttag("%s", "", "f")}', Pl#Segment#Modes('!N')) -\ ]) diff --git a/bundle/powerline/autoload/Powerline/Segments/virtualenv.vim b/bundle/powerline/autoload/Powerline/Segments/virtualenv.vim deleted file mode 100644 index 8c7d6fb..0000000 --- a/bundle/powerline/autoload/Powerline/Segments/virtualenv.vim +++ /dev/null @@ -1,5 +0,0 @@ -let g:Powerline#Segments#virtualenv#segments = Pl#Segment#Init(['virtualenv', - \ has('python') && (exists('g:virtualenv_loaded') && g:virtualenv_loaded == 1), - \ - \ Pl#Segment#Create('statusline', '%{virtualenv#statusline()}') -\ ]) diff --git a/bundle/powerline/autoload/Powerline/Themes/default.vim b/bundle/powerline/autoload/Powerline/Themes/default.vim deleted file mode 100644 index a97d5b9..0000000 --- a/bundle/powerline/autoload/Powerline/Themes/default.vim +++ /dev/null @@ -1,116 +0,0 @@ -let g:Powerline#Themes#default#theme = Pl#Theme#Create( - \ Pl#Theme#Buffer('' - \ , 'paste_indicator' - \ , 'mode_indicator' - \ , 'fugitive:branch' - \ , 'hgrev:branch' - \ , 'fileinfo' - \ , 'syntastic:errors' - \ , Pl#Segment#Truncate() - \ , 'tagbar:currenttag' - \ , Pl#Segment#Split() - \ , 'rvm:string' - \ , 'virtualenv:statusline' - \ , 'fileformat' - \ , 'fileencoding' - \ , 'filetype' - \ , 'scrollpercent' - \ , 'lineinfo' - \ ), - \ - \ Pl#Theme#Buffer('command_t' - \ , ['static_str.name', 'Command-T'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , ['raw.line', '%10(Match #%l%)'] - \ ), - \ - \ Pl#Theme#Buffer('gundo', Pl#Match#Any('gundo_tree') - \ , ['static_str.name', 'Gundo'] - \ , ['static_str.buffer', 'Undo tree'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('gundo', Pl#Match#Any('gundo_preview') - \ , ['static_str.name', 'Gundo'] - \ , ['static_str.buffer', 'Diff preview'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('bt_help' - \ , ['static_str.name', 'Help'] - \ , 'filename' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'scrollpercent' - \ ), - \ - \ Pl#Theme#Buffer('ft_vimpager' - \ , ['static_str.name', 'Pager'] - \ , 'filename' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'scrollpercent' - \ ), - \ - \ Pl#Theme#Buffer('lustyexplorer' - \ , ['static_str.name', 'LustyExplorer'] - \ , ['static_str.buffer', 'Buffer list'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('ft_man' - \ , ['static_str.name', 'Man page'] - \ , 'filename' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'scrollpercent' - \ ), - \ - \ Pl#Theme#Buffer('minibufexplorer' - \ , ['static_str.name', 'MiniBufExplorer'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('ft_qf' - \ , ['static_str.name', 'Quickfix'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('tagbar' - \ , ['static_str.name', 'Tagbar'] - \ , ['static_str.buffer', 'Tree'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('ctrlp', Pl#Theme#Callback('ctrlp_main', 'if ! exists("g:ctrlp_status_func") | let g:ctrlp_status_func = {} | endif | let g:ctrlp_status_func.main = "%s"') - \ , 'ctrlp:prev' - \ , 'ctrlp:item' - \ , 'ctrlp:next' - \ , 'ctrlp:marked' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'ctrlp:focus' - \ , 'ctrlp:byfname' - \ , 'pwd' - \ ), - \ - \ Pl#Theme#Buffer('ctrlp', Pl#Theme#Callback('ctrlp_prog', 'if ! exists("g:ctrlp_status_func") | let g:ctrlp_status_func = {} | endif | let g:ctrlp_status_func.prog = "%s"') - \ , 'ctrlp:count' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'pwd' - \ ), - \ - \ Pl#Theme#Buffer('nerdtree' - \ , ['raw.name', '%{Powerline#Functions#GetShortPath(4)}'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ) -\ ) diff --git a/bundle/powerline/autoload/Powerline/Themes/solarized16.vim b/bundle/powerline/autoload/Powerline/Themes/solarized16.vim deleted file mode 100644 index ee8b91a..0000000 --- a/bundle/powerline/autoload/Powerline/Themes/solarized16.vim +++ /dev/null @@ -1,114 +0,0 @@ -" Authors: -" @stephenmckinney -" -let g:Powerline#Themes#solarized16#theme = Pl#Theme#Create( - \ Pl#Theme#Buffer('' - \ , 'fugitive:branch' - \ , 'fileinfo' - \ , 'flags.mod' - \ , 'syntastic:errors' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'sass:status' - \ , 'rvm:string' - \ , 'filetype' - \ , 'scrollpercent' - \ , 'paste_indicator' - \ ), - \ - \ Pl#Theme#Buffer('command_t' - \ , ['static_str.name', 'Command-T'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , ['raw.line', '%10(Match #%l%)'] - \ ), - \ - \ Pl#Theme#Buffer('gundo', Pl#Match#Any('gundo_tree') - \ , ['static_str.name', 'Gundo'] - \ , ['static_str.buffer', 'Undo tree'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('gundo', Pl#Match#Any('gundo_preview') - \ , ['static_str.name', 'Gundo'] - \ , ['static_str.buffer', 'Diff preview'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('bt_help' - \ , ['static_str.name', 'Help'] - \ , 'filename' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'scrollpercent' - \ ), - \ - \ Pl#Theme#Buffer('ft_vimpager' - \ , ['static_str.name', 'Pager'] - \ , 'filename' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'scrollpercent' - \ ), - \ - \ Pl#Theme#Buffer('lustyexplorer' - \ , ['static_str.name', 'LustyExplorer'] - \ , ['static_str.buffer', 'Buffer list'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('ft_man' - \ , ['static_str.name', 'Man page'] - \ , 'filename' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'scrollpercent' - \ ), - \ - \ Pl#Theme#Buffer('minibufexplorer' - \ , ['static_str.name', 'MiniBufExplorer'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('ft_qf' - \ , ['static_str.name', 'Quickfix'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('tagbar' - \ , ['static_str.name', 'Tagbar'] - \ , ['static_str.buffer', 'Tree'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('ctrlp', Pl#Theme#Callback('ctrlp_main', 'if ! exists("g:ctrlp_status_func") | let g:ctrlp_status_func = {} | endif | let g:ctrlp_status_func.main = "%s"') - \ , 'ctrlp:prev' - \ , 'ctrlp:item' - \ , 'ctrlp:next' - \ , 'ctrlp:marked' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'ctrlp:focus' - \ , 'ctrlp:byfname' - \ , 'pwd' - \ ), - \ - \ Pl#Theme#Buffer('ctrlp', Pl#Theme#Callback('ctrlp_prog', 'if ! exists("g:ctrlp_status_func") | let g:ctrlp_status_func = {} | endif | let g:ctrlp_status_func.prog = "%s"') - \ , 'ctrlp:count' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'pwd' - \ ), - \ - \ Pl#Theme#Buffer('nerdtree' - \ , ['raw.name', '%{Powerline#Functions#GetShortPath(4)}'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ) -\ ) diff --git a/bundle/powerline/autoload/Powerline/Themes/solarized256.vim b/bundle/powerline/autoload/Powerline/Themes/solarized256.vim deleted file mode 100644 index 82c06bf..0000000 --- a/bundle/powerline/autoload/Powerline/Themes/solarized256.vim +++ /dev/null @@ -1,119 +0,0 @@ -" Authors: -" @skwp -" -" Disabled: -" Add the following line into the first theme group to see the highlight -" group -" \ , 'currhigroup' -" -" Line info taken out - I know which line number I'm on from the gutter -"\ , 'lineinfo' -let g:Powerline#Themes#solarized256#theme = Pl#Theme#Create( - \ Pl#Theme#Buffer('' - \ , 'fugitive:branch' - \ , 'fileinfo' - \ , 'flags.mod' - \ , 'syntastic:errors' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'sass:status' - \ , 'rvm:string' - \ , 'paste_indicator' - \ ), - \ - \ Pl#Theme#Buffer('command_t' - \ , ['static_str.name', 'Command-T'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , ['raw.line', '%10(Match #%l%)'] - \ ), - \ - \ Pl#Theme#Buffer('gundo', Pl#Match#Any('gundo_tree') - \ , ['static_str.name', 'Gundo'] - \ , ['static_str.buffer', 'Undo tree'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('gundo', Pl#Match#Any('gundo_preview') - \ , ['static_str.name', 'Gundo'] - \ , ['static_str.buffer', 'Diff preview'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('bt_help' - \ , ['static_str.name', 'Help'] - \ , 'filename' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'scrollpercent' - \ ), - \ - \ Pl#Theme#Buffer('ft_vimpager' - \ , ['static_str.name', 'Pager'] - \ , 'filename' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'scrollpercent' - \ ), - \ - \ Pl#Theme#Buffer('lustyexplorer' - \ , ['static_str.name', 'LustyExplorer'] - \ , ['static_str.buffer', 'Buffer list'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('ft_man' - \ , ['static_str.name', 'Man page'] - \ , 'filename' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'scrollpercent' - \ ), - \ - \ Pl#Theme#Buffer('minibufexplorer' - \ , ['static_str.name', 'MiniBufExplorer'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('ft_qf' - \ , ['static_str.name', 'Quickfix'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('tagbar' - \ , ['static_str.name', 'Tagbar'] - \ , ['static_str.buffer', 'Tree'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ), - \ - \ Pl#Theme#Buffer('ctrlp', Pl#Theme#Callback('ctrlp_main', 'if ! exists("g:ctrlp_status_func") | let g:ctrlp_status_func = {} | endif | let g:ctrlp_status_func.main = "%s"') - \ , 'ctrlp:prev' - \ , 'ctrlp:item' - \ , 'ctrlp:next' - \ , 'ctrlp:marked' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'ctrlp:focus' - \ , 'ctrlp:byfname' - \ , 'pwd' - \ ), - \ - \ Pl#Theme#Buffer('ctrlp', Pl#Theme#Callback('ctrlp_prog', 'if ! exists("g:ctrlp_status_func") | let g:ctrlp_status_func = {} | endif | let g:ctrlp_status_func.prog = "%s"') - \ , 'ctrlp:count' - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ , 'pwd' - \ ), - \ - \ Pl#Theme#Buffer('nerdtree' - \ , ['raw.name', '%{Powerline#Functions#GetShortPath(4)}'] - \ , Pl#Segment#Truncate() - \ , Pl#Segment#Split() - \ ) -\ ) diff --git a/bundle/powerline/doc/Powerline.txt b/bundle/powerline/doc/Powerline.txt deleted file mode 100644 index af1b0cf..0000000 --- a/bundle/powerline/doc/Powerline.txt +++ /dev/null @@ -1,439 +0,0 @@ -*Powerline.txt* For Vim version 7.3. Last change: 2011 Nov 23 - - ______ - _________ \ /__ - \_____ \______ _ _____________ / /'__' ___ ____ - | ___/ _ \ \/ \/ / __ \_ ___\ / | |/ \_/ __ \ - | | | (_) \ _ / ___/| | / /__| | | \ ___/ - '___' \____/ \/ \/ \___ |__' /___ /'__'__| /\___ \ - \/ / / \/ \/ - | / - |/ - ' - -============================================================================== -CONTENTS *Powerline-contents* - - 1. Introduction ....................... |Powerline-introduction| - 2. Usage .............................. |Powerline-usage| - 3. Requirements ....................... |Powerline-requirements| - 3.1 Recommended settings ........... |Powerline-recommended-settings| - 4. Configuration ...................... |Powerline-configuration| - 4.1 Powerline_cache_file ........... |Powerline_cache_file| - 4.1.1 Clearing the cache ....... |:PowerlineClearCache| - 4.1.2 Powerline_cache_dir ...... |Powerline_cache_dir| - 4.2 Powerline_cache_enabled ........ |Powerline_cache_enabled| - 4.3 Powerline_symbols .............. |Powerline_symbols| - 4.3.1 Compatible symbols ....... |Powerline-symbols-compatible| - 4.3.2 Fancy symbols ............ |Powerline-symbols-fancy| - 4.3.3 Overriding symbols ....... |Powerline_symbols_override| - 4.3.4 Overriding dividers ...... |Powerline_dividers_override| - 4.4 Powerline_theme ................ |Powerline_theme| - 4.5 Powerline_colorscheme .......... |Powerline_colorscheme| - 4.6 Powerline_stl_path_style ....... |Powerline_stl_path_style| - 5. Fonts .............................. |Powerline-fonts| - 6. Customization ...................... |Powerline-customization| - 6.1 Basic customization ............ |Powerline-basic-customization| - 6.2 Advanced customization ......... |Powerline-advanced-customization| - 6.2.1 Colorschemes ............. |Powerline-cust-colorschemes| - 6.2.2 Functions ................ |Powerline-cust-functions| - 6.2.3 Segments ................. |Powerline-cust-segments| - 6.2.4 Themes ................... |Powerline-cust-themes| - 7. License ............................ |Powerline-license| - 8. Known issues ....................... |Powerline-known-issues| - 9. Contributing ....................... |Powerline-contributing| - -============================================================================== -1. Introduction *Powerline* *Powerline-introduction* - -Powerline is a utility plugin which allows you to create better-looking, more -functional Vim statuslines. - -============================================================================== -2. Usage *Powerline-usage* - -Powerline is automatically enabled when it's installed, either by unzipping -the provided archive or by adding it as a Pathogen/Vundle bundle. - -Powerline replaces the standard Vim 'statusline' with a custom statusline made -up of Powerline segments. - -Powerline ignores any 'statusline' customizations you have defined in your -|vimrc|. If you remove Powerline, your 'statusline' customizations are -restored. - -============================================================================== -3. Requirements *Powerline-requirements* - -Powerline has been developed and tested in Vim 7.3, but it should run without -any problems in Vim 7.2. The default configuration requires a Unix-like system -to work properly. - -The plugin only works with Vim running in an 88/256-color terminal or Gvim. - -Vi-compatible mode must be disabled. - ------------------------------------------------------------------------------- -3.1 Recommended settings *Powerline-recommended-settings* - -The following configuration options should be set in your |vimrc|: > - - set nocompatible " Disable vi-compatibility - set laststatus=2 " Always show the statusline - set encoding=utf-8 " Necessary to show Unicode glyphs - -Note: If you're using an 88/256-color terminal but still don't see the colored -statusline, you may have to set the following option as well: > - - set t_Co=256 " Explicitly tell Vim that the terminal supports 256 colors - -============================================================================== -4. Configuration *Powerline-configuration* - -Powerline will work fine without any user configuration, but default behavior -can be overridden by setting configuration variables globally in your |vimrc| -file. - ------------------------------------------------------------------------------- -4.1 Powerline_cache_file *Powerline_cache_file* - -By default Powerline caches all the statuslines and colors in a cache file in -the plugin's directory (or the Vim directory, depending on the installation -method used). - -It's recommended that you enable the cache, as this dramatically improves Vim -startup time after the cache file has been generated (the plugin usually loads -within ~100ms without the cache and ~1ms with the cache). - -Note: The default cache filename includes the current theme, colorscheme and -symbol settings in order to tie the cache file to your current configuration, -so the cache file will be regenerated when you change any settings. This may -leave several old cache files in your Vim folder, and these may safely be -deleted. - -Defaults: "|Powerline_cache_dir|/Powerline___.cache" - ------------------------------------------------------------------------------- -4.1.1 Powerline_cache_dir *Powerline_cache_dir* - -This is the directory used for |Powerline_cache_file|. - -Default: Plugin directory: > - - let g:Powerline_cache_dir = simplify(expand(':p:h') .'/..') -< ------------------------------------------------------------------------------- -4.1.2 Clearing the cache *:PowerlineClearCache* - -Powerline provides a command to easily clear the cache after changing your -settings or updating your theme. Simply run the following command to clear -your cache, and restart Vim afterwards: > - - :PowerlineClearCache -< ------------------------------------------------------------------------------- -4.2 Powerline_cache_enabled *Powerline_cache_enabled* - -It's possible to disable statusline caching by setting this option to 0. This -is mostly useful when developing statuslines. - -Example: > - - let g:Powerline_cache_enabled = 0 -< - -Default: 1 - ------------------------------------------------------------------------------- -4.3 Powerline_symbols *Powerline_symbols* - -This option defines which set of symbols and dividers you want to use. There -are currently three available options: "compatible", "unicode" and "fancy". - - TYPE DESCRIPTION ~ - compatible Doesn't use any special characters. - unicode Simulates icons and arrows using similar Unicode glyphs. - fancy Custom icons and arrows. Requires a patched font. - -Example: > - - let g:Powerline_symbols = 'fancy' -< - -Default: "compatible" - -Symbols can be inserted into statuslines by using the following variables -(just insert the variables as text in your segments): - - VARIABLE DESCRIPTION ~ - $BRANCH Inserts a branch symbol - $RO Inserts a read-only symbol - $FT Inserts a filetype symbol - $LINE Inserts a line number symbol - ------------------------------------------------------------------------------- -4.3.1 Compatible symbols *Powerline-symbols-compatible* - -These symbols will work in any configuration, and do not require a special -font to work. This option will replace the fancy icons with plain text, and -the pointy dividers with straight lines. - ------------------------------------------------------------------------------- -4.3.2 Fancy symbols *Powerline-symbols-fancy* - -These symbols require a custom font to work. A font patcher is provided for -adding the required symbols to any outline font and some bitmap fonts, see -|Powerline-fonts| and the provided README file for usage details. - ------------------------------------------------------------------------------- -4.3.3 Overriding symbols *Powerline_symbols_override* - -You can override symbols by adding your symbols to the -g:Powerline_symbols_override dictionary. Example: If you want the branch -symbol to be "∓" (hex code 0x2213) and the line symbol to be "L" you can add -the following to your |vimrc|: > - - let g:Powerline_symbols_override = { - \ 'BRANCH': [0x2213], - \ 'LINE': 'L', - \ } -< ------------------------------------------------------------------------------- -4.3.4 Overriding dividers *Powerline_dividers_override* - -If you for some reason want to override the dividers then you can set -g:Powerline_dividers_override to a list with exactly four elements: - - 1: Hard right-pointing arrow - 2: Soft right-pointing arrow - 3: Hard left-pointing arrow - 4: Soft left-pointing arrow - -Example: > - - let g:Powerline_dividers_override = ['>>', '>', '<<', '<'] -< - ------------------------------------------------------------------------------- -4.3.5 Overriding mode names *Powerline_mode* - -You can change the names used for modes at the far left by setting some -variables in your |vimrc|. For example you can change "N" to "NORMAL" with: > - - let g:Powerline_mode_n = 'NORMAL' -< -The variables are all named beginning with 'g:Powerline_mode_', as follows: - -mode name default note ~ -Normal n ' N ' (surrounded by spaces) -Insert i INSERT -Replace R REPLACE |Replace-mode| -Visual v VISUAL |Visual-mode| -Visual linewise V V⋅LINE -Visual blockwise cv V⋅BLOCK -Select s SELECT |Select-mode| -Select linewise S S⋅LINE -Select blockwise cs S⋅BLOCK - ------------------------------------------------------------------------------ -4.4 Powerline_theme *Powerline_theme* - -This option defines the theme Powerline uses. The available themes are located -in autoload/Powerline/Themes/. A theme is a pre-defined set of Powerline -segments which make up the statusline. - -Example: > - - let g:Powerline_theme = 'solarized256' -< - -Default: "default" - ------------------------------------------------------------------------------- -4.5 Powerline_colorscheme *Powerline_colorscheme* - -This option defines the colorscheme Powerline uses. The available colorschemes -are located in autoload/Powerline/Colorschemes/. - -Example: > - - let g:Powerline_colorscheme = 'solarized256' -< - -Default: "default" - ------------------------------------------------------------------------------- -4.6 Powerline_stl_path_style *Powerline_stl_path_style* - -There are currently four ways to display the current path and file name. The -default is to only display the file name like the %t statusline item. By -setting this configuration value you can choose from the following ways -display the current path and file name: - - VALUE DESCRIPTION ~ - filename Display only the file name using the %t statusline item. - short Display a short path. The home directory is substituted with - "~", the first directory is displayed with its full name, and - subsequent directories are shortened to their first letter. - I.e. "/home/user/foo/bar/baz.vim" becomes "~/f/b/baz.vim" and - "long/relative/path/foo/bar/baz.vim becomes - "long/r/p/f/b/baz.vim". - relative Display a relative path, similar to the %f statusline item. - full Display the full path, similar to the %F statusline item. - -Example: > - - let g:Powerline_stl_path_style = 'full' -< - -Default: "relative" - -============================================================================== -5. Fonts *Powerline-fonts* - -TODO - -============================================================================== -6. Customization *Powerline-customization* - -There are currently two ways of customizing Powerline: Basic customization -using a couple of functions to insert and remove existing segments from the -statusline, and advanced customization using your own autoload files. The -customization features of Powerline allow you to create your own statuslines -without ever touching the original source code. - ------------------------------------------------------------------------------- -6.1 Basic customization *Powerline-basic-customization* - -Powerline provides the following functions to alter the default statusline -look. These functions should be called from your |vimrc| file or another file -which is sourced at Vim startup. - -Note: These functions are currently applied to all statuslines, so if you -insert a segment after a segment which is present in many statuslines (e.g. -the "filename" segment), all the statuslines will have the inserted segment. -This behavior may be changed in a future version of Powerline. - -Note: Remember to clear your cache with |:PowerlineClearCache| after changing -your statusline! - -Example: > - - " Insert the charcode segment after the filetype segment - call Pl#Theme#InsertSegment('charcode', 'after', 'filetype') - - " Replace the scrollpercent segment with the charcode segment - call Pl#Theme#ReplaceSegment('scrollpercent', 'fileinfo') -< - *Pl#Theme#InsertSegment* -Pl#Theme#InsertSegment({newsegment}, {location}, {targetsegment}) - -This function inserts {newsegment} before or after {targetsegment}. The -{location} parameter specifies the location of the new segment, valid values -are "before" and "after". You can see all the available segments in -autoload/Powerline/Segments.vim and the files specified in -|Powerline-cust-segments|. - -Pl#Theme#RemoveSegment({targetsegment}) *Pl#Theme#RemoveSegment* - -This function removes the {targetsegment} segment entirely. - -Pl#Theme#ReplaceSegment({oldsegment}, {newsegment}) *Pl#Theme#ReplaceSegment* - -This function replaces {oldsegment} with {newsegment}. - ------------------------------------------------------------------------------- -6.2 Advanced customization *Powerline-advanced-customization* - -Because Powerline utilizes Vim's autoload functionality, you can easily create -your own segments, themes, functions and colorschemes without touching the -original source code. This is a bit more complex than using the utility -functions, but it allows you to do a lot more with your statusline. - -Your custom autoload files should be stored in your |runtimepath| (usually in -"~/.vim/autoload/Powerline/*"). - -Note: Remember to clear your cache with |:PowerlineClearCache| after changing -your statusline! - -6.2.1 Colorschemes *Powerline-cust-colorschemes* ------------------------------------------------------------------------------- - -Colorschemes should be stored as separate files in -{runtimepath}/autoload/Powerline/Colorschemes/. - -SYNTAX ~ - -TODO - -EXAMPLE ~ - -TODO - -6.2.2 Functions *Powerline-cust-functions* ------------------------------------------------------------------------------- - -Functions should be stored as separate files in -{runtimepath}/autoload/Powerline/Functions/. - -SYNTAX ~ - -TODO - -EXAMPLE ~ - -TODO - -6.2.3 Segments *Powerline-cust-segments* ------------------------------------------------------------------------------- - -Segments should be stored as separate files in -{runtimepath}/autoload/Powerline/Segments/. - -SYNTAX ~ - -TODO - -EXAMPLE ~ - -TODO - -6.2.4 Themes *Powerline-cust-themes* ------------------------------------------------------------------------------- - -Themes should be stored as separate files in -{runtimepath}/autoload/Powerline/Themes/. - -SYNTAX ~ - -TODO - -EXAMPLE ~ - -TODO - -============================================================================== -7. License *Powerline-license* - -Creative Commons Attribution-ShareAlike 3.0 Unported - -http://creativecommons.org/licenses/by-sa/3.0/ - -============================================================================== -8. Known issues *Powerline-known-issues* - -See the issue tracker at -https://github.com/Lokaltog/vim-powerline/issues - -============================================================================== -9. Contributing *Powerline-contributing* - -If you experience any bugs or have feature requests, please open an issue on -GitHub. Fork the source repository on GitHub and send a pull request if you -have any code improvements. - -Author: Kim Silkebækken -Source repository: https://github.com/Lokaltog/vim-powerline - -============================================================================== -vim:tw=78:sw=4:ts=8:ft=help:norl: diff --git a/bundle/powerline/fontpatcher/PowerlineSymbols.sfd b/bundle/powerline/fontpatcher/PowerlineSymbols.sfd deleted file mode 100644 index 34d7d0c..0000000 --- a/bundle/powerline/fontpatcher/PowerlineSymbols.sfd +++ /dev/null @@ -1,319 +0,0 @@ -SplineFontDB: 3.0 -FontName: PowerlineSymbols -FullName: PowerlineSymbols -FamilyName: PowerlineSymbols -Weight: Medium -Copyright: -UComments: "2011-11-21: Created." -Version: 001.000 -ItalicAngle: 0 -UnderlinePosition: -98.6328 -UnderlineWidth: 48.8281 -Ascent: 800 -Descent: 200 -LayerCount: 2 -Layer: 0 0 "Back" 1 -Layer: 1 0 "Fore" 0 -XUID: [1021 211 26716215 11021609] -FSType: 0 -OS2Version: 0 -OS2_WeightWidthSlopeOnly: 0 -OS2_UseTypoMetrics: 1 -CreationTime: 1321867751 -ModificationTime: 1326665029 -OS2TypoAscent: 0 -OS2TypoAOffset: 1 -OS2TypoDescent: 0 -OS2TypoDOffset: 1 -OS2TypoLinegap: 90 -OS2WinAscent: 0 -OS2WinAOffset: 1 -OS2WinDescent: 0 -OS2WinDOffset: 1 -HheadAscent: 0 -HheadAOffset: 1 -HheadDescent: 0 -HheadDOffset: 1 -OS2Vendor: 'PfEd' -MarkAttachClasses: 1 -DEI: 91125 -Encoding: UnicodeFull -Compacted: 1 -UnicodeInterp: none -NameList: Adobe Glyph List -DisplaySize: -24 -AntiAlias: 1 -FitToEm: 1 -WinInfo: 0 31 18 -BeginPrivate: 0 -EndPrivate -BeginChars: 1114112 9 - -StartChar: uni2B80 -Encoding: 11136 11136 0 -Width: 621 -Flags: HMW -LayerCount: 2 -Fore -SplineSet -0 1000 m 1 - 621 379 l 1 - 0 -243 l 1 - 0 1000 l 1 -EndSplineSet -EndChar - -StartChar: uni2B81 -Encoding: 11137 11137 1 -Width: 621 -Flags: HMW -LayerCount: 2 -Fore -SplineSet -10 991 m 0 - 16 997 23 1000 32 1000 c 0 - 41 1000 48 996 54 990 c 2 - 613 400 l 2 - 619 394 621 386 621 378 c 0 - 621 370 618 362 613 357 c 2 - 54 -233 l 2 - 48 -239 41 -242 32 -242 c 0 - 23 -242 16 -240 10 -234 c 0 - 4 -228 0 -221 0 -212 c 0 - 0 -203 3 -196 8 -190 c 2 - 547 379 l 1 - 8 948 l 2 - 3 954 0 961 0 970 c 0 - 0 979 4 985 10 991 c 0 -EndSplineSet -EndChar - -StartChar: uni2B82 -Encoding: 11138 11138 2 -Width: 621 -Flags: HMW -LayerCount: 2 -Fore -SplineSet -621 1000 m 5 - 621 -243 l 5 - 0 379 l 5 - 621 1000 l 5 -EndSplineSet -EndChar - -StartChar: uni2B83 -Encoding: 11139 11139 3 -Width: 621 -Flags: HMW -LayerCount: 2 -Fore -SplineSet -612 991 m 0 - 618 985 621 979 621 970 c 0 - 621 961 619 954 613 948 c 2 - 74 379 l 1 - 613 -190 l 2 - 619 -196 621 -203 621 -212 c 0 - 621 -221 618 -228 612 -234 c 0 - 606 -240 598 -242 589 -242 c 0 - 580 -242 574 -239 568 -233 c 2 - 8 357 l 2 - 3 362 0 370 0 378 c 0 - 0 386 3 394 8 400 c 2 - 568 990 l 2 - 574 996 580 1000 589 1000 c 0 - 598 1000 606 997 612 991 c 0 -EndSplineSet -EndChar - -StartChar: uni2B61 -Encoding: 11105 11105 4 -Width: 555 -VWidth: 0 -Flags: HMW -LayerCount: 2 -Fore -SplineSet -0 800 m 5 - 92 800 l 5 - 92 513 l 5 - 253 513 l 5 - 253 444 l 5 - 0 444 l 5 - 0 800 l 5 -236 312 m 5 - 339 312 l 5 - 468 67 l 5 - 468 312 l 5 - 555 312 l 5 - 555 -44 l 5 - 453 -44 l 5 - 323 200 l 5 - 323 -44 l 5 - 236 -44 l 5 - 236 312 l 5 -EndSplineSet -EndChar - -StartChar: uni2B60 -Encoding: 11104 11104 5 -Width: 676 -Flags: HMW -LayerCount: 2 -Fore -SplineSet -0 197 m 1 - 94 207 419 279 419 384 c 2 - 419 537 l 1 - 278 501 l 1 - 478 794 l 1 - 677 501 l 1 - 536 537 l 1 - 536 384 l 2 - 536 196 208 126 208 21 c 2 - 208 -244 l 1 - 0 -244 l 1 - 0 197 l 1 -0 288 m 1 - 0 405 0 944 0 944 c 1 - 208 944 l 1 - 208 944 208 451 208 334 c 1 - 185 311 12 288 0 288 c 1 -EndSplineSet -EndChar - -StartChar: uni2B62 -Encoding: 11106 11106 6 -Width: 428 -VWidth: 0 -Flags: HMW -LayerCount: 2 -Fore -SplineSet -88 677 m 2 - 429 677 l 1 - 429 589 l 1 - 88 589 l 1 - 88 162 l 1 - 198 162 l 1 - 198 343 l 1 - 374 343 l 1 - 374 427 l 1 - 198 427 l 1 - 198 506 l 1 - 429 506 l 1 - 429 274 l 1 - 416 263 391 255 374 255 c 2 - 286 255 l 1 - 286 162 l 2 - 286 114 246 74 198 74 c 2 - 88 74 l 2 - 40 74 0 114 0 162 c 2 - 0 589 l 2 - 0 637 40 677 88 677 c 2 -EndSplineSet -EndChar - -StartChar: uni2B63 -Encoding: 11107 11107 7 -Width: 428 -VWidth: 0 -Flags: HMW -LayerCount: 2 -Fore -SplineSet -0 677 m 5 - 341 677 l 6 - 389 677 429 637 429 589 c 6 - 429 506 l 6 - 429 458 389 418 341 418 c 6 - 287 418 l 5 - 287 162 l 6 - 287 114 247 74 199 74 c 6 - 89 74 l 6 - 41 74 1 114 1 162 c 6 - 1 274 l 6 - 0 274 l 6 - 0 506 l 5 - 89 506 l 5 - 89 162 l 5 - 199 162 l 5 - 199 506 l 5 - 341 506 l 5 - 341 589 l 5 - 0 589 l 5 - 0 677 l 5 -EndSplineSet -EndChar - -StartChar: uni2B64 -Encoding: 11108 11108 8 -Width: 546 -VWidth: 0 -Flags: HMW -LayerCount: 2 -Fore -SplineSet -273 733 m 4 - 429 733 430 538 430 538 c 5 - 430 420 l 5 - 547 420 l 5 - 547 303 l 5 - 547 303 546 -9 273 -9 c 4 - 0 -9 0 303 0 303 c 5 - 0 420 l 5 - 117 420 l 5 - 117 538 l 5 - 117 538 117 733 273 733 c 4 -273 655 m 4 - 195 655 195 576 195 420 c 5 - 352 420 l 5 - 352 576 351 655 273 655 c 4 -273 342 m 4 - 195 342 195 147 273 147 c 4 - 351 147 351 342 273 342 c 4 -EndSplineSet -EndChar -EndChars -BitmapFont: 10 10 8 2 1 -BDFChar: 0 11136 6 0 4 -2 7 -JAC+4q"X@:^jlCb -BDFChar: 1 11137 6 0 4 -2 7 -J3Y4g#RCta5_&h7 -BDFChar: 2 11138 6 1 5 -2 7 -#T,OGq"T(n(^L*A -BDFChar: 3 11139 6 1 5 -2 7 -#S8+DJ:Km-&-r79 -BDFChar: 4 11105 6 1 4 -1 7 -J:N1>!0GR3O8o7\ -BDFChar: 5 11104 7 0 5 -2 7 -^rYQ3 -BDFChar: 8 11108 5 0 5 0 6 -0M"b4bku\c -EndBitmapFont -BitmapFont: 12 10 10 2 1 -BDFChar: 0 11136 7 0 6 -2 11 -!!%Pbi:-O>r:od>^jlCb -BDFChar: 1 11137 7 0 6 -3 11 -!!%O7+:ne]":,P]5_&h7 -BDFChar: 2 11138 7 0 6 -2 11 -!!!-1*'AWHr-UUH$j6P1 -BDFChar: 3 11139 7 0 6 -2 11 -!!!--&0O5gJ3Y4g#Qt,- -BDFChar: 4 11105 7 0 5 0 8 -J:N1>!$jBP,QIfE -BDFChar: 5 11104 8 0 8 -3 11 -z^];.Ma8juqa8j9]a8jQehuLOm^];.Mz -BDFChar: 6 11106 5 1 6 0 8 -!-j$]R"1Qc?iU0, -BDFChar: 7 11107 5 0 5 0 7 -p]QtGOH>Q3 -BDFChar: 8 11108 7 0 5 0 8 -0M"`*r63C_GQ7^D -EndBitmapFont -EndSplineFont diff --git a/bundle/powerline/fontpatcher/README.rst b/bundle/powerline/fontpatcher/README.rst deleted file mode 100644 index 35b3d5d..0000000 --- a/bundle/powerline/fontpatcher/README.rst +++ /dev/null @@ -1,164 +0,0 @@ -====================== -Powerline font patcher -====================== - -:Author: Kim Silkebækken (kim.silkebaekken+vim@gmail.com) - -Description ------------ - -This font patcher creates dividers and symbols for use with Powerline. The -script requires Python 2 and FontForge compiled with Python bindings. - -Patched fonts are renamed by default (" for Powerline" is added to the font -name) so they don't conflict with existing fonts. Use the ``--no-rename`` -option to disable font renaming. - -Glyph table ------------ - -All the glyphs are stored in the ``U+2B60``-``U+2BFF`` range ("Misc symbols -and arrows"). - -+------------+-------------------+ -| Code point | Description | -+============+===================+ -| ``U+2B60`` | Branch symbol | -+------------+-------------------+ -| ``U+2B61`` | LN (line) symbol | -+------------+-------------------+ -| ``U+2B62`` | FT symbol, part 1 | -+------------+-------------------+ -| ``U+2B63`` | FT symbol, part 2 | -+------------+-------------------+ -| ``U+2B64`` | Padlock (closed) | -+------------+-------------------+ -| ``U+2B80`` | Hard right arrow | -+------------+-------------------+ -| ``U+2B81`` | Soft right arrow | -+------------+-------------------+ -| ``U+2B82`` | Hard left arrow | -+------------+-------------------+ -| ``U+2B83`` | Soft left arrow | -+------------+-------------------+ - -=================== -Font patching guide -=================== - -There's a `GitHub wiki page`_ dedicated to community-contributed patched -fonts. You may download one of the fonts on that page if you don't want to -patch the fonts yourself. - -If you do patch a font that's not included in the wiki (and you have -permission to distribute it), please include it on the wiki page. - -**Note:** The fonts in the wiki may be outdated, and may have different -glyphs than the ones provided in the latest version of Powerline. It's -recommended that you always patch your fonts yourself if you have the -required software. - -.. _`GitHub wiki page`: https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts - -Linux ------ - -1. Install fontforge with Python bindings. For Ubuntu users the required - package is ``python-fontforge``, for Arch Linux users the required - package is ``fontforge``. It should be something similar for other - distros. - -2. Run the font patcher:: - - $ /path/to/fontpatcher MyFontFile.ttf - -3. Copy the font file into ``~/.fonts`` (or another X font directory):: - - $ cp MyFontFile-Powerline.otf ~/.fonts - - **Note:** If the font is a pure bitmap font (e.g. a PCF font) it will be - stored in the BDF format. This is usually not a problem, and you may - convert the font back to the PCF format using ``bdftopcf`` if you want - to. All other fonts will be stored in the OTF format regardless of the - original format. - -4. Update your font cache:: - - $ sudo fc-cache -vf - - **Note:** If you use vim in rxvt-unicode in the client/daemon mode, you - may need to close all running terminals as well for the font to be - updated. - -5. **For gvim users:** Update the GUI font in your ``vimrc`` file:: - - set guifont=MyFont\ for\ Powerline - - **For terminal users:** Update your terminal configuration to use the - patched font. - -6. Update your ``vimrc`` configuration to use the new symbols:: - - let g:Powerline_symbols = 'fancy' - -7. Make sure that the cache file is deleted:: - - $ rm /tmp/Powerline.cache - -8. Start vim and enjoy your new statusline! - -OS X ----- - -1. Check if you have a FontForge version with Python support by running - ``fontforge -version``. You should see something like this:: - - $ fontforge -version - Copyright (c) 2000-2011 by George Williams. - Executable based on sources from 13:48 GMT 22-Feb-2011-D. - Library based on sources from 13:48 GMT 22-Feb-2011. - fontforge 20110222 - libfontforge 20110222 - - Make sure that the executable version number doesn't have ``NoPython`` in - it. If everything looks OK, skip ahead to step 4. - -2. If you have FontForge but with ``NoPython`` in the version number, please - try to update to a later version:: - - $ brew uninstall fontforge - $ brew update - $ brew install --use-gcc fontforge - - **Note:** You may have to use ``--use-clang`` instead of ``--use-gcc`` - when compiling FontForge. - -3. If you don't have FontForge, install it with Homebrew:: - - $ brew update - $ brew install --use-gcc fontforge - -4. Patch your fonts by passing the ``fontpatcher`` script as a parameter to - FontForge:: - - $ fontforge -script /path/to/fontpatcher MyFontFile.ttf - -5. Install the font by double-clicking the font file in Finder and click - "Install this font" from the preview window. - -6. **For gvim users:** Update the GUI font in your ``vimrc`` file:: - - set guifont=MyFont\ for\ Powerline - - **For terminal users:** Update your terminal configuration to use the - patched font. - -7. Update your ``vimrc`` configuration to use the new symbols:: - - let g:Powerline_symbols = 'fancy' - -8. Make sure that the cache file is deleted:: - - $ rm /tmp/Powerline.cache - -9. Start vim and enjoy your new statusline! diff --git a/bundle/powerline/fontpatcher/fontpatcher b/bundle/powerline/fontpatcher/fontpatcher deleted file mode 100755 index 2c54a3f..0000000 --- a/bundle/powerline/fontpatcher/fontpatcher +++ /dev/null @@ -1,240 +0,0 @@ -#!/usr/bin/env python - -"""Font patcher for Powerline. - -Creates dividers and symbols for use with Powerline. Requires FontForge with Python bindings. - -Stores glyphs in the 2b60-2bff Unicode range ("Misc symbols and arrows"). - -[2b60] Branch symbol -[2b61] LN (line) symbol -[2b62] FT symbol 1 -[2b63] FT symbol 2 -[2b64] Padlock (closed) symbol -[2b80] Hard right arrow -[2b81] Soft right arrow -[2b82] Hard left arrow -[2b83] Soft left arrow -""" - -from __future__ import division - -import argparse -import os -import sys -import re - -try: - import fontforge - import psMat -except ImportError: - sys.stderr.write('The required FontForge modules could not be loaded.\n\n') - - if sys.version_info.major > 2: - sys.stderr.write('FontForge only supports Python 2. Please run this script with the Python 2 executable - e.g. "python2 {0}"\n'.format(sys.argv[0])) - else: - sys.stderr.write('You need FontForge with Python bindings for this script to work.\n') - - sys.exit(1) - -# Handle command-line arguments -parser = argparse.ArgumentParser(description='Font patcher for Powerline. Creates dividers and symbols in FontForge-compatible font files. Requires FontForge with Python bindings. Stores glyphs in the U+2B80-U+2BFF range ("Miscellaneous symbols and arrows"). Stores the patched font as a new, renamed font file by default.') - -parser.add_argument('fonts', help='font file to patch', metavar='font', nargs='+') -parser.add_argument('--no-rename', help='don\'t add " for Powerline" to the font name', default=True, action='http://github.com/store_false', dest='rename') -parser.add_argument('--symbol-font', help='font file with symbols', metavar='font', dest='symbol_font', default='{0}/PowerlineSymbols.sfd'.format(sys.path[0])) -parser.add_argument('--fix-mono', help='fixes some mono-fonts which have glyphs of 0 widths', default=False, action='http://github.com/store_true', dest='fixmono') -parser.add_argument('--fix-win', help='modifies font names such that Windows correctly recognizes font families', default=False, action='http://github.com/store_true', dest='fixwin') - -args = parser.parse_args() - -SYM_ATTR = { - # Right/left-aligned glyphs will have their advance width reduced in order to overlap the next glyph slightly - 0x2b60: { 'align': 'c', 'stretch': 'y' , 'overlap': False }, - 0x2b61: { 'align': 'c', 'stretch': '' , 'overlap': False }, - 0x2b62: { 'align': 'r', 'stretch': '' , 'overlap': False }, - 0x2b63: { 'align': 'l', 'stretch': '' , 'overlap': False }, - 0x2b64: { 'align': 'c', 'stretch': '' , 'overlap': False }, - 0x2b80: { 'align': 'l', 'stretch': 'xy', 'overlap': True }, - 0x2b81: { 'align': 'l', 'stretch': 'xy', 'overlap': True }, - 0x2b82: { 'align': 'r', 'stretch': 'xy', 'overlap': True }, - 0x2b83: { 'align': 'r', 'stretch': 'xy', 'overlap': True }, -} - -# Open symbol font -try: - symbols = fontforge.open(args.symbol_font) -except EnvironmentError: - sys.exit(1) - -# Patch provided fonts -for font_path in args.fonts: - try: - font = fontforge.open(font_path) - except EnvironmentError: - sys.exit(1) - - # Rename font - if args.rename: - font.familyname += ' for Powerline' - font.fullname += ' for Powerline' - font.fontname += 'ForPowerline' - font.appendSFNTName('English (US)', 'Preferred Family', font.familyname) - font.appendSFNTName('English (US)', 'Compatible Full', font.fullname) - if args.fixwin: - font.fontname = re.sub(r'\W', '', font.familyname) - - # Force the em size to be equal - symbols.em = font.em - - # Initial font dimensions - font_dim = { - 'xmin' : 0, - 'ymin' : -font.descent, - 'xmax' : 0, - 'ymax' : font.ascent, - - 'width' : 0, - 'height': 0, - } - - # Find the biggest char width and height - # - # 0x00-0x17f is the Latin Extended-A range - # 0x2500-0x2600 is the box drawing range - for glyph in range(0x00, 0x17f) + range(0x2500, 0x2600): - try: - (xmin, ymin, xmax, ymax) = font[glyph].boundingBox() - except TypeError: - continue - - if font_dim['width'] == 0: - font_dim['width'] = font[glyph].width - - if ymin < font_dim['ymin']: font_dim['ymin'] = ymin - if ymax > font_dim['ymax']: font_dim['ymax'] = ymax - if xmax > font_dim['xmax']: font_dim['xmax'] = xmax - - # Calculate font height - font_dim['height'] = abs(font_dim['ymin']) + font_dim['ymax'] - - # Update the font encoding to ensure that the Unicode glyphs are available - font.encoding = 'ISO10646' - - # Fetch this property before adding outlines - onlybitmaps = font.onlybitmaps - - def get_dim(glyph): - bbox = glyph.boundingBox() - - return { - 'xmin' : bbox[0], - 'ymin' : bbox[1], - 'xmax' : bbox[2], - 'ymax' : bbox[3], - - 'width' : bbox[2] + (-bbox[0]), - 'height': bbox[3] + (-bbox[1]), - } - - # Create glyphs from symbol font - for sym_glyph in symbols.glyphs(): - sym_attr = SYM_ATTR[sym_glyph.unicode] - - # Prepare symbol glyph dimensions - sym_dim = get_dim(sym_glyph) - - # Select and copy symbol from its encoding point - symbols.selection.select(sym_glyph.encoding) - symbols.copy() - - # Select and paste symbol to its unicode code point - font.selection.select(sym_glyph.unicode) - font.paste() - - # Now that we have copy/pasted the glyph, it's time to scale and move it - - # Handle glyph stretching - if 'x' in sym_attr['stretch']: - # Stretch the glyph horizontally - scale_ratio = font_dim['width'] / sym_dim['width'] - - font.transform(psMat.scale(scale_ratio, 1)) - if 'y' in sym_attr['stretch']: - # Stretch the glyph vertically - scale_ratio = font_dim['height'] / sym_dim['height'] - - font.transform(psMat.scale(1, scale_ratio)) - - # Use the dimensions from the pasted and stretched glyph - sym_dim = get_dim(font[sym_glyph.unicode]) - - # Center-align the glyph vertically - font_ycenter = font_dim['height'] / 2 - sym_ycenter = sym_dim['height'] / 2 - - # First move it to the ymax (top) - font.transform(psMat.translate(0, font_dim['ymax'] - sym_dim['ymax'])) - - # Then move it the y center difference - font.transform(psMat.translate(0, sym_ycenter - font_ycenter)) - - # Ensure that the glyph doesn't extend outside the font's bounding box - if sym_dim['width'] > font_dim['width']: - # The glyph is too wide, scale it down to fit - scale_matrix = psMat.scale(font_dim['width'] / sym_dim['width'], 1) - - font.transform(scale_matrix) - - # Use the dimensions from the stretched glyph - sym_dim = get_dim(font[sym_glyph.unicode]) - - # Handle glyph alignment - if sym_attr['align'] == 'c': - # Center align - align_matrix = psMat.translate(font_dim['width'] / 2 - sym_dim['width'] / 2 , 0) - elif sym_attr['align'] == 'r': - # Right align - align_matrix = psMat.translate(font_dim['width'] - sym_dim['width'], 0) - else: - # No alignment (left alignment) - align_matrix = psMat.translate(0, 0) - - font.transform(align_matrix) - - if sym_attr['overlap'] is True: - overlap_width = font.em / 48 - - # Stretch the glyph slightly horizontally if it should overlap - font.transform(psMat.scale((sym_dim['width'] + overlap_width) / sym_dim['width'], 1)) - - if sym_attr['align'] == 'l': - # The glyph should be left-aligned, so it must be moved overlap_width to the left - # This only applies to left-aligned glyphs because the glyph is scaled to the right - font.transform(psMat.translate(-overlap_width, 0)) - - # Ensure the font is considered monospaced on Windows - font[sym_glyph.unicode].width = font_dim['width'] - - if font.bitmapSizes and not onlybitmaps: - # If this is an outline font with bitmaps, regenerate bitmaps for the changed glyphs - font.selection.changed() - - for size in font.bitmapSizes: - font.regenBitmaps((size, )) - - output_name, extension = os.path.split(font_path)[1].rsplit('.', 1) - if extension.lower() not in ['ttf', 'otf']: - # Default to OpenType if input is not TrueType/OpenType - extension = 'otf' - if args.fixmono: - for glyph in font.glyphs(): - if glyph.width == 0: glyph.width = font_dim['width'] - - if onlybitmaps: - # Generate BDF font - font.generate('{0}-Powerline.bdf'.format(output_name, bitmap_type='bdf')) - else: - # Generate OTF/TTF font - font.generate('{0}-Powerline.{1}'.format(output_name, extension)) - diff --git a/bundle/powerline/plugin/Powerline.vim b/bundle/powerline/plugin/Powerline.vim deleted file mode 100644 index e715677..0000000 --- a/bundle/powerline/plugin/Powerline.vim +++ /dev/null @@ -1,78 +0,0 @@ -" Powerline - The ultimate statusline utility -" -" Author: Kim Silkebækken -" Source repository: https://github.com/Lokaltog/vim-powerline - -" Script initialization {{{ - if exists('g:Powerline_loaded') || &compatible || version < 702 - finish - endif - - let g:Powerline_loaded = 1 -" }}} -" Commands {{{ - command! PowerlineClearCache call Pl#ClearCache() - command! PowerlineReloadColorscheme call Pl#ReloadColorscheme() -" }}} -" Set default options {{{ - for [s:key, s:value] in items({ - \ 'theme' : 'default' - \ , 'colorscheme' : 'default' - \ , 'symbols' : 'compatible' - \ , 'symbols_override' : {} - \ , 'dividers_override': [] - \ , 'stl_path_style' : 'relative' - \ , 'cache_enabled' : 1 - \ }) - - if ! exists('g:Powerline_' . s:key) - exec printf('let g:Powerline_%s = %s', s:key, string(s:value)) - endif - - unlet! s:key s:value - endfor - - if ! exists('g:Powerline_cache_dir') - let g:Powerline_cache_dir = simplify(expand(':p:h') .'/..') - endif - - if ! exists('g:Powerline_cache_file') - exec 'let g:Powerline_cache_file = '. string(printf('%s/Powerline_%s_%s_%s.cache' - \ , g:Powerline_cache_dir - \ , g:Powerline_theme - \ , g:Powerline_colorscheme - \ , g:Powerline_symbols - \ )) - endif -" }}} -" Autocommands {{{ - function! s:Startup() - augroup PowerlineMain - autocmd! - - " Reload statuslines when changing color scheme - autocmd ColorScheme * - \ call Pl#Load() - - autocmd BufEnter,WinEnter,FileType,BufUnload,CmdWinEnter * - \ call Pl#UpdateStatusline(1) - - autocmd BufLeave,WinLeave,CmdWinLeave * - \ call Pl#UpdateStatusline(0) - - autocmd BufWritePost */autoload/Powerline/Colorschemes/*.vim - \ :PowerlineReloadColorscheme - augroup END - - let curwindow = winnr() - for window in range(1, winnr('$')) - call Pl#UpdateStatusline(window == curwindow, window) - endfor - endfunction - - augroup PowerlineStartup - autocmd! - - autocmd VimEnter * call s:Startup() - augroup END -" }}} diff --git a/bundle/rust/ftdetect/rust.vim b/bundle/rust/ftdetect/rust.vim deleted file mode 100755 index 10b6162..0000000 --- a/bundle/rust/ftdetect/rust.vim +++ /dev/null @@ -1 +0,0 @@ -au BufRead,BufNewFile *.rs,*.rc set filetype=rust diff --git a/bundle/rust/ftplugin/rust.vim b/bundle/rust/ftplugin/rust.vim deleted file mode 100755 index bf02d7b..0000000 --- a/bundle/rust/ftplugin/rust.vim +++ /dev/null @@ -1,43 +0,0 @@ -" Vim syntax file -" Language: Rust -" Maintainer: Chris Morgan -" Last Change: 2013 Jul 10 - -if exists("b:did_ftplugin") - finish -endif -let b:did_ftplugin = 1 - -" The rust source code at present seems to typically omit a leader on /*! -" comments, so we'll use that as our default, but make it easy to switch. -" This does not affect indentation at all (I tested it with and without -" leader), merely whether a leader is inserted by default or not. -if exists("g:rust_bang_comment_leader") && g:rust_bang_comment_leader == 1 - " Why is the `,s0:/*,mb:\ ,ex:*/` there, you ask? I don't understand why, - " but without it, */ gets indented one space even if there were no - " leaders. I'm fairly sure that's a Vim bug. - setlocal comments=s1:/*,mb:*,ex:*/,s0:/*,mb:\ ,ex:*/,:///,://!,:// -else - setlocal comments=s0:/*!,m:\ ,ex:*/,s1:/*,mb:*,ex:*/,:///,://!,:// -endif -setlocal commentstring=//%s -setlocal formatoptions-=t formatoptions+=croqnlj - -" This includeexpr isn't perfect, but it's a good start -setlocal includeexpr=substitute(v:fname,'::','/','g') - -" NOT adding .rc as it's being phased out (0.7) -setlocal suffixesadd=.rs - -if exists("g:ftplugin_rust_source_path") - let &l:path=g:ftplugin_rust_source_path . ',' . &l:path -endif - -if exists("g:loaded_delimitMate") - if exists("b:delimitMate_excluded_regions") - let b:rust_original_delimitMate_excluded_regions = b:delimitMate_excluded_regions - endif - let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate' -endif - -let b:undo_ftplugin = "setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd< | if exists('b:rust_original_delimitMate_excluded_regions') | let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions | unlet b:rust_original_delimitMate_excluded_regions | elseif exists('b:delimitMate_excluded_regions') | unlet b:delimitMate_excluded_regions | endif" diff --git a/bundle/rust/syntax/rust.vim b/bundle/rust/syntax/rust.vim deleted file mode 100755 index 260b23c..0000000 --- a/bundle/rust/syntax/rust.vim +++ /dev/null @@ -1,200 +0,0 @@ -" Vim syntax file -" Language: Rust -" Maintainer: Patrick Walton -" Maintainer: Ben Blum -" Maintainer: Chris Morgan -" Last Change: 2013 Aug 1 - -if version < 600 - syntax clear -elseif exists("b:current_syntax") - finish -endif - -syn keyword rustConditional match if else -syn keyword rustOperator as - -syn match rustAssert "\(); - -" This is merely a convention; note also the use of [A-Z], restricting it to -" latin identifiers rather than the full Unicode uppercase. I have not used -" [:upper:] as it depends upon 'noignorecase' -"syn match rustCapsIdent display "[A-Z]\w\(\w\)*" - -syn match rustOperator display "\%(+\|-\|/\|*\|=\|\^\|&\||\|!\|>\|<\|%\)=\?" -" This one isn't *quite* right, as we could have binary-& with a reference -syn match rustSigil display /&\s\+[&~@*][^)= \t\r\n]/he=e-1,me=e-1 -syn match rustSigil display /[&~@*][^)= \t\r\n]/he=e-1,me=e-1 -" This isn't actually correct; a closure with no arguments can be `|| { }`. -" Last, because the & in && isn't a sigil -syn match rustOperator display "&&\|||" - -syn match rustMacro '\w\(\w\)*!' contains=rustAssert,rustFail -syn match rustMacro '#\w\(\w\)*' contains=rustAssert,rustFail - -syn match rustFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn?]\|\[\^\=.[^]]*\]\)" contained -syn match rustFormat display "%%" contained -syn match rustSpecial display contained /\\\([nrt\\'"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)/ -syn region rustString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=rustTodo,rustFormat,rustSpecial - -syn region rustAttribute start="#\[" end="\]" contains=rustString,rustDeriving -syn region rustDeriving start="deriving(" end=")" contained contains=rustTrait - -" Number literals -syn match rustNumber display "\<[0-9][0-9_]*\>" -syn match rustNumber display "\<[0-9][0-9_]*\(u\|u8\|u16\|u32\|u64\)\>" -syn match rustNumber display "\<[0-9][0-9_]*\(i\|i8\|i16\|i32\|i64\)\>" - -syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\>" -syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\(u\|u8\|u16\|u32\|u64\)\>" -syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\(i8\|i16\|i32\|i64\)\>" -syn match rustBinNumber display "\<0b[01_]\+\>" -syn match rustBinNumber display "\<0b[01_]\+\(u\|u8\|u16\|u32\|u64\)\>" -syn match rustBinNumber display "\<0b[01_]\+\(i8\|i16\|i32\|i64\)\>" - -syn match rustFloat display "\<[0-9][0-9_]*\(f\|f32\|f64\)\>" -syn match rustFloat display "\<[0-9][0-9_]*\([eE][+-]\=[0-9_]\+\)\>" -syn match rustFloat display "\<[0-9][0-9_]*\([eE][+-]\=[0-9_]\+\)\(f\|f32\|f64\)\>" -syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\>" -syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\(f\|f32\|f64\)\>" -syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9_]\+\)\>" -syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9_]\+\)\(f\|f32\|f64\)\>" - -" For the benefit of delimitMate -syn region rustLifetimeCandidate display start=/&'\%(\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'\)\@!/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime -syn region rustGenericRegion display start=/<\%('\|[^[cntrl:][:space:][:punct:]]\)\@=')\S\@=/ end=/>/ contains=rustGenericLifetimeCandidate -syn region rustGenericLifetimeCandidate display start=/\%(<\|,\s*\)\@<='/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime - -"rustLifetime must appear before rustCharacter, or chars will get the lifetime highlighting -syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" -syn match rustCharacter /'\([^'\\]\|\\\([nrt\\'"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'/ contains=rustSpecial - -syn region rustCommentML start="/\*" end="\*/" contains=rustTodo -syn region rustComment start="//" skip="\\$" end="$" contains=rustTodo keepend -syn region rustCommentMLDoc start="/\*\%(!\|\*/\@!\)" end="\*/" contains=rustTodo -syn region rustCommentDoc start="//[/!]" skip="\\$" end="$" contains=rustTodo keepend - -syn keyword rustTodo contained TODO FIXME XXX NB NOTE - -" Trivial folding rules to begin with. -" TODO: use the AST to make really good folding -syn region rustFoldBraces start="{" end="}" transparent fold -" If you wish to enable this, setlocal foldmethod=syntax -" It's not enabled by default as it would drive some people mad. - -hi def link rustHexNumber rustNumber -hi def link rustBinNumber rustNumber -hi def link rustIdentifierPrime rustIdentifier -hi def link rustTrait rustType - -hi def link rustSigil StorageClass -hi def link rustFormat Special -hi def link rustSpecial Special -hi def link rustString String -hi def link rustCharacter Character -hi def link rustNumber Number -hi def link rustBoolean Boolean -hi def link rustConstant Constant -hi def link rustSelf Constant -hi def link rustFloat Float -hi def link rustOperator Operator -hi def link rustKeyword Keyword -hi def link rustConditional Conditional -hi def link rustIdentifier Identifier -hi def link rustCapsIdent rustIdentifier -hi def link rustModPath Include -hi def link rustModPathSep Delimiter -hi def link rustFuncName Function -hi def link rustFuncCall Function -hi def link rustCommentMLDoc rustCommentDoc -hi def link rustCommentDoc SpecialComment -hi def link rustCommentML rustComment -hi def link rustComment Comment -hi def link rustAssert PreCondit -hi def link rustFail PreCondit -hi def link rustMacro Macro -hi def link rustType Type -hi def link rustTodo Todo -hi def link rustAttribute PreProc -hi def link rustDeriving PreProc -hi def link rustStorage StorageClass -hi def link rustLifetime Special - -" Other Suggestions: -" hi rustAttribute ctermfg=cyan -" hi rustDeriving ctermfg=cyan -" hi rustAssert ctermfg=yellow -" hi rustFail ctermfg=red -" hi rustMacro ctermfg=magenta - -syn sync minlines=200 -syn sync maxlines=500 - -let b:current_syntax = "rust" diff --git a/bundle/tagbar/plugin/tagbar.vmb b/bundle/tagbar/plugin/tagbar.vmb deleted file mode 100644 index 1e0e750..0000000 --- a/bundle/tagbar/plugin/tagbar.vmb +++ /dev/null @@ -1,5704 +0,0 @@ -" Vimball Archiver by Charles E. Campbell, Jr., Ph.D. -UseVimball -finish -README.md [[[1 -19 -# Overview - -Tagbar is a vim plugin for browsing the tags of source code files. -It provides a sidebar that displays the ctags-generated tags of the current file, ordered by their scope. This means that for example methods in C++ are displayed under the class they are defined in. - -Check out the homepage at http://majutsushi.github.io/tagbar/ for more information. - -# Support for additional filetypes - -For filetypes that are not supported by Exuberant Ctags check out [the wiki](https://github.com/majutsushi/tagbar/wiki) to see whether other projects offer support for them and how to use them. Please add any other projects/configurations that you find or create yourself so that others can benefit from them, too. - -# Important: If the file structure is displayed wrong - -If you notice that there are some errors in the way your file's structure is displayed in Tagbar, please make sure that the bug is actually in Tagbar before you report a bug. Since Tagbar uses [exuberant-ctags](http://ctags.sourceforge.net/) and compatible programs to do the actual file parsing, it is likely that the bug is actually in one of those programs instead. - -There is an example in `:h tagbar-issues` about how to run ctags manually so you can determine where the bug actually is. If the bug is actually in ctags, please report it on their website instead, as there is nothing I can do about it in Tagbar. Thank you! - -You can also have a look at ctags bugs that have previously been filed on Tagbar here: -https://github.com/majutsushi/tagbar/issues?labels=ctags-bug&page=1&state=closed -autoload/tagbar.vim [[[1 -4052 -" ============================================================================ -" File: tagbar.vim -" Description: List the current file's tags in a sidebar, ordered by class etc -" Author: Jan Larres -" Licence: Vim licence -" Website: http://majutsushi.github.com/tagbar/ -" Version: 2.6.1 -" Note: This plugin was heavily inspired by the 'Taglist' plugin by -" Yegappan Lakshmanan and uses a small amount of code from it. -" -" Original taglist copyright notice: -" Permission is hereby granted to use and distribute this code, -" with or without modifications, provided that this copyright -" notice is copied with it. Like anything else that's free, -" taglist.vim is provided *as is* and comes with no warranty of -" any kind, either expressed or implied. In no event will the -" copyright holder be liable for any damamges resulting from the -" use of this software. -" ============================================================================ - -scriptencoding utf-8 - -" Initialization {{{1 - -" If another plugin calls an autoloaded Tagbar function on startup before the -" plugin/tagbar.vim file got loaded, load it explicitly -if exists(':Tagbar') == 0 - runtime plugin/tagbar.vim -endif - -" Basic init {{{2 - -redir => s:ftype_out -silent filetype -redir END -if s:ftype_out !~# 'detection:ON' - echomsg 'Tagbar: Filetype detection is turned off, skipping plugin' - unlet s:ftype_out - finish -endif -unlet s:ftype_out - -let s:icon_closed = g:tagbar_iconchars[0] -let s:icon_open = g:tagbar_iconchars[1] - -let s:type_init_done = 0 -let s:autocommands_done = 0 -let s:statusline_in_use = 0 - -" 0: not checked yet; 1: checked and found; 2: checked and not found -let s:checked_ctags = 0 -let s:checked_ctags_types = 0 -let s:ctags_types = {} - -let s:new_window = 1 -let s:is_maximized = 0 -let s:winrestcmd = '' -let s:short_help = 1 -let s:nearby_disabled = 0 -let s:paused = 0 -let s:pwin_by_tagbar = 0 - -let s:window_expanded = 0 -let s:expand_bufnr = -1 -let s:window_pos = { - \ 'pre' : { 'x' : 0, 'y' : 0 }, - \ 'post' : { 'x' : 0, 'y' : 0 } -\} - -" Script-local variable needed since compare functions can't -" take extra arguments -let s:compare_typeinfo = {} - -let s:visibility_symbols = { - \ 'public' : '+', - \ 'protected' : '#', - \ 'private' : '-' -\ } - -let g:loaded_tagbar = 1 - -let s:last_highlight_tline = 0 -let s:debug = 0 -let s:debug_file = '' - -" s:Init() {{{2 -function! s:Init(silent) abort - if s:checked_ctags == 2 && a:silent - return 0 - elseif s:checked_ctags != 1 - if !s:CheckForExCtags(a:silent) - return 0 - endif - endif - - if !s:checked_ctags_types - call s:GetSupportedFiletypes() - endif - - if !s:type_init_done - call s:InitTypes() - endif - - if !s:autocommands_done - call s:CreateAutocommands() - call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 0) - endif - - return 1 -endfunction - -" s:InitTypes() {{{2 -function! s:InitTypes() abort - call s:LogDebugMessage('Initializing types') - - let s:known_types = {} - - " Ant {{{3 - let type_ant = s:TypeInfo.New() - let type_ant.ctagstype = 'ant' - let type_ant.kinds = [ - \ {'short' : 'p', 'long' : 'projects', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'targets', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.ant = type_ant - " Asm {{{3 - let type_asm = s:TypeInfo.New() - let type_asm.ctagstype = 'asm' - let type_asm.kinds = [ - \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'd', 'long' : 'defines', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.asm = type_asm - " ASP {{{3 - let type_aspvbs = s:TypeInfo.New() - let type_aspvbs.ctagstype = 'asp' - let type_aspvbs.kinds = [ - \ {'short' : 'd', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.aspvbs = type_aspvbs - " Awk {{{3 - let type_awk = s:TypeInfo.New() - let type_awk.ctagstype = 'awk' - let type_awk.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.awk = type_awk - " Basic {{{3 - let type_basic = s:TypeInfo.New() - let type_basic.ctagstype = 'basic' - let type_basic.kinds = [ - \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'g', 'long' : 'enumerations', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.basic = type_basic - " BETA {{{3 - let type_beta = s:TypeInfo.New() - let type_beta.ctagstype = 'beta' - let type_beta.kinds = [ - \ {'short' : 'f', 'long' : 'fragments', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'slots', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'patterns', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.beta = type_beta - " C {{{3 - let type_c = s:TypeInfo.New() - let type_c.ctagstype = 'c' - let type_c.kinds = [ - \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, - \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, - \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let type_c.sro = '::' - let type_c.kind2scope = { - \ 'g' : 'enum', - \ 's' : 'struct', - \ 'u' : 'union' - \ } - let type_c.scope2kind = { - \ 'enum' : 'g', - \ 'struct' : 's', - \ 'union' : 'u' - \ } - let s:known_types.c = type_c - " C++ {{{3 - let type_cpp = s:TypeInfo.New() - let type_cpp.ctagstype = 'c++' - let type_cpp.kinds = [ - \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'p', 'long' : 'prototypes', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, - \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'u', 'long' : 'unions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} - \ ] - let type_cpp.sro = '::' - let type_cpp.kind2scope = { - \ 'g' : 'enum', - \ 'n' : 'namespace', - \ 'c' : 'class', - \ 's' : 'struct', - \ 'u' : 'union' - \ } - let type_cpp.scope2kind = { - \ 'enum' : 'g', - \ 'namespace' : 'n', - \ 'class' : 'c', - \ 'struct' : 's', - \ 'union' : 'u' - \ } - let s:known_types.cpp = type_cpp - " C# {{{3 - let type_cs = s:TypeInfo.New() - let type_cs.ctagstype = 'c#' - let type_cs.kinds = [ - \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, - \ {'short' : 't', 'long' : 'typedefs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'structs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'E', 'long' : 'events', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1} - \ ] - let type_cs.sro = '.' - let type_cs.kind2scope = { - \ 'n' : 'namespace', - \ 'i' : 'interface', - \ 'c' : 'class', - \ 's' : 'struct', - \ 'g' : 'enum' - \ } - let type_cs.scope2kind = { - \ 'namespace' : 'n', - \ 'interface' : 'i', - \ 'class' : 'c', - \ 'struct' : 's', - \ 'enum' : 'g' - \ } - let s:known_types.cs = type_cs - " COBOL {{{3 - let type_cobol = s:TypeInfo.New() - let type_cobol.ctagstype = 'cobol' - let type_cobol.kinds = [ - \ {'short' : 'd', 'long' : 'data items', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'file descriptions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'g', 'long' : 'group items', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'P', 'long' : 'program ids', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.cobol = type_cobol - " DOS Batch {{{3 - let type_dosbatch = s:TypeInfo.New() - let type_dosbatch.ctagstype = 'dosbatch' - let type_dosbatch.kinds = [ - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.dosbatch = type_dosbatch - " Eiffel {{{3 - let type_eiffel = s:TypeInfo.New() - let type_eiffel.ctagstype = 'eiffel' - let type_eiffel.kinds = [ - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'features', 'fold' : 0, 'stl' : 1} - \ ] - let type_eiffel.sro = '.' " Not sure, is nesting even possible? - let type_eiffel.kind2scope = { - \ 'c' : 'class', - \ 'f' : 'feature' - \ } - let type_eiffel.scope2kind = { - \ 'class' : 'c', - \ 'feature' : 'f' - \ } - let s:known_types.eiffel = type_eiffel - " Erlang {{{3 - let type_erlang = s:TypeInfo.New() - let type_erlang.ctagstype = 'erlang' - let type_erlang.kinds = [ - \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'd', 'long' : 'macro definitions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'r', 'long' : 'record definitions', 'fold' : 0, 'stl' : 1} - \ ] - let type_erlang.sro = '.' " Not sure, is nesting even possible? - let type_erlang.kind2scope = { - \ 'm' : 'module' - \ } - let type_erlang.scope2kind = { - \ 'module' : 'm' - \ } - let s:known_types.erlang = type_erlang - " Flex {{{3 - " Vim doesn't support Flex out of the box, this is based on rough - " guesses and probably requires - " http://www.vim.org/scripts/script.php?script_id=2909 - " Improvements welcome! - let type_as = s:TypeInfo.New() - let type_as.ctagstype = 'flex' - let type_as.kinds = [ - \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'x', 'long' : 'mxtags', 'fold' : 0, 'stl' : 0} - \ ] - let type_as.sro = '.' - let type_as.kind2scope = { - \ 'c' : 'class' - \ } - let type_as.scope2kind = { - \ 'class' : 'c' - \ } - let s:known_types.mxml = type_as - let s:known_types.actionscript = type_as - " Fortran {{{3 - let type_fortran = s:TypeInfo.New() - let type_fortran.ctagstype = 'fortran' - let type_fortran.kinds = [ - \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'k', 'long' : 'components', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'derived types and structures', 'fold' : 0, - \ 'stl' : 1}, - \ {'short' : 'c', 'long' : 'common blocks', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'b', 'long' : 'block data', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'e', 'long' : 'entry points', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'n', 'long' : 'namelists', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} - \ ] - let type_fortran.sro = '.' " Not sure, is nesting even possible? - let type_fortran.kind2scope = { - \ 'm' : 'module', - \ 'p' : 'program', - \ 'f' : 'function', - \ 's' : 'subroutine' - \ } - let type_fortran.scope2kind = { - \ 'module' : 'm', - \ 'program' : 'p', - \ 'function' : 'f', - \ 'subroutine' : 's' - \ } - let s:known_types.fortran = type_fortran - " HTML {{{3 - let type_html = s:TypeInfo.New() - let type_html.ctagstype = 'html' - let type_html.kinds = [ - \ {'short' : 'f', 'long' : 'JavaScript funtions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'a', 'long' : 'named anchors', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.html = type_html - " Java {{{3 - let type_java = s:TypeInfo.New() - let type_java.ctagstype = 'java' - let type_java.kinds = [ - \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'fields', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'g', 'long' : 'enum types', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'enum constants', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1} - \ ] - let type_java.sro = '.' - let type_java.kind2scope = { - \ 'g' : 'enum', - \ 'i' : 'interface', - \ 'c' : 'class' - \ } - let type_java.scope2kind = { - \ 'enum' : 'g', - \ 'interface' : 'i', - \ 'class' : 'c' - \ } - let s:known_types.java = type_java - " JavaScript {{{3 - " JavaScript is weird -- it does have scopes, but ctags doesn't seem to - " properly generate the information for them, instead it simply uses the - " complete name. So ctags has to be fixed before I can do anything here. - " Alternatively jsctags/doctorjs will be used if available. - let type_javascript = s:TypeInfo.New() - let type_javascript.ctagstype = 'javascript' - let jsctags = s:CheckFTCtags('jsctags', 'javascript') - if jsctags != '' - let type_javascript.kinds = [ - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let type_javascript.sro = '.' - let type_javascript.kind2scope = { - \ 'v' : 'namespace', - \ 'f' : 'namespace' - \ } - let type_javascript.scope2kind = { - \ 'namespace' : 'v' - \ } - let type_javascript.ctagsbin = jsctags - let type_javascript.ctagsargs = '-f -' - else - let type_javascript.kinds = [ - \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'properties', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - endif - let s:known_types.javascript = type_javascript - " Lisp {{{3 - let type_lisp = s:TypeInfo.New() - let type_lisp.ctagstype = 'lisp' - let type_lisp.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.lisp = type_lisp - let s:known_types.clojure = type_lisp - " Lua {{{3 - let type_lua = s:TypeInfo.New() - let type_lua.ctagstype = 'lua' - let type_lua.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.lua = type_lua - " Make {{{3 - let type_make = s:TypeInfo.New() - let type_make.ctagstype = 'make' - let type_make.kinds = [ - \ {'short' : 'm', 'long' : 'macros', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.make = type_make - " Matlab {{{3 - let type_matlab = s:TypeInfo.New() - let type_matlab.ctagstype = 'matlab' - let type_matlab.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.matlab = type_matlab - " Ocaml {{{3 - let type_ocaml = s:TypeInfo.New() - let type_ocaml.ctagstype = 'ocaml' - let type_ocaml.kinds = [ - \ {'short' : 'M', 'long' : 'modules or functors', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'global variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'C', 'long' : 'constructors', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'exceptions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'type names', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'r', 'long' : 'structure fields', 'fold' : 0, 'stl' : 0} - \ ] - let type_ocaml.sro = '.' " Not sure, is nesting even possible? - let type_ocaml.kind2scope = { - \ 'M' : 'Module', - \ 'c' : 'class', - \ 't' : 'type' - \ } - let type_ocaml.scope2kind = { - \ 'Module' : 'M', - \ 'class' : 'c', - \ 'type' : 't' - \ } - let s:known_types.ocaml = type_ocaml - " Pascal {{{3 - let type_pascal = s:TypeInfo.New() - let type_pascal.ctagstype = 'pascal' - let type_pascal.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.pascal = type_pascal - " Perl {{{3 - let type_perl = s:TypeInfo.New() - let type_perl.ctagstype = 'perl' - let type_perl.kinds = [ - \ {'short' : 'p', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'formats', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.perl = type_perl - " PHP {{{3 - let type_php = s:TypeInfo.New() - let type_php.ctagstype = 'php' - let type_php.kinds = [ - \ {'short' : 'i', 'long' : 'interfaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'd', 'long' : 'constant definitions', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'j', 'long' : 'javascript functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.php = type_php - " Python {{{3 - let type_python = s:TypeInfo.New() - let type_python.ctagstype = 'python' - let type_python.kinds = [ - \ {'short' : 'i', 'long' : 'imports', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0} - \ ] - let type_python.sro = '.' - let type_python.kind2scope = { - \ 'c' : 'class', - \ 'f' : 'function', - \ 'm' : 'function' - \ } - let type_python.scope2kind = { - \ 'class' : 'c', - \ 'function' : 'f' - \ } - let s:known_types.python = type_python - let s:known_types.pyrex = type_python - let s:known_types.cython = type_python - " REXX {{{3 - let type_rexx = s:TypeInfo.New() - let type_rexx.ctagstype = 'rexx' - let type_rexx.kinds = [ - \ {'short' : 's', 'long' : 'subroutines', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.rexx = type_rexx - " Ruby {{{3 - let type_ruby = s:TypeInfo.New() - let type_ruby.ctagstype = 'ruby' - let type_ruby.kinds = [ - \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'F', 'long' : 'singleton methods', 'fold' : 0, 'stl' : 1} - \ ] - let type_ruby.sro = '.' - let type_ruby.kind2scope = { - \ 'c' : 'class', - \ 'm' : 'class' - \ } - let type_ruby.scope2kind = { - \ 'class' : 'c' - \ } - let s:known_types.ruby = type_ruby - " Scheme {{{3 - let type_scheme = s:TypeInfo.New() - let type_scheme.ctagstype = 'scheme' - let type_scheme.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'sets', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.scheme = type_scheme - let s:known_types.racket = type_scheme - " Shell script {{{3 - let type_sh = s:TypeInfo.New() - let type_sh.ctagstype = 'sh' - let type_sh.kinds = [ - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.sh = type_sh - let s:known_types.csh = type_sh - let s:known_types.zsh = type_sh - " SLang {{{3 - let type_slang = s:TypeInfo.New() - let type_slang.ctagstype = 'slang' - let type_slang.kinds = [ - \ {'short' : 'n', 'long' : 'namespaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.slang = type_slang - " SML {{{3 - let type_sml = s:TypeInfo.New() - let type_sml.ctagstype = 'sml' - let type_sml.kinds = [ - \ {'short' : 'e', 'long' : 'exception declarations', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'function definitions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'functor definitions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'signature declarations', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'r', 'long' : 'structure declarations', 'fold' : 0, 'stl' : 0}, - \ {'short' : 't', 'long' : 'type definitions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'value bindings', 'fold' : 0, 'stl' : 0} - \ ] - let s:known_types.sml = type_sml - " SQL {{{3 - " The SQL ctags parser seems to be buggy for me, so this just uses the - " normal kinds even though scopes should be available. Improvements - " welcome! - let type_sql = s:TypeInfo.New() - let type_sql.ctagstype = 'sql' - let type_sql.kinds = [ - \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 1}, - \ {'short' : 'd', 'long' : 'prototypes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'cursors', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'F', 'long' : 'record fields', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'L', 'long' : 'block label', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'tables', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'T', 'long' : 'triggers', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'i', 'long' : 'indexes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'U', 'long' : 'publications', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'R', 'long' : 'services', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'D', 'long' : 'domains', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'V', 'long' : 'views', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'n', 'long' : 'synonyms', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'x', 'long' : 'MobiLink Table Scripts', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'y', 'long' : 'MobiLink Conn Scripts', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'z', 'long' : 'MobiLink Properties', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.sql = type_sql - " Tcl {{{3 - let type_tcl = s:TypeInfo.New() - let type_tcl.ctagstype = 'tcl' - let type_tcl.kinds = [ - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.tcl = type_tcl - " LaTeX {{{3 - let type_tex = s:TypeInfo.New() - let type_tex.ctagstype = 'tex' - let type_tex.kinds = [ - \ {'short' : 'i', 'long' : 'includes', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'p', 'long' : 'parts', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'chapters', 'fold' : 0, 'stl' : 1}, - \ {'short' : 's', 'long' : 'sections', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'u', 'long' : 'subsections', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'b', 'long' : 'subsubsections', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'P', 'long' : 'paragraphs', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'G', 'long' : 'subparagraphs', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 0} - \ ] - let type_tex.sro = '""' - let type_tex.kind2scope = { - \ 'p' : 'part', - \ 'c' : 'chapter', - \ 's' : 'section', - \ 'u' : 'subsection', - \ 'b' : 'subsubsection' - \ } - let type_tex.scope2kind = { - \ 'part' : 'p', - \ 'chapter' : 'c', - \ 'section' : 's', - \ 'subsection' : 'u', - \ 'subsubsection' : 'b' - \ } - let type_tex.sort = 0 - let s:known_types.tex = type_tex - " Vala {{{3 - " Vala is supported by the ctags fork provided by Anjuta, so only add the - " type if the fork is used to prevent error messages otherwise - if has_key(s:ctags_types, 'vala') || executable('anjuta-tags') - let type_vala = s:TypeInfo.New() - let type_vala.ctagstype = 'vala' - let type_vala.kinds = [ - \ {'short' : 'e', 'long' : 'Enumerations', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'Enumeration values', 'fold' : 0, 'stl' : 0}, - \ {'short' : 's', 'long' : 'Structures', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'i', 'long' : 'Interfaces', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'd', 'long' : 'Delegates', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'Classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'Properties', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'Fields', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'm', 'long' : 'Methods', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'E', 'long' : 'Error domains', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'r', 'long' : 'Error codes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'S', 'long' : 'Signals', 'fold' : 0, 'stl' : 1} - \ ] - let type_vala.sro = '.' - " 'enum' doesn't seem to be used as a scope, but it can't hurt to have - " it here - let type_vala.kind2scope = { - \ 's' : 'struct', - \ 'i' : 'interface', - \ 'c' : 'class', - \ 'e' : 'enum' - \ } - let type_vala.scope2kind = { - \ 'struct' : 's', - \ 'interface' : 'i', - \ 'class' : 'c', - \ 'enum' : 'e' - \ } - let s:known_types.vala = type_vala - endif - if !has_key(s:ctags_types, 'vala') && executable('anjuta-tags') - let s:known_types.vala.ctagsbin = 'anjuta-tags' - endif - " Vera {{{3 - " Why are variables 'virtual'? - let type_vera = s:TypeInfo.New() - let type_vera.ctagstype = 'vera' - let type_vera.kinds = [ - \ {'short' : 'd', 'long' : 'macros', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'g', 'long' : 'enums', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'T', 'long' : 'typedefs', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'classes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'enumerators', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'm', 'long' : 'members', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'p', 'long' : 'programs', 'fold' : 0, 'stl' : 1} - \ ] - let type_vera.sro = '.' " Nesting doesn't seem to be possible - let type_vera.kind2scope = { - \ 'g' : 'enum', - \ 'c' : 'class', - \ 'v' : 'virtual' - \ } - let type_vera.scope2kind = { - \ 'enum' : 'g', - \ 'class' : 'c', - \ 'virtual' : 'v' - \ } - let s:known_types.vera = type_vera - " Verilog {{{3 - let type_verilog = s:TypeInfo.New() - let type_verilog.ctagstype = 'verilog' - let type_verilog.kinds = [ - \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'e', 'long' : 'events', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'm', 'long' : 'modules', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'n', 'long' : 'net data types', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'ports', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'r', 'long' : 'register data types', 'fold' : 0, 'stl' : 1}, - \ {'short' : 't', 'long' : 'tasks', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.verilog = type_verilog - " VHDL {{{3 - " The VHDL ctags parser unfortunately doesn't generate proper scopes - let type_vhdl = s:TypeInfo.New() - let type_vhdl.ctagstype = 'vhdl' - let type_vhdl.kinds = [ - \ {'short' : 'P', 'long' : 'packages', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'c', 'long' : 'constants', 'fold' : 0, 'stl' : 0}, - \ {'short' : 't', 'long' : 'types', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'T', 'long' : 'subtypes', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'r', 'long' : 'records', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'e', 'long' : 'entities', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'p', 'long' : 'procedures', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.vhdl = type_vhdl - " Vim {{{3 - let type_vim = s:TypeInfo.New() - let type_vim.ctagstype = 'vim' - let type_vim.kinds = [ - \ {'short' : 'n', 'long' : 'vimball filenames', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'v', 'long' : 'variables', 'fold' : 1, 'stl' : 0}, - \ {'short' : 'f', 'long' : 'functions', 'fold' : 0, 'stl' : 1}, - \ {'short' : 'a', 'long' : 'autocommand groups', 'fold' : 1, 'stl' : 1}, - \ {'short' : 'c', 'long' : 'commands', 'fold' : 0, 'stl' : 0}, - \ {'short' : 'm', 'long' : 'maps', 'fold' : 1, 'stl' : 0} - \ ] - let s:known_types.vim = type_vim - " YACC {{{3 - let type_yacc = s:TypeInfo.New() - let type_yacc.ctagstype = 'yacc' - let type_yacc.kinds = [ - \ {'short' : 'l', 'long' : 'labels', 'fold' : 0, 'stl' : 1} - \ ] - let s:known_types.yacc = type_yacc - " }}}3 - - call s:LoadUserTypeDefs() - - for typeinfo in values(s:known_types) - call typeinfo.createKinddict() - endfor - - let s:type_init_done = 1 -endfunction - -" s:LoadUserTypeDefs() {{{2 -function! s:LoadUserTypeDefs(...) abort - if a:0 > 0 - let type = a:1 - - call s:LogDebugMessage("Initializing user type '" . type . "'") - - let defdict = {} - let defdict[type] = g:tagbar_type_{type} - else - call s:LogDebugMessage('Initializing user types') - - let defdict = tagbar#getusertypes() - endif - - let transformed = {} - for [type, def] in items(defdict) - let transformed[type] = s:TransformUserTypeDef(def) - endfor - - for [key, value] in items(transformed) - if !has_key(s:known_types, key) || get(value, 'replace', 0) - let s:known_types[key] = s:TypeInfo.New(value) - else - call extend(s:known_types[key], value) - endif - endfor - - if a:0 > 0 - call s:known_types[type].createKinddict() - endif -endfunction - -" s:TransformUserTypeDef() {{{2 -" Transform the user definitions into the internal format -function! s:TransformUserTypeDef(def) abort - let newdef = copy(a:def) - - if has_key(a:def, 'kinds') - let newdef.kinds = [] - let kinds = a:def.kinds - for kind in kinds - let kindlist = split(kind, ':') - let kinddict = {'short' : kindlist[0], 'long' : kindlist[1]} - let kinddict.fold = get(kindlist, 2, 0) - let kinddict.stl = get(kindlist, 3, 1) - call add(newdef.kinds, kinddict) - endfor - endif - - " If the user only specified one of kind2scope and scope2kind then use it - " to generate the respective other - if has_key(a:def, 'kind2scope') && !has_key(a:def, 'scope2kind') - let newdef.scope2kind = {} - for [key, value] in items(a:def.kind2scope) - let newdef.scope2kind[value] = key - endfor - elseif has_key(a:def, 'scope2kind') && !has_key(a:def, 'kind2scope') - let newdef.kind2scope = {} - for [key, value] in items(a:def.scope2kind) - let newdef.kind2scope[value] = key - endfor - endif - - return newdef -endfunction - -" s:RestoreSession() {{{2 -" Properly restore Tagbar after a session got loaded -function! s:RestoreSession() abort - call s:LogDebugMessage('Restoring session') - - let curfile = fnamemodify(bufname('%'), ':p') - - let tagbarwinnr = bufwinnr('__Tagbar__') - if tagbarwinnr == -1 - " Tagbar wasn't open in the saved session, nothing to do - return - else - let in_tagbar = 1 - if winnr() != tagbarwinnr - call s:goto_win(tagbarwinnr) - let in_tagbar = 0 - endif - endif - - let s:last_autofocus = 0 - - call s:Init(0) - - call s:InitWindow(g:tagbar_autoclose) - - call s:AutoUpdate(curfile, 0) - - if !in_tagbar - call s:goto_win('p') - endif -endfunction - -" s:MapKeys() {{{2 -function! s:MapKeys() abort - call s:LogDebugMessage('Mapping keys') - - nnoremap