aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/map.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2016-02-23 23:32:21 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2016-02-23 23:32:21 +0100
commitb10c9b4f5b28a50c752ddadc8dc4319546c9d039 (patch)
tree2c544bc2c01abea43f59e9a48598f3d74df45760 /src/nvim/map.c
parent18605d678517ca7347a8fae234e5f39f79fb6904 (diff)
parent2a4ea9a54674b642c39fc0745c7feca11f14ec46 (diff)
downloadrneovim-b10c9b4f5b28a50c752ddadc8dc4319546c9d039.tar.gz
rneovim-b10c9b4f5b28a50c752ddadc8dc4319546c9d039.tar.bz2
rneovim-b10c9b4f5b28a50c752ddadc8dc4319546c9d039.zip
Merge pull request #1817 from bfredl/bufmatch
support buffer-associated highlighting by external plugins
Diffstat (limited to 'src/nvim/map.c')
-rw-r--r--src/nvim/map.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/nvim/map.c b/src/nvim/map.c
index ed7bda4cce..d4262ae9a8 100644
--- a/src/nvim/map.c
+++ b/src/nvim/map.c
@@ -18,6 +18,9 @@
#define uint32_t_eq kh_int_hash_equal
#define int_hash kh_int_hash_func
#define int_eq kh_int_hash_equal
+#define linenr_T_hash kh_int_hash_func
+#define linenr_T_eq kh_int_hash_equal
+
#if defined(ARCH_64)
#define ptr_t_hash(key) uint64_t_hash((uint64_t)key)
@@ -78,6 +81,25 @@
return rv; \
} \
\
+ U *map_##T##_##U##_ref(Map(T, U) *map, T key, bool put) \
+ { \
+ int ret; \
+ khiter_t k; \
+ if (put) { \
+ k = kh_put(T##_##U##_map, map->table, key, &ret); \
+ if (ret) { \
+ kh_val(map->table, k) = INITIALIZER(T, U); \
+ } \
+ } else { \
+ k = kh_get(T##_##U##_map, map->table, key); \
+ if (k == kh_end(map->table)) { \
+ return NULL; \
+ } \
+ } \
+ \
+ return &kh_val(map->table, k); \
+ } \
+ \
U map_##T##_##U##_del(Map(T, U) *map, T key) \
{ \
U rv = INITIALIZER(T, U); \
@@ -118,3 +140,5 @@ MAP_IMPL(ptr_t, ptr_t, DEFAULT_INITIALIZER)
MAP_IMPL(uint64_t, ptr_t, DEFAULT_INITIALIZER)
#define MSGPACK_HANDLER_INITIALIZER {.fn = NULL, .async = false}
MAP_IMPL(String, MsgpackRpcRequestHandler, MSGPACK_HANDLER_INITIALIZER)
+#define KVEC_INITIALIZER { .size = 0, .capacity = 0, .items = NULL }
+MAP_IMPL(linenr_T, bufhl_vec_T, KVEC_INITIALIZER)