0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

updated for version 7.0221

This commit is contained in:
Bram Moolenaar 2006-03-11 21:35:11 +00:00
parent 038221bcd0
commit eb94e559e0
4 changed files with 147 additions and 69 deletions

View File

@ -1,7 +1,7 @@
" Vim completion script
" Language: C
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2006 Mar 09
" Last Change: 2006 Mar 11
" This function is used for the 'omnifunc' option.
@ -123,7 +123,8 @@ function! ccomplete#Complete(findstart, base)
" Completing one word and it's a local variable: May add '[', '.' or
" '->'.
let match = items[0]
if match(line, match . '\s*\[') > 0
let kind = 'v'
if match(line, '\<' . match . '\s*\[') > 0
let match .= '['
else
let res = s:Nextitem(strpart(line, 0, col), [''], 0, 1)
@ -136,7 +137,7 @@ function! ccomplete#Complete(findstart, base)
endif
endif
endif
let res = [{'match': match, 'tagline' : ''}]
let res = [{'match': match, 'tagline' : '', 'kind' : kind, 'info' : line}]
else
" Completing "var.", "var.something", etc.
let res = s:Nextitem(strpart(line, 0, col), items[1:], 0, 1)
@ -145,13 +146,24 @@ function! ccomplete#Complete(findstart, base)
if len(items) == 1
" Only one part, no "." or "->": complete from tags file.
call extend(res, map(taglist('^' . base), 's:Tag2item(v:val)'))
let tags = taglist('^' . base)
" Remove members, these can't appear without something in front.
call filter(tags, 'has_key(v:val, "kind") ? v:val["kind"] != "m" : 1')
" Remove static matches in other files.
call filter(tags, '!has_key(v:val, "static") || !v:val["static"] || bufnr("%") == bufnr(v:val["filename"])')
call extend(res, map(tags, 's:Tag2item(v:val)'))
endif
if len(res) == 0
" Find the variable in the tags file(s)
let diclist = taglist('^' . items[0] . '$')
" Remove members, these can't appear without something in front.
call filter(diclist, 'has_key(v:val, "kind") ? v:val["kind"] != "m" : 1')
let res = []
for i in range(len(diclist))
" New ctags has the "typename" field.
@ -216,17 +228,29 @@ endfunction
" If it is a variable we may add "." or "->". Don't do it for other types,
" such as a typedef, by not including the info that s:GetAddition() uses.
function! s:Tag2item(val)
let x = s:Tagcmd2extra(a:val['cmd'], a:val['name'], a:val['filename'])
let res = {'match': a:val['name']}
let res['extra'] = s:Tagcmd2extra(a:val['cmd'], a:val['name'], a:val['filename'])
" Use the whole search command as the "info" entry.
let s = matchstr(a:val['cmd'], '/^\s*\zs.*\ze$/')
if s != ''
let res['info'] = substitute(s, '\\\(.\)', '\1', 'g')
endif
let res['tagline'] = ''
if has_key(a:val, "kind")
if a:val["kind"] == 'v'
return {'match': a:val['name'], 'tagline': "\t" . a:val['cmd'], 'dict': a:val, 'extra': x}
endif
if a:val["kind"] == 'f'
return {'match': a:val['name'] . '(', 'tagline': "", 'extra': x}
let kind = a:val['kind']
let res['kind'] = kind
if kind == 'v'
let res['tagline'] = "\t" . a:val['cmd']
let res['dict'] = a:val
elseif kind == 'f'
let res['match'] = a:val['name'] . '('
endif
endif
return {'match': a:val['name'], 'tagline': '', 'extra': x}
return res
endfunction
" Turn a match item "val" into an item for completion.
@ -234,17 +258,42 @@ endfunction
" "val['tagline']" is the tagline in which the last part was found.
function! s:Tagline2item(val, brackets)
let line = a:val['tagline']
let word = a:val['match'] . a:brackets . s:GetAddition(line, a:val['match'], [a:val], a:brackets == '')
let add = s:GetAddition(line, a:val['match'], [a:val], a:brackets == '')
let res = {'word': a:val['match'] . a:brackets . add }
if has_key(a:val, 'info')
" Use info from Tag2item().
let res['info'] = a:val['info']
else
" Use the whole search command as the "info" entry.
let s = matchstr(line, '\t/^\s*\zs.*\ze$/')
if s != ''
let res['info'] = substitute(s, '\\\(.\)', '\1', 'g')
endif
endif
if has_key(a:val, 'kind')
let res['kind'] = a:val['kind']
elseif add == '('
let res['kind'] = 'f'
else
let s = matchstr(line, '\t\(kind:\)\=\zs\S\ze\(\t\|$\)')
if s != ''
let res['kind'] = s
endif
endif
if has_key(a:val, 'extra')
return {'word': word, 'menu': a:val['extra']}
let res['menu'] = a:val['extra']
return res
endif
" Isolate the command after the tag and filename.
let s = matchstr(line, '[^\t]*\t[^\t]*\t\zs\(/^.*$/\|[^\t]*\)\ze\(;"\t\|\t\|$\)')
if s != ''
return {'word': word, 'menu': s:Tagcmd2extra(s, a:val['match'], matchstr(line, '[^\t]*\t\zs[^\t]*\ze\t'))}
let res['menu'] = s:Tagcmd2extra(s, a:val['match'], matchstr(line, '[^\t]*\t\zs[^\t]*\ze\t'))
endif
return {'word': word}
return res
endfunction
" Turn a command from a tag line to something that is useful in the menu
@ -297,20 +346,27 @@ function! s:Nextitem(lead, items, depth, all)
" Use the tags file to find out if this is a typedef.
let diclist = taglist('^' . tokens[tidx] . '$')
for tagidx in range(len(diclist))
let item = diclist[tagidx]
" New ctags has the "typename" field.
if has_key(diclist[tagidx], 'typename')
call extend(res, s:StructMembers(diclist[tagidx]['typename'], a:items, a:all))
if has_key(item, 'typename')
call extend(res, s:StructMembers(item['typename'], a:items, a:all))
continue
endif
" Only handle typedefs here.
if diclist[tagidx]['kind'] != 't'
if item['kind'] != 't'
continue
endif
" Skip matches local to another file.
if has_key(item, 'static') && item['static'] && bufnr('%') != bufnr(item['filename'])
continue
endif
" For old ctags we recognize "typedef struct aaa" and
" "typedef union bbb" in the tags file command.
let cmd = diclist[tagidx]['cmd']
let cmd = item['cmd']
let ei = matchend(cmd, 'typedef\s\+')
if ei > 1
let cmdtokens = split(strpart(cmd, ei), '\s\+\|\<')
@ -385,11 +441,26 @@ function! s:StructMembers(typename, items, all)
endif
endif
" Put matching members in matches[].
let matches = []
for l in qflist
let memb = matchstr(l['text'], '[^\t]*')
if memb =~ '^' . a:items[0]
call add(matches, {'match': memb, 'tagline': l['text']})
" Skip matches local to another file.
if match(l['text'], "\tfile:") < 0 || bufnr('%') == bufnr(matchstr(l['text'], '\t\zs[^\t]*'))
let item = {'match': memb, 'tagline': l['text']}
" Add the kind of item.
let s = matchstr(l['text'], '\t\(kind:\)\=\zs\S\ze\(\t\|$\)')
if s != ''
let item['kind'] = s
if s == 'f'
let item['match'] = memb . '('
endif
endif
call add(matches, item)
endif
endif
endfor

