Mirror of the Vim source from https://github.com/vim/vim
Révision | 7e6d264ec0a270beb9692df71fedb210c1896640 (tree) |
---|---|
l'heure | 2005-09-06 07:14:46 |
Auteur | vimboss |
Commiter | vimboss |
updated for version 7.0141
@@ -1,7 +1,7 @@ | ||
1 | 1 | " Vim completion script |
2 | 2 | " Language: C |
3 | 3 | " Maintainer: Bram Moolenaar <Bram@vim.org> |
4 | -" Last Change: 2005 Sep 01 | |
4 | +" Last Change: 2005 Sep 05 | |
5 | 5 | |
6 | 6 | function! ccomplete#Complete(findstart, base) |
7 | 7 | if a:findstart |
@@ -21,12 +21,81 @@ | ||
21 | 21 | endif |
22 | 22 | |
23 | 23 | " return list of matches |
24 | - let items = split(a:base, '\.\|->') | |
25 | - if len(items) == 1 | |
24 | + if a:base !~ '\.\|->' | |
26 | 25 | " Only one part, no "." or "->": complete from tags file. |
27 | - let diclist = taglist(items[0]) | |
26 | + let diclist = taglist(a:base) | |
28 | 27 | return map(diclist, 'v:val["name"]') |
29 | 28 | endif |
30 | - return items | |
29 | + | |
30 | + " Find variable locally in function or file. | |
31 | + let items = split(a:base, '\.\|->') | |
32 | + | |
33 | + " At the moment we only do "aa.bb", not "aa.bb.cc" | |
34 | + if len(items) > 2 | |
35 | + return [] | |
36 | + endif | |
37 | + | |
38 | + let line = '' | |
39 | + if searchdecl(items[0]) == 0 || searchdecl(items[0], 1) == 0 | |
40 | + " Found, now figure out the type. | |
41 | + " TODO: join previous line if it makes sense | |
42 | + let line = getline('.') | |
43 | + let col = col('.') | |
44 | + else | |
45 | + " Find the variable in the tags file | |
46 | + let diclist = taglist(items[0]) | |
47 | + for i in range(len(diclist)) | |
48 | + " For now we only recognize a variable. | |
49 | + if diclist[i]['kind'] == 'v' | |
50 | + let line = diclist[i]['cmd'] | |
51 | + if line[0] == '/' && line[1] == '^' | |
52 | + " the command is a search pattern, remove the leading /^ | |
53 | + let line = strpart(line, 2) | |
54 | + endif | |
55 | + let col = match(line, items[0]) | |
56 | + break | |
57 | + endif | |
58 | + endfor | |
59 | + endif | |
60 | + | |
61 | + if line == '' | |
62 | + return [] | |
63 | + endif | |
64 | + | |
65 | + " Is there a * before the variable name? | |
66 | + let col -= 1 | |
67 | + let star = 0 | |
68 | + while col > 0 | |
69 | + let col -= 1 | |
70 | + if line[col] == '*' | |
71 | + let star = 1 | |
72 | + elseif line[col] !~ '\s' | |
73 | + break | |
74 | + endif | |
75 | + endwhile | |
76 | + | |
77 | + " Use the line up to the variable name and split it in tokens. | |
78 | + let lead = strpart(line, 0, col + 1) | |
79 | + let tokens = split(lead, '\s\+\|\<') | |
80 | + | |
81 | + let basetext = matchstr(a:base, '.*\.\|->') | |
82 | + | |
83 | + for i in range(len(tokens) - 1) | |
84 | + if tokens[i] == 'struct' | |
85 | + let name = tokens[i + 1] | |
86 | + " Todo: Use all tags files; What about local structures? | |
87 | + exe 'vimgrep /\<struct:' . name . '\>/j tags' | |
88 | + let res = [] | |
89 | + for l in getqflist() | |
90 | + let memb = matchstr(l['text'], '[^\t]*') | |
91 | + if len(items) == 1 || memb =~ '^' . items[1] | |
92 | + call add(res, basetext . memb) | |
93 | + endif | |
94 | + endfor | |
95 | + return res | |
96 | + endif | |
97 | + endfor | |
98 | + | |
99 | + return tokens | |
31 | 100 | endfunction |
32 | 101 |
@@ -1,4 +1,4 @@ | ||
1 | -*todo.txt* For Vim version 7.0aa. Last change: 2005 Sep 01 | |
1 | +*todo.txt* For Vim version 7.0aa. Last change: 2005 Sep 05 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -86,6 +86,7 @@ | ||
86 | 86 | How to get the type of "var"? |
87 | 87 | tags file doesn't give type of typedef! E.g., oparg_T is |
88 | 88 | listed with "^} oparg_T;$" |
89 | + mlcscope may do it, but I can't find the sources | |
89 | 90 | How to get the members of that type? |
90 | 91 | tags file has struct: and class: fields |
91 | 92 |
@@ -1,4 +1,4 @@ | ||
1 | -*version7.txt* For Vim version 7.0aa. Last change: 2005 Aug 31 | |
1 | +*version7.txt* For Vim version 7.0aa. Last change: 2005 Sep 05 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -123,6 +123,10 @@ | ||
123 | 123 | s is replaced with "SS". This does not happen with "~" to avoid backwards |
124 | 124 | compatibility problems and because "SS" can't be changed back to a sharp s. |
125 | 125 | |
126 | +"gd" previously found the very first occurrence of a variable in a function, | |
127 | +that could be the function argument without type. Now it finds the position | |
128 | +where the type is given. | |
129 | + | |
126 | 130 | ============================================================================== |
127 | 131 | NEW FEATURES *new-7* |
128 | 132 |
@@ -569,6 +573,8 @@ | ||
569 | 573 | ":function" and ":autocmd" commands will show where it was last defined. |
570 | 574 | (Yegappan Lakshmanan) |
571 | 575 | |
576 | +":function /pattern" lists functions matching the pattern. | |
577 | + | |
572 | 578 | ============================================================================== |
573 | 579 | IMPROVEMENTS *improvements-7* |
574 | 580 |
@@ -580,6 +580,7 @@ | ||
580 | 580 | static void f_resolve __ARGS((typval_T *argvars, typval_T *rettv)); |
581 | 581 | static void f_reverse __ARGS((typval_T *argvars, typval_T *rettv)); |
582 | 582 | static void f_search __ARGS((typval_T *argvars, typval_T *rettv)); |
583 | +static void f_searchdecl __ARGS((typval_T *argvars, typval_T *rettv)); | |
583 | 584 | static void f_searchpair __ARGS((typval_T *argvars, typval_T *rettv)); |
584 | 585 | static void f_server2client __ARGS((typval_T *argvars, typval_T *rettv)); |
585 | 586 | static void f_serverlist __ARGS((typval_T *argvars, typval_T *rettv)); |
@@ -6818,6 +6819,7 @@ | ||
6818 | 6819 | {"resolve", 1, 1, f_resolve}, |
6819 | 6820 | {"reverse", 1, 1, f_reverse}, |
6820 | 6821 | {"search", 1, 2, f_search}, |
6822 | + {"searchdecl", 1, 2, f_searchdecl}, | |
6821 | 6823 | {"searchpair", 3, 5, f_searchpair}, |
6822 | 6824 | {"server2client", 2, 2, f_server2client}, |
6823 | 6825 | {"serverlist", 0, 0, f_serverlist}, |
@@ -12976,6 +12978,28 @@ | ||
12976 | 12978 | } |
12977 | 12979 | |
12978 | 12980 | /* |
12981 | + * "searchdecl()" function | |
12982 | + */ | |
12983 | + static void | |
12984 | +f_searchdecl(argvars, rettv) | |
12985 | + typval_T *argvars; | |
12986 | + typval_T *rettv; | |
12987 | +{ | |
12988 | + int locally = 1; | |
12989 | + int error = FALSE; | |
12990 | + char_u *name; | |
12991 | + | |
12992 | + rettv->vval.v_number = 1; /* default: FAIL */ | |
12993 | + | |
12994 | + name = get_tv_string_chk(&argvars[0]); | |
12995 | + if (argvars[1].v_type != VAR_UNKNOWN) | |
12996 | + locally = get_tv_number_chk(&argvars[1], &error) == 0; | |
12997 | + if (!error && name != NULL) | |
12998 | + rettv->vval.v_number = find_decl(name, (int)STRLEN(name), | |
12999 | + locally, SEARCH_KEEP) == FAIL; | |
13000 | +} | |
13001 | + | |
13002 | +/* | |
12979 | 13003 | * "searchpair()" function |
12980 | 13004 | */ |
12981 | 13005 | static void |
@@ -16801,6 +16825,44 @@ | ||
16801 | 16825 | } |
16802 | 16826 | |
16803 | 16827 | /* |
16828 | + * ":function /pat": list functions matching pattern. | |
16829 | + */ | |
16830 | + if (*eap->arg == '/') | |
16831 | + { | |
16832 | + p = skip_regexp(eap->arg + 1, '/', TRUE, NULL); | |
16833 | + if (!eap->skip) | |
16834 | + { | |
16835 | + regmatch_T regmatch; | |
16836 | + | |
16837 | + c = *p; | |
16838 | + *p = NUL; | |
16839 | + regmatch.regprog = vim_regcomp(eap->arg + 1, RE_MAGIC); | |
16840 | + *p = c; | |
16841 | + if (regmatch.regprog != NULL) | |
16842 | + { | |
16843 | + regmatch.rm_ic = p_ic; | |
16844 | + | |
16845 | + todo = func_hashtab.ht_used; | |
16846 | + for (hi = func_hashtab.ht_array; todo > 0 && !got_int; ++hi) | |
16847 | + { | |
16848 | + if (!HASHITEM_EMPTY(hi)) | |
16849 | + { | |
16850 | + --todo; | |
16851 | + fp = HI2UF(hi); | |
16852 | + if (!isdigit(*fp->uf_name) | |
16853 | + && vim_regexec(®match, fp->uf_name, 0)) | |
16854 | + list_func_head(fp, FALSE); | |
16855 | + } | |
16856 | + } | |
16857 | + } | |
16858 | + } | |
16859 | + if (*p == '/') | |
16860 | + ++p; | |
16861 | + eap->nextcmd = check_nextcmd(p); | |
16862 | + return; | |
16863 | + } | |
16864 | + | |
16865 | + /* | |
16804 | 16866 | * Get the function name. There are these situations: |
16805 | 16867 | * func normal function name |
16806 | 16868 | * "name" == func, "fudi.fd_dict" == NULL |
@@ -17,7 +17,7 @@ | ||
17 | 17 | pos_T *findmatchlimit __ARGS((oparg_T *oap, int initc, int flags, int maxtravel)); |
18 | 18 | void showmatch __ARGS((int c)); |
19 | 19 | int findsent __ARGS((int dir, long count)); |
20 | -int findpar __ARGS((oparg_T *oap, int dir, long count, int what, int both)); | |
20 | +int findpar __ARGS((int *pincl, int dir, long count, int what, int both)); | |
21 | 21 | int startPS __ARGS((linenr_T lnum, int para, int both)); |
22 | 22 | int fwd_word __ARGS((long count, int bigword, int eol)); |
23 | 23 | int bck_word __ARGS((long count, int bigword, int stop)); |