mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 16:28:17 +00:00
Replace references to viminfo in various places
This commit is contained in:
14
man/nvim.1
14
man/nvim.1
@@ -138,7 +138,7 @@ Sets the options 'hkmap' and 'rightleft'.
|
|||||||
.It Fl V Ns Oo Ar N Oc Ns Op Ar file
|
.It Fl V Ns Oo Ar N Oc Ns Op Ar file
|
||||||
Verbose mode.
|
Verbose mode.
|
||||||
Print messages about which files are being sourced and for reading and
|
Print messages about which files are being sourced and for reading and
|
||||||
writing an nviminfo file.
|
writing a ShaDa file.
|
||||||
.Ar N
|
.Ar N
|
||||||
is the value for the 'verbose' option; defaults to
|
is the value for the 'verbose' option; defaults to
|
||||||
.Cm 10
|
.Cm 10
|
||||||
@@ -191,18 +191,18 @@ is
|
|||||||
loading plugins is also skipped.
|
loading plugins is also skipped.
|
||||||
See
|
See
|
||||||
.Ic :help initialization .
|
.Ic :help initialization .
|
||||||
.It Fl i Ar nviminfo
|
.It Fl i Ar shada
|
||||||
Use
|
Use
|
||||||
.Ar nviminfo
|
.Ar shada
|
||||||
instead of the default of
|
instead of the default of
|
||||||
.Pa ~/.nviminfo .
|
.Pa ~/.nvim/shada/main.shada .
|
||||||
If
|
If
|
||||||
.Ar nviminfo
|
.Ar shada
|
||||||
is
|
is
|
||||||
.Cm NONE ,
|
.Cm NONE ,
|
||||||
do not read or write an nviminfo file.
|
do not read or write a ShaDa file.
|
||||||
See
|
See
|
||||||
.Ic :help viminfo .
|
.Ic :help shada .
|
||||||
.It Fl -noplugin
|
.It Fl -noplugin
|
||||||
Skip loading plugins.
|
Skip loading plugins.
|
||||||
Implied by
|
Implied by
|
||||||
|
@@ -1075,7 +1075,7 @@ if you stop editing a file without writing, like with ":n!".
|
|||||||
When you split a window, the jumplist will be copied to the new window.
|
When you split a window, the jumplist will be copied to the new window.
|
||||||
|
|
||||||
If you have included the ' item in the 'viminfo' option the jumplist will be
|
If you have included the ' item in the 'viminfo' option the jumplist will be
|
||||||
stored in the shada file and restored when starting Vim.
|
stored in the ShaDa file and restored when starting Vim.
|
||||||
|
|
||||||
|
|
||||||
CHANGE LIST JUMPS *changelist* *change-list-jumps* *E664*
|
CHANGE LIST JUMPS *changelist* *change-list-jumps* *E664*
|
||||||
|
@@ -476,7 +476,7 @@ accordingly. Vim proceeds in this order:
|
|||||||
|gui-init|.
|
|gui-init|.
|
||||||
|
|
||||||
9. Read the ShaDa file
|
9. Read the ShaDa file
|
||||||
If the 'viminfo' option is not empty, the viminfo file is read. See
|
If the 'viminfo' option is not empty, the ShaDa file is read. See
|
||||||
|shada-file|.
|
|shada-file|.
|
||||||
|
|
||||||
10. Read the quickfix file
|
10. Read the quickfix file
|
||||||
@@ -564,8 +564,8 @@ just like executing a command from a vimrc/exrc in the current directory.
|
|||||||
If Vim takes a long time to start up, use the |--startuptime| argument to find
|
If Vim takes a long time to start up, use the |--startuptime| argument to find
|
||||||
out what happens.
|
out what happens.
|
||||||
|
|
||||||
If you have "viminfo" enabled, the loading of the ShaDa file may take a
|
If you have 'viminfo' enabled, the loading of the ShaDa file may take a
|
||||||
while. You can find out if this is the problem by disabling viminfo for a
|
while. You can find out if this is the problem by disabling ShaDa for a
|
||||||
moment (use the Vim argument "-i NONE", |-i|). Try reducing the number of
|
moment (use the Vim argument "-i NONE", |-i|). Try reducing the number of
|
||||||
lines stored in a register with ":set viminfo='20,<50,s10". |shada-file|.
|
lines stored in a register with ":set viminfo='20,<50,s10". |shada-file|.
|
||||||
|
|
||||||
|
@@ -168,7 +168,7 @@ exiting Vim, there is a slightly more complicated way. You can see a list of
|
|||||||
files by typing the command: >
|
files by typing the command: >
|
||||||
|
|
||||||
:oldfiles
|
:oldfiles
|
||||||
< 1: ~/.viminfo ~
|
< 1: ~/.vimrc ~
|
||||||
2: ~/text/resume.txt ~
|
2: ~/text/resume.txt ~
|
||||||
3: /tmp/draft ~
|
3: /tmp/draft ~
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ That #<123 thing is a bit complicated when you just want to edit a file.
|
|||||||
Fortunately there is a simpler way: >
|
Fortunately there is a simpler way: >
|
||||||
|
|
||||||
:browse oldfiles
|
:browse oldfiles
|
||||||
< 1: ~/.viminfo ~
|
< 1: ~/.vimrc ~
|
||||||
2: ~/text/resume.txt ~
|
2: ~/text/resume.txt ~
|
||||||
3: /tmp/draft ~
|
3: /tmp/draft ~
|
||||||
-- More --
|
-- More --
|
||||||
|
@@ -1226,8 +1226,8 @@ if has("mksession")
|
|||||||
call append("$", "viewdir\tdirectory where to store files with :mkview")
|
call append("$", "viewdir\tdirectory where to store files with :mkview")
|
||||||
call <SID>OptionG("vdir", &vdir)
|
call <SID>OptionG("vdir", &vdir)
|
||||||
endif
|
endif
|
||||||
if has("viminfo")
|
if has("shada")
|
||||||
call append("$", "viminfo\tlist that specifies what to write in the viminfo file")
|
call append("$", "viminfo\tlist that specifies what to write in the ShaDa file")
|
||||||
call <SID>OptionG("vi", &vi)
|
call <SID>OptionG("vi", &vi)
|
||||||
endif
|
endif
|
||||||
if has("quickfix")
|
if has("quickfix")
|
||||||
|
@@ -9144,18 +9144,18 @@ int put_line(FILE *fd, char *s)
|
|||||||
*/
|
*/
|
||||||
static void ex_viminfo(exarg_T *eap)
|
static void ex_viminfo(exarg_T *eap)
|
||||||
{
|
{
|
||||||
char_u *save_viminfo;
|
char_u *save_shada;
|
||||||
|
|
||||||
save_viminfo = p_viminfo;
|
save_shada = p_shada;
|
||||||
if (*p_viminfo == NUL)
|
if (*p_shada == NUL)
|
||||||
p_viminfo = (char_u *)"'100";
|
p_shada = (char_u *)"'100";
|
||||||
if (eap->cmdidx == CMD_rviminfo) {
|
if (eap->cmdidx == CMD_rviminfo) {
|
||||||
if (shada_read_everything((char *) eap->arg, eap->forceit) == FAIL)
|
if (shada_read_everything((char *) eap->arg, eap->forceit) == FAIL)
|
||||||
EMSG(_("E195: Cannot open ShaDa file for reading"));
|
EMSG(_("E195: Cannot open ShaDa file for reading"));
|
||||||
} else {
|
} else {
|
||||||
shada_write_file((char *) eap->arg, eap->forceit);
|
shada_write_file((char *) eap->arg, eap->forceit);
|
||||||
}
|
}
|
||||||
p_viminfo = save_viminfo;
|
p_shada = save_shada;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -2172,7 +2172,7 @@ readfile_charconvert (
|
|||||||
*/
|
*/
|
||||||
static void check_marks_read(void)
|
static void check_marks_read(void)
|
||||||
{
|
{
|
||||||
if (!curbuf->b_marks_read && get_viminfo_parameter('\'') > 0
|
if (!curbuf->b_marks_read && get_shada_parameter('\'') > 0
|
||||||
&& curbuf->b_ffname != NULL) {
|
&& curbuf->b_ffname != NULL) {
|
||||||
shada_read_marks();
|
shada_read_marks();
|
||||||
}
|
}
|
||||||
|
@@ -382,7 +382,7 @@ int main(int argc, char **argv)
|
|||||||
* Read in registers, history etc, from the ShaDa file.
|
* Read in registers, history etc, from the ShaDa file.
|
||||||
* This is where v:oldfiles gets filled.
|
* This is where v:oldfiles gets filled.
|
||||||
*/
|
*/
|
||||||
if (*p_viminfo != NUL) {
|
if (*p_shada != NUL) {
|
||||||
(void) shada_read_file(NULL, (kShaDaWantInfo
|
(void) shada_read_file(NULL, (kShaDaWantInfo
|
||||||
| kShaDaGetOldfiles
|
| kShaDaGetOldfiles
|
||||||
| kShaDaWantMarks));
|
| kShaDaWantMarks));
|
||||||
@@ -807,8 +807,8 @@ void getout(int exitval)
|
|||||||
apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf);
|
apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_viminfo && *p_viminfo != NUL) {
|
if (p_shada && *p_shada != NUL) {
|
||||||
// Write out the registers, history, marks etc, to the viminfo file
|
// Write out the registers, history, marks etc, to the ShaDa file
|
||||||
shada_write_file(NULL, false);
|
shada_write_file(NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5238,7 +5238,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet)
|
|||||||
reg->additional_data = NULL;
|
reg->additional_data = NULL;
|
||||||
reg->timestamp = 0;
|
reg->timestamp = 0;
|
||||||
// Timestamp is not saved for clipboard registers because clipboard registers
|
// Timestamp is not saved for clipboard registers because clipboard registers
|
||||||
// are not saved in the viminfo.
|
// are not saved in the ShaDa file.
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (listitem_T *li = lines->lv_first; li != NULL; li = li->li_next) {
|
for (listitem_T *li = lines->lv_first; li != NULL; li = li->li_next) {
|
||||||
|
@@ -1743,11 +1743,11 @@ set_options_bin (
|
|||||||
* If the parameter is not specified in the string or there is no following
|
* If the parameter is not specified in the string or there is no following
|
||||||
* number, return -1.
|
* number, return -1.
|
||||||
*/
|
*/
|
||||||
int get_viminfo_parameter(int type)
|
int get_shada_parameter(int type)
|
||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
p = find_viminfo_parameter(type);
|
p = find_shada_parameter(type);
|
||||||
if (p != NULL && ascii_isdigit(*p))
|
if (p != NULL && ascii_isdigit(*p))
|
||||||
return atoi((char *)p);
|
return atoi((char *)p);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1758,11 +1758,11 @@ int get_viminfo_parameter(int type)
|
|||||||
* '/') in the 'viminfo' option and return a pointer to the string after it.
|
* '/') in the 'viminfo' option and return a pointer to the string after it.
|
||||||
* Return NULL if the parameter is not specified in the string.
|
* Return NULL if the parameter is not specified in the string.
|
||||||
*/
|
*/
|
||||||
char_u *find_viminfo_parameter(int type)
|
char_u *find_shada_parameter(int type)
|
||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
for (p = p_viminfo; *p; ++p) {
|
for (p = p_shada; *p; ++p) {
|
||||||
if (*p == type)
|
if (*p == type)
|
||||||
return p + 1;
|
return p + 1;
|
||||||
if (*p == 'n') /* 'n' is always the last one */
|
if (*p == 'n') /* 'n' is always the last one */
|
||||||
@@ -2443,8 +2443,8 @@ did_set_string_option (
|
|||||||
errmsg = e_invarg;
|
errmsg = e_invarg;
|
||||||
}
|
}
|
||||||
/* 'viminfo' */
|
/* 'viminfo' */
|
||||||
else if (varp == &p_viminfo) {
|
else if (varp == &p_shada) {
|
||||||
for (s = p_viminfo; *s; ) {
|
for (s = p_shada; *s; ) {
|
||||||
/* Check it's a valid character */
|
/* Check it's a valid character */
|
||||||
if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) {
|
if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) {
|
||||||
errmsg = illegal_char(errbuf, *s);
|
errmsg = illegal_char(errbuf, *s);
|
||||||
@@ -2486,7 +2486,7 @@ did_set_string_option (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
|
if (*p_shada && errmsg == NULL && get_shada_parameter('\'') < 0)
|
||||||
errmsg = (char_u *)N_("E528: Must specify a ' value");
|
errmsg = (char_u *)N_("E528: Must specify a ' value");
|
||||||
}
|
}
|
||||||
/* 'showbreak' */
|
/* 'showbreak' */
|
||||||
|
@@ -558,7 +558,7 @@ EXTERN long p_ur; /* 'undoreload' */
|
|||||||
EXTERN long p_uc; /* 'updatecount' */
|
EXTERN long p_uc; /* 'updatecount' */
|
||||||
EXTERN long p_ut; /* 'updatetime' */
|
EXTERN long p_ut; /* 'updatetime' */
|
||||||
EXTERN char_u *p_fcs; /* 'fillchar' */
|
EXTERN char_u *p_fcs; /* 'fillchar' */
|
||||||
EXTERN char_u *p_viminfo; /* 'viminfo' */
|
EXTERN char_u *p_shada; /* 'viminfo' */
|
||||||
EXTERN char_u *p_vdir; /* 'viewdir' */
|
EXTERN char_u *p_vdir; /* 'viewdir' */
|
||||||
EXTERN char_u *p_vop; /* 'viewoptions' */
|
EXTERN char_u *p_vop; /* 'viewoptions' */
|
||||||
EXTERN unsigned vop_flags; /* uses SSOP_ flags */
|
EXTERN unsigned vop_flags; /* uses SSOP_ flags */
|
||||||
|
@@ -2584,7 +2584,7 @@ return {
|
|||||||
type='string', list='comma', scope={'global'},
|
type='string', list='comma', scope={'global'},
|
||||||
deny_duplicates=true,
|
deny_duplicates=true,
|
||||||
secure=true,
|
secure=true,
|
||||||
varname='p_viminfo',
|
varname='p_shada',
|
||||||
defaults={if_true={vi="", vim="!,'100,<50,s10,h"}}
|
defaults={if_true={vi="", vim="!,'100,<50,s10,h"}}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@@ -63,8 +63,8 @@ KHASH_MAP_INIT_STR(fnamebufs, buf_T *)
|
|||||||
|
|
||||||
#define copy_option_part(src, dest, ...) \
|
#define copy_option_part(src, dest, ...) \
|
||||||
((char *) copy_option_part((char_u **) src, (char_u *) dest, __VA_ARGS__))
|
((char *) copy_option_part((char_u **) src, (char_u *) dest, __VA_ARGS__))
|
||||||
#define find_viminfo_parameter(...) \
|
#define find_shada_parameter(...) \
|
||||||
((const char *) find_viminfo_parameter(__VA_ARGS__))
|
((const char *) find_shada_parameter(__VA_ARGS__))
|
||||||
#define emsg2(a, b) emsg2((char_u *) a, (char_u *) b)
|
#define emsg2(a, b) emsg2((char_u *) a, (char_u *) b)
|
||||||
#define emsg3(a, b, c) emsg3((char_u *) a, (char_u *) b, (char_u *) c)
|
#define emsg3(a, b, c) emsg3((char_u *) a, (char_u *) b, (char_u *) c)
|
||||||
#define emsgu(a, ...) emsgu((char_u *) a, __VA_ARGS__)
|
#define emsgu(a, ...) emsgu((char_u *) a, __VA_ARGS__)
|
||||||
@@ -167,7 +167,7 @@ enum SRNIFlags {
|
|||||||
kSDReadBufferList = (1 << kSDItemBufferList), ///< Determines whether buffer
|
kSDReadBufferList = (1 << kSDItemBufferList), ///< Determines whether buffer
|
||||||
///< list should be read
|
///< list should be read
|
||||||
///< (disabled by removing
|
///< (disabled by removing
|
||||||
///< % entry from viminfo).
|
///< % entry from &viminfo).
|
||||||
kSDReadUnknown = (1 << (SHADA_LAST_ENTRY + 1)), ///< Determines whether
|
kSDReadUnknown = (1 << (SHADA_LAST_ENTRY + 1)), ///< Determines whether
|
||||||
///< unknown items should be
|
///< unknown items should be
|
||||||
///< read (usually disabled).
|
///< read (usually disabled).
|
||||||
@@ -200,6 +200,7 @@ typedef struct {
|
|||||||
int64_t offset;
|
int64_t offset;
|
||||||
bool is_last_used;
|
bool is_last_used;
|
||||||
bool is_substitute_pattern;
|
bool is_substitute_pattern;
|
||||||
|
// TODO(ZyX-I): Also store v:hlsearch, see :h shada-h
|
||||||
char *pat;
|
char *pat;
|
||||||
Dictionary *additional_data;
|
Dictionary *additional_data;
|
||||||
} search_pattern;
|
} search_pattern;
|
||||||
@@ -524,7 +525,7 @@ int shada_read_file(const char *const file, const int flags)
|
|||||||
|
|
||||||
if (p_verbose > 0) {
|
if (p_verbose > 0) {
|
||||||
verbose_enter();
|
verbose_enter();
|
||||||
smsg(_("Reading viminfo file \"%s\"%s%s%s"),
|
smsg(_("Reading ShaDa file \"%s\"%s%s%s"),
|
||||||
fname,
|
fname,
|
||||||
(flags & kShaDaWantInfo) ? _(" info") : "",
|
(flags & kShaDaWantInfo) ? _(" info") : "",
|
||||||
(flags & kShaDaWantMarks) ? _(" marks") : "",
|
(flags & kShaDaWantMarks) ? _(" marks") : "",
|
||||||
@@ -672,21 +673,22 @@ static inline bool marks_equal(const pos_T a, const pos_T b)
|
|||||||
static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
|
static void shada_read(ShaDaReadDef *const sd_reader, const int flags)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
|
// TODO(ZyX-I): Also load v:oldfiles.
|
||||||
unsigned srni_flags = 0;
|
unsigned srni_flags = 0;
|
||||||
if (flags & kShaDaWantInfo) {
|
if (flags & kShaDaWantInfo) {
|
||||||
srni_flags |= kSDReadUndisableableData | kSDReadRegisters;
|
srni_flags |= kSDReadUndisableableData | kSDReadRegisters;
|
||||||
if (p_hi) {
|
if (p_hi) {
|
||||||
srni_flags |= kSDReadHistory;
|
srni_flags |= kSDReadHistory;
|
||||||
}
|
}
|
||||||
if (find_viminfo_parameter('!') != NULL) {
|
if (find_shada_parameter('!') != NULL) {
|
||||||
srni_flags |= kSDReadVariables;
|
srni_flags |= kSDReadVariables;
|
||||||
}
|
}
|
||||||
if (find_viminfo_parameter('%') != NULL && ARGCOUNT == 0) {
|
if (find_shada_parameter('%') != NULL && ARGCOUNT == 0) {
|
||||||
srni_flags |= kSDReadBufferList;
|
srni_flags |= kSDReadBufferList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flags & kShaDaWantMarks) {
|
if (flags & kShaDaWantMarks) {
|
||||||
if (get_viminfo_parameter('\'') > 0) {
|
if (get_shada_parameter('\'') > 0) {
|
||||||
srni_flags |= kSDReadLocalMarks;
|
srni_flags |= kSDReadLocalMarks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1039,7 +1041,7 @@ static char *shada_filename(const char *file)
|
|||||||
if (file == NULL || *file == NUL) {
|
if (file == NULL || *file == NUL) {
|
||||||
if (used_shada_file != NULL) {
|
if (used_shada_file != NULL) {
|
||||||
file = used_shada_file;
|
file = used_shada_file;
|
||||||
} else if ((file = find_viminfo_parameter('n')) == NULL || *file == NUL) {
|
} else if ((file = find_shada_parameter('n')) == NULL || *file == NUL) {
|
||||||
#ifdef SHADA_FILE2
|
#ifdef SHADA_FILE2
|
||||||
// don't use $HOME when not defined (turned into "c:/"!).
|
// don't use $HOME when not defined (turned into "c:/"!).
|
||||||
if (os_getenv((char_u *)"HOME") == NULL) {
|
if (os_getenv((char_u *)"HOME") == NULL) {
|
||||||
@@ -1364,7 +1366,7 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
|
|||||||
FUNC_ATTR_NONNULL_ARG(1)
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
khash_t(bufset) *const removable_bufs = kh_init(bufset);
|
khash_t(bufset) *const removable_bufs = kh_init(bufset);
|
||||||
int max_kbyte_i = get_viminfo_parameter('s');
|
int max_kbyte_i = get_shada_parameter('s');
|
||||||
if (max_kbyte_i < 0) {
|
if (max_kbyte_i < 0) {
|
||||||
max_kbyte_i = 10;
|
max_kbyte_i = 10;
|
||||||
}
|
}
|
||||||
@@ -1409,7 +1411,7 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
|
|||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
// 2. Buffer list
|
// 2. Buffer list
|
||||||
if (find_viminfo_parameter('%') != NULL) {
|
if (find_shada_parameter('%') != NULL) {
|
||||||
size_t buf_count = 0;
|
size_t buf_count = 0;
|
||||||
FOR_ALL_BUFFERS(buf) {
|
FOR_ALL_BUFFERS(buf) {
|
||||||
if (buf->b_ffname != NULL && !SHADA_REMOVABLE(buf)) {
|
if (buf->b_ffname != NULL && !SHADA_REMOVABLE(buf)) {
|
||||||
@@ -1498,7 +1500,7 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
|
|||||||
// 4. History
|
// 4. History
|
||||||
HistoryMergerState hms[HIST_COUNT];
|
HistoryMergerState hms[HIST_COUNT];
|
||||||
for (uint8_t i = 0; i < HIST_COUNT; i++) {
|
for (uint8_t i = 0; i < HIST_COUNT; i++) {
|
||||||
long num_saved = get_viminfo_parameter(hist_type2char(i));
|
long num_saved = get_shada_parameter(hist_type2char(i));
|
||||||
if (num_saved == -1) {
|
if (num_saved == -1) {
|
||||||
num_saved = p_hi;
|
num_saved = p_hi;
|
||||||
}
|
}
|
||||||
@@ -1599,7 +1601,7 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 7. Global marks
|
// 7. Global marks
|
||||||
if (get_viminfo_parameter('f') != 0) {
|
if (get_shada_parameter('f') != 0) {
|
||||||
ShadaEntry *const global_marks = list_global_marks(removable_bufs);
|
ShadaEntry *const global_marks = list_global_marks(removable_bufs);
|
||||||
for (ShadaEntry *mark = global_marks; mark->type != kSDItemMissing;
|
for (ShadaEntry *mark = global_marks; mark->type != kSDItemMissing;
|
||||||
mark++) {
|
mark++) {
|
||||||
@@ -1636,12 +1638,12 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// FIXME: Copy previous marks, up to num_marked_files
|
// FIXME: Copy previous marks, up to num_marked_files
|
||||||
// size_t num_marked_files = get_viminfo_parameter('\'');
|
// size_t num_marked_files = get_shada_parameter('\'');
|
||||||
|
|
||||||
// 9. Registers
|
// 9. Registers
|
||||||
int max_num_lines_i = get_viminfo_parameter('<');
|
int max_num_lines_i = get_shada_parameter('<');
|
||||||
if (max_num_lines_i < 0) {
|
if (max_num_lines_i < 0) {
|
||||||
max_num_lines_i = get_viminfo_parameter('"');
|
max_num_lines_i = get_shada_parameter('"');
|
||||||
}
|
}
|
||||||
if (max_num_lines_i != 0) {
|
if (max_num_lines_i != 0) {
|
||||||
const size_t max_num_lines = (max_num_lines_i < 0
|
const size_t max_num_lines = (max_num_lines_i < 0
|
||||||
@@ -1673,7 +1675,7 @@ static void shada_write(ShaDaWriteDef *const sd_writer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 10. Variables
|
// 10. Variables
|
||||||
if (find_viminfo_parameter('!') != NULL) {
|
if (find_shada_parameter('!') != NULL) {
|
||||||
const void *var_iter = NULL;
|
const void *var_iter = NULL;
|
||||||
const Timestamp cur_timestamp = os_time();
|
const Timestamp cur_timestamp = os_time();
|
||||||
do {
|
do {
|
||||||
@@ -1730,6 +1732,7 @@ int shada_write_file(const char *const file, bool nomerge)
|
|||||||
intptr_t fd;
|
intptr_t fd;
|
||||||
|
|
||||||
if (!nomerge) {
|
if (!nomerge) {
|
||||||
|
// TODO(ZyX-I): Fail on read error.
|
||||||
if (open_shada_file_for_reading(fname, &sd_reader) != OK) {
|
if (open_shada_file_for_reading(fname, &sd_reader) != OK) {
|
||||||
nomerge = true;
|
nomerge = true;
|
||||||
goto shada_write_file_nomerge;
|
goto shada_write_file_nomerge;
|
||||||
@@ -1741,6 +1744,7 @@ int shada_write_file(const char *const file, bool nomerge)
|
|||||||
}
|
}
|
||||||
|
|
||||||
shada_write_file_open:
|
shada_write_file_open:
|
||||||
|
// TODO(ZyX-I): Preserve existing permissions
|
||||||
fd = (intptr_t) open_file(tempname, O_CREAT|O_WRONLY|O_NOFOLLOW|O_EXCL,
|
fd = (intptr_t) open_file(tempname, O_CREAT|O_WRONLY|O_NOFOLLOW|O_EXCL,
|
||||||
0600);
|
0600);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
@@ -1754,6 +1758,8 @@ shada_write_file_open:
|
|||||||
if (*wp == 'z') {
|
if (*wp == 'z') {
|
||||||
// Tried names from .tmp.a to .tmp.z, all failed. Something must be
|
// Tried names from .tmp.a to .tmp.z, all failed. Something must be
|
||||||
// wrong then.
|
// wrong then.
|
||||||
|
EMSG2(_("E138: All %s.tmp.X files exist, cannot write ShaDa file!"),
|
||||||
|
fname);
|
||||||
xfree(fname);
|
xfree(fname);
|
||||||
xfree(tempname);
|
xfree(tempname);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -1772,7 +1778,7 @@ shada_write_file_nomerge:
|
|||||||
|
|
||||||
if (p_verbose > 0) {
|
if (p_verbose > 0) {
|
||||||
verbose_enter();
|
verbose_enter();
|
||||||
smsg(_("Writing viminfo file \"%s\""), fname);
|
smsg(_("Writing ShaDa file \"%s\""), fname);
|
||||||
verbose_leave();
|
verbose_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1793,7 +1799,7 @@ shada_write_file_nomerge:
|
|||||||
if (!nomerge) {
|
if (!nomerge) {
|
||||||
close_file((int)(intptr_t) sd_reader.cookie);
|
close_file((int)(intptr_t) sd_reader.cookie);
|
||||||
if (vim_rename(tempname, fname) == -1) {
|
if (vim_rename(tempname, fname) == -1) {
|
||||||
EMSG3(_("E886: Can't rename viminfo file from %s to %s!"),
|
EMSG3(_("E886: Can't rename ShaDa file from %s to %s!"),
|
||||||
tempname, fname);
|
tempname, fname);
|
||||||
} else {
|
} else {
|
||||||
os_remove(tempname);
|
os_remove(tempname);
|
||||||
@@ -3021,7 +3027,7 @@ bool shada_removable(const char *name)
|
|||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
char *new_name = home_replace_save(NULL, name);
|
char *new_name = home_replace_save(NULL, name);
|
||||||
for (p = (char *) p_viminfo; *p; ) {
|
for (p = (char *) p_shada; *p; ) {
|
||||||
(void) copy_option_part(&p, part, 51, ", ");
|
(void) copy_option_part(&p, part, 51, ", ");
|
||||||
if (part[0] == 'r') {
|
if (part[0] == 'r') {
|
||||||
n = STRLEN(part + 1);
|
n = STRLEN(part + 1);
|
||||||
|
@@ -4,7 +4,7 @@ local clear, execute, eq, neq, spawn, nvim_prog, set_session, wait, write_file
|
|||||||
helpers.nvim_prog, helpers.set_session, helpers.wait, helpers.write_file
|
helpers.nvim_prog, helpers.set_session, helpers.wait, helpers.write_file
|
||||||
|
|
||||||
describe(':wviminfo', function()
|
describe(':wviminfo', function()
|
||||||
local viminfo_file = 'wviminfo_test'
|
local shada_file = 'wviminfo_test'
|
||||||
local session
|
local session
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
@@ -17,38 +17,41 @@ describe(':wviminfo', function()
|
|||||||
'--cmd', 'set swapfile'})
|
'--cmd', 'set swapfile'})
|
||||||
set_session(session)
|
set_session(session)
|
||||||
|
|
||||||
os.remove(viminfo_file)
|
os.remove(shada_file)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('creates a viminfo file', function()
|
it('creates a shada file', function()
|
||||||
-- file should _not_ exist
|
-- file should _not_ exist
|
||||||
eq(nil, lfs.attributes(viminfo_file))
|
eq(nil, lfs.attributes(shada_file))
|
||||||
execute('wv! '..viminfo_file)
|
execute('wv! '..shada_file)
|
||||||
wait()
|
wait()
|
||||||
-- file _should_ exist
|
-- file _should_ exist
|
||||||
neq(nil, lfs.attributes(viminfo_file))
|
neq(nil, lfs.attributes(shada_file))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('overwrites existing files', function()
|
it('overwrites existing files', function()
|
||||||
local text = 'wviminfo test'
|
local text = 'wviminfo test'
|
||||||
|
|
||||||
-- Create a dummy file
|
-- Create a dummy file
|
||||||
write_file(viminfo_file, text)
|
write_file(shada_file, text)
|
||||||
|
|
||||||
-- sanity check
|
-- sanity check
|
||||||
eq(text, io.open(viminfo_file):read())
|
eq(text, io.open(shada_file):read())
|
||||||
neq(nil, lfs.attributes(viminfo_file))
|
neq(nil, lfs.attributes(shada_file))
|
||||||
|
|
||||||
execute('wv! '..viminfo_file)
|
execute('wv! '..shada_file)
|
||||||
wait()
|
wait()
|
||||||
|
|
||||||
-- File should have been overwritten with a viminfo file.
|
-- File should have been overwritten with a shada file.
|
||||||
local line1 = io.lines(viminfo_file)()
|
local fp = io.open(shada_file, 'r')
|
||||||
assert(nil ~= string.find(line1, 'This viminfo file was generated by Nvim'),
|
local char1 = fp:read(1)
|
||||||
viminfo_file..' should be a viminfo-formatted file')
|
fp:close()
|
||||||
|
-- ShaDa file starts with a “header” entry
|
||||||
|
assert(char1:byte() == 0x01,
|
||||||
|
shada_file..' should be a shada file')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
teardown(function()
|
teardown(function()
|
||||||
os.remove(viminfo_file)
|
os.remove(shada_file)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@@ -1,14 +1,15 @@
|
|||||||
-- Tests for storing global variables in the .viminfo file
|
-- Tests for storing global variables in the .shada file
|
||||||
|
|
||||||
local helpers, lfs = require('test.functional.helpers'), require('lfs')
|
local helpers, lfs = require('test.functional.helpers'), require('lfs')
|
||||||
local clear, execute, eq, neq, eval, wait, spawn =
|
local clear, execute, eq, neq, eval, wait, spawn =
|
||||||
helpers.clear, helpers.execute, helpers.eq, helpers.neq, helpers.eval,
|
helpers.clear, helpers.execute, helpers.eq, helpers.neq, helpers.eval,
|
||||||
helpers.wait, helpers.spawn
|
helpers.wait, helpers.spawn
|
||||||
|
|
||||||
describe('storing global variables in viminfo files', function()
|
describe('storing global variables in ShaDa files', function()
|
||||||
|
local tempname = 'Xtest-functional-legacy-074'
|
||||||
setup(function()
|
setup(function()
|
||||||
clear()
|
clear()
|
||||||
os.remove("Xviminfo")
|
os.remove(tempname)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('is working', function()
|
it('is working', function()
|
||||||
@@ -29,31 +30,32 @@ describe('storing global variables in viminfo files', function()
|
|||||||
'set visualbell',
|
'set visualbell',
|
||||||
'set viminfo+=!',
|
'set viminfo+=!',
|
||||||
"let MY_GLOBAL_DICT={'foo': 1, 'bar': 0, 'longvarible': 1000}",
|
"let MY_GLOBAL_DICT={'foo': 1, 'bar': 0, 'longvarible': 1000}",
|
||||||
-- Store a really long list, so line wrapping will occur in viminfo
|
-- Store a really long list. Initially this was testing line wrapping in
|
||||||
-- file.
|
-- viminfo, but shada files has no line wrapping, no matter how long the
|
||||||
|
-- list is.
|
||||||
'let MY_GLOBAL_LIST=range(1,100)'
|
'let MY_GLOBAL_LIST=range(1,100)'
|
||||||
)
|
)
|
||||||
eq(test_dict, eval('MY_GLOBAL_DICT'))
|
eq(test_dict, eval('MY_GLOBAL_DICT'))
|
||||||
eq(test_list, eval('MY_GLOBAL_LIST'))
|
eq(test_list, eval('MY_GLOBAL_LIST'))
|
||||||
|
|
||||||
execute('wv! Xviminfo')
|
execute('wv! ' .. tempname)
|
||||||
wait()
|
wait()
|
||||||
|
|
||||||
-- Assert that the viminfo file exists.
|
-- Assert that the shada file exists.
|
||||||
neq(nil, lfs.attributes('Xviminfo'))
|
neq(nil, lfs.attributes(tempname))
|
||||||
execute('unlet MY_GLOBAL_DICT',
|
execute('unlet MY_GLOBAL_DICT',
|
||||||
'unlet MY_GLOBAL_LIST')
|
'unlet MY_GLOBAL_LIST')
|
||||||
-- Assert that the variables where deleted.
|
-- Assert that the variables where deleted.
|
||||||
eq(0, eval('exists("MY_GLOBAL_DICT")'))
|
eq(0, eval('exists("MY_GLOBAL_DICT")'))
|
||||||
eq(0, eval('exists("MY_GLOBAL_LIST")'))
|
eq(0, eval('exists("MY_GLOBAL_LIST")'))
|
||||||
|
|
||||||
execute('rv! Xviminfo')
|
execute('rv! ' .. tempname)
|
||||||
|
|
||||||
eq(test_list, eval('MY_GLOBAL_LIST'))
|
eq(test_list, eval('MY_GLOBAL_LIST'))
|
||||||
eq(test_dict, eval('MY_GLOBAL_DICT'))
|
eq(test_dict, eval('MY_GLOBAL_DICT'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
teardown(function()
|
teardown(function()
|
||||||
os.remove('Xviminfo')
|
os.remove(tempname)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user