View File

@ -1,4 +1,4 @@
*todo.txt* For Vim version 7.0aa. Last change: 2006 Mar 10
*todo.txt* For Vim version 7.0aa. Last change: 2006 Mar 11
VIM REFERENCE MANUAL by Bram Moolenaar
@ -30,11 +30,6 @@ be worked on, but only if you sponsor Vim development. See |sponsor|.
*known-bugs*
-------------------- Known bugs and current work -----------------------
--remote-tab to open file in new tab in existing Vim server?
--remote-tab-silent
--remote-tab-wait
--remote-tab-wait-silent
Win32: Describe how to do debugging. (George Reilly)
Mac unicode patch (Da Woon Jung):
@ -53,17 +48,6 @@ Mac unicode patch (Da Woon Jung):
CONSIDERED FOR VERSION 7.0:
Omni completion:
ccomplete:
- For C add tag "kind" field to each match?
- When a typedef or struct is local to a file only use it in that file?
UI:
- Show "info" from a match in preview window (with an option or by opening
a preview window with a specific name).
Or use one window for matches, another for context/info (Doug Kearns,
2005 Sep 13)
- UNDO TREE: keep all states of the text, don't delete undo info.
When making a change, instead of clearing any future undo (thus redo)
info, make a new branch.

View File

@ -1,4 +1,4 @@
*version7.txt* For Vim version 7.0aa. Last change: 2006 Mar 10
*version7.txt* For Vim version 7.0aa. Last change: 2006 Mar 11
VIM REFERENCE MANUAL by Bram Moolenaar
@ -1896,4 +1896,9 @@ would be given for using a '|'. Also with ":loadkeymap".
Motif: When using a fontset and 'encoding' is "utf-8" and sizeof(wchar_t) !=
sizeof(XChar2b) then display was wrong. (Yukihiro Nakadaira)
":all" always set the current window to the first window, even when it
contains a buffer that is not in the argument list (can't be closed because it
is modified). Now go to the window that has the first item of the argument
list.
vim:tw=78:ts=8:ft=help:norl:

View File

@ -1461,20 +1461,16 @@ early_arg_scan(parmp)
mainerr_arg_missing((char_u *)argv[i]);
parmp->serverName_arg = (char_u *)argv[++i];
}
else if (STRICMP(argv[i], "--serverlist") == 0
|| STRICMP(argv[i], "--remote-send") == 0
|| STRICMP(argv[i], "--remote-expr") == 0
|| STRICMP(argv[i], "--remote") == 0
|| STRICMP(argv[i], "--remote-silent") == 0)
else if (STRICMP(argv[i], "--serverlist") == 0)
parmp->serverArg = TRUE;
else if (STRICMP(argv[i], "--remote-wait") == 0
|| STRICMP(argv[i], "--remote-wait-silent") == 0)
else if (STRNICMP(argv[i], "--remote", 8) == 0)
{
parmp->serverArg = TRUE;
#ifdef FEAT_GUI
/* don't fork() when starting the GUI to edit the files ourself */
gui.dofork = FALSE;
#endif
# ifdef FEAT_GUI
if (strstr(argv[i], "-wait") != 0)
/* don't fork() when starting the GUI to edit files ourself */
gui.dofork = FALSE;
# endif
}
# endif
# ifdef FEAT_GUI_GTK
@ -3127,7 +3123,7 @@ gettimeofday(struct timeval *tv, char *dummy)
* Common code for the X command server and the Win32 command server.
*/
static char_u *build_drop_cmd __ARGS((int filec, char **filev, int sendReply));
static char_u *build_drop_cmd __ARGS((int filec, char **filev, int tabs, int sendReply));
/*
* Do the client-server stuff, unless "--servername ''" was used.
@ -3235,6 +3231,7 @@ cmdsrv_main(argc, argv, serverName_arg, serverStr)
#define ARGTYPE_EDIT_WAIT 2
#define ARGTYPE_SEND 3
int silent = FALSE;
int tabs = FALSE;
# ifndef FEAT_X11
HWND srv;
# else
@ -3264,24 +3261,40 @@ cmdsrv_main(argc, argv, serverName_arg, serverStr)
break;
}
if (STRICMP(argv[i], "--remote") == 0)
argtype = ARGTYPE_EDIT;
else if (STRICMP(argv[i], "--remote-silent") == 0)
{
argtype = ARGTYPE_EDIT;
silent = TRUE;
}
else if (STRICMP(argv[i], "--remote-wait") == 0)
argtype = ARGTYPE_EDIT_WAIT;
else if (STRICMP(argv[i], "--remote-wait-silent") == 0)
{
argtype = ARGTYPE_EDIT_WAIT;
silent = TRUE;
}
else if (STRICMP(argv[i], "--remote-send") == 0)
if (STRICMP(argv[i], "--remote-send") == 0)
argtype = ARGTYPE_SEND;
else if (STRNICMP(argv[i], "--remote", 8) == 0)
{
char *p = argv[i] + 8;
argtype = ARGTYPE_EDIT;
while (*p != NUL)
{
if (STRNICMP(p, "-wait", 5) == 0)
{
argtype = ARGTYPE_EDIT_WAIT;
p += 5;
}
else if (STRNICMP(p, "-silent", 7) == 0)
{
silent = TRUE;
p += 7;
}
else if (STRNICMP(p, "-tab", 4) == 0)
{
tabs = TRUE;
p += 4;
}
else
{
argtype = ARGTYPE_OTHER;
break;
}
}
}
else
argtype = ARGTYPE_OTHER;
if (argtype != ARGTYPE_OTHER)
{
if (i == *argc - 1)
@ -3294,7 +3307,7 @@ cmdsrv_main(argc, argv, serverName_arg, serverStr)
else
{
*serverStr = build_drop_cmd(*argc - i - 1, argv + i + 1,
argtype == ARGTYPE_EDIT_WAIT);
tabs, argtype == ARGTYPE_EDIT_WAIT);
if (*serverStr == NULL)
{
/* Probably out of memory, exit. */
@ -3473,9 +3486,10 @@ cmdsrv_main(argc, argv, serverName_arg, serverStr)
* Build a ":drop" command to send to a Vim server.
*/
static char_u *
build_drop_cmd(filec, filev, sendReply)
build_drop_cmd(filec, filev, tabs, sendReply)
int filec;
char **filev;
int tabs; /* Use ":tab drop" instead of ":drop". */
int sendReply;
{
garray_T ga;
@ -3500,9 +3514,13 @@ build_drop_cmd(filec, filev, sendReply)
ga_init2(&ga, 1, 100);
ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd ");
ga_concat(&ga, p);
/* Call inputsave() so that a prompt for an encryption key works. */
ga_concat(&ga, (char_u *)"<CR>:if exists('*inputsave')|call inputsave()|endif|drop");
vim_free(p);
/* Call inputsave() so that a prompt for an encryption key works. */
ga_concat(&ga, (char_u *)"<CR>:if exists('*inputsave')|call inputsave()|endif|");
if (tabs)
ga_concat(&ga, (char_u *)"tab ");
ga_concat(&ga, (char_u *)"drop");
for (i = 0; i < filec; i++)
{
/* On Unix the shell has already expanded the wildcards, don't want to