From 26fd7bbb50afc4ce7de9eed0f2d1004045323834 Mon Sep 17 00:00:00 2001 From: Bryan Ramos Date: Thu, 7 May 2026 10:59:00 -0400 Subject: [PATCH] final --- vimrc | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/vimrc b/vimrc index bcf7d68..b57349c 100644 --- a/vimrc +++ b/vimrc @@ -3,9 +3,12 @@ if empty(glob(data_dir . '/autoload/plug.vim')) silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' endif -autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) - \| PlugInstall --sync | source $MYVIMRC - \| endif +augroup vimrc_plug_install + autocmd! + autocmd VimEnter * if exists('g:plugs') && len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) + \| PlugInstall --sync | source $MYVIMRC + \| endif +augroup END call plug#begin('~/.vim/plugged') Plug 'tpope/vim-surround' @@ -62,10 +65,13 @@ let g:netrw_liststyle = 3 let g:netrw_browse_split = 4 let g:netrw_altv = 1 -autocmd FileType netrw nnoremap :wincmd l -autocmd FileType netrw nnoremap :wincmd h -autocmd FileType netrw nnoremap :wincmd j -autocmd FileType netrw nnoremap :wincmd k +augroup vimrc_netrw + autocmd! + autocmd FileType netrw nnoremap :wincmd l + autocmd FileType netrw nnoremap :wincmd h + autocmd FileType netrw nnoremap :wincmd j + autocmd FileType netrw nnoremap :wincmd k +augroup END set laststatus=2 @@ -81,8 +87,12 @@ set smartcase set clipboard=unnamedplus set noswapfile set nobackup -set undofile -set undodir=~/.vim/undodir +if exists('&undofile') + set undofile + if exists('&undodir') + set undodir=~/.vim/undodir + endif +endif set hidden @@ -109,28 +119,27 @@ function! NetrwToggle() let g:netrw_return_win = winnr() if exists(':Lexplore') == 2 Lexplore - elseif exists(':Vexplore') == 2 - execute 'topleft ' . g:netrw_winsize . 'Vexplore' else + execute 'topleft vertical ' . g:netrw_winsize . 'new' Explore endif endfunction function! SafeWincmd(dir) - let target = winnr(a:dir) - if target == winnr() - return - endif - if getbufvar(winbufnr(target), '&filetype') ==# 'netrw' - return - endif + let l:current = winnr() execute 'wincmd ' . a:dir + if winnr() == l:current + return + endif + if &filetype ==# 'netrw' + execute l:current . 'wincmd w' + endif endfunction function! GitRoot() - let l:root = systemlist('git rev-parse --show-toplevel') - if v:shell_error == 0 && !empty(l:root) && !empty(l:root[0]) - return l:root[0] + let l:root = substitute(system('git rev-parse --show-toplevel'), '\n\+$', '', '') + if v:shell_error == 0 && !empty(l:root) + return l:root endif return getcwd() endfunction