Skip to content

Instantly share code, notes, and snippets.

@artronics
Created February 27, 2020 19:24
Show Gist options
  • Save artronics/171b1d00342687814a3effd31138b790 to your computer and use it in GitHub Desktop.
Save artronics/171b1d00342687814a3effd31138b790 to your computer and use it in GitHub Desktop.
call plug#begin()
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug '907th/vim-auto-save'
Plug 'blueshirts/darcula', { 'as': 'darcula' }
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-commentary'
Plug 'vim-scripts/DoxygenToolkit.vim'
Plug 'liuchengxu/vim-clap', { 'do': ':Clap install-binary' }
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
Plug 'ludovicchabant/vim-gutentags'
Plug 'vim-syntastic/syntastic'
Plug 'jiangmiao/auto-pairs'
Plug 'rust-lang/rust.vim'
Plug 'majutsushi/tagbar'
call plug#end()
syntax on " enable syntax highlighting
"color darcula
color darcula
let mapleader = ','
inoremap jj <esc>
nnoremap <space> viw
vnoremap <space> e
nnoremap <bs> diw
nnoremap <leader>j 25j
nnoremap <leader>k 25k
nmap <esc> :noh<cr>
"nnoremap <cr> o<esc>
nnoremap <leader><leader> :w<cr>
filetype plugin on " load indent settings based on file type
set shiftwidth=2 " number of spaces to use for indenting
set softtabstop=2 " number of spaces to use when inserting a tab
set tabstop=2 " show tabs as 2 spaces
"set expandtab " convert tabs into spaces
set autoindent " copy indent from previous line
set nowrap " don't wrap long lines
set ignorecase smartcase " search case-insensitively unless uppercase characters are used
set hidden " allow unsaved buffers to be hidden
set number
set showcmd " show current command in status line
set notimeout " disable timeout for finishing a mapping key sequence
set visualbell " visual bell = no sounds
set undofile " store undo info in a file
set undodir=~/.vim-undo " where to store undo info
set mouse=a
set colorcolumn=120 " show vertical line at 120 chars
set scrolloff=3 " keep 3 lines visible above/below the cursor when scrolling
set sidescrolloff=7 " keep 7 characters visible to the left/right of the cursor when scrolling
set sidescroll=1 " scroll left/right one character at a time
set splitbelow splitright " put new windows below or to the right
set updatetime=250
set wildmenu
set wildmode=full
" Gutter
let g:GitGutterLineNrHighlightsEnable=1
" NERDTree
map º <esc>:NERDTreeToggle<cr>
map <c-i> <esc>:NERDTreeFind<cr>
" buffer
map <c-j> :bnext<cr>
map <c-k> :bprev<cr>
map <c-n> :Clap buffers<cr>
" fuzzy finder
"map <c-f> <esc>:Files<cr>
map <c-f> <esc>:Clap files<cr>
map § <esc>:Clap git_diff_files<cr>
" Terminal
" alt+9 new terminal with 15 lines hight
map ª <esc>:15split term://zsh<cr>
tnoremap <Esc> <C-\><C-n> " Exit terminal
" Commentary
map <c-c> <esc>Vgcj
" tags , use universal-ctags
set tags=tags;/
" ingore files and directories
set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png,*.ico
set wildignore+=*.pdf,*.psd
set wildignore+=node_modules/*,bower_components/*
set wildignore+=build,cmake-build-*
"autosave
let g:auto_save = 1 " enable AutoSave on Vim startup
let g:auto_save_silent = 1 " do not display the auto-save notification
" Open nerdtree if no file specified
"autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" Open it when opening a directory
" autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
" Close if it's a last window
" autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Sessions
" let g:sessions_dir = '~/.vim-sessions'
" exec 'nnoremap <Leader>ss :mks! ' . g:sessions_dir . '/*.vim<C-D><BS><BS><BS><BS><BS>'
" exec 'nnoremap <Leader>sr :so ' . g:sessions_dir. '/*.vim<C-D><BS><BS><BS><BS><BS>'
function! MakeSession(overwrite)
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
if (filewritable(b:sessiondir) != 2)
exe 'silent !mkdir -p ' b:sessiondir
redraw!
endif
let b:filename = b:sessiondir . '/session.vim'
if a:overwrite == 0 && !empty(glob(b:filename))
return
endif
exe "mksession! " . b:filename
endfunction
function! LoadSession()
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
let b:sessionfile = b:sessiondir . "/session.vim"
if (filereadable(b:sessionfile))
exe 'source ' b:sessionfile
else
echo "No session loaded."
endif
endfunction
" Adding automatons for when entering or leaving Vim
if(argc() == 0)
au VimEnter * nested :call LoadSession()
au VimEnter * NERDTree
au VimLeave * NERDTreeClose
au VimLeave * :call MakeSession(1)
else
au VimLeave * NERDTreeClose
au VimLeave * :call MakeSession(0)
endif
" Rust
"let g:rustfmt_autosave = 1
" Abbreviations
ab fro for
ab teh the
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment