Skip to content

Instantly share code, notes, and snippets.

@jcortesg
Created January 17, 2022 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcortesg/4f04d823b13c9e2f63fce0ef43113497 to your computer and use it in GitHub Desktop.
Save jcortesg/4f04d823b13c9e2f63fce0ef43113497 to your computer and use it in GitHub Desktop.
set nocompatible
filetype off
filetype plugin indent on
syntax enable
call plug#begin('~/.config/nvim/plugged')
" Visuals "
Plug 'morhetz/gruvbox'
Plug 'chrisbra/Colorizer'
Plug 'honza/vim-snippets'
" Code navigation
Plug 'scrooloose/nerdtree'
Plug 't9md/vim-choosewin'
Plug 'easymotion/vim-easymotion'
" Search
Plug 'mileszs/ack.vim'
Plug 'skwp/greplace.vim'
" Util "
Plug 'pangloss/vim-javascript' " JavaScript support
Plug 'leafgarland/typescript-vim' " TypeScript syntax
Plug 'maxmellon/vim-jsx-pretty' " JS and JSX syntax
Plug 'jparise/vim-graphql' " GraphQL syntax
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
Plug 'elixir-editors/vim-elixir'
Plugin 'slim-template/vim-slim.git'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'airblade/vim-gitgutter'
Plug 'jxnblk/vim-mdx-js'
Plug 'tpope/vim-sleuth'
Plug 'tpope/vim-fugitive'
Plug 'mattn/emmet-vim'
Plug 'slashmili/alchemist.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
au FileType javascript setlocal formatprg=prettier
au FileType javascript.jsx setlocal formatprg=prettier
au FileType typescript setlocal formatprg=prettier\ — parser\ typescript
" General settings
" ----------------
set nobackup
set noswapfile
set nowritebackup
set lazyredraw " Don't redraw while executing macros
set autoread " Autoread from disk when a file changes
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=2
set shiftround
set autoindent
set smartindent
set modelines=1 " Open rcfiles as VIM files
set scrolloff=5 " Keep at least 5 lines below the cursor
set nofoldenable " Smells so bad when code needs folding
set history=500
set relativenumber
set number
set incsearch " Highlight when searching
set hlsearch " ...also other matches
set ignorecase
set smartcase
set nowrap
set formatoptions-=t " don't automatically wrap text while typing
set mouse=a " scroll with mouse as well
set backspace=indent,eol,start
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pdf,*.gz,*.beam
set cursorline
set noshowmode
set showmatch
set clipboard=unnamed " Natural copy/paste with macOS
set colorcolumn=80 " Make it obvious when lines are too long
set background=dark
colorscheme gruvbox
" Close a help file with the `q` key
autocmd Filetype help nmap <buffer> q :q<cr>
let mapleader = "\<space>"
let g:vim_jsx_pretty_colorful_config = 1
let g:deoplete#enable_at_startup = 1
" Phoenix & Elixir framework
let g:alchemist_tag_map = '<C-L>'
let g:alchemist_tag_stack_map = '<C-S>'
let g:alchemist_tag_disable = 1
let g:gutentags_cache_dir = '~/.tags_cache'
" CoC extensions
let g:coc_global_extensions = ['coc-tsserver']
" 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)
"Show hidden files at Nerdtree
let NERDTreeShowHidden=1
" ncm2 settings
set completeopt=menuone,noselect,noinsert
set shortmess+=c
inoremap <c-c> <ESC>
" make it fast
let ncm2#popup_delay = 5
let ncm2#complete_length = [[1, 1]]
" autocmd BufEnter * call ncm2#enable_for_buffer()
" autocmd BufEnter * call ncm2#enable_for_buffer()
" Use new fuzzy based matches
let g:ncm2#matcher = 'substrfuzzy'
" Disable Jedi-vim autocompletion and enable call-signatures options
let g:jedi#auto_initialization = 1
let g:jedi#completions_enabled = 0
let g:jedi#auto_vim_configuration = 0
let g:jedi#smart_auto_mappings = 0
let g:jedi#popup_on_dot = 0
let g:jedi#completions_command = ""
let g:jedi#show_call_signatures = "1"
" Use 0 to go to the beginning of text in the current line.
nmap 0 ^
" Behave like a good citizen when moving through wrapped lines
nmap j gj
nmap k gk
" The nvim config>:wa: is constantly tweaked, so I need a simple
" way to access it and reload it at will
nmap <leader>vi :tabe $MYVIMRC<cr>
nmap <leader>vo :source $MYVIMRC<cr>
" =========================================================
" Keymaps
" =========================================================
" Escape insert mode
imap fd <Esc>
" Panes
nnoremap <leader>w/ :vsp<cr>
nnoremap <leader>w- :sp<cr>
nnoremap <leader>x :close<cr>
" Files
nnoremap <leader>fs :w<cr>
nnoremap <leader>fS :wa<cr>
" Navigation
noremap K :Rg! <C-r>=expand('<cword>')<CR><CR>
nnoremap \ :Rg<SPACE>
nnoremap <C-p> :Files<cr>
nnoremap <leader>, :Buffers<cr>
nnoremap <leader>m :Marks<cr>
nnoremap <leader>s :Snippets<cr>
nnoremap <leader>ss :BLines<cr>
nnoremap <silent> <leader>. :Tags<cr>
nnoremap <leader>ft :NERDTreeToggle<cr>
nnoremap <leader>ff :NERDTreeFind<cr>
nnoremap <leader>as :Ag<space>
nnoremap <leader>sp :exe "Ag ".expand('<cword>')<cr>
nnoremap <leader>p :set paste<cr>o<esc>"*]p:set nopaste<cr>
nnoremap <leader>; :copen<cr>
nnoremap <leader>o :cclose<cr>
nnoremap <leader>gs :Magit<cr>
nnoremap <leader>h :nohlsearch<cr>
nnoremap <silent> <BS> :TmuxNavigateLeft<cr>
nmap - <Plug>(choosewin)
nnoremap <leader>qQ :qall<cr>
let g:tmux_navigator_save_on_switch = 2 " Save file before navigating to a tmux
" pane
" EasyAlign
xmap ,a <Plug>(EasyAlign)
nmap ,a <Plug>(EasyAlign)
" Disable exmode, I keep hitting it by accident
nnoremap Q <nop>
" Test runner
let test#strategy = "dispatch"
nmap <silent> ,tt :TestNearest<cr>
nmap <silent> ,ta :TestFile<cr>
nmap <silent> ,tA :TestSuite<cr>
nmap <silent> ,tl :TestLast<cr>
" Tmux runner
nnoremap <leader>ta :VtrAttachToPane<cr>
map <leader>ts :VtrSendLinesToRunner<cr>
" Greplace
set grepprg=ag
let g:grep_cmd_opts = '--line-numbers --noheading'
" Emmet
let g:user_emmet_install_global = 0
autocmd FileType html,css,eruby,hbs,handlebars,elixir,javascript.jsx,vue,*.tpl,jsx,javascript.tsx,tsx EmmetInstall
" Easymotion
let g:EasyMotion_do_mapping = 0
let g:EasyMotion_smartcase = 1
" map \ <Plug>(easymotion-overwin-f)
" map <leader>\ <Plug>(easymotion-bd-f)
map <leader>L <Plug>(easymotion-overwin-line)
map <leader>j <Plug>(easymotion-j)
map <leader>k <Plug>(easymotion-k)
" Ale linter only lint after the file is saved
let g:ale_linters = { 'javascript': ['eslint'], 'ruby': ['rubocop'] }
let g:ale_sign_column_always = 1
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_enter = 0
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ZOOM PANES
"""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap <silent> <leader>wm :ZoomToggle<cr>
function! s:ZoomToggle() abort
if exists('t:zoomed') && t:zoomed
execute t:zoom_winrestcmd
let t:zoomed = 0
else
let t:zoom_winrestcmd = winrestcmd()
resize
vertical resize
let t:zoomed = 1
endif
endfunction
command! ZoomToggle call s:ZoomToggle()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment