aboutsummaryrefslogtreecommitdiff
path: root/src/api/vim.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/vim.c')
-rw-r--r--src/api/vim.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/api/vim.c b/src/api/vim.c
index 33e5a8ad85..361a57218c 100644
--- a/src/api/vim.c
+++ b/src/api/vim.c
@@ -11,6 +11,7 @@
#include "ex_docmd.h"
#include "screen.h"
#include "eval.h"
+#include "misc2.h"
#include "memory.h"
#include "lib/khash.h"
@@ -88,7 +89,40 @@ int64_t vim_strwidth(String str)
StringArray vim_list_runtime_paths(void)
{
- abort();
+ StringArray rv = {.size = 0};
+ uint8_t *rtp = p_rtp;
+
+ if (*rtp == NUL) {
+ // No paths
+ return rv;
+ }
+
+ // Count the number of paths in rtp
+ while (*rtp != NUL) {
+ if (*rtp == ',') {
+ rv.size++;
+ }
+ rtp++;
+ }
+
+ // index
+ uint32_t i = 0;
+ // Allocate memory for the copies
+ rv.items = xmalloc(sizeof(String) * rv.size);
+ // reset the position
+ rtp = p_rtp;
+ // Start copying
+ while (*rtp != NUL) {
+ rv.items[i].data = xmalloc(MAXPATHL);
+ // Copy the path from 'runtimepath' to rv.items[i]
+ rv.items[i].size = copy_option_part(&rtp,
+ (char_u *)rv.items[i].data,
+ MAXPATHL,
+ ",");
+ i++;
+ }
+
+ return rv;
}
void vim_change_directory(String dir)