diff options
-rw-r--r-- | runtime/doc/api.txt | 6 | ||||
-rw-r--r-- | runtime/lua/vim/_meta/api.lua | 6 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 4 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 10 |
4 files changed, 18 insertions, 8 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 45c6168e3d..6c9471b169 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -954,11 +954,11 @@ nvim_get_proc_children({pid}) *nvim_get_proc_children()* Array of child process ids, empty if process not found. nvim_get_runtime_file({name}, {all}) *nvim_get_runtime_file()* - Find files in runtime directories + Finds files in runtime directories, in 'runtimepath' order. "name" can contain wildcards. For example - nvim_get_runtime_file("colors/*.vim", true) will return all color scheme - files. Always use forward slashes (/) in the search pattern for + `nvim_get_runtime_file("colors/*.{vim,lua}", true)` will return all color + 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. diff --git a/runtime/lua/vim/_meta/api.lua b/runtime/lua/vim/_meta/api.lua index 871521db43..1d8354f6f7 100644 --- a/runtime/lua/vim/_meta/api.lua +++ b/runtime/lua/vim/_meta/api.lua @@ -1454,11 +1454,11 @@ function vim.api.nvim_get_proc(pid) end --- @return any[] function vim.api.nvim_get_proc_children(pid) end ---- Find files in runtime directories +--- Finds files in runtime directories, in 'runtimepath' order. --- --- "name" can contain wildcards. For example ---- nvim_get_runtime_file("colors/*.vim", true) will return all color scheme ---- files. Always use forward slashes (/) in the search pattern for +--- `nvim_get_runtime_file("colors/*.{vim,lua}", true)` will return all color +--- 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. diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 4b80369654..3d60dfa8ab 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -573,10 +573,10 @@ typedef struct { Arena *arena; } RuntimeCookie; -/// Find files in runtime directories +/// Finds files in runtime directories, in 'runtimepath' order. /// /// "name" can contain wildcards. For example -/// nvim_get_runtime_file("colors/*.vim", true) will return all color +/// `nvim_get_runtime_file("colors/*.{vim,lua}", true)` will return all color /// scheme files. Always use forward slashes (/) in the search pattern for /// subdirectories regardless of platform. /// diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index ae61e50624..ea6b70f4d7 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3307,6 +3307,16 @@ describe('API', function() exc_exec("echo nvim_get_runtime_file('{', v:false)") ) end) + it('preserves order of runtimepath', function() + local vimruntime = fn.getenv('VIMRUNTIME') + local rtp = string.format('%s/syntax,%s/ftplugin', vimruntime, vimruntime) + api.nvim_set_option_value('runtimepath', rtp, {}) + + local val = api.nvim_get_runtime_file('vim.vim', true) + eq(2, #val) + eq(p(val[1]), vimruntime .. '/syntax/vim.vim') + eq(p(val[2]), vimruntime .. '/ftplugin/vim.vim') + end) end) describe('nvim_get_all_options_info', function() |