Recent patch 7.2.143 introduced completion for the ":cscope" command.
Attached patch improves completion further to also add completion for
the ":lcscope" and ":scscope" commands:
:lcscope completion is identical to :cscope
:scscope completion restricts to subcommands which can run in split window.
Regards
-- Dominique
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Index: if_cscope.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/if_cscope.c,v
retrieving revision 1.35
diff -c -r1.35 if_cscope.c
*** if_cscope.c 18 Mar 2009 13:32:24 -0000 1.35
--- if_cscope.c 20 Mar 2009 23:00:56 -0000
***************
*** 98,103 ****
--- 98,104 ----
static enum
{
EXP_CSCOPE_SUBCMD, /* expand ":cscope" sub-commands */
+ EXP_SCSCOPE_SUBCMD, /* expand ":scscope" sub-commands */
EXP_CSCOPE_FIND, /* expand ":cscope find" arguments */
EXP_CSCOPE_KILL /* expand ":cscope kill" arguments */
} expand_what;
***************
*** 112,123 ****
--- 113,135 ----
expand_T *xp;
int idx;
{
+ int current_idx;
+ int i;
+
switch (expand_what)
{
case EXP_CSCOPE_SUBCMD:
/* Complete with sub-commands of ":cscope":
* add, find, help, kill, reset, show */
return (char_u *)cs_cmds[idx].name;
+ case EXP_SCSCOPE_SUBCMD:
+ /* Complete with sub-commands of ":scscope": same sub-commands as
+ * ":cscope" but skip commands which don't support split windows */
+ for (i = 0, current_idx = 0; cs_cmds[i].name != NULL; i++)
+ if (cs_cmds[i].cansplit)
+ if (current_idx++ == idx)
+ break;
+ return (char_u *)cs_cmds[i].name;
case EXP_CSCOPE_FIND:
{
const char *query_type[] =
***************
*** 133,147 ****
}
case EXP_CSCOPE_KILL:
{
- int i;
- int current_idx = 0;
static char_u connection[2];
/* ":cscope kill" accepts connection numbers or partial names of
* the pathname of the cscope database as argument. Only complete
* with connection numbers. -1 can also be used to kill all
* connections. */
! for (i = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
{
if (csinfo[i].fname == NULL)
continue;
--- 145,157 ----
}
case EXP_CSCOPE_KILL:
{
static char_u connection[2];
/* ":cscope kill" accepts connection numbers or partial names of
* the pathname of the cscope database as argument. Only complete
* with connection numbers. -1 can also be used to kill all
* connections. */
! for (i = 0, current_idx = 0; i < CSCOPE_MAX_CONNECTIONS; i++)
{
if (csinfo[i].fname == NULL)
continue;
***************
*** 165,180 ****
* Handle command line completion for :cscope command.
*/
void
! set_context_in_cscope_cmd(xp, arg)
expand_T *xp;
char_u *arg;
{
char_u *p;
/* Default: expand subcommands */
xp->xp_context = EXPAND_CSCOPE;
- expand_what = EXP_CSCOPE_SUBCMD;
xp->xp_pattern = arg;
/* (part of) subcommand already typed */
if (*arg != NUL)
--- 175,192 ----
* Handle command line completion for :cscope command.
*/
void
! set_context_in_cscope_cmd(xp, arg, cmdidx)
expand_T *xp;
char_u *arg;
+ cmdidx_T cmdidx;
{
char_u *p;
/* Default: expand subcommands */
xp->xp_context = EXPAND_CSCOPE;
xp->xp_pattern = arg;
+ expand_what = (cmdidx == CMD_scscope)
+ ? EXP_SCSCOPE_SUBCMD : EXP_CSCOPE_SUBCMD;
/* (part of) subcommand already typed */
if (*arg != NUL)
Index: ex_docmd.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/ex_docmd.c,v
retrieving revision 1.169
diff -c -r1.169 ex_docmd.c
*** ex_docmd.c 18 Mar 2009 11:52:27 -0000 1.169
--- ex_docmd.c 20 Mar 2009 23:01:01 -0000
***************
*** 3685,3691 ****
break;
#ifdef FEAT_CSCOPE
case CMD_cscope:
! set_context_in_cscope_cmd(xp, arg);
break;
#endif
#ifdef FEAT_LISTCMDS
--- 3685,3693 ----
break;
#ifdef FEAT_CSCOPE
case CMD_cscope:
! case CMD_lcscope:
! case CMD_scscope:
! set_context_in_cscope_cmd(xp, arg, ea.cmdidx);
break;
#endif
#ifdef FEAT_LISTCMDS
Index: proto/if_cscope.pro
===================================================================
RCS file: /cvsroot/vim/vim7/src/proto/if_cscope.pro,v
retrieving revision 1.5
diff -c -r1.5 if_cscope.pro
*** proto/if_cscope.pro 18 Mar 2009 11:52:12 -0000 1.5
--- proto/if_cscope.pro 20 Mar 2009 23:01:01 -0000
***************
*** 1,6 ****
/* if_cscope.c */
char_u *get_cscope_name __ARGS((expand_T *xp, int idx));
! void set_context_in_cscope_cmd __ARGS((expand_T *xp, char_u *arg));
void do_cscope __ARGS((exarg_T *eap));
void do_scscope __ARGS((exarg_T *eap));
void do_cstag __ARGS((exarg_T *eap));
--- 1,6 ----
/* if_cscope.c */
char_u *get_cscope_name __ARGS((expand_T *xp, int idx));
! void set_context_in_cscope_cmd __ARGS((expand_T *xp, char_u *arg, cmdidx_T cmdidx));
void do_cscope __ARGS((exarg_T *eap));
void do_scscope __ARGS((exarg_T *eap));
void do_cstag __ARGS((exarg_T *eap));