From 2329f0fd6b5f3f0947560d754b86b84d0648f177 Mon Sep 17 00:00:00 2001 From: Adam Lamers Date: Thu, 31 Mar 2022 16:07:43 -0400 Subject: [PATCH] new vim config --- vimrc | 256 ++++++++++++++++++++------------------------------- vimrc_vundle | 93 ------------------- 2 files changed, 101 insertions(+), 248 deletions(-) delete mode 100644 vimrc_vundle diff --git a/vimrc b/vimrc index eb2a1ce..0bdf892 100644 --- a/vimrc +++ b/vimrc @@ -1,48 +1,12 @@ -if filereadable($HOME . "/.vimrc_vundle") - source $HOME/.vimrc_vundle -endif -set history=700 - -nnoremap -let mapleader="\" -let g:mapleader="\" - -filetype plugin on -filetype indent on - -"Auto reload files and enable Vim mode -set autoread +" General settings set nocompatible - +filetype off +set hidden set backspace=eol,start,indent -set whichwrap+=<,>,h,l - -set ignorecase -set smartcase -set hlsearch -set incsearch -set lazyredraw -set magic -set showmatch -set mat=2 - -set noerrorbells -set novisualbell -set t_vb= -set tm=500 - -syntax enable -set nocp - -"enable line numbers set nu +set ignorecase +filetype plugin indent on -set encoding=utf8 - -set ffs=unix,dos,mac -set nobackup -set nowb -set noswapfile " Tab settings set expandtab @@ -51,117 +15,19 @@ set shiftwidth=4 set tabstop=4 "File specific tab settings -autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab +autocmd FileType yaml setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab +autocmd FileType javascript setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab +autocmd FileType typescript setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab +autocmd FileType typescriptreact setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab +autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2 expandtab +autocmd FileType python setlocal shiftwidth=4 tabstop=4 softtabstop=4 expandtab -set lbr -"Max 100 columns -set tw=100 - -set autoindent -set smartindent - -set path=$PWD/** -map j gj -map k gk - -"leader bindings -map :noh -map ba :1,1000 bd! -map q :bd -map qq :q -map w :w -map g :NERDTreeToggle - -"Return to last position when re-opening file -autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ exe "normal! g`\"" | - \ endif -set viminfo^=% - -function! HasPaste() - if &paste - return 'PASTE MODE ' - en - return '' -endfunction - -set laststatus=2 -set statusline=\ %{HasPaste()}%F%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l/%L\ [Col\ %v]\ M%m\ %=%-5y\ %-5{&ff} - -"Color compatibility with some terminals -let g:rehash256=1 -let &t_Co=256 -let &t_AF="\e[38;5;%dm" -let &t_AB="\e[48;5;%dm" -colorscheme monokai - -"change tabs with tab and shift-tab -nnoremap gt -nnoremap gT -nnoremap :CtrlP - -autocmd BufWritePre * :%s/\s\+$//e - -"Highlight lines that go over 120 columns -highlight ColorColumn ctermfg=208 ctermbg=Black -function! MarkMargin (on) - if exists('b:MarkMargin') - try - call matchdelete(b:MarkMargin) - catch /./ - endtry - unlet b:MarkMargin - endif - if a:on - let b:MarkMargin = matchadd('ColorColumn', '\%120v\s*\S', 120) - endif -endfunction - -augroup MarkMargin - autocmd! - autocmd BufEnter * :call MarkMargin(1) - autocmd BufEnter *.vp* :call MarkMargin(0) -augroup END - -"Reverse directions of # and * -nnoremap # * -nnoremap * # -inoremap jk -inoremap kj - -inoremap :compl-filename - -" Transparent editing of gpg encrypted files. -" By Wouter Hanegraaff -augroup encrypted - au! - - " First make sure nothing is written to ~/.viminfo while editing - " an encrypted file. - autocmd BufReadPre,FileReadPre *.gpg set viminfo= - " We don't want a swap file, as it writes unencrypted data to disk - autocmd BufReadPre,FileReadPre *.gpg set noswapfile - - " Switch to binary mode to read the encrypted file - autocmd BufReadPre,FileReadPre *.gpg set bin - autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2 - " (If you use tcsh, you may need to alter this line.) - autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null - - " Switch to normal mode for editing - autocmd BufReadPost,FileReadPost *.gpg set nobin - autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save - autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r") - - " Convert all text to encrypted text before writing - " (If you use tcsh, you may need to alter this line.) - autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-recipient-self -ae 2>/dev/null - " Undo the encryption so we are back in the normal text, directly - " after the file has been written. - autocmd BufWritePost,FileWritePost *.gpg u -augroup END +"Space as leader +nmap +nnoremap +let mapleader="\" +let g:mapleader="\" " Window navigation nnoremap h @@ -169,9 +35,89 @@ nnoremap j nnoremap k nnoremap l -if v:version > 800 - tnoremap h - tnoremap j - tnoremap k - tnoremap l + +set cmdheight=2 +set updatetime=300 +set shortmess+=c +set signcolumn=yes + +"Auto install vim-plug +let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' +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' + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif + +"Plugins +call plug#begin() +Plug 'preservim/nerdtree' +Plug 'tmhedberg/SimpylFold' +Plug 'tpope/vim-fugitive' +Plug 'sainnhe/gruvbox-material' +Plug 'kien/ctrlp.vim' +Plug 'itchyny/lightline.vim' +Plug 'junegunn/fzf' +Plug 'junegunn/fzf.vim' +Plug 'neoclide/coc.nvim', {'branch': 'release'} +Plug 'neoclide/coc-snippets' +Plug 'pangloss/vim-javascript' +Plug 'neoclide/vim-jsx-improve' +Plug 'leafgarland/typescript-vim' +Plug 'peitalin/vim-jsx-typescript' +call plug#end() + + +"Colorscheme +colorscheme gruvbox-material + + +"Coc Keybinds +nmap d (coc-definition) +nmap rn (coc-rename) +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) +imap (coc-snippets-expand) + +let g:coc_disable_transparent_cursor=1 + +"Use tab for snippet completion and jumping +inoremap + \ pumvisible() ? coc#_select_confirm() : + \ coc#expandableOrJumpable() ? "\=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\" : + \ check_back_space() ? "\" : + \ coc#refresh() + +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +let g:coc_snippet_next = '' + + +"SimpylFold Config +let g:SimpylFold_docstring_preview=1 + + +"NERDTree keybinds +nmap g :NERDTreeFind +nmap tt :NERDTreeFocus +let NERDTreeIgnore = ['__pycache__', '\.pyc$', '\.egg-info$', 'node_modules'] + + +"CtrlP config +nmap :CtrlPBuffer +let g:ctrlp_working_path_mode= 'ra' +let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git\|\.egg-info|\.pyc' + + +"fzf keybinds +let $FZF_DEFAULT_COMMAND = 'ag -g "" --ignore="(dist|*.svg)"' +nmap :FZF +nmap :Ag + + +"Wildignore +set wildignore+=*/node_modules/*,*/__pycache__/*,*.pyc,*.egg-info diff --git a/vimrc_vundle b/vimrc_vundle deleted file mode 100644 index 86cf721..0000000 --- a/vimrc_vundle +++ /dev/null @@ -1,93 +0,0 @@ -set nocompatible " be iMproved, required -filetype off " required - -nnoremap -let mapleader="\" -let g:mapleader="\" - -" set the runtime path to include Vundle and initialize -set rtp+=~/.vim/bundle/Vundle.vim -call vundle#begin() -" alternatively, pass a path where Vundle should install plugins -"call vundle#begin('~/some/path/here') - -" let Vundle manage Vundle, required -Plugin 'gmarik/Vundle.vim' - -" The following are examples of different formats supported. -" Keep Plugin commands between vundle#begin/end. -" plugin on GitHub repo -" plugin from http://vim-scripts.org/vim/scripts.html -Plugin 'tmhedberg/SimpylFold' -Plugin 'vimwiki/vimwiki' -Plugin 'kien/ctrlp.vim' -Plugin 'octol/vim-cpp-enhanced-highlight' -Plugin 'mattn/emmet-vim' -Plugin 'tpope/vim-surround' -Plugin 'scrooloose/nerdtree' - -" All of your Plugins must be added before the following line -call vundle#end() " required -filetype plugin indent on " required -" To ignore plugin indent changes, instead use: -"filetype plugin on -" -" Brief help -" :PluginList - lists configured plugins -" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate -" :PluginSearch foo - searches for foo; append `!` to refresh local cache -" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal -" -" see :h vundle for more details or wiki for FAQ -" Put your non-Plugin stuff after this line - -" this mapping Enter key to to chose the current highlight item -" and close the selection list, same as other IDEs. -" CONFLICT with some plugins like tpope/Endwise -inoremap pumvisible() ? "\" : "\u\" - -"SimpylFold Config -let g:SimpylFold_docstring_preview=1 - -"CtrlP config -let g:ctrlp_map = 'f' -nmap b :CtrlPBuffer -nmap r :CtrlPMRU - -"Ranger utility function -function! RangeChooser() - let temp = tempname() - " The option "--choosefiles" was added in ranger 1.5.1. Use the next line - " with ranger 1.4.2 through 1.5.0 instead. - "exec 'silent !ranger --choosefile=' . shellescape(temp) - exec 'silent !ranger --choosefiles=' . shellescape(temp) - if !filereadable(temp) - redraw! - " Nothing to read. - return - endif - let names = readfile(temp) - if empty(names) - redraw! - " Nothing to open. - return - endif - " Edit the first item. - exec 'tabe ' . fnameescape(names[0]) - " Add any remaning items to the arg list/buffer list. - for name in names[1:] - exec 'argadd ' . fnameescape(name) - endfor - redraw! -endfunction -command! -bar RangerChooser call RangeChooser() -nnoremap o :RangerChooser - -let g:ycm_server_python_interpreter="/usr/local/bin/python2" -let g:ycm_confirm_extra_conf=0 - -let g:user_emmet_leader_key="" - -"NERDTree settings -nnoremap tt :NERDTreeFocus -let NERDTreeIgnore = ['__pycache__', '\.pyc$']