Created
January 4, 2019 02:32
-
-
Save hungdh0x5e/ba7d1bd5ce3c793aa35ceb7d3ec3c0de to your computer and use it in GitHub Desktop.
configuration for vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ============= BEGIN BASIC CONFIGURATION ============= | |
set nocompatible | |
set number | |
syntax on | |
filetype plugin indent on | |
filetype on | |
filetype indent on | |
filetype plugin on | |
set clipboard=unnamed | |
set backspace=indent,eol,start | |
" Set mouse | |
if has('mouse') | |
set mouse=a | |
endif | |
" Set default font and size | |
set guifont=Monaco:h16 | |
" Auto load when file changed | |
set autoread | |
set autowrite | |
set nobackup | |
set nowb | |
set noswapfile | |
set backupdir=~/tmp,/tmp | |
set backupcopy=yes | |
set backupskip=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/* | |
set directory=/tmp | |
" Set spell check | |
set spell spelllang=en_ca | |
let loaded_netrwPlug = 1 | |
let mapleader=" " " Set Space for Leader key | |
" remap splitting windows | |
nnoremap <C-h> <C-w>h | |
nnoremap <C-j> <C-w>j | |
nnoremap <C-k> <C-w>k | |
nnoremap <C-l> <C-w>l " remap splits | |
nmap :vs :vsplit | |
nmap :s :split | |
" Indent for each language | |
autocmd FileType ruby setlocal expandtab shiftwidth=2 tabstop=2 | |
autocmd FileType eruby setlocal expandtab shiftwidth=2 tabstop=2 | |
" ============= END BASIC CONFIGURATION ============ | |
"Pathogen | |
set nocp | |
call pathogen#infect() | |
" Fzf search enable | |
set rtp+=/usr/local/opt/fzf | |
" set ctrlP plugin | |
set runtimepath^=~/.vim/bundle/ctrlp.vim | |
" allow vim to jump through directories for ctags | |
set tags=tags;/ | |
syntax enable | |
let g:solarized_termcolors = 16 | |
call plug#begin('~/.vim/plugged') | |
" ============= BEGIN INSTALL PLUGINS ============ | |
" Ocean theme VS | |
Plug 'mhartington/oceanic-next' | |
if (has("termguicolors")) | |
set termguicolors | |
endif | |
colorscheme OceanicNext | |
set background=dark | |
let g:oceanic_next_terminal_italic = 1 | |
let g:oceanic_next_terminal_bold = 1 | |
" plugin on GitHub repo | |
Plug 'tpope/vim-fugitive' | |
" Scala highlights | |
Plug 'derekwyatt/vim-scala' | |
" show git diff in vim | |
Plug 'airblade/vim-gitgutter' | |
" Auto completed | |
" Plug 'Shougo/deoplete.nvim' | |
" Plug 'roxma/nvim-yarp' | |
" Plug 'roxma/vim-hug-neovim-rpc' | |
" let g:deoplete#enable_at_startup = 1 | |
" Install L9 and avoid a Naming conflict if you've already | |
" installed a | |
" different version somewhere else. | |
Plug 'ascenator/L9', {'name': 'newL9'} | |
Plug 'vim-ruby/vim-ruby' | |
Plug 'tpope/vim-rails' | |
Plug 'tpope/vim-endwise' | |
Plug 'tpope/vim-bundler' | |
Plug 'thoughtbot/vim-rspec' | |
Plug 'MarcWeber/vim-addon-mw-utils' | |
Plug 'tomtom/tlib_vim' | |
Plug 'garbas/vim-snipmate' | |
" Fzg plugin | |
Plug '/usr/local/opt/fzf' | |
Plug 'junegunn/fzf.vim' | |
" remap envoke key | |
" nnoremap <silent> <C-z> :FZF<CR> | |
" Ripgrep | |
Plug 'jremmen/vim-ripgrep' | |
let g:rg_highligh = 1 | |
" Quick comment toggling | |
Plug 'tpope/vim-commentary' | |
noremap <Leader>/ :Commentary<CR> | |
" Files stucture tree | |
Plug 'scrooloose/nerdtree' | |
" Multiple cursors | |
Plug 'terryma/vim-multiple-cursors' | |
" ============= END INSTALL PLUGINS ============ | |
call plug#end() | |
" Move up and down in autocomplete with <c-j> and <c-k> | |
inoremap <expr> <c-j> ("\<C-n>") | |
inoremap <expr> <c-k> ("\<C-p>") | |
" Customize fzf key | |
nnoremap <c-p> :Files<CR> | |
nnoremap <c-b> :Buffer<CR> | |
nmap <Leader>f :GFiles<CR> | |
nmap <Leader>F :Files<CR> | |
nmap <Leader>b :Buffers<CR> | |
nmap <Leader>h :History<CR> | |
nmap <Leader>t :BTags<CR> | |
nmap <Leader>T :Tags<CR> | |
" Customize fzf colors to match your color scheme | |
let g:fzf_colors = | |
\ { 'fg': ['fg', 'Normal'], | |
\ 'bg': ['bg', 'Normal'], | |
\ 'hl': ['fg', 'Comment'], | |
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], | |
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], | |
\ 'hl+': ['fg', 'Statement'], | |
\ 'info': ['fg', 'PreProc'], | |
\ 'border': ['fg', 'Ignore'], | |
\ 'prompt': ['fg', 'Conditional'], | |
\ 'pointer': ['fg', 'Exception'], | |
\ 'marker': ['fg', 'Keyword'], | |
\ 'spinner': ['fg', 'Label'], | |
\ 'header': ['fg', 'Comment'] } | |
" vim-ruby | |
let g:ruby_indent_access_modifier_style = 'normal' | |
let g:ruby_indent_assignment_style = 'variable' | |
let g:ruby_indent_block_style = 'do' | |
" NERDTree Configuration | |
" How can I close vim if the only window left open is a NERDTree? | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
" using - to toggle NERDTree | |
map - :NERDTreeToggle<CR> | |
map <leader>r :NERDTreeFind<cr> " this is the key to jump to the nerdtree window from any other window | |
" autocmd BufWinEnter * NERDTreeFind | |
map ] :NERDTreeFind<CR> " pressing this inside any open file in vim will jump to the nerdtree and highlight where that file is -> very useful when you have multiple files open at once | |
let g:NERDTreeChDirMode=2 | |
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__', 'node_modules', 'tmp'] | |
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$'] | |
let g:NERDTreeShowBookmarks=1 | |
let g:nerdtree_tabs_focus_on_files=1 | |
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>' | |
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite | |
nmap <Leader>v :e ~/.vimrc<CR> " Quickly edit .vimrc file | |
noremap <Leader><Leader>s :so ~/.vimrc<CR> " Source .vimrc file | |
" Multiple cursors | |
function! Multiple_cursors_before() | |
if exists(':NeoCompleteLock')==2 | |
exe 'NeoCompleteLock' | |
endif | |
endfunction | |
function! Multiple_cursors_after() | |
if exists(':NeoCompleteUnlock')==2 | |
exe 'NeoCompleteUnlock' | |
endif | |
endfunction | |
" Rename current file | |
function! RenameFile() | |
let old_name = expand('%') | |
let new_name = input('New file name: ', expand('%'), 'file') | |
if new_name != '' && new_name != old_name | |
exec ':saveas ' . new_name | |
exec ':silent !rm ' . old_name | |
redraw! | |
endif | |
endfunction | |
map <Leader>rnf :call RenameFile()<cr> | |
" Configuration for markdown preview | |
let g:instant_markdown_slow = 1 | |
let g:instant_markdown_autostart = 0 | |
nmap :preview :InstantMarkdownPreview |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment