├── .gitignore
├── HISTORY.md
├── README.md
├── doc
└── fastunite.txt
└── plugin
└── fastunite.vim
/.gitignore:
--------------------------------------------------------------------------------
1 | doc/tags
2 |
--------------------------------------------------------------------------------
/HISTORY.md:
--------------------------------------------------------------------------------
1 | ## v0.2.0 - May 25, 2015
2 |
3 | Add grep bindings: `,ug` (grep for keyword), `,u]` (grep current word), and `,uG` (reopen grep window).
4 |
5 | ## v0.1.0 - Apr 24, 2015
6 |
7 | Initial version.
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vim-fastunite
2 |
3 | The fastest way to navigate your files powered by [unite.vim]. Just press `Ctrl-P`. No lags.
4 |
5 |
6 |
7 | ## About
8 |
9 | vim-fastunite is pre-configured to give you a pleasant out-of-the-box experience with [unite.vim], the best Vim file matcher.
10 |
11 | Just install the vim plugins and `ag` — no need for complicated vimrc incantations.
12 |
13 | * No lags when opening Unite (via resuming)
14 | * Fast file indexing (via `ag`)
15 | * Smart sorting and fuzzy matching
16 | * [...and many more](#features)
17 |
18 | **[Read documentation ›](doc/fastunite.txt)**
19 |
20 |
21 |
22 | ## Installation
23 |
24 | Use your favorite Vim package manager to install `vim-fastunite` with its dependencies. With [vim-plug]:
25 |
26 | ```vim
27 | " ~/.vimrc
28 | Plug 'Shougo/vimproc.vim', { 'do': 'make' }
29 | Plug 'Shougo/unite.vim'
30 | Plug 'rstacruz/vim-fastunite'
31 |
32 | Plug 'Shougo/neomru.vim'
33 | Plug 'Shougo/unite-outline'
34 | Plug 'tsukkee/unite-tag'
35 |
36 | map [unite]p
37 | ```
38 |
39 | If you're not using vim-plug and it's the first time to install `vimproc`, be sure to run `make`.
40 |
41 | Install [the_silver_searcher] for faster searches. (optional, but recommended)
42 |
43 | ```sh
44 | brew install the_silver_searcher # OSX
45 | apt-get install silversearcher-ag # Ubuntu
46 | yum install the_silver_searcher # Fedora
47 | ```
48 |
49 | Now press `` in your big project.
50 |
51 | *Only the first 3 vimrc lines are required; the other plugins are optional but recommended.*
52 |
53 |
54 |
55 | ## Usage
56 |
57 | **Press** `,up` **to search for files in the project**.
58 |
59 | All keys are prefixed with `u` by default (referred to as `[unite]`). Assuming your leader key is `,` that's:
60 |
61 | | Key | Description |
62 | | --- | --- |
63 | | `,u` `p` | **Project:** search for files in the project |
64 | | `,u` `t` | **Tags:** search for tags (requires [unite-tag]) |
65 | | `,u` `r` | **Recent:** show recent files (require ([neomru]) |
66 | | `,u` `o` | **Outline:** outline sidebar (requires [unite-outline]) |
67 |
68 | For grepping:
69 |
70 | | Key | Description |
71 | | --- | --- |
72 | | `,u` `g` | **Grep:** search in files |
73 | | `,u` `]` | search current word under cursor |
74 | | `,u` `G` | Show last grep window |
75 |
76 | **[Documentation →](doc/fastunite.txt)**
77 |
78 |
79 |
80 | ## Features
81 |
82 | So you've probably tried Unite before. You added a few lines to your vimrc to get Unite running. If you're like me, you probably used it a few times and forgot about it because it was slow.
83 |
84 | This plugin is a bag of many tweaks to make the Unite experience more seamless. Here are a few:
85 |
86 | * *Unite resuming:* invoking unite after the first time will resume the previous unite session, making it fast.
87 |
88 | * *Faster file search:* If `ag` is available, it's used for `file_rec`.
89 |
90 | * *Mercurial support:* by using `ag`, .hgignore and .bzrignore are supported.
91 |
92 | * *Use better sorting:* If `+ruby` is available in your Vim build, a better sorting method (selecta) will be selected for you. This gets you better top results, saving you keystrokes.
93 |
94 | * *Kep mappings:* all the useful key mappings are set up for you, set up conveniently with a configurable ` u` prefix.
95 |
96 | * *Sleeker airline:* provides a more pleasant integration with airline.vim by omitting extraneous statusbar information.
97 |
98 | * *Faster grepping:* `ag` will be used for grepping if it's available.
99 |
100 | * *Better unite-tag integration:* if `unite-tag` is installed, it will be used as the tag browser when pressing `^]`.
101 |
102 | * *Preconfigured matchers:* fuzzy matching and smart sorting is enabled by default.
103 |
104 | * And many more.
105 |
106 |
107 |
108 | ## Tips and tricks
109 |
110 |
111 | * *Refreshing files:* the window is cached, so new files won't show up. Press `ctrl-l` in Unite.
112 |
113 | * *Fixing Unite glitches:* press `ctrl-r` to restart Unite.
114 |
115 | * *Navigating:* after opening `,up`, you can navigate directories with
116 | `ctrl-e`. press `ctrl-g` to leave a directory. eg: `app` `ctrl-e` `ass`
117 | `ctrl-e` `styl` `ctrl-e` will navigate to app/assets/stylesheets, letting you
118 | create a file in that directory.
119 |
120 |
121 | [unite.vim]: https://github.com/Shougo/unite.vim
122 | [vim-plug]: https://github.com/junegunn/vim-plug
123 | [unite-outline]: https://github.com/Shougo/unite-outline
124 | [unite-tag]: https://github.com/tsukkee/unite-tag
125 | [neomru]: https://github.com/Shougo/neomru.vim
126 | [the_silver_searcher]: https://github.com/ggreer/the_silver_searcher
127 |
--------------------------------------------------------------------------------
/doc/fastunite.txt:
--------------------------------------------------------------------------------
1 | *fastunite.txt* integration for unite.vim
2 |
3 | ==============================================================================
4 | INTRODUCTION *fastunite*
5 |
6 | Fast integration for unite.vim.
7 |
8 | All key bindings start with u.
9 |
10 | ==============================================================================
11 | BINDINGS *fastunite-bindings*
12 |
13 | *fastunite-p*
14 | u p
15 | u P
16 | Search for files in the current project.
17 | When the uppercase `P` is used, it unite will spawn the picker in the
18 | currently active buffer.
19 | Compare with |:Unite| `file_rec`.
20 | *fastunite-b*
21 | u b
22 | u B
23 | Search buffers. Compare with |:Unite| `buffer`.
24 | *fastunite-t*
25 | u t
26 | u T
27 | Search for tags. Compare with |:Unite| `tag`.
28 | Requires the |unite-tag|.vim plugin.
29 | *fastunite-g*
30 | u g
31 | Search all files in the project. Compare with |:Unite| `grep`.
32 | u G
33 | Re-opens the previous grep buffer.
34 | *fastunite-o*
35 | u o
36 | u O
37 | Open an outline of the current file. Compare with |:Unite| `outline`.
38 | Requires the |unite-outline|.vim plugin.
39 | *fastunite-r*
40 | u r
41 | u R
42 | Open a recent file. Compare with |:Unite| `neomru/file`.
43 | Requires the |neomru|.vim plugin.
44 |
45 | ==============================================================================
46 | GREP FEATURES *fastunite-grep*
47 |
48 | u g
49 | Grep
50 |
51 | u ]
52 | Grep the word under the cursor
53 |
54 | u G
55 | re-open last grep window
56 |
57 | ==============================================================================
58 | OPTIONS *fastunite-options*
59 |
60 | *g:fastunite_default_options*
61 | Default options for unite. This allows you to set default options whenever
62 | unite commands are invoked either though the mappings or `:Unite file`. See
63 | |unite-options| for available options.
64 | default: `{}`
65 | >
66 | let g:fastunite_default_options = {
67 | \ 'direction' : 'botright'
68 | }
69 |
70 | ==============================================================================
71 | ADVANCED CUSTOMIZATION *fastunite-customization*
72 |
73 | Overriding fastunite customizations ~
74 |
75 | If there's anything you want to override, put it in a function
76 | called `fastunite#loaded()`.
77 | >
78 | function! fastunite#loaded()
79 | let g:unite_prompt = ' ▸ '
80 | endfunction
81 |
82 | Changing prefixes ~
83 |
84 | You can remap a new prefix using: >
85 |
86 | nmap U [unite]
87 |
88 | ==============================================================================
89 | vim ft:help
90 |
--------------------------------------------------------------------------------
/plugin/fastunite.vim:
--------------------------------------------------------------------------------
1 | if globpath(&rtp, "plugin/unite.vim") == ""
2 | echohl WarningMsg | echomsg "fastunite: unite.vim is not found." | echohl none
3 | finish
4 | endif
5 |
6 | "
7 | " Options:
8 | "
9 |
10 | if !exists('g:fastunite_default_options')
11 | let g:fastunite_default_options = { }
12 | endif
13 |
14 | "
15 | " Feature Detection:
16 | "
17 |
18 | let s:has_outline = globpath(&rtp, "autoload/unite/sources/outline.vim") != ""
19 | let s:has_airline = 0
20 | " globpath(&rtp, "plugin/airline.vim") != ""
21 | let s:has_neomru = globpath(&rtp, "plugin/neomru.vim") != ""
22 | let s:has_tag = globpath(&rtp, "autoload/unite/sources/tag.vim") != ""
23 | let s:has_ag = executable('ag')
24 |
25 | "
26 | " Settings:
27 | " some reasonable default settings.
28 | "
29 |
30 | let g:unite_data_directory = expand("~/.cache/unite")
31 |
32 | if s:has_tag
33 | let g:unite_source_tag_max_fname_length = 70
34 | endif
35 |
36 | "
37 | " Unite Marks:
38 | " show file marks (eg, `mA`) in unite-mark.vim, if it's available.
39 | "
40 |
41 | let g:unite_source_mark_marks =
42 | \ "abcdefghijklmnopqrstuvwxyz" .
43 | \ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
44 |
45 | "
46 | " Improved Searching:
47 | " Use `ag` so that file_rec will respect gitignore.
48 | " https://github.com/Shougo/unite.vim/issues/398#issuecomment-27012821
49 | "
50 |
51 | if s:has_ag
52 | " let g:unite_source_rec_async_command =
53 | " \ ['ag', '--nocolor', '--nogroup', '-g', '""']
54 | " \ '--ignore', '*.jpg',
55 | " \ '--ignore', '*.jpeg',
56 | " \ '--ignore', '*.gif',
57 | " \ '--ignore', '*.png',
58 | " \ '--ignore', '*.ttf',
59 | " \ '--ignore', '*.woff',
60 | " \ '--ignore', '*.eot'
61 | " \ ]
62 | endif
63 |
64 | "
65 | " Tag Sorting:
66 | " ensure that `on_page` matches `on_page?` and not `confirmation_page`.
67 | " sorter_selecta would be better, but it's not as fast as sorter_rank.
68 | "
69 |
70 | call unite#custom#source('tag', 'sorters', ['sorter_rank'])
71 |
72 | "
73 | " File_rec Matchers:
74 | " strip off absolute paths from file_rec.
75 | " also, use fuzzy ctrl-p-style matcher.
76 | " also, neovim doesn't have ruby so... no selecta
77 | "
78 |
79 | let s:file_recs = 'file,directory,file_rec,file_rec/async'
80 | if s:has_tag
81 | let s:file_recs .= ',tag'
82 | endif
83 |
84 | let s:sorter = has('python') ? 'sorter_selecta' : 'sorter_rank'
85 | call unite#custom#source(s:file_recs, 'sorters', [s:sorter])
86 | call unite#custom#source(s:file_recs, 'matchers', [
87 | \ 'converter_relative_word',
88 | \ 'matcher_fuzzy' ])
89 |
90 | "
91 | " Neomru:
92 | " Restrict to project. unite-filter-matcher_project_files
93 | "
94 |
95 | if s:has_neomru
96 | call unite#custom#source(
97 | \ 'neomru/file', 'matchers',
98 | \ ['converter_relative_word', 'matcher_project_files', 'matcher_fuzzy'])
99 | end
100 |
101 | "
102 | " Prefix Key:
103 | " map u as the unite prefix.
104 | "
105 |
106 | nnoremap [unite]
107 | nmap u [unite]
108 |
109 | "
110 | " Source Profiles:
111 | " see :h unite-options
112 | "
113 |
114 | call unite#custom#profile('default', 'context', extend({
115 | \ 'direction' : 'topleft',
116 | \ 'prompt' : ' → '
117 | \ }, g:fastunite_default_options))
118 |
119 | call unite#custom#profile('source/grep', 'context', {
120 | \ 'buffer_name' : 'grep',
121 | \ 'no_quit' : 0
122 | \ })
123 |
124 | call unite#custom#profile('source/buffer', 'context', {
125 | \ 'buffer_name' : 'buffer',
126 | \ 'start_insert' : 1
127 | \ })
128 |
129 | call unite#custom#profile('source/tag', 'context', {
130 | \ 'buffer_name' : 'tag',
131 | \ 'start_insert' : 1,
132 | \ 'resume' : 1,
133 | \ 'input' : ''
134 | \ })
135 |
136 | call unite#custom#profile('source/neomru/file', 'context', {
137 | \ 'buffer_name' : 'mru',
138 | \ 'start_insert' : 1
139 | \ })
140 |
141 | call unite#custom#profile('source/neomru/directory', 'context', {
142 | \ 'buffer_name' : 'dirs',
143 | \ 'start_insert' : 1,
144 | \ 'default_action' : 'cd'
145 | \ })
146 |
147 | "
148 | " Key Bindings:
149 | "
150 |
151 | function! s:unite_map(key1, key2, opts)
152 | let l:here = '-no-split '
153 | let l:unite = ':Unite '
154 |
155 | exe "nnoremap [unite]" . a:key1 . ' ' . l:unite . ' ' . a:opts . ''
156 | exe "nnoremap [unite]" . a:key2 . ' ' . l:unite . ' ' . l:here . ' ' . a:opts . ''
157 | endfunction
158 |
159 | call s:unite_map('p', 'P',
160 | \ "-resume -buffer-name=project -no-restore -input= -start-insert -hide-source-names -unique file_rec/git:--cached:--others:--exclude-standard")
161 |
162 | call s:unite_map('f', 'F',
163 | \ "-resume -buffer-name=file -no-restore -input= -start-insert -hide-source-names -unique file file/new")
164 |
165 | nnoremap [unite]g :UniteWithInput grep:.
166 | nnoremap [unite]] :UniteWithCursorWord -no-start-insert grep:.
167 | nnoremap [unite]G :UniteResume grep
168 |
169 | call s:unite_map('b', 'B', "buffer")
170 | call s:unite_map('t', 'T', "-input= tag")
171 |
172 | if s:has_neomru
173 | call s:unite_map('r', 'R', "neomru/file")
174 | call s:unite_map('d', 'D', "neomru/directory")
175 | endif
176 |
177 | if s:has_outline
178 | " outline
179 | nnoremap [unite]o
180 | \ :Unite -buffer-name=outline
181 | \ -auto-highlight
182 | \ -vertical
183 | \ -winwidth=30
184 | \ outline:!
185 | endif
186 |
187 | "
188 | " Uhhh just trying this out
189 | "
190 |
191 | nnoremap [unite]] :call NavigateTo()
192 | function! s:NavigateTo()
193 | let l:word = expand('')
194 | exe 'Unite tag grep:. -buffer-name=navigate -input=' . l:word
195 | endfunction
196 |
197 | "
198 | " Unite Tag Integration:
199 | " Use unite-tag instead of ^] for navigating to tags.
200 | " :help unite-tag-customize
201 | "
202 |
203 | " autocmd BufEnter *
204 | " \ if empty(&buftype)
205 | " \| nnoremap :UniteWithCursorWord -buffer-name=tag -no-start-insert -immediately tag
206 | " \| endif
207 |
208 | "
209 | " Improved Grep:
210 | " Use ag for `:Unite grep` search if available.
211 | " https://github.com/ggreer/the_silver_searcher
212 | "
213 |
214 | if s:has_ag
215 | let g:unite_source_grep_command = 'ag'
216 | let g:unite_source_grep_default_opts = '--vimgrep'
217 | let g:unite_source_grep_recursive_opt = ''
218 | endif
219 |
220 | "
221 | " Airline Integration:
222 | " simplifies the status line and gets rid of the unnecessary cruft
223 | " for airline.vim.
224 | "
225 | " from:
226 | " Unite > project > file(25) file_rec/async(31) | directory: /Users/...
227 | "
228 | " to:
229 | " Unite > project
230 | "
231 |
232 | if s:has_airline
233 | function! airline#extensions#unite#apply(...)
234 | if &ft == 'unite'
235 | call a:1.add_section('airline_a', ' Unite ')
236 | call a:1.add_section('airline_b', ' %{get(unite#get_context(), "buffer_name", "")} ')
237 | call a:1.add_section('airline_c', ' ')
238 | return 1
239 | endif
240 | endfunction
241 | endif
242 |
243 | "
244 | " Loaded Hook:
245 | " allow the user to override some settings with a custom function
246 | "
247 |
248 | if exists('*fastunite#loaded')
249 | call fastunite#loaded()
250 | endif
251 |
252 | "
253 | " Buffer Keys:
254 | " custom mappings for the unite buffer.
255 | " http://www.codeography.com/2013/06/17/replacing-all-the-things-with-unite-vim.html
256 | "
257 |
258 | autocmd FileType unite call s:unite_settings()
259 | function! s:unite_settings()
260 | " Play nice with supertab
261 | let b:SuperTabDisabled=1
262 |
263 | " Enable navigation with control-j and control-k in insert mode
264 | imap (unite_select_next_line)
265 | imap (unite_select_previous_line)
266 |
267 | " Restart for glitches
268 | imap (unite_restart)
269 |
270 | " Tab to drill-down (app ass sty )
271 | " remap old tab to C-z
272 | imap
273 | imap (unite_choose_action)
274 | endfunction
275 |
276 | "
277 | " Input Prompt Style:
278 | " Usually set to 'normal', which is silly
279 | "
280 | hi link uniteInputPrompt Special
281 |
--------------------------------------------------------------------------------