Skip to content

Instantly share code, notes, and snippets.

@float1251
Last active September 29, 2018 00:58
Show Gist options
  • Save float1251/598a4d561b5d7274b3002d0eb5e0deee to your computer and use it in GitHub Desktop.
Save float1251/598a4d561b5d7274b3002d0eb5e0deee to your computer and use it in GitHub Desktop.
nvim設定
"{{{ macかどうかの判定
if has("unix")
let s:uname = system("uname -s")
if s:uname == "Darwin\n"
" Do Mac stuff here
let s:isMac = 1
else
let s:isMac = 0
endif
endif
" mac専用の変数設定
if exists('s:isMac') && s:isMac
" let g:python2_host_prog = '/usr/local/bin/python'
let g:python3_host_prog = $HOME.'/.pyenv/versions/3.5.6/bin/python'
set pythonthreedll=$HOME/.pyenv/versions/3.5.6/lib/libpython3.5m.dylib
else
" 環境にあわせて変更する
let g:python3_host_prog = '$HOME\AppData\Local\Programs\Python\Python36-32\python.exe'
endif
" python3を有効にする.
if has("python3")
endif
"}}}
"フォントの設定
" set guifont=MigMix_1M:h10
" {{{ dein.vim
if &compatible
set nocompatible
endif
if version < 740
finish
endif
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')
" call dein#add('Shougo/dein.vim')
call dein#add('Shougo/vimproc.vim', {
\ 'build': {
\ 'mac': 'make -f make_mac.mak',
\ 'linux': 'make',
\ 'unix': 'gmake',
\ }
\})
call dein#add('Shougo/deoplete.nvim')
if !has('nvim')
" hug-neovim-rpcの設定
" これでもまだ動作しない...
set pyxversion=3
call dein#add('roxma/nvim-yarp')
call dein#add('roxma/vim-hug-neovim-rpc')
endif
call dein#add('zchee/deoplete-go')
" call dein#add('Shougo/vimshell.vim')
call dein#add('Shougo/unite.vim')
call dein#add('fatih/vim-go') " golang plugin
" vim-goのすべてが実装されているわけではないのでやめます
" call dein#add('zchee/nvim-go', {'build': 'make'}) " nvim用のgolang plugin. delveがguiで使えるらしい.
" call dein#add('sebdah/vim-delve') " nvim用のgo debug plugin
" call dein#add('Shougo/vimshell') " vim-delveが依存している
" call dein#add('jodosha/vim-godebug') " nvim用のgo debug plugin.何故か機能しないのでコメントアウト
call dein#add('scrooloose/nerdtree') " ファイルツリー
call dein#add('itchyny/lightline.vim') " ステータスラインのカスタマイズ
call dein#add('haya14busa/incsearch.vim') " 単語検索のプラグイン Ex:/\v{word}|{word}
call dein#add('nathanaelkane/vim-indent-guides')
call dein#add('tpope/vim-surround')
call dein#add('mattn/emmet-vim') " htmlの簡易入力記法 <ctrl-y>,で展開
call dein#add('jmcantrell/vim-virtualenv')
call dein#add('davidhalter/jedi-vim') " pythonの補完plugin
call dein#add('scrooloose/syntastic') " format,lintライブラリ
call dein#add('justmao945/vim-clang') " c/c++の補完プラグイン
call dein#add('kmnk/vim-unite-svn') " unite.vimでsubversionを扱う
call dein#add('kmnk/vim-unite-giti') " unite.vimでgitを扱う
call dein#add('thinca/vim-template') " ファイル作成時に自動でtemplateを挿入したりするplugin
call dein#add('glidenote/memolist.vim') " memo
" +pythonじゃないとダメ。install後にserverのbuildが必要
" https://github.com/OmniSharp/omnisharp-vim
if has("python") || has("python3")
call dein#add('OmniSharp/omnisharp-vim', {'on_ft': 'cs'})
endif
call dein#add('editorconfig/editorconfig-vim')
call dein#add('kchmck/vim-coffee-script') " coffee-scriptのsyntaxhighlight
call dein#add('Quramy/tsuquyomi')
call dein#add('leafgarland/typescript-vim') " typescriptのsyntaxhighlight
call dein#add('Shougo/denite.nvim') " unite.vimの代替
" nyaovimの設定
if exists('g:nyaovim_version')
" Write NyaoVim specific code here
call dein#add('rhysd/nyaovim-markdown-preview')
call dein#add('rhysd/nyaovim-popup-tooltip')
call dein#add('rhysd/nyaovim-mini-browser')
endif
call dein#end()
call dein#save_state()
endif
filetype plugin indent on
syntax enable
" If you want to install not installed plugins on startup.
if dein#check_install()
call dein#install()
endif
" }}}
" {{{ start general settings
" leaderをspaceに変更する
let mapleader = "\<Space>"
" }}}
" {{{ Unite.vim
" 起動時にinsert modeにする
let g:unite_enable_start_insert=1
" 分割の設定
let g:unite_sprit_rule='bottomleft'
let g:unite_source_rec_async_command=['ag', '--follow', '--nocolor', '--nogroup', '--hidden', '-g']
" space*2 でファイル検索
nnoremap <Space><Space> :Unite file_rec/async<CR>
" ,ubでBuffer検索
nnoremap <silent>,ub :Unite buffer<CR>
" file_rec/asyncでcwdからの相対パスで検索を開始するようにする
function! InputRelativePathFromCWD()
let s:cwd = getcwd()
let s:input_var = input('from(' . s:cwd .') : ') "入力を受け取る
call unite#start([['file_rec/async', s:cwd.'/'.s:input_var]]) " file_rec/asyncを実行する
endfunction
nnoremap ,uf :call InputRelativePathFromCWD()<CR>
" }}}
"{{{ jedi.vim
let g:jedi#show_call_signatures = 0
let g:jedi#popup_on_dot = 0
let g:jedi#popup_select_first = 0
"}}}
" {{{ incsearch.vim
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
" }}}
" {{{ vim-indent-guides
let g:indent_guides_guide_size = 1 " 色サイズは1
let g:indent_guides_enable_on_vim_startup=1 " 起動時に有効にする
let g:indent_guides_auto_colors=0 " 色は手動で設定
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=3
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=4
" }}}
" {{{ vim-go
" 各種key mappingの設定
au FileType go nmap <Leader>>gr <Plug>(go-run)
au FileType go nmap <Leader>>gb <Plug>(go-build)
au FileType go nmap <Leader>>gt <Plug>(go-test)
au FileType go nmap <Leader>>gc <Plug>(go-coverage)
au FileType go nmap <Leader>>gi :GoImport
au FileType go nmap <Leader>>gd :GoDocBrowser<CR>
au FileType go nmap <Space>gf :GoDef<CR>
au FileType go nmap <S-left> :GoDefPop<CR>
au FileType go nmap <Leader>i <Plug>(go-info)
" gocodeのgocomplete.vimがvim-goのomnifuncを書き換えているのか、正常に動作して
" いないので無理やり書き換え
autocmd BufNewFile,BufRead *.go setlocal omnifunc=go#complete#Complete
" }}}
" {{{ OmniSharp-vim
au FileType cs nmap ,df :OmniSharpCodeFormat
" }}}
" {{{ vim-template
" templateを配置するdirを設定
" 他OSなどでうまく動作していないのでコメントアウト
" g:template_basedir=$HOME/.vim/template/
" }}}
" {{{ neocomplete
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
let g:neocomplete#sources#omni#input_patterns.go = '[^.[:digit:] *\t]\.\w*'
autocmd FileType python setlocal omnifunc=jedi#completions
let g:jedi#completions_enabled = 0
let g:jedi#auto_vim_configuration = 0
if !exists('g:neocomplete#force_omni_input_patterns')
let g:neocomplete#force_omni_input_patterns = {}
endif
" let g:neocomplete#force_omni_input_patterns.python = '\%([^. \t]\.\|^\s*@\|^\s*from\s.\+import \|^\s*from \|^\s*import \)\w*'
let g:neocomplete#force_omni_input_patterns.python = '\h\w*\|[^. \t]\.\w*'
" }}}
"{{{ vim-clang
" :h clang.txt
" clangへのpathが通っていること
let g:clang_c_options = '-std=gnu11'
let g:clang_cpp_options = '-std=c++11 -stdlib=libc++'
"}}}
"{{{ virtualenv.vim
let g:virtualenv_directory='/Users/t-iwatani/.pyenv/versions/'
"}}}
" {{{ denite.vim
" space*2 でファイル検索
nnoremap <Space><Space> :Denite file_rec -mode=normal<CR>
" Denite grepのショートカット
nnoremap <silent>,ug :Denite grep -mode=normal<CR>
" 前回開いたDeniteの結果を表示する
nnoremap <silent>,up :Denite -resume<CR>
" }}}
"{{{ deoplete.nvim
let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_ignore_case = 1
let g:deoplte#max_list = 20
set completeopt+=noinsert
"}}}
" {{{ memolist.vim
let g:memolist_path = "~/Google\ ドライブ/Memo"
let g:memolist_memo_suffix = "md"
" use unite (default 0)
let g:memolist_unite = 1
" use arbitrary unite source (default is 'file')
let g:memolist_unite_source = "file_rec"
" }}}
" {{{ general settings
" encodingはutf-8
set encoding=utf-8
" タブは半角スペースにする
set expandtab
" 改行時に自動でインデントをかける
set autoindent
" 自動インデント時のspaceは4
set shiftwidth=4
" 行数を表示
set number
" 検索の際のハイライトを消す
nnoremap <ESC><ESC> :nohl<CR>
" colorscheme
colorscheme desert
" tabspaceは4
set ts=4
" カーソルがいる行にラインを表示する
set cursorline
" 100文字目のところで背景色を変更する
if(exists('+colorcolumn'))
set colorcolumn=100
highlight ColorColomn ctermbg=9
endif
" tabの移動
nnoremap <C-tab> :tabn<CR>
" omni補完はS-spaceにする
imap <S-Space> <C-x><C-o>
" grepのpathを設定.
" cygwinのgrepを使用する
" if has("win32") || has("win64")
" set grepprg=c:/cygwin/bin/grep\ -nH
" endif
" un~ファイルを作らないようにする
:set noundofile
"クリップボードを共有する
set clipboard=unnamed
" swapfileは作らない
" 別ディレクトリに格納するようにしてもよいかも
" set directory=$HOME/.swap
set noswapfile
" backupファイルは作らない
set nobackup
" 自動で折り返し改行はしない
set tw=0
" terminal関連の設定
" :VT :Tでsplitしてからterminalを開く
command! -nargs=* T terminal ++rows=12 <args>
" terminalではescでコマンドモードから切り替える
tnoremap <silent> <ESC> <C-\><C-n>
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment