Skip to content

Instantly share code, notes, and snippets.

@totegamma
Last active October 21, 2016 12:02
Show Gist options
  • Save totegamma/caff0323133d31f74f1962afdc6b411d to your computer and use it in GitHub Desktop.
Save totegamma/caff0323133d31f74f1962afdc6b411d to your computer and use it in GitHub Desktop.
"-=-=-=-=-=-=-=-=-=-=-=-=-=-"
" .vimrc "
" created by thotgamma "
" http://lab.thotgamma.com "
"-=-=-=-=-=-=-=-=-=-=-=-=-=-"
" このvimrcのバージョン
let s:version = "1.1"
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" プラグイン管理ツールとしてdein.vimを使う。
" ### 定数等の設定
" dein.vimが置かれる場所
let s:deinDir = expand("~/.vim/dein")
" dein.vim本体
let s:deinVim = s:deinDir . "/dein.vim"
" プラグインリスト
let s:pluginList = expand("~/.vim/pluginList.toml")
" ### dein関連
" dein.vimがインストールされてなければインストールする
if &runtimepath !~# "/dein.vim"
if !isdirectory(s:deinVim)
"dein.vimのインストール
echo "dein.vimがインストールされていませんね?"
echo "完璧で幸福なvim市民はdein.vimをインストールしているはずです。"
echo "今回は大目に見てコンピュータ様である私が代わりにdein.vimを"
echo "インストールしてあげましょう。"
execute "!git clone https://github.com/Shougo/dein.vim" s:deinVim
"tomlファイルの生成
echo "tomlファイルも作っておきます。ここに導入したいプラグインを"
echo "記述するように。更新があれば次回vim起動時にインストールされます。"
execute "!git clone https://gist.github.com/thotgamma/db39adf0ccc606abb1c14f9c83f906cd ~/.vim/tmp"
execute "!mv ~/.vim/tmp/pluginList.toml" s:pluginList
execute "!rm -rf ~/.vim/tmp"
"molokai.vimのインストール
echo "おや?molokai.vimも入っていないようですね。"
echo "仕方がありません。私がインストールしてあげましょう。"
execute "!mkdir ~/.vim/colors"
execute "!git clone https://github.com/tomasr/molokai ~/.vim/tmp"
execute "!mv ~/.vim/tmp/colors/molokai.vim ~/.vim/colors"
execute "!rm -rf ~/.vim/tmp"
echo "これで導入は完了です。"
echo "それでは完璧で幸福なコーディングを。"
endif
execute "set runtimepath^=" . fnamemodify(s:deinVim, ":p")
endif
" dein.vimの設定をする
if dein#load_state(s:deinDir)
call dein#begin(s:deinDir)
" TOMLを読み込み、キャッシュしておく
call dein#load_toml(s:pluginList, {"lazy": 0})
"設定終了
call dein#end()
call dein#save_state()
endif
"未インストールのプラグインがあればインストールする
if dein#check_install()
call dein#install()
endif
let s:res = webapi#http#get('http://thotgamma.com/.vimrcversion')
if s:version . "\n" != s:res.content
echo "currentVersion: \"" . s:version . "\" => newVersion: \"" . s:res.content . "\""
echo "お久しぶりです。進捗はいかがでしょうか?"
echo "vimrcが変更されたので更新いたします。"
execute "!curl -o ~/.vimrc http://thotgamma.com/.vimrc"
echo "更新が完了しました。"
echo "それでは完璧で幸福なコーディングを。"
endif
" ### vim基本設定
" 256色モードを使用する
set t_Co=256
" lightline用の設定
set laststatus=2
" ファイルタイプ別のプラグイン/インデントを有効にする
filetype plugin indent on
" カラースキマの設定
set background=dark
colorscheme molokai
" フォントをSourceCodeProに設定する
set guifont=Source\ Code\ Pro\ Medium:h12et nocompatible
" シンタックスハイライト
syntax on
" エンコード
set encoding=utf8
" ファイルエンコード
set fileencoding=utf-8
" スクロールする時に下が見えるようにする
set scrolloff=5
" .swapファイルを作らない
set noswapfile
" バックアップファイルを作らない
set nowritebackup
" バックアップをしない
set nobackup
" バックスペースで各種消せるようにする
set backspace=indent,eol,start
" ビープ音を消す
set vb t_vb=
set novisualbell
" OSのクリップボードを使う
set clipboard+=unnamed
set clipboard=unnamed
" 不可視文字を表示
set list
" 行番号を表示
set number
" 右下に表示される行・列の番号を表示する
set ruler
" compatibleオプションをオフにする
set nocompatible
" 移動コマンドを使ったとき、行頭に移動しない
set nostartofline
" 対応括弧に<と>のペアを追加
set matchpairs& matchpairs+=<:>
" 対応括弧をハイライト表示する
set showmatch
" 対応括弧の表示秒数を3秒にする
set matchtime=3
" ウィンドウの幅より長い行は折り返され、次の行に続けて表示される
set wrap
" 入力されているテキストの最大幅を無効にする
set textwidth=0
" 不可視文字を表示
set listchars=tab:»-,trail:-,extends:»,precedes:«,nbsp:%,eol:↲
" インデントをshiftwidthの倍数に丸める
set shiftround
" 補完の際の大文字小文字の区別しない
set infercase
" 変更中のファイルでも、保存しないで他のファイルを表示
set hidden
" 新しく開く代わりにすでに開いてあるバッファを開く
set switchbuf=useopen
" 小文字の検索でも大文字も見つかるようにする
set ignorecase
" ただし大文字も含めた検索の場合はその通りに検索する
set smartcase
" インクリメンタルサーチを行う
set incsearch
" 検索結果をハイライト表示
set hlsearch
" コマンド、検索パターンを10000個まで履歴に残す
set history=10000
" マウスモード有効
set mouse=a
" xtermとscreen対応
set ttymouse=xterm2
" コマンドを画面最下部に表示する
set showcmd
" タブをタブとして扱う
set noexpandtab
" 改行時に前の行のインデントを継続する
set autoindent
" 改行時に入力された行の末尾に合わせて次のインデントを増減する
set smartindent
" tabの大きさをスペース4個分にする
set tabstop=4
" 自動インデントでずれる幅
set shiftwidth=4
set softtabstop=4
" 自動でコメントにしない
set formatoptions-=ro
if has('gui_macvim')
set transparency=4
endif
" ### キーリマップの設定
" w!! でスーパーユーザーとして保存(sudoが使える環境限定)
cmap w!! w !sudo tee > /dev/null %
" 入力モード中に素早くJJと入力した場合はESCとみなす
inoremap jj <Esc>
" ESCを二回押すことでハイライトを消す
nmap <silent> <Esc><Esc> :nohlsearch<CR>
" カーソル下の単語を * で検索
vnoremap <silent> * "vy/\V<C-r>=substitute(escape(@v, '\/'), "\n", '\\n', 'g')<CR><CR>
" 検索後にジャンプした際に検索単語を画面中央に持ってくる
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
" j, k による移動を折り返されたテキストでも自然に振る舞うように変更
nnoremap j gj
nnoremap k gk
" vを二回で行末まで選択
vnoremap v $h
" TABにて対応ペアにジャンプ
nnoremap &lt;Tab&gt; %
vnoremap &lt;Tab&gt; %
" Ctrl + e でNerdTreeのon/off切り替え
nnoremap <silent><C-e> :NERDTreeToggle<CR>
" Ctrl + hjkl でウィンドウ間を移動
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Shift + 矢印でウィンドウサイズを変更
nnoremap <S-Left> <C-w><<CR>
nnoremap <S-Right> <C-w><CR>
nnoremap <S-Up> <C-w>-<CR>
nnoremap <S-Down> <C-w>+<CR>
"syntasticの設定
"c++11、glutを使用する
let g:syntastic_cpp_compiler = 'g++'
let g:syntastic_cpp_compiler_options = ' -std=c++11 -lglut -lGL'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment