VIM: Remove GoldenView

GoldenView causes several problems with badly written plugins like
traces.vim. The problem manifests in errors occuring due to GoldenView
setting the 'winminwidth' parameter to anything but 0. Traces.vim then
tries to set the winwidth to 1 or 0 and throws errors as vim is
enforcing the 'winminwidth'.
This commit is contained in:
Tobias Manske 2018-09-01 10:31:01 +02:00
parent a3fac1d9f6
commit b705be0c1e
No known key found for this signature in database
GPG Key ID: 978D99F12D4E041F
22 changed files with 0 additions and 3562 deletions

3
.gitmodules vendored
View File

@ -40,9 +40,6 @@
[submodule "vim/plugins/vim-nerdtree-tabs"] [submodule "vim/plugins/vim-nerdtree-tabs"]
path = vim/plugins/vim-nerdtree-tabs path = vim/plugins/vim-nerdtree-tabs
url = https://github.com/jistr/vim-nerdtree-tabs url = https://github.com/jistr/vim-nerdtree-tabs
[submodule "vim/plugins/GoldenView"]
path = vim/plugins/GoldenView
url = git://github.com/zhaocai/GoldenView.Vim.git
[submodule "vim/plugins/ultisnips"] [submodule "vim/plugins/ultisnips"]
path = vim/plugins/ultisnips path = vim/plugins/ultisnips
url = https://github.com/SirVer/ultisnips.git url = https://github.com/SirVer/ultisnips.git

View File

@ -21,35 +21,6 @@ let g:airline_theme="minimalist"
autocmd TextChanged * GitGutter autocmd TextChanged * GitGutter
" GoldenView
let g:goldenview__enable_default_mapping = 0
let g:goldenview__ignore_urule = {
\ 'filetype' : [
\ '' ,
\ 'qf' , 'vimpager', 'undotree', 'tagbar',
\ 'nerdtree', 'vimshell', 'vimfiler', 'voom' ,
\ 'tabman' , 'unite' , 'quickrun', 'Decho' ,
\ 'netrw' ,
\ ],
\ 'buftype' : [
\ 'nofile' ,
\ ],
\ 'bufname' : [
\ 'GoToFile' , 'diffpanel_\d\+' ,
\ '__Gundo_Preview__' , '__Gundo__' ,
\ '\[LustyExplorer-Buffers\]' , '\-MiniBufExplorer\-' ,
\ '_VOOM\d\+$' , '__Urannotate_\d\+__' ,
\ '__MRU_Files__' ,
\ ],
\}
let g:goldenview__restore_urule = {
\ 'filetype' : [
\ 'nerdtree', 'vimfiler', 'netrw',
\ ],
\ 'bufname' : [
\ '__MRU_Files__' ,
\ ],
\ }
" JavaComplete " JavaComplete

View File

@ -1 +0,0 @@
*.zip

View File

@ -1,31 +0,0 @@
# Heuristics used by VCLog itself.
type :major, 3, "Major Enhancements"
type :minor, 2, "Minor Enhancements"
type :bug, 1, "Bug Fixes"
type :fix, 1, "Bug Fixes"
type :update, 0, "Nominal Changes"
type :doc, -1, "Documentation Changes"
type :test, -1, "Test/Spec Adjustments"
type :admin, -2, "Administrative Changes"
type :log, -3, "Just a record"
on Regexp.union(/^(?<type> \w+):/, /^\[(?<type>\w+)\]/) do |commit, md|
type = md[:type].to_sym
commit.type = type
commit.message = commit.message.sub(md[0],'').strip
end
on /updated? (README\.md|PROFILE|PACKAGE|VERSION|Manifest\.txt)/ do |commit|
commit.type = :admin
end
on /(bump|bumped|prepare) version/ do |commit|
commit.type = :admin
end
colors :grey, :blue, :cyan, :green, :yellow, :red, [:red, :bold]
# vim: set ft=ruby ts=2 sw=2 tw=78 fmr=[[[,]]] fdm=syntax :

View File

@ -1,124 +0,0 @@
script_name: GoldenView.Vim
script_id: '4529'
script_type: utility
script_package: '{script_name}-{version}.zip'
required_vim_version: '7.3'
summary: Always have a nice view for vim split windows
detailed_description: |
Please goto homepage for a better view of the introduction.
Homepage: http://zhaocai.github.io/GoldenView.Vim/
Screencast: http://dl.dropboxusercontent.com/u/1897501/Screencasts/GoldenView.gif
If you like it, please star or fork in https://github.com/zhaocai/GoldenView.Vim so that more people may find it.
>>> Introduction:
The initial motive for GoldenView comes from the frustration of using other vim plugins to autoresize split windows. The idea is deadly simple and very useful: resize the focused window to a proper size. However, in practice, many hiccups makes autoresizing not a smooth experience. Below are a list of issues I am trying to solve:
First and the most important one, autoresizing should play nicely with existing plugins like tagbar, vimfiler, unite, VOoM, quickfix, undotree, gundo, etc. These windows should manage there own window size.
Second, autoresizing should take care of the other windows too. Resizing the focused window may cause the other windows become too small. When you have 4+ split windows, autoresizing may just make a mess out of it.
>>> Features:
GoldenView has preliminarily solved the issues described above. It also provides other features. Bascally, it does two things:
1. Autoresizing
First of all, it automatically resize the focused split window to a "golden" view based on golden ratio and textwidth.
2. Tiled Windows Management
Second, it maps a single key (<C-L> by default) to nicely split windows to tiled windows.
====+==============+============+===+
| | | | |
| F | | S1 | T |
| I | +------------| A |
| L | MAIN PANE | S2 | G |
| E | +------------+ B |
| R | | S3 | A |
| | | | |
+===+==============+============+===+
To get this view, just hit <C-L> 4 times. or, if you have a large monitor, you may get tiled windows below.
+===+==============+==============+============+===+
| | | | | |
| F | | | S1 | T |
| I | | +------------| A |
| L | MAIN PANE | M2 | S2 | G |
| E | | +------------+ B |
| R | | | S3 | A |
| | | | | |
+===+==============+==============+============+===+
To quickly switch between those windows, a few keys are mapped to
- Focuse to the main window
- Switch with the largest, smallest, etc.
- Jump to next and previous window
Requirements:
- Vim 7.3 or later
install_details: |
http://zhaocai.github.io/GoldenView.Vim/
versions:
- '1.3.6': |
- Maintenance update
- '1.3.5': |
- Fix for issue #5 (github).
- Fix for Dirdiff, FencView
- Improve tracing
- '1.3.0': |
- Diff mode auto-resizing
- refactor autocmd function: tweak restore behavior
- '1.2.2': |
Improve documents and small bug fixes,
Load guard for #4 (github)
- '1.2.0': |
add restore rule for some special buffers, which solves all the hiccups I could identify so far.
- '1.1.2': |
Improve documents, fix load sequence
- '1.1.1': |
Improve documents, fix zl library load
- '1.1.0': |
- 3 Major Enhancements
* add WinLeave event into account. This version works perfectly.
* fix various hiccups caused by winleave
* use ignore rules from zl.vim
- 4 Minor Enhancements
* add mapping to switch to main pane. [minor] speed up buffer switch with noautocmd
* include zl.vim into source code
* tune for autocmd sequence
* treat winfixwidth and winfixheight separately
- 2 Bug Fixes
* winleave cause ignored windows resized
* cannot let &winminwidth > &winwidth
- 2 Nominal Changes
* change profile variable scope to s\:
* tweak golden ratio for win size
# __END__
# vim: filetype=yaml

View File

@ -1,102 +0,0 @@
# RELEASE HISTORY
## V1.3.0 / 2013-04-22
Diff Mode auto resizing (Zhao Cai <caizhaoff@gmail.com>)
Changes:
* 1 Major Enhancements
* diff mode auto-resizing.
* 1 Minor Enhancements
* refactor autocmd function: tweak restore behavior
## V1.2.2 / 2013-04-21
Improve documents and small bug fixes,
Load guard for #4 (github) (Zhao Cai <caizhaoff@gmail.com>)
Changes:
* 1 Minor Enhancements
* better tracing
* 1 Bug Fixes
* load guard for issue #4
E806: using Float as a String
## V1.2.0 / 2013-04-18
(Zhao Cai <caizhaoff@gmail.com>)
Changes:
* 1 Major Enhancements
* add restore rule for some special buffers
* 4 Bug Fixes
* E36 no enough room to split
* issue #2 MRU plugin window
* init sequence
* zl load guard
## V1.1.2 / 2013-04-18
Fix init sequence between zl.vim and GoldenVim (Zhao Cai <caizhaoff@gmail.com>)
## HEAD / 2013-04-23
Current Development (Zhao Cai)
## V1.1.1 / 2013-04-18
improve documents, fix zl library load (Zhao Cai <caizhaoff@gmail.com>)
## V1.1.0 / 2013-04-18
(Zhao Cai <caizhaoff@gmail.com>)
Changes:
* 3 Major Enhancements
* add WinLeave event into account. This version works perfectly.
* fix various hiccups caused by winleave
* use ignore rules from zl.vim
* 4 Minor Enhancements
* add mapping to switch to main pane. [minor] speed up buffer switch with noautocmd
* include zl.vim into source code
* tune for autocmd sequence
* treat winfixwidth and winfixheight separately
* 2 Bug Fixes
* winleave cause ignored windows resized
* cannot let &winminwidth > &winwidth
* 2 Nominal Changes
* change profile variable scope to s:
* tweak golden ratio for win size
## 1.0 / 2012-09-18
(Zhao Cai <caizhaoff@gmail.com>)

View File

@ -1,343 +0,0 @@
# Always have a nice view for vim split windows
------------- - -----------------------------------------------
Plugin : GoldenView.vim
Author : Zhao Cai
EMail : caizhaoff@gmail.com
Homepage : http://zhaocai.github.io/GoldenView.Vim/
Vim.org : http://www.vim.org/scripts/script.php?script_id=4529
Version : 1.3.6
Date Created : Tue 18 Sep 2012 05:23:13 PM EDT
Last Modified : Mon 22 Apr 2013 05:55:22 PM EDT
------------- - -----------------------------------------------
The initial motive for [GoldenView][GoldenView] comes from the frustration of using other vim plugins to auto-resize split windows. The idea is deadly simple and very useful: **resize the focused window to a proper size.** However, in practice, many hiccups makes **auto-resizing** not a smooth experience. Below are a list of issues [GoldenView][GoldenView] attempts to solve:
First and the most important one, auto-resizing should play nicely with existing plugins like `tagbar`, `vimfiler`, `unite`, `VOoM`, `quickfix`, `undotree`, `gundo`, etc. These windows should manage there own window size.
Second, auto-resizing should take care of **the other windows** too. Resizing the focused window may cause the other windows become too small. When you have 4+ split windows, auto-resizing may just make a mess out of it.
![GoldView Screencast]( http://dl.dropboxusercontent.com/u/1897501/Screencasts/GoldenView.gif )
## Features
[GoldenView][GoldenView] has preliminarily solved the issues described above. It also provides other features. Bascally, it does two things:
### 1. AutoResizing
First of all, it automatically resize the focused split window to a "golden" view based on [golden ratio][golden-ratio-wikipedia] and `textwidth`.
### 2. Tiled Windows Management
Second, it maps a single key (`<C-L>` by default) to nicely split windows to tiled windows.
```
----+----------------+------------+---+
| | | | |
| F | | S1 | T |
| I | +------------| A |
| L | | S2 | G |
| E | MAIN PANE +------------+ B |
| R | | S3 | A |
| | | | R |
| | | | |
+---+----------------+------------+---+
```
To get this view, just hit `<C-L>` 4 times. or, if you have a large monitor, you may get tiled windows below.
```
----+---------------+--------------+------------+---+
| | | | | |
| F | | | S1 | T |
| I | | +------------| A |
| L | | M2 | S2 | G |
| E | MAIN PANE | +------------+ B |
| R | | | S3 | A |
| | | | | B |
| | | | | |
+---+---------------+--------------+------------+---+
```
To quickly switch between those windows, a few keys are mapped to
- Focus to the main window
- Switch with the `MAIN PANE`, the largest, smallest, etc.
- Jump to the next and previous window
## Installation
Install [GoldenView][GoldenView] is the *same as installing other vim plugins*. If experienced with vim, you can skim the example below and move to [next section](#quick-start).
### **Option A** - With [Plugin Manager][vim-plugin-manager] ( **recommended** )
If you use plugin managers like *Pathogen*, *vundle*, *neobundle*, *vim-addon-manager*, etc., just unarchive the zip file or clone the [GoldenView][GoldenView] repo from `git://github.com/zhaocai/GoldenView.git` into your local plugin installation directory (most likely `~/.vim/bundle/`). Then add corresponding scripts in .vimrc for the bundle manager you are using.
**Example**:
- *neobundle*:
```vim
NeoBundle 'zhaocai/GoldenView.Vim' "Always have a nice view for vim split windows
```
- *vundle*:
```vim
Bundle 'zhaocai/GoldenView.Vim'
```
- *vim-addon-manager*:
```vim
call vam#ActivateAddons(['GoldenView.Vim'], {'auto_install' : 1})
```
### **Option B** - Without [Plugin Manager][vim-plugin-manager]
Unarchive the zip file into a directory that is under `runtimepath` of your vim, `~/.vim` for example.
## Quick Start
[GoldenView][GoldenView] should work out of the box without configuration. It should automatically start to resize focused window to [golden ratio][golden-ratio-wikipedia] based on `textwidth` and vim available size. You may start to play with it now.
To get you started, a few default keys are mapped as below:
```vim
" 1. split to tiled windows
nmap <silent> <C-L> <Plug>GoldenViewSplit
" 2. quickly switch current window with the main pane
" and toggle back
nmap <silent> <F8> <Plug>GoldenViewSwitchMain
nmap <silent> <S-F8> <Plug>GoldenViewSwitchToggle
" 3. jump to next and previous window
nmap <silent> <C-N> <Plug>GoldenViewNext
nmap <silent> <C-P> <Plug>GoldenViewPrevious
```
The meaning of those keys are self-explaining. A general workflow would be `<Plug>GoldenViewSplit` key to quickly and nicely split windows to the layout as below. Then you may open your files.
```
----+----------------+------------+---+
| | | | |
| F | | S1 | T |
| I | +------------| A |
| L | | S2 | G |
| E | MAIN PANE +------------+ B |
| R | | S3 | A |
| | | | R |
| | | | |
+---+----------------+------------+---+
```
To switch `S1` with `MAIN PANE`, in `S1` and hit `<Plug>GoldenViewSwitchMain`. To switch back, hit `<Plug>GoldenViewSwitchToggle` in either `MAIN PAIN` or `S1`
#### g:goldenview__enable_default_mapping
Every experienced vim user has a different set of key mappings. If you you are (most likely) unhappy about some of the mappings, map you own keys as below:
```vim
let g:goldenview__enable_default_mapping = 0
nmap <silent> <MY_KEY> <Plug>GoldenViewSplit
" ... and so on
```
#### g:goldenview__enable_at_startup
if you do not want to start auto-resizing automatically, you can put the following script in your vimrc.
```vim
let g:goldenview__enable_at_startup = 0
```
## More Commands and Mappings
### `:ToggleGoldenViewAutoResize`
### `:DisableGoldenViewAutoResize`
### `:EnableGoldenViewAutoResize`
These commands toggle, enable, and disable GoldenView auto-resizing.
### `:GoldenViewResize`
this command do manual resizing of focused window.
You can also map a key for this as below:
```vim
nmap <silent> <YOUR_KEY> <Plug>GoldenViewResize
```
### `:SwitchGoldenViewMain`
### `:SwitchGoldenViewLargest`
### `:SwitchGoldenViewSmallest`
these commands do as it named.
You can also add mappings as below. ( no default keys for these mappings)
```vim
nmap <silent> <YOUR_KEY> <Plug>GoldenViewSwitchWithLargest
nmap <silent> <YOUR_KEY> <Plug>GoldenViewSwitchWithSmallest
```
Other switch rules can be easily defined. If you have some ideas, please post to [github issue][GoldenViewIssue] for discussion.
## Rules
[GoldenView][] defines two rules:
### `g:goldenview__ignore_urule`
is to "ignore" - allow those special buffers to manage their own window size.
### `g:goldenview__restore_urule`
is to "restore" - restore window size of some of special buffers.
The `urule` (user rules) are like this, which will be normalize at runtime for faster processing.
```vim
\{
\ 'filetype' : [
\ '' ,
\ 'qf' , 'vimpager', 'undotree', 'tagbar',
\ 'nerdtree', 'vimshell', 'vimfiler', 'voom' ,
\ 'tabman' , 'unite' , 'quickrun', 'Decho' ,
\ ],
\ 'buftype' : [
\ 'nofile' ,
\ ],
\ 'bufname' : [
\ 'GoToFile' , 'diffpanel_\d\+' ,
\ '__Gundo_Preview__' , '__Gundo__' ,
\ '\[LustyExplorer-Buffers\]' , '\-MiniBufExplorer\-' ,
\ '_VOOM\d\+$' , '__Urannotate_\d\+__' ,
\ '__MRU_Files__' ,
\ ],
\},
```
## Profiles
[GoldenView][] defines two profile:
### `g:goldenview__active_profile`
defines the functions and preferences to auto resize windows.
### `g:goldenview__reset_profile`
defines reset preferences to restore everything to default.
`function GoldenView#ExtendProfile()` is provided to customize preferences.
For more details, please read the source code! :)
## Troubleshooting:
### Please do not resize me!
[GoldenView][] maintains rules for "common" cases. But vim offers a great variety of plugins which defines buffers for special purposes. If you find some special buffers which is supposed to not be auto-resized. Please check `g:goldenview__ignore_urule`. You may extend the `g:goldenview__active_profile` yourself or post the issue to [github issue][GoldenViewIssue] for adding it to builtin support.
### [minibufexpl.vim][] takes 5+ lines
Check my fork [minibufexpl.vim][] to see if it is working for you. I have send pull request to the origin repo.
### I cannot resize window height to < 7
This is features. As mentioned in the [Introduction](#always-have-a-nice-view-for-vim-split-windows) section, there is no normal cases to have a normal window too small. For special cases like [minibufexpl.vim][], it can be handled case by case.
However, if you really want to have small windows. It can be done by :
```vim
" Extend a new profile named 'small-height' from default profile.
"
" 1. Change "2" to your desire minimal height
" 2. Change "small-height" to the profile name you like
" ---------------------------------------------------------------
call GoldenView#ExtendProfile('small-height', {
\ 'other_window_winheight' : 2 ,
\ })
let g:goldenview__active_profile = 'small-height'
```
(refer to issue #5)
### I still have Issues:
If you have any issues, please post it to [github issue][GoldenViewIssue] for discussion.
Remember to run the following command and post the results.
```vim
echo GoldenView#Info()
```
## Contributors
## RELEASE HISTORY
Refer to [History.md]( https://github.com/zhaocai/GoldenView.Vim/blob/master/History.md )
## LICENSE:
Copyright (c) 2013 Zhao Cai \<caizhaoff@gmail.com\>
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 3 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.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
[dwm]: http://www.vim.org/scripts/script.php?script_id=4186
[golden-ratio-plugin]: http://www.vim.org/scripts/script.php?script_id=3690
[golden-ratio-wikipedia]: http://en.wikipedia.org/wiki/Golden_ratio
[zl]: https://github.com/zhaocai/zl.vim "zl.vim vim script library"
[GoldenView]: http://zhaocai.github.io/GoldenView.Vim/ "GoldenView Homepage"
[GoldenViewCode]: https://github.com/zhaocai/GoldenView.Vim "GoldenView Vim Plugin"
[vim-plugin-manager]: http://vim-scripts.org/vim/tools.html "Vim Plugin Manangers"
[GoldenViewIssue]: https://github.com/zhaocai/GoldenView.Vim/issues "GoldenView Issue Track"
[minibufexpl.vim]: https://github.com/zhaocai/minibufexpl.vim

View File

@ -1,54 +0,0 @@
require 'facets/string'
require 'rake/clean'
project_name = __FILE__.pathmap("%-1d")
def version
project_readme = FileList['README.*']
version_re = /Version \s+ : \s* (?<version> \d\.\d\.\d) $/x
project_readme.each { |f|
File.read(f).mscan(version_re).each { |m|
return m[:version]
}
}
end
desc "version"
task :version => [] do
puts version
end
desc "zip for distribution"
task :zip => [] do
sh "zip -r #{project_name}-#{version}.zip autoload plugin doc README.md --exclude='*/.DS_Store'"
end
CLEAN.include('*.zip')
vimup = File.expand_path('~/Developer/Vim/Bundle/tool/vimup/vimup')
vimorg = File.expand_path('~/.apps/vimup/vim.org.yml')
namespace :vimup do
desc "new vim.org script"
task :new do
sh vimup, 'new-script', project_name, vimorg
end
desc "updae vim.org script"
task :release => [:zip] do
sh vimup, 'update-script', project_name, vimorg
task(:clean).invoke
end
desc "updae vim.org script detail"
task :details do
sh vimup, 'update-details', project_name, vimorg
end
end

View File

@ -1,529 +0,0 @@
" =============== ============================================================
" Name : GoldenView
" Description : Always have a nice view for vim split windows
" Author : Zhao Cai <caizhaoff@gmail.com>
" HomePage : https://github.com/zhaocai/GoldenView.Vim
" Date Created : Tue 18 Sep 2012 10:25:23 AM EDT
" Last Modified : Fri 19 Oct 2012 05:55:17 PM EDT
" Tag : [ vim, window, golden-ratio ]
" Copyright : © 2012 by Zhao Cai,
" Released under current GPL license.
" =============== ============================================================
" ============================================================================
" Initialization And Profile: ⟨⟨⟨1
" ============================================================================
function! GoldenView#ExtendProfile(name, def)
let default = get(s:goldenview__profile, a:name,
\ copy(s:goldenview__profile['default']))
let s:goldenview__profile[a:name] = extend(default, a:def)
endfunction
function! GoldenView#Init()
if exists('g:goldenview__initialized') && g:goldenview__initialized == 1
return
endif
let s:goldenview__golden_ratio = 1.618
lockvar s:goldenview__golden_ratio
set equalalways
set eadirection=ver
let s:goldenview__profile = {
\ 'reset' : {
\ 'focus_window_winheight' : &winheight ,
\ 'focus_window_winwidth' : &winwidth ,
\ 'other_window_winheight' : &winminheight ,
\ 'other_window_winwidth' : &winminwidth ,
\ },
\ 'default' : {
\ 'focus_window_winheight' : function('GoldenView#GoldenHeight') ,
\ 'focus_window_winwidth' : function('GoldenView#TextWidth') ,
\ 'other_window_winheight' : function('GoldenView#GoldenMinHeight') ,
\ 'other_window_winwidth' : function('GoldenView#GoldenMinWidth') ,
\ },
\
\ }
call GoldenView#ExtendProfile('golden-ratio', {
\ 'focus_window_winwidth' : function('GoldenView#GoldenWidth') ,
\ })
let s:goldenview__ignore_nrule = GoldenView#zl#rule#norm(
\ g:goldenview__ignore_urule, {
\ 'logic' : 'or',
\ }
\ )
let s:goldenview__restore_nrule = GoldenView#zl#rule#norm(
\ g:goldenview__restore_urule, {
\ 'logic' : 'or',
\ }
\ )
let g:goldenview__initialized = 1
endfunction
" ============================================================================
" Auto Resize: ⟨⟨⟨1
" ============================================================================
function! GoldenView#ToggleAutoResize()
if exists('s:goldenview__auto_resize') && s:goldenview__auto_resize == 1
call GoldenView#DisableAutoResize()
call GoldenView#zl#print#moremsg('GoldenView Auto Resize: Off')
else
call GoldenView#EnableAutoResize()
call GoldenView#zl#print#moremsg('GoldenView Auto Resize: On')
endif
endfunction
function! GoldenView#EnableAutoResize()
call GoldenView#Init()
let active_profile = s:goldenview__profile[g:goldenview__active_profile]
call s:set_focus_window(active_profile)
call s:set_other_window(active_profile)
augroup GoldenView
au!
" Enter
autocmd VimResized * call GoldenView#Enter({'event' : 'VimResized'})
autocmd BufWinEnter * call GoldenView#Enter({'event' : 'BufWinEnter'})
autocmd WinEnter * call GoldenView#Enter({'event' : 'WinEnter'})
" Leave
autocmd WinLeave * call GoldenView#Leave()
augroup END
let s:goldenview__auto_resize = 1
endfunction
function! GoldenView#DisableAutoResize()
au! GoldenView
call GoldenView#ResetResize()
let s:goldenview__auto_resize = 0
endfunction
function! GoldenView#Leave(...)
" GoldenViewTrace 'WinLeave', a:000
" Do nothing if there is no split window
" --------------------------------------
if winnr('$') < 2
return
endif
call GoldenView#Diff()
if GoldenView#IsIgnore()
" Record the last size of ignored windows. Restore there sizes if affected
" by GoldenView.
" For new split, the size does not count, which is highly possible
" to be resized later. Should use the size with WinLeave event.
"
call GoldenView#initialize_tab_variable()
let t:goldenview['bufs'][bufnr('%')] = {
\ 'winnr' : winnr() ,
\ 'winwidth' : winwidth(0) ,
\ 'winheight' : winheight(0) ,
\ }
let t:goldenview['cmdheight'] = &cmdheight
end
endfunction
function! GoldenView#Diff()
" Diff Mode: auto-resize to equal size
if ! exists('b:goldenview_diff')
let b:goldenview_diff = 0
endif
if &diff
if ! b:goldenview_diff
for nr in GoldenView#zl#list#uniq(tabpagebuflist())
if getbufvar(nr, '&diff')
call setbufvar(nr, 'goldenview_diff', 1)
endif
endfor
exec 'wincmd ='
endif
return 1
else
if b:goldenview_diff
let b:goldenview_diff = 0
endif
endif
return 0
endfunction
function! GoldenView#Enter(...)
if GoldenView#Diff()
return
endif
if &lazyredraw
return
endif
return call('GoldenView#Resize', a:000)
endfunction
function! GoldenView#Resize(...)
"--------- ------------------------------------------------
" Desc : resize focused window
"
" Args : {'event' : event}
" Return : none
"
" Raise : none from this function
"
" Pitfall :
" - Can not set winminwith > winwidth
" - AutoCmd Sequence:
" - `:copen` :
" 1. WinEnter (&ft inherited from last buffer)
" 2. BufWinEnter (&ft == '')
" 3. BufWinEnter (&ft == 'qf', set winfixheight)
" - `:split`
" 1. WinLeave current window
" 2. WinEnter new split window with current buffer
" 3. `split` return, user script may change the buffer
" type, width, etc.
"
"
"--------- ------------------------------------------------
" GoldenViewTrace 'GoldenView Resize', a:000
let opts = {'is_force' : 0}
if a:0 >= 1 && GoldenView#zl#var#is_dict(a:1)
call extend(opts, a:1)
endif
let winnr_diff = s:winnr_diff()
if winnr_diff > 0
" Plus Split Window:
" ++++++++++++++++++
" GoldenViewTrace '+++ winnr +++', a:000
return
elseif winnr_diff < 0
" Minus Split Window:
" -------------------
call GoldenView#initialize_tab_variable()
let saved_lazyredraw = &lazyredraw
set lazyredraw
let current_winnr = winnr()
" Restore: original size based on "g:goldenview__restore_urule"
" ------------------------------------------------------------
for winnr in range(1, winnr('$'))
let bufnr = winbufnr(winnr)
let bufsaved = get(t:goldenview['bufs'], bufnr, {})
" Ignored Case: same buffer displayed in multiply windows
" -------------------------------------------------------
if ! empty(bufsaved) && bufsaved['winnr'] == winnr
silent noautocmd exec winnr 'wincmd w'
if GoldenView#IsRestore()
silent exec 'vertical resize ' . bufsaved['winwidth']
silent exec 'resize ' . bufsaved['winheight']
" GoldenViewTrace 'restore buffer:'. nr, a:000
endif
endif
endfor
if &cmdheight != t:goldenview['cmdheight']
exec 'set cmdheight=' . t:goldenview['cmdheight']
endif
silent exec current_winnr 'wincmd w'
redraw
let &lazyredraw = saved_lazyredraw
" GoldenViewTrace '--- winnr ---', a:000
return
endif
if ! opts['is_force']
" Do nothing if there is no split window
if winnr('$') < 2
return
endif
if GoldenView#IsIgnore()
" GoldenViewTrace 'Ignored', a:000
return
endif
endif
let active_profile = s:goldenview__profile[g:goldenview__active_profile]
call s:set_focus_window(active_profile)
" GoldenViewTrace 'Set Focuse', a:000
" reset focus windows minimal size
let &winheight = &winminheight
let &winwidth = &winminwidth
" GoldenViewTrace 'Reset Focus', a:000
endfunction
function! GoldenView#IsIgnore()
return GoldenView#zl#rule#is_true(s:goldenview__ignore_nrule)
endfunction
function! GoldenView#IsRestore()
return GoldenView#zl#rule#is_true(s:goldenview__restore_nrule)
endfunction
function! GoldenView#ResetResize()
let reset_profile = s:goldenview__profile[g:goldenview__reset_profile]
call s:set_other_window(reset_profile, {'force' : 1})
call s:set_focus_window(reset_profile, {'force' : 1})
endfunction
function! GoldenView#GoldenHeight(...)
return float2nr(&lines / s:goldenview__golden_ratio)
endfunction
function! GoldenView#GoldenWidth(...)
return float2nr(&columns / s:goldenview__golden_ratio)
endfunction
function! GoldenView#GoldenMinHeight(...)
return float2nr(GoldenView#GoldenHeight()/(5*s:goldenview__golden_ratio))
endfunction
function! GoldenView#GoldenMinWidth(...)
return float2nr(GoldenView#GoldenWidth()/(3*s:goldenview__golden_ratio))
endfunction
function! GoldenView#TextWidth(...)
let tw = &l:textwidth
if tw != 0
return float2nr(tw * 4/3)
else
let tw = float2nr(80 * 4/3)
let gw = GoldenView#GoldenWidth()
return tw > gw ? gw : tw
endif
endfunction
function! s:set_focus_window(profile,...)
let opts = {
\ 'force' : 0
\ }
if a:0 >= 1 && GoldenView#zl#var#is_dict(a:1)
call extend(opts, a:1)
endif
try
if !&winfixwidth || opts['force']
let &winwidth =
\ s:eval(a:profile, a:profile['focus_window_winwidth'])
endif
if !&winfixheight || opts['force']
let &winheight =
\ s:eval(a:profile, a:profile['focus_window_winheight'])
endif
catch /^Vim\%((\a\+)\)\=:E36/ " Not enough room
call GoldenView#zl#print#warning('GoldenView: ' . v:exception)
endtry
endfunction
function! s:set_other_window(profile,...)
let opts = {
\ 'force' : 0
\ }
if a:0 >= 1 && GoldenView#zl#var#is_dict(a:1)
call extend(opts, a:1)
endif
try
if !&winfixwidth || opts['force']
let &winminwidth =
\ s:eval(a:profile, a:profile['other_window_winwidth'])
endif
if !&winfixheight || opts['force']
let &winminheight =
\ s:eval(a:profile, a:profile['other_window_winheight'])
endif
catch /^Vim\%((\a\+)\)\=:E36/ " Not enough room
call GoldenView#zl#print#warning('GoldenView: ' . v:exception)
endtry
endfunction
" ============================================================================
" Split: ⟨⟨⟨1
" ============================================================================
function! GoldenView#Split()
call GoldenView#zl#window#split_nicely()
endfunction
" ============================================================================
" Switch: ⟨⟨⟨1
" ============================================================================
function! GoldenView#SwitchMain(...)
let opts = {
\ 'from_bufnr' : bufnr('%') ,
\}
if a:0 >= 1 && type(a:1) == type({})
call extend(opts, a:1)
endif
let window_count = winnr('$')
if window_count < 2
return
endif
let current_winnr = winnr()
let switched = 0
let saved_lazyredraw = &lazyredraw
set lazyredraw
for i in range(1, window_count)
silent noautocmd exec i 'wincmd w'
if ! GoldenView#IsIgnore()
let switched = GoldenView#zl#window#switch_buffer(
\ opts['from_bufnr'], winbufnr(i))
break
endif
endfor
redraw
let &lazyredraw = saved_lazyredraw
if switched
call GoldenView#Resize({'event' : 'WinEnter'})
else
silent noautocmd exec current_winnr 'wincmd w'
endif
endfunction
" ============================================================================
" Helper Functions: ⟨⟨⟨1
" ============================================================================
function! s:eval(profile, val)
if GoldenView#zl#var#is_number(a:val)
return a:val
elseif GoldenView#zl#var#is_funcref(a:val)
return a:val(a:profile)
else
try
return eval(a:val)
catch /^Vim\%((\a\+)\)\=:E/
throw 'GoldenView: invalid profile value type!'
endtry
endif
endfunction
function! GoldenView#initialize_tab_variable()
if !exists('t:goldenview')
let t:goldenview = {
\ 'nrwin' : winnr('$') ,
\ 'cmdheight' : &cmdheight ,
\ 'bufs' : {} ,
\ }
endif
endfunction
function! s:winnr_diff()
call GoldenView#initialize_tab_variable()
let nrwin = winnr('$')
if nrwin != t:goldenview['nrwin']
let diff = nrwin - t:goldenview['nrwin']
let t:goldenview['nrwin'] = nrwin
return diff
else
return 0
endif
endfunction
" ============================================================================
" Debug: ⟨⟨⟨1
" ============================================================================
function! GoldenView#Info()
return {
\ 'buffer' : {
\ 'filetype' : &ft ,
\ 'buftype' : &buftype ,
\ 'bufname' : bufname('%') ,
\ 'winwidth' : winwidth(0) ,
\ 'winheight' : winheight(0) ,
\ },
\ 'goldenview' : get(t:, 'goldenview', GoldenView#initialize_tab_variable()),
\ 'setting' : {
\ 'win_count' : winnr('$') ,
\ 'lazyredraw' : &lazyredraw ,
\ 'cmdheight' : &cmdheight ,
\ 'winfixwidth' : &winfixwidth ,
\ 'winfixheight' : &winfixheight ,
\ 'winwidth' : &winwidth ,
\ 'winminwidth' : &winminwidth ,
\ 'winheight' : &winheight ,
\ 'winminheight' : &winminheight ,
\ }
\}
endfunction
function! GoldenView#Trace(...)
" -------- - -----------------------------------------------
" Example : >
" GoldenViewTrace 'WinLeave', a:000
" -------- - -----------------------------------------------
call GoldenView#initialize_tab_variable()
let info = GoldenView#Info()
let info['context'] = get(g:,'GoldenView_zl_context','')
let info['args'] = a:000
call GoldenView#zl#log#debug(info)
endfunction
command! -nargs=* -complete=expression GoldenViewTrace
\ exec GoldenView#zl#vim#context() | call GoldenView#Trace(<args>)
" ============================================================================
" Modeline: ⟨⟨⟨1
" ============================================================================
" vim: set ft=vim ts=4 sw=4 tw=78 fdm=syntax fmr=⟨⟨⟨,⟩⟩⟩ fdl=1 :

View File

@ -1,126 +0,0 @@
" =============== ============================================================
" Synopsis : list helper functions
" Author : Zhao Cai <caizhaoff@gmail.com>
" HomePage : https://github.com/zhaocai/zl.vim
" Version : 0.1
" Date Created : Sat 03 Sep 2011 03:54:00 PM EDT
" Last Modified : Thu 20 Sep 2012 04:25:10 PM EDT
" Tag : [ vim, list ]
" Copyright : (c) 2012 by Zhao Cai,
" Released under current GPL license.
" =============== ============================================================
" ============================================================================
" Sort: ⟨⟨⟨1
" ============================================================================
function! GoldenView#zl#list#unique_sort(list, ...)
"--------- ------------------------------------------------
" Args : list, [func]
" Return : unique sorted list
" Raise :
"
" Refer : http://vim.wikia.com/wiki/Unique_sorting
"--------- ------------------------------------------------
let list = copy(a:list)
if exists('a:1') && type(a:1) == type(function('function'))
call sort(list, a:1)
else
call sort(list)
endif
if len(list) <= 1 | return list | endif
let result = [ list[0] ]
let last = list[0]
let i = 1
while i < len(list)
if last != list[i]
let last = list[i]
call add(result, last)
endif
let i += 1
endwhile
return result
endfunction
function! GoldenView#zl#list#sort_by(list, expr)
"--------- ------------------------------------------------
" Desc : sort list by expr
"
" Args : v:val is used in {expr}
" Return : sroted list
" Raise :
"
" Example : >
" let list = [{'a' : 1}, {'a' : 22}, {'a' : 3}]
" echo GoldenView#zl#list#sort_by(list, 'v:val["a"]')
"
" Refer : vital.vim
"--------- ------------------------------------------------
let pairs = map(a:list, printf('[v:val, %s]', a:expr))
return map(GoldenView#zl#list#sort(pairs,
\ 'a:a[1] ==# a:b[1] ? 0 : a:a[1] ># a:b[1] ? 1 : -1'),
\ 'v:val[0]')
endfunction
function! s:_compare(a, b)
return eval(s:expr)
endfunction
function! GoldenView#zl#list#sort(list, expr)
"--------- ------------------------------------------------
" Desc : sort list with expr to compare two values.
"
" Args : a:a and a:b can be used in {expr}
" Return : sroted list
" Raise :
"
" Refer : vital.vim
"--------- ------------------------------------------------
if type(a:expr) == type(function('function'))
return sort(a:list, a:expr)
endif
let s:expr = a:expr
return sort(a:list, 's:_compare')
endfunction
function! GoldenView#zl#list#uniq(list, ...)
let list = a:0
\ ? map(copy(a:list), printf('[v:val, %s]', a:1))
\ : copy(a:list)
let i = 0
let seen = {}
while i < len(list)
let key = string(a:0 ? list[i][1] : list[i])
if has_key(seen, key)
call remove(list, i)
else
let seen[key] = 1
let i += 1
endif
endwhile
return a:0 ? map(list, 'v:val[0]') : list
endfunction
" ============================================================================
" Modeline: ⟨⟨⟨1
" ============================================================================
" vim: set ft=vim ts=4 sw=4 tw=78 fdm=marker fmr=⟨⟨⟨,⟩⟩⟩ fdl=1 :

View File

@ -1,310 +0,0 @@
" =============== ============================================================
" Name : log.vim
" Synopsis : vim script library: log
" Author : Zhao Cai <caizhaoff@gmail.com>
" HomePage : https://github.com/zhaocai/zl.vim
" Date Created : Sat 03 Sep 2012 03:54:00 PM EDT
" Last Modified : Sat 27 Apr 2013 06:58:13 PM EDT
" Tag : [ vim, log ]
" Copyright : © 2012 by Zhao Cai,
" Released under current GPL license.
" =============== ============================================================
" ============================================================================
" Logger: [[[1
" ============================================================================
if !has('ruby')
function! GoldenView#zl#log#info(...)
call GoldenView#zl#print#warning("GoldenView(log): require vim to be built with +ruby.")
endfunction
function! GoldenView#zl#log#level_info(...)
call GoldenView#zl#print#warning("GoldenView(log): require vim to be built with +ruby.")
endfunction
function! GoldenView#zl#log#debug(...)
call GoldenView#zl#print#warning("GoldenView(log): require vim to be built with +ruby.")
endfunction
function! GoldenView#zl#log#level_debug(...)
call GoldenView#zl#print#warning("GoldenView(log): require vim to be built with +ruby.")
endfunction
function! GoldenView#zl#log#warn(...)
call GoldenView#zl#print#warning("GoldenView(log): require vim to be built with +ruby.")
endfunction
function! GoldenView#zl#log#level_warn(...)
call GoldenView#zl#print#warning("GoldenView(log): require vim to be built with +ruby.")
endfunction
function! GoldenView#zl#log#error(...)
call GoldenView#zl#print#warning("GoldenView(log): require vim to be built with +ruby.")
endfunction
function! GoldenView#zl#log#level_error(...)
call GoldenView#zl#print#warning("GoldenView(log): require vim to be built with +ruby.")
endfunction
function! GoldenView#zl#log#fatal(...)
call GoldenView#zl#print#warning("GoldenView(log): require vim to be built with +ruby.")
endfunction
function! GoldenView#zl#log#level_fatal(...)
call GoldenView#zl#print#warning("GoldenView(log): require vim to be built with +ruby.")
endfunction
else
function! <SID>get_logfile()
if GoldenView#zl#sys#is_mac()
let logfile = expand('~/Library/Logs/vim/GoldenView.log')
elseif GoldenView#zl#sys#is_win()
let logfile = "C:/windows/temp/vim/GoldenView.log"
elseif GoldenView#zl#sys#is_linux()
let logfile = expand('/var/log/vim/GoldenView.log')
else
let logfile = input('Please Input logfile: ', '/var/log/vim/GoldenView.log', 'file')
endif
let log_dir = fnamemodify(logfile, ':p:h')
if !isdirectory(log_dir)
call mkdir(log_dir, 'p')
endif
return logfile
endfunction
let s:GoldenView_zl_ruby_loaded = 0
function! <SID>setup_ruby()
if s:GoldenView_zl_ruby_loaded == 0
let logfile = <SID>get_logfile()
ruby << __RUBY__
# ($LOAD_PATH << File.join(Vim.evaluate('g:GoldenView_zl_autoload_path'), 'lib')).uniq!
require "logger"
require "awesome_print"
$GoldenView_zl_logger = Logger.new(Vim.evaluate('logfile'), 'weekly')
__RUBY__
autocmd VimLeavePre * call <SID>cleanup_ruby()
let s:GoldenView_zl_ruby_loaded = 1
endif
endfunction
function! <SID>cleanup_ruby()
if s:GoldenView_zl_ruby_loaded
ruby $GoldenView_zl_logger.close
endif
endfunction
" --------------------------------%>--------------------------------
" Example:
" function! Trace(...) abort
" let message = {}
" let message['context'] = get(g:,'GoldenView_zl_context','')
" let message['args'] = a:000
" call GoldenView#zl#log#info(message)
" endfunction
"
" command! -nargs=* -complete=expression Trace
" \ exec GoldenView#zl#vim#context() | call GoldenView#zl#log#info(<args>)
" --------------------------------%<--------------------------------
function! GoldenView#zl#log#info(...)
call <SID>setup_ruby()
ruby << __RUBY__
args = Vim.evaluate('a:000')
case args.size
when 0
return
when 1
$GoldenView_zl_logger.info("GoldenView") { args[0].ai(:plain => true) }
when 2
$GoldenView_zl_logger.info(args[0]) { args[1].ai(:plain => true) }
else
$GoldenView_zl_logger.info(args[0]) { args[1].ai(:plain => true) }
end
__RUBY__
endfunction
function! GoldenView#zl#log#level_info()
ruby $GoldenView_zl_logger.level = Logger::INFO
endfunction
function! GoldenView#zl#log#debug(...)
call <SID>setup_ruby()
ruby << __RUBY__
args = Vim.evaluate('a:000')
case args.size
when 0
return
when 1
$GoldenView_zl_logger.debug("GoldenView") { args[0].ai(:plain => true) }
when 2
$GoldenView_zl_logger.debug(args[0]) { args[1].ai(:plain => true) }
else
$GoldenView_zl_logger.debug(args[0]) { args[1].ai(:plain => true) }
end
__RUBY__
endfunction
function! GoldenView#zl#log#level_debug()
ruby $GoldenView_zl_logger.level = Logger::DEBUG
endfunction
function! GoldenView#zl#log#warn(...)
call <SID>setup_ruby()
ruby << __RUBY__
args = Vim.evaluate('a:000')
case args.size
when 0
return
when 1
$GoldenView_zl_logger.warn("GoldenView") { args[0].ai(:plain => true) }
when 2
$GoldenView_zl_logger.warn(args[0]) { args[1].ai(:plain => true) }
else
$GoldenView_zl_logger.warn(args[0]) { args[1].ai(:plain => true) }
end
__RUBY__
endfunction
function! GoldenView#zl#log#level_warn()
ruby $GoldenView_zl_logger.level = Logger::WARN
endfunction
function! GoldenView#zl#log#error(...)
call <SID>setup_ruby()
ruby << __RUBY__
args = Vim.evaluate('a:000')
case args.size
when 0
return
when 1
$GoldenView_zl_logger.error("GoldenView") { args[0].ai(:plain => true) }
when 2
$GoldenView_zl_logger.error(args[0]) { args[1].ai(:plain => true) }
else
$GoldenView_zl_logger.error(args[0]) { args[1].ai(:plain => true) }
end
__RUBY__
endfunction
function! GoldenView#zl#log#level_error()
ruby $GoldenView_zl_logger.level = Logger::ERROR
endfunction
function! GoldenView#zl#log#fatal(...)
call <SID>setup_ruby()
ruby << __RUBY__
args = Vim.evaluate('a:000')
case args.size
when 0
return
when 1
$GoldenView_zl_logger.fatal("GoldenView") { args[0].ai(:plain => true) }
when 2
$GoldenView_zl_logger.fatal(args[0]) { args[1].ai(:plain => true) }
else
$GoldenView_zl_logger.fatal(args[0]) { args[1].ai(:plain => true) }
end
__RUBY__
endfunction
function! GoldenView#zl#log#level_fatal()
ruby $GoldenView_zl_logger.level = Logger::FATAL
endfunction
endif
" ============================================================================
" Modeline: [[[1
" ============================================================================
" vim: set ts=4 sw=4 tw=78 fdm=marker fmr=[[[,]]] fdl=1 :

View File

@ -1,69 +0,0 @@
" =============== ============================================================
" Name : print.vim
" Synopsis : vim script library: print
" Author : Zhao Cai <caizhaoff@gmail.com>
" HomePage : https://github.com/zhaocai/zl.vim
" Date Created : Sat 03 Sep 2011 03:54:00 PM EDT
" Last Modified : Thu 20 Sep 2012 04:25:11 PM EDT
" Tag : [ vim, print ]
" Copyright : © 2012 by Zhao Cai,
" Released under current GPL license.
" =============== ============================================================
" ============================================================================
" Echo Message: ⟨⟨⟨1
" ============================================================================
function! GoldenView#zl#print#echomsg(message, ...)
"--------- ------------------------------------------------
" Desc : echomsg wrapper
"
" Args :
" - message to print
" - opts : >
" {
" 'hl' : 'MoreMsg' ,
" }
" Return :
" Raise :
"--------- ------------------------------------------------
if empty(a:message) | return | endif
let opts = {
\ 'hl' : 'MoreMsg',
\ }
if a:0 >= 1 && type(a:1) == type({})
call extend(opts, a:1)
endif
execute 'echohl ' . opts.hl
for m in split(a:message, "\n")
echomsg m
endfor
echohl NONE
endfunction
function! GoldenView#zl#print#warning(message)
call GoldenView#zl#print#echomsg(a:message, {'hl':'WarningMsg'})
endfunction
function! GoldenView#zl#print#error(message)
call GoldenView#zl#print#echomsg(a:message, {'hl':'ErrorMsg'})
endfunction
function! GoldenView#zl#print#moremsg(message)
call GoldenView#zl#print#echomsg(a:message, {'hl':'MoreMsg'})
endfunction
" ============================================================================
" Modeline: ⟨⟨⟨1
" ============================================================================
" vim: set ts=4 sw=4 tw=78 fdm=marker fmr=⟨⟨⟨,⟩⟩⟩ fdl=1 :

View File

@ -1,222 +0,0 @@
" =============== ============================================================
" Description : vim script library
" Author : Zhao Cai <caizhaoff@gmail.com>
" HomePage : https://github.com/zhaocai/zl.vim
" Date Created : Mon 03 Sep 2012 09:05:14 AM EDT
" Last Modified : Thu 18 Apr 2013 03:16:39 PM EDT
" Tag : [ vim, library ]
" Copyright : © 2012 by Zhao Cai,
" Released under current GPL license.
" =============== ============================================================
" ============================================================================
" Initialization: [[[1
" ============================================================================
let s:GOLDENVIEW_ZL_VERSION_CURRENT = 140
let s:VERSION_FACTOR = str2float('0.01')
function! GoldenView#zl#rc#init() abort
if exists('g:loaded_GoldenView_zl')
return
endif
if v:version < 700
echoerr "zl.vim: requires Vim >= 7"
return
endif
if !exists("g:GoldenView_zl_force_reload")
let g:GoldenView_zl_force_reload = 0
endif
if !exists("g:GoldenView_zl_debug_mode")
let g:GoldenView_zl_debug_mode = 0
endif
let g:loaded_GoldenView_zl = s:GOLDENVIEW_ZL_VERSION_CURRENT * s:VERSION_FACTOR
endfunction
function! GoldenView#zl#rc#load_guard(prefix, vim_version, GoldenView_zl_version,exprs,...)
"--------- ------------------------------------------------
" Desc : gereric script load guard function
"
" Args :
" - prefix : to generate loaded_var_name
" - vim_version : minmium vim version requirement
" - GoldenView_zl_version : minmium zl.vim version requirement.
" set 0 to ignore.
" - exprs : assert list of expresses to be true
" - ... scope : 'g' , 'b', ...
"
" Return :
" - 1 : unloaded
" - 0 : already loaded
"
" Raise :
"
" Example : >
" try | if !GoldenView#zl#rc#load_guard(expand('<sfile>:t:r'), 703, 140, ['!&cp'])
" finish
" endif
" catch /^Vim\%((\a\+)\)\=:E117/
" " E117: Unknown Function
" throw 'zl.vim is required!'
" endtry
"
" Details :
" g:loaded_{script name} is defined as 1 if:
" - vim version > 702
" - zl version > 100
" - test !&cp is true
"
" Refer :
"--------- ------------------------------------------------
" call Dfunc('GoldenView#zl#rc#load_guard(' . a:prefix .' '. a:vim_version .' '. a:GoldenView_zl_version .' '. join(a:exprs))
let l:scope = a:0 >= 1 ? a:1 : 'g'
let l:loaded_var_name = l:scope . ':loaded_'
\ . substitute(a:prefix, '[^0-9a-zA-Z_]', '_', 'g')
" call Decho("loaded_var_name: " . l:loaded_var_name)
if exists(l:loaded_var_name) && g:GoldenView_zl_force_reload == 0
" call Decho(l:loaded_var_name . ' loaded: return 0')
" call Dret('GoldenView#zl#rc#load_guard')
return 0
endif
if a:vim_version > 0 && a:vim_version > v:version
echoerr l:loaded_var_name . ' requires Vim version '
\ . string(a:vim_version * s:VERSION_FACTOR)
return 0
elseif a:GoldenView_zl_version > 0
if !exists("g:loaded_GoldenView_zl")
echoerr 'zl.vim is required but not loaded'
return 0
endif
if (a:GoldenView_zl_version > s:GOLDENVIEW_ZL_VERSION_CURRENT)
echoerr l:loaded_var_name . ' requires zl library version '
\ . string(a:GoldenView_zl_version * s:VERSION_FACTOR)
return 0
endif
endif
for expr in a:exprs
if !eval(expr)
echoerr l:loaded_var_name . ' requires: ' . expr
" call Dret('GoldenView#zl#rc#load_guard')
return 0
endif
endfor
let {l:loaded_var_name} = 1
" call Dret('GoldenView#zl#rc#load_guard')
return 1
endfunction
function! GoldenView#zl#rc#script_force_reload(...)
"--------- ------------------------------------------------
" Desc : Call to ignore GoldenView#zl#rc#load_guard() and source.
"
" Args : script path or current script by default
" Return :
" Raise : E484: cannot open file
"
"--------- ------------------------------------------------
let script = a:0 >= 1 ? a:1 : '%'
let l:saved = g:GoldenView_zl_force_reload
let g:GoldenView_zl_force_reload = 1
exec "so " . script
let g:GoldenView_zl_force_reload = l:saved
endfunction
function! GoldenView#zl#rc#init_python()
if has("python3")
let g:GoldenView_zl_py = 'py3'
let g:GoldenView_zl_pyeval = 'py3eval'
elseif has("python")
let g:GoldenView_zl_py = 'py'
let g:GoldenView_zl_pyeval = 'pyeval'
else
let g:GoldenView_zl_py = ''
let g:GoldenView_zl_pyeval = ''
endif
endfunction
" ============================================================================
" Set Initialization Default Variables: [[[1
" ============================================================================
function! GoldenView#zl#rc#set_default(var, ...)
"--------- ------------------------------------------------
" Desc : Set Initialization Default Variables
"
" Args : ('var', val) || ( {dict} )
" Return :
" Raise : 'zl.vim ***'
"
" Pitfall : avoid 's:' variables, which will be defined in
" this rc.vim script bur your script
"
" Example : >
" call GoldenView#zl#rc#set_default({
" \ 'g:xxx_yyy' : {
" \ 'abc' : 1,
" \ }
" \
" \ , 'g:yyy_zzz' : 'bcd'
" \ })
"--------- ------------------------------------------------
if type(a:var) == type({})
for key in keys(a:var)
call <SID>set_default(key, a:var[key])
endfor
elseif type(a:var) == type("")
if a:0 >= 1
call <SID>set_default(a:var, a:1)
else
throw "zl.vim should call with default value for " . a:var
endif
else
throw "zl.vim unsupported type: " . type(a:var)
endif
endfunction
function! s:set_default(var,val)
if !exists(a:var) || type({a:var}) != type(a:val)
let {a:var} = a:val
endif
endfunction
"
" Note:
" add this call to other files if they need to check g:loaded_GoldenView_zl
" or g:GoldenView_zl_install_path
"
call GoldenView#zl#rc#init()
" ============================================================================
" Modeline: [[[1
" ============================================================================
" vim: set ft=vim ts=4 sw=4 tw=78 fdm=marker fmr=[[[,]]] fdl=1 :

View File

@ -1,94 +0,0 @@
" =============== ============================================================
" Name : regex.vim
" Description : vim library: Regular Expression
" Author : Zhao Cai <caizhaoff@gmail.com>
" HomePage : https://github.com/zhaocai/zl.vim
" Date Created : Mon 03 Sep 2012 09:05:14 AM EDT
" Last Modified : Thu 20 Sep 2012 04:25:12 PM EDT
" Tag : [ vim, library, regex ]
" Copyright : © 2012 by Zhao Cai,
" Released under current GPL license.
" =============== ============================================================
" ============================================================================
" Regex Escape: ⟨⟨⟨1
" ============================================================================
function! GoldenView#zl#regex#escape(text, ...) " (text, ?magic='m') ⟨⟨⟨2
"--------- ------------------------------------------------
" Desc : escape common special characters.
"
" Args :
"
" - text to escape
" - magic : one of m, M, v, V. See :help 'magic'
"
" Return : escaped text
" Raise :
"
" Example : echo GoldenView#zl#regex#escape('I|||love&you\\\', 'v')
"
" Refer :
"--------- ------------------------------------------------
let l:magic = a:0 >= 1 ? a:1 : 'm'
if l:magic =~# '^\\\?m$'
return escape(a:text, '^$.*\[]~')
elseif l:magic =~# '^\\\?M$'
return escape(a:text, '^$\')
elseif l:magic =~# '^\\\?V$'
return escape(a:text, '\')
elseif l:magic =~# '^\\\?v$'
return substitute(a:text, '[^0-9a-zA-Z_]', '\\&', 'g')
else
throw 'unsupported magic type'
return a:text
endif
endfunction " ⟩⟩⟩
" ----------------------------------------------------------------------------
" Regex Builder: ⟨⟨⟨1
function! GoldenView#zl#regex#or(list, ...) "⟨⟨⟨
let opts =
\ { 'is_capturing' : 0
\ , 'magic' : 'm'
\ }
if a:0 >= 1 && GoldenView#zl#var#is_dict(a:1)
call extend(opts, a:1)
endif
let begin = opts['is_capturing'] ? '\(' : '\%('
let or = '\|'
let end = '\)'
if opts['magic'] =~# '^\\\?v$'
let begin = opts['is_capturing'] ? '(' : '%('
let or = '|'
let end = ')'
endif
return begin
\ . join(map(
\ a:list, 'GoldenView#zl#regex#escape(v:val, "' . opts['magic'] . '")'),
\ or)
\ . end
endfunction "⟩⟩⟩
" ⟩⟩⟩
" ============================================================================
" Modeline: ⟨⟨⟨1
" ============================================================================
" vim: set ft=vim ts=4 sw=4 tw=78 fdm=marker fmr=⟨⟨⟨,⟩⟩⟩ fdl=1 :

View File

@ -1,331 +0,0 @@
" =============== ============================================================
" Name : rule.vim
" Synopsis : vim script library: rule
" Author : Zhao Cai <caizhaoff@gmail.com>
" HomePage : https://github.com/zhaocai/zl.vim
" Date Created : Sat 03 Sep 2011 03:54:00 PM EDT
" Last Modified : Sat 29 Sep 2012 01:03:24 AM EDT
" Tag : [ vim, rule ]
" Copyright : © 2012 by Zhao Cai,
" Released under current GPL license.
" =============== ============================================================
" ============================================================================
" Rule: [[[1
" ============================================================================
" [TODO]( list for at type ) @zhaocai @start(2012-09-27 08:05)
let s:rule_types = [
\ 'filetype', 'buftype', 'mode' , 'cword',
\ 'bufname' , 'at' , 'syntax', 'expr' ,
\ ]
let s:nrule = {
\ 'eval_order' : copy(s:rule_types),
\ 'eval_negate' : [] ,
\ 'logic' : 'or' ,
\ 'rule' : {} ,
\ }
function! GoldenView#zl#rule#norm(urule, ...)
"--------- ------------------------------------------------
" Desc : normalize rules
"
" Rule :
" - "urule" : "Unnormalized RULE", rules written by users.
" - "nrule" : "Nnormalized RULE", rules completed with
" optional items and internal items.
"
" Args :
" - urule: un-normalized rule
" - opts :
" - eval_order : order in s:rule_types,
" - eval_negate : reverse eval result
" - logic :
" - {or} : 'v:filetype || v:bufname || ...'
" - {and} : 'v:filetype && v:bufname && ...'
" - {string} : similar to v:val for filter()
"
" Return : normalized rules
" Raise :
"
" Example : >
"
" Refer :
"--------- ------------------------------------------------
let nrule = deepcopy(s:nrule)
if a:0 >= 1 && GoldenView#zl#var#is_dict(a:1)
call extend(nrule, a:1)
endif
let type_expr = {
\ 'buftype' : '&buftype' ,
\ 'filetype' : '&ft' ,
\ 'bufname' : "bufname('%')" ,
\ 'cword' : "expand('<cword>')" ,
\ }
let type_pat = {}
for type in ['filetype', 'buftype', 'syntax']
if has_key(a:urule, type)
let type_pat[type] = '^\%(' . join(a:urule[type], '\|') . '\)$'
endif
endfor
for type in ['bufname', 'cword']
if has_key(a:urule, type)
let type_pat[type] = '^\%('
\ . join(map(a:urule[type], 'GoldenView#zl#regex#escape(v:val)'), '\|')
\ . '\)$'
endif
endfor
" normalize each type of rules
for type in ['mode']
if has_key(a:urule, type)
let nrule.rule[type] = a:urule[type]
endif
endfor
for type in ['filetype', 'buftype', 'bufname', 'cword']
if has_key(a:urule, type)
let nrule.rule[type] =
\ {
\ 'eval_expr' : 1 ,
\ 'expr' : type_expr[type] ,
\ 'pat' : type_pat[type] ,
\ }
endif
endfor
for type in ['syntax']
if has_key(a:urule, type)
let nrule.rule[type] = type_pat[type]
endif
endfor
for type in ['mode', 'at']
if has_key(a:urule, type)
let nrule.rule[type] = a:urule[type]
endif
endfor
for type in ['expr']
if has_key(a:urule, type)
try | let nrule.rule[type] =
\ join(
\ map(
\ map(
\ copy(a:urule[type])
\ ,"join(v:val,' || ')"
\ )
\ , "'('.v:val.')'"
\ )
\ ,' && '
\ )
catch /^Vim\%((\a\+)\)\=:E714/ " E714: List required
throw 'zl(rule): expr rule should be written as list of lists.'
endtry
endif
endfor
call filter(
\ nrule['eval_order']
\ , 'has_key(nrule.rule, v:val) && !empty(nrule.rule[v:val])'
\ )
return nrule
endfunction
function! GoldenView#zl#rule#is_true(nrule, ...)
try
return call('GoldenView#zl#rule#logic_'.a:nrule['logic'], [a:nrule] + a:000)
catch /^Vim\%((\a\+)\)\=:E129/
throw 'zl(rule): undefined logic funcref'
endtry
endfunction
function! GoldenView#zl#rule#is_false(nrule, ...)
return !call('GoldenView#zl#rule#is_true', [a:nrule] + a:000)
endfunction
" rule logic
function! s:_return(nrule, type, ret)
return
\ index(a:nrule.eval_negate, a:type) >= 0
\ ? !a:ret
\ : a:ret
endfunction
function! GoldenView#zl#rule#logic_or(nrule, ...)
let opts = {}
if a:0 >= 1 && GoldenView#zl#var#is_dict(a:1)
call extend(opts, a:1)
endif
for type in a:nrule['eval_order']
if s:_return(a:nrule, type, s:eval_{type}(a:nrule['rule'], opts))
return 1
endif
endfor
return 0
endfunction
function! GoldenView#zl#rule#logic_and(nrule, ...)
let opts = {}
if a:0 >= 1 && GoldenView#zl#var#is_dict(a:1)
call extend(opts, a:1)
endif
for type in a:nrule['eval_order']
if !s:_return(a:nrule, type, s:eval_{type}(a:nrule['rule'], opts))
return 0
endif
endfor
return 1
endfunction
function! GoldenView#zl#rule#logic_expr(nrule, ...)
let opts = {}
if a:0 >= 1 && GoldenView#zl#var#is_dict(a:1)
call extend(opts, a:1)
endif
let str = a:nrule['expr']
for type in a:nrule['eval_order']
let str = substitute(str
\ , 'v:'.type
\ , string(
\ s:_return(a:nrule, type,
\ s:eval_{type}(a:nrule['rule'], opts)
\ )
\ )
\ , 'ge'
\ )
endfor
try
return eval(str)
catch /^Vim\%((\a\+)\)\=:E/
throw printf('zl(rule): eval(%s) raises %s', str, v:exception)
endtry
endfunction
" nrule eval
function! s:eval_filetype(nrule, ...)
return call('s:_eval_match', ['filetype', a:nrule] + a:000)
endfunction
function! s:eval_cword(nrule, ...)
return call('s:_eval_match', ['cword', a:nrule] + a:000)
endfunction
function! s:eval_buftype(nrule, ...)
return call('s:_eval_match', ['buftype', a:nrule] + a:000)
endfunction
function! s:eval_bufname(nrule, ...)
return call('s:_eval_match', ['bufname', a:nrule] + a:000)
endfunction
function! s:eval_at(nrule, ...)
return search(get(a:nrule, 'at', '\%#'), 'bcnW')
endfunction
function! s:eval_mode(nrule, ...)
let mode_pat = get(a:nrule, 'mode', [])
let mode_expr =
\ a:0 >= 1 && GoldenView#zl#var#is_dict(a:1)
\ ? get(a:1, 'mode', mode())
\ : mode()
return
\ !empty(
\ filter(
\ mode_pat
\ , 'stridx(mode_expr, v:val) == -1'
\ )
\ )
endfunction
function! s:eval_syntax(nrule, ...)
let pat = get(a:nrule, 'syntax', '')
let opts = {}
if a:0 >= 1 && GoldenView#zl#var#is_dict(a:1)
call extend(opts, a:1)
endif
let syn_names = GoldenView#zl#syntax#synstack_names(opts)
return !empty(filter(syn_names, 'match(v:val, pat) != -1'))
endfunction
function! s:eval_expr(nrule, ...)
try
return eval(get(a:nrule, 'expr', 1))
catch /^Vim\%((\a\+)\)\=:E/
return 0
endtry
endfunction
function! s:_eval_match(type, nrule, ...)
"--------- ------------------------------------------------
" Desc : internal match evluation
" Rule :
" { 'type' :
" {
" 'eval_expr' : (1|0) ,
" 'expr' : {expr} ,
" 'pat' : {pat} ,
" }
" }
"
" Args : [{type}, {nrule}[, {opts}]]
" Return :
" - 0 : false
" - 1 : true
" Raise : zl(rule)
"
" Refer : vimhelp:match()
"--------- ------------------------------------------------
let rule = copy(get(a:nrule, a:type, {}))
if empty(rule)
throw 'zl(rule): ' . v:exception
endif
" opt for {expr} from runtime opts
if a:0 >= 1 && GoldenView#zl#var#is_dict(a:1) && has_key(a:1, a:type)
let rt_rule = a:1[a:type]
if GoldenView#zl#var#is_dict(rt_rule)
call extend(rule, rt_rule)
elseif GoldenView#zl#var#is_string(rt_rule)
let rule['expr'] = rt_rule
let rule['eval_expr'] = 0
endif
endif
if rule['eval_expr']
let rule['expr'] = eval(rule['expr'])
endif
try
return call('match', [rule['expr'], rule['pat']]) != -1
catch /^Vim\%((\a\+)\)\=:E/
throw 'zl(rule): ' . v:exception
endtry
endfunction
" ============================================================================
" Modeline: [[[1
" ============================================================================
" vim: set ft=vim ts=4 sw=4 tw=78 fdm=marker fmr=[[[,]]] fdl=1 :

View File

@ -1,78 +0,0 @@
" =============== ============================================================
" Name : sys.vim
" Description : vim library
" Author : Zhao Cai <caizhaoff@gmail.com>
" HomePage : https://github.com/zhaocai/zl.vim
" Date Created : Mon 03 Sep 2012 09:05:14 AM EDT
" Last Modified : Thu 20 Sep 2012 04:25:15 PM EDT
" Tag : [ vim, library ]
" Copyright : © 2012 by Zhao Cai,
" Released under current GPL license.
" =============== ============================================================
" ============================================================================
" Environment: [[[1
" ============================================================================
function! GoldenView#zl#sys#ostype()
"--------- ------------------------------------------------
" Args :
" Return :
" - Mac, Windows, Linux, FreeBSD, SunOS, Unix,
" - undefined
" Raise :
"
" Example : >
" call GoldenView#zl#rc#set_default('g:os_type', GoldenView#zl#sys#ostype())
"--------- ------------------------------------------------
if (has("win32") || has("win95") || has("win64") || has("win16"))
let s:os_type = "Windows"
elseif has('mac')
let s:os_type="Mac"
elseif has('unix')
let arch = system("uname | tr -d '\n'")
if ( arch=="Linux" )
let s:os_type="Linux"
elseif ( arch=="FreeBSD" )
let s:os_type="FreeBSD"
elseif ( arch=="SunOS" )
let s:os_type="SunOS"
elseif ( arch=="Darwin" )
let s:os_type="Mac"
else
let s:os_type="Unix"
endif
endif
return s:os_type
endfunction
function! GoldenView#zl#sys#is_cygwin()
return s:is_cygwin
endfunction
function! GoldenView#zl#sys#is_win()
return s:os_type == 'Windows'
endfunction
function! GoldenView#zl#sys#is_mac()
return s:os_type == 'Mac'
endfunction
function! GoldenView#zl#sys#is_linux()
return s:os_type == 'Linux'
endfunction
let s:os_type = GoldenView#zl#sys#ostype()
let s:is_cygwin = has('win32unix')
" ============================================================================
" Modeline: [[[1
" ============================================================================
" vim: set ft=vim ts=4 sw=4 tw=78 fdm=marker fmr=[[[,]]] fdl=1 :

View File

@ -1,86 +0,0 @@
" =============== ============================================================
" Name : var.vim
" Synopsis : vim script library: variable
" Author : Zhao Cai <caizhaoff@gmail.com>
" HomePage : https://github.com/zhaocai/zl.vim
" Date Created : Sat 03 Sep 2011 03:54:00 PM EDT
" Last Modified : Thu 20 Sep 2012 04:25:16 PM EDT
" Tag : [ vim, variable ]
" Copyright : © 2012 by Zhao Cai,
" Released under current GPL license.
" =============== ============================================================
" ============================================================================
" Type: [[[1
" ============================================================================
"--------- ------------------------------------------------
" Desc : Wrapper functions for type()
"
" Refer : vital.vim
"--------- ------------------------------------------------
let [
\ s:__TYPE_NUMBER,
\ s:__TYPE_STRING,
\ s:__TYPE_FUNCREF,
\ s:__TYPE_LIST,
\ s:__TYPE_DICT,
\ s:__TYPE_FLOAT
\] = [
\ type(3),
\ type(""),
\ type(function('tr')),
\ type([]),
\ type({}),
\ has('float') ? type(str2float('0')) : -1
\]
" __TYPE_FLOAT = -1 when -float
" This doesn't match to anything.
" Number or Float
function! GoldenView#zl#var#is_numeric(Value)
let _ = type(a:Value)
return _ ==# s:__TYPE_NUMBER
\ || _ ==# s:__TYPE_FLOAT
endfunction
" Number
function! GoldenView#zl#var#is_integer(Value)
return type(a:Value) ==# s:__TYPE_NUMBER
endfunction
function! GoldenView#zl#var#is_number(Value)
return type(a:Value) ==# s:__TYPE_NUMBER
endfunction
" Float
function! GoldenView#zl#var#is_float(Value)
return type(a:Value) ==# s:__TYPE_FLOAT
endfunction
" String
function! GoldenView#zl#var#is_string(Value)
return type(a:Value) ==# s:__TYPE_STRING
endfunction
" Funcref
function! GoldenView#zl#var#is_funcref(Value)
return type(a:Value) ==# s:__TYPE_FUNCREF
endfunction
" List
function! GoldenView#zl#var#is_list(Value)
return type(a:Value) ==# s:__TYPE_LIST
endfunction
" Dictionary
function! GoldenView#zl#var#is_dict(Value)
return type(a:Value) ==# s:__TYPE_DICT
endfunction
" ============================================================================
" Modeline: [[[1
" ============================================================================
" vim: set ft=vim ts=4 sw=4 tw=78 fdm=marker fmr=[[[,]]] fdl=1 :

View File

@ -1,50 +0,0 @@
" =============== ============================================================
" Description : vim library: vim
" Author : Zhao Cai <caizhaoff@gmail.com>
" HomePage : https://github.com/zhaocai/zl.vim
" Date Created : Mon 03 Sep 2012 09:05:14 AM EDT
" Last Modified : Thu 20 Sep 2012 06:01:48 PM EDT
" Tag : [ vim, library, debug ]
" Copyright : © 2012 by Zhao Cai,
" Released under current GPL license.
" =============== ============================================================
" ============================================================================
" Context: [[[1
" ============================================================================
function! GoldenView#zl#vim#context()
" -------- - -----------------------------------------------
" Desc : generate context
"
" Example : >
" function BeTraced(...)
" exec GoldenView#zl#vim#context() | call XXX#Trace(a:000)
" endfunction
"
" function XXX#Trace(...)
" let context = g:GoldenView_zl_context
" "...
" endfunction
" Refer :
" -------- - -----------------------------------------------
return
\'try
\| throw ""
\|catch
\| let g:GoldenView_zl_context = v:throwpoint
\|endtry
\'
endfunction
" ============================================================================
" Modeline: [[[1
" ============================================================================
" vim: set ft=vim ts=4 sw=4 tw=78 fdm=marker fmr=[[[,]]] fdl=1 :

View File

@ -1,432 +0,0 @@
" =============== ============================================================
" Name : window.vim
" Synopsis : vim script library: window
" Author : Zhao Cai <caizhaoff@gmail.com>
" HomePage : https://github.com/zhaocai/zl.vim
" Version : 0.1
" Date Created : Sat 03 Sep 2011 03:54:00 PM EDT
" Last Modified : Tue 23 Oct 2012 04:59:06 PM EDT
" Tag : [ vim, syntax ]
" Copyright : © 2012 by Zhao Cai,
" Released under current GPL license.
" =============== ============================================================
" ============================================================================
" Status: ⟨⟨⟨1
" ============================================================================
call GoldenView#zl#rc#set_default({
\ 'g:GoldenView_zl_window__ignore_urule' : {
\ 'filetype' : [
\ '' ,
\ 'qf' , 'vimpager', 'undotree', 'tagbar',
\ 'nerdtree', 'vimshell', 'vimfiler', 'voom' ,
\ 'tabman' , 'unite' , 'quickrun', 'Decho' ,
\ ],
\ 'buftype' : [
\ 'nofile' ,
\ ],
\ 'bufname' : [
\ 'GoToFile' , 'diffpanel_\d\+' ,
\ '__Gundo_Preview__' , '__Gundo__' ,
\ '\[LustyExplorer-Buffers\]' , '\-MiniBufExplorer\-' ,
\ '_VOOM\d\+$' , '__Urannotate_\d\+__' ,
\ '__MRU_Files__' ,
\ ],
\ },
\ })
let s:GoldenView_zl_window__ignore_nrule = GoldenView#zl#rule#norm(
\ g:GoldenView_zl_window__ignore_urule, {
\ 'logic' : 'or',
\ }
\ )
function! GoldenView#zl#window#is_last_visible()
"--------- ------------------------------------------------
" Desc : check if no visible buffer left
"
" Args :
"
" Return :
" - 0 : false
" - 1 : true
" Raise :
"
"--------- ------------------------------------------------
for i in range(tabpagenr('$'))
let tabnr = i + 1
for bufnr in tabpagebuflist(tabnr)
let ft = getbufvar(bufnr, '&ft')
let buftype = getbufvar(bufnr, '&buftype')
if empty(ft) && empty(buftype)
continue
endif
if ! GoldenView#zl#rule#is_true(s:GoldenView_zl_window__ignore_nrule)
return 0
endif
endfor
endfor
return 1
endfunction
" ============================================================================
" Move: ⟨⟨⟨1
" ============================================================================
let s:golden_ratio = 1.618
function! GoldenView#zl#window#next_window_or_tab()
if tabpagenr('$') == 1 && winnr('$') == 1
call GoldenView#zl#window#split_nicely()
elseif winnr() < winnr("$")
wincmd w
else
tabnext
wincmd w
endif
endfunction
function! GoldenView#zl#window#previous_window_or_tab()
if winnr() > 1
wincmd W
else
tabprevious
execute winnr("$") . "wincmd w"
endif
endfunction
" ============================================================================
" Size: ⟨⟨⟨1
" ============================================================================
function! GoldenView#zl#window#golden_ratio_width()
return float2nr(&columns / s:golden_ratio)
endfunction
function! GoldenView#zl#window#golden_ratio_height()
return float2nr(&lines / s:golden_ratio)
endfunction
function! GoldenView#zl#window#textwidth()
return &tw == 0 ? 78 : &tw
endfunction
" ============================================================================
" Split: ⟨⟨⟨1
" ============================================================================
function! GoldenView#zl#window#nicely_split_cmd(...)
let opts = {
\ 'winnr' : 0 ,
\}
if a:0 >= 1 && type(a:1) == type({})
call extend(opts, a:1)
endif
let ww = winwidth(opts['winnr'])
let tw = &textwidth
if tw != 0 && ww > s:golden_ratio * tw
return 'vsplit'
endif
if ww > &columns / s:golden_ratio
return 'vsplit'
endif
return 'split'
endfunction
function! GoldenView#zl#window#split_nicely()
let split_cmd = GoldenView#zl#window#nicely_split_cmd()
try
exec split_cmd
catch /^Vim\%((\a\+)\)\=:E36/
if split_cmd == 'split'
let &winminheight = &winminheight / 2
else
let &winminwidth = &winminwidth / 2
endif
exec split_cmd
endtry
wincmd p
endfunction
function! GoldenView#zl#window#toggle_split()
let prev_name = winnr()
silent! wincmd w
if prev_name == winnr()
split
else
call GoldenView#zl#buf#quit()
endif
endfunction
" ============================================================================
" Sort: ⟨⟨⟨1
" ============================================================================
function! GoldenView#zl#window#sort_by(...)
"--------- ------------------------------------------------
" Desc : sort buffer by size, height, or width
"
" Args :
" - opts : > ↓
" {
" 'by' : size|height|width|winnr|bufnr ,
" 'tabnr' : tabpagenr() ,
" 'width_weight' : s:golden_ratio ,
" 'height_weight' : 1 ,
" }
"
" Return : sorted list of
" {
" 'bufnr' : bufnr ,
" 'winnr' : winnr ,
" 'width' : width ,
" 'height' : height ,
" 'size' : size ,
" }
"
" Raise :
"
"--------- ------------------------------------------------
let opts = {
\ 'by' : 'size' ,
\ 'tabnr' : tabpagenr() ,
\ 'width_weight' : s:golden_ratio ,
\ 'height_weight' : 1 ,
\}
if a:0 >= 1 && type(a:1) == type({})
call extend(opts, a:1)
endif
let list = []
for bufnr in tabpagebuflist(opts['tabnr'])
let winnr = bufwinnr(bufnr)
let width = winwidth(winnr)
let height = winheight(winnr)
let size = width * opts['width_weight']
\ + height * opts['height_weight']
call add(list, {
\ 'bufnr' : bufnr ,
\ 'winnr' : winnr ,
\ 'width' : width ,
\ 'height' : height ,
\ 'size' : size ,
\ })
endfor
return GoldenView#zl#list#sort_by(list,'v:val["'.opts['by'].'"]')
endfunction
" ============================================================================
" Switch: ⟨⟨⟨1
" ============================================================================
function! GoldenView#zl#window#switch_buffer_toggle(...)
"--------- ------------------------------------------------
" Desc : toggle buffer switch
"
" Args :
" - opts : >
" {
" 'with' : 'largest' ,
" }
"
" Return :
" Raise :
"
" Example : >
" nnoremap <silent> <C-@>
" \ :<C-u>call GoldenView#zl#window#switch_buffer_toggle()<CR>
"--------- ------------------------------------------------
let opts = {
\ 'with' : 'largest',
\}
if a:0 >= 1 && type(a:1) == type({})
call extend(opts, a:1)
endif
let bufnr = bufnr('%')
if exists('b:switch_buffer')
\ && bufwinnr(b:switch_buffer['bufnr']) == b:switch_buffer['winnr']
call GoldenView#zl#window#switch_buffer(bufnr, b:switch_buffer['bufnr'])
else
try
let fn = 'GoldenView#zl#window#switch_buffer_with_'.opts['with']
exec 'call ' . fn . '()'
catch /^Vim%((a+))=:E700/
throw "zl: function " . fn . 'for ' . opts['with']
\ . ' is not implemented!'
endtry
endif
endfunction
function! GoldenView#zl#window#switch_buffer_with_sorted_by_size_index(index, ...)
"--------- ------------------------------------------------
" Desc : switch buffer with the largest window
"
" Args :
" - opts : >
" {
" 'bufnr' : bufnr('%') ,
" 'by' : 'size'|'height'|'width' ,
" 'tabnr' : tabpagenr() ,
" 'width_weight' : s:golden_ratio ,
" 'height_weight' : 1 ,
" }
"
" Return :
" Raise :
"
" Example : >
" nnoremap <silent> <C-@>
" \ :<C-u>call GoldenView#zl#window#switch_buffer_with_largest()<CR>
"--------- ------------------------------------------------
let opts = {
\ 'bufnr' : bufnr('%') ,
\ 'by' : 'size' ,
\ 'tabnr' : tabpagenr() ,
\ 'width_weight' : s:golden_ratio ,
\ 'height_weight' : 1 ,
\}
if a:0 >= 1 && type(a:1) == type({})
call extend(opts, a:1)
endif
let sorted = GoldenView#zl#window#sort_by(filter(copy(opts),'v:key != "bufnr"'))
let bufnr_to = sorted[a:index]['bufnr']
call GoldenView#zl#window#switch_buffer(opts['bufnr'], bufnr_to)
endfunction
function! GoldenView#zl#window#switch_buffer_with_largest(...)
call GoldenView#zl#window#switch_buffer_with_sorted_by_size_index(-1, a:000)
endfunction
function! GoldenView#zl#window#switch_buffer_with_smallest(...)
call GoldenView#zl#window#switch_buffer_with_sorted_by_size_index(0, a:000)
endfunction
function! GoldenView#zl#window#switch_buffer(bufnr1, bufnr2)
"--------- ------------------------------------------------
" Desc : switch buffer window if both are visible
"
" Args : bufnr1 <-> bufnr2
" Return :
" - 0 : fail
" - 1 : success
" Raise :
"
" Example : >
"
" Refer :
"--------- ------------------------------------------------
let winnr1 = bufwinnr(a:bufnr1)
let winnr2 = bufwinnr(a:bufnr2)
if winnr1 != -1 && winnr2 != -1
silent noautocmd exec winnr1 'wincmd w'
if bufnr('%') != a:bufnr2
silent noautocmd exec 'buffer' a:bufnr2
let b:switch_buffer = {
\ 'bufnr' : a:bufnr1 ,
\ 'winnr' : winnr2 ,
\ }
endif
silent noautocmd exec winnr2 'wincmd w'
if bufnr('%') != a:bufnr1
silent noautocmd exec 'buffer' a:bufnr1
" need filetype detect (maybe) because bufnr1 disappears for a
" moment
silent filetype detect
let b:switch_buffer = {
\ 'bufnr' : a:bufnr2 ,
\ 'winnr' : winnr1 ,
\ }
endif
return 1
else
return 0
endif
endfunction
function! GoldenView#zl#window#alternate_buffer()
if bufnr('%') != bufnr('#') && buflisted(bufnr('#'))
buffer #
else
let cnt = 0
let pos = 1
let current = 0
while pos <= bufnr('$')
if buflisted(pos)
if pos == bufnr('%')
let current = cnt
endif
let cnt += 1
endif
let pos += 1
endwhile
if current > cnt / 2
bprevious
else
bnext
endif
endif
endfunction
" ============================================================================
" Scroll: ⟨⟨⟨1
" ============================================================================
function! GoldenView#zl#window#scroll_other_window(direction)
execute 'wincmd' (winnr('#') == 0 ? 'w' : 'p')
execute (a:direction ? "normal! \<C-d>" : "normal! \<C-u>")
wincmd p
endfunction
" ============================================================================
" View: ⟨⟨⟨1
" ============================================================================
function! GoldenView#zl#window#save_view_command(command) range
let view = winsaveview()
let range = ''
if a:firstline != a:lastline
let range = a:firstline.','.a:lastline
endif
try
keepjumps execute range.a:command
finally
call winrestview(view)
endtry
endfunction
" ============================================================================
" Modeline: ⟨⟨⟨1
" ============================================================================
" vim: set ft=vim ts=4 sw=4 tw=78 fdm=marker fmr=⟨⟨⟨,⟩⟩⟩ fdl=1 :

View File

@ -1,366 +0,0 @@
*GoldenView.txt* Always have a nice view for vim split windows
===============================================================================
CONTENTS *goldenview-contents*
1. Introduction |goldenview-introduction|
2. Features |goldenview-features|
1. 1. AutoResizing |goldenview-1.-autoresizing|
2. 2. Tiled Windows Management |goldenview-2.-tiled-windows-management|
3. Installation |goldenview-installation|
1. Option A - With Plugin Manager [4] ( recommanded )
2. Option B - Without Plugin Manager [4]
4. Quick Start |goldenview-quick-start|
1. |g:goldenview__enable_default_mapping|
2. |g:goldenview__enable_at_startup|
5. More Commands and Mappings |goldenview-more-commands-and-mappings|
1. |:ToggleGoldenViewAutoResize|
2. |:DisableGoldenViewAutoResize|
3. |:EnableGoldenViewAutoResize|
4. |:GoldenViewResize|
5. |:SwitchGoldenViewLargest|
6. |:SwitchGoldenViewSmallest|
6. Rules |goldenview-rules|
1. |g:goldenview__ignore_urule|
2. |g:goldenview__restore_urule|
7. Profiles |goldenview-profiles|
1. |g:goldenview__active_profile|
2. |g:goldenview__reset_profile|
8. Troubleshooting: |goldenview-troubleshooting:|
1. Please do not resize me! |goldenview-please-do-not-resize-me|
2. minibufexpl.vim [6] takes 5+ lines |goldenview-minibufexpl.vim-6-takes-5-lines|
3. I still have Issues: |goldenview-i-still-have-issues:|
9. Contributors |goldenview-contributors|
10. RELEASE HISTORY |goldenview-release-history|
11. LICENSE: |goldenview-license:|
===============================================================================
INTRODUCTION *goldenview-introduction*
>
------------- - -----------------------------------------------
Plugin : GoldenView.vim
Author : Zhao Cai
EMail : caizhaoff@gmail.com
URL : http://zhaocai.github.io/GoldenView.Vim/
Version : 1.2.2
Date Created : Tue 18 Sep 2012 05:23:13 PM EDT
Last Modified : Wed 17 Apr 2013 09:52:45 PM EDT
------------- - -----------------------------------------------
The initial motive for GoldenView [1] comes from the frustration of using
other vim plugins to auto-resize split windows. The idea is deadly simple and
very useful: resize the focused window to a proper size. However, in practice,
many hiccups makes auto-resizing not a smooth experience. Below are a list of
issues GoldenView [1] attempts to solve:
First and the most important one, auto-resizing should play nicely with
existing plugins like 'tagbar', 'vimfiler', 'unite', 'VOoM', 'quickfix',
'undotree', 'gundo', etc. These windows should manage there own window size.
Second, auto-resizing should take care of the other windows too. Resizing the
focused window may cause the other windows become too small. When you have 4+
split windows, auto-resizing may just make a mess out of it.
GoldView Screencast, see reference [2]
GoldView Screencast
===============================================================================
FEATURES *goldenview-features*
GoldenView [1] has preliminarily solved the issues described above. It also
provides other features. Bascally, it does two things:
-------------------------------------------------------------------------------
1. AUTORESIZING *goldenview-1.-autoresizing*
First of all, it automatically resize the focused split window to a "golden"
view based on golden ratio [3] and 'textwidth'.
-------------------------------------------------------------------------------
2. TILED WINDOWS MANAGEMENT *goldenview-2.-tiled-windows-management*
Second, it maps a single key ('<C-L>' by default) to nicely split windows to
tiled windows.
>
----+----------------+------------+---+
| | | | |
| F | | S1 | T |
| I | +------------| A |
| L | | S2 | G |
| E | MAIN PANE +------------+ B |
| R | | S3 | A |
| | | | R |
| | | | |
+---+----------------+------------+---+
To get this view, just hit '<C-L>' 4 times. or, if you have a large monitor,
you may get tiled windows below.
>
----+---------------+--------------+------------+---+
| | | | | |
| F | | | S1 | T |
| I | | +------------| A |
| L | | M2 | S2 | G |
| E | MAIN PANE | +------------+ B |
| R | | | S3 | A |
| | | | | B |
| | | | | |
+---+---------------+--------------+------------+---+
To quickly switch between those windows, a few keys are mapped to
- Focus to the main window
- Switch with the 'MAIN PANE', the largest, smallest, etc.
- Jump to the next and previous window
===============================================================================
INSTALLATION *goldenview-installation*
Install GoldenView [1] is the same as installing other vim plugins. If
experienced with vim, you can skim the example below and move to next section.
-------------------------------------------------------------------------------
OPTION A - WITH PLUGIN MANAGER [4] ( RECOMMANDED )
If you use plugin managers like Pathogen, vundle, neobundle,
vim-addon-manager, etc., just unarchive the zip file or clone the GoldenView
[1] repo from 'git://github.com/zhaocai/GoldenView.git' into your local plugin
installation directory (most likely '~/.vim/bundle/'). Then add corresponding
scripts in .vimrc for the bundle manager you are using.
Example:
- neobundle:
>
NeoBundle 'zhaocai/GoldenView.Vim' "Always have a nice view for vim split windows
- vundle:
>
Bundle 'zhaocai/GoldenView.Vim'
- vim-addon-manager:
>
call vam#ActivateAddons(['GoldenView.Vim'], {'auto_install' : 1})
-------------------------------------------------------------------------------
OPTION B - WITHOUT PLUGIN MANAGER [4]
Unarchive the zip file into a directory that is under 'runtimepath' of your
vim, '~/.vim' for example.
===============================================================================
QUICK START *goldenview-quick-start*
GoldenView [1] should work out of the box without configuration. It should
automatically start to resize focused window to golden ratio [3] based on
'textwidth' and vim available size. You may start to play with it now.
To get you started, a few default keys are mapped as below:
>
" 1. split to tiled windows
nmap <silent> <C-L> <Plug>GoldenViewSplit
" 2. quickly switch current window with the main pane
" and toggle back
nmap <silent> <F8> <Plug>GoldenViewSwitchMain
nmap <silent> <S-F8> <Plug>GoldenViewSwitchToggle
" 3. jump to next and previous window
nmap <silent> <C-N> <Plug>GoldenViewNext
nmap <silent> <C-P> <Plug>GoldenViewPrevious
The meaning of those keys are self-explaining. A general workflow would be
'<Plug>GoldenViewSplit' key to quickly and nicely split windows to the layout
as below. Then you may open your files.
>
----+----------------+------------+---+
| | | | |
| F | | S1 | T |
| I | +------------| A |
| L | | S2 | G |
| E | MAIN PANE +------------+ B |
| R | | S3 | A |
| | | | R |
| | | | |
+---+----------------+------------+---+
To switch 'S1' with 'MAIN PANE', in 'S1' and hit '<Plug>GoldenViewSwitchMain'.
To switch back, hit '<Plug>GoldenViewSwitchToggle' in either 'MAIN PAIN' or
'S1'
-------------------------------------------------------------------------------
*g:goldenview__enable_default_mapping*
Every experienced vim user has a different set of key mappings. If you you are
(most likely) unhappy about some of the mappings, map you own keys as below:
>
let g:goldenview__enable_default_mapping = 0
nmap <silent> <MY_KEY> <Plug>GoldenViewSplit
" ... and so on
-------------------------------------------------------------------------------
*g:goldenview__enable_at_startup*
if you do not want to start auto-resizing automatically, you can put 'let
g:goldenview__enable_at_startup = 0' in your vimrc.
===============================================================================
MORE COMMANDS AND MAPPINGS *goldenview-more-commands-and-mappings*
-------------------------------------------------------------------------------
*:ToggleGoldenViewAutoResize*
-------------------------------------------------------------------------------
*:DisableGoldenViewAutoResize*
-------------------------------------------------------------------------------
*:EnableGoldenViewAutoResize*
These commands toggle, enable, and disable GoldenView auto-resizing.
-------------------------------------------------------------------------------
*:GoldenViewResize*
this command do manual resizing of focused window.
You can also map a key for this as below:
>
nmap <silent> <YOUR_KEY> <Plug>GoldenViewResize
-------------------------------------------------------------------------------
*:SwitchGoldenViewLargest*
-------------------------------------------------------------------------------
*:SwitchGoldenViewSmallest*
these commands do as it named.
You can also add mappings as below. ( no default keys for these mappings)
```vim nmap GoldenViewSwitchWithLargest nmap GoldenViewSwitchWithSmallest
```
Other switch rules can be easily defined. If you have some ideas, please post
to github issue [5] for discussion.
===============================================================================
RULES *goldenview-rules*
GoldenView [1] defines two rules:
-------------------------------------------------------------------------------
*g:goldenview__ignore_urule*
is to "ignore" - allow those special buffers to manage their own window size.
-------------------------------------------------------------------------------
*g:goldenview__restore_urule*
is to "restore" - restore window size of some of special buffers.
The 'urule' (user rules) are like this, which will be normalize at runtime for
faster processing.
>
\{
\ 'filetype' : [
\ '' ,
\ 'qf' , 'vimpager', 'undotree', 'tagbar',
\ 'nerdtree', 'vimshell', 'vimfiler', 'voom' ,
\ 'tabman' , 'unite' , 'quickrun', 'Decho' ,
\ ],
\ 'buftype' : [
\ 'nofile' ,
\ ],
\ 'bufname' : [
\ 'GoToFile' , 'diffpanel_\d\+' ,
\ '__Gundo_Preview__' , '__Gundo__' ,
\ '\[LustyExplorer-Buffers\]' , '\-MiniBufExplorer\-' ,
\ '_VOOM\d\+$' , '__Urannotate_\d\+__' ,
\ '__MRU_Files__' ,
\ ],
\},
===============================================================================
PROFILES *goldenview-profiles*
GoldenView [1] defines two profile:
-------------------------------------------------------------------------------
*g:goldenview__active_profile*
defines the functions and preferences to auto resize windows.
-------------------------------------------------------------------------------
*g:goldenview__reset_profile*
defines reset preferences to restore everything to default.
'function GoldenView#ExtendProfile()' is provided to customize preferences.
For more details, please read the source code! :)
===============================================================================
TROUBLESHOOTING: *goldenview-troubleshooting:*
-------------------------------------------------------------------------------
PLEASE DO NOT RESIZE ME! *goldenview-please-do-not-resize-me*
GoldenView [1] maintains rules for "common" cases. But vim offers a great
variety of plugins which defines buffers for special purposes. If you find
some special buffers which is supposed to not be auto-resized. Please check
|g:goldenview__ignore_urule|. You may extend the |g:goldenview__active_profile|
or post the issue to github issue [5] for adding it to builtin support.
-------------------------------------------------------------------------------
MINIBUFEXPL.VIM [6] TAKES 5+ LINES *goldenview-minibufexpl.vim-6-takes-5-lines*
Check my fork minibufexpl.vim [6] to see if it is working for you. I have send
pull request to the origin repo.
-------------------------------------------------------------------------------
I STILL HAVE ISSUES: *goldenview-i-still-have-issues:*
If you have any issues, please post it to github issue [5] for discussion.
===============================================================================
CONTRIBUTORS *goldenview-contributors*
===============================================================================
RELEASE HISTORY *goldenview-release-history*
Refer to History.md [7]
===============================================================================
LICENSE: *goldenview-license:*
Copyright (c) 2013 Zhao Cai <caizhaoff@gmail.com>
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 3 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.
You should have received a copy of the GNU General Public License along with
this program. If not, see 'http://www.gnu.org/licenses/' [8].
===============================================================================
REFERENCES *goldenview-references*
[1] http://zhaocai.github.io/GoldenView.Vim/
[2] http://dl.dropboxusercontent.com/u/1897501/Screencasts/GoldenView.gif
[3] http://en.wikipedia.org/wiki/Golden_ratio
[4] http://vim-scripts.org/vim/tools.html
[5] https://github.com/zhaocai/GoldenView.Vim/issues
[6] https://github.com/zhaocai/minibufexpl.vim
[7] https://github.com/zhaocai/GoldenView.Vim/blob/master/History.md
[8] http://www.gnu.org/licenses/
vim: ft=help

View File

@ -1,177 +0,0 @@
" =============== ============================================================
" Name : GoldenView
" Description : Golden view for vim split windows
" Author : Zhao Cai <caizhaoff@gmail.com>
" HomePage : https://github.com/zhaocai/GoldenView.Vim
" Date Created : Tue 18 Sep 2012 10:25:23 AM EDT
" Last Modified : Sat 29 Sep 2012 01:23:02 AM EDT
" Tag : [ vim, window, size, golden-ratio ]
" Copyright : © 2012 by Zhao Cai,
" Released under current GPL license.
" =============== ============================================================
" ============================================================================
" Load Guard: ⟨⟨⟨1
" ============================================================================
if !GoldenView#zl#rc#load_guard(
\ expand('<sfile>:t:r'), 700, 130, ['!&cp', "has('float')"])
finish
endif
let s:save_cpo = &cpo
set cpo&vim
" ============================================================================
" Settings: ⟨⟨⟨1
" ============================================================================
call GoldenView#zl#rc#set_default({
\ 'g:goldenview__enable_at_startup' : 1 ,
\ 'g:goldenview__enable_default_mapping' : 1 ,
\ 'g:goldenview__active_profile' : 'default' ,
\ 'g:goldenview__reset_profile' : 'reset' ,
\ 'g:goldenview__ignore_urule' : {
\ 'filetype' : [
\ '' ,
\ 'qf' , 'vimpager', 'undotree', 'tagbar',
\ 'nerdtree', 'vimshell', 'vimfiler', 'voom' ,
\ 'tabman' , 'unite' , 'quickrun', 'Decho' ,
\ 'ControlP', 'diff' , 'extradite'
\ ],
\ 'buftype' : [
\ 'nofile' ,
\ ],
\ 'bufname' : [
\ 'GoToFile' , 'diffpanel_\d\+' ,
\ '__Gundo_Preview__' , '__Gundo__' ,
\ '\[LustyExplorer-Buffers\]' , '\-MiniBufExplorer\-' ,
\ '_VOOM\d\+$' , '__Urannotate_\d\+__' ,
\ '__MRU_Files__' , 'FencView_\d\+$'
\ ],
\ },
\ 'g:goldenview__restore_urule' : {
\ 'filetype' : [
\ 'nerdtree', 'vimfiler',
\ ],
\ 'bufname' : [
\ '__MRU_Files__' ,
\ ],
\ },
\
\ })
" ============================================================================
" Public Interface: ⟨⟨⟨1
" ============================================================================
" Auto Resize:
" ------------
command! -nargs=0 ToggleGoldenViewAutoResize
\ call GoldenView#ToggleAutoResize()
command! -nargs=0 DisableGoldenViewAutoResize
\ call GoldenView#DisableAutoResize()
command! -nargs=0 EnableGoldenViewAutoResize
\ call GoldenView#EnableAutoResize()
nnoremap <Plug>ToggleGoldenViewAutoResize
\ :<C-U>ToggleGoldenViewAutoResize<CR>
" Manual Resize:
" --------------
command! -nargs=0 GoldenViewResize
\ call GoldenView#EnableAutoResize()
\|call GoldenView#DisableAutoResize()
nnoremap <Plug>GoldenViewResize
\ :<C-U>GoldenViewResize<CR>
" Layout Split:
" -------------
nnoremap <Plug>GoldenViewSplit
\ :<C-u>call GoldenView#Split()<CR>
" [TODO]( define comfortable width &tw * 4/3) @zhaocai @start(2012-09-29 01:17)
" Goto Window:
" ------------
nnoremap <Plug>GoldenViewNext
\ :<C-u>call GoldenView#zl#window#next_window_or_tab()<CR>
nnoremap <Plug>GoldenViewPrevious
\ :<C-u>call GoldenView#zl#window#previous_window_or_tab()<CR>
" Switch Window:
" --------------
nnoremap <Plug>GoldenViewSwitchMain
\ :<C-u>call GoldenView#SwitchMain()<CR>
command! -nargs=0 SwitchGoldenViewMain
\ call GoldenView#SwitchMain()
nnoremap <Plug>GoldenViewSwitchToggle
\ :<C-u>call GoldenView#zl#window#switch_buffer_toggle()<CR>
command! -nargs=0 SwitchGoldenViewToggle
\ call GoldenView#zl#window#switch_buffer_toggle()
nnoremap <Plug>GoldenViewSwitchWithLargest
\ :<C-u>call GoldenView#zl#window#switch_buffer_with_largest()<CR>
command! -nargs=0 SwitchGoldenViewLargest
\ call GoldenView#zl#window#switch_buffer_with_largest()
nnoremap <Plug>GoldenViewSwitchWithSmallest
\ :<C-u>call GoldenView#zl#window#switch_buffer_with_smallest()<CR>
command! -nargs=0 SwitchGoldenViewSmallest
\ call GoldenView#zl#window#switch_buffer_with_smallest()
" ============================================================================
" Initialization: ⟨⟨⟨1
" ============================================================================
if g:goldenview__enable_at_startup == 1
call GoldenView#EnableAutoResize()
endif
if g:goldenview__enable_default_mapping == 1
nmap <silent> <C-N> <Plug>GoldenViewNext
nmap <silent> <C-P> <Plug>GoldenViewPrevious
nmap <silent> <F8> <Plug>GoldenViewSwitchMain
nmap <silent> <S-F8> <Plug>GoldenViewSwitchToggle
nmap <silent> <C-L> <Plug>GoldenViewSplit
endif
let &cpo = s:save_cpo
unlet s:save_cpo
" ============================================================================
" Modeline: ⟨⟨⟨1
" ============================================================================
" vim: set ft=vim ts=4 sw=4 tw=78 fdm=marker fmr=⟨⟨⟨,⟩⟩⟩ fdl=1 :

View File

@ -1,5 +0,0 @@
if !exists('g:GoldenView_zl_bundle_path')
let g:GoldenView_zl_bundle_path = fnamemodify(expand("<sfile>"), ":p:h:h:h")
let g:GoldenView_zl_autoload_path = expand(g:GoldenView_zl_bundle_path . '/autoload/GoldenView/zl')
end