Inicialização automática do Vim com Vexplore e terminal

Inicialização automática do Vim com Vexplore e terminal

Quero configurar o vim para se comportar como um ide tradicional na maior parte. O que eu gostaria de fazer é quando digito o comando vim ele abre desta forma:

Janela Vim

O problema é que abre assim:

demonstração do vim

Gostaria que o terminal iniciasse automaticamente, mas na janela anterior. Tentei ler a documentação, mas não estou muito informado sobre como ler a documentação e colocá-la no código, a maior parte do código no meu vimrc é copiado e colado e alguns dos princípios básicos eu já sabia. gostaria que ele iniciasse automaticamente como na primeira foto.

Além disso, mais uma pergunta que não tenho certeza se é possível no vim, às vezes no NetRW, quando eu clico fora, o buffer apaga a árvore de diretórios e então um buffer em branco aparece. Existe alguma maneira de impedir que certos comandos interfiram no buffer do terminal e na listagem da árvore dir? Um exemplo é se eu tentar abrir um arquivo e o último buffer for o buffer do terminal ele vai me perguntar se quero salvar o buffer atual (terminal) e abrir o arquivo, gostaria que fosse mais inteligente em abri-lo no buffer não terminal em vez do terminal. Basicamente ignorando o terminal além de inserir comandos.

Aqui está meu vimrc, provavelmente uma bagunça, já que não fiz nada além de copiar e colar:

set mouse=a
set number
imap jj <Esc>
set autochdir
map <Tab> <C-W>W:cd %:p:h<CR>:<CR>
map <C-l> :q!<CR>
map <C-t> :term bash<CR>
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')

" Make sure you use single quotes

" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'

" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'

" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'

" On-demand loading
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }

" Using a non-master branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }

" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }

" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }

" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }

" Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin'

" Initialize plugin system
call plug#end()


function! NetrwOpenMultiTab(current_line,...) range
   " Get the number of lines.
   let n_lines =  a:lastline - a:firstline + 1

   " This is the command to be built up.
   let command = "normal "

   " Iterator.
   let i = 1

   " Virtually iterate over each line and build the command.
   while i < n_lines
      let command .= "tgT:" . ( a:firstline + i ) . "\<CR>:+tabmove\<CR>"
      let i += 1
   endwhile
   let command .= "tgT"

   " Restore the Explore tab position.
   if i != 1
      let command .= ":tabmove -" . ( n_lines - 1 ) . "\<CR>"
   endif

   " Restore the previous cursor line.
   let command .= ":" . a:current_line  . "\<CR>"

   " Check function arguments
   if a:0 > 0
      if a:1 > 0 && a:1 <= n_lines
         " The current tab is for the nth file.
         let command .= ( tabpagenr() + a:1 ) . "gt"
      else
         " The current tab is for the last selected file.
         let command .= (tabpagenr() + n_lines) . "gt"
      endif
   endif
   " The current tab is for the Explore tab by default.

   " Execute the custom command.
   execute command
endfunction

" Define mappings.
augroup NetrwOpenMultiTabGroup
   autocmd!
   autocmd Filetype netrw vnoremap <buffer> <silent> <expr> t ":call NetrwOpenMultiTab(" . line(".") . "," . "v:count)\<CR>"
   autocmd Filetype netrw vnoremap <buffer> <silent> <expr> T ":call NetrwOpenMultiTab(" . line(".") . "," . (( v:count == 0) ? '' : v:count) . ")\<CR>"
augroup END

" Toggle Vexplore with Ctrl-E
function! ToggleVExplorer()
  if exists("t:expl_buf_num")
      let expl_win_num = bufwinnr(t:expl_buf_num)
      if expl_win_num != -1
          let cur_win_nr = winnr()
          exec expl_win_num . 'wincmd w'
          close
          exec cur_win_nr . 'wincmd w'
          unlet t:expl_buf_num
      else
          unlet t:expl_buf_num
      endif
  else
      exec '1wincmd w'
      Vexplore
      let t:expl_buf_num = bufnr("%")
  endif
endfunction

" NeTRW Explorer Settings

let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 15
augroup ProjectDrawer
  autocmd!
  autocmd VimEnter * :Vexplore
augroup END
map <silent> <C-n> :Vexplore<CR>

" Per default, netrw leaves unmodified buffers open. This autocommand
" deletes netrw's buffer once it's hidden (using ':q', for example)
autocmd FileType netrw setl bufhidden=delete
autocmd TabNew * call feedkeys(":Vexplore\<CR>", 'n')

" terminal split below
set splitbelow
autocmd VimEnter * :term bash

Responder1

Use este autocmd em vez disso:

autocmd VimEnter *
    \ Vexplore |
    \ execute "wincmd l" |
    \ rightbelow term bash

Isso executará toda a sequência uma vez, conforme você entra no Vim. Estou usando continuações de linha (as linhas de acompanhamento começam com uma barra invertida) e barras para executar vários comandos. Observe também que autocmdele executa comandos Ex, portanto, os comandos anteriores com :não são realmente necessários.

O primeiro comando abrirá a janela NERDTree, à esquerda, conforme o esperado.

Em segundo lugar, wincmd lirá para a janela à direita (veja :help :wincmd). Essa é a etapa que falta na sua tentativa, o que está fazendo com que a próxima etapa divida o NERDTree em vez da janela principal. O wincmdprecisa rodar dentro de um execute, pois senão tentará interpretar o |que o segue, o que deixará de funcionar como separador.

Por fim, o último comando abre o terminal, usando um explícito rightbelow(veja :help :rightbelow) para abrir esta divisão na parte inferior. É isso!

informação relacionada