@@ -43,7 +43,7 @@ def dec(f):
43
43
44
44
45
45
def command (name , nargs = 0 , complete = None , range = None , count = None , bang = False ,
46
- register = False , sync = False , eval = None ):
46
+ register = False , sync = False , allow_nested = False , eval = None ):
47
47
"""Tag a function or plugin method as a Nvim command handler."""
48
48
def dec (f ):
49
49
f ._nvim_rpc_method_name = 'command:{}' .format (name )
@@ -73,17 +73,22 @@ def dec(f):
73
73
if eval :
74
74
opts ['eval' ] = eval
75
75
76
+ if not sync and allow_nested :
77
+ rpc_sync = "urgent"
78
+ else :
79
+ rpc_sync = sync
80
+
76
81
f ._nvim_rpc_spec = {
77
82
'type' : 'command' ,
78
83
'name' : name ,
79
- 'sync' : sync ,
84
+ 'sync' : rpc_sync ,
80
85
'opts' : opts
81
86
}
82
87
return f
83
88
return dec
84
89
85
90
86
- def autocmd (name , pattern = '*' , sync = False , eval = None ):
91
+ def autocmd (name , pattern = '*' , sync = False , allow_nested = False , eval = None ):
87
92
"""Tag a function or plugin method as a Nvim autocommand handler."""
88
93
def dec (f ):
89
94
f ._nvim_rpc_method_name = 'autocmd:{}:{}' .format (name , pattern )
@@ -98,17 +103,22 @@ def dec(f):
98
103
if eval :
99
104
opts ['eval' ] = eval
100
105
106
+ if not sync and allow_nested :
107
+ rpc_sync = "urgent"
108
+ else :
109
+ rpc_sync = sync
110
+
101
111
f ._nvim_rpc_spec = {
102
112
'type' : 'autocmd' ,
103
113
'name' : name ,
104
- 'sync' : sync ,
114
+ 'sync' : rpc_sync ,
105
115
'opts' : opts
106
116
}
107
117
return f
108
118
return dec
109
119
110
120
111
- def function (name , range = False , sync = False , eval = None ):
121
+ def function (name , range = False , sync = False , allow_nested = False , eval = None ):
112
122
"""Tag a function or plugin method as a Nvim function handler."""
113
123
def dec (f ):
114
124
f ._nvim_rpc_method_name = 'function:{}' .format (name )
@@ -124,10 +134,15 @@ def dec(f):
124
134
if eval :
125
135
opts ['eval' ] = eval
126
136
137
+ if not sync and allow_nested :
138
+ rpc_sync = "urgent"
139
+ else :
140
+ rpc_sync = sync
141
+
127
142
f ._nvim_rpc_spec = {
128
143
'type' : 'function' ,
129
144
'name' : name ,
130
- 'sync' : sync ,
145
+ 'sync' : rpc_sync ,
131
146
'opts' : opts
132
147
}
133
148
return f
0 commit comments