-*options.txt* For Vim version 9.1. Last change: 2025 Sep 15
+*options.txt* For Vim version 9.1. Last change: 2025 Sep 20
VIM REFERENCE MANUAL by Bram Moolenaar
*'autocomplete'* *'ac'* *'noautocomplete'* *'noac'*
'autocomplete' 'ac' boolean (default off)
- global
+ global or local to buffer |global-local|
{only available on platforms with timing support}
When on, Vim shows a completion menu as you type, similar to using
|i_CTRL-N|, but triggered automatically. See |ins-autocompletion|.
" These commands create the option window.
"
" Maintainer: The Vim Project <https://github.com/vim/vim>
-" Last Change: 2025 Sep 02
+" Last Change: 2025 Sep 20
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" If there already is an option window, jump to that one.
call append("$", "\t" .. s:local_to_buffer)
call <SID>OptionL("cpt")
call <SID>AddOption("autocomplete", gettext("automatic completion in insert mode"))
+ call append("$", "\t" .. s:global_or_local)
call <SID>BinOptionG("ac", &ac)
call <SID>AddOption("autocompletetimeout", gettext("initial decay timeout for 'autocomplete' algorithm"))
call append("$", " \tset act=" . &act)
#endif
clear_string_option(&buf->b_p_tsr);
clear_string_option(&buf->b_p_qe);
+ buf->b_p_ac = -1;
buf->b_p_ar = -1;
buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
clear_string_option(&buf->b_p_lw);
{
ins_compl_delete();
if (ins_compl_has_preinsert()
- && ins_compl_has_autocomplete())
+ && ins_compl_autocomplete_enabled())
(void)ins_compl_insert(FALSE, TRUE);
else
(void)ins_compl_insert(FALSE, FALSE);
case Ctrl_H:
did_backspace = ins_bs(c, BACKSPACE_CHAR, &inserted_space);
auto_format(FALSE, TRUE);
- if (did_backspace && p_ac && !char_avail()
+ if (did_backspace && ins_compl_has_autocomplete() && !char_avail()
&& curwin->w_cursor.col > 0)
{
c = char_before_cursor();
foldOpenCursor();
#endif
// Trigger autocompletion
- if (p_ac && !char_avail() && vim_isprintc(c))
+ if (ins_compl_has_autocomplete() && !char_avail()
+ && vim_isprintc(c))
{
update_screen(UPD_VALID); // Show character immediately
out_flush();
* Returns TRUE if autocompletion is active.
*/
int
-ins_compl_has_autocomplete(void)
+ins_compl_autocomplete_enabled(void)
{
return compl_autocomplete;
}
&& compl_opt_refresh_always);
}
+/*
+ * Return TRUE if 'autocomplete' option is set
+ */
+ int
+ins_compl_has_autocomplete(void)
+{
+ // Use buffer-local setting if defined (>= 0), otherwise use global
+ return curbuf->b_p_ac >= 0 ? curbuf->b_p_ac : p_ac;
+}
+
/*
* Called after changing "compl_leader".
* Show the popup menu with a different set of matches.
save_w_wrow = curwin->w_wrow;
save_w_leftcol = curwin->w_leftcol;
compl_restarting = TRUE;
- if (p_ac)
- compl_autocomplete = TRUE;
+ compl_autocomplete = ins_compl_has_autocomplete();
if (ins_complete(Ctrl_N, FALSE) == FAIL)
compl_cont_status = 0;
compl_restarting = FALSE;
#endif
curbuf->b_p_initialized = TRUE;
+ curbuf->b_p_ac = -1;
curbuf->b_p_ar = -1; // no local 'autoread' value
curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
check_buf_options(curbuf);
// For 'autoread' -1 means to use global value.
if ((int *)varp == &curbuf->b_p_ar && opt_flags == OPT_LOCAL)
value = -1;
+ else if ((int *)varp == &curbuf->b_p_ac && opt_flags == OPT_LOCAL)
+ value = -1;
else
value = *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
}
case PV_PATH:
clear_string_option(&buf->b_p_path);
break;
+ case PV_AC:
+ buf->b_p_ac = -1;
+ break;
case PV_AR:
buf->b_p_ar = -1;
break;
case PV_EP: return (char_u *)&(curbuf->b_p_ep);
case PV_KP: return (char_u *)&(curbuf->b_p_kp);
case PV_PATH: return (char_u *)&(curbuf->b_p_path);
+ case PV_AC: return (char_u *)&(curbuf->b_p_ac);
case PV_AR: return (char_u *)&(curbuf->b_p_ar);
case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
case PV_TC: return (char_u *)&(curbuf->b_p_tc);
? (char_u *)&curbuf->b_p_kp : p->var;
case PV_PATH: return *curbuf->b_p_path != NUL
? (char_u *)&(curbuf->b_p_path) : p->var;
+ case PV_AC: return curbuf->b_p_ac >= 0
+ ? (char_u *)&(curbuf->b_p_ac) : p->var;
case PV_AR: return curbuf->b_p_ar >= 0
? (char_u *)&(curbuf->b_p_ar) : p->var;
case PV_TAGS: return *curbuf->b_p_tags != NUL
// options that are normally global but also have a local value
// are not copied, start using the global value
+ buf->b_p_ac = -1;
buf->b_p_ar = -1;
buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
buf->b_p_bkc = empty_option;
enum
{
BV_AI = 0
+ , BV_AC
, BV_AR
, BV_BH
, BV_BKC
// Definition of the PV_ values for buffer-local options.
// The BV_ values are defined in option.h.
+#define PV_AC OPT_BOTH(OPT_BUF(BV_AC))
#define PV_AI OPT_BUF(BV_AI)
#define PV_AR OPT_BOTH(OPT_BUF(BV_AR))
#define PV_BKC OPT_BOTH(OPT_BUF(BV_BKC))
SCTX_INIT},
#ifdef ELAPSED_FUNC
{"autocomplete", "ac", P_BOOL|P_VI_DEF,
- (char_u *)&p_ac, PV_NONE, NULL,
+ (char_u *)&p_ac, PV_AC, NULL,
NULL, {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
{"autocompletedelay", "acl", P_NUM|P_VI_DEF,
(char_u *)&p_acl, PV_NONE, NULL, NULL,
int ins_compl_len(void);
int ins_compl_has_preinsert(void);
int ins_compl_preinsert_effect(void);
-int ins_compl_has_autocomplete(void);
+int ins_compl_autocomplete_enabled(void);
int ins_compl_bs(void);
void ins_compl_addleader(int c);
void ins_compl_addfrommatch(void);
int ins_complete(int c, int enable_pum);
void ins_compl_enable_autocomplete(void);
void free_insexpand_stuff(void);
+int ins_compl_has_autocomplete(void);
/* vim: set ft=c : */
sctx_T b_p_script_ctx[BV_COUNT]; // SCTXs for buffer-local options
#endif
+ int b_p_ac; // 'autocomplete'
int b_p_ai; // 'autoindent'
int b_p_ai_nopaste; // b_p_ai saved for paste mode
char_u *b_p_bkc; // 'backupcopy'
call test_override("char_avail", 1)
new
inoremap <buffer> <F2> <Cmd>let b:matches = complete_info(["matches"]).matches<CR>
- set autocomplete
+ setlocal autocomplete
setlocal complete=.,Fcompl#Func
call feedkeys("im\<F2>\<Esc>0", 'xt!')
call assert_equal(['foo', 'foobar'], b:matches->mapnew('v:val.word'))
setlocal complete&
- set autocomplete&
bwipe!
call test_override("char_avail", 0)
let &rtp = save_rtp
let lines =<< trim [SCRIPT]
call setline(1, ['foo', 'foobar', 'foobarbaz'])
- set autocomplete
+ setlocal autocomplete
[SCRIPT]
call writefile(lines, 'XTest_autocomplete_delay', 'D')
let buf = RunVimInTerminal('-S XTest_autocomplete_delay', {'rows': 10})
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1779,
/**/
1778,
/**/