2021-03-20 22:36:25 +00:00
|
|
|
" Install vim-plug if not found
|
2021-04-11 11:50:44 +00:00
|
|
|
if empty(glob('~/.vim/autoload/plug.vim'))
|
2021-03-20 22:36:25 +00:00
|
|
|
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
|
|
|
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Run PlugInstall if there are missing plugins
|
|
|
|
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
|
|
|
|
\| PlugInstall --sync | source $MYVIMRC
|
|
|
|
\| endif
|
|
|
|
|
2021-04-20 14:47:59 +00:00
|
|
|
"""""
|
2021-03-20 22:36:25 +00:00
|
|
|
"--- Plugins
|
2021-03-21 07:23:10 +00:00
|
|
|
call plug#begin('~/.vim/plugged')
|
2021-03-20 22:36:25 +00:00
|
|
|
|
2021-04-06 19:56:10 +00:00
|
|
|
" General
|
|
|
|
Plug 'ojroques/vim-oscyank'
|
|
|
|
Plug 'tpope/vim-obsession'
|
2021-04-11 11:50:44 +00:00
|
|
|
Plug 'tmux-plugins/vim-tmux-focus-events'
|
2021-04-06 19:56:10 +00:00
|
|
|
" Look
|
|
|
|
Plug 'vim-airline/vim-airline'
|
|
|
|
Plug 'sonph/onehalf', { 'rtp': 'vim' }
|
|
|
|
Plug 'Yggdroot/indentLine'
|
|
|
|
" Git
|
2021-03-20 22:36:25 +00:00
|
|
|
Plug 'tpope/vim-fugitive'
|
|
|
|
Plug 'airblade/vim-gitgutter'
|
2021-04-06 19:56:10 +00:00
|
|
|
" Search/Files
|
2021-03-20 22:36:25 +00:00
|
|
|
Plug 'preservim/nerdtree'
|
2021-03-21 07:23:10 +00:00
|
|
|
Plug 'ctrlpvim/ctrlp.vim'
|
2021-04-06 19:56:10 +00:00
|
|
|
" Ignore/Edit files
|
|
|
|
Plug 'vim-scripts/gitignore'
|
|
|
|
" Languages
|
2021-11-17 14:54:03 +00:00
|
|
|
Plug 'pantharshit00/vim-prisma'
|
2021-03-20 22:36:25 +00:00
|
|
|
Plug 'fatih/vim-go'
|
|
|
|
Plug 'pangloss/vim-javascript'
|
|
|
|
Plug 'leafgarland/typescript-vim'
|
|
|
|
Plug 'peitalin/vim-jsx-typescript'
|
|
|
|
Plug 'styled-components/vim-styled-components', { 'branch': 'main' }
|
|
|
|
Plug 'jparise/vim-graphql'
|
|
|
|
Plug 'kevinoid/vim-jsonc'
|
2021-11-17 14:54:03 +00:00
|
|
|
" protobuf with buf
|
|
|
|
Plug 'dense-analysis/ale'
|
|
|
|
Plug 'bufbuild/vim-buf'
|
|
|
|
let g:ale_linters = {
|
|
|
|
\ 'proto': ['buf-lint',],
|
|
|
|
\}
|
|
|
|
let g:ale_lint_on_text_changed = 'never'
|
|
|
|
let g:ale_linters_explicit = 1
|
2021-04-30 09:01:56 +00:00
|
|
|
" Code helpers
|
|
|
|
Plug 'jiangmiao/auto-pairs'
|
2021-03-20 22:36:25 +00:00
|
|
|
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
2021-04-30 09:01:56 +00:00
|
|
|
|
2021-03-21 07:23:10 +00:00
|
|
|
call plug#end()
|
2021-04-06 19:56:10 +00:00
|
|
|
|
2021-04-20 14:47:59 +00:00
|
|
|
"""""
|
2021-03-21 07:23:10 +00:00
|
|
|
"--- CodeServer Configurations
|
2021-03-20 22:36:25 +00:00
|
|
|
let g:coc_global_extensions = [
|
|
|
|
\ 'coc-tsserver',
|
2021-03-20 22:52:08 +00:00
|
|
|
\ 'coc-prettier',
|
2021-03-21 12:13:37 +00:00
|
|
|
\ 'coc-yaml',
|
2021-04-06 19:56:10 +00:00
|
|
|
\ 'coc-json',
|
|
|
|
\ 'coc-git',
|
2021-04-11 11:50:44 +00:00
|
|
|
\ 'coc-pyright'
|
2021-03-20 22:36:25 +00:00
|
|
|
\ ]
|
|
|
|
if isdirectory('./node_modules') && isdirectory('./node_modules/prettier')
|
|
|
|
let g:coc_global_extensions += ['coc-prettier']
|
|
|
|
endif
|
|
|
|
if isdirectory('./node_modules') && isdirectory('./node_modules/eslint')
|
|
|
|
let g:coc_global_extensions += ['coc-eslint']
|
|
|
|
endif
|
2021-04-06 19:56:10 +00:00
|
|
|
|
|
|
|
" Diagnostic list
|
|
|
|
nnoremap <silent> <space>d :<C-u>CocList diagnostics<cr>
|
|
|
|
" Symbols list
|
|
|
|
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
|
|
|
|
" Code actions
|
|
|
|
nmap <leader>do <Plug>(coc-codeaction)
|
2021-04-30 09:01:56 +00:00
|
|
|
" Rename current world
|
|
|
|
nmap <leader>rn <Plug>(coc-rename)
|
2021-04-06 19:56:10 +00:00
|
|
|
" 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
|
|
|
|
" 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)
|
2021-11-17 14:54:03 +00:00
|
|
|
" 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)
|
2021-04-06 19:56:10 +00:00
|
|
|
|
2021-04-20 14:47:59 +00:00
|
|
|
"""""
|
2021-03-20 22:36:25 +00:00
|
|
|
"--- TMUX/Clipboard fixes
|
|
|
|
set t_Co=256
|
2021-03-21 07:23:10 +00:00
|
|
|
set t_ut=
|
2021-03-20 22:36:25 +00:00
|
|
|
" Set Vim-specific sequences for RGB colors
|
|
|
|
" Fixes 'termguicolors' usage in vim+tmux
|
|
|
|
" :h xterm-true-color
|
|
|
|
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
|
|
|
|
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
|
|
|
|
" Enables 24-bit RGB color in the terminal
|
|
|
|
if has('termguicolors')
|
|
|
|
if empty($COLORTERM) || $COLORTERM =~# 'truecolor\|24bit'
|
|
|
|
set termguicolors
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
" Use system clipboard to get buffers synced between TMUX and VIM
|
|
|
|
if has('clipboard') && has('vim_starting')
|
|
|
|
" set clipboard& clipboard+=unnamedplus
|
|
|
|
set clipboard& clipboard^=unnamed,unnamedplus
|
|
|
|
endif
|
|
|
|
if exists('##TextYankPost')
|
|
|
|
augroup BlinkClipboardIntegration
|
|
|
|
autocmd!
|
2021-11-17 14:54:03 +00:00
|
|
|
autocmd TextYankPost * if v:event.operator is 'y' && v:event.regname is '' | execute 'OSCYankReg "' | endif
|
2021-03-20 22:36:25 +00:00
|
|
|
augroup END
|
|
|
|
endif
|
2021-04-06 19:56:10 +00:00
|
|
|
|
2021-04-20 14:47:59 +00:00
|
|
|
"""""
|
2021-03-21 07:23:10 +00:00
|
|
|
"--- VIM Configuration
|
2021-04-06 19:56:10 +00:00
|
|
|
set encoding=UTF-8
|
|
|
|
set autoread " will re-read opened file if changed externaly
|
|
|
|
set autowrite
|
|
|
|
set splitright
|
|
|
|
set splitbelow
|
|
|
|
|
|
|
|
set smarttab
|
|
|
|
set autoindent
|
|
|
|
set tabstop=2
|
|
|
|
set softtabstop=0
|
|
|
|
set vartabstop=
|
|
|
|
set shiftwidth=2
|
|
|
|
set expandtab
|
|
|
|
|
|
|
|
set noswapfile
|
|
|
|
set nobackup
|
|
|
|
set nowritebackup
|
|
|
|
set incsearch " search as you type
|
|
|
|
set ignorecase
|
|
|
|
set smartcase
|
|
|
|
set mouse=a
|
2021-04-11 11:50:44 +00:00
|
|
|
set ttymouse=sgr
|
2021-04-06 19:56:10 +00:00
|
|
|
set spell spelllang=en_us
|
|
|
|
set updatetime=300
|
2021-04-11 11:50:44 +00:00
|
|
|
set cmdheight=1
|
2021-04-06 19:56:10 +00:00
|
|
|
set hidden
|
|
|
|
set shortmess+=c
|
2021-03-21 15:09:03 +00:00
|
|
|
|
2021-04-20 14:47:59 +00:00
|
|
|
"""""
|
2021-03-21 15:09:03 +00:00
|
|
|
"- Custom commands
|
2021-03-21 12:39:42 +00:00
|
|
|
command! -nargs=0 Prettier :CocCommand prettier.formatFile
|
2021-03-21 12:13:37 +00:00
|
|
|
|
2021-04-20 14:47:59 +00:00
|
|
|
"""""
|
2021-04-06 19:56:10 +00:00
|
|
|
"- CtrlP
|
2021-04-20 14:47:59 +00:00
|
|
|
let g:ctrlp_max_files=0
|
|
|
|
let g:ctrlp_max_depth=40
|
|
|
|
let g:ctrlp_show_hidden=1
|
2021-04-06 19:56:10 +00:00
|
|
|
let g:ctrlp_custom_ignore = {
|
2021-11-17 14:54:03 +00:00
|
|
|
\ 'dir': '\.git$\|\.yardoc\|node_modules\|tmp$\|dist$',
|
2021-04-20 14:47:59 +00:00
|
|
|
\ 'file': '\.so$\|\.dat$|\.DS_Store$'
|
2021-04-06 19:56:10 +00:00
|
|
|
\ }
|
|
|
|
|
2021-04-20 14:47:59 +00:00
|
|
|
""""""
|
2021-03-21 15:09:03 +00:00
|
|
|
"- NERDTree
|
2021-04-20 14:47:59 +00:00
|
|
|
let NERDTreeShowHidden=1
|
|
|
|
let NERDTreeIgnore=['\.git$[[dir]]', 'node_modules$[[dir]]']
|
|
|
|
let NERDTreeRespectWildIgnore=1
|
|
|
|
let NERDTreeStatusline="NERDTree"
|
|
|
|
let NERDTreeMinimalUI=1
|
|
|
|
let NERDTreeCascadeSingleChildDir=1
|
2021-03-21 15:09:03 +00:00
|
|
|
nnoremap <leader>n :NERDTreeFocus<CR>
|
|
|
|
nnoremap <C-n> :NERDTree<CR>
|
|
|
|
nnoremap <C-f> :NERDTreeFind<CR>
|
|
|
|
nnoremap <leader>f 1z= " fix spelling
|
2021-04-06 19:56:10 +00:00
|
|
|
map <C-t> :call NERDTreeToggleAndRefresh()<CR>
|
|
|
|
function NERDTreeToggleAndRefresh()
|
|
|
|
:NERDTreeToggle
|
|
|
|
if g:NERDTree.IsOpen()
|
|
|
|
:NERDTreeRefreshRoot
|
|
|
|
endif
|
|
|
|
endfunction
|
2021-03-21 15:09:03 +00:00
|
|
|
|
2021-04-20 14:47:59 +00:00
|
|
|
"""""
|
2021-03-21 07:23:10 +00:00
|
|
|
"- Keybindings
|
2021-04-20 14:47:59 +00:00
|
|
|
nnoremap <SPACE> <Nop>
|
|
|
|
let mapleader = " "
|
2021-03-21 15:09:03 +00:00
|
|
|
|
2021-03-21 07:23:10 +00:00
|
|
|
let g:ctrlp_map = '<c-p>'
|
|
|
|
let g:ctrlp_cmd = 'CtrlP'
|
2021-03-20 22:36:25 +00:00
|
|
|
|
2021-04-20 14:47:59 +00:00
|
|
|
"""""
|
2021-03-21 07:23:10 +00:00
|
|
|
"- Visuals
|
2021-04-06 19:56:10 +00:00
|
|
|
set noshowmode
|
2021-03-21 07:23:10 +00:00
|
|
|
set number
|
2021-03-21 10:59:47 +00:00
|
|
|
set cursorline
|
2021-03-21 15:09:03 +00:00
|
|
|
set hlsearch " highlight all results
|
2021-03-21 15:12:08 +00:00
|
|
|
set signcolumn=yes " always show git diff column
|
2021-03-21 10:59:47 +00:00
|
|
|
colorscheme onehalflight
|
2021-04-11 11:50:44 +00:00
|
|
|
|
|
|
|
if !exists('g:airline_symbols')
|
|
|
|
let g:airline_symbols = {}
|
|
|
|
endif
|
|
|
|
let g:airline_symbols.branch = ''
|
|
|
|
let g:airline_symbols.dirty=' '
|
|
|
|
let g:airline_symbols.linenr = '☰ '
|
|
|
|
let g:airline_symbols.maxlinenr = ' '
|
|
|
|
let g:airline_left_sep=''
|
|
|
|
let g:airline_right_sep=''
|
|
|
|
|
|
|
|
let g:airline_detect_spell=0
|
|
|
|
let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
|
2021-03-21 10:59:47 +00:00
|
|
|
let g:airline_theme = 'onehalflight'
|