diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2020-11-24 16:47:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-24 16:47:48 +0100 |
commit | a6bd52d877875deecb65d367bca8eda5d89fb8bc (patch) | |
tree | 732c1fd886be77aa31d0781a2c6816f8fa1b1b0f /src | |
parent | 7e0e0782a17b91a9d90d493f326770dcf33c7598 (diff) | |
parent | d285fa73da7ce2cb9abfbbb423eb8506e7202411 (diff) | |
download | rneovim-a6bd52d877875deecb65d367bca8eda5d89fb8bc.tar.gz rneovim-a6bd52d877875deecb65d367bca8eda5d89fb8bc.tar.bz2 rneovim-a6bd52d877875deecb65d367bca8eda5d89fb8bc.zip |
Merge pull request #13366 from bfredl/path3a
api: enable nvim_get_runtime_file to find subdirectories
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/api/vim.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 710885d295..77002697fe 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -788,10 +788,15 @@ ArrayOf(String) nvim_list_runtime_paths(void) /// /// 'name' can contain wildcards. For example /// nvim_get_runtime_file("colors/*.vim", true) will return all color -/// scheme files. +/// scheme files. Always use forward slashes (/) in the search pattern for +/// subdirectories regardless of platform. /// /// It is not an error to not find any files. An empty array is returned then. /// +/// To find a directory, `name` must end with a forward slash, like +/// "rplugin/python/". Without the slash it would instead look for an ordinary +/// file called "rplugin/python". +/// /// @param name pattern of files to search for /// @param all whether to return all matches or only the first /// @return list of absolute paths to the found files @@ -801,14 +806,13 @@ ArrayOf(String) nvim_get_runtime_file(String name, Boolean all, Error *err) { Array rv = ARRAY_DICT_INIT; - // TODO(bfredl): - if (name.size == 0) { - api_set_error(err, kErrorTypeValidation, "not yet implemented"); - return rv; + int flags = DIP_START | (all ? DIP_ALL : 0); + + if (name.size == 0 || name.data[name.size-1] == '/') { + flags |= DIP_DIR; } - int flags = DIP_START | (all ? DIP_ALL : 0); - do_in_runtimepath((char_u *)name.data, + do_in_runtimepath((char_u *)(name.size ? name.data : ""), flags, find_runtime_cb, &rv); return rv; } |