xaizek / vim-qthelp (License: Unspecified) (since 2018-12-07)
This plugin opens Qt help pages in browser from C++ source code.
Commit c47898f04a734406048de4dbd9b1af8b5fb0ae03

Some comments have been corrected. Todo list has been added.
Author: xaizek
Author date (UTC): 2010-12-05 21:25
Committer name: xaizek
Committer date (UTC): 2010-12-05 21:25
Parent(s): d8f89acca53b1a7227bf58a6f8d64ae409da1337
Signing key:
Tree: bb2268a1a9681772398290ba7e59929148d9be76
File Lines added Lines deleted
plugin/qthelp.vim 23 17
File plugin/qthelp.vim changed (mode: 100644) (index 302b7f8..8599f2e)
1 1 " Name: qthelp " Name: qthelp
2 2 " Author: xaizek (xaizek@gmail.com) " Author: xaizek (xaizek@gmail.com)
3 " Version: 1.0
3 " Version: 1.0.0
4 4 " "
5 5 " Description: This plugin would allow you to open Qt help pages in browser " Description: This plugin would allow you to open Qt help pages in browser
6 6 " from your C++ source code. Currently it can show help if the word " from your C++ source code. Currently it can show help if the word
7 " under your cursor is a class name, a variable name or a
7 " underneath your cursor is a class name, a variable name or a
8 8 " class-member name. " class-member name.
9 9 " "
10 10 " Examples: QStr|ing trackTitle, artistName; " Examples: QStr|ing trackTitle, artistName;
11 11 " QString track|Title, artistName("Unknown"); " QString track|Title, artistName("Unknown");
12 12 " track|Title = "Unknown"; " track|Title = "Unknown";
13 " Running command QHelpOnThis will open help on QString.
13 " Running command :QHelpOnThis will open help on QString.
14 14 " "
15 15 " trackTitle.ri|ght(10); " trackTitle.ri|ght(10);
16 16 " Running command :QHelpOnThis will open help on QString::right. " Running command :QHelpOnThis will open help on QString::right.
 
21 21 " Configuring: g:qthelp_browser - command to run your browser " Configuring: g:qthelp_browser - command to run your browser
22 22 " default: '' (so an error message will be printed if your try to " default: '' (so an error message will be printed if your try to
23 23 " use plugin) " use plugin)
24 " Note: on Windows use something like
24 " Note: on Windows use something like (notice 'start' at the
25 " beginning)
25 26 " 'start c:\Program files\Mozilla Firefox\firefox.exe' " 'start c:\Program files\Mozilla Firefox\firefox.exe'
26 27 " or Vim will be waiting until you close your browser. " or Vim will be waiting until you close your browser.
27 28 " "
 
29 30 " 2. Add that tags-file into your 'tags' option (WARNING: doing " 2. Add that tags-file into your 'tags' option (WARNING: doing
30 31 " this in your .vimrc file can slow down and pollute completion " this in your .vimrc file can slow down and pollute completion
31 32 " list for not Qt-projects). " list for not Qt-projects).
32 " 3. Let g:qthelp_browser command to run your browser.
33 " 3. Setup g:qthelp_browser variable with the command to run your
34 " browser.
33 35 " 4. Map command QHelpOnThis on some hotkey. " 4. Map command QHelpOnThis on some hotkey.
34 36 " 5. Use QHelp from command-line for faster navigating through " 5. Use QHelp from command-line for faster navigating through
35 " help (to escape manual searching of needed method).
37 " help (to escape manual searching of needed section).
36 38 " "
37 39 " Limitation: I didn't found a way to determine inheritance hierarchy using " Limitation: I didn't found a way to determine inheritance hierarchy using
38 40 " tags so trying " tags so trying
 
43 45 " Warning: In some cases it can take a while for searching definition (for " Warning: In some cases it can take a while for searching definition (for
44 46 " example when it doesn't exist) if this happens hit Ctrl-C to " example when it doesn't exist) if this happens hit Ctrl-C to
45 47 " break searching. " break searching.
48 "
49 " ToDo: - Maybe it should look for declaration not only in one header
50 " file ("companion"), but in all included from this?
51 " - Is there a way to determine variable type without regexps?
46 52
47 53 if exists("g:loaded_qthelp") if exists("g:loaded_qthelp")
48 54 finish finish
 
... ... let s:typeregex = '^\s*\%(const\s\+\)\?'.s:nsregex.'\zs'.s:idregex.'\ze'
77 83 " b:foundinfile " b:foundinfile
78 84 " b:foundatline " b:foundatline
79 85
80 " some commands
86 " commands definition
81 87 command! -nargs=0 QHelpOnThis call QHHelp('') command! -nargs=0 QHelpOnThis call QHHelp('')
82 88 command! -nargs=1 QHelp call QHHelp('<args>') command! -nargs=1 QHelp call QHHelp('<args>')
83 89
84 90 " the main function " the main function
85 " cword parameter is what we want to get help on or '' for analyzing word under
86 " cursor
91 " cword parameter is what we want to get help on or '' for analyzing word
92 " underneath the cursor
87 93 function! QHHelp(query) function! QHHelp(query)
88 94 call s:QHDebug('QHDBG: QHHelp(cword="'.a:query.'")') call s:QHDebug('QHDBG: QHHelp(cword="'.a:query.'")')
89 95 if a:query != '' if a:query != ''
 
... ... function! QHHelp(query)
100 106 endif endif
101 107 endfunction endfunction
102 108
103 " determines if a class name, a variable name or a class member name is under
104 " cursor and returns appropriate taglist
109 " determines if a class name, a variable name or a class member name is
110 " underneath the cursor and returns appropriate taglist
105 111 function! s:QHGetTagsListUC() function! s:QHGetTagsListUC()
106 " wuc is for Word Under Cursor
112 " wuc is for Word Underneath the Cursor
107 113 let l:wuc = expand('<cword>') let l:wuc = expand('<cword>')
108 114 let l:lst = taglist('//apple_ref/cpp/cl//'.l:wuc.'$') let l:lst = taglist('//apple_ref/cpp/cl//'.l:wuc.'$')
109 115 if len(l:lst) == 0 " if WUC is var_name if len(l:lst) == 0 " if WUC is var_name
 
... ... function! s:QHGetTagsListUC()
123 129 return l:lst return l:lst
124 130 endfunction endfunction
125 131
126 " b:membername should be set before calling this function because it should
132 " b:membername should be set before calling this function because one should
127 133 " modify it last " modify it last
128 134 function! s:QHGetTagsListOnMember(class, member) function! s:QHGetTagsListOnMember(class, member)
129 135 let l:lst = taglist('^'.a:member.'-typedef$') let l:lst = taglist('^'.a:member.'-typedef$')
 
... ... endfunction
234 240 " stuff below is for analyzing code -------------------------------------------- " stuff below is for analyzing code --------------------------------------------
235 241 " ------------------------------------------------------------------------------ " ------------------------------------------------------------------------------
236 242
237 " returns list with information about Variable Under Cursor in form of
243 " returns list with information about Variable Underneath the Cursor in form of
238 244 " [classname, membername] " [classname, membername]
239 245 function! QHGetVUCInfo() function! QHGetVUCInfo()
240 246 let l:wuc = expand('<cword>') let l:wuc = expand('<cword>')
 
... ... function! QHGetVUCInfo()
256 262 endfunction endfunction
257 263
258 264 " this function searches for variable definition in current file and header " this function searches for variable definition in current file and header
259 " file if the current one is source
265 " file if the current one is a source
260 266 function! s:QHGetVarType(varname) function! s:QHGetVarType(varname)
261 267 let b:foundatline = line('.') let b:foundatline = line('.')
262 268
 
... ... function! s:QHSearchComplexVarDef(varname)
339 345 endif endif
340 346 endfunction endfunction
341 347
342 " searches for declaration of varname in args of current function
348 " searches for declaration of varname in argument list of current function
343 349 function! s:QHSearchVarDefInArgs(varname) function! s:QHSearchVarDefInArgs(varname)
344 350 let l:argdefregex = '[(,]\s*\%(const\)\?'.s:nsregex.s:idregex.s:varpfxregex let l:argdefregex = '[(,]\s*\%(const\)\?'.s:nsregex.s:idregex.s:varpfxregex
345 351 \.'\s\+'.a:varname.s:varsfxregex.'\s*[,)]\?' \.'\s\+'.a:varname.s:varsfxregex.'\s*[,)]\?'
 
... ... function! s:QHGetWUCType(wuc)
410 416 endif endif
411 417 endfunction endfunction
412 418
413 " vim: set foldmethod=syntax foldlevel=0 :
419 " vim: set foldmethod=syntax foldlevel=0 :miv "
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vim-qthelp

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vim-qthelp

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master