Created
August 3, 2020 07:53
-
-
Save kyasu1/46cc593226c65af57959f66f1c32bb84 to your computer and use it in GitHub Desktop.
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
| " Specify a directory for plugins | |
| " - For Neovim: stdpath('data') . '/plugged' | |
| " - Avoid using standard Vim directory names like 'plugin' | |
| call plug#begin('~/.vim/plugged') | |
| Plug 'vim-scripts/sudo.vim' | |
| Plug 'bronson/vim-trailing-whitespace', { 'on': 'FixWhitespace' } | |
| Plug 'rking/ag.vim' | |
| Plug 'easymotion/vim-easymotion' | |
| Plug 'deris/vim-gothrough-jk' | |
| Plug 'vim-scripts/surround.vim' | |
| Plug 'scrooloose/nerdcommenter' | |
| Plug 'https://github.com/itchyny/lightline.vim' | |
| Plug 'https://github.com/Shougo/vimproc', { 'do': 'make' } | |
| Plug 'https://github.com/Shougo/neomru.vim' | |
| Plug 'vim-scripts/The-NERD-tree', { 'on': 'NERDTree' } | |
| Plug 'vim-scripts/desert256.vim' | |
| Plug 'morhetz/gruvbox' | |
| Plug 'https://github.com/airblade/vim-gitgutter' | |
| Plug 'tpope/vim-fugitive' | |
| " LSP | |
| Plug 'prabirshrestha/async.vim' | |
| Plug 'prabirshrestha/asyncomplete.vim' | |
| Plug 'prabirshrestha/asyncomplete-lsp.vim' | |
| Plug 'prabirshrestha/vim-lsp' | |
| Plug 'mattn/vim-lsp-settings' | |
| " Syntaxes | |
| Plug 'leshill/vim-json', { 'for': 'json' } | |
| Plug 'tpope/vim-haml', { 'for': 'haml' } | |
| " Plug 'othree/html5.vim', { 'for': 'html' } | |
| " Plug 'cakebaker/scss-syntax.vim', { 'for': 'scss' } | |
| Plug 'othree/yajs.vim', { 'for': 'javascript' } | |
| Plug 'maxmellon/vim-jsx-pretty', { 'for': 'javascript' } | |
| Plug 'plasticboy/vim-markdown', { 'for': 'markdown' } | |
| Plug 'cespare/vim-toml', { 'for': 'toml' } | |
| " Plug 'JulesWang/css.vim', { 'for': 'css' } | |
| Plug 'hail2u/vim-css3-syntax', { 'for': 'css' } | |
| " Initialize plugin system | |
| call plug#end() | |
| " ========================= " | |
| " General settings " | |
| " ========================= " | |
| scriptencoding utf-8 | |
| set tabstop=2 shiftwidth=2 softtabstop=2 | |
| set fencs=utf-8,euc-jp,iso-2022-jp,cp932 | |
| set matchpairs+=<:> | |
| set whichwrap+=h,l,<,>,[,],b,s,~ | |
| set autoindent | |
| set autoread | |
| set ambiwidth=double | |
| set expandtab | |
| set notitle | |
| set number | |
| set incsearch | |
| set hlsearch | |
| set ignorecase | |
| set smartcase | |
| set clipboard=unnamed | |
| set ruler | |
| set noswapfile | |
| set nowrap | |
| set confirm | |
| set title | |
| set ttyfast | |
| set cursorline | |
| set showmatch | |
| set showcmd | |
| set splitright | |
| set laststatus=2 | |
| set encoding=utf-8 | |
| set fileencoding=utf-8 | |
| set fileencodings=utf-8,iso-2022-jp,euc-jp,sjis | |
| set fileformats=unix,dos,mac | |
| set backspace=indent,eol,start | |
| set completeopt=menu,preview | |
| set updatetime=100 | |
| set relativenumber | |
| syntax on | |
| "silent! colorscheme desert256 | |
| "set background=light | |
| silent! colorscheme gruvbox | |
| filetype on | |
| autocmd BufEnter * silent! lcd %:p:h | |
| " Maps leader key | |
| let mapleader="," | |
| " Prevent performance slow-down with long line | |
| set synmaxcol=200 | |
| " Remove 'thank you for flying vim' | |
| let &titleold=getcwd() | |
| " ========================== " | |
| " Filetype detection " | |
| " ========================== " | |
| au BufRead,BufNewFile,BufReadPost *.erb set filetype=eruby.html | |
| au BufRead,BufNewFile,BufReadPost {*.ts,*.tsx} set filetype=typescript | |
| au BufRead,BufNewFile,BufReadPost *.elm set filetype=elm | |
| au BufRead,BufNewFile,BufReadPost *.toml set filetype=toml | |
| au BufRead,BufNewFile {COMMIT_EDITMSG} set filetype=gitcommit | |
| au BufRead,BufNewFile {.envrc,_bash*} set filetype=sh | |
| " Special tab/indent width | |
| au FileType c,cpp,go,python,elm set tabstop=4 shiftwidth=4 softtabstop=4 | |
| au FileType c,cpp set cindent | |
| " Check files' modifiction more frequently | |
| augroup checktime | |
| autocmd! | |
| autocmd WinEnter * checktime | |
| augroup END | |
| " Trim whitespace before saving a file except markdown | |
| au BufWritePre *\({*.md}\)\@<! :FixWhitespace | |
| nnoremap <silent>,tr :NERDTree<CR> | |
| nnoremap <F7> :Errors<CR> | |
| nnoremap <F8> :make<CR> | |
| command VIMRC edit $MYVIMRC | |
| command Encutf8 :e ++enc=utf8 | |
| command Sudow :w sudo:% | |
| command Sudoe :e sudo:% | |
| " Command to update tabs to spaces | |
| command ChangeTab2Space :call s:change_tab_function() | |
| function s:change_tab_function() | |
| set expandtab | |
| retab | |
| endfunction | |
| " =============================== " | |
| " Customized key mappings " | |
| " =============================== " | |
| nnoremap <C-t> :tabnew<CR> | |
| nnoremap <C-m> :tabn<CR> | |
| nnoremap <C-n> :tabp<CR> | |
| nnoremap <C-x> :q<CR> | |
| " Quick horizontal key manueuvers | |
| nmap <silent><C-h> b | |
| nmap <silent><C-l> w | |
| vmap <silent><C-h> b | |
| vmap <silent><C-l> w | |
| " Fix strange behavior of Backspace | |
| inoremap <expr><BS> "\<C-h>" | |
| " Visual mode key-mappings for multiple indents | |
| vnoremap > >gv | |
| vnoremap < <gv | |
| " Resets highlighting | |
| nnoremap <silent> <Esc><Esc> :noh<CR> :call clearmatches()<CR> | |
| " Block opening command history. | |
| " It is triggered off mistakenly when using :q | |
| nnoremap q: <NOP> | |
| " It applies ordinary Windows key binding for undo | |
| " On the default setting, Vim has Ctrl-Z for temporary quitting | |
| " with shell control system, but it is not actually useful. | |
| " nnoremap <silent>u <NOP> | |
| " nnoremap <silent><C-z> <NOP> | |
| " nnoremap <silent><C-z> :undo<CR> | |
| " Stop opening split windows with Ctrl+w+n | |
| " to block bumping with GNU screen keybinding to change windows | |
| nnoremap <C-w><C-n> <NOP> | |
| " Disable dot action | |
| nnoremap . <NOP> | |
| " Shift-free command mode in US layout | |
| nmap ; : | |
| " ================= " | |
| " vim-lsp " | |
| " ================= " | |
| let g:lsp_diagnostics_float_delay = 1000 | |
| let g:lsp_diagnostics_echo_delay = 1000 | |
| let g:lsp_documentation_float = 0 | |
| let g:lsp_settings = { | |
| \ 'elm-language-server': { | |
| \ 'initialization_options': { | |
| \ 'elmPath': './node_modules/.bin/elm', | |
| \ 'elmFormatPath': './node_modules/.bin/elm-format', | |
| \ 'elmTestPath': './node_modules/.bin/elm-test' | |
| \ } | |
| \ } | |
| \ } | |
| au BufWritePre {*.go,*.elm,*.ts,*.js} :LspDocumentFormatSync | |
| " nnoremap <leader>df :vert LspDefinition<CR> | |
| " nnoremap <leader>tt :tab LspDefinition<CR> | |
| " nnoremap <leader>ee :LspDocumentDiagnostics<CR> | |
| function! s:on_lsp_buffer_enabled() abort | |
| setlocal omnifunc=lsp#complete | |
| setlocal signcolumn=yes | |
| if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif | |
| nmap <buffer> gd <plug>(lsp-definition) | |
| nmap <buffer> gr <plug>(lsp-references) | |
| nmap <buffer> gi <plug>(lsp-implementation) | |
| nmap <buffer> gt <plug>(lsp-type-definition) | |
| nmap <buffer> <leader>rn <plug>(lsp-rename) | |
| nmap <buffer> [g <Plug>(lsp-previous-diagnostic) | |
| nmap <buffer> ]g <Plug>(lsp-next-diagnostic) | |
| nmap <buffer> K <plug>(lsp-hover) | |
| " refer to doc to add more commands | |
| endfunction | |
| " ====================== " | |
| " asyncomplete " | |
| " ====================== " | |
| let g:asyncomplete_popup_delay = 150 | |
| let g:asyncomplete_auto_popup = 0 | |
| set pumheight=30 | |
| inoremap <expr><CR> pumvisible() ? "<C-y>" : "<CR>" | |
| inoremap <expr><C-j> pumvisible() ? "<Down>" : "<C-j>" | |
| inoremap <expr><C-k> pumvisible() ? "<Up>" : "<C-k>" | |
| inoremap <expr><C-u> pumvisible() ? "<Up><Up><Up><Up><Up>" : "<C-u>" | |
| inoremap <expr><C-d> pumvisible() ? "<Down><Down><Down><Down><Down>" : "<C-d>" | |
| inoremap <expr><C-h> pumvisible() ? asyncomplete#cancel_popup() : "<C-h>" | |
| inoremap <expr><C-c> pumvisible() ? asyncomplete#cancel_popup() : "<C-c>" | |
| " Completion triggers (when CTRL-L or a period typed) | |
| inoremap <expr><C-l> pumvisible() ? asyncomplete#close_popup() : asyncomplete#force_refresh() | |
| imap . .<Plug>(asyncomplete_force_refresh) | |
| " ========================== " | |
| " Lightline settings " | |
| " ========================== " | |
| if !has('gui_running') | |
| set t_Co=256 | |
| endif | |
| let g:lightline = { | |
| \ 'colorscheme': 'one', | |
| \ 'active': { | |
| \ 'left': [ | |
| \ ['mode', 'paste'], | |
| \ ['readonly', 'filename', 'modified'] | |
| \ ], | |
| \ 'right': [ | |
| \ ['lineinfo'], | |
| \ ['fileformat', 'fileencoding', 'filetype'] | |
| \ ] | |
| \ }, | |
| \ 'component': { | |
| \ 'fugitive': '%{exists("*fugitive#head") ? "<".fugitive#head().">" : ""}', | |
| \ 'readonly': '%{&readonly ? "[LOCKED]" : ""}', | |
| \ } | |
| \ } | |
| " ============================= " | |
| " Git plugin settings " | |
| " ============================= " | |
| let g:git_command_edit = 'rightbelow vnew' | |
| nnoremap <silent>,gg :GitGutterToggle<CR> | |
| nnoremap <silent>,gh :GitGutterLineHighlightsToggle<CR> | |
| nnoremap <silent>,gl :GV!<CR> | |
| " ======================= " | |
| " Settings for Markdown " | |
| " ======================= " | |
| let g:vim_markdown_folding_disabled = 1 | |
| " =========================== " | |
| " Settings for easymotion " | |
| " =========================== " | |
| let g:EasyMotion_keys = 'hjklasdfgyuiopqwertnmzxcvbHJKLASDFGYUIOPQWERTNMZXCVB' | |
| let g:EasyMotion_do_mapping = 0 | |
| let g:EasyMotion_smartcase = 1 | |
| nmap <C-j> <Plug>(easymotion-s2) | |
| nmap <C-k> <Plug>(easymotion-s2) | |
| hi EasyMotionShade ctermbg=none ctermfg=blue | |
| " ================= " | |
| " NeedCommenter " | |
| " ================= " | |
| let g:NERDSpaceDelims = 1 | |
| " ==================== " | |
| " vim-gothrough-jk " | |
| " ==================== " | |
| let g:go_through_jk_reset_interval = 2000 | |
| let g:go_through_jk_move_count = 5 | |
| " ================= " | |
| " Highlight " | |
| " ================= " | |
| " Enable background transparency on Ubuntu. these highlight settings needs to be here. | |
| " highlight Normal ctermbg=none | |
| " highlight NonText ctermbg=none | |
| " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment