aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ops.h
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2020-01-02 12:01:43 -0700
committerJosh Rahm <rahm@google.com>2022-01-11 14:31:07 -0700
commit1d4d42398055b1979b66a243161f8ee5fc7a19f5 (patch)
treeb8c4a68041ac9f60c53f2f2b34184a3557656e74 /src/nvim/ops.h
parent3b1675cc6215851fcf5c9274d6913539a7c97da6 (diff)
downloadrneovim-1d4d42398055b1979b66a243161f8ee5fc7a19f5.tar.gz
rneovim-1d4d42398055b1979b66a243161f8ee5fc7a19f5.tar.bz2
rneovim-1d4d42398055b1979b66a243161f8ee5fc7a19f5.zip
Add user-registers for arbitrary registers.
This allows users to define behaviors for arbitrary registers. These registers can be any character including multibyte characters. This means that any character may be used as a register and if that register is not a builtin register, it will defer to a user-defined vimscript function for behavior. This is done throw an option called 'userregfun' The function that 'userregfun' defines is a function that takes 3 arguments: action - Either set to "put" or "yank" register - The character representing the register. content - If the action is "yank" this string contains the content yanked. Multibyte registers are still broken for expressions. So while let @&=xyz Works as expected, let @λ=xyz will still throw a parse error.
Diffstat (limited to 'src/nvim/ops.h')
-rw-r--r--src/nvim/ops.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/nvim/ops.h b/src/nvim/ops.h
index efde7290cf..af49e271cb 100644
--- a/src/nvim/ops.h
+++ b/src/nvim/ops.h
@@ -22,6 +22,7 @@ typedef int (*Indenter)(void);
#define PUT_LINE_SPLIT 16 // split line for linewise register
#define PUT_LINE_FORWARD 32 // put linewise register below Visual sel.
#define PUT_BLOCK_INNER 64 // in block mode, do not add trailing spaces
+#define ITER_REGISTER_NULL 0
/*
* Registers:
@@ -37,7 +38,8 @@ typedef int (*Indenter)(void);
// The following registers should not be saved in ShaDa file:
#define STAR_REGISTER 37
#define PLUS_REGISTER 38
-#define NUM_REGISTERS 39
+#define USER_REGISTERS_START 39
+#define NUM_REGISTERS USER_REGISTERS_START
// Operator IDs; The order must correspond to opchars[] in ops.c!
#define OP_NOP 0 // no pending operation
@@ -96,6 +98,8 @@ typedef enum {
YREG_YANK,
YREG_PUT,
} yreg_mode_t;
+/// Returns a reference to a user-defined register.
+int get_userreg(const int regname);
/// Convert register name into register index
///
@@ -118,10 +122,15 @@ static inline int op_reg_index(const int regname)
} else if (regname == '+') {
return PLUS_REGISTER;
} else {
- return -1;
+ return get_userreg(regname);
}
}
+struct yank_registers;
+typedef struct yank_registers yank_registers_T;
+
+typedef size_t iter_register_T;
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "ops.h.generated.h"
#endif