Skip to content

Instantly share code, notes, and snippets.

@k2works
Last active December 16, 2020 04:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k2works/b32efc6644dd41e4629503cc1443c54f to your computer and use it in GitHub Desktop.
Save k2works/b32efc6644dd41e4629503cc1443c54f to your computer and use it in GitHub Desktop.
neovim
set encoding=utf-8 " バッファ内で扱う文字コード
"----------------------------------------------------------
" パッケージマネージャ
"----------------------------------------------------------
if &compatible
set nocompatible
endif
" add the dein installation directory into runtimepath
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim
if dein#load_state('~/.cache/dein')
call dein#begin('~/.cache/dein')
call dein#add('~/.cache/dein/repos/github.com/Shougo/dein.vim')
call dein#add('shougo/deoplete.nvim')
if !has('nvim')
call dein#add('roxma/nvim-yarp')
call dein#add('roxma/vim-hug-neovim-rpc')
endif
" インストールするvimプラグインを以下に記述
" カラースキームmolokai
call dein#add('tomasr/molokai')
" ステータスラインの表示内容強化
call dein#add('itchyny/lightline.vim')
call dein#add('vim-airline/vim-airline')
call dein#add('vim-airline/vim-airline-themes')
" インデントの可視化
call dein#add('yggdroot/indentline')
" 末尾の全角半角空白文字を赤くハイライト
call dein#add('bronson/vim-trailing-whitespace')
" 構文エラーチェック
call dein#add('scrooloose/syntastic')
" 多機能セレクタ
call dein#add('ctrlpvim/ctrlp.vim')
" ctrlpの拡張プラグイン. 関数検索
call dein#add('tacahiroy/ctrlp-funky')
" ctrlpの拡張プラグイン. コマンド履歴検索
call dein#add('suy/vim-ctrlp-commandline')
call dein#add('rking/ag.vim')
" プロジェクトに入ってるESLintを読み込む
call dein#add('pmsorhaindo/syntastic-local-eslint.vim')
" 閉じ括弧を補完する
call dein#add('cohama/lexima.vim')
" Vim ランゲージサーバプロトコル
call dein#add('neoclide/coc.nvim')
let g:lsp_settings = {
\ 'pyls-ms': {'initialization_options':{
\ 'InterpreterPath' : exepath('python3'),
\ 'Version' : trim(matchstr(system('python3 -V'),'\s\zs\S\+'))
\ }}}
call dein#end()
call dein#save_state()
endif
if dein#check_install()
call dein#install()
endif
" ファイルタイプ別のVimプラグイン/インデントを有効にする
filetype plugin indent on
syntax enable
" tabを複数のspaceに置き換え
set expandtab
" tabは半角2文字
set tabstop=2
" tabの幅
set shiftwidth=2
"----------------------------------------------------------
" カラースキーム
"----------------------------------------------------------
if dein#check_install('molokai')
colorscheme molokai " カラースキームにmolokaiを設定する
endif
set t_Co=256 " iTerm2など既に256色環境なら無くても良い
syntax enable " 構文に色を付ける
"----------------------------------------------------------
" 文字
"----------------------------------------------------------
set fileencoding=utf-8 " 保存時の文字コード
set fileencodings=ucs-boms,utf-8,euc-jp,cp932 " 読み込み時の文字コードの自動判別. 左側が優先される
set fileformats=unix,dos,mac " 改行コードの自動判別. 左側が優先される
"----------------------------------------------------------
" ステータスライン
"----------------------------------------------------------
set laststatus=2 " ステータスラインを常に表示
set showmode " 現在のモードを表示
set showcmd " 打ったコマンドをステータスラインの下に表示
set ruler " ステータスラインの右側にカーソルの位置を表示する
"----------------------------------------------------------
" コマンドモード
"----------------------------------------------------------
set wildmenu " コマンドモードの補完
set history=5000 " 保存するコマンド履歴の数
"----------------------------------------------------------
" 文字列検索
"----------------------------------------------------------
set incsearch " インクリメンタルサーチ. 1文字入力毎に検索を行う
set ignorecase " 検索パターンに大文字小文字を区別しない
set smartcase " 検索パターンに大文字を含んでいたら大文字小文字を区別する
set hlsearch " 検索結果をハイライト
" ESCキー2度押しでハイライトの切り替え
nnoremap <silent><Esc><Esc> :<C-u>set nohlsearch!<CR>
"----------------------------------------------------------
" カーソル
"----------------------------------------------------------
set whichwrap=b,s,h,l,<,>,[,],~ " カーソルの左右移動で行末から次の行の行頭への移動が可能になる
set number " 行番号を表示
set cursorline " カーソルラインをハイライト
" 行が折り返し表示されていた場合、行単位ではなく表示行単位でカーソルを移動する
nnoremap j gj
nnoremap k gk
nnoremap <down> gj
nnoremap <up> gk
" バックスペースキーの有効化
set backspace=indent,eol,start
"----------------------------------------------------------
" カッコ・タグの対応
"----------------------------------------------------------
set showmatch " 括弧の対応関係を一瞬表示する
source $VIMRUNTIME/macros/matchit.vim " Vimの「%」を拡張する
"----------------------------------------------------------
" クリップボードからのペースト
"----------------------------------------------------------
" 挿入モードでクリップボードからペーストする時に自動でインデントさせないようにする
if &term =~ "xterm"
let &t_SI .= "\e[?2004h"
let &t_EI .= "\e[?2004l"
let &pastetoggle = "\e[201~"
function XTermPasteBegin(ret)
set paste
return a:ret
endfunction
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin("")
endif
"----------------------------------------------------------
" Syntastic
"----------------------------------------------------------
" 構文エラー行に「>>」を表示
let g:syntastic_enable_signs = 1
" 他のVimプラグインと競合するのを防ぐ
let g:syntastic_always_populate_loc_list = 1
" 構文エラーリストを非表示
let g:syntastic_auto_loc_list = 0
" ファイルを開いた時に構文エラーチェックを実行する
let g:syntastic_check_on_open = 1
" 「:wq」で終了する時も構文エラーチェックする
let g:syntastic_check_on_wq = 1
" Javascript用. 構文エラーチェックにESLintを使用
let g:syntastic_javascript_checkers=['eslint']
" Javascript以外は構文エラーチェックをしない
let g:syntastic_mode_map = { 'mode': 'passive',
\ 'active_filetypes': ['javascript'],
\ 'passive_filetypes': [] }
"----------------------------------------------------------
" CtrlP
"----------------------------------------------------------
let g:ctrlp_match_window = 'order:ttb,min:20,max:20,results:100' " マッチウインドウの設定. 「下部に表示, 大きさ20行で固定, 検索結果100件」
let g:ctrlp_show_hidden = 1 " .(ドット)から始まるファイルも検索対象にする
let g:ctrlp_types = ['fil'] "ファイル検索のみ使用
let g:ctrlp_extensions = ['funky', 'commandline'] " CtrlPの拡張として「funky」と「commandline」を使用
" CtrlPCommandLineの有効化
command! CtrlPCommandLine call ctrlp#init(ctrlp#commandline#id())
" CtrlPFunkyの絞り込み検索設定
let g:ctrlp_funky_matchtype = 'path'
if executable('ag')
let g:ctrlp_use_caching=0 " CtrlPのキャッシュを使わない
let g:ctrlp_user_command='ag %s -i --hidden -g ""' " 「ag」の検索設定
endif
"----------------------------------------------------------
" deoplete
"----------------------------------------------------------
let g:deoplete#enable_at_startup = 0
let g:python3_host_prog = '/usr/local/bin/python3'
"Tab補完の設定
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#manual_complete()
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
"Shift+Tabで前の補完候補へ
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>
"----------------------------------------------------------
" Prettier (coc-prettier)
"----------------------------------------------------------
command! -nargs=0 Prettier :CocCommand prettier.formatFile
"----------------------------------------------------------
" vim-airline
"----------------------------------------------------------
let g:airline_powerline_fonts = 1
let g:airline_theme = 'minimalist'
let g:airline_theme = 'tomorrow'
let g:airline_theme = 'molokai'
"----------------------------------------------------------
" KeyMap
"----------------------------------------------------------
noremap! <C-p> <Up>
noremap! <C-n> <Down>
noremap! <C-b> <Left>
noremap! <C-f> <Right>
@k2works
Copy link
Author

k2works commented Dec 16, 2020

curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh

For example, we just use ~/.cache/dein as installation directory

sh ./installer.sh ~/.cache/dein
git clone https://gist.github.com/k2works/b32efc6644dd41e4629503cc1443c54f
mv b32efc6644dd41e4629503cc1443c54f/gistfile1.txt ~/.config/nvim/init.vim
rm -rf b32efc6644dd41e4629503cc1443c54f/
rm installer.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment