aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-04-17 20:24:23 -0400
committerJustin M. Keyes <justinkz@gmail.com>2016-04-17 20:24:23 -0400
commit007d573147bb9086c63e779b1db3938690037db8 (patch)
tree8a0833743202d0e6be899fe65b50a47197c0e40a /src/nvim/api/vim.c
parent83c683f5e15867c2e2889442860e91fd1074b4e1 (diff)
parenta64114eba017c0db3d1849186c9c54fb09308761 (diff)
downloadrneovim-007d573147bb9086c63e779b1db3938690037db8.tar.gz
rneovim-007d573147bb9086c63e779b1db3938690037db8.tar.bz2
rneovim-007d573147bb9086c63e779b1db3938690037db8.zip
Merge pull request #4131 from ZyX-I/json-functions
Add JSON support
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 9279f6b469..10110b0f62 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -331,15 +331,31 @@ Object vim_get_var(String name, Error *err)
return dict_get_value(&globvardict, name, err);
}
-/// Sets a global variable. Passing 'nil' as value deletes the variable.
+/// Sets a global variable
///
/// @param name The variable name
/// @param value The variable value
/// @param[out] err Details of an error that may have occurred
-/// @return the old value if any
+/// @return The old value or nil if there was no previous value.
+///
+/// @warning It may return nil if there was no previous value
+/// or if previous value was `v:null`.
Object vim_set_var(String name, Object value, Error *err)
{
- return dict_set_value(&globvardict, name, value, err);
+ return dict_set_value(&globvardict, name, value, false, err);
+}
+
+/// Removes a global variable
+///
+/// @param name The variable name
+/// @param[out] err Details of an error that may have occurred
+/// @return The old value or nil if there was no previous value.
+///
+/// @warning It may return nil if there was no previous value
+/// or if previous value was `v:null`.
+Object vim_del_var(String name, Error *err)
+{
+ return dict_set_value(&globvardict, name, NIL, true, err);
}
/// Gets a vim variable