Skip to content

Instantly share code, notes, and snippets.

@diegosomar
Created April 15, 2020 23:11
Show Gist options
  • Save diegosomar/bd2b4e626d4066526222fc8f71a83bee to your computer and use it in GitHub Desktop.
Save diegosomar/bd2b4e626d4066526222fc8f71a83bee to your computer and use it in GitHub Desktop.
call plug#begin('~/.vim/plugged')
Plug 'jiangmiao/auto-pairs'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-surround'
Plug 'kien/ctrlp.vim'
Plug 'tpope/vim-commentary'
Plug 'joshdick/onedark.vim'
Plug 'pangloss/vim-javascript'
Plug 'othree/yajs.vim', {'for': 'javascript'}
Plug 'othree/es.next.syntax.vim', {'for': 'javascript'}
Plug 'HerringtonDarkholme/yats.vim'
Plug 'preservim/nerdtree'
Plug 'mattn/emmet-vim'
Plug 'mileszs/ack.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Syntax format for jsx
Plug 'maxmellon/vim-jsx-pretty'
call plug#end()
syntax on
" vim javascript
let g:javascript_plugin_jsdoc = 1
let g:javascript_plugin_ngdoc = 1
" ctrlp ignore folders
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git'
" Needed to tmux recongnize true colors
set termguicolors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set background=dark
let g:onedark_terminal_italics = 1
colorscheme onedark
set showmatch
set nowrap
set linebreak "Wrap lines at convenient points
set shiftwidth=2
set autoindent
set smartindent
set tabstop=2
set expandtab
set smarttab
set backspace=indent,eol,start
set laststatus=2
set cpoptions+=n
set modeline
set mouse=a
set number relativenumber
set clipboard=unnamed
set inccommand=split
set autoread " Vim will automatically read all changes made outside Vim.
set ruler " Display current line and column numbers, as `live, column`.
set splitright " open file in right split
" Auto indent pasted text
" nnoremap p p=`]<C-o>
" nnoremap P P=`]<C-o>
" ESC timeout
" https://www.johnhawthorn.com/2012/09/vi-escape-delays/
set timeoutlen=1000 ttimeoutlen=0
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
"" Enable hidden buffers
set hidden
set splitright " Puts the new splitted window right the current one.
set cursorline " Highlight the screen line of the cursor.
set nobackup " No backup files.
set nowb " Don't write backup files.
set noswapfile " No swap files.
set noundofile " Deactivate file backup.
" Prevent ENTER to add comments
" https://vi.stackexchange.com/a/17739/26842
au BufEnter * set fo-=c fo-=r fo-=o
let mapleader="\<space>"
" Short cuts:
map <C-p> :Files<CR>
map <leader>v :vertical :new<CR> " open new vertical window
map <leader>n :new<CR> " open a new horizontal window
map <leader>q :bd<CR> " it quit current vim buffer
map <leader><Left> :bp<CR> " move to previous tab
map <leader><Right> :bn<CR> " move to next tab
map <leader><Up> :CtrlPBuffer<cr>
nmap <silent> k :call CocAction('doHover')<CR>
" Completion
set wildmode=list:longest
set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing
set wildignore+=*vim/backups*
set wildignore+=*sass-cache*
set wildignore+=*DS_Store*
set wildignore+=vendor/rails/**
set wildignore+=vendor/cache/**
set wildignore+=*.gem
set wildignore+=log/**
set wildignore+=tmp/**
set wildignore+=*.png,*.jpg,*.gif
" CtrlP to ignore
set wildignore+=*.swp,*.pyc
let g:ctrlp_show_hidden = 1
" vim-airline
let g:airline_theme = 'powerlineish'
" let g:airline#extensions#branch#enabled = 1
" let g:airline#extensions#ale#enabled = 1
" let g:airline#extensions#tabline#enabled = 1
" let g:airline#extensions#tagbar#enabled = 0
" let g:airline_skip_empty_sections = 1
" vim-airline
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
if !exists('g:airline_powerline_fonts')
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline_left_sep = '‚ñ∂'
let g:airline_left_alt_sep = '»'
let g:airline_right_sep = '‚óÄ'
let g:airline_right_alt_sep = '¬´'
let g:airline#extensions#branch#prefix = '⤴' "➔, ➥, ⎇
let g:airline#extensions#readonly#symbol = '‚äò'
let g:airline#extensions#linecolumn#prefix = '¶'
let g:airline#extensions#paste#symbol = 'ρ'
let g:airline_symbols.linenr = '‚êä'
let g:airline_symbols.branch = '‚éá'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = '√û'
let g:airline_symbols.paste = '‚à•'
let g:airline_symbols.whitespace = 'Ξ'
endif
"" Encoding
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
set scrolloff=10 " Offset lines to top or bottom of a file
"" Clean search (highlight)
nnoremap <leader><tab> :noh<cr>
" Duplicate current line, like ST3
nnoremap <leader>d <ESC>yyp
:command! W w
:command! Q q
" no visual bell & flash
set vb t_vb=
" Add/Remove comments <c-/>
map <c-_> gcc
" Resize Vertical Splits
noremap <silent> <C-L> :vertical resize -5<CR>
noremap <silent> <C-H> :vertical resize +5<CR>
" Slash comments in scss are not gray
" The only way to keep comments in gray is to change the format to
autocmd FileType scss setlocal commentstring=/*%s*/
" Save with CTRL S
nnoremap <c-s> :w<cr>
nnoremap <S-Up> {
nnoremap <S-Down> }
" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__', '.DS_Store', '\.zip$']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=0
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeWinSize = 32
let g:NERDTreeShowHidden = 1
nnoremap <silent> <leader>l :NERDTreeFind<CR>
noremap <leader>t :NERDTreeToggle<CR>
autocmd vimenter * NERDTree "open a NERDTree automatically when vim starts up
" open a NERDTree automatically when vim starts up if no files were specified
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 vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | :bd | endif
" enable line numbers
let NERDTreeShowLineNumbers=1
" make sure relative line numbers are used
autocmd FileType nerdtree setlocal relativenumber
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
map <leader>f :Ack<space>
" Change tag expand from Emmet.vim
imap <S-tab> <plug>(emmet-expand-abbr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment