My nvim is goated; Add console with keybinding Ctrl+Shift+Q

This commit is contained in:
Xamora 2024-01-18 09:54:11 +01:00
parent 971cb80416
commit 0675055e49

View file

@ -36,25 +36,71 @@ Plug 'norcalli/nvim-colorizer.lua' "Color Hexadecimal
call plug#end() 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 " NerdTree
" Start NERDTree and put the cursor back in the other window. "
autocmd VimEnter * NERDTree | wincmd p " Size
" Exit Vim if NERDTree is the only window remaining in the only tab. let g:NERDTreeDefaultSize = 20
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif let g:NERDTreeWinSize=g:NERDTreeDefaultSize
" Start NERDTree and put the cursor back in the other window.
autocmd VimEnter * NERDTree | wincmd p
" Focus and unfocus function! IsNerdTreeEnabled()
function! ToggleNERDTree() return exists('t:NERDTreeBufName') && bufwinnr(t:NERDTreeBufName) != -1
if exists("g:NERDTree") && g:NERDTree.IsOpen() && bufname('%') =~ 'NERD_tree_' endfunction
wincmd p
else
NERDTreeFocus
endif
endfunction
nnoremap <C-z> :call ToggleNERDTree()<CR> " Add
nnoremap <C-x> :NERDTreeToggle<CR> function! AddNERDTreeSize(add)
nnoremap <C-c> :NERDTreeFind<CR> call SetNERDTreeSize(g:NERDTreeWinSize + a:add)
" Unfocus on the file open 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()
if exists("g:NERDTree") && g:NERDTree.IsOpen() && bufname('%') =~ 'NERD_tree_'
wincmd p
else
NERDTreeFocus
endif
endfunction
" Unfocus on the file open
nnoremap <C-z> :call ToggleNERDTree()<CR>
nnoremap <C-x> :NERDTreeToggle<CR>
nnoremap <C-c> :NERDTreeFind<CR>
" 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> nnoremap <F8> :TagbarToggle<CR>