aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/doc/indent.txt17
-rw-r--r--src/nvim/CMakeLists.txt1
-rw-r--r--src/nvim/api/ui.c4
-rw-r--r--src/nvim/buffer_defs.h1
-rw-r--r--src/nvim/eval.c3
-rw-r--r--src/nvim/event/loop.c3
-rw-r--r--src/nvim/indent_c.c62
-rw-r--r--src/nvim/macros.h2
-rw-r--r--src/nvim/testdir/test_cindent.vim60
-rw-r--r--src/nvim/tui/tui.c21
-rw-r--r--src/nvim/ui.c10
-rw-r--r--src/nvim/ui_bridge.c3
-rw-r--r--test/functional/eval/system_spec.lua3
-rw-r--r--test/functional/normal/langmap_spec.lua280
-rw-r--r--third-party/cmake/BuildLuarocks.cmake6
15 files changed, 450 insertions, 26 deletions
diff --git a/runtime/doc/indent.txt b/runtime/doc/indent.txt
index cf45ec4f38..7ba5a373dc 100644
--- a/runtime/doc/indent.txt
+++ b/runtime/doc/indent.txt
@@ -321,6 +321,21 @@ The examples below assume a 'shiftwidth' of 4.
void function(); void function();
} }
<
+ *cino-E*
+ EN Indent inside C++ linkage specifications (extern "C" or
+ extern "C++") N characters extra compared to a normal block.
+ (default 0).
+
+ cino= cino=E-s >
+ extern "C" { extern "C" {
+ void function(); void function();
+ } }
+
+ extern "C" extern "C"
+ { {
+ void function(); void function();
+ } }
+<
*cino-p*
pN Parameter declarations for K&R-style function declarations will
be indented N characters from the margin. (default
@@ -550,7 +565,7 @@ The examples below assume a 'shiftwidth' of 4.
The defaults, spelled out in full, are:
- cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,ps,ts,is,+s,
+ cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,E0,ps,ts,is,+s,
c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#0
Vim puts a line in column 1 if:
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index b14f93f90a..0e174c3c61 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -14,7 +14,6 @@ if(WIN32)
# tell MinGW compiler to enable wmain
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -municode")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -iframework CoreFoundation")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreFoundation")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -framework CoreFoundation")
endif()
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index 35508fde6b..760c95eb5b 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -43,10 +43,10 @@ void remote_ui_disconnect(uint64_t channel_id)
return;
}
UIData *data = ui->data;
- // destroy pending screen updates
- api_free_array(data->buffer);
+ api_free_array(data->buffer); // Destroy pending screen updates.
pmap_del(uint64_t)(connected_uis, channel_id);
xfree(ui->data);
+ ui->data = NULL; // Flag UI as "stopped".
ui_detach_impl(ui);
xfree(ui);
}
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 5702ceaaef..8de4286216 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -718,6 +718,7 @@ struct file_buffer {
int b_ind_hash_comment;
int b_ind_cpp_namespace;
int b_ind_if_for_while;
+ int b_ind_cpp_extern_c;
linenr_T b_no_eol_lnum; /* non-zero lnum when last line of next binary
* write should not have an end-of-line */
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index f663d13c55..07a9e9286d 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -17504,7 +17504,8 @@ static char *save_tv_as_string(typval_T *tv, ptrdiff_t *const len, bool endnl)
// print an error.
if (tv->v_type != VAR_LIST && tv->v_type != VAR_NUMBER) {
const char *ret = tv_get_string_chk(tv);
- if (ret && (*len = strlen(ret))) {
+ if (ret) {
+ *len = strlen(ret);
return xmemdupz(ret, (size_t)(*len));
} else {
*len = -1;
diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c
index 55ef0261d9..d92464f17b 100644
--- a/src/nvim/event/loop.c
+++ b/src/nvim/event/loop.c
@@ -33,6 +33,9 @@ void loop_init(Loop *loop, void *data)
loop->poll_timer.data = xmalloc(sizeof(bool)); // "timeout expired" flag
}
+/// Processes one `Loop.uv` event (at most).
+/// Processes all `Loop.fast_events` events.
+///
/// @returns true if `ms` timeout was reached
bool loop_poll_events(Loop *loop, int ms)
{
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 53364c0fc5..2a215f854f 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -1314,6 +1314,43 @@ static int cin_starts_with(char_u *s, char *word)
return STRNCMP(s, word, l) == 0 && !vim_isIDc(s[l]);
}
+/// Recognize a `extern "C"` or `extern "C++"` linkage specifications.
+static int cin_is_cpp_extern_c(char_u *s)
+{
+ char_u *p;
+ int has_string_literal = false;
+
+ s = cin_skipcomment(s);
+ if (STRNCMP(s, "extern", 6) == 0 && (s[6] == NUL || !vim_iswordc(s[6]))) {
+ p = cin_skipcomment(skipwhite(s + 6));
+ while (*p != NUL) {
+ if (ascii_iswhite(*p)) {
+ p = cin_skipcomment(skipwhite(p));
+ } else if (*p == '{') {
+ break;
+ } else if (p[0] == '"' && p[1] == 'C' && p[2] == '"') {
+ if (has_string_literal) {
+ return false;
+ }
+ has_string_literal = true;
+ p += 3;
+ } else if (p[0] == '"' && p[1] == 'C' && p[2] == '+' && p[3] == '+'
+ && p[4] == '"') {
+ if (has_string_literal) {
+ return false;
+ }
+ has_string_literal = true;
+ p += 5;
+ } else {
+ return false;
+ }
+ }
+ return has_string_literal ? true : false;
+ }
+ return false;
+}
+
+
/*
* Skip strings, chars and comments until at or past "trypos".
* Return the column found.
@@ -1322,14 +1359,19 @@ static int cin_skip2pos(pos_T *trypos)
{
char_u *line;
char_u *p;
+ char_u *new_p;
p = line = ml_get(trypos->lnum);
while (*p && (colnr_T)(p - line) < trypos->col) {
- if (cin_iscomment(p))
+ if (cin_iscomment(p)) {
p = cin_skipcomment(p);
- else {
- p = skip_string(p);
- ++p;
+ } else {
+ new_p = skip_string(p);
+ if (new_p == p) {
+ p++;
+ } else {
+ p = new_p;
+ }
}
}
return (int)(p - line);
@@ -1622,6 +1664,9 @@ void parse_cino(buf_T *buf)
// indentation for # comments
buf->b_ind_hash_comment = 0;
+ // Handle C++ extern "C" or "C++"
+ buf->b_ind_cpp_extern_c = 0;
+
for (p = buf->b_p_cino; *p; ) {
l = p++;
if (*p == '-')
@@ -1690,6 +1735,7 @@ void parse_cino(buf_T *buf)
case '#': buf->b_ind_hash_comment = n; break;
case 'N': buf->b_ind_cpp_namespace = n; break;
case 'k': buf->b_ind_if_for_while = n; break;
+ case 'E': buf->b_ind_cpp_extern_c = n; break;
}
if (*p == ',')
++p;
@@ -2320,8 +2366,11 @@ int get_c_indent(void)
amount += curbuf->b_ind_open_imag;
l = skipwhite(get_cursor_line_ptr());
- if (cin_is_cpp_namespace(l))
+ if (cin_is_cpp_namespace(l)) {
amount += curbuf->b_ind_cpp_namespace;
+ } else if (cin_is_cpp_extern_c(l)) {
+ amount += curbuf->b_ind_cpp_extern_c;
+ }
} else {
/* Compensate for adding b_ind_open_extra later. */
amount -= curbuf->b_ind_open_extra;
@@ -2520,6 +2569,9 @@ int get_c_indent(void)
amount += curbuf->b_ind_cpp_namespace
- added_to_amount;
break;
+ } else if (cin_is_cpp_extern_c(l)) {
+ amount += curbuf->b_ind_cpp_extern_c - added_to_amount;
+ break;
}
if (cin_nocode(l))
diff --git a/src/nvim/macros.h b/src/nvim/macros.h
index a98c1e05a0..0406574990 100644
--- a/src/nvim/macros.h
+++ b/src/nvim/macros.h
@@ -75,7 +75,7 @@
do { \
if (*p_langmap \
&& (condition) \
- && (p_lrm || KeyTyped) \
+ && (p_lrm || (vgetc_busy ? typebuf_maplen() == 0 : KeyTyped)) \
&& !KeyStuffed \
&& (c) >= 0) \
{ \
diff --git a/src/nvim/testdir/test_cindent.vim b/src/nvim/testdir/test_cindent.vim
index 5685c2be66..444c4c4109 100644
--- a/src/nvim/testdir/test_cindent.vim
+++ b/src/nvim/testdir/test_cindent.vim
@@ -14,3 +14,63 @@ func Test_cino_hash()
call assert_equal(["#include <iostream>", "#include"], getline(1,2))
bwipe!
endfunc
+
+func Test_cino_extern_c()
+ " Test for cino-E
+
+ let without_ind = [
+ \ '#ifdef __cplusplus',
+ \ 'extern "C" {',
+ \ '#endif',
+ \ 'int func_a(void);',
+ \ '#ifdef __cplusplus',
+ \ '}',
+ \ '#endif'
+ \ ]
+
+ let with_ind = [
+ \ '#ifdef __cplusplus',
+ \ 'extern "C" {',
+ \ '#endif',
+ \ "\tint func_a(void);",
+ \ '#ifdef __cplusplus',
+ \ '}',
+ \ '#endif'
+ \ ]
+ new
+ setlocal cindent cinoptions=E0
+ call setline(1, without_ind)
+ call feedkeys("gg=G", 'tx')
+ call assert_equal(with_ind, getline(1, '$'))
+
+ setlocal cinoptions=E-s
+ call setline(1, with_ind)
+ call feedkeys("gg=G", 'tx')
+ call assert_equal(without_ind, getline(1, '$'))
+
+ setlocal cinoptions=Es
+ let tests = [
+ \ ['recognized', ['extern "C" {'], "\t\t;"],
+ \ ['recognized', ['extern "C++" {'], "\t\t;"],
+ \ ['recognized', ['extern /* com */ "C"{'], "\t\t;"],
+ \ ['recognized', ['extern"C"{'], "\t\t;"],
+ \ ['recognized', ['extern "C"', '{'], "\t\t;"],
+ \ ['not recognized', ['extern {'], "\t;"],
+ \ ['not recognized', ['extern /*"C"*/{'], "\t;"],
+ \ ['not recognized', ['extern "C" //{'], ";"],
+ \ ['not recognized', ['extern "C" /*{*/'], ";"],
+ \ ]
+
+ for pair in tests
+ let lines = pair[1]
+ call setline(1, lines)
+ call feedkeys(len(lines) . "Go;", 'tx')
+ call assert_equal(pair[2], getline(len(lines) + 1), 'Failed for "' . string(lines) . '"')
+ endfor
+
+
+
+ bwipe!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index f3383eb006..2dfe7faa04 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -69,7 +69,6 @@ typedef struct {
typedef struct {
UIBridgeData *bridge;
Loop *loop;
- bool stop;
unibi_var_t params[9];
char buf[OUTBUF_SIZE];
size_t bufpos;
@@ -124,7 +123,7 @@ static bool cursor_style_enabled = false;
UI *tui_start(void)
{
- UI *ui = xcalloc(1, sizeof(UI));
+ UI *ui = xcalloc(1, sizeof(UI)); // Freed by ui_bridge_stop().
ui->stop = tui_stop;
ui->rgb = p_tgc;
ui->resize = tui_resize;
@@ -324,11 +323,11 @@ static void tui_terminal_stop(UI *ui)
static void tui_stop(UI *ui)
{
tui_terminal_stop(ui);
- TUIData *data = ui->data;
- data->stop = true;
+ // Flag UI as "stopped". Needed by tui_scheduler (called from main thread).
+ ui->data = NULL;
}
-// Main function of the TUI thread
+/// Main function of the TUI thread.
static void tui_main(UIBridgeData *bridge, UI *ui)
{
Loop tui_loop;
@@ -349,7 +348,6 @@ static void tui_main(UIBridgeData *bridge, UI *ui)
#endif
term_input_init(&data->input, &tui_loop);
tui_terminal_start(ui);
- data->stop = false;
// Allow main thread to continue, we are ready to handle UI callbacks.
CONTINUE(bridge);
@@ -358,17 +356,17 @@ static void tui_main(UIBridgeData *bridge, UI *ui)
event_create(show_termcap_event, 1, data->ut));
// "Active" loop: first ~100 ms of startup.
- for (size_t ms = 0; ms < 100 && !data->stop;) {
+ for (size_t ms = 0; ms < 100 && !ui_is_stopped(ui);) {
ms += (loop_poll_events(&tui_loop, 20) ? 20 : 1);
}
- if (!data->stop) {
+ if (!ui_is_stopped(ui)) {
tui_terminal_after_startup(ui);
// Tickle `main_loop` with a dummy event, else the initial "focus-gained"
// terminal response may not get processed until user hits a key.
loop_schedule_deferred(&main_loop, event_create(tui_dummy_event, 0));
}
// "Passive" (I/O-driven) loop: TUI thread "main loop".
- while (!data->stop) {
+ while (!ui_is_stopped(ui)) {
loop_poll_events(&tui_loop, -1); // tui_loop.events is never processed
}
@@ -380,16 +378,19 @@ static void tui_main(UIBridgeData *bridge, UI *ui)
loop_close(&tui_loop, false);
kv_destroy(data->invalid_regions);
xfree(data);
- xfree(ui);
}
static void tui_dummy_event(void **argv)
{
}
+/// Handoff point between the main (ui_bridge) thread and the TUI thread.
static void tui_scheduler(Event event, void *d)
{
UI *ui = d;
+ if (ui_is_stopped(ui)) {
+ return; // tui_stop was handled, teardown underway.
+ }
TUIData *data = ui->data;
loop_schedule(data->loop, event); // `tui_loop` local to tui_main().
}
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 81da88c54a..8aec923538 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -143,6 +143,12 @@ void ui_builtin_stop(void)
UI_CALL(stop);
}
+/// Returns true if UI `ui` is stopped.
+bool ui_is_stopped(UI *ui)
+{
+ return ui->data == NULL;
+}
+
bool ui_rgb_attached(void)
{
for (size_t i = 0; i < ui_count; i++) {
@@ -404,7 +410,7 @@ void ui_start_highlight(int attr_code)
{
current_attr_code = attr_code;
- if (!ui_count) {
+ if (!ui_active()) {
return;
}
@@ -415,7 +421,7 @@ void ui_stop_highlight(void)
{
current_attr_code = HL_NORMAL;
- if (!ui_count) {
+ if (!ui_active()) {
return;
}
diff --git a/src/nvim/ui_bridge.c b/src/nvim/ui_bridge.c
index 0a69cf0ecb..16dd42ebaa 100644
--- a/src/nvim/ui_bridge.c
+++ b/src/nvim/ui_bridge.c
@@ -118,11 +118,12 @@ static void ui_bridge_stop(UI *b)
if (stopped) {
break;
}
- loop_poll_events(&main_loop, 10);
+ loop_poll_events(&main_loop, 10); // Process one event.
}
uv_thread_join(&bridge->ui_thread);
uv_mutex_destroy(&bridge->mutex);
uv_cond_destroy(&bridge->cond);
+ xfree(bridge->ui); // Threads joined, now safe to free UI container. #7922
ui_detach_impl(b);
xfree(b);
}
diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua
index 66d569416e..77e7424452 100644
--- a/test/functional/eval/system_spec.lua
+++ b/test/functional/eval/system_spec.lua
@@ -258,6 +258,9 @@ describe('system()', function()
end
eq(2, eval("1+1")) -- Still alive?
end)
+ it('works with an empty string', function()
+ eq("test\n", eval('system("echo test", "")'))
+ end)
end)
describe('passing a lot of input', function()
diff --git a/test/functional/normal/langmap_spec.lua b/test/functional/normal/langmap_spec.lua
new file mode 100644
index 0000000000..e4349a22e7
--- /dev/null
+++ b/test/functional/normal/langmap_spec.lua
@@ -0,0 +1,280 @@
+local helpers = require('test.functional.helpers')(after_each)
+
+local eq, neq, call = helpers.eq, helpers.neq, helpers.call
+local eval, feed, clear = helpers.eval, helpers.feed, helpers.clear
+local command, insert, expect = helpers.command, helpers.insert, helpers.expect
+local feed_command = helpers.feed_command
+local curwin = helpers.curwin
+
+describe("'langmap'", function()
+ before_each(function()
+ clear()
+ insert('iii www')
+ command('set langmap=iw,wi')
+ feed('gg0')
+ end)
+
+ it("converts keys in normal mode", function()
+ feed('ix')
+ expect('iii ww')
+ feed('whello<esc>')
+ expect('iii helloww')
+ end)
+ it("gives characters that are mapped by :nmap.", function()
+ command('map i 0x')
+ feed('w')
+ expect('ii www')
+ end)
+ describe("'langnoremap' option.", function()
+ before_each(function()
+ command('nmapclear')
+ end)
+ it("'langnoremap' is by default ON", function()
+ eq(eval('&langnoremap'), 1)
+ end)
+ it("Results of maps are not converted when 'langnoremap' ON.",
+ function()
+ command('nmap x i')
+ feed('xdl<esc>')
+ expect('dliii www')
+ end)
+ it("applies when deciding whether to map recursively", function()
+ command('nmap l i')
+ command('nmap w j')
+ feed('ll')
+ expect('liii www')
+ end)
+ it("does not stop applying 'langmap' on first character of a mapping",
+ function()
+ command('1t1')
+ command('1t1')
+ command('goto 1')
+ command('nmap w j')
+ feed('iiahello')
+ expect([[
+ iii www
+ iii www
+ ihelloii www]])
+ end)
+ it("Results of maps are converted when 'langnoremap' OFF.",
+ function()
+ command('set nolangnoremap')
+ command('nmap x i')
+ feed('xdl<esc>')
+ expect('iii ww')
+ end)
+ end)
+ -- e.g. CTRL-W_j , mj , 'j and "jp
+ it('conversions are applied to keys in middle of command',
+ function()
+ -- Works in middle of window command
+ feed('<C-w>s')
+ local origwin = curwin()
+ feed('<C-w>i')
+ neq(curwin(), origwin)
+ -- Works when setting a mark
+ feed('yy3p3gg0mwgg0mi')
+ eq(call('getpos', "'i"), {0, 3, 1, 0})
+ eq(call('getpos', "'w"), {0, 1, 1, 0})
+ feed('3dd')
+ -- Works when moving to a mark
+ feed("'i")
+ eq(call('getpos', '.'), {0, 1, 1, 0})
+ -- Works when selecting a register
+ feed('qillqqwhhq')
+ eq(eval('@i'), 'hh')
+ eq(eval('@w'), 'll')
+ feed('a<C-r>i<esc>')
+ expect('illii www')
+ feed('"ip')
+ expect('illllii www')
+ -- Works with i_CTRL-O
+ feed('0a<C-O>ihi<esc>')
+ expect('illllii hiwww')
+ end)
+
+ describe('exceptions', function()
+ -- All "command characters" that 'langmap' does not apply to.
+ -- These tests consist of those places where some subset of ASCII
+ -- characters define certain commands, yet 'langmap' is not applied to
+ -- them.
+ -- n.b. I think these shouldn't be exceptions.
+ it(':s///c confirmation', function()
+ command('set langmap=yn,ny')
+ feed('qa')
+ feed_command('s/i/w/gc')
+ feed('yynq')
+ expect('wwi www')
+ feed('u@a')
+ expect('wwi www')
+ eq(eval('@a'), ':s/i/w/gc\ryyn')
+ end)
+ it('insert-mode CTRL-G', function()
+ command('set langmap=jk,kj')
+ command('d')
+ insert([[
+ hello
+ hello
+ hello]])
+ expect([[
+ hello
+ hello
+ hello]])
+ feed('qa')
+ feed('gg3|ahello<C-G>jx<esc>')
+ feed('q')
+ expect([[
+ helhellolo
+ helxlo
+ hello]])
+ eq(eval('@a'), 'gg3|ahellojx')
+ end)
+ it('command-line CTRL-\\', function()
+ command('set langmap=en,ne')
+ feed(':<C-\\>e\'hello\'\r<C-B>put ="<C-E>"<CR>')
+ expect([[
+ iii www
+ hello]])
+ end)
+ it('command-line CTRL-R', function()
+ helpers.source([[
+ let i_value = 0
+ let j_value = 0
+ call setreg('i', 'i_value')
+ call setreg('j', 'j_value')
+ set langmap=ij,ji
+ ]])
+ feed(':let <C-R>i=1<CR>')
+ eq(eval('i_value'), 1)
+ eq(eval('j_value'), 0)
+ end)
+ -- it('-- More -- prompt', function()
+ -- -- The 'b' 'j' 'd' 'f' commands at the -- More -- prompt
+ -- end)
+ it('ask yes/no after backwards range', function()
+ command('set langmap=yn,ny')
+ feed('dd')
+ insert([[
+ hello
+ there
+ these
+ are
+ some
+ lines
+ ]])
+ feed_command('4,2d')
+ feed('n')
+ expect([[
+ hello
+ there
+ these
+ are
+ some
+ lines
+ ]])
+ end)
+ it('prompt for number', function()
+ command('set langmap=12,21')
+ helpers.source([[
+ let gotten_one = 0
+ function Map()
+ let answer = inputlist(['a', '1.', '2.', '3.'])
+ if answer == 1
+ let g:gotten_one = 1
+ endif
+ endfunction
+ nnoremap x :call Map()<CR>
+ ]])
+ feed('x1<CR>')
+ eq(eval('gotten_one'), 1)
+ command('let g:gotten_one = 0')
+ feed_command('call Map()')
+ feed('1<CR>')
+ eq(eval('gotten_one'), 1)
+ end)
+ end)
+ it('conversions are not applied during setreg()',
+ function()
+ call('setreg', 'i', 'ww')
+ eq(eval('@i'), 'ww')
+ end)
+ it('conversions not applied in insert mode', function()
+ feed('aiiiwww')
+ expect('iiiiwwwii www')
+ end)
+ it('conversions not applied in search mode', function()
+ feed('/iii<cr>x')
+ expect('ii www')
+ end)
+ it('conversions not applied in cmdline mode', function()
+ feed(':call append(1, "iii")<cr>')
+ expect([[
+ iii www
+ iii]])
+ end)
+
+ local function testrecording(command_string, expect_string, setup_function)
+ if setup_function then setup_function() end
+ feed('qa' .. command_string .. 'q')
+ expect(expect_string)
+ eq(helpers.funcs.nvim_replace_termcodes(command_string, true, true, true),
+ eval('@a'))
+ if setup_function then setup_function() end
+ -- n.b. may need nvim_replace_termcodes() here.
+ feed('@a')
+ expect(expect_string)
+ end
+
+ local function local_setup()
+ -- Can't use `insert` as it uses `i` and we've swapped the meaning of that
+ -- with the `langmap` setting.
+ command('%d')
+ command("put ='hello'")
+ command('1d')
+ end
+
+ it('does not affect recording special keys', function()
+ testrecording('A<BS><esc>', 'hell', local_setup)
+ testrecording('>><lt><lt>', 'hello', local_setup)
+ command('nnoremap \\ x')
+ testrecording('\\', 'ello', local_setup)
+ testrecording('A<C-V><BS><esc>', 'hello<BS>', local_setup)
+ end)
+ pending('Translates modified keys correctly', function()
+ command('nnoremap <M-i> x')
+ command('nnoremap <M-w> l')
+ testrecording('<M-w>', 'ello', local_setup)
+ testrecording('<M-i>x', 'hllo', local_setup)
+ end)
+ pending('handles multi-byte characters', function()
+ command('set langmap=ïx')
+ testrecording('ï', 'ello', local_setup)
+ -- The test below checks that what's recorded is correct.
+ -- It doesn't check the behaviour, as in order to cause some behaviour we
+ -- need to map the multi-byte character, and there is a known bug
+ -- preventing this from working (see the test below).
+ command('set langmap=xï')
+ testrecording('x', 'hello', local_setup)
+ end)
+ pending('handles multibyte mappings', function()
+ -- See this vim issue for the problem, may as well add a test.
+ -- https://github.com/vim/vim/issues/297
+ command('set langmap=ïx')
+ command('nnoremap x diw')
+ testrecording('ï', '', local_setup)
+ command('set nolangnoremap')
+ command('set langmap=xï')
+ command('nnoremap ï ix<esc>')
+ testrecording('x', 'xhello', local_setup)
+ end)
+ -- This test is to ensure the behaviour doesn't change from what's already
+ -- around. I (hardenedapple) personally think this behaviour should be
+ -- changed.
+ it('treats control modified keys as characters', function()
+ command('nnoremap <C-w> iw<esc>')
+ command('nnoremap <C-i> ii<esc>')
+ testrecording('<C-w>', 'whello', local_setup)
+ testrecording('<C-i>', 'ihello', local_setup)
+ end)
+
+end)
diff --git a/third-party/cmake/BuildLuarocks.cmake b/third-party/cmake/BuildLuarocks.cmake
index c7b7f8d837..7673959392 100644
--- a/third-party/cmake/BuildLuarocks.cmake
+++ b/third-party/cmake/BuildLuarocks.cmake
@@ -136,8 +136,10 @@ if(USE_BUNDLED_BUSTED)
if(WIN32)
set(BUSTED_EXE "${HOSTDEPS_BIN_DIR}/busted.bat")
+ set(LUACHECK_EXE "${HOSTDEPS_BIN_DIR}/luacheck.bat")
else()
set(BUSTED_EXE "${HOSTDEPS_BIN_DIR}/busted")
+ set(LUACHECK_EXE "${HOSTDEPS_BIN_DIR}/luacheck")
endif()
# DEPENDS on the previous module, because Luarocks breaks if parallel.
add_custom_command(OUTPUT ${BUSTED_EXE}
@@ -148,12 +150,12 @@ if(USE_BUNDLED_BUSTED)
DEPENDS ${BUSTED_EXE})
# DEPENDS on the previous module, because Luarocks breaks if parallel.
- add_custom_command(OUTPUT ${HOSTDEPS_BIN_DIR}/luacheck
+ add_custom_command(OUTPUT ${LUACHECK_EXE}
COMMAND ${LUAROCKS_BINARY}
ARGS build https://raw.githubusercontent.com/mpeterv/luacheck/master/luacheck-scm-1.rockspec ${LUAROCKS_BUILDARGS}
DEPENDS busted)
add_custom_target(luacheck
- DEPENDS ${HOSTDEPS_BIN_DIR}/luacheck)
+ DEPENDS ${LUACHECK_EXE})
set(LUV_DEPS luacheck luv-static)
if(MINGW AND CMAKE_CROSSCOMPILING)