Skip to content

Instantly share code, notes, and snippets.

@AceroM
Last active July 1, 2020 17:37
Show Gist options
  • Save AceroM/64dd2e89c3f5d834f6ee74c66551bace to your computer and use it in GitHub Desktop.
Save AceroM/64dd2e89c3f5d834f6ee74c66551bace to your computer and use it in GitHub Desktop.
Vimrc for mac system
" settings General
set number
set mouse=a
set relativenumber
set hlsearch
set guicursor=
set smartcase
set noswapfile
set tabstop=2 softtabstop=2 expandtab shiftwidth=2 smarttab
set undodir=~/.vim/undodir
set noshowmatch
set nocompatible
set noswapfile
set nobackup
set nowrap
set termguicolors
set scrolloff=9
set cmdheight=2
set updatetime=50
set colorcolumn=80
highlight ColorColumn ctermbg=0 guibg=lightgrey
syntax on
syntax enable " enable syntax processing
"Vundle
filetype off " required
" set the runtime path to include Vundle and initialize
call plug#begin('~/.vim/plugged')
Plug 'sheerun/vim-polyglot'
Plug 'ThePrimeagen/vim-be-good', {'do': './install.sh'}
Plug 'neoclide/coc.nvim', { 'do': './install.sh nightly' }
Plug 'VundleVim/Vundle.vim'
Plug 'tpope/vim-fugitive'
Plug 'rstacruz/sparkup', {'rtp': 'vim/'}
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-abolish'
Plug 'junegunn/fzf', {'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'morhetz/gruvbox'
Plug 'francoiscabrol/ranger.vim'
Plug 'mbbill/undotree'
Plug 'joereynolds/vim-minisnip'
Plug 'govim/govim'
Plug 'majutsushi/tagbar'
Plug 'jremmen/vim-ripgrep'
Plug 'ruanyl/vim-gh-line'
Plug 'vuciv/vim-bujo'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
call plug#end()
" filetype plugin indent on " required
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
" Setup for fzf
set rtp+=/usr/local/opt/fzf
let g:gruvbox_contrast_dark = 'hard'
colorscheme gruvbox
set background=dark
let mapleader = " "
" Mac specific remaps
nnoremap <leader>w :w<cr>
" Remaps
nnoremap <leader>w :w<cr>
nnoremap <leader>q :q!<cr>
nnoremap <leader>n :noh<cr>
nnoremap <leader>h :wincmd h<CR>
nnoremap <leader>j :wincmd j<CR>
nnoremap <leader>k :wincmd k<CR>
nnoremap <leader>l :wincmd l<CR>
nnoremap <Leader>+ :vertical resize +5<CR>
nnoremap <Leader>- :vertical resize -5<CR>
nnoremap <leader>c <C-^>
nnoremap gs :only<bar>vsplit<CR>gd
nnoremap <leader>d :echo expand('%:p')<CR>
" search and replace current word in the same line
nnoremap <Leader>s :s/\<<C-r><C-w>\>/
" search and replace current word globally
nnoremap <Leader>sg :%s/\<<C-r><C-w>\>/
" File stuff
nnoremap <C-p> :GFiles<CR>
nnoremap <leader>pf :Files<CR>
nnoremap <leader>u :UndotreeShow<CR>
noremap <Leader>y "*y
" Govim
nnoremap <leader>p : <C-u>call GOVIMHover()<CR>
" Ripgrep
nnoremap <leader>ps :Rg<SPACE>
" Tagbar
nnoremap <leader>t :TagbarToggle<CR>
" Code navigation
nmap <leader>gd <Plug>(coc-definition)
nmap <leader>gy <Plug>(coc-type-definition)
nmap <leader>gi <Plug>(coc-implementation)
nmap <leader>gr <Plug>(coc-references)
nmap <leader>rr <Plug>(coc-rename)
nmap <leader>g[ <Plug>(coc-diagnostic-prev)
nmap <leader>g] <Plug>(coc-diagnostic-next)
nmap <silent> <leader>gp <Plug>(coc-diagnostic-prev-error)
nmap <silent> <leader>gn <Plug>(coc-diagnostic-next-error)
nnoremap <leader>cr :CocRestart
" --- vim-bujo todo list
nmap <leader>ba <Plug>BujoAddnormal
imap <leader>ba <Plug>BujoAddinsert
nmap <leader>bd <Plug>BujoChecknormal
imap <leader>bd <Plug>BujoCheckinsert
" MarkdownPreview
nmap <leader>mp <Plug>MarkdownPreview
" Fugitive
nnoremap <leader>gvd :Gvdiff<CR>
nnoremap gdh :diffget //2<CR>
nnoremap gdl :diffget //3<CR>
" --- vim go (polyglot) settings.
let g:go_highlight_build_constraints = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_operators = 1
let g:go_highlight_structs = 1
let g:go_highlight_types = 1
let g:go_highlight_function_parameters = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_generate_tags = 1
let g:go_highlight_format_strings = 1
let g:go_highlight_variable_declarations = 1
let g:go_auto_sameids = 1
" --- ripgrep
" let g:rg_derive_root = 1
" Autoclose bracket
function! s:CloseBracket()
let line = getline('.')
if line =~# '^\s*\(struct\|class\|enum\) '
return "{\<Enter>};\<Esc>O"
elseif searchpair('(', '', ')', 'bmn', '', line('.'))
" Probably inside a function call. Close it off.
return "{\<Enter>})\<Esc>O"
else
return "{\<Enter>}\<Esc>O"
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment