@@ -43,7 +43,7 @@ def dec(f):
4343
4444
4545def 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 ):
4747 """Tag a function or plugin method as a Nvim command handler."""
4848 def dec (f ):
4949 f ._nvim_rpc_method_name = 'command:{}' .format (name )
@@ -73,17 +73,22 @@ def dec(f):
7373 if eval :
7474 opts ['eval' ] = eval
7575
76+ if not sync and allow_nested :
77+ rpc_sync = "urgent"
78+ else :
79+ rpc_sync = sync
80+
7681 f ._nvim_rpc_spec = {
7782 'type' : 'command' ,
7883 'name' : name ,
79- 'sync' : sync ,
84+ 'sync' : rpc_sync ,
8085 'opts' : opts
8186 }
8287 return f
8388 return dec
8489
8590
86- def autocmd (name , pattern = '*' , sync = False , eval = None ):
91+ def autocmd (name , pattern = '*' , sync = False , allow_nested = False , eval = None ):
8792 """Tag a function or plugin method as a Nvim autocommand handler."""
8893 def dec (f ):
8994 f ._nvim_rpc_method_name = 'autocmd:{}:{}' .format (name , pattern )
@@ -98,17 +103,22 @@ def dec(f):
98103 if eval :
99104 opts ['eval' ] = eval
100105
106+ if not sync and allow_nested :
107+ rpc_sync = "urgent"
108+ else :
109+ rpc_sync = sync
110+
101111 f ._nvim_rpc_spec = {
102112 'type' : 'autocmd' ,
103113 'name' : name ,
104- 'sync' : sync ,
114+ 'sync' : rpc_sync ,
105115 'opts' : opts
106116 }
107117 return f
108118 return dec
109119
110120
111- def function (name , range = False , sync = False , eval = None ):
121+ def function (name , range = False , sync = False , allow_nested = False , eval = None ):
112122 """Tag a function or plugin method as a Nvim function handler."""
113123 def dec (f ):
114124 f ._nvim_rpc_method_name = 'function:{}' .format (name )
@@ -124,10 +134,15 @@ def dec(f):
124134 if eval :
125135 opts ['eval' ] = eval
126136
137+ if not sync and allow_nested :
138+ rpc_sync = "urgent"
139+ else :
140+ rpc_sync = sync
141+
127142 f ._nvim_rpc_spec = {
128143 'type' : 'function' ,
129144 'name' : name ,
130- 'sync' : sync ,
145+ 'sync' : rpc_sync ,
131146 'opts' : opts
132147 }
133148 return f
0 commit comments