mirror of
https://github.com/neovim/neovim.git
synced 2025-01-01 17:23:36 -07:00
parent
f357c9bca5
commit
420bb2eb8a
@ -1055,64 +1055,6 @@ static void f_col(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
get_col(argvars, rettv, false);
|
get_col(argvars, rettv, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// "complete()" function
|
|
||||||
static void f_complete(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|
||||||
{
|
|
||||||
if ((State & MODE_INSERT) == 0) {
|
|
||||||
emsg(_("E785: complete() can only be used in Insert mode"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for undo allowed here, because if something was already inserted
|
|
||||||
// the line was already saved for undo and this check isn't done.
|
|
||||||
if (!undo_allowed(curbuf)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argvars[1].v_type != VAR_LIST) {
|
|
||||||
emsg(_(e_invarg));
|
|
||||||
} else {
|
|
||||||
const colnr_T startcol = tv_get_number_chk(&argvars[0], NULL);
|
|
||||||
if (startcol > 0) {
|
|
||||||
set_completion(startcol - 1, argvars[1].vval.v_list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// "complete_add()" function
|
|
||||||
static void f_complete_add(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|
||||||
{
|
|
||||||
rettv->vval.v_number = ins_compl_add_tv(&argvars[0], 0, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// "complete_check()" function
|
|
||||||
static void f_complete_check(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|
||||||
{
|
|
||||||
int saved = RedrawingDisabled;
|
|
||||||
|
|
||||||
RedrawingDisabled = 0;
|
|
||||||
ins_compl_check_keys(0, true);
|
|
||||||
rettv->vval.v_number = ins_compl_interrupted();
|
|
||||||
RedrawingDisabled = saved;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// "complete_info()" function
|
|
||||||
static void f_complete_info(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|
||||||
{
|
|
||||||
tv_dict_alloc_ret(rettv);
|
|
||||||
|
|
||||||
list_T *what_list = NULL;
|
|
||||||
|
|
||||||
if (argvars[0].v_type != VAR_UNKNOWN) {
|
|
||||||
if (argvars[0].v_type != VAR_LIST) {
|
|
||||||
emsg(_(e_listreq));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
what_list = argvars[0].vval.v_list;
|
|
||||||
}
|
|
||||||
get_complete_info(what_list, rettv->vval.v_dict);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// "confirm(message, buttons[, default [, type]])" function
|
/// "confirm(message, buttons[, default [, type]])" function
|
||||||
static void f_confirm(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_confirm(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "nvim/strings.h"
|
#include "nvim/strings.h"
|
||||||
#include "nvim/tag.h"
|
#include "nvim/tag.h"
|
||||||
#include "nvim/ui.h"
|
#include "nvim/ui.h"
|
||||||
|
#include "nvim/undo.h"
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
#include "nvim/window.h"
|
#include "nvim/window.h"
|
||||||
|
|
||||||
@ -2109,7 +2110,7 @@ theend:
|
|||||||
/// @return NOTDONE if the given string is already in the list of completions,
|
/// @return NOTDONE if the given string is already in the list of completions,
|
||||||
/// otherwise it is added to the list and OK is returned. FAIL will be
|
/// otherwise it is added to the list and OK is returned. FAIL will be
|
||||||
/// returned in case of error.
|
/// returned in case of error.
|
||||||
int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast)
|
static int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
const char *word;
|
const char *word;
|
||||||
@ -2195,7 +2196,7 @@ static void ins_compl_add_dict(dict_T *dict)
|
|||||||
///
|
///
|
||||||
/// @param startcol where the matched text starts (1 is first column).
|
/// @param startcol where the matched text starts (1 is first column).
|
||||||
/// @param list the list of matches.
|
/// @param list the list of matches.
|
||||||
void set_completion(colnr_T startcol, list_T *list)
|
static void set_completion(colnr_T startcol, list_T *list)
|
||||||
{
|
{
|
||||||
int flags = CP_ORIGINAL_TEXT;
|
int flags = CP_ORIGINAL_TEXT;
|
||||||
|
|
||||||
@ -2253,6 +2254,47 @@ void set_completion(colnr_T startcol, list_T *list)
|
|||||||
ui_flush();
|
ui_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// "complete()" function
|
||||||
|
void f_complete(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
|
{
|
||||||
|
if ((State & MODE_INSERT) == 0) {
|
||||||
|
emsg(_("E785: complete() can only be used in Insert mode"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for undo allowed here, because if something was already inserted
|
||||||
|
// the line was already saved for undo and this check isn't done.
|
||||||
|
if (!undo_allowed(curbuf)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argvars[1].v_type != VAR_LIST) {
|
||||||
|
emsg(_(e_invarg));
|
||||||
|
} else {
|
||||||
|
const colnr_T startcol = (colnr_T)tv_get_number_chk(&argvars[0], NULL);
|
||||||
|
if (startcol > 0) {
|
||||||
|
set_completion(startcol - 1, argvars[1].vval.v_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// "complete_add()" function
|
||||||
|
void f_complete_add(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
|
{
|
||||||
|
rettv->vval.v_number = ins_compl_add_tv(&argvars[0], 0, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// "complete_check()" function
|
||||||
|
void f_complete_check(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
|
{
|
||||||
|
int saved = RedrawingDisabled;
|
||||||
|
|
||||||
|
RedrawingDisabled = 0;
|
||||||
|
ins_compl_check_keys(0, true);
|
||||||
|
rettv->vval.v_number = ins_compl_interrupted();
|
||||||
|
RedrawingDisabled = saved;
|
||||||
|
}
|
||||||
|
|
||||||
/// Return Insert completion mode name string
|
/// Return Insert completion mode name string
|
||||||
static char_u *ins_compl_mode(void)
|
static char_u *ins_compl_mode(void)
|
||||||
{
|
{
|
||||||
@ -2312,8 +2354,8 @@ static void ins_compl_update_sequence_numbers(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get complete information
|
/// Get complete information
|
||||||
void get_complete_info(list_T *what_list, dict_T *retdict)
|
static void get_complete_info(list_T *what_list, dict_T *retdict)
|
||||||
{
|
{
|
||||||
#define CI_WHAT_MODE 0x01
|
#define CI_WHAT_MODE 0x01
|
||||||
#define CI_WHAT_PUM_VISIBLE 0x02
|
#define CI_WHAT_PUM_VISIBLE 0x02
|
||||||
@ -2397,6 +2439,23 @@ void get_complete_info(list_T *what_list, dict_T *retdict)
|
|||||||
// if (ret == OK && (what_flag & CI_WHAT_INSERTED))
|
// if (ret == OK && (what_flag & CI_WHAT_INSERTED))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// "complete_info()" function
|
||||||
|
void f_complete_info(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
|
{
|
||||||
|
tv_dict_alloc_ret(rettv);
|
||||||
|
|
||||||
|
list_T *what_list = NULL;
|
||||||
|
|
||||||
|
if (argvars[0].v_type != VAR_UNKNOWN) {
|
||||||
|
if (argvars[0].v_type != VAR_LIST) {
|
||||||
|
emsg(_(e_listreq));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
what_list = argvars[0].vval.v_list;
|
||||||
|
}
|
||||||
|
get_complete_info(what_list, rettv->vval.v_dict);
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns true when using a user-defined function for thesaurus completion.
|
/// Returns true when using a user-defined function for thesaurus completion.
|
||||||
static bool thesaurus_func_complete(int type)
|
static bool thesaurus_func_complete(int type)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef NVIM_INSEXPAND_H
|
#ifndef NVIM_INSEXPAND_H
|
||||||
#define NVIM_INSEXPAND_H
|
#define NVIM_INSEXPAND_H
|
||||||
|
|
||||||
|
#include "nvim/eval/funcs.h"
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
|
|
||||||
/// state for pum_ext_select_item.
|
/// state for pum_ext_select_item.
|
||||||
|
Loading…
Reference in New Issue
Block a user