Last active
October 22, 2021 01:56
-
-
Save simon-lang/50e67b1779cb147848792b576b6dd422 to your computer and use it in GitHub Desktop.
This file contains 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
syntax on | |
" colorscheme onedark | |
set shortmess=I | |
set backspace=start,eol,indent | |
" set colorcolumn=80 | |
" set cursorline | |
set expandtab | |
set foldlevel=2 | |
set foldmethod=indent | |
set foldnestmax=10 | |
set incsearch | |
set nobackup | |
set noerrorbells | |
set nofoldenable | |
set noswapfile | |
set nowrap | |
set nu | |
set rnu | |
set scrolloff=10 | |
set shiftwidth=4 | |
set ignorecase | |
set smartcase | |
set smartindent | |
set softtabstop=4 | |
set tabstop=4 | |
set hlsearch | |
set hidden | |
" highlight ColorColumn ctermbg=0 guibg=lightgrey | |
call plug#begin('~/.vim/plugged') | |
Plug 'elzr/vim-json' | |
Plug 'codeindulgence/vim-tig' | |
Plug 'leafgarland/typescript-vim' | |
Plug 'peitalin/vim-jsx-typescript' | |
Plug 'Galooshi/vim-import-js' | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'joshdick/onedark.vim' | |
Plug 'mhartington/oceanic-next' | |
Plug 'junegunn/vim-peekaboo' | |
Plug 'tpope/vim-commentary' | |
Plug 'tpope/vim-surround' | |
Plug 'preservim/nerdtree' | |
Plug 'mbbill/undotree' | |
Plug 'vim-airline/vim-airline' | |
Plug 'SirVer/ultisnips' | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'ervandew/supertab' | |
Plug 'mattn/emmet-vim' | |
Plug 'tpope/vim-fugitive' | |
Plug 'ruanyl/vim-fixmyjs' | |
Plug 'junegunn/goyo.vim' | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'junegunn/fzf.vim' | |
Plug 'ervandew/ag' | |
Plug 'mileszs/ack.vim' | |
Plug 'andreshazard/vim-freemarker' | |
call plug#end() | |
let mapleader = " " | |
let g:user_emmet_leader_key='<C-Z>' | |
let NERDTreeShowHidden=1 | |
" nnoremap <C-`> :bprev<CR> | |
map Q <Nop> | |
nnoremap <silent> <leader><Home> ^ | |
" NERDTree | |
nnoremap <silent> <leader>d :NERDTreeToggle<CR> | |
nnoremap <silent> <leader>f :NERDTreeFind<CR> | |
nnoremap <Tab> :bnext<CR> | |
nnoremap <S-Tab> :bprevious<CR> | |
" Save file with Ctrl+S | |
noremap <silent> <C-S> :update<CR> | |
vnoremap <silent> <C-S> <C-C>:update<CR> | |
inoremap <silent> <C-S> <C-O>:update<CR> | |
" Toggle Whitespace | |
set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:. | |
noremap <F5> :set list!<CR> | |
inoremap <F5> <C-o>:set list!<CR> | |
cnoremap <F5> <C-c>:set list!<CR> | |
" indenting? | |
vnoremap < <gv | |
vnoremap > >gv | |
" sneaky exit insert mode | |
imap jj <Esc> | |
imap kk <Esc> | |
" git stuff | |
map <C-G> :Tig<Cr> | |
map <C-H> :Tig!<Cr> | |
nmap <leader>bq :bp <BAR> bd #<CR> | |
nmap <leader>gb :Gblame<CR> | |
nmap <leader>gh :diffget //3<CR> | |
nmap <leader>gu :diffget //2<CR> | |
nmap <leader>gs :G<CR> | |
" navigation between panes | |
map <leader><Left> :wincmd h<CR> | |
map <leader><Down> :wincmd j<CR> | |
map <leader><Up> :wincmd k<CR> | |
map <leader><Right> :wincmd l<CR> | |
map <leader>h :wincmd h<CR> | |
map <leader>j :wincmd j<CR> | |
map <leader>k :wincmd k<CR> | |
map <leader>l :wincmd l<CR> | |
" Function keys | |
noremap <F3> :set invnumber invrelativenumber<CR> | |
noremap <F4> :Goyo<CR> | |
" noremap <F7> :%bd<CR>e#<CR> | |
map <F6> :set invpaste<CR> | |
map <F8> =it | |
inoremap <F9> <Esc><CR> | |
noremap <F9> :w<CR>:Fixmyjs<CR> | |
noremap <F10> :noh<CR> | |
" Ag | |
nmap <A-S-F> :Ag!<space> | |
let g:ag_working_path_mode="r" | |
nnoremap \ :Ag!<space> | |
nnoremap \| :Ag! "\b<C-R><C-W>\b"<cr>:cw<cr> | |
" FZF | |
" nnoremap <leader>p :FZF<cr> | |
" map <C-P> :FZF<cr> | |
nnoremap <leader>r :Buffers<cr> | |
nnoremap <leader>t :GFiles<CR> | |
nnoremap <leader>p :GFiles<CR> | |
nnoremap <leader>0 <End> | |
nnoremap <leader>$ ^ | |
set ttimeoutlen=50 | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline#extensions#tabline#formatter = 'unique_tail' | |
function! s:goyo_enter() | |
set wrap | |
CocDisable | |
endfunction | |
function! s:goyo_leave() | |
set nowrap | |
CocEnable | |
endfunction | |
autocmd! User GoyoEnter nested call <SID>goyo_enter() | |
autocmd! User GoyoLeave nested call <SID>goyo_leave() | |
command! BufOnly silent! execute "%bd|e#|bd#" | |
" Always show the signcolumn, otherwise it would shift the text each time | |
" diagnostics appear/become resolved. | |
if has("patch-8.1.1564") | |
" Recently vim can merge signcolumn and number column into one | |
set signcolumn=number | |
else | |
set signcolumn=yes | |
endif | |
" Use <c-space> to trigger completion. | |
if has('nvim') | |
inoremap <silent><expr> <c-space> coc#refresh() | |
else | |
inoremap <silent><expr> <c-@> coc#refresh() | |
endif | |
" Use `[g` and `]g` to navigate diagnostics | |
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. | |
nmap <silent> [g <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]g <Plug>(coc-diagnostic-next) | |
" 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) | |
" Use K to show documentation in preview window. | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
elseif (coc#rpc#ready()) | |
call CocActionAsync('doHover') | |
else | |
execute '!' . &keywordprg . " " . expand('<cword>') | |
endif | |
endfunction | |
" Highlight the symbol and its references when holding the cursor. | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" Symbol renaming. | |
" nmap <leader>rn <Plug>(coc-rename) | |
" Formatting selected code. | |
" xmap <leader>f <Plug>(coc-format-selected) | |
" nmap <leader>f <Plug>(coc-format-selected) | |
augroup mygroup | |
autocmd! | |
" Setup formatexpr specified filetype(s). | |
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') | |
" Update signature help on jump placeholder. | |
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') | |
augroup end | |
" Applying codeAction to the selected region. | |
" Example: `<leader>aap` for current paragraph | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
" Remap keys for applying codeAction to the current buffer. | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Apply AutoFix to problem on the current line. | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" Map function and class text objects | |
" NOTE: Requires 'textDocument.documentSymbol' support from the language server. | |
xmap if <Plug>(coc-funcobj-i) | |
omap if <Plug>(coc-funcobj-i) | |
xmap af <Plug>(coc-funcobj-a) | |
omap af <Plug>(coc-funcobj-a) | |
xmap ic <Plug>(coc-classobj-i) | |
omap ic <Plug>(coc-classobj-i) | |
xmap ac <Plug>(coc-classobj-a) | |
omap ac <Plug>(coc-classobj-a) | |
" Remap <C-f> and <C-b> for scroll float windows/popups. | |
if has('nvim-0.4.0') || has('patch-8.2.0750') | |
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" | |
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" | |
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" | |
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" | |
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" | |
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" | |
endif | |
" Add `:Format` command to format current buffer. | |
command! -nargs=0 Format :call CocAction('format') | |
" Add `:Fold` command to fold current buffer. | |
command! -nargs=? Fold :call CocAction('fold', <f-args>) | |
" Add `:OR` command for organize imports of the current buffer. | |
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') | |
" Add (Neo)Vim's native statusline support. | |
" NOTE: Please see `:h coc-status` for integrations with external plugins that | |
" provide custom statusline: lightline.vim, vim-airline. | |
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} | |
" Mappings for CoCList | |
" Show all diagnostics. | |
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr> | |
" Manage extensions. | |
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr> | |
" Show commands. | |
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr> | |
" Find symbol of current document. | |
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr> | |
" Search workspace symbols. | |
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr> | |
" Do default action for next item. | |
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR> | |
" Do default action for previous item. | |
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR> | |
" Resume latest coc list. | |
" nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR> | |
" | |
set termguicolors | |
colorscheme OceanicNext |
export FZF_DEFAULT_COMMAND="rg --files --no-ignore --hidden --follow --glob '!.git/*' --glob '!dist/*' --glob '!node_modules/*'"
command! BufOnly silent! execute "%bd|e#|bd#"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Find and replace with Ag:
junegunn/fzf.vim#528 (comment)