mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
api: add nvim_get_runtime_file for finding runtime files
This commit is contained in:
@@ -703,6 +703,35 @@ ArrayOf(String) nvim_list_runtime_paths(void)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/// Find files in runtime directories
|
||||
///
|
||||
/// 'name' can contain wildcards. For example
|
||||
/// nvim_get_runtime_file("colors/*.vim", true) will return all color
|
||||
/// scheme files.
|
||||
///
|
||||
/// It is not an error to not find any files. An empty array is returned then.
|
||||
///
|
||||
/// @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
|
||||
ArrayOf(String) nvim_get_runtime_file(String name, Boolean all)
|
||||
FUNC_API_SINCE(7)
|
||||
{
|
||||
Array rv = ARRAY_DICT_INIT;
|
||||
if (!name.data) {
|
||||
return rv;
|
||||
}
|
||||
int flags = DIP_START | (all ? DIP_ALL : 0);
|
||||
do_in_runtimepath((char_u *)name.data, flags, find_runtime_cb, &rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static void find_runtime_cb(char_u *fname, void *cookie)
|
||||
{
|
||||
Array *rv = (Array *)cookie;
|
||||
ADD(*rv, STRING_OBJ(cstr_to_string((char *)fname)));
|
||||
}
|
||||
|
||||
/// Changes the global working directory.
|
||||
///
|
||||
/// @param dir Directory path
|
||||
|
Reference in New Issue
Block a user