出しちゃいます。
/dotfiles/vim/mattn-vimrc - CodeRepos::Share - Trac正直デカイです。
/dotfiles/vim/mattn-gvimrc - CodeRepos::Share - Trac
もう随分昔からあるvimrcなので使ってない機能もあれば、忘れてしまったノウハウもいっぱい...
あまり参考にならないかもしれませんが、どうぞ。
mattn the vimmer!
追記
マルチプラットフォーム用です。
/dotfiles/vim/mattn-vimrc - CodeRepos::Share - Trac正直デカイです。
/dotfiles/vim/mattn-gvimrc - CodeRepos::Share - Trac
C:\TEMP> svn checkout http://google-gtags.googlecode.com/svn/trunk/ google-gtags
次に、以下のパッチを当てます。
Index: regexp.h
===================================================================
--- regexp.h (revision 57)
+++ regexp.h (working copy)
@@ -4,7 +4,9 @@
#ifndef TOOLS_TAGS_REGEXP_H__
#define TOOLS_TAGS_REGEXP_H__
+extern "C" {
#include <regex.h>
+}
#include "tagsutil.h"
class RegExp {
Index: configure
===================================================================
--- configure (revision 57)
+++ configure (working copy)
@@ -10,7 +10,7 @@
if [ ! -e "scons/scons.py" ]; then
pushd scons > /dev/null
echo "Unpacking scons..."
- tar xzvf scons-local.tar.gz > /dev/null
+ gzip -dc scons-local.tar.gz | tar xv > /dev/null
if [[ "$?" == 0 ]]; then
echo "Done"
else
Index: gtags.cc
===================================================================
--- gtags.cc (revision 57)
+++ gtags.cc (working copy)
@@ -49,6 +49,10 @@
#include "tagsoptionparser.h"
#include "tagsrequesthandler.h"
+#ifdef WIN32
+# include <winsock2.h>
+#endif
+
DEFINE_STRING(tags_file, "", "The file containing the tags information.");
@@ -78,6 +82,11 @@
return -1;
}
+#ifdef _WIN32
+ WSAData wsadata;
+ WSAStartup(MAKEWORD(2,0), &wsadata);
+#endif
+
logger = new StdErrLogger();
tags_request_handler = new TagsRequestHandler(GET_FLAG(tags_file),
@@ -90,4 +99,9 @@
delete tags_request_handler;
delete logger;
+
+
+#ifdef _WIN32
+ WSACleanup();
+#endif
}
Index: gtags.py
===================================================================
--- gtags.py (revision 57)
+++ gtags.py (working copy)
@@ -175,11 +175,11 @@
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
address = socket.getaddrinfo(host, port, socket.AF_INET,
socket.SOCK_STREAM)
- signal.signal(signal.SIGALRM, alarm_handler)
- signal.alarm(CONNECT_TIMEOUT)
+ #signal.signal(signal.SIGALRM, alarm_handler)
+ #signal.alarm(CONNECT_TIMEOUT)
s.connect(address[0][4])
- signal.alarm(0)
- signal.alarm(DATA_TIMEOUT)
+ #signal.alarm(0)
+ #signal.alarm(DATA_TIMEOUT)
# need \r\n to match telnet protocol
s.sendall(command + '\r\n')
@@ -191,7 +191,7 @@
while data:
buf.write(data)
data = s.recv(1024)
- signal.alarm(0)
+ #signal.alarm(0)
return buf.getvalue()
# Instance of connection_manager that forwards client requests to gtags server
Index: tags_logger.h
===================================================================
--- tags_logger.h (revision 57)
+++ tags_logger.h (working copy)
@@ -67,6 +67,7 @@
}
};
+#undef ERROR
const int INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3, NUM_SEVERITIES = 4;
// uncomment out the standard google logger
Index: socket_server.cc
===================================================================
--- socket_server.cc (revision 57)
+++ socket_server.cc (working copy)
@@ -18,10 +18,14 @@
#include <assert.h>
#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <unistd.h>
+#ifdef WIN32
+# include <winsock2.h>
+#else
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# include <unistd.h>
+#endif
#include <string>
#include "tagsprofiler.h"
@@ -29,6 +33,12 @@
#include "tagsrequesthandler.h"
#include "socket_server.h"
+#ifdef WIN32
+typedef int socklen_t;
+#define write(x, y, z) send(x, y, z, 0)
+#define close(x) closesocket(x)
+#endif
+
extern GtagsLogger* logger;
DEFINE_INT32(tags_port, 2222, "port to tags server");
次にgoogle-gtagsのソースルートにregex for win32を解凍します。これで、gnu_regex_distというフォルダが出来ます。
sh configure
お持ちでない方でもconfigureの中身を見ると大体検討が付きます。
all: gtags.exe
gtags.exe : filename.cc gtags.cc sexpression.cc strutil.cc symboltable.cc tagsoptionparser.cc tagsprofiler.cc tagsrequesthandler.cc tagstable.cc socket_server.cc gnu_regex_dist/regex.c
gcc -DHAVE_STRING_H -c -I. gnu_regex_dist/regex.c
gcc -I. -Ignu_regex_dist -o gtags.exe filename.cc gtags.cc sexpression.cc strutil.cc symboltable.cc tagsoptionparser.cc tagsprofiler.cc tagsrequesthandler.cc tagstable.cc socket_server.cc regex.o -lstdc++ -lws2_32
あとはspiritlooseのはてなダイアリー - [Vim]Google Tags(GTags)を試してみた(with Vim)を参考に
lang_call_to_server = {
"c++" : { "definition" : [("localhost", 2222)],
"callgraph" : [] },
"java" : { "definition" : [],
"callgraph" : [] },
"python" : { "definition" : [],
"callgraph" : [] } }
等と設定して、vimrcに
exec "set runtimepath+=".escape(globpath(&runtimepath, 'gtags'), ' ')
nmap <C-]> :call Gtag(expand('<cword>'))<CR>
を追加します。
python c:/temp/google-gtags/gentags.py --etags=c:/emacs/bin/etags.exe --rtags=c:/temp/google-gtags/rtags.py --etags_to_tags=c:/temp/google-gtags/etags_to_tags.py
ここではetagsとしてemacsに含まれるバイナリを使用しましたが、ctags.exeをetags.exeにリネームしても同様に使えます。
c:/temp/gtags.exe --tags_file ./cpp.tags.gz --tags_port 2222 --gunzip
起動したらvim(gvim)を起動して、タグジャンプしたい部分でC-]します。
svn ci -m "lang/LanguageName/BigProjectName: Commit messege."
svn ci -m "lang/LanguageName/misc/ScriptName: Commit messege."
svn ci -m "dotfiles/SoftwareName/Username-Filename: Commit messege."
を守ってcommit時にファイル名を一覧しました。
lang/LanguageName/BigProjectName,
lang/LanguageName/misc/ScriptName,
dotfiles/SoftwareName/Username-Filename:
Added.
といった書き方をされていました。
URL : http://host/root/path/to/dir
Repository Root : http://host/root
という部分の2行の差、「path/to/dir」を取得し、svn commit実行時にエディタに表示されている
--This line, and those below, will be ignored--
A docs
A docs/file1.txt
A docs/file2.txt
A docs/file3.txt
のファイル名部分の先頭に上記フォルダ「path/to/dir」を付与し
path/to/dir/docs,
path/to/dir/docs/file1.txt,
path/to/dir/docs/file2.txt,
path/to/dir/docs/file3.txt:
というコメントを生成します。
path/to/dir/docs,
path/to/dir/docs/file1.txt,
path/to/dir/docs/file2.txt,
path/to/dir/docs/file3.txt:
--This line, and those below, will be ignored--
A docs
A docs/file1.txt
A docs/file2.txt
A docs/file3.txt
という画面が現れます。カーソルも":"の次の行に移動しますので、そこからコメントを書くと事が出来ます。
"=============================================================================
" File: svn_file_comment.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" Last Change: Fri, 12 Oct 2007
" Version: 0.1
"-----------------------------------------------------------------------------
" when editing comment for 'svn commit',
" it append svn comment like following
"
" root/path/to/dir/docs,
" root/path/to/dir/docs/file1.txt,
" root/path/to/dir/docs/file2.txt,
" root/path/to/dir/docs/file3.txt:
" <= cursor
" --This line, and those below, will be ignored--
" A docs
" A docs/file1.txt
" A docs/file2.txt
" A docs/file3.txt
"-----------------------------------------------------------------------------
function! AppendCommitFiles()
let lstart = search("^--", "n")
let lend = line("$")
if line(".") > 1 || lstart != 2
return
endif
let oldlang=$LANG
let $LANG="C"
let lines=system("svn info")
let $LANG=oldlang
let url=substitute(lines, '.*\nURL: \([^\x0A]*\).*', '\1', '')
let root=substitute(lines, '.*\nRepository Root: \([^\x0A]*\).*', '\1', '')
if match(url, root) != 0
return
endif
let basedir=substitute(strpart(url, strlen(root)), '^\/*', '', '')
let lcur = lstart
let lines = ""
let mx = '^\s*[A-Z]\s\+\([^$]\+\)$'
while lcur <= lend
let line = getline(lcur)
if line =~ mx
let lines .= basedir."/".substitute(line, mx, '\1', '')."\<NL>"
endif
let lcur = lcur + 1
endwhile
let lines = substitute(lines, '\n.', ',&', 'g')
let lines = substitute(lines, '\n$', ':&', '')
call cursor(0)
let value = getreg("a")
let type = getregtype("a")
call setreg("a", lines, "c")
execute 'normal! "ap'
call setreg("a", value, type)
silent! /^$
endfunction
autocmd FileType svn call AppendCommitFiles()
例によって、このソースもCodeReposのコノ辺に置く予定です。このブログを応援する