vim が autocomplete で落ちるのを対応メモ。

vimで編集中に落ちるようになってしまったのでその対応メモ。

環境

  • OS: Ubuntu 12.04 64bit
  • Vim: 7.3
  • paco: 2.0.9

現象

rubyソースで . と1文字打つと

Vim: 致命的シグナル SEGV を検知しました

とエラーメッセージが表示され落ちる。
以前はこんなことなかった。

hoge.f 例えばこんな感じで f を打った時に落ちる。
どうやら autocomplete の時に落ちている模様。

ただし、phpソースなどのruby以外のソースでは発生しない。

久しぶりにrubyソースを開いたので、正常に動いていた時から何を変更したかが把握できていないため原因はよくわかってません。

対応内容

rails.vim が問題だとかいう話も見たので外してみたり設定変えてみたりしたのですが結果は同様に落ちます。

最新のvimなら落ちないというような話も見たので、とりあえずソースからインストールしてみます。

vim をソースからインストールする。

ソースから入れなおすので apt でインストールした vim を削除します。

Terminal
1
$ sudo aptitude remove vim-gnome

ソースをダウンロードして展開。

Terminal
1
2
3
$ wget ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2
$ tar jxvf vim-7.3.tar.bz2
$ cd vim73

パッチを当てる。現在までで905まで出てる模様。すべて当てます。

