Skip to content

Instantly share code, notes, and snippets.

@hirochachacha
Created February 7, 2020 07:23
Show Gist options
  • Save hirochachacha/a3a3e2b5b832d15e374fc20db6c1e035 to your computer and use it in GitHub Desktop.
Save hirochachacha/a3a3e2b5b832d15e374fc20db6c1e035 to your computer and use it in GitHub Desktop.
nvim
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" On-demand loading
Plug 'Townk/vim-autoclose'
Plug 'fatih/vim-go'
Plug 'scrooloose/nerdcommenter'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-abolish'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'mileszs/ack.vim'
Plug 'altercation/vim-colors-solarized'
Plug 'dart-lang/dart-vim-plugin'
Plug 'rust-lang/rust.vim'
Plug 'racer-rust/vim-racer'
Plug 'mattn/emmet-vim'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'w0rp/ale'
Plug 'leafgarland/typescript-vim'
Plug 'tomlion/vim-solidity'
Plug 'hashivim/vim-terraform'
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/async.vim'
Plug 'ryanolsonx/vim-lsp-javascript'
Plug 'ryanolsonx/vim-lsp-typescript'
Plug 'ryanolsonx/vim-lsp-python'
Plug 'jparise/vim-graphql'
Plug 'lepture/vim-velocity'
" Add plugins to &runtimepath
call plug#end()
colorscheme solarized
"Edit
set autoindent
set expandtab
set shiftwidth=2
set tabstop=4
set tabstop=2
set iminsert=0
set imsearch=0
set tabpagemax=30
set number
set incsearch
set hlsearch
set autowrite
set noswapfile
set list
if (exists('+colorcolumn'))
set colorcolumn=80
highlight ColorColumn ctermbg=10
endif
"emacs like key bindings
noremap! <silent> <C-f> <Right>
noremap! <silent> <C-b> <Left>
noremap! <silent> <C-a> <HOME>
noremap! <silent> <C-e> <END>
"vimperator like key bindings
nnoremap <silent> <Space>d :q!<CR>
nnoremap <silent> <Space>e :Lex<CR>
nnoremap <silent> <Space>o :Explore<CR>
nnoremap <silent> <Space>t :tabnew .<CR>
nnoremap <silent> <Space>r :edit!<CR>
nnoremap <silent> <Space>l gt
nnoremap <silent> <Space>h gT
nnoremap <silent> <Space>y "*y
nnoremap <silent> <Space>p "*p
vnoremap <silent> <Space>y "*y
vnoremap <silent> <Space>p "*p
nnoremap <silent> <C-l> :tabmove+1<CR>
nnoremap <silent> <C-h> :tabmove-1<CR>
"quickfix
nnoremap <silent> <C-j> :Cnext<CR>
nnoremap <silent> <C-k> :Cprev<CR>
nnoremap <silent> <C-c> :cclose<CR>
command! Cnext try | cnext | catch | cfirst | catch | endtry
command! Cprev try | cprev | catch | clast | catch | endtry
command! Lnext try | lnext | catch | lfirst | catch | endtry
command! Lprev try | lprev | catch | llast | catch | endtry
" command! CLnext try | :Cnext | catch | :Lnext | endtry
" command! CLprev try | :Cprev | catch | :Lprev | endtry
" command! CLclose try | cclose | catch | lclose | endtry
"split and focus window
nnoremap <silent> <C-w>v <C-w>v<C-w>l
nnoremap <silent> <C-w>s <C-w>s<C-w>j
"cleanup high light
nnoremap <silent> <ESC><ESC> :nohlsearch<CR><ESC>
"nerdcommenter
let g:NERDCreateDefaultMappings = 0
let NERDSpaceDelims = 1
nmap <C-_> <Plug>NERDCommenterToggle
vmap <C-_> <Plug>NERDCommenterToggle
"delete needless spaces before writing
autocmd BufEnter * silent! lcd %:p:h
au BufNewFile,BufRead *.vm,*.vtl set ft=velocity
au FileType dart nmap <silent> ,r :!dart %<CR>
"vim-lsp
au FileType javascript nmap <C-i> :LspDefinition<CR>
au FileType javascript nmap ,< :LspReferences<CR>
au FileType javascript nmap ,e :LspRename<CR>
au FileType typescript nmap <C-i> :LspDefinition<CR>
au FileType typescript nmap ,< :LspReferences<CR>
au FileType typescript nmap ,e :LspRename<CR>
au FileType python nmap <C-i> :LspDefinition<CR>
au FileType python nmap ,< :LspReferences<CR>
au FileType python nmap ,e :LspRename<CR>
"vim-go
au FileType go nmap <C-i> <Plug>(go-def)
au FileType go nmap <silent> ,r :GoRun %<CR>
au FileType go nmap ,b <Plug>(go-build)
au FileType go nmap ,t <Plug>(go-test)
au FileType go nmap ,c <Plug>(go-coverage-toggle)
au FileType go nmap ,e <Plug>(go-rename)
au FileType go nmap ,< <Plug>(go-referrers)
au FileType go nmap <silent> ,p :GoPlay<CR>
au FileType go vmap <silent> ,p :GoPlay<CR>
setlocal cindent
setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
setlocal shiftwidth=2
setlocal softtabstop=2
setlocal textwidth=79
setlocal fo-=ro fo+=cql
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_fmt_command = "goimports"
let g:go_list_type = "quickfix"
let g:go_def_reuse_buffer = 1
let g:go_asmfmt_autosave = 0
"rust.vim
au FileType rust nmap <C-i> <Plug>(rust-def)
au FileType rust nmap <silent> ,r :RustRun %<CR>
au FileType rust nmap <silent> ,p :RustPlay<CR>
au FileType rust vmap <silent> ,p :RustPlay<CR>
let g:rustfmt_command = 'rustup run nightly rustfmt'
let g:rustfmt_autosave = 1
"vim-airline
let g:airline#extensions#tabline#enabled = 1
"ack.vim
let g:ackprg = 'ag --vimgrep --smart-case'
nnoremap <silent> ,g :exec "Ack ".expand("<cword>")[2:-3]<CR>
" set encoding=utf-8
" set fileencodings=iso-2022-jp,euc-jp,sjis,utf-8
let g:user_emmet_leader_key='<C-e>'
let g:jsx_ext_required = 0
let g:ale_fixers = {
\ 'javascript': [
\ 'prettier',
\ 'remove_trailing_lines',
\ 'trim_whitespace',
\ ],
\ 'typescript': [
\ 'eslint',
\ 'remove_trailing_lines',
\ 'trim_whitespace',
\ ],
\ 'python': [
\ 'remove_trailing_lines',
\ 'trim_whitespace',
\ ],
\ 'css': [
\ 'stylelint',
\ 'remove_trailing_lines',
\ 'trim_whitespace',
\ ],
\ 'xml': [
\ 'xmllint',
\ 'remove_trailing_lines',
\ 'trim_whitespace',
\ ],
\ 'java': [
\ 'google_java_format',
\ ],
\}
" \ 'eslint',
" \ 'remove_trailing_lines',
" \ 'trim_whitespace',
"\ 'prettier',
"\ 'remove_trailing_lines',
"\ 'trim_whitespace',
" \ 'prettier',
" \ 'black',
" \ 'prettier',
" \ 'eslint',
" \ 'tslint',
" \ 'black',
" \ 'black',
" \ 'yapf',
" \ 'isort',
" \ 'autopep8',
let g:ale_lint_on_text_changed = 'never'
let g:ale_fix_on_save = 1
let g:ale_lint_on_enter = 1
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
let g:ale_pattern_options = {
\ '.go$': {'ale_enabled': 0},
\ '.d.ts$': {'ale_enabled': 0}
\}
" let g:ale_open_list = 1
let g:lsp_virtual_text_enabled = 0
let g:terraform_align=1
let g:terraform_fold_sections=1
let g:terraform_remap_spacebar=1
let g:terraform_fmt_on_save=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment