summaryrefslogtreecommitdiff
path: root/nvimctl.py
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2023-01-25 23:22:24 +0000
committerJosh Rahm <rahm@google.com>2023-01-25 23:22:24 +0000
commit30d4ba81d319b56ec5ec8eae7ef7c71083839e9a (patch)
treefe48b7aeac64639521af91be8666513575421f51 /nvimctl.py
parent3edb113742ea3e555695c5b88eeef2572021d2a8 (diff)
downloadconfig.vim-30d4ba81d319b56ec5ec8eae7ef7c71083839e9a.tar.gz
config.vim-30d4ba81d319b56ec5ec8eae7ef7c71083839e9a.tar.bz2
config.vim-30d4ba81d319b56ec5ec8eae7ef7c71083839e9a.zip
Add feedkeys() to nvimctl
Diffstat (limited to 'nvimctl.py')
-rwxr-xr-xnvimctl.py40
1 files changed, 35 insertions, 5 deletions
diff --git a/nvimctl.py b/nvimctl.py
index 42e083a..e0c9b70 100755
--- a/nvimctl.py
+++ b/nvimctl.py
@@ -14,6 +14,7 @@ nvim = neovim.attach('socket', path=nvim_socket)
class GetReg:
+
def name(self):
return "getreg"
@@ -29,18 +30,26 @@ class GetReg:
class PutReg:
+
def name(self):
return "setreg"
def usage(self):
- return "[register]"
+ return "<register> [content]"
def descr(self):
- return "Puts the contents of stdin into a Neovim register."
+ return "Puts [content] into <register>. If no content is " + \
+ "provided, it is read from stdin"
def run(self, args):
register = args[0]
- lines = sys.stdin.read().splitlines()
+
+ if len(args) > 1:
+ lines = " ".join(args[1:])
+ else:
+ lines = sys.stdin.read()
+
+ lines = lines.splitlines()
if len(lines) == 1:
lines = lines[0]
@@ -48,6 +57,29 @@ class PutReg:
nvim.funcs.setreg(register, lines)
+class Feedkeys:
+
+ def name(self):
+ return "feedkeys"
+
+ def usage(self):
+ return "[args]"
+
+ def descr(self):
+ return "Feedkeys from args to neovim. If args is empty, stdin is used."
+
+ def run(self, args):
+ if len(args) < 1:
+ keys = sys.stdin.read()
+ else:
+ keys = "".join(args)
+
+ nvim.funcs.feedkeys(keys)
+
+
+commands = [GetReg(), PutReg(), Feedkeys()]
+
+
def print_help():
sys.stderr.write("USAGE %s <command> [args...]\n" % sys.argv[0])
sys.stderr.write("commands:\n")
@@ -55,8 +87,6 @@ def print_help():
sys.stderr.write("\t%s: %s\n" % (c.name(), c.descr()))
-commands = [GetReg(), PutReg()]
-
if len(sys.argv) < 2:
print_help()
sys.exit(1)