Terminal
1
2
3
4
5
$ mkdir patches
$ cd patches/
$ curl -O 'http://ftp.vim.org/pub/vim/patches/7.3/7.3.[001-905]'
$ cd ../
$ cat patches/* | patch -p0

pacoを利用してインストールします。

Terminal
1
2
3
$ ./configure --with-features=huge --enable-multibyte --enable-rubyinterp
$ make
$ sudo paco -D make install

インストールできたか確認。

Terminal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Apr 19 2013 10:42:04)
Included patches: 1-905
Huge version without GUI. Features included (+) or not (-):
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
-balloon_eval +float +mouse_urxvt -tag_any_white
-browse +folding +mouse_xterm -tcl
++builtin_terms -footer +multi_byte +terminfo
+byte_offset +fork() +multi_lang +termresponse
+cindent -gettext -mzscheme +textobjects
+clientserver -hangul_input +netbeans_intg +title
+clipboard +iconv +path_extra -toolbar
+cmdline_compl +insert_expand -perl +user_commands
+cmdline_hist +jumplist +persistent_undo +vertsplit
+cmdline_info +keymap +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak -python +viminfo
+cscope +lispindent -python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con -lua +rightleft +windows
+diff +menu +ruby +writebackup
+digraphs +mksession +scrollbind +X11
-dnd +modify_fname +signs +xfontset
-ebcdic +mouse +smartindent -xim
+emacs_tags -mouseshape -sniff +xsmp_interact
+eval +mouse_dec +startuptime +xterm_clipboard
+ex_extra -mouse_gpm +statusline -xterm_save
+extra_search -mouse_jsbterm -sun_workshop
+farsi +mouse_netterm +syntax
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -I/usr/local/include -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -fstack-protector -rdynamic -Wl,-export-dynamic -L/usr/local/lib -Wl,--as-needed -o vim -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -ldl -Wl,-R -Wl,/home/nanigashi/.rvm/rubies/ruby-2.0.0-p0/lib -L/home/nanigashi/.rvm/rubies/ruby-2.0.0-p0/lib -lruby -lpthread -lrt -ldl -lcrypt -lm -L/home/nanigashi/.rvm/rubies/ruby-2.0.0-p0/lib

一応は無事インストールできました。

Terminal
1
$ vim

無事起動。

gvimが無い。

次にGUIで起動してみます。

Terminal
1
2
$ gvim
zsh: command not found: gvim

コマンドが無い。

Terminal
1
2
$ vim -g
E25: GUI cannot be used: Not enabled at compile time

gvimが無い。

ログを見直してみる。

Terminal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
checking --enable-gui argument... GNOME 2.x GUI support
checking --disable-gtktest argument... gtk test enabled
checking for pkg-config... /usr/bin/pkg-config
checking for GTK - version >= 2.2.0... no
checking X11/SM/SMlib.h usability... yes
checking X11/SM/SMlib.h presence... yes
checking for X11/SM/SMlib.h... yes
checking X11/xpm.h usability... no
checking X11/xpm.h presence... no
checking for X11/xpm.h... no
checking X11/Sunkeysym.h usability... yes
checking X11/Sunkeysym.h presence... yes
checking for X11/Sunkeysym.h... yes
checking for XIMText in X11/Xlib.h... yes
no GUI selected; xim has been disabled

どうやらGUIが有効になってなかったみたいです。

GUI を有効にして vim を再インストールする。

vim を一旦アンインストール。

Terminal
1
2
3
$ sudo paco -r vim73
Remove package vim73 (y/N) ? y #=> yを入力
$ make distclean

GUIを有効にするには libgtk2.0-dev が必要みたいなのでインストール。

Terminal
1
$ sudo aptitude install libgtk2.0-dev

--enable-xim --enable-x --enable-gui=gnome2 のオプションをつける

Terminal
1
$ ./configure --with-features=huge --enable-multibyte --enable-rubyinterp --enable-xim --enable-x --enable-gui=gnome2

ログを確認。

Terminal
1
2
3
4
checking --enable-gui argument... GNOME 2.x GUI support
checking --disable-gtktest argument... gtk test enabled
checking for pkg-config... /usr/bin/pkg-config
checking for GTK - version >= 2.2.0... yes; found version 2.24.10

有効になっている模様。

インストール。

Terminal
1
2
$ make
$ sudo paco -D make install

起動。

Terminal
1
$ gvim

無事起動しました。

ruby を同じように編集してみたところ、autocomplete で落ちなくなっていたので解決したと思います。

以上です。

phpDocumentor をインストールしてみた。

phpdoc を使いなさいと言われたので、インストールしてみました。

あと、vim でコメントのひな形をいれれるようにしました。

環境

  • OS: Ubuntu 12.04 64bit
  • PHP: PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch
  • phpDocumentor: 2.0.0a12
  • Vim: 7.3
    • vim-doc.vim: 1.0.1

Vim に phpdoc コメント生成プラグインを入れる

これがよさげ。

PDV - phpDocumentor for Vim

http://www.vim.org/scripts/script.php?script_id=1355

bundle を利用してインストール。

Bundle を利用してインストールするので .vimrc に以下を追記。

.vimrc
1
Bundle 'PDV--phpDocumentor-for-Vim'

追記後に :BundleInstall を実行してインストール。

PDV の設定をする。

デフォルトのコメント設定をするため php-doc.vim の77行目〜83行目あたりにある下記を変更する。

~/.vim/bundle/PDV--phpDocumentor-for-Vim/plugin/php-doc.vim
1
2
3
4
5
6
7
" Default values
let g:pdv_cfg_Type = "mixed"
let g:pdv_cfg_Package = ""
let g:pdv_cfg_Version = "$id$"
let g:pdv_cfg_Author = "Tobias Schlitt <toby@php.net>"
let g:pdv_cfg_Copyright = "1997-2005 The PHP Group"
let g:pdv_cfg_License = "PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}"

今回は Auhor くらいしか入れないみたいなので下記に変更。

~/.vim/bundle/PDV--phpDocumentor-for-Vim/plugin/php-doc.vim
1
2
3
4
5
6
7
" Default values
let g:pdv_cfg_Type = "mixed"
let g:pdv_cfg_Package = ""
let g:pdv_cfg_Version = ""
let g:pdv_cfg_Author = "nanigashi <nanigashi@example.com>"
let g:pdv_cfg_Copyright = ""
let g:pdv_cfg_License = ""

キーバインドも変更。

.vimrc
1
2
3
inoremap <C-P> <ESC>:call PhpDocSingle()<CR>i
nnoremap <C-P> :call PhpDocSingle()<CR>
vnoremap <C-P> :call PhpDocRange()<CR>

phpdoc のコメントを入れてみる。

class の場合は class の行で、function の場合は function が記述してある行で Ctrl + P で自動でひな形が入る。

doctest.php
1
2
3
4
5
6
<?php
class Hoge {
function Foo($bar, $piyo, $fuga=array(), $hogera=null) {
return $bar;
}
}

このコードで実行すると下記になる。

doctest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
/**
* Hoge
*
* @package
* @version
* @copyright
* @author nanigashi <nanigashi@example.com>
* @license
*/
class Hoge {
/**
* Foo
*
* @param mixed $bar
* @param mixed $piyo
* @param array $fuga
* @param mixed $hogera
* @access public
* @return void
*/
function Foo($bar, $piyo, $fuga=array(), $hogera=null) {
return $bar;
}
}

phpDocumentor で phpdoc を生成する。

phpDocumentor 2

http://www.phpdoc.org/

Pear のインストール

pearを利用しているようなのでインストールする。

Terminal
1
$ sudo apt-get install php-pear

phpDocumentor のインストール

チャンネルを登録後、インストールする。

Terminal
1
2
$ sudo pear channel-discover pear.phpdoc.org
$ sudo pear install phpdoc/phpDocumentor-alpha

インストールされているか確認。

Terminal
1
2
$ phpdoc --version
phpDocumentor version 2.0.0a12

phpdocの生成方法。

phpdoc run -d [input_path] -t [output_path]

phpdoc を生成してみる。

試しにコマンド実行。

Terminal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ phpdoc run -d . -t ./doc
Initializing parser and collecting files .. OK
Parsing files
Parsing /home/nanigashi/phpdoc_test/doctest.php
No page-level DocBlock was found in file doctest.php
Storing structure.xml in "/home/nanigashi/phpdoc_test/doc/structure.xml" .. OK
Initializing transformer .. OK
Processing behaviours .. OK
Executing transformations



[phpDocumentor\Plugin\Core\Exception]
The XSL writer was unable to find your XSLTProcessor; please check if you have installed the PHP XSL extension



project:run [-t|--target[="..."]] [-f|--filename[="..."]] [-d|--directory[="..."]] [--encoding[="..."]] [-e|--extensions[="..."]] [-i|--ignore[="..."]] [--ignore-tags[="..."]] [--hidden] [--ignore-symlinks] [-m|--markers[="..."]] [--title[="..."]] [--force] [--validate] [--visibility[="..."]] [--defaultpackagename[="..."]] [--sourcecode] [-p|--progressbar] [--template[="..."]] [--parseprivate] [-c|--config[="..."]]

実行してみると以下のエラーが発生。

The XSL writer was unable to find your XSLTProcessor; please check if you have installed the PHP XSL extension

調べてみると php5-xsl というのが必要のようなので以下でインストール。

Terminal
1
$ sudo aptitude install php5-xsl

再度実行。

Terminal
1
2
3
4
5
6
7
8
phpdoc run -d . -t doc/
Initializing parser and collecting files .. OK
Parsing files
Parsing /home/nanigashi/phpdoc_test/doctest.php
Storing structure.xml in "/home/nanigashi/phpdoc_test/doc/structure.xml" .. OK
Initializing transformer .. OK
Processing behaviours .. OK
Executing transformations

無事生成されました。

生成された doc/index.html をブラウザで開くと結構お洒落なドキュメントができます。

以上です。

近所で桜を撮ってきた。

はぁー。小銭稼いでたシステムが昨年10月から止まってた。どうも何某です。こんばんは。

サーバー代くらい稼げてたのに勿体無い。

昨日、カメラとスキットルを持って歩きながら1人でぶらぶら散歩しました。

途中で団子屋寄って団子買ったりして。

近所の桜

いい写真が撮れないのは酔ってるからじゃないんだろうなぁ。練習しないと。

スキットル。良い。

スキットル

http://ja.wikipedia.org/wiki/%E3%82%B9%E3%82%AD%E3%83%83%E3%83%88%E3%83%AB

スキットルは主にウイスキーなどアルコール濃度の高い蒸留酒を入れる携帯用の水筒である。

これを買って使ってるんですが、こういうステンレス製は鉄の味がするので避けるほうがいいという話。

実際使ってみたところですが、ちょっといいお酒だと確かに味の変化がすごい気がする。多分。変わってる気がする。

変えたくないならチタン製らしい。

ブラックニッカとかみたいな安酒がいいですね。雰囲気あるので安い酒のほうが逆に美味しく感じます。

240ml入るので、だいたいショット6〜8杯分くらいでしょうか。結構飲めます。

僕はメーカーズマークなんかよく呑むんですが、大体一杯500〜600円とか。

だいぶ節約なるのでおすすめです。

以上です。

© 2024 磁力式駆動 All Rights Reserved.
Theme by hiero