Created
July 19, 2016 15:23
-
-
Save mhinz/3e962884e41726ed93aa52a827e0de19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import os | |
from neovim import attach | |
# WORKING: | |
def make_func(num): | |
def func(): | |
num -= 1 | |
print(num) | |
return func | |
try: | |
make_func(5)() | |
except UnboundLocalError as e: | |
print('As expected: ' + str(e)) | |
# NOT WORKING: | |
def setup_cb(): | |
nvim.command('call rpcnotify({}, "foo")'.format(nvim.channel_id)) | |
def make_notification_cb(num): | |
def notification_cb(msg, _args): | |
# num -= 1 | |
print(str(num)) | |
nvim.stop_loop() | |
return notification_cb | |
notification_cb = make_notification_cb(5) | |
nvim = attach('child', argv=['nvim', '-u', 'NONE', '--embed']) | |
nvim.run_loop(None, notification_cb, setup_cb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment