aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorckelsel <ckelsel@hotmail.com>2017-10-09 21:17:15 +0800
committerckelsel <ckelsel@hotmail.com>2017-10-10 14:50:13 +0800
commitd2b0c5838a999483a59953755e8c52507b0420b8 (patch)
tree97d44e212a3287b9967f0006cd4d587a77de72cd /src/nvim/api/vim.c
parent5d369ad3843bbc0a3541827284f55430ec4f46e4 (diff)
parentceb40c0411843b35005f019bf2c61f22572afcdf (diff)
downloadrneovim-d2b0c5838a999483a59953755e8c52507b0420b8.tar.gz
rneovim-d2b0c5838a999483a59953755e8c52507b0420b8.tar.bz2
rneovim-d2b0c5838a999483a59953755e8c52507b0420b8.zip
Merge branch 'master' of github.com:ckelsel/neovim into vim-8.0.0101
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index ab893a4c0f..98f4410347 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -55,6 +55,47 @@ void nvim_command(String command, Error *err)
try_end(err);
}
+/// Gets a highlight definition by name.
+///
+/// @param name Highlight group name
+/// @param rgb Export RGB colors
+/// @param[out] err Error details, if any
+/// @return Highlight definition map
+/// @see nvim_get_hl_by_id
+Dictionary nvim_get_hl_by_name(String name, Boolean rgb, Error *err)
+ FUNC_API_SINCE(3)
+{
+ Dictionary result = ARRAY_DICT_INIT;
+ int id = syn_name2id((const char_u *)name.data);
+
+ if (id == 0) {
+ api_set_error(err, kErrorTypeException, "Invalid highlight name: %s",
+ name.data);
+ return result;
+ }
+ result = nvim_get_hl_by_id(id, rgb, err);
+ return result;
+}
+
+/// Gets a highlight definition by id. |hlID()|
+///
+/// @param hl_id Highlight id as returned by |hlID()|
+/// @param rgb Export RGB colors
+/// @param[out] err Error details, if any
+/// @return Highlight definition map
+/// @see nvim_get_hl_by_name
+Dictionary nvim_get_hl_by_id(Integer hl_id, Boolean rgb, Error *err)
+ FUNC_API_SINCE(3)
+{
+ Dictionary dic = ARRAY_DICT_INIT;
+ if (syn_get_final_id((int)hl_id) == 0) {
+ api_set_error(err, kErrorTypeException, "Invalid highlight id: %d", hl_id);
+ return dic;
+ }
+ int attrcode = syn_id2attr((int)hl_id);
+ return hl_get_attr_by_id(attrcode, rgb, err);
+}
+
/// Passes input keys to Nvim.
/// On VimL error: Does not fail, but updates v:errmsg.
///