diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-05-08 13:41:58 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-05-13 09:33:36 -0300 |
commit | d8f8521915984a00623562d8606c04e247fa2967 (patch) | |
tree | 073aaa8d5e9189340806aad8697c4587639c7f35 /src/api/vim.c | |
parent | b812e84bb5023c8d720f2cf44488c98ed4cc3822 (diff) | |
download | rneovim-d8f8521915984a00623562d8606c04e247fa2967.tar.gz rneovim-d8f8521915984a00623562d8606c04e247fa2967.tar.bz2 rneovim-d8f8521915984a00623562d8606c04e247fa2967.zip |
API: Implement vim_list_runtime_paths
Diffstat (limited to 'src/api/vim.c')
-rw-r--r-- | src/api/vim.c | 36 |
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) |