diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/nvim/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 30 | ||||
-rw-r--r-- | src/nvim/autocmd.c | 7 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 82 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 2 | ||||
-rw-r--r-- | src/nvim/os/lang.c | 60 | ||||
-rw-r--r-- | src/nvim/testdir/test_filetype.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_help_tagjump.vim | 14 |
8 files changed, 105 insertions, 95 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 64de2ec7e0..2cf1bda45f 100755 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -16,8 +16,8 @@ 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_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreFoundation") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -framework CoreFoundation") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreServices") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -framework CoreServices") endif() set(TOUCHES_DIR ${PROJECT_BINARY_DIR}/touches) diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 3d1b5eade4..061653c5af 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -2624,27 +2624,27 @@ Dictionary nvim_parse_cmd(String str, Dictionary opts, Error *err) PUT(mods, "emsg_silent", BOOLEAN_OBJ(cmdinfo.emsg_silent)); PUT(mods, "sandbox", BOOLEAN_OBJ(cmdinfo.sandbox)); PUT(mods, "noautocmd", BOOLEAN_OBJ(cmdinfo.noautocmd)); - PUT(mods, "tab", INTEGER_OBJ(cmdmod.tab)); + PUT(mods, "tab", INTEGER_OBJ(cmdinfo.cmdmod.tab)); PUT(mods, "verbose", INTEGER_OBJ(cmdinfo.verbose)); - PUT(mods, "browse", BOOLEAN_OBJ(cmdmod.browse)); - PUT(mods, "confirm", BOOLEAN_OBJ(cmdmod.confirm)); - PUT(mods, "hide", BOOLEAN_OBJ(cmdmod.hide)); - PUT(mods, "keepalt", BOOLEAN_OBJ(cmdmod.keepalt)); - PUT(mods, "keepjumps", BOOLEAN_OBJ(cmdmod.keepjumps)); - PUT(mods, "keepmarks", BOOLEAN_OBJ(cmdmod.keepmarks)); - PUT(mods, "keeppatterns", BOOLEAN_OBJ(cmdmod.keeppatterns)); - PUT(mods, "lockmarks", BOOLEAN_OBJ(cmdmod.lockmarks)); - PUT(mods, "noswapfile", BOOLEAN_OBJ(cmdmod.noswapfile)); - PUT(mods, "vertical", BOOLEAN_OBJ(cmdmod.split & WSP_VERT)); + PUT(mods, "browse", BOOLEAN_OBJ(cmdinfo.cmdmod.browse)); + PUT(mods, "confirm", BOOLEAN_OBJ(cmdinfo.cmdmod.confirm)); + PUT(mods, "hide", BOOLEAN_OBJ(cmdinfo.cmdmod.hide)); + PUT(mods, "keepalt", BOOLEAN_OBJ(cmdinfo.cmdmod.keepalt)); + PUT(mods, "keepjumps", BOOLEAN_OBJ(cmdinfo.cmdmod.keepjumps)); + PUT(mods, "keepmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.keepmarks)); + PUT(mods, "keeppatterns", BOOLEAN_OBJ(cmdinfo.cmdmod.keeppatterns)); + PUT(mods, "lockmarks", BOOLEAN_OBJ(cmdinfo.cmdmod.lockmarks)); + PUT(mods, "noswapfile", BOOLEAN_OBJ(cmdinfo.cmdmod.noswapfile)); + PUT(mods, "vertical", BOOLEAN_OBJ(cmdinfo.cmdmod.split & WSP_VERT)); const char *split; - if (cmdmod.split & WSP_BOT) { + if (cmdinfo.cmdmod.split & WSP_BOT) { split = "botright"; - } else if (cmdmod.split & WSP_TOP) { + } else if (cmdinfo.cmdmod.split & WSP_TOP) { split = "topleft"; - } else if (cmdmod.split & WSP_BELOW) { + } else if (cmdinfo.cmdmod.split & WSP_BELOW) { split = "belowright"; - } else if (cmdmod.split & WSP_ABOVE) { + } else if (cmdinfo.cmdmod.split & WSP_ABOVE) { split = "aboveleft"; } else { split = ""; diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index bfeb70dce9..9bc0a4fabf 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1191,8 +1191,9 @@ char_u *aucmd_next_pattern(char_u *pat, size_t patlen) /// Return OK for success, FAIL for failure; /// /// @param do_msg give message for no matching autocmds? -int do_doautocmd(char_u *arg, bool do_msg, bool *did_something) +int do_doautocmd(char_u *arg_start, bool do_msg, bool *did_something) { + char_u *arg = arg_start; int nothing_done = true; if (did_something != NULL) { @@ -1224,8 +1225,8 @@ int do_doautocmd(char_u *arg, bool do_msg, bool *did_something) } } - if (nothing_done && do_msg) { - msg(_("No matching autocommands")); + if (nothing_done && do_msg && !aborting()) { + smsg(_("No matching autocommands: %s"), arg_start); } if (did_something != NULL) { *did_something = !nothing_done; diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 5cd3e7f968..06fa981ba7 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -5023,37 +5023,59 @@ static int help_compare(const void *s1, const void *s2) int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep_lang) { int i; - static const char *(mtable[]) = { - "*", "g*", "[*", "]*", - "/*", "/\\*", "\"*", "**", - "/\\(\\)", "/\\%(\\)", - "?", ":?", "?<CR>", "g?", "g?g?", "g??", - "-?", "q?", "v_g?", - "/\\?", "/\\z(\\)", "\\=", ":s\\=", - "[count]", "[quotex]", - "[range]", ":[range]", - "[pattern]", "\\|", "\\%$", - "s/\\~", "s/\\U", "s/\\L", - "s/\\1", "s/\\2", "s/\\3", "s/\\9" - }; - static const char *(rtable[]) = { - "star", "gstar", "[star", "]star", - "/star", "/\\\\star", "quotestar", "starstar", - "/\\\\(\\\\)", "/\\\\%(\\\\)", - "?", ":?", "?<CR>", "g?", "g?g?", "g??", - "-?", "q?", "v_g?", - "/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=", - "\\[count]", "\\[quotex]", - "\\[range]", ":\\[range]", - "\\[pattern]", "\\\\bar", "/\\\\%\\$", - "s/\\\\\\~", "s/\\\\U", "s/\\\\L", - "s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9" + + // Specific tags that either have a specific replacement or won't go + // throught the generic rules. + static char *(except_tbl[][2]) = { + { "*", "star" }, + { "g*", "gstar" }, + { "[*", "[star" }, + { "]*", "]star" }, + { ":*", ":star" }, + { "/*", "/star" }, // NOLINT + { "/\\*", "/\\\\star" }, + { "\"*", "quotestar" }, + { "**", "starstar" }, + { "cpo-*", "cpo-star" }, + { "/\\(\\)", "/\\\\(\\\\)" }, + { "/\\%(\\)", "/\\\\%(\\\\)" }, + { "?", "?" }, + { "??", "??" }, + { ":?", ":?" }, + { "?<CR>", "?<CR>" }, + { "g?", "g?" }, + { "g?g?", "g?g?" }, + { "g??", "g??" }, + { "-?", "-?" }, + { "q?", "q?" }, + { "v_g?", "v_g?" }, + { "/\\?", "/\\\\?" }, + { "/\\z(\\)", "/\\\\z(\\\\)" }, + { "\\=", "\\\\=" }, + { ":s\\=", ":s\\\\=" }, + { "[count]", "\\[count]" }, + { "[quotex]", "\\[quotex]" }, + { "[range]", "\\[range]" }, + { ":[range]", ":\\[range]" }, + { "[pattern]", "\\[pattern]" }, + { "\\|", "\\\\bar" }, + { "\\%$", "/\\\\%\\$" }, + { "s/\\~", "s/\\\\\\~" }, + { "s/\\U", "s/\\\\U" }, + { "s/\\L", "s/\\\\L" }, + { "s/\\1", "s/\\\\1" }, + { "s/\\2", "s/\\\\2" }, + { "s/\\3", "s/\\\\3" }, + { "s/\\9", "s/\\\\9" }, + { NULL, NULL } }; + static const char *(expr_table[]) = { "!=?", "!~?", "<=?", "<?", "==?", "=~?", ">=?", ">?", "is?", "isnot?" }; char *d = (char *)IObuff; // assume IObuff is long enough! + d[0] = NUL; if (STRNICMP(arg, "expr-", 5) == 0) { // When the string starting with "expr-" and containing '?' and matches @@ -5075,16 +5097,16 @@ int find_help_tags(const char *arg, int *num_matches, char ***matches, bool keep } } else { // Recognize a few exceptions to the rule. Some strings that contain - // '*' with "star". Otherwise '*' is recognized as a wildcard. - for (i = (int)ARRAY_SIZE(mtable); --i >= 0;) { - if (STRCMP(arg, mtable[i]) == 0) { - STRCPY(d, rtable[i]); + // '*'are changed to "star", otherwise '*' is recognized as a wildcard. + for (i = 0; except_tbl[i][0] != NULL; i++) { + if (STRCMP(arg, except_tbl[i][0]) == 0) { + STRCPY(d, except_tbl[i][1]); break; } } } - if (i < 0) { // no match in table + if (d[0] == NUL) { // no match in table // Replace "\S" with "/\\S", etc. Otherwise every tag is matched. // Also replace "\%^" and "\%(", they match every tag too. // Also "\zs", "\z1", etc. diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 7b5d14a404..b2a71b386b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1306,6 +1306,7 @@ bool parse_cmdline(char_u *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo) char *errormsg = NULL; char *cmd; char *p; + cmdmod_T save_cmdmod = cmdmod; // Initialize cmdinfo memset(cmdinfo, 0, sizeof(*cmdinfo)); @@ -1346,6 +1347,7 @@ bool parse_cmdline(char_u *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo) p_verbose = eap->verbose_save; } cmdinfo->cmdmod = cmdmod; + cmdmod = save_cmdmod; // Save location after command modifiers cmd = eap->cmd; diff --git a/src/nvim/os/lang.c b/src/nvim/os/lang.c index b63faacaae..28f43ff3af 100644 --- a/src/nvim/os/lang.c +++ b/src/nvim/os/lang.c @@ -3,9 +3,10 @@ #ifdef __APPLE__ # define Boolean CFBoolean // Avoid conflict with API's Boolean -# include <CoreFoundation/CFLocale.h> -# include <CoreFoundation/CFString.h> +# define FileInfo CSFileInfo // Avoid conflict with API's Fileinfo +# include <CoreServices/CoreServices.h> # undef Boolean +# undef FileInfo #endif #include "auto/config.h" @@ -21,55 +22,24 @@ void lang_init(void) { #ifdef __APPLE__ if (os_getenv("LANG") == NULL) { - const char *lang_region = NULL; - CFTypeRef cf_lang_region = NULL; - - CFLocaleRef cf_locale = CFLocaleCopyCurrent(); - if (cf_locale) { - cf_lang_region = CFLocaleGetValue(cf_locale, kCFLocaleIdentifier); - CFRetain(cf_lang_region); - lang_region = CFStringGetCStringPtr(cf_lang_region, - kCFStringEncodingUTF8); - CFRelease(cf_locale); - } else { - // Use the primary language defined in Preferences -> Language & Region - CFArrayRef cf_langs = CFLocaleCopyPreferredLanguages(); - if (cf_langs && CFArrayGetCount(cf_langs) > 0) { - cf_lang_region = CFArrayGetValueAtIndex(cf_langs, 0); - CFRetain(cf_lang_region); - CFRelease(cf_langs); - lang_region = CFStringGetCStringPtr(cf_lang_region, - kCFStringEncodingUTF8); - } else { - ELOG("$LANG is empty and your primary language cannot be inferred."); - return; - } - } - char buf[50] = { 0 }; - bool set_lang; - if (lang_region) { - set_lang = true; - xstrlcpy(buf, lang_region, sizeof(buf)); - } else { - set_lang = CFStringGetCString(cf_lang_region, buf, 40, - kCFStringEncodingUTF8); - } - if (set_lang) { + + // $LANG is not set, either because it was unset or Nvim was started + // from the Dock. Query the system locale. + if (LocaleRefGetPartString(NULL, + kLocaleLanguageMask | kLocaleLanguageVariantMask | + kLocaleRegionMask | kLocaleRegionVariantMask, + sizeof(buf) - 10, buf) == noErr && *buf) { if (strcasestr(buf, "utf-8") == NULL) { xstrlcat(buf, ".UTF-8", sizeof(buf)); } os_setenv("LANG", buf, true); + setlocale(LC_ALL, ""); + // Make sure strtod() uses a decimal point, not a comma. + setlocale(LC_NUMERIC, "C"); + } else { + ELOG("$LANG is empty and the macOS primary language cannot be inferred."); } - CFRelease(cf_lang_region); -# ifdef HAVE_LOCALE_H - setlocale(LC_ALL, ""); - -# ifdef LC_NUMERIC - // Make sure strtod() uses a decimal point, not a comma. - setlocale(LC_NUMERIC, "C"); -# endif -# endif } #endif } diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 6ae957da70..63b598dca8 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -456,6 +456,7 @@ let s:filename_checks = { \ 'rib': ['file.rib'], \ 'rnc': ['file.rnc'], \ 'rng': ['file.rng'], + \ 'robot': ['file.robot', 'file.resource'], \ 'robots': ['robots.txt'], \ 'routeros': ['file.rsc'], \ 'rpcgen': ['file.x'], diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim index a43889b57e..ece8ccf215 100644 --- a/src/nvim/testdir/test_help_tagjump.vim +++ b/src/nvim/testdir/test_help_tagjump.vim @@ -28,11 +28,25 @@ func Test_help_tagjump() call assert_true(getline('.') =~ '\*quote\*') helpclose + help * + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*star\*') + helpclose + help "* call assert_equal("help", &filetype) call assert_true(getline('.') =~ '\*quotestar\*') helpclose + " The test result is different in vim. There ":help ??" will jump to the + " falsy operator ??, which hasn't been ported to neovim yet. Instead, neovim + " jumps to the tag "g??". This test result needs to be changed if neovim + " ports the falsy operator. + help ?? + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*g??\*') + helpclose + help ch?ckhealth call assert_equal("help", &filetype) call assert_true(getline('.') =~ '\*:checkhealth\*') |