diff options
-rw-r--r-- | runtime/filetype.vim | 1 | ||||
-rw-r--r-- | runtime/ftplugin/gitcommit.vim | 8 | ||||
-rw-r--r-- | runtime/syntax/gitcommit.vim | 15 | ||||
-rw-r--r-- | src/nvim/ex_cmds2.c | 26 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 19 | ||||
-rw-r--r-- | src/nvim/getchar.c | 4 | ||||
-rw-r--r-- | src/nvim/lua/treesitter.c | 4 | ||||
-rw-r--r-- | src/nvim/normal.c | 5 | ||||
-rw-r--r-- | src/nvim/popupmnu.c | 18 | ||||
-rw-r--r-- | src/nvim/syntax.c | 39 | ||||
-rw-r--r-- | src/nvim/testdir/test_filetype.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_mapping.vim | 36 | ||||
-rw-r--r-- | src/nvim/testdir/test_syntax.vim | 3 | ||||
-rw-r--r-- | test/functional/core/startup_spec.lua | 25 | ||||
-rw-r--r-- | test/functional/fixtures/start/nvim-leftpad/autoload/leftpad.vim | 3 | ||||
-rw-r--r-- | test/functional/fixtures/start/nvim-leftpad/lua/leftpad.lua | 1 | ||||
-rw-r--r-- | third-party/cmake/BuildLuv.cmake | 4 |
17 files changed, 174 insertions, 38 deletions
diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 8eb26046da..4e617052a9 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1301,6 +1301,7 @@ au BufNewFile,BufRead *.pml setf promela " Google protocol buffers au BufNewFile,BufRead *.proto setf proto +au BufNewFile,BufRead *.pbtxt setf pbtxt " Protocols au BufNewFile,BufRead */etc/protocols setf protocols diff --git a/runtime/ftplugin/gitcommit.vim b/runtime/ftplugin/gitcommit.vim index 6767ff719e..9b1998acaa 100644 --- a/runtime/ftplugin/gitcommit.vim +++ b/runtime/ftplugin/gitcommit.vim @@ -1,7 +1,7 @@ " Vim filetype plugin " Language: git commit file " Maintainer: Tim Pope <vimNOSPAM@tpope.org> -" Last Change: 2016 Aug 29 +" Last Change: 2019 Dec 05 " Only do this when not done yet for this buffer if (exists("b:did_ftplugin")) @@ -13,8 +13,10 @@ let b:did_ftplugin = 1 setlocal comments=:# commentstring=#\ %s setlocal nomodeline tabstop=8 formatoptions+=tl textwidth=72 -setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=q -let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms<' +setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=q formatoptions+=n +setlocal formatlistpat+=\\\|^\\s*[-*+]\\s\\+ + +let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms< formatlistpat<' if exists("g:no_gitcommit_commands") || v:version < 700 finish diff --git a/runtime/syntax/gitcommit.vim b/runtime/syntax/gitcommit.vim index 5e0642fbcc..63b1ce920f 100644 --- a/runtime/syntax/gitcommit.vim +++ b/runtime/syntax/gitcommit.vim @@ -2,7 +2,7 @@ " Language: git commit file " Maintainer: Tim Pope <vimNOSPAM@tpope.org> " Filenames: *.git/COMMIT_EDITMSG -" Last Change: 2016 Aug 29 +" Last Change: 2019 Dec 05 if exists("b:current_syntax") finish @@ -18,11 +18,18 @@ endif syn include @gitcommitDiff syntax/diff.vim syn region gitcommitDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|#\)\@=/ fold contains=@gitcommitDiff -syn match gitcommitFirstLine "\%^[^#].*" nextgroup=gitcommitBlank skipnl -syn match gitcommitSummary "^.\{0,50\}" contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell +syn match gitcommitSummary "^.*\%<51v." contained containedin=gitcommitFirstLine nextgroup=gitcommitOverflow contains=@Spell syn match gitcommitOverflow ".*" contained contains=@Spell syn match gitcommitBlank "^[^#].*" contained contains=@Spell -syn match gitcommitComment "^#.*" + +if get(g:, "gitcommit_cleanup") is# "scissors" + syn match gitcommitFirstLine "\%^.*" nextgroup=gitcommitBlank skipnl + syn region gitcommitComment start=/^# -\+ >8 -\+$/ end=/\%$/ contains=gitcommitDiff +else + syn match gitcommitFirstLine "\%^[^#].*" nextgroup=gitcommitBlank skipnl + syn match gitcommitComment "^#.*" +endif + syn match gitcommitHead "^\%(# .*\n\)\+#$" contained transparent syn match gitcommitOnBranch "\%(^# \)\@<=On branch" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite syn match gitcommitOnBranch "\%(^# \)\@<=Your branch .\{-\} '" contained containedin=gitcommitComment nextgroup=gitcommitBranch skipwhite diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 713d18b44d..42454b7c9a 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2551,6 +2551,17 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, done = do_in_path(p_pp, s, flags, callback, cookie); xfree(s); + + if (done == FAIL|| (flags & DIP_ALL)) { + start_dir = "start/*/%s"; // NOLINT + len = STRLEN(start_dir) + STRLEN(name); + s = xmallocz(len); + + vim_snprintf((char *)s, len, start_dir, name); + done = do_in_path(p_pp, s, flags, callback, cookie); + + xfree(s); + } } if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_OPT)) { @@ -2562,6 +2573,17 @@ int do_in_path_and_pp(char_u *path, char_u *name, int flags, done = do_in_path(p_pp, s, flags, callback, cookie); xfree(s); + + if (done == FAIL || (flags & DIP_ALL)) { + opt_dir = "opt/*/%s"; // NOLINT + len = STRLEN(opt_dir) + STRLEN(name); + s = xmallocz(len); + + vim_snprintf((char *)s, len, opt_dir, name); + done = do_in_path(p_pp, s, flags, callback, cookie); + + xfree(s); + } } return done; @@ -2822,6 +2844,8 @@ void add_pack_start_dirs(void) { do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT add_pack_plugin, &APP_ADD_DIR); + do_in_path(p_pp, (char_u *)"start/*", DIP_ALL + DIP_DIR, // NOLINT + add_pack_plugin, &APP_ADD_DIR); } /// Load plugins from all packages in the "start" directory. @@ -2830,6 +2854,8 @@ void load_start_packages(void) did_source_packages = true; do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT add_pack_plugin, &APP_LOAD); + do_in_path(p_pp, (char_u *)"start/*", DIP_ALL + DIP_DIR, // NOLINT + add_pack_plugin, &APP_LOAD); } // ":packloadall" diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 9edb826ea6..0100be15bc 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -5533,6 +5533,7 @@ static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file, garray_T ga; ga_init(&ga, (int)sizeof(char *), 10); + // TODO(bfredl): this is bullshit, exandpath should not reinvent path logic. for (int i = 0; dirnames[i] != NULL; i++) { size_t size = STRLEN(dirnames[i]) + pat_len + 7; char_u *s = xmalloc(size); @@ -5549,6 +5550,14 @@ static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file, globpath(p_pp, s, &ga, 0); xfree(s); } + + for (int i = 0; dirnames[i] != NULL; i++) { + size_t size = STRLEN(dirnames[i]) + pat_len + 22; + char_u *s = xmalloc(size); + snprintf((char *)s, size, "start/*/%s/%s*.vim", dirnames[i], pat); // NOLINT + globpath(p_pp, s, &ga, 0); + xfree(s); + } } if (flags & DIP_OPT) { @@ -5559,6 +5568,14 @@ static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file, globpath(p_pp, s, &ga, 0); xfree(s); } + + for (int i = 0; dirnames[i] != NULL; i++) { + size_t size = STRLEN(dirnames[i]) + pat_len + 20; + char_u *s = xmalloc(size); + snprintf((char *)s, size, "opt/*/%s/%s*.vim", dirnames[i], pat); // NOLINT + globpath(p_pp, s, &ga, 0); + xfree(s); + } } for (int i = 0; i < ga.ga_len; i++) { @@ -5606,6 +5623,8 @@ static int ExpandPackAddDir(char_u *pat, int *num_file, char_u ***file) char_u *s = xmalloc(buflen); snprintf((char *)s, buflen, "pack/*/opt/%s*", pat); // NOLINT globpath(p_pp, s, &ga, 0); + snprintf((char *)s, buflen, "opt/%s*", pat); // NOLINT + globpath(p_pp, s, &ga, 0); xfree(s); for (int i = 0; i < ga.ga_len; i++) { diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index a5c81b2795..2e2993ed26 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -4476,9 +4476,7 @@ char_u * getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat) aborted = true; } else if (IS_SPECIAL(c1)) { if (c1 == K_SNR) { - ga_append(&line_ga, (char)K_SPECIAL); - ga_append(&line_ga, (char)KS_EXTRA); - ga_append(&line_ga, (char)KE_SNR); + ga_concat(&line_ga, (char_u *)"<SNR>"); } else { EMSG2(e_cmdmap_key, get_special_key_name(c1, cmod)); aborted = true; diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c index 0515bbfe53..a9a57d386b 100644 --- a/src/nvim/lua/treesitter.c +++ b/src/nvim/lua/treesitter.c @@ -743,7 +743,9 @@ static int node_field(lua_State *L) if (ts_tree_cursor_goto_first_child(&cursor)) { do { - if (!STRCMP(field_name, ts_tree_cursor_current_field_name(&cursor))) { + const char *current_field = ts_tree_cursor_current_field_name(&cursor); + + if (current_field != NULL && !STRCMP(field_name, current_field)) { push_node(L, ts_tree_cursor_current_node(&cursor), 1); // [table, node] lua_rawseti(L, -2, ++curr_index); } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 2805a7d74e..4b26ae259e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1485,7 +1485,8 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) if ((redo_yank || oap->op_type != OP_YANK) && ((!VIsual_active || oap->motion_force) // Also redo Operator-pending Visual mode mappings. - || (cap->cmdchar == ':' && oap->op_type != OP_COLON)) + || ((cap->cmdchar == ':' || cap->cmdchar == K_COMMAND) + && oap->op_type != OP_COLON)) && cap->cmdchar != 'D' && oap->op_type != OP_FOLD && oap->op_type != OP_FOLDOPEN @@ -1678,7 +1679,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) prep_redo(oap->regname, cap->count0, get_op_char(oap->op_type), get_extra_op_char(oap->op_type), oap->motion_force, cap->cmdchar, cap->nchar); - } else if (cap->cmdchar != ':') { + } else if (cap->cmdchar != ':' && cap->cmdchar != K_COMMAND) { int nchar = oap->op_type == OP_REPLACE ? cap->nchar : NUL; // reverse what nv_replace() did diff --git a/src/nvim/popupmnu.c b/src/nvim/popupmnu.c index ac0c1f6eb1..f242b7d71a 100644 --- a/src/nvim/popupmnu.c +++ b/src/nvim/popupmnu.c @@ -376,6 +376,8 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed, // the positioning. Limit this to two times, when there is not much // room the window size will keep changing. } while (pum_set_selected(selected, redo_count) && (++redo_count <= 2)); + + pum_redraw(); } /// Redraw the popup menu, using "pum_first" and "pum_selected". @@ -534,7 +536,17 @@ void pum_redraw(void) xfree(st); col -= width; } else { - grid_puts_len(&pum_grid, st, (int)STRLEN(st), row, col, attr); + int size = (int)STRLEN(st); + int cells = (int)mb_string2cells(st); + + // only draw the text that fits + while (size > 0 && col + cells > pum_width + pum_col) { + size--; + size -= utf_head_off(st, st + size); + cells -= utf_ptr2cells(st + size); + } + + grid_puts_len(&pum_grid, st, size, row, col, attr); xfree(st); col += width; } @@ -824,10 +836,6 @@ static int pum_set_selected(int n, int repeat) } } - if (!resized) { - pum_redraw(); - } - return resized; } diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 2e593e39de..5e54354ea8 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -3505,12 +3505,16 @@ syn_cmd_list( syn_match_msg(); return; } else if (!(curwin->w_s->b_syn_sync_flags & SF_MATCH)) { - if (curwin->w_s->b_syn_sync_minlines == 0) + if (curwin->w_s->b_syn_sync_minlines == 0) { MSG_PUTS(_("no syncing")); - else { - MSG_PUTS(_("syncing starts ")); - msg_outnum(curwin->w_s->b_syn_sync_minlines); - MSG_PUTS(_(" lines before top line")); + } else { + if (curwin->w_s->b_syn_sync_minlines == MAXLNUM) { + MSG_PUTS(_("syncing starts at the first line")); + } else { + MSG_PUTS(_("syncing starts ")); + msg_outnum(curwin->w_s->b_syn_sync_minlines); + MSG_PUTS(_(" lines before top line")); + } syn_match_msg(); } return; @@ -3566,17 +3570,22 @@ static void syn_lines_msg(void) if (curwin->w_s->b_syn_sync_maxlines > 0 || curwin->w_s->b_syn_sync_minlines > 0) { MSG_PUTS("; "); - if (curwin->w_s->b_syn_sync_minlines > 0) { - MSG_PUTS(_("minimal ")); - msg_outnum(curwin->w_s->b_syn_sync_minlines); - if (curwin->w_s->b_syn_sync_maxlines) - MSG_PUTS(", "); - } - if (curwin->w_s->b_syn_sync_maxlines > 0) { - MSG_PUTS(_("maximal ")); - msg_outnum(curwin->w_s->b_syn_sync_maxlines); + if (curwin->w_s->b_syn_sync_minlines == MAXLNUM) { + MSG_PUTS(_("from the first line")); + } else { + if (curwin->w_s->b_syn_sync_minlines > 0) { + MSG_PUTS(_("minimal ")); + msg_outnum(curwin->w_s->b_syn_sync_minlines); + if (curwin->w_s->b_syn_sync_maxlines) { + MSG_PUTS(", "); + } + } + if (curwin->w_s->b_syn_sync_maxlines > 0) { + MSG_PUTS(_("maximal ")); + msg_outnum(curwin->w_s->b_syn_sync_maxlines); + } + MSG_PUTS(_(" lines before top line")); } - MSG_PUTS(_(" lines before top line")); } } diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 9f7e153955..af8482bdbe 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -329,6 +329,7 @@ let s:filename_checks = { \ 'papp': ['file.papp', 'file.pxml', 'file.pxsl'], \ 'pascal': ['file.pas', 'file.pp', 'file.dpr', 'file.lpr'], \ 'passwd': ['any/etc/passwd', 'any/etc/passwd-', 'any/etc/passwd.edit', 'any/etc/shadow', 'any/etc/shadow-', 'any/etc/shadow.edit', 'any/var/backups/passwd.bak', 'any/var/backups/shadow.bak'], + \ 'pbtxt': ['file.pbtxt'], \ 'pccts': ['file.g'], \ 'pdf': ['file.pdf'], \ 'perl': ['file.plx', 'file.al', 'file.psgi', 'gitolite.rc', '.gitolite.rc', 'example.gitolite.rc'], diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 152afb4b9d..c4807797ff 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -499,4 +499,40 @@ func Test_mapcomplete() call assert_match("abbr! \x01", @:) endfunc +func Test_map_cmdkey_redo() + func SelectDash() + call search('^---\n\zs', 'bcW') + norm! V + call search('\n\ze---$', 'W') + endfunc + + let text =<< trim END + --- + aaa + --- + bbb + bbb + --- + ccc + ccc + ccc + --- + END + new Xcmdtext + call setline(1, text) + + onoremap <silent> i- <Cmd>call SelectDash()<CR> + call feedkeys('2Gdi-', 'xt') + call assert_equal(['---', '---'], getline(1, 2)) + call feedkeys('j.', 'xt') + call assert_equal(['---', '---', '---'], getline(1, 3)) + call feedkeys('j.', 'xt') + call assert_equal(['---', '---', '---', '---'], getline(1, 4)) + + bwipe! + call delete('Xcmdtext') + delfunc SelectDash + ounmap i- +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 2617aa3945..4cf0e983b0 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -308,6 +308,8 @@ func Test_syntax_arg_skipped() syn sync ccomment endif call assert_notmatch('on C-style comments', execute('syntax sync')) + syn sync fromstart + call assert_match('syncing starts at the first line', execute('syntax sync')) syn clear endfunc @@ -669,6 +671,7 @@ func Test_syntax_foldlevel() redir END call assert_equal("\nsyntax foldlevel start", @c) syn sync fromstart + call assert_match('from the first line$', execute('syn sync')) let a = map(range(3,9), 'foldclosed(v:val)') call assert_equal([3,3,3,3,3,3,3], a) " attached cascade folds together let a = map(range(10,15), 'foldclosed(v:val)') diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 3bfae5f3d7..27793ab936 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -313,14 +313,33 @@ describe('startup', function() it("handles &packpath during startup", function() - pack_clear [[ let g:x = bar#test() ]] + pack_clear [[ + let g:x = bar#test() + let g:y = leftpad#pad("heyya") + ]] eq(-3, eval 'g:x') + eq(" heyya", eval 'g:y') - pack_clear [[ lua _G.y = require'bar'.doit() ]] - eq(9003, exec_lua [[ return _G.y ]]) + pack_clear [[ lua _G.y = require'bar'.doit() _G.z = require'leftpad''howdy' ]] + eq({9003, '\thowdy'}, exec_lua [[ return { _G.y, _G.z } ]]) end) it("handles :packadd during startup", function() + -- control group: opt/bonus is not availabe by default + pack_clear [[ + try + let g:x = bonus#secret() + catch + let g:err = v:exception + endtry + ]] + eq('Vim(let):E117: Unknown function: bonus#secret', eval 'g:err') + + pack_clear [[ lua _G.test = {pcall(function() require'bonus'.launch() end)} ]] + eq({false, [[[string ":lua"]:1: module 'bonus' not found:]]}, + exec_lua [[ _G.test[2] = string.gsub(_G.test[2], '[\r\n].*', '') return _G.test ]]) + + -- ok, time to launch the nukes: pack_clear [[ packadd! bonus | let g:x = bonus#secret() ]] eq('halloj', eval 'g:x') diff --git a/test/functional/fixtures/start/nvim-leftpad/autoload/leftpad.vim b/test/functional/fixtures/start/nvim-leftpad/autoload/leftpad.vim new file mode 100644 index 0000000000..2f428f59e0 --- /dev/null +++ b/test/functional/fixtures/start/nvim-leftpad/autoload/leftpad.vim @@ -0,0 +1,3 @@ +function! leftpad#pad(str) + return ' '.a:str +endfunction diff --git a/test/functional/fixtures/start/nvim-leftpad/lua/leftpad.lua b/test/functional/fixtures/start/nvim-leftpad/lua/leftpad.lua new file mode 100644 index 0000000000..866ed2fd30 --- /dev/null +++ b/test/functional/fixtures/start/nvim-leftpad/lua/leftpad.lua @@ -0,0 +1 @@ +return function (str) return '\t' .. str end diff --git a/third-party/cmake/BuildLuv.cmake b/third-party/cmake/BuildLuv.cmake index ab3e2190ab..ac4196f910 100644 --- a/third-party/cmake/BuildLuv.cmake +++ b/third-party/cmake/BuildLuv.cmake @@ -68,6 +68,7 @@ set(LUV_CONFIGURE_COMMAND_COMMON -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR} -DLUA_BUILD_TYPE=System + -DLUA_COMPAT53_DIR=${DEPS_BUILD_DIR}/src/lua-compat-5.3 -DWITH_SHARED_LIBUV=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_MODULE=OFF) @@ -88,8 +89,7 @@ endif() if(USE_BUNDLED_LIBUV) set(LUV_CONFIGURE_COMMAND_COMMON ${LUV_CONFIGURE_COMMAND_COMMON} - -DCMAKE_PREFIX_PATH=${DEPS_INSTALL_DIR} - -DLUA_COMPAT53_DIR=${DEPS_BUILD_DIR}/src/lua-compat-5.3) + -DCMAKE_PREFIX_PATH=${DEPS_INSTALL_DIR}) endif() if(MINGW AND CMAKE_CROSSCOMPILING) |