44
55let s: VIMIDE_BOOT_FINISHED = 0
66
7+ let s: rootPath = fnamemodify (resolve (expand (' <sfile>:p' )), ' :h:h' )
8+ let s: bundlePath = s: rootPath . " /bundle"
9+
10+ function ! vimide#getRootPath () " {{{
11+ return s: rootPath
12+ endfunction " }}}
13+
14+ function ! vimide#getBundlePath () " {{{
15+ return s: bundlePath
16+ endfunction " }}}
17+
718function ! vimide#setDefaults () " {{{
819 call s: setGlobal (' g:vimide_global_enable' , 0 )
920 call s: setGlobal (' g:vimide_manage_indents' , 1 )
@@ -43,6 +54,7 @@ function! vimide#setDefaults() " {{{
4354 call s: setGlobal (' g:vimide_install_comment_shortcuts' , 1 )
4455 call s: setGlobal (' g:vimide_install_align_shortcuts' , 1 )
4556 call s: setGlobal (' g:vimide_install_other_shortcuts' , 1 )
57+ call s: setGlobal (' g:vimide_install_elixir_shortcuts' , 1 )
4658 call s: setGlobal (' g:vimide_manage_misc_settings' , 1 )
4759 call s: setGlobal (' g:vimide_install_hack_font' , 1 )
4860endfunction " }}}
@@ -56,7 +68,10 @@ function! vimide#init() " {{{
5668endfunction " }}}
5769
5870function ! vimide#boot (setGlobal) " {{{
59- if ! s: VIMIDE_BOOT_FINISHED
71+ let bootVarName = (a: setGlobal ? " s:VIMIDE_BOOT_FINISHED" : " b:VIMIDE_BOOT_FINISHED" )
72+ let bootFinished = s: VIMIDE_BOOT_FINISHED || (exists (bootVarName) && execute (" echo " .bootVarName) == 1 )
73+
74+ if ! bootFinished
6075 if g: vimide_colorscheme != ' ' | call vimide#setColorscheme (a: setGlobal ) | endif
6176 if g: vimide_manage_encoding | call vimide#setVimEncodingSettings (a: setGlobal ) | endif
6277 if g: vimide_manage_indents | call vimide#setIndentSettings (a: setGlobal ) | endif
@@ -74,10 +89,12 @@ function! vimide#boot(setGlobal) " {{{
7489 if g: vimide_install_other_shortcuts | call vimide#setOtherShortcuts (a: setGlobal ) | endif
7590 if g: vimide_install_hack_font | call vimide#setHackFont (a: setGlobal ) | endif
7691 if g: vimide_manage_misc_settings | call vimide#setMiscSettings (a: setGlobal ) | endif
77- let s: VIMIDE_BOOT_FINISHED = 1
92+ execute ( " let " . bootVarName . " = 1" )
7893 endif
7994
8095 if &filetype == ' elixir'
96+ " filetype specific initialization goes here, but it is basically very
97+ " small piece of code
8198 call vimide#elixir#boot ()
8299 endif
83100
@@ -231,9 +248,7 @@ function! vimide#setIndentLineSettigns(setGlobal) "{{{
231248 " let g:indentLine_char = '⎥' straigh line
232249 " let g:indentLine_char = '⎸' (needs FreeSerif)
233250 else
234- " TODO: add BufferEnter/Exit logic to toggle indentLine only in elixir
235- " buffers
236- let pass = 1
251+ nnoremap <silent> <buffer> <C-K><C-I> :IndentLinesToggle<CR>
237252 endif
238253endfunction " }}}
239254
@@ -295,6 +310,8 @@ function! vimide#setCommentShortcuts(setGlobal) " {{{
295310 " we want comments to be nicely aligned under each other and not follow
296311 " indentation
297312 let g: NERDDefaultAlign = " left"
313+ let g: NERDCommentEmptyLines = 1
314+
298315 " TODO: think of possibility leaving commented area in visual selected mode
299316 " (if it is good idea at all :)
300317 if a: setGlobal
@@ -330,22 +347,41 @@ function! vimide#setTabularizeShortcuts(setGlobal) " {{{
330347 " ####################################################################
331348 " Integration with Tabularize
332349
350+ " TODO: may be remove all indenting funcitonality alltogether, as it may be
351+ " extremely annoying
352+
333353 if a: setGlobal
334354 " tabularize both => and =
335- map <Leader> = =:Tabularize /=><CR>
336- map <Leader> eq =:Tabularize /=/<CR>
355+ nmap <Leader> = = =:Tabularize /=><CR>
356+ nmap <Leader> eq = =:Tabularize /=/<CR>
337357 " tabularize case clauses
338- map <Leader> - =:Tabularize /-><CR>
358+ nmap <Leader> - = =:Tabularize /-><CR>
339359 " tabularize : in hashmaps and similar
340- map <Leader> : =:Tabularize /\v(:)@<=\s/l0<CR>
360+ nmap <Leader> : ==:Tabularize /\v(:)@<=\s/l0<CR>
361+
362+ " tabularize both => and =
363+ vmap <Leader> = =:'<,'> Tabularize /=><CR>
364+ vmap <Leader> eq =:'<,'> Tabularize /=/<CR>
365+ " tabularize case clauses
366+ vmap <Leader> - =:'<,'> Tabularize /-><CR>
367+ " tabularize : in hashmaps and similar
368+ vmap <Leader> : =:'<,'> Tabularize /\v(:)@<=\s/l0<CR>
341369 else
342370 " tabularize both => and =
343- map <buffer> <Leader> = =:Tabularize /=><CR>
344- map <buffer> <Leader> eq =:Tabularize /=/<CR>
371+ nmap <buffer> <Leader> = = =:Tabularize /=><CR>
372+ nmap <buffer> <Leader> eq = =:Tabularize /=/<CR>
345373 " tabularize case clauses
346- map <buffer> <Leader> - =:Tabularize /-><CR>
374+ nmap <buffer> <Leader> - = =:Tabularize /-><CR>
347375 " tabularize : in hashmaps and similar
348- map <buffer> <Leader> : =:Tabularize /\v(:)@<=\s/l0<CR>
376+ nmap <buffer> <Leader> : ==:Tabularize /\v(:)@<=\s/l0<CR>
377+
378+ " tabularize both => and =
379+ vmap <buffer> <Leader> = =:'<,'> Tabularize /=><CR>
380+ vmap <buffer> <Leader> eq =:'<,'> Tabularize /=/<CR>
381+ " tabularize case clauses
382+ vmap <buffer> <Leader> - =:'<,'> Tabularize /-><CR>
383+ " tabularize : in hashmaps and similar
384+ vmap <buffer> <Leader> : =:'<,'> Tabularize /\v(:)@<=\s/l0<CR>
349385 endif
350386endfunction " }}}
351387
@@ -382,7 +418,6 @@ function! vimide#setOtherShortcuts(setGlobal) " {{{
382418 map <C-K><C-l> :exec 'match NonText /\<' . expand("<cword> ") . '\>/'<CR>
383419
384420 " delete buffer and keep split
385- " cannot have it local
386421 cab bdd bp \| bd #
387422
388423 " refactoring support
@@ -435,6 +470,9 @@ function! vimide#setOtherShortcuts(setGlobal) " {{{
435470 nmap <buffer> <F2> :w<CR>
436471 imap <buffer> <F2> <Esc> :w<CR> a
437472
473+ " delete buffer and keep split
474+ cab <buffer> bdd bp \| bd #
475+
438476 " lookup item under the cursor in file and show the list of
439477 " entries
440478 "
@@ -529,6 +567,7 @@ function! vimide#stripTrailingWhitespace() " {{{
529567 call winrestview (l: save )
530568endfunction " }}}
531569
570+ " TODO: consolidate in lib
532571function ! s: setGlobal (name, default) " {{{
533572 if ! exists (a: name )
534573 if type (a: name ) == 0 || type (a: name ) == 5
0 commit comments