分页: 1 / 1
asistant.vim 插件备份,助手类型插件,通常用来查询函数原型
发表于 : 2009-09-12 0:08
由 A-yu
最近写php的时间多了一点…唉……那些个函数,名称又长又乱,参数顺序也乱七八糟……没事自己就搞乱下顺序……
用全能补全的时候提示函数原型屏幕老闪啊闪,也不喜欢上面划出的那么一个框…碍事…
于是自己写了个查看提示信息的插件,基本上类似翻译字典,在要查的单词上,通常是函数名,按下绑定键就可以查看对应的信息。
加了php和vim函数原型的字典,vim是现成帮助里头就有,php的是从官网上下了英文手册用grep和vim抓的,5000多个函数和方法…丫…
这下省心多了,写着代码时某个函数一时记不清参数顺序了按下自己绑定的 ctrl + h 就弹出函数原型了……
有同样需要的可以下载下面的备份包,解压丢到plugin中了事,默认快捷键 ctrl + h
另外,现在只有php和vim的函数原型包……有需要别的可以自己抓取,保存成 关键字 => 提示信息 这样的格式到某个文件就行了,然后定义文件的路径 etc
代码: 全选
" == "acomment" == {{{
"
" File: assistant.vim
" Path: ~/.vim/plugin
" Author: A-yu
" Modifier: A-yu
" Modified: 2009-09-11 23:46:12
" Description: 查询某一单词相关说明的vim插件,很简单
" 通常我是用来查看一个函数的原型
" 仅在linux系统下的Vim中测试
" Note: 在Windows下使用请在Vim配置中将文件编码设为支持utf-8
" 或者转换该脚本至你所使用的编码
" License: 使用公共领域(public domain)许可
"
" --}}}
Re: asistant.vim 插件备份,助手类型插件,通常用来查询函数原型
发表于 : 2009-09-12 0:09
由 A-yu
代码: 全选
" == "acomment" == {{{
"
" File: assistant.vim
" Path: ~/.vim/plugin
" Author: A-yu
" Modifier: A-yu
" Modified: 2009-09-12 00:27:30
" Description: 查询某一单词相关说明的vim插件,很简单
" 通常我是用来查看一个函数的原型
" 仅在linux系统下的Vim中测试
" Note: 在Windows下使用请在Vim配置中将文件编码设为支持utf-8
" 或者转换该脚本至你所使用的编码
" License: 使用公共领域(public domain)许可
"
" --}}}
" Exit if already loaded
if exists("g:loaded_assistant")
finish
endif
" assistant插件版本号
let g:loaded_assistant = "Version 1.0"
" 不同后缀名文件对应的查询文件
let s:aType = {
\'php':'php', 'phps':'php', 'phtml':'php',
\'vim':'vim', 'vimrc':'vim'
\}
" 查询文件的路径名
let s:aUrl = {
\'php':expand('~/.vim/plugin/assistant/php/assistant.txt'),
\'vim':expand('~/.vim/plugin/assistant/vim/assistant.txt')
\}
" 显示帮助信息的函数,根据当前文件类型载入对应的查询文件
" 默认绑定键 <C-h>
nmap <silent> <unique> <C-h> :call <SID>ShowHelp()<Cr>
function s:ShowHelp()
if !exists("s:aDict")
let s:aDict = {}
endif
let fType = tolower((strridx(expand("%"),".") == -1) ?
\"" :
\strpart(expand("%"),(strridx(expand("%"),".") + 1)))
if !has_key(s:aType, fType)
echo "assistant.MISS : 当前文件类型尚未启用助手查询信息"
return
endif
if !has_key(s:aUrl, s:aType[fType])
echo "assistant.ERR : 当前文件类型对应的查询文件路径名缺少定义"
return
endif
if !has_key(s:aDict, s:aType[fType])
let s:aDict[s:aType[fType]] = {}
for line in readfile(s:aUrl[s:aType[fType]])
let idx = stridx(line, ' => ')
let ic = 4
if (idx == -1)
let idx = stridx(line, '=>')
let ic = 2
endif
if (idx > 0)
let s:aDict[s:aType[fType]][strpart(line, 0, idx)] = strpart(line, idx+ic)
endif
endfor
endif
let str = getline(".")
let col = col(".")
let end = col("$")
let nameSpace = 'FALSE'
let num = col - 1
while num >= 0
if strpart(str, num, 1) !~ '[a-zA-Z0-9_]'
break
endif
let lcol = num
let num -= 1
endw
if !exists("lcol")
echo 'assistant.MISS : 当前光标所在处的内容不是关键字'
return
endif
if num >=2 && strpart(str, 0, num+1) =~ '^\(.\+:\{2}\s*\)\|\(.\+->\s*\)$'
let nameSpace = 'TRUE'
endif
let num = col - 1
while num <= end
if strpart(str, num, 1) !~ '[a-zA-Z0-9_]'
break
endif
let rcol = num
let num += 1
endw
let key = strpart(str, lcol, rcol-lcol+1)
let len = len(s:aDict[s:aType[fType]]) - 1
let keys = keys(s:aDict[s:aType[fType]])
let vals = values(s:aDict[s:aType[fType]])
if nameSpace == 'FALSE'
while len >= 0
if keys[len] ==? key
echo keys[len] . vals[len]
return
endif
let len -= 1
endw
else
let results = []
while len >= 0
if keys[len] =~? '^.\+:\{2}' . key . '$'
call add(results, keys[len] . vals[len])
endif
let len -= 1
endw
if len(results) > 0
echo join(sort(results), "\n")
return
endif
endif
echo 'assistant.MISS : 没有选中内容 ' . key . ' 对应的信息'
return
endf
" vim:ft=vim:ff=unix:tabstop=4:shiftwidth=4:softtabstop=4:expandtab
" End of file : assistant.vim
Re: asistant.vim 插件备份,助手类型插件,通常用来查询函数原型
发表于 : 2009-09-12 0:13
由 eexpress
支持。
不用。
反正lin的库太多。tags都麻烦。不折腾。