My nvim is goated; Add console with keybinding Ctrl+Shift+Q
This commit is contained in:
parent
971cb80416
commit
0675055e49
52
init.vim
52
init.vim
|
@ -36,11 +36,51 @@ Plug 'norcalli/nvim-colorizer.lua' "Color Hexadecimal
|
|||
|
||||
call plug#end()
|
||||
|
||||
" If there are only terminal and NerdTree, all close
|
||||
autocmd bufenter * if (winnr("$") == 2 && IsNerdTreeEnabled() && g:terminal_id != -1) | qa | endif
|
||||
|
||||
" Terminal
|
||||
function! ToggleTerminal()
|
||||
if (g:terminal_id == -1)
|
||||
below split | resize 10 | term
|
||||
let g:terminal_id = win_getid()
|
||||
else
|
||||
call win_gotoid(g:terminal_id)
|
||||
let g:terminal_id = -1
|
||||
close
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let g:terminal_id = -1
|
||||
nnoremap <C-S-q> :call ToggleTerminal()<CR>
|
||||
nnoremap <C-S-a> :echo win_getid()<CR>
|
||||
|
||||
" NerdTree
|
||||
"
|
||||
" Size
|
||||
let g:NERDTreeDefaultSize = 20
|
||||
let g:NERDTreeWinSize=g:NERDTreeDefaultSize
|
||||
" Start NERDTree and put the cursor back in the other window.
|
||||
autocmd VimEnter * NERDTree | wincmd p
|
||||
" Exit Vim if NERDTree is the only window remaining in the only tab.
|
||||
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
||||
|
||||
function! IsNerdTreeEnabled()
|
||||
return exists('t:NERDTreeBufName') && bufwinnr(t:NERDTreeBufName) != -1
|
||||
endfunction
|
||||
|
||||
" Add
|
||||
function! AddNERDTreeSize(add)
|
||||
call SetNERDTreeSize(g:NERDTreeWinSize + a:add)
|
||||
endfunction
|
||||
|
||||
" Set
|
||||
function! SetNERDTreeSize(value)
|
||||
if exists("g:NERDTree") && g:NERDTree.IsOpen()
|
||||
execute 'let g:NERDTreeWinSize = ' . (a:value)
|
||||
execute 'NERDTree'
|
||||
wincmd p
|
||||
execute 'NERDTreeFind'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Focus and unfocus
|
||||
function! ToggleNERDTree()
|
||||
|
@ -51,10 +91,16 @@ function! ToggleNERDTree()
|
|||
endif
|
||||
endfunction
|
||||
|
||||
" Unfocus on the file open
|
||||
nnoremap <C-z> :call ToggleNERDTree()<CR>
|
||||
nnoremap <C-x> :NERDTreeToggle<CR>
|
||||
nnoremap <C-c> :NERDTreeFind<CR>
|
||||
" Unfocus on the file open
|
||||
|
||||
" Resize NERDTree
|
||||
nnoremap <C-S-Up> :call AddNERDTreeSize(2)<CR>
|
||||
nnoremap <C-S-Down> :call AddNERDTreeSize(-2)<CR>
|
||||
nnoremap <C-S-Left> :call SetNERDTreeSize(g:NERDTreeDefaultSize)<CR>
|
||||
nnoremap <C-S-Right> :call SetNERDTreeSize(g:NERDTreeDefaultSize)<CR>
|
||||
|
||||
"
|
||||
nnoremap <F8> :TagbarToggle<CR>
|
||||
|
|
Loading…
Reference in a new issue