Skip to content

Instantly share code, notes, and snippets.

@EduardoRodriguesF
Last active August 20, 2022 14:15
Show Gist options
  • Save EduardoRodriguesF/bd35ab735b9a8a09888a980f01701e29 to your computer and use it in GitHub Desktop.
Save EduardoRodriguesF/bd35ab735b9a8a09888a980f01701e29 to your computer and use it in GitHub Desktop.
Vim Settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" ██╗ ██╗██╗███╗ ███╗██████╗ ██████╗
" ██║ ██║██║████╗ ████║██╔══██╗██╔════╝
" ██║ ██║██║██╔████╔██║██████╔╝██║
" ╚██╗ ██╔╝██║██║╚██╔╝██║██╔══██╗██║
" ╚████╔╝ ██║██║ ╚═╝ ██║██║ ██║╚██████╗
" ╚═══╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" IMPORTANT BELLOW
"
"
" I have decided to migrate to neovim, and therefore this file is outdated.
" You can checkout my ACTUAL NEOVIM SETUP at:
" github.com/EduardoRodriguesF/nvim
"
"
" IMPORTANT ABOVE
" Based on FreeCodeCamp guide
" (https://www.freecodecamp.org/news/vimrc-configuration-guide-customize-your-vim-editor/)
" Disable compatibility with vi which can cause unexpected issues.
set nocompatible
" Enable type file detection. Vim will be able to try to detect the type of file in use.
filetype on
" Enable plugins and load plugin for the detected file type.
filetype plugin on
" Load an indent file for the detected file type.
filetype indent on
" Turn syntax highlighting on.
syntax on
" Add line numbers.
set number
" Show line numbers relative to current cursor position.
set relativenumber
" Highlight cursor line underneath the cursor horizontally.
set cursorline
" Tab indent width,
set shiftwidth=4
set tabstop=4
" Do not save backup files.
set nobackup
" Do not wrap lines.
set nowrap
" While searching though a file incrementally highlight matching characters as you type.
set incsearch
" Use highlighting when doing a search
set hlsearch
" Enable auto completion menu after pressing TAB.
set wildmenu
" Wildmenu will ignore files with these extensions
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
" Use highlighting when doing a search
set hlsearch
" Enable auto completino menu after pressing TAB.
set wildmenu
" Wildmenu will ignore files with these extensions.
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
" Sets update time to 500ms to avoid delay.
set updatetime=500
" Make cursor a line in insert.
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
" Keep VisualMode after indent with > or <
vmap < <gv
vmap > >gv
" Move Visual blocks with J an K
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" Plugins ------------ {{{
call plug#begin('~/.vim/plugged')
Plug 'preservim/nerdtree'
Plug 'scrooloose/nerdcommenter'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
Plug 'Yggdroot/indentLine'
Plug 'jiangmiao/auto-pairs'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'ryanoasis/vim-devicons'
Plug 'airblade/vim-gitgutter'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'liuchengxu/vim-which-key'
" omni colorscheme
Plug 'GuiLra/vim'
Plug 'sheerun/vim-polyglot'
Plug 'HerringtonDarkholme/yats.vim'
call plug#end()
colorscheme omni
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
let g:coc_global_extensions = [
\ 'coc-json',
\ 'coc-tsserver',
\ 'coc-prettier',
\ 'coc-eslint',
\ 'coc-css'
\ ]
" Adjust iskeyword option as coc-css docs suggest.
autocmd FileType css setl iskeyword+=-
" Fix coc-css for sass files.
autocmd FileType scss setl iskeyword+=@-@
" MAPPINGS --------------------------------------------------------------- {{{
" Set the backslash as the leader key.
let mapleader = ' '
" Press space-space to jump back to the last cursor position.
nnoremap <leader><space> ``
" Show key bindings for leader and localleader.
nnoremap <silent> <leader> :<c-u>WhichKey mapleader<CR>
nnoremap <silent> <localleader> :<c-u>WhichKey localleader<CR>
" Type jj to exit insert mode quickly.
inoremap jj <Esc>
" Center the cursor vertically when moving to the next word during a search.
nnoremap n nzz
nnoremap N Nzz
" Yank from cursor to the end of line.
nnoremap Y y$
" You can split the window in Vim by typing :split or :vsplit.
" Navigate the split view easier by pressing CTRL+j, CTRL+k, CTRL+h, or CTRL+l.
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" Resize split windows using arrow keys by pressing:
" CTRL+UP, CTRL+DOWN, CTRL+LEFT, or CTRL+RIGHT.
noremap <c-up> <c-w>+
noremap <c-down> <c-w>-
noremap <c-left> <c-w>>
noremap <c-right> <c-w><
" NERDTree specific mappings.
" Map the space+N to toggle NERDTree.
nnoremap <leader>n :NERDTreeToggle<cr>
" Have nerdtree ignore certain files and directories.
let NERDTreeIgnore=['\.git$', '\.jpg$', '\.mp4$', '\.ogg$', '\.iso$', '\.pdf$', '\.pyc$', '\.odt$', '\.png$', '\.gif$', '\.db$']
" FZF specific mappings.
" Map space+P to fuzzy find git files
nnoremap <leader>p :GFiles<cr>
" Map Ctrl+P to fuzzy find git files
nnoremap <leader>p :Files<cr>
" GitGutter specific mappings.
" Jump between hunks
nmap <Leader>gn <Plug>GitGutterNextHunk
nmap <Leader>gp <Plug>GitGutterPrevHunk
" Hunk-add and hunk-revert for chunk staging
nmap <Leader>ga <Plug>GitGutterStageHunk
nmap <Leader>gu <Plug>GitGutterUndoHunk
" }}}
{
"suggest.noselect": false,
"coc.preferences.formatOnSaveFiletypes": [
"json",
"css",
"markdown",
"javascript",
"javascriptreact",
"typescript",
"typescript.tsx",
"typescriptreact",
"graphql"
],
"eslint.autoFixOnSave": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment