diff --git a/.gitmodules b/.gitmodules index 48a19bd..1152d25 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "gtkdoc"] path = gtkdoc - url = git://github.com/eiiches/gtkdoc.git + url = git://github.com/albfan/gtkdoc.git diff --git a/README b/README deleted file mode 100644 index 41948e1..0000000 --- a/README +++ /dev/null @@ -1,15 +0,0 @@ -vim-ref addon for gtkdoc (or devhelp?) -====================================== - -Requirements: - devhelpforcui [http://github.com/eiiches/devhelpforcui] - vim-ref [http://github.com/thinca/vim-ref] - -Installation: - 1. install files under 'runtimepath' directory. - 2. set g:ref_gtkdoc_cmd to devhelpforcui's show command. - Ex) let g:ref_gtkdoc_cmd='/path/to/devhelp/for/cui/command/show' - -Usage: - :Ref gtkdoc - diff --git a/README.md b/README.md new file mode 100644 index 0000000..df361b4 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# vim-ref addon for gtkdoc (or devhelp) + +See gtk documentation on vim + +## Screencast + +![screencast of vim-ref-gtkdoc](etc/GtkHelp_vim.gif) + +## Install with Vundle: + + Plugin 'thinca/vim-ref' + Plugin 'eiiches/gtkdoc' + + cd path/to/plugin + # usually ~/.vim/bundle/vim-ref-gtkdoc) + make + +## Usage: + + :Ref gtkdoc + :GtkHelp (word under cursor or visual selection) + +## Credits + + - gtkdoc-cui [http://github.com/eiiches/gtkdoc] + - vim-ref [http://github.com/thinca/vim-ref] + diff --git a/autoload/ref/gtkdoc.vim b/autoload/ref/gtkdoc.vim index 0a3886e..abf3735 100644 --- a/autoload/ref/gtkdoc.vim +++ b/autoload/ref/gtkdoc.vim @@ -50,5 +50,21 @@ function! ref#gtkdoc#define() " {{{2 return s:source endfunction +function! ref#gtkdoc#vsel(type) " {{{2 + if "vV" =~ mode() + let [lnum1, col1] = getpos("'<")[1:2] + let [lnum2, col2] = getpos("'>")[1:2] + let lines = getline(lnum1, lnum2) + let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)] + let lines[0] = lines[0][col1 - 1:] + let patter = join(lines) + else + let pattern = expand("") + endif + + call ref#ref(a:type . ' ' . pattern) + +endfunction + let &cpo = s:save_cpo unlet s:save_cpo diff --git a/autoload/ref/gtkdocfull.vim b/autoload/ref/gtkdocfull.vim new file mode 100644 index 0000000..ec88a46 --- /dev/null +++ b/autoload/ref/gtkdocfull.vim @@ -0,0 +1,53 @@ +" A ref source for gtkdocfull. +" Version: 0.0.1 +" Author : albfan +" License: Creative Commons Attribution 2.1 Japan License +" + +let s:save_cpo = &cpo +set cpo&vim + +if !exists('g:ref_gtkdoc_cmd_full') + let g:ref_gtkdoc_cmd_full = globpath(&rtp, 'gtkdoc/gtkdocfull', 1) +endif + +let s:source = {'name': 'gtkdocfull'} " {{{1 + +function! s:source.available() " {{{2 + return !empty(g:ref_gtkdoc_cmd_full) +endfunction + +function! s:source.get_body(query) " {{{2 + return ref#system(g:ref_gtkdoc_cmd_full.' '.a:query).stdout +endfunction + +function! s:source.opened(query) " {{{2 + execute "normal! gg" + call s:syntax(a:query) +endfunction + +function! s:source.normalize(query) " {{{2 + return substitute(substitute(a:query, '\_s\+', ' ', 'g'), '^ \| $', '', 'g') +endfunction + +" misc. {{{1 +function! s:syntax(query) " {{{2 + if exists('b:current_syntax') && b:current_syntax == 'ref-gtkdocfull' + return + endif + + syntax clear + let str = escape(substitute(a:query, '\s\+', '\\_s\\+', 'g'), '"') + if str =~# '^[[:alnum:]_[:space:]]\+$' + let str = '\<' . str . '\>' + execute 'syntax match refGtkDocFullKeyword "\c'.str.'"' + highlight default link refGtkDocFullKeyword Special + endif +endfunction + +function! ref#gtkdocfull#define() " {{{2 + return s:source +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/etc/GtkHelp_vim.gif b/etc/GtkHelp_vim.gif new file mode 100644 index 0000000..ece3c7b Binary files /dev/null and b/etc/GtkHelp_vim.gif differ diff --git a/gtkdoc b/gtkdoc index 173f9fb..5fd543a 160000 --- a/gtkdoc +++ b/gtkdoc @@ -1 +1 @@ -Subproject commit 173f9fb15f7378827679bd050ab00d6797fb1b73 +Subproject commit 5fd543a7e92c7544e61fcd02eef1f0c258c230ce diff --git a/plugin/gtkdoc.vim b/plugin/gtkdoc.vim new file mode 100644 index 0000000..23abed8 --- /dev/null +++ b/plugin/gtkdoc.vim @@ -0,0 +1,2 @@ +command! -range GtkHelp call ref#gtkdoc#vsel('gtkdoc') +command! -range GtkHelpFull call ref#gtkdoc#vsel('gtkdocfull')