LoginSignup
5
3

More than 5 years have passed since last update.

deinに乗り換えよう(第六段階)

Last updated at Posted at 2016-12-23

前提条件

  • MacOS ElCapitan 10.11.6
  • vim8.0
  • homebrew
  • iTerm2
  • ctags

今回の作業

今回はgo言語のプラグインをインストール

ちなみにまだgo言語のごの字も知らないので、いろんな人の設定を見て、共通して使っている

  • vim-go

だけ入れておくことにする

手順

vim-goをインストール

.vimrcに

" go plugins
call dein#add('fatih/vim-go')

を追加してviを開き直すだけ。超(以下略)

vim-goの設定

この辺はvim-goのgithubから。
.vimrcに

let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1

を追加

他のプラグインとか設定とかは追々。

というわけで、ここまでに設定したvimrcは、こんな感じ。

let s:dein_dir=expand('~/.vim/dein')
let s:dein_repo_dir=s:dein_dir . '/repos/github.com/Shougo/dein.vim'

if &compatible
  set nocompatible               " Be iMproved
endif

if !isdirectory(s:dein_repo_dir)
  execute '!git clone git@github.com:Shougo/dein.vim.git' s:dein_repo_dir
endif

" Required:
execute 'set runtimepath^=' . s:dein_repo_dir

" Required:
call dein#begin(s:dein_dir)

" Let dein manage dein
" Required:
call dein#add('Shougo/dein.vim')

" Add or remove your plugins here:
call dein#add('Shougo/neosnippet.vim')
call dein#add('Shougo/neosnippet-snippets')
call dein#add('Shougo/neocomplete.vim')
call dein#add('scrooloose/nerdtree')
call dein#add('scrooloose/syntastic')
call dein#add('majutsushi/tagbar')
call dein#add('szw/vim-tags')

" php plugins
call dein#add('violetyk/neocomplete-php.vim')
call dein#add('vim-scripts/PDV--phpDocumentor-for-Vim')

" go plugins
call dein#add('fatih/vim-go')

" You can specify revision/branch/tag.
call dein#add('Shougo/vimshell', { 'rev': '3787e5' })

" Required:
call dein#end()

" Required:
filetype plugin indent on
syntax enable

" If you want to install not installed plugins on startup.
if dein#check_install()
  call dein#install()
endif

" *******************************************************
" 基本設定 
" *******************************************************
" 文字コード
set encoding=utf-8
" 書込文字コード
set fileencoding=utf-8
" 読込文字コード
set fileencodings=utf-8,euc-jp,shift_jis

" 検索
set hlsearch
set incsearch
set ignorecase
set smartcase
set wrapscan

" 改行で自動的にコメント挿入されるのを防ぐ
autocmd FileType * setlocal formatoptions-=ro

" 構文ハイライト有効
syntax enable

set number
set ruler
set wildmenu
set showmatch
set list
set listchars=tab:>-,extends:<,trail:-,eol:$
set laststatus=2

set autoindent
set expandtab

" マウス有効
set mouse=a
set ttymouse=xterm2

set shiftwidth=4
set tabstop=4
set softtabstop=4

set wrap
set whichwrap=h,l,b,s,<,>,[,]
set backspace=indent,eol,start
set title

" Copy/Paste/Cut
set clipboard=unnamed,autoselect

" *******************************************************
" neosnippet
" *******************************************************
" Plugin key-mappings.
imap <C-k>     <Plug>(neosnippet_expand_or_jump)
smap <C-k>     <Plug>(neosnippet_expand_or_jump)
xmap <C-k>     <Plug>(neosnippet_expand_target)

" SuperTab like snippets behavior.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \    "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"

" For conceal markers.
if has('conceal')
    set conceallevel=2 concealcursor=niv
endif

" *******************************************************
" neocomplete
" *******************************************************
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3

" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
    \ 'default' : '',
    \ 'vimshell' : $HOME.'/.vimshell_hist',
    \ 'scheme' : $HOME.'/.gosh_completions'
        \ }

" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
    let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'

" Plugin key-mappings.
inoremap <expr><C-g>     neocomplete#undo_completion()
inoremap <expr><C-l>     neocomplete#complete_common_string()

" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
    return (pumvisible() ? "\<C-y>" : "" ) . "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"

" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags


" *******************************************************
" NERDTree
" *******************************************************
" ブックマーク初期表示
let g:NERDTreeShowBookmarks=1
"
let g:NERDTreeChDirMode=2
" windowサイズ設定
let g:NERDTreeWinSize=20
" 表示したくないファイル、ディレクトリ
let g:NERDTreeIgnore=['\.DS_Store$', '\.swp$', '\~$', '\.so']
" vim起動時に常に表示
autocmd vimenter * NERDTree
" NERDTreeだけが残る場合はvim終了
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

" *******************************************************
" syntastic
" *******************************************************
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

let g:syntastic_javascript_checkers=['eslint']
let g:syntastic_scss_checkers = ['scss_lint']
let g:syntastic_php_checkers = ['php', 'phpcs', 'phpmd']

" *******************************************************
" tagbar
" *******************************************************
" windowサイズ
let g:tagbar_width=20
" 起動時に常に表示
autocmd vimenter *.php TagbarOpen

" *******************************************************
" vim-tags
" *******************************************************
let g:vim_tags_project_tags_command = "/usr/local/Cellar/ctags/5.8_1/bin/ctags -f .tags -R . 2>/dev/null"
let g:vim_tags_auto_generate = 1

" *******************************************************
" ctags
" *******************************************************
" phpファイル用tags
au BufNewFile,BufRead *.php set tags+=$HOME/.tags/php.tag


" *******************************************************
" neocomplete-php
" *******************************************************
let g:neocomplete_php_locale = 'ja'

" *******************************************************
" PHP Documentor for VIM
" *******************************************************
inoremap <C-P> <Esc>:call PhpDocSingle()<CR>
nnoremap <C-P> :call PhpDocSingle()<CR>
vnoremap <C-P> :call PhpDocSingle()<CR>

" *******************************************************
" vim-go 
" *******************************************************
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1

基本設定あたりは、好みが分かれると思うのですが、とりあえず以前使ってたvimrcからコピペ。
なぜこの設定にしたかは覚えていないぐらい古いものを使いまわしているので、改めてこの設定なんだったっけ・・・?を調べようと思います。

それにしても、なげぇ・・・
分割する方法があるようなので、またの機会に。
とりあえず、これにてdeinへの乗り換えは終了。ガシガシ使っていく段階に入ります。

年越す前に乗り換えできてよかったわー
コード書くのそっちのけでやってたけど、そろそろちゃんとgo言語勉強しないと間に合わないw

(2017/1/22追記)
ここまでの設定をgithubにあげました
https://github.com/tomo62/dotfiles
これでどこからでも同じ環境が作れる・・・はず・・・githubに入れない設定されたネットワークの職場とかだったら無理っす。

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3