mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
Compare commits
10 Commits
0f308f1f0c
...
c080100fdb
Author | SHA1 | Date | |
---|---|---|---|
|
c080100fdb | ||
|
003b8a251d | ||
|
0cfbc6eaff | ||
|
95b65a7554 | ||
|
e37404f7fe | ||
|
b40ec083ae | ||
|
d338ec9cb2 | ||
|
5ddf2ab768 | ||
|
3d1110674e | ||
|
738a84de09 |
@ -1129,9 +1129,9 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
list:{n} Adds an additional indent for lines that match a
|
||||
numbered or bulleted list (using the
|
||||
'formatlistpat' setting).
|
||||
list:-1 Uses the length of a match with 'formatlistpat'
|
||||
for indentation.
|
||||
(default: 0)
|
||||
list:-1 Uses the width of a match with 'formatlistpat' for
|
||||
indentation.
|
||||
column:{n} Indent at column {n}. Will overrule the other
|
||||
sub-options. Note: an additional indent may be
|
||||
added for the 'showbreak' setting.
|
||||
|
@ -53,11 +53,17 @@ active yes yes 'a'
|
||||
hidden no yes 'h'
|
||||
inactive no no ' '
|
||||
|
||||
Note: All CTRL-W commands can also be executed with |:wincmd|, for those
|
||||
places where a Normal mode command can't be used or is inconvenient.
|
||||
*buffer-reuse*
|
||||
Each buffer has a unique number and the number will not change within a Vim
|
||||
session. The |bufnr()| and |bufname()| functions can be used to convert
|
||||
between a buffer name and the buffer number. There is one exception: if a new
|
||||
empty buffer is created and it is not modified, the buffer will be re-used
|
||||
when loading another file into that buffer. This also means the buffer number
|
||||
will not change.
|
||||
|
||||
The main Vim window can hold several split windows. There are also tab pages
|
||||
|tab-page|, each of which can hold multiple windows.
|
||||
|
||||
*window-ID* *winid* *windowid*
|
||||
Each window has a unique identifier called the window ID. This identifier
|
||||
will not change within a Vim session. The |win_getid()| and |win_id2tabwin()|
|
||||
@ -69,9 +75,6 @@ across tabs. For most functions that take a window ID or a window number, the
|
||||
window number only applies to the current tab, while the window ID can refer
|
||||
to a window in any tab.
|
||||
|
||||
Each buffer has a unique number and the number will not change within a Vim
|
||||
session. The |bufnr()| and |bufname()| functions can be used to convert
|
||||
between a buffer name and the buffer number.
|
||||
|
||||
==============================================================================
|
||||
2. Starting Vim *windows-starting*
|
||||
@ -468,6 +471,10 @@ These commands can also be executed with ":wincmd":
|
||||
:exe nr .. "wincmd w"
|
||||
< This goes to window "nr".
|
||||
|
||||
Note: All CTRL-W commands can also be executed with |:wincmd|, for those
|
||||
places where a Normal mode command can't be used or is inconvenient (e.g.
|
||||
in a browser-based terminal).
|
||||
|
||||
==============================================================================
|
||||
5. Moving windows around *window-moving*
|
||||
|
||||
|
@ -1293,9 +1293,25 @@ local function opt_to_global_state(opt, title)
|
||||
local fonts = {}
|
||||
if opt.font then
|
||||
fonts = type(opt.font) == 'string' and { opt.font } or opt.font --[[@as (string[])]]
|
||||
for i, v in pairs(fonts) do
|
||||
fonts[i] = ('"%s"'):format(v)
|
||||
end
|
||||
elseif vim.o.guifont:match('^[^:]+') then
|
||||
table.insert(fonts, vim.o.guifont:match('^[^:]+'))
|
||||
-- Example:
|
||||
-- Input: "Font,Escape\,comma, Ignore space after comma"
|
||||
-- Output: { "Font","Escape,comma","Ignore space after comma" }
|
||||
local prev = ''
|
||||
for name in vim.gsplit(vim.o.guifont:match('^[^:]+'), ',', { trimempty = true }) do
|
||||
if vim.endswith(name, '\\') then
|
||||
prev = prev .. vim.trim(name:sub(1, -2) .. ',')
|
||||
elseif vim.trim(name) ~= '' then
|
||||
table.insert(fonts, ('"%s%s"'):format(prev, vim.trim(name)))
|
||||
prev = ''
|
||||
end
|
||||
end
|
||||
end
|
||||
-- Generic family names (monospace here) must not be quoted
|
||||
-- because the browser recognizes them as font families.
|
||||
table.insert(fonts, 'monospace')
|
||||
--- @type vim.tohtml.state.global
|
||||
local state = {
|
||||
|
4
runtime/lua/vim/_meta/options.lua
generated
4
runtime/lua/vim/_meta/options.lua
generated
@ -558,9 +558,9 @@ vim.wo.bri = vim.wo.breakindent
|
||||
--- list:{n} Adds an additional indent for lines that match a
|
||||
--- numbered or bulleted list (using the
|
||||
--- 'formatlistpat' setting).
|
||||
--- list:-1 Uses the length of a match with 'formatlistpat'
|
||||
--- for indentation.
|
||||
--- (default: 0)
|
||||
--- list:-1 Uses the width of a match with 'formatlistpat' for
|
||||
--- indentation.
|
||||
--- column:{n} Indent at column {n}. Will overrule the other
|
||||
--- sub-options. Note: an additional indent may be
|
||||
--- added for the 'showbreak' setting.
|
||||
|
@ -77,12 +77,7 @@ function M.on_inlayhint(err, result, ctx, _)
|
||||
local col = position.character
|
||||
if col > 0 then
|
||||
local line = lines[position.line + 1] or ''
|
||||
local ok, convert_result
|
||||
ok, convert_result = pcall(util._str_byteindex_enc, line, col, client.offset_encoding)
|
||||
if ok then
|
||||
return convert_result
|
||||
end
|
||||
return math.min(#line, col)
|
||||
return util._str_byteindex_enc(line, col, client.offset_encoding)
|
||||
end
|
||||
return col
|
||||
end
|
||||
|
@ -140,12 +140,7 @@ local function tokens_to_ranges(data, bufnr, client, request)
|
||||
local function _get_byte_pos(col)
|
||||
if col > 0 then
|
||||
local buf_line = lines[line + 1] or ''
|
||||
local ok, result
|
||||
ok, result = pcall(util._str_byteindex_enc, buf_line, col, client.offset_encoding)
|
||||
if ok then
|
||||
return result
|
||||
end
|
||||
return math.min(#buf_line, col)
|
||||
return util._str_byteindex_enc(buf_line, col, client.offset_encoding)
|
||||
end
|
||||
return col
|
||||
end
|
||||
|
@ -147,6 +147,12 @@ end
|
||||
---@param encoding string utf-8|utf-16|utf-32| defaults to utf-16
|
||||
---@return integer byte (utf-8) index of `encoding` index `index` in `line`
|
||||
function M._str_byteindex_enc(line, index, encoding)
|
||||
local len = vim.fn.strlen(line)
|
||||
if index > len then
|
||||
-- LSP spec: if character > line length, default to the line length.
|
||||
-- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position
|
||||
return len
|
||||
end
|
||||
if not encoding then
|
||||
encoding = 'utf-16'
|
||||
end
|
||||
@ -166,7 +172,6 @@ function M._str_byteindex_enc(line, index, encoding)
|
||||
end
|
||||
|
||||
local _str_utfindex_enc = M._str_utfindex_enc
|
||||
local _str_byteindex_enc = M._str_byteindex_enc
|
||||
|
||||
--- Replaces text in a range with new text.
|
||||
---
|
||||
@ -334,12 +339,7 @@ local function get_line_byte_from_position(bufnr, position, offset_encoding)
|
||||
-- character
|
||||
if col > 0 then
|
||||
local line = get_line(bufnr, position.line) or ''
|
||||
local ok, result
|
||||
ok, result = pcall(_str_byteindex_enc, line, col, offset_encoding)
|
||||
if ok then
|
||||
return result
|
||||
end
|
||||
return math.min(#line, col)
|
||||
return M._str_byteindex_enc(line, col, offset_encoding or 'utf-16')
|
||||
end
|
||||
return col
|
||||
end
|
||||
@ -436,14 +436,15 @@ function M.apply_text_edits(text_edits, bufnr, offset_encoding)
|
||||
e.end_col = last_line_len
|
||||
has_eol_text_edit = true
|
||||
else
|
||||
-- If the replacement is over the end of a line (i.e. e.end_col is out of bounds and the
|
||||
-- If the replacement is over the end of a line (i.e. e.end_col is equal to the line length and the
|
||||
-- replacement text ends with a newline We can likely assume that the replacement is assumed
|
||||
-- to be meant to replace the newline with another newline and we need to make sure this
|
||||
-- doesn't add an extra empty line. E.g. when the last line to be replaced contains a '\r'
|
||||
-- in the file some servers (clangd on windows) will include that character in the line
|
||||
-- while nvim_buf_set_text doesn't count it as part of the line.
|
||||
if
|
||||
e.end_col > last_line_len
|
||||
e.end_col >= last_line_len
|
||||
and text_edit.range['end'].character > e.end_col
|
||||
and #text_edit.newText > 0
|
||||
and string.sub(text_edit.newText, -1) == '\n'
|
||||
then
|
||||
@ -1795,17 +1796,9 @@ function M.locations_to_items(locations, offset_encoding)
|
||||
local row = pos.line
|
||||
local end_row = end_pos.line
|
||||
local line = lines[row] or ''
|
||||
local line_len = vim.fn.strcharlen(line)
|
||||
local end_line = lines[end_row] or ''
|
||||
local end_line_len = vim.fn.strcharlen(end_line)
|
||||
-- LSP spec: if character > line length, default to the line length.
|
||||
-- https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position
|
||||
local col = pos.character <= line_len
|
||||
and M._str_byteindex_enc(line, pos.character, offset_encoding)
|
||||
or line_len
|
||||
local end_col = end_pos.character <= end_line_len
|
||||
and M._str_byteindex_enc(end_line, end_pos.character, offset_encoding)
|
||||
or end_line_len
|
||||
local col = M._str_byteindex_enc(line, pos.character, offset_encoding)
|
||||
local end_col = M._str_byteindex_enc(end_line, end_pos.character, offset_encoding)
|
||||
|
||||
table.insert(items, {
|
||||
filename = filename,
|
||||
|
@ -152,14 +152,14 @@ function M.open(path)
|
||||
else
|
||||
return nil, 'vim.ui.open: rundll32 not found'
|
||||
end
|
||||
elseif vim.fn.executable('wslview') == 1 then
|
||||
cmd = { 'wslview', path }
|
||||
elseif vim.fn.executable('explorer.exe') == 1 then
|
||||
cmd = { 'explorer.exe', path }
|
||||
elseif vim.fn.executable('xdg-open') == 1 then
|
||||
cmd = { 'xdg-open', path }
|
||||
opts.stdout = false
|
||||
opts.stderr = false
|
||||
elseif vim.fn.executable('wslview') == 1 then
|
||||
cmd = { 'wslview', path }
|
||||
elseif vim.fn.executable('explorer.exe') == 1 then
|
||||
cmd = { 'explorer.exe', path }
|
||||
else
|
||||
return nil, 'vim.ui.open: no handler found (tried: wslview, explorer.exe, xdg-open)'
|
||||
end
|
||||
|
@ -891,7 +891,17 @@ int get_breakindent_win(win_T *wp, char *line)
|
||||
if (wp->w_briopt_list > 0) {
|
||||
prev_list += wp->w_briopt_list;
|
||||
} else {
|
||||
prev_indent = (int)(*regmatch.endp - *regmatch.startp);
|
||||
char *ptr = *regmatch.startp;
|
||||
char *end_ptr = *regmatch.endp;
|
||||
int indent = 0;
|
||||
// Compute the width of the matched text.
|
||||
// Use win_chartabsize() so that TAB size is correct,
|
||||
// while wrapping is ignored.
|
||||
while (ptr < end_ptr) {
|
||||
indent += win_chartabsize(wp, ptr, indent);
|
||||
MB_PTR_ADV(ptr);
|
||||
}
|
||||
prev_indent = indent;
|
||||
}
|
||||
}
|
||||
vim_regfree(regmatch.regprog);
|
||||
|
@ -266,7 +266,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if (argc > 1 && STRICMP(argv[1], "-ll") == 0) {
|
||||
if (argc == 2) {
|
||||
print_mainerr(err_arg_missing, argv[1]);
|
||||
print_mainerr(err_arg_missing, argv[1], NULL);
|
||||
exit(1);
|
||||
}
|
||||
nlua_run_script(argv, argc, 3);
|
||||
@ -357,10 +357,8 @@ int main(int argc, char **argv)
|
||||
assert(!ui_client_channel_id && !use_builtin_ui);
|
||||
// Nvim server...
|
||||
|
||||
int listen_rv = server_init(params.listen_addr);
|
||||
if (listen_rv != 0) {
|
||||
mainerr("Failed to --listen", listen_rv < 0
|
||||
? os_strerror(listen_rv) : (listen_rv == 1 ? "empty address" : NULL));
|
||||
if (!server_init(params.listen_addr)) {
|
||||
mainerr(IObuff, NULL, NULL);
|
||||
}
|
||||
|
||||
TIME_MSG("expanding arguments");
|
||||
@ -1053,7 +1051,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
// "+" or "+{number}" or "+/{pat}" or "+{command}" argument.
|
||||
if (argv[0][0] == '+' && !had_minmin) {
|
||||
if (parmp->n_commands >= MAX_ARG_CMDS) {
|
||||
mainerr(err_extra_cmd, NULL);
|
||||
mainerr(err_extra_cmd, NULL, NULL);
|
||||
}
|
||||
argv_idx = -1; // skip to next argument
|
||||
if (argv[0][1] == NUL) {
|
||||
@ -1074,7 +1072,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
parmp->no_swap_file = true;
|
||||
} else {
|
||||
if (parmp->edit_type > EDIT_STDIN) {
|
||||
mainerr(err_too_many_args, argv[0]);
|
||||
mainerr(err_too_many_args, argv[0], NULL);
|
||||
}
|
||||
parmp->had_stdin_file = true;
|
||||
parmp->edit_type = EDIT_STDIN;
|
||||
@ -1137,7 +1135,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
nlua_disable_preload = true;
|
||||
} else {
|
||||
if (argv[0][argv_idx]) {
|
||||
mainerr(err_opt_unknown, argv[0]);
|
||||
mainerr(err_opt_unknown, argv[0], NULL);
|
||||
}
|
||||
had_minmin = true;
|
||||
}
|
||||
@ -1211,7 +1209,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
break;
|
||||
case 'q': // "-q" QuickFix mode
|
||||
if (parmp->edit_type != EDIT_NONE) {
|
||||
mainerr(err_too_many_args, argv[0]);
|
||||
mainerr(err_too_many_args, argv[0], NULL);
|
||||
}
|
||||
parmp->edit_type = EDIT_QF;
|
||||
if (argv[0][argv_idx]) { // "-q{errorfile}"
|
||||
@ -1240,7 +1238,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
break;
|
||||
case 't': // "-t {tag}" or "-t{tag}" jump to tag
|
||||
if (parmp->edit_type != EDIT_NONE) {
|
||||
mainerr(err_too_many_args, argv[0]);
|
||||
mainerr(err_too_many_args, argv[0], NULL);
|
||||
}
|
||||
parmp->edit_type = EDIT_TAG;
|
||||
if (argv[0][argv_idx]) { // "-t{tag}"
|
||||
@ -1274,7 +1272,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
case 'c': // "-c{command}" or "-c {command}" exec command
|
||||
if (argv[0][argv_idx] != NUL) {
|
||||
if (parmp->n_commands >= MAX_ARG_CMDS) {
|
||||
mainerr(err_extra_cmd, NULL);
|
||||
mainerr(err_extra_cmd, NULL, NULL);
|
||||
}
|
||||
parmp->commands[parmp->n_commands++] = argv[0] + argv_idx;
|
||||
argv_idx = -1;
|
||||
@ -1291,19 +1289,19 @@ static void command_line_scan(mparm_T *parmp)
|
||||
break;
|
||||
|
||||
default:
|
||||
mainerr(err_opt_unknown, argv[0]);
|
||||
mainerr(err_opt_unknown, argv[0], NULL);
|
||||
}
|
||||
|
||||
// Handle option arguments with argument.
|
||||
if (want_argument) {
|
||||
// Check for garbage immediately after the option letter.
|
||||
if (argv[0][argv_idx] != NUL) {
|
||||
mainerr(err_opt_garbage, argv[0]);
|
||||
mainerr(err_opt_garbage, argv[0], NULL);
|
||||
}
|
||||
|
||||
argc--;
|
||||
if (argc < 1 && c != 'S') { // -S has an optional argument
|
||||
mainerr(err_arg_missing, argv[0]);
|
||||
mainerr(err_arg_missing, argv[0], NULL);
|
||||
}
|
||||
argv++;
|
||||
argv_idx = -1;
|
||||
@ -1312,7 +1310,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
case 'c': // "-c {command}" execute command
|
||||
case 'S': // "-S {file}" execute Vim script
|
||||
if (parmp->n_commands >= MAX_ARG_CMDS) {
|
||||
mainerr(err_extra_cmd, NULL);
|
||||
mainerr(err_extra_cmd, NULL, NULL);
|
||||
}
|
||||
if (c == 'S') {
|
||||
char *a;
|
||||
@ -1343,7 +1341,7 @@ static void command_line_scan(mparm_T *parmp)
|
||||
if (strequal(argv[-1], "--cmd")) {
|
||||
// "--cmd {command}" execute command
|
||||
if (parmp->n_pre_commands >= MAX_ARG_CMDS) {
|
||||
mainerr(err_extra_cmd, NULL);
|
||||
mainerr(err_extra_cmd, NULL, NULL);
|
||||
}
|
||||
parmp->pre_commands[parmp->n_pre_commands++] = argv[0];
|
||||
} else if (strequal(argv[-1], "--listen")) {
|
||||
@ -1425,7 +1423,7 @@ scripterror:
|
||||
|
||||
// Check for only one type of editing.
|
||||
if (parmp->edit_type > EDIT_STDIN) {
|
||||
mainerr(err_too_many_args, argv[0]);
|
||||
mainerr(err_too_many_args, argv[0], NULL);
|
||||
}
|
||||
parmp->edit_type = EDIT_FILE;
|
||||
|
||||
@ -1472,7 +1470,7 @@ scripterror:
|
||||
}
|
||||
|
||||
if (embedded_mode && (silent_mode || parmp->luaf)) {
|
||||
mainerr(_("--embed conflicts with -es/-Es/-l"), NULL);
|
||||
mainerr(_("--embed conflicts with -es/-Es/-l"), NULL, NULL);
|
||||
}
|
||||
|
||||
// If there is a "+123" or "-c" command, set v:swapcommand to the first one.
|
||||
@ -2135,28 +2133,30 @@ static int execute_env(char *env)
|
||||
return OK;
|
||||
}
|
||||
|
||||
/// Prints the following then exits:
|
||||
/// - An error message `errstr`
|
||||
/// - A string `str` if not null
|
||||
/// Prints a message of the form "{msg1}: {msg2}: {msg3}", then exits with code 1.
|
||||
///
|
||||
/// @param errstr string containing an error message
|
||||
/// @param str string to append to the primary error message, or NULL
|
||||
static void mainerr(const char *errstr, const char *str)
|
||||
/// @param msg1 error message
|
||||
/// @param msg2 extra message, or NULL
|
||||
/// @param msg3 extra message, or NULL
|
||||
static void mainerr(const char *msg1, const char *msg2, const char *msg3)
|
||||
FUNC_ATTR_NORETURN
|
||||
{
|
||||
print_mainerr(errstr, str);
|
||||
print_mainerr(msg1, msg2, msg3);
|
||||
os_exit(1);
|
||||
}
|
||||
|
||||
static void print_mainerr(const char *errstr, const char *str)
|
||||
static void print_mainerr(const char *msg1, const char *msg2, const char *msg3)
|
||||
{
|
||||
char *prgname = path_tail(argv0);
|
||||
|
||||
signal_stop(); // kill us with CTRL-C here, if you like
|
||||
|
||||
fprintf(stderr, "%s: %s", prgname, _(errstr));
|
||||
if (str != NULL) {
|
||||
fprintf(stderr, ": \"%s\"", str);
|
||||
fprintf(stderr, "%s: %s", prgname, _(msg1));
|
||||
if (msg2 != NULL) {
|
||||
fprintf(stderr, ": \"%s\"", msg2);
|
||||
}
|
||||
if (msg3 != NULL) {
|
||||
fprintf(stderr, ": \"%s\"", msg3);
|
||||
}
|
||||
fprintf(stderr, _("\nMore info with \""));
|
||||
fprintf(stderr, "%s -h\"\n", prgname);
|
||||
|
@ -2925,17 +2925,17 @@ void f_setcellwidths(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
emsg(_(e_listreq));
|
||||
return;
|
||||
}
|
||||
|
||||
const list_T *const l = argvars[0].vval.v_list;
|
||||
if (tv_list_len(l) == 0) {
|
||||
cw_interval_T *table = NULL;
|
||||
const size_t table_size = (size_t)tv_list_len(l);
|
||||
if (table_size == 0) {
|
||||
// Clearing the table.
|
||||
xfree(cw_table);
|
||||
cw_table = NULL;
|
||||
cw_table_size = 0;
|
||||
goto done;
|
||||
goto update;
|
||||
}
|
||||
|
||||
// Note: use list_T instead of listitem_T so that TV_LIST_ITEM_NEXT can be used properly below.
|
||||
const list_T **ptrs = xmalloc(sizeof(const list_T *) * (size_t)tv_list_len(l));
|
||||
const list_T **ptrs = xmalloc(sizeof(const list_T *) * table_size);
|
||||
|
||||
// Check that all entries are a list with three numbers, the range is
|
||||
// valid and the cell width is valid.
|
||||
@ -2987,12 +2987,12 @@ void f_setcellwidths(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
});
|
||||
|
||||
// Sort the list on the first number.
|
||||
qsort((void *)ptrs, (size_t)tv_list_len(l), sizeof(const list_T *), tv_nr_compare);
|
||||
qsort((void *)ptrs, table_size, sizeof(const list_T *), tv_nr_compare);
|
||||
|
||||
cw_interval_T *table = xmalloc(sizeof(cw_interval_T) * (size_t)tv_list_len(l));
|
||||
table = xmalloc(sizeof(cw_interval_T) * table_size);
|
||||
|
||||
// Store the items in the new table.
|
||||
for (item = 0; item < tv_list_len(l); item++) {
|
||||
for (item = 0; (size_t)item < table_size; item++) {
|
||||
const list_T *const li_l = ptrs[item];
|
||||
const listitem_T *lili = tv_list_first(li_l);
|
||||
const varnumber_T n1 = TV_LIST_ITEM_TV(lili)->vval.v_number;
|
||||
@ -3011,10 +3011,12 @@ void f_setcellwidths(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
|
||||
xfree((void *)ptrs);
|
||||
|
||||
update:
|
||||
;
|
||||
cw_interval_T *const cw_table_save = cw_table;
|
||||
const size_t cw_table_size_save = cw_table_size;
|
||||
cw_table = table;
|
||||
cw_table_size = (size_t)tv_list_len(l);
|
||||
cw_table_size = table_size;
|
||||
|
||||
// Check that the new value does not conflict with 'listchars' or
|
||||
// 'fillchars'.
|
||||
@ -3028,7 +3030,6 @@ void f_setcellwidths(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
}
|
||||
|
||||
xfree(cw_table_save);
|
||||
done:
|
||||
changed_window_setting_all();
|
||||
redraw_all_later(UPD_NOT_VALID);
|
||||
}
|
||||
|
@ -11,12 +11,14 @@
|
||||
#include "nvim/event/socket.h"
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/garray_defs.h"
|
||||
#include "nvim/globals.h"
|
||||
#include "nvim/log.h"
|
||||
#include "nvim/main.h"
|
||||
#include "nvim/memory.h"
|
||||
#include "nvim/msgpack_rpc/server.h"
|
||||
#include "nvim/os/os.h"
|
||||
#include "nvim/os/stdpaths_defs.h"
|
||||
#include "nvim/types_defs.h"
|
||||
|
||||
#define MAX_CONNECTIONS 32
|
||||
#define ENV_LISTEN "NVIM_LISTEN_ADDRESS" // deprecated
|
||||
@ -27,20 +29,24 @@ static garray_T watchers = GA_EMPTY_INIT_VALUE;
|
||||
# include "msgpack_rpc/server.c.generated.h"
|
||||
#endif
|
||||
|
||||
/// Initializes the module
|
||||
/// Initializes resources, handles `--listen`, starts the primary server at v:servername.
|
||||
///
|
||||
/// @returns 0: success, 1: validation error, 2: already listening, -errno: failed to bind/listen.
|
||||
int server_init(const char *listen_addr)
|
||||
/// @returns true on success, false on fatal error (message stored in IObuff)
|
||||
bool server_init(const char *listen_addr)
|
||||
{
|
||||
bool ok = true;
|
||||
bool must_free = false;
|
||||
TriState user_arg = kTrue; // User-provided --listen arg.
|
||||
ga_init(&watchers, sizeof(SocketWatcher *), 1);
|
||||
|
||||
// $NVIM_LISTEN_ADDRESS (deprecated)
|
||||
if ((!listen_addr || listen_addr[0] == '\0') && os_env_exists(ENV_LISTEN)) {
|
||||
user_arg = kFalse; // User-provided env var.
|
||||
listen_addr = os_getenv(ENV_LISTEN);
|
||||
}
|
||||
|
||||
if (!listen_addr || listen_addr[0] == '\0') {
|
||||
user_arg = kNone; // Autogenerated server address.
|
||||
listen_addr = server_address_new(NULL);
|
||||
must_free = true;
|
||||
}
|
||||
@ -51,12 +57,6 @@ int server_init(const char *listen_addr)
|
||||
|
||||
int rv = server_start(listen_addr);
|
||||
|
||||
if (os_env_exists(ENV_LISTEN)) {
|
||||
// Unset $NVIM_LISTEN_ADDRESS, it's a liability hereafter. It is "input only", it must not be
|
||||
// leaked to child jobs or :terminal.
|
||||
os_unsetenv(ENV_LISTEN);
|
||||
}
|
||||
|
||||
// TODO(justinmk): this is for logging_spec. Can remove this after nvim_log #7062 is merged.
|
||||
if (os_env_exists("__NVIM_TEST_LOG")) {
|
||||
ELOG("test log message");
|
||||
@ -66,7 +66,28 @@ int server_init(const char *listen_addr)
|
||||
xfree((char *)listen_addr);
|
||||
}
|
||||
|
||||
return rv;
|
||||
if (rv == 0 || user_arg == kNone) {
|
||||
// The autogenerated servername can fail if the user has a broken $XDG_RUNTIME_DIR. #30282
|
||||
// But that is not fatal (startup will continue, logged in $NVIM_LOGFILE, empty v:servername).
|
||||
goto end;
|
||||
}
|
||||
|
||||
(void)snprintf(IObuff, IOSIZE,
|
||||
user_arg ==
|
||||
kTrue ? "Failed to --listen: %s: \"%s\""
|
||||
: "Failed $NVIM_LISTEN_ADDRESS: %s: \"%s\"",
|
||||
rv < 0 ? os_strerror(rv) : (rv == 1 ? "empty address" : "?"),
|
||||
listen_addr ? listen_addr : "(empty)");
|
||||
ok = false;
|
||||
|
||||
end:
|
||||
if (os_env_exists(ENV_LISTEN)) {
|
||||
// Unset $NVIM_LISTEN_ADDRESS, it's a liability hereafter. It is "input only", it must not be
|
||||
// leaked to child jobs or :terminal.
|
||||
os_unsetenv(ENV_LISTEN);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/// Teardown a single server
|
||||
|
@ -761,9 +761,9 @@ return {
|
||||
list:{n} Adds an additional indent for lines that match a
|
||||
numbered or bulleted list (using the
|
||||
'formatlistpat' setting).
|
||||
list:-1 Uses the length of a match with 'formatlistpat'
|
||||
for indentation.
|
||||
(default: 0)
|
||||
list:-1 Uses the width of a match with 'formatlistpat' for
|
||||
indentation.
|
||||
column:{n} Indent at column {n}. Will overrule the other
|
||||
sub-options. Note: an additional indent may be
|
||||
added for the 'showbreak' setting.
|
||||
|
@ -1079,34 +1079,21 @@ describe('lua stdlib', function()
|
||||
return vim.deep_equal(c, { sub = { [1] = 'a', b = 'a' } })
|
||||
]]))
|
||||
|
||||
matches(
|
||||
'invalid "behavior": nil',
|
||||
pcall_err(
|
||||
exec_lua,
|
||||
[[
|
||||
return vim.tbl_deep_extend()
|
||||
]]
|
||||
)
|
||||
)
|
||||
matches('invalid "behavior": nil', pcall_err(exec_lua, [[return vim.tbl_deep_extend()]]))
|
||||
|
||||
matches(
|
||||
'wrong number of arguments %(given 1, expected at least 3%)',
|
||||
pcall_err(
|
||||
exec_lua,
|
||||
[[
|
||||
return vim.tbl_deep_extend("keep")
|
||||
]]
|
||||
)
|
||||
pcall_err(exec_lua, [[return vim.tbl_deep_extend("keep")]])
|
||||
)
|
||||
|
||||
matches(
|
||||
'wrong number of arguments %(given 2, expected at least 3%)',
|
||||
pcall_err(
|
||||
exec_lua,
|
||||
[[
|
||||
return vim.tbl_deep_extend("keep", {})
|
||||
]]
|
||||
)
|
||||
pcall_err(exec_lua, [[return vim.tbl_deep_extend("keep", {})]])
|
||||
)
|
||||
|
||||
matches(
|
||||
'after the second argument%: expected table, got number',
|
||||
pcall_err(exec_lua, [[return vim.tbl_deep_extend("keep", {}, 42)]])
|
||||
)
|
||||
end)
|
||||
|
||||
|
@ -3607,21 +3607,21 @@ describe('LSP', function()
|
||||
range = {
|
||||
['end'] = {
|
||||
character = 8,
|
||||
line = 9,
|
||||
line = 3,
|
||||
},
|
||||
start = {
|
||||
character = 6,
|
||||
line = 9,
|
||||
line = 3,
|
||||
},
|
||||
},
|
||||
selectionRange = {
|
||||
['end'] = {
|
||||
character = 8,
|
||||
line = 9,
|
||||
line = 3,
|
||||
},
|
||||
start = {
|
||||
character = 6,
|
||||
line = 9,
|
||||
line = 3,
|
||||
},
|
||||
},
|
||||
uri = 'file:///home/jiangyinzuo/hello.cpp',
|
||||
@ -3651,21 +3651,21 @@ describe('LSP', function()
|
||||
range = {
|
||||
['end'] = {
|
||||
character = 8,
|
||||
line = 8,
|
||||
line = 2,
|
||||
},
|
||||
start = {
|
||||
character = 6,
|
||||
line = 8,
|
||||
line = 2,
|
||||
},
|
||||
},
|
||||
selectionRange = {
|
||||
['end'] = {
|
||||
character = 8,
|
||||
line = 8,
|
||||
line = 2,
|
||||
},
|
||||
start = {
|
||||
character = 6,
|
||||
line = 8,
|
||||
line = 2,
|
||||
},
|
||||
},
|
||||
uri = 'file:///home/jiangyinzuo/hello.cpp',
|
||||
@ -3679,7 +3679,15 @@ describe('LSP', function()
|
||||
})
|
||||
local client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd })
|
||||
local handler = require 'vim.lsp.handlers'['typeHierarchy/subtypes']
|
||||
handler(nil, clangd_response, { client_id = client_id, bufnr = 1 })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {
|
||||
'class B : public A{};',
|
||||
'class C : public B{};',
|
||||
'class D1 : public C{};',
|
||||
'class D2 : public C{};',
|
||||
'class E : public D1, D2 {};',
|
||||
})
|
||||
handler(nil, clangd_response, { client_id = client_id, bufnr = bufnr })
|
||||
return vim.fn.getqflist()
|
||||
end)
|
||||
|
||||
@ -3689,7 +3697,7 @@ describe('LSP', function()
|
||||
col = 7,
|
||||
end_col = 0,
|
||||
end_lnum = 0,
|
||||
lnum = 10,
|
||||
lnum = 4,
|
||||
module = '',
|
||||
nr = 0,
|
||||
pattern = '',
|
||||
@ -3703,7 +3711,7 @@ describe('LSP', function()
|
||||
col = 7,
|
||||
end_col = 0,
|
||||
end_lnum = 0,
|
||||
lnum = 9,
|
||||
lnum = 3,
|
||||
module = '',
|
||||
nr = 0,
|
||||
pattern = '',
|
||||
@ -3763,7 +3771,15 @@ describe('LSP', function()
|
||||
})
|
||||
local client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd })
|
||||
local handler = require 'vim.lsp.handlers'['typeHierarchy/subtypes']
|
||||
handler(nil, jdtls_response, { client_id = client_id, bufnr = 1 })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {
|
||||
'package mylist;',
|
||||
'',
|
||||
'public class MyList {',
|
||||
' static class Inner extends MyList{}',
|
||||
'~}',
|
||||
})
|
||||
handler(nil, jdtls_response, { client_id = client_id, bufnr = bufnr })
|
||||
return vim.fn.getqflist()
|
||||
end)
|
||||
|
||||
@ -3840,21 +3856,21 @@ describe('LSP', function()
|
||||
range = {
|
||||
['end'] = {
|
||||
character = 8,
|
||||
line = 9,
|
||||
line = 3,
|
||||
},
|
||||
start = {
|
||||
character = 6,
|
||||
line = 9,
|
||||
line = 3,
|
||||
},
|
||||
},
|
||||
selectionRange = {
|
||||
['end'] = {
|
||||
character = 8,
|
||||
line = 9,
|
||||
line = 3,
|
||||
},
|
||||
start = {
|
||||
character = 6,
|
||||
line = 9,
|
||||
line = 3,
|
||||
},
|
||||
},
|
||||
uri = 'file:///home/jiangyinzuo/hello.cpp',
|
||||
@ -3884,21 +3900,21 @@ describe('LSP', function()
|
||||
range = {
|
||||
['end'] = {
|
||||
character = 8,
|
||||
line = 8,
|
||||
line = 2,
|
||||
},
|
||||
start = {
|
||||
character = 6,
|
||||
line = 8,
|
||||
line = 2,
|
||||
},
|
||||
},
|
||||
selectionRange = {
|
||||
['end'] = {
|
||||
character = 8,
|
||||
line = 8,
|
||||
line = 2,
|
||||
},
|
||||
start = {
|
||||
character = 6,
|
||||
line = 8,
|
||||
line = 2,
|
||||
},
|
||||
},
|
||||
uri = 'file:///home/jiangyinzuo/hello.cpp',
|
||||
@ -3912,7 +3928,16 @@ describe('LSP', function()
|
||||
})
|
||||
local client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd })
|
||||
local handler = require 'vim.lsp.handlers'['typeHierarchy/supertypes']
|
||||
handler(nil, clangd_response, { client_id = client_id, bufnr = 1 })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {
|
||||
'class B : public A{};',
|
||||
'class C : public B{};',
|
||||
'class D1 : public C{};',
|
||||
'class D2 : public C{};',
|
||||
'class E : public D1, D2 {};',
|
||||
})
|
||||
|
||||
handler(nil, clangd_response, { client_id = client_id, bufnr = bufnr })
|
||||
return vim.fn.getqflist()
|
||||
end)
|
||||
|
||||
@ -3922,7 +3947,7 @@ describe('LSP', function()
|
||||
col = 7,
|
||||
end_col = 0,
|
||||
end_lnum = 0,
|
||||
lnum = 10,
|
||||
lnum = 4,
|
||||
module = '',
|
||||
nr = 0,
|
||||
pattern = '',
|
||||
@ -3936,7 +3961,7 @@ describe('LSP', function()
|
||||
col = 7,
|
||||
end_col = 0,
|
||||
end_lnum = 0,
|
||||
lnum = 9,
|
||||
lnum = 3,
|
||||
module = '',
|
||||
nr = 0,
|
||||
pattern = '',
|
||||
@ -3996,7 +4021,15 @@ describe('LSP', function()
|
||||
})
|
||||
local client_id = vim.lsp.start({ name = 'dummy', cmd = server.cmd })
|
||||
local handler = require 'vim.lsp.handlers'['typeHierarchy/supertypes']
|
||||
handler(nil, jdtls_response, { client_id = client_id, bufnr = 1 })
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {
|
||||
'package mylist;',
|
||||
'',
|
||||
'public class MyList {',
|
||||
' static class Inner extends MyList{}',
|
||||
'~}',
|
||||
})
|
||||
handler(nil, jdtls_response, { client_id = client_id, bufnr = bufnr })
|
||||
return vim.fn.getqflist()
|
||||
end)
|
||||
|
||||
|
@ -136,6 +136,50 @@ local function run_tohtml_and_assert(screen, func)
|
||||
screen:expect({ grid = expected.grid, attr_ids = expected.attr_ids })
|
||||
end
|
||||
|
||||
---@param guifont boolean
|
||||
local function test_generates_html(guifont, expect_font)
|
||||
insert([[line]])
|
||||
exec('set termguicolors')
|
||||
local bg = fn.synIDattr(fn.hlID('Normal'), 'bg#', 'gui')
|
||||
local fg = fn.synIDattr(fn.hlID('Normal'), 'fg#', 'gui')
|
||||
local tmpfile = t.tmpname()
|
||||
|
||||
exec_lua(
|
||||
[[
|
||||
local guifont, outfile = ...
|
||||
local html = (guifont
|
||||
and require('tohtml').tohtml(0,{title="title"})
|
||||
or require('tohtml').tohtml(0,{title="title",font={ "dumyfont","anotherfont" }}))
|
||||
vim.fn.writefile(html, outfile)
|
||||
vim.cmd.split(outfile)
|
||||
]],
|
||||
guifont,
|
||||
tmpfile
|
||||
)
|
||||
|
||||
local out_file = api.nvim_buf_get_name(api.nvim_get_current_buf())
|
||||
eq({
|
||||
'<!DOCTYPE html>',
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<meta charset="UTF-8">',
|
||||
'<title>title</title>',
|
||||
('<meta name="colorscheme" content="%s"></meta>'):format(api.nvim_get_var('colors_name')),
|
||||
'<style>',
|
||||
('* {font-family: %s,monospace}'):format(expect_font),
|
||||
('body {background-color: %s; color: %s}'):format(bg, fg),
|
||||
'</style>',
|
||||
'</head>',
|
||||
'<body style="display: flex">',
|
||||
'<pre>',
|
||||
'line',
|
||||
'',
|
||||
'</pre>',
|
||||
'</body>',
|
||||
'</html>',
|
||||
}, fn.readfile(out_file))
|
||||
end
|
||||
|
||||
describe(':TOhtml', function()
|
||||
--- @type test.functional.ui.screen
|
||||
local screen
|
||||
@ -146,41 +190,16 @@ describe(':TOhtml', function()
|
||||
exec('colorscheme default')
|
||||
end)
|
||||
|
||||
it('expected internal html generated', function()
|
||||
insert([[line]])
|
||||
exec('set termguicolors')
|
||||
local bg = fn.synIDattr(fn.hlID('Normal'), 'bg#', 'gui')
|
||||
local fg = fn.synIDattr(fn.hlID('Normal'), 'fg#', 'gui')
|
||||
exec_lua [[
|
||||
local outfile = vim.fn.tempname() .. '.html'
|
||||
local html = require('tohtml').tohtml(0,{title="title",font="dumyfont"})
|
||||
vim.fn.writefile(html, outfile)
|
||||
vim.cmd.split(outfile)
|
||||
]]
|
||||
local out_file = api.nvim_buf_get_name(api.nvim_get_current_buf())
|
||||
eq({
|
||||
'<!DOCTYPE html>',
|
||||
'<html>',
|
||||
'<head>',
|
||||
'<meta charset="UTF-8">',
|
||||
'<title>title</title>',
|
||||
('<meta name="colorscheme" content="%s"></meta>'):format(api.nvim_get_var('colors_name')),
|
||||
'<style>',
|
||||
'* {font-family: dumyfont,monospace}',
|
||||
('body {background-color: %s; color: %s}'):format(bg, fg),
|
||||
'</style>',
|
||||
'</head>',
|
||||
'<body style="display: flex">',
|
||||
'<pre>',
|
||||
'line',
|
||||
'',
|
||||
'</pre>',
|
||||
'</body>',
|
||||
'</html>',
|
||||
}, fn.readfile(out_file))
|
||||
it('generates html with given font', function()
|
||||
test_generates_html(false, '"dumyfont","anotherfont"')
|
||||
end)
|
||||
|
||||
it('expected internal html generated from range', function()
|
||||
it("generates html, respects 'guifont'", function()
|
||||
exec_lua [[vim.o.guifont='Font,Escape\\,comma, Ignore space after comma']]
|
||||
test_generates_html(true, '"Font","Escape,comma","Ignore space after comma"')
|
||||
end)
|
||||
|
||||
it('generates html from range', function()
|
||||
insert([[
|
||||
line1
|
||||
line2
|
||||
@ -218,7 +237,7 @@ describe(':TOhtml', function()
|
||||
}, fn.readfile(out_file))
|
||||
end)
|
||||
|
||||
it('highlight attributes generated', function()
|
||||
it('generates highlight attributes', function()
|
||||
--Make sure to uncomment the attribute in `html_syntax_match()`
|
||||
exec('hi LINE guisp=#00ff00 gui=' .. table.concat({
|
||||
'bold',
|
||||
|
@ -41,6 +41,21 @@ describe('server', function()
|
||||
end
|
||||
end)
|
||||
|
||||
it('broken $XDG_RUNTIME_DIR is not fatal #30282', function()
|
||||
clear {
|
||||
args_rm = { '--listen' },
|
||||
env = { NVIM_LOG_FILE = testlog, XDG_RUNTIME_DIR = '/non-existent-dir/subdir//' },
|
||||
}
|
||||
|
||||
if is_os('win') then
|
||||
-- Windows pipes have a special namespace and thus aren't decided by $XDG_RUNTIME_DIR.
|
||||
matches('nvim', api.nvim_get_vvar('servername'))
|
||||
else
|
||||
eq('', api.nvim_get_vvar('servername'))
|
||||
t.assert_log('Failed to start server%: no such file or directory', testlog, 100)
|
||||
end
|
||||
end)
|
||||
|
||||
it('serverstart(), serverstop() does not set $NVIM', function()
|
||||
clear()
|
||||
local s = eval('serverstart()')
|
||||
@ -175,56 +190,79 @@ describe('server', function()
|
||||
end)
|
||||
|
||||
describe('startup --listen', function()
|
||||
-- Tests Nvim output when failing to start, with and without "--headless".
|
||||
-- TODO(justinmk): clear() should have a way to get stdout if Nvim fails to start.
|
||||
local function _test(args, env, expected)
|
||||
local function run(cmd)
|
||||
return n.exec_lua(function(cmd_, env_)
|
||||
return vim
|
||||
.system(cmd_, {
|
||||
text = true,
|
||||
env = vim.tbl_extend(
|
||||
'force',
|
||||
-- Avoid noise in the logs; we expect failures for these tests.
|
||||
{ NVIM_LOG_FILE = testlog },
|
||||
env_ or {}
|
||||
),
|
||||
})
|
||||
:wait()
|
||||
end, cmd, env) --[[@as vim.SystemCompleted]]
|
||||
end
|
||||
|
||||
local cmd = vim.list_extend({ n.nvim_prog, '+qall!', '--headless' }, args)
|
||||
local r = run(cmd)
|
||||
eq(1, r.code)
|
||||
matches(expected, (r.stderr .. r.stdout):gsub('\\n', ' '))
|
||||
|
||||
if is_os('win') then
|
||||
return -- On Windows, output without --headless is garbage.
|
||||
end
|
||||
table.remove(cmd, 3) -- Remove '--headless'.
|
||||
assert(not vim.tbl_contains(cmd, '--headless'))
|
||||
r = run(cmd)
|
||||
eq(1, r.code)
|
||||
matches(expected, (r.stderr .. r.stdout):gsub('\\n', ' '))
|
||||
end
|
||||
|
||||
it('validates', function()
|
||||
clear { env = { NVIM_LOG_FILE = testlog } }
|
||||
|
||||
-- Tests args with and without "--headless".
|
||||
local function _test(args, expected)
|
||||
local function run(cmd)
|
||||
return n.exec_lua(function(cmd_)
|
||||
return vim
|
||||
.system(cmd_, {
|
||||
text = true,
|
||||
env = {
|
||||
-- Avoid noise in the logs; we expect failures for these tests.
|
||||
NVIM_LOG_FILE = testlog,
|
||||
},
|
||||
})
|
||||
:wait()
|
||||
end, cmd) --[[@as vim.SystemCompleted]]
|
||||
end
|
||||
|
||||
local cmd = vim.list_extend({ n.nvim_prog, '+qall!', '--headless' }, args)
|
||||
local r = run(cmd)
|
||||
eq(1, r.code)
|
||||
matches(expected, (r.stderr .. r.stdout):gsub('\\n', ' '))
|
||||
|
||||
if is_os('win') then
|
||||
return -- On Windows, output without --headless is garbage.
|
||||
end
|
||||
table.remove(cmd, 3) -- Remove '--headless'.
|
||||
assert(not vim.tbl_contains(cmd, '--headless'))
|
||||
r = run(cmd)
|
||||
eq(1, r.code)
|
||||
matches(expected, (r.stderr .. r.stdout):gsub('\\n', ' '))
|
||||
end
|
||||
local in_use = n.eval('v:servername') ---@type string Address already used by another server.
|
||||
|
||||
t.assert_nolog('Failed to start server', testlog, 100)
|
||||
t.assert_nolog('Host lookup failed', testlog, 100)
|
||||
|
||||
_test({ '--listen' }, 'nvim.*: Argument missing after: "%-%-listen"')
|
||||
_test({ '--listen2' }, 'nvim.*: Garbage after option argument: "%-%-listen2"')
|
||||
_test({ '--listen', n.eval('v:servername') }, 'nvim.*: Failed to %-%-listen: ".* already .*"')
|
||||
_test({ '--listen', '/' }, 'nvim.*: Failed to %-%-listen: ".*"')
|
||||
_test({ '--listen' }, nil, 'nvim.*: Argument missing after: "%-%-listen"')
|
||||
_test({ '--listen2' }, nil, 'nvim.*: Garbage after option argument: "%-%-listen2"')
|
||||
_test(
|
||||
{ '--listen', in_use },
|
||||
nil,
|
||||
('nvim.*: Failed to %%-%%-listen: [^:]+ already [^:]+: "%s"'):format(vim.pesc(in_use))
|
||||
)
|
||||
_test({ '--listen', '/' }, nil, 'nvim.*: Failed to %-%-listen: [^:]+: "/"')
|
||||
_test(
|
||||
{ '--listen', 'https://example.com' },
|
||||
('nvim.*: Failed to %%-%%-listen: "%s"'):format(
|
||||
nil,
|
||||
('nvim.*: Failed to %%-%%-listen: %s: "https://example.com"'):format(
|
||||
is_os('mac') and 'unknown node or service' or 'service not available for socket type'
|
||||
)
|
||||
)
|
||||
|
||||
t.assert_log('Failed to start server', testlog, 100)
|
||||
t.assert_log('Host lookup failed', testlog, 100)
|
||||
|
||||
_test(
|
||||
{},
|
||||
{ NVIM_LISTEN_ADDRESS = in_use },
|
||||
('nvim.*: Failed $NVIM_LISTEN_ADDRESS: [^:]+ already [^:]+: "%s"'):format(vim.pesc(in_use))
|
||||
)
|
||||
_test({}, { NVIM_LISTEN_ADDRESS = '/' }, 'nvim.*: Failed $NVIM_LISTEN_ADDRESS: [^:]+: "/"')
|
||||
_test(
|
||||
{},
|
||||
{ NVIM_LISTEN_ADDRESS = 'https://example.com' },
|
||||
('nvim.*: Failed $NVIM_LISTEN_ADDRESS: %s: "https://example.com"'):format(
|
||||
is_os('mac') and 'unknown node or service' or 'service not available for socket type'
|
||||
)
|
||||
)
|
||||
end)
|
||||
|
||||
it('sets v:servername, overrides $NVIM_LISTEN_ADDRESS', function()
|
||||
|
@ -837,18 +837,73 @@ func Test_breakindent20_list()
|
||||
\ ]
|
||||
let lines = s:screen_lines2(1, 9, 20)
|
||||
call s:compare_lines(expect, lines)
|
||||
|
||||
" check with TABs
|
||||
call setline(1, ["\t1.\tCongress shall make no law",
|
||||
\ "\t2.) Congress shall make no law",
|
||||
\ "\t3.] Congress shall make no law"])
|
||||
setl tabstop=4 list listchars=tab:<->
|
||||
norm! 1gg
|
||||
redraw!
|
||||
let expect = [
|
||||
\ "<-->1.<>Congress ",
|
||||
\ " shall make ",
|
||||
\ " no law ",
|
||||
\ "<-->2.) Congress ",
|
||||
\ " shall make ",
|
||||
\ " no law ",
|
||||
\ "<-->3.] Congress ",
|
||||
\ " shall make ",
|
||||
\ " no law ",
|
||||
\ ]
|
||||
let lines = s:screen_lines2(1, 9, 20)
|
||||
call s:compare_lines(expect, lines)
|
||||
|
||||
setl tabstop=2 nolist
|
||||
redraw!
|
||||
let expect = [
|
||||
\ " 1. Congress ",
|
||||
\ " shall make no ",
|
||||
\ " law ",
|
||||
\ " 2.) Congress ",
|
||||
\ " shall make no ",
|
||||
\ " law ",
|
||||
\ " 3.] Congress ",
|
||||
\ " shall make no ",
|
||||
\ " law ",
|
||||
\ ]
|
||||
let lines = s:screen_lines2(1, 9, 20)
|
||||
call s:compare_lines(expect, lines)
|
||||
|
||||
setl tabstop& list listchars=space:_
|
||||
redraw!
|
||||
let expect = [
|
||||
\ "^I1.^ICongress_ ",
|
||||
\ " shall_make_no_",
|
||||
\ " law ",
|
||||
\ "^I2.)_Congress_ ",
|
||||
\ " shall_make_no_",
|
||||
\ " law ",
|
||||
\ "^I3.]_Congress_ ",
|
||||
\ " shall_make_no_",
|
||||
\ " law ",
|
||||
\ ]
|
||||
let lines = s:screen_lines2(1, 9, 20)
|
||||
call s:compare_lines(expect, lines)
|
||||
|
||||
" check formatlistpat indent with different list levels
|
||||
let &l:flp = '^\s*\*\+\s\+'
|
||||
let &l:flp = '^\s*\(\*\|•\)\+\s\+'
|
||||
setl list&vim listchars&vim
|
||||
%delete _
|
||||
call setline(1, ['* Congress shall make no law',
|
||||
\ '*** Congress shall make no law',
|
||||
\ '••• Congress shall make no law',
|
||||
\ '**** Congress shall make no law'])
|
||||
norm! 1gg
|
||||
redraw!
|
||||
let expect = [
|
||||
\ "* Congress shall ",
|
||||
\ " make no law ",
|
||||
\ "*** Congress shall ",
|
||||
\ "••• Congress shall ",
|
||||
\ " make no law ",
|
||||
\ "**** Congress shall ",
|
||||
\ " make no law ",
|
||||
@ -864,7 +919,7 @@ func Test_breakindent20_list()
|
||||
let expect = [
|
||||
\ "* Congress shall ",
|
||||
\ "> make no law ",
|
||||
\ "*** Congress shall ",
|
||||
\ "••• Congress shall ",
|
||||
\ "> make no law ",
|
||||
\ "**** Congress shall ",
|
||||
\ "> make no law ",
|
||||
@ -880,7 +935,7 @@ func Test_breakindent20_list()
|
||||
let expect = [
|
||||
\ "* Congress shall ",
|
||||
\ "> make no law ",
|
||||
\ "*** Congress shall ",
|
||||
\ "••• Congress shall ",
|
||||
\ "> make no law ",
|
||||
\ "**** Congress shall ",
|
||||
\ "> make no law ",
|
||||
|
@ -255,15 +255,21 @@ func Test_setcellwidths()
|
||||
|
||||
call assert_fails('call setcellwidths([[0x33, 0x44, 2]])', 'E1114:')
|
||||
|
||||
set listchars=tab:--\\u2192
|
||||
set listchars=tab:--\\u2192 fillchars=stl:\\u2501
|
||||
call assert_fails('call setcellwidths([[0x2192, 0x2192, 2]])', 'E834:')
|
||||
|
||||
set fillchars=stl:\\u2501
|
||||
call assert_fails('call setcellwidths([[0x2501, 0x2501, 2]])', 'E835:')
|
||||
|
||||
call setcellwidths([[0x201c, 0x201d, 1]])
|
||||
set listchars& fillchars& ambiwidth=double
|
||||
|
||||
set listchars=nbsp:\\u201c fillchars=vert:\\u201d
|
||||
call assert_fails('call setcellwidths([])', 'E834:')
|
||||
set listchars&
|
||||
call assert_fails('call setcellwidths([])', 'E835:')
|
||||
set fillchars&
|
||||
|
||||
call setcellwidths([])
|
||||
set ambiwidth&
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user