Last active
June 26, 2022 23:35
-
-
Save jbyman/620dd955c696508b501f8a7d88a87853 to your computer and use it in GitHub Desktop.
Vim Setup
This file contains hidden or 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
"COC Settings | |
let g:coc_global_extensions = [ 'coc-tsserver' ] | |
highlight FgCocErrorFloatBgCocFloating ctermfg=0 guifg=#585858 guibg=#ffffff | |
let g:coc_global_extensions = [ 'coc-tsserver', 'coc-eslint', 'coc-prettier', 'coc-json' ] | |
map <silent><C-]> :call CocAction('jumpDefinition')<CR> | |
vmap <silent><C-]> :<C-U> call CocAction('jumpDefinition')<CR> | |
map <silent><C-]> :call CocAction('jumpImplementation')<CR> | |
vmap <silent><C-]> :<C-U> call CocAction('jumpImplementation')<CR> | |
"Remap keys for applying codeAction to the current line. | |
nmap <silent> <leader>t <Plug>(coc-codeaction) | |
nmap <silent> <leader>r <Plug>(coc-fix-current) | |
"GoTo code navigation. | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) |
This file contains hidden or 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
{ | |
"eslint.enable": true, | |
"eslint.quiet": true, | |
"eslint.autoFixOnSave": false, | |
"eslint.executeAutofix": true, | |
"eslint.validate": [{ "language": "typescript", "autoFix": true }], | |
"coc.preferences.formatOnSaveFiletypes": ["*"], | |
"eslint.filetypes": [ | |
"javascript", | |
"typescript", | |
"typescriptreact", | |
"javascriptreact" | |
] | |
} |
This file contains hidden or 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
"Custom color scheme | |
colorscheme dark | |
syntax on | |
"Highlight Whitespace | |
highlight ExtraWhitespace ctermbg=red guibg=red | |
au ColorScheme * highlight ExtraWhitespace guibg=red | |
au BufEnter * match ExtraWhitespace /\s\+$/ | |
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/ | |
au InsertLeave * match ExtraWhiteSpace /\s\+$/ | |
"NGINX | |
autocmd BufRead,BufNewFile /etc/nginx/sites-*/* setfiletype conf | |
au BufRead,BufNewFile nginx.conf set ft=nginx | |
"Don’t conflict colors with iTerm | |
set termguicolors |
This file contains hidden or 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
function XitToIt() | |
:%s:\(\t\+\)xit(:\1it( | |
:%s:\(\t\+\)xdescribe(:\1describe( | |
endfunction | |
function ItToXit() | |
:%s:\(\t\+\)it(:\1xit( | |
:%s:\(\t\+\)describe(:\1xdescribe( | |
endfunction | |
if v:version >= 801 | |
set balloonevalterm | |
let g:ale_set_balloons = 1 | |
let balloondelay = 250 | |
endif | |
"Toggle hardcore mode | |
let s:isHardcore=0 | |
function ToggleHardcore() | |
if s:isHardcore | |
unmap h | |
unmap j | |
unmap k | |
unmap l | |
else | |
noremap h <Nop> | |
noremap j <Nop> | |
noremap k <Nop> | |
noremap l <Nop> | |
endif | |
let s:isHardcore = !s:isHardcore | |
endfunction | |
nnoremap <C-h> :call ToggleHardcore()<CR> |
This file contains hidden or 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
let mapleader = '\' | |
let $NVIM_COC_LOG_LEVEL = 'debug' | |
"Key bindings | |
source ~/.vim/mappings.vim | |
"Default formats for various formatting languages | |
autocmd filetype crontab setlocal nobackup nowritebackup | |
"General settings | |
source ~/.vim/settings.vim | |
"Formatting rules | |
source ~/.vim/formatting.vim | |
"Plugins | |
filetype plugin on | |
filetype plugin indent on | |
syntax enable | |
syntax on | |
source ~/.vim/plugins.vim | |
source ~/.vim/coc-settings.vim | |
"Omnicomplete (C-n and C-p to navigate) | |
set completeopt=longest,menuone | |
set complete-=i | |
"Ctags | |
set tags=../tags;tags;/ | |
"Make things faster | |
source ~/.vim/performance.vim | |
"Helper functions | |
source ~/.vim/functions.vim | |
"Swap files | |
set noswapfile | |
set re=0 |
This file contains hidden or 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
"Navigation | |
nnoremap <C-a> <esc>ggVG<CR> | |
nnoremap <Leader>b :Git blame<CR> | |
nnoremap <Space> : | |
nnoremap <Left> gT | |
nnoremap <Right> gt | |
nnoremap <BS> :bd<CR> | |
nnoremap <C-o> o<Esc> | |
nnoremap <C-j> :bprev<CR> | |
nnoremap <C-k> :bnext<CR> | |
nnoremap <Leader>r :set list!<CR> | |
"Multi-Paste | |
xnoremap p pgvy | |
"Smooth Scroll | |
noremap <silent> <c-u> :call smooth_scroll#up(&scroll, 0, 2)<CR> | |
noremap <silent> <c-d> :call smooth_scroll#down(&scroll, 0, 2)<CR> | |
noremap <silent> <c-b> :call smooth_scroll#up(&scroll*2, 0, 4)<CR> | |
noremap <silent> <c-f> :call smooth_scroll#down(&scroll*2, 0, 4)<CR> | |
"Search | |
nnoremap n nzz | |
nnoremap N Nzz | |
nnoremap * *zz | |
nnoremap # #zz | |
nnoremap g* g*zz | |
nnoremap g# g#zz | |
nnoremap <CR> :noh<CR><CR>:<backspace> | |
"Disable arrow keys | |
nnoremap <Up> <Nop> | |
nnoremap <Down> <Nop> | |
nnoremap <Up> <Nop> | |
nnoremap <Down> <Nop> | |
"Brace completion | |
inoremap {<CR> {<CR>}<Esc>ko | |
inoremap [<CR> [<CR>]<Esc>ko | |
inoremap (<CR> (<CR>)<Esc>ko | |
"Buffers | |
map <Leader><Tab> :bprevious<CR> | |
map <Tab> :bnext<CR> |
This file contains hidden or 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
function! s:Highlight_Matching_Pair() | |
endfunction | |
let g:loaded_matchparen = 1 | |
set redrawtime=10000 | |
syntax sync fromstart |
This file contains hidden or 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
call plug#begin('~/.vim/plugged') | |
Plug 'gmarik/Vundle.vim' | |
Plug 'tpope/vim-fugitive' | |
Plug 'junegunn/fzf' | |
"cs"<p> to replace double quotes with <p> tag, ysiw" to quote an unquoted word | |
"ds' to delete the surrounding single-quotes | |
Plug 'tpope/vim-surround' | |
Plug 'tpope/vim-sleuth' | |
Plug 'scrooloose/nerdtree' | |
""""\cc to comment, \cu to uncomment | |
Plug 'scrooloose/nerdcommenter' | |
Plug 'terryma/vim-smooth-scroll' | |
Plug 'MarcWeber/vim-addon-mw-utils' | |
Plug 'tomtom/tlib_vim' | |
Plug 'SirVer/ultisnips' | |
Plug 'honza/vim-snippets' | |
Plug 'henrik/vim-indexed-search' | |
Plug 'fatih/vim-go' | |
Plug 'chr4/nginx.vim' | |
Plug 'github/copilot.vim' | |
Plug 'jparise/vim-graphql' | |
Plug 'neoclide/coc.nvim' , { 'branch' : 'release' } | |
call plug#end() | |
"FZF | |
let g:fzf_action = { | |
\ 'ctrl-m': 'e', | |
\ 'ctrl-o': 'e', | |
\ 'ctrl-t': 'e', | |
\ 'ctrl-h': 'botright split', | |
\ 'ctrl-v': 'vertical botright split' } | |
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'] } | |
let g:fzf_layout = { 'down': '~40%' } | |
nnoremap <Leader>y :NERDTree<CR> | |
function! s:find_git_root() | |
return system('git rev-parse --show-toplevel 2> /dev/null')[:-2] | |
endfunction | |
command! ProjectFiles execute 'FZF' s:find_git_root() | |
nnoremap <Leader>f :ProjectFiles<CR> | |
"Snippets | |
let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/UltiSnips'] | |
let g:UltiSnipsExpandTrigger="<tab>" | |
let g:UltiSnipsJumpForwardTrigger="<tab>" | |
let g:UltiSnipsJumpBackwardTrigger="<c-b>" |
This file contains hidden or 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
set nowrap | |
set ignorecase | |
set title | |
set laststatus=2 | |
set smartcase | |
set history=1000 | |
set ruler | |
set incsearch | |
set visualbell | |
set autoindent | |
set copyindent | |
set number | |
set mouse=a | |
set expandtab | |
set tabstop=2 | |
set softtabstop=2 | |
set shiftwidth=2 | |
set backspace=indent,eol,start | |
set nocompatible | |
set nostartofline | |
set showmatch | |
set t_Co=256 | |
set autochdir | |
set nocursorcolumn | |
set nocursorline | |
set timeoutlen=1000 | |
set ttimeoutlen=0 | |
set ttyfast | |
set nolist | |
set listchars=tab:\|\ , | |
set path+=** | |
set relativenumber | |
set clipboard=unnamed | |
let g:go_version_warning = 0 | |
if has('mouse_sgr') | |
set ttymouse=sgr | |
endif | |
"Indentation for YAML files | |
augroup yaml_fix | |
autocmd! | |
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab indentkeys-=0# indentkeys-=<:> | |
augroup END | |
"Folding | |
set foldmethod=indent | |
set foldnestmax=10 | |
set nofoldenable | |
set foldlevel=2 | |
"Ignore errors | |
function Null(error, response) abort | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment