Skip to content

Instantly share code, notes, and snippets.

@AK-10
Created December 13, 2020 16:42
Show Gist options
  • Save AK-10/dad4e087546b1a23a36b676eb7b8a1be to your computer and use it in GitHub Desktop.
Save AK-10/dad4e087546b1a23a36b676eb7b8a1be to your computer and use it in GitHub Desktop.
old vimrc
filetype plugin indent on
syntax on
" mapleader
let mapleader = ","
nnoremap <Leader>e :Explore<CR>
nnoremap <Leader>se :Sexplore<CR>
nnoremap <Leader>ve :Vexplore<CR>
set nocompatible
set backspace=indent,eol,start
set expandtab
set cursorline
set tabstop=4
set smartindent
set mouse=a
set number
set autoindent
set tabstop=4 "tab -> space変換時のサイズ
set shiftwidth=4
set expandtab
set clipboard=unnamed "yank = pbcopy
set whichwrap=b,s,h,l,<,>,[,],~
colorscheme muon
" popupの色変更
highlight Pmenu ctermfg=white ctermbg=darkgray
highlight PmenuSel ctermfg=black ctermbg=blue
augroup fileTypeIndent
autocmd!
autocmd BufNewFile,BufRead *.py setlocal tabstop=4 softtabstop=4 shiftwidth=4
autocmd BufNewFile,BufRead *.rb setlocal tabstop=2 softtabstop=2 shiftwidth=2
autocmd BufNewFile,BufRead *.swift setlocal tabstop=4 softtabstop=4 shiftwidth=4
autocmd BufNewFile,BufRead *.json setlocal tabstop=2 softtabstop=2 shiftwidth=2
augroup END
" Plugins will be downloaded under the specified directory.
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree' "file-explorer
Plug 'Yggdroot/indentLine' "visualize indent
Plug 'bronson/vim-trailing-whitespace' "highlight unnecessary white-space
Plug 'tpope/vim-endwise' " auto end
" ruby syntax highlight
Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' }
" FZF: あいまい検索
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
" language server
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
" super cool vim ui
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" swift syntax highlight
Plug 'keith/swift.vim'
Plug 'tpope/vim-fugitive'
" :XtermColorTable
Plug 'guns/xterm-color-table.vim'
" nginx syntax highlight
Plug 'chr4/nginx.vim'
Plug 'NLKNguyen/papercolor-theme'
call plug#end()
" nerdtree
map <C-n> :NERDTreeToggle<CR>
" airline
set laststatus=2
" let airline_theme = 'papercolor'
" colorscheme
" set t_Co=256 " This is may or may not needed.
" colorscheme PaperColor
" fzf
let g:fzf_action = {
\ 'ctrl-s': 'split' }
nnoremap <C-p> :FZFFileList<CR>
command! FZFFileList call fzf#run(fzf#wrap({
\ 'source': 'find . -type d -name .git -prune -o ! -name .DS_Store',
\ 'down': '40%'}))
nnoremap <C-b> :Buffers<CR>
" nnoremap <C-g> :Ag<CR>
" nnoremap <silent> <C-]> :call fzf#vim#tags(expand('<cword>'))<CR>
let g:fzf_buffers_jump = 1
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
" ripgrep
if executable('rg')
set grepprg=rg\ --vimgrep\ --no-heading
set grepformat=%f:%l:%c:%m,%f:%l:%m
endif
" fire fzf when called Rg
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
" mapping :Rg
nnoremap <C-g> :Rg<CR>
" vim-lsp config
let g:lsp_diagnostics_enabled = 1
let g:lsp_diagnostics_echo_cursor = 1
let g:asyncomplete_auto_popup = 1
let g:asyncomplete_popup_delay = 200
let g:lsp_text_edit_enabled = 1
" vim-lsp:debug
" let g:lsp_log_verbose = 1
let g:lsp_log_file = expand('~/.config/nvim/log/vim-lsp.log')
let g:asyncomplete_log_file = expand('~/.config/nvim/log/asyncomplete.log')
" vim-lsp: python
if executable('/Users/atsushikonishi/.pyenv/versions/3.7.4/bin/pyls')
autocmd! BufNewFile,BufRead *.py call lsp#register_server({
\ 'name': 'pyls',
\ 'cmd': {server_info->['/Users/atsushikonishi/.pyenv/versions/3.7.4/bin/pyls']},
\ 'whitelist': ['python'],
\ })
endif
if executable('/Users/atsushikonishi/.rbenv/versions/2.6.4/bin/solargraph')
au User lsp_setup call lsp#register_server({
\ 'name': 'solargraph',
\ 'cmd': {server_info->['/Users/atsushikonishi/.rbenv/versions/2.6.4/bin/solargraph', 'stdio']},
\ 'initialization_options': {"diagnostics": "true"},
\ 'whitelist': ['ruby'],
\ })
endif
" vim-lsp: swift
if executable('sourcekit-lsp')
autocmd! BufNewFile,BufRead *.swift call lsp#register_server({
\ 'name': 'sourcekit-lsp',
\ 'cmd': {server_info->['sourcekit-lsp']},
\ 'whitelist': ['swift'],
\ })
endif
" vim-lsp: c, c++
if executable('clangd')
au User lsp_setup call lsp#register_server({
\ 'name': 'clangd',
\ 'cmd': {server_info->['clangd', '-background-index']},
\ 'whitelist': ['c', 'cpp', 'objc', 'objcpp'],
\ })
endif
" vim-lsp: rust
if executable('rust-analyzer')
autocmd! BufNewFile,BufRead *.rs call lsp#register_server({
\ 'name': 'rust-analyzer',
\ 'cmd': {server_info->['rust-analyzer']},
\ 'whitelist': ['rust'],
\ })
endif
" vim-lsp code jump
nmap <silent> <Leader>d <Plug>(lsp-definition)
nmap <silent> <Leader>t <Plug>(lsp-type-definition)
nmap <silent> <Leader>i <Plug>(lsp-implementation)
nmap <silent> <Leader>r <Plug>(lsp-references)
nmap <silent> <Leader>sd :split \| :LspDefinition <CR>
nmap <silent> <Leader>st :split \| :LspTypeDefintion <CR>
nmap <silent> <Leader>si :split \| :LspImplementation <CR>
nmap <silent> <Leader>sr :split \| :LspReferences <CR>
nmap <silent> ]g <Plug>(lsp-next-diagnostic)
" tab utility
nnoremap <Leader>tn :tabnew<CR>
nnoremap th :tabprevious<CR>
nnoremap tl :tabnext<CR>
nnoremap tH :-tabmove<CR>
nnoremap tL :+tabmove<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment