
    ZgOU                       S r SSKJr  SSKrSSKrSSKrSSKrSSKJr  SSK	J
r
  SSKJr  SSKJrJrJrJrJrJrJrJrJr  SSKJr  SS	KJr  SS
KJrJrJrJrJ r J!r!J"r"J#r#  SSK$J%r%  SSK&J'r'  SSK(J)r)  \(       a  SSK*J+r+  \RX                  S:  a  SSK-J.r.  OSSKJ.r.  S/r/\R`                  r1Sr2 " S S5      r3 " S S\45      r5 " S S\45      r6 " S S\45      r7 " S S5      r8 " S S5      r9g)zMain Nvim interface.    )annotationsN)partial)format_stack)SimpleNamespace)	AnyAnyStrCallableDictIteratorListOptionalTYPE_CHECKINGUnion)ExtType)Buffer)	NvimErrorRemote	RemoteApi	RemoteMapRemoteSequenceTDecodeModedecode_if_byteswalk)Tabpage)Window)format_exc_skip)Session)      )LiteralNvima=  
local a = vim.api
local function update_highlights(buf, src_id, hls, clear_first, clear_end)
  if clear_first ~= nil then
      a.nvim_buf_clear_highlight(buf, src_id, clear_first, clear_end)
  end
  for _,hl in pairs(hls) do
    local group, line, col_start, col_end = unpack(hl)
    if col_start == nil then
      col_start = 0
    end
    if col_end == nil then
      col_end = -1
    end
    a.nvim_buf_add_highlight(buf, src_id, group, line, col_start, col_end)
  end
end

local chid = ...
local mod = {update_highlights=update_highlights}
_G["_pynvim_"..chid] = mod
c                  .   \ rS rSrSr\S+S j5       r\S,S j5       r  S-           S.S jjr\	S/S j5       r
S0S1S jjrS2S	 jrS3S
 jrS4S jrS5S jr  S6         S7S jjrS8S jrS8S jrS9S jrS:S jrS;S<S jjr S0         S=S jjrS8S jrS>S jrS?S jrS?S jrS@S jrSAS jrSBS jrS4S jrSCS jrSDS jr SES jr!SFS jr"SGS  jr#SHSIS! jjr$SJS" jr%   SK         SLS# jjr&SMS$ jr'SMS% jr(SNS& jr)SOSPS' jjr*SQS( jr+SRS) jr,S*r-g)Sr!   =   a  Class that represents a remote Nvim instance.

This class is main entry point to Nvim remote API, it is a wrapper
around Session instances.

The constructor of this class must not be called directly. Instead, the
`from_session` class method should be used to create the first instance
from a raw `Session` instance.

Subsequent instances for the same session can be created by calling the
`with_decode` instance method to change the decoding behavior or
`SubClass.from_nvim(nvim)` where `SubClass` is a subclass of `Nvim`, which
is useful for having multiple `Nvim` objects that behave differently
without one affecting the other.

When this library is used on python3.4+, asyncio event loop is guaranteed
to be used. It is available as the "loop" attribute of this class. Note
that asyncio callbacks cannot make blocking requests, which includes
accessing state-dependent attributes. They should instead schedule another
callback using nvim.async_call, which will not have this restriction.
c                    S Ul         UR                  S5      u  p#[        [        U5      nUS   S   S   [        US   S   S   [
        US   S   S   [        0nU " XX45      $ )zCreate a new Nvim instance for a Session instance.

This method must be called to create the first Nvim instance, since it
queries Nvim metadata for type information and sets a SessionHook for
creating specialized objects from Nvim remote handles.
c                0    [        [        U S   5      5      $ )N   )r   r   )es    1/usr/lib/python3/dist-packages/pynvim/api/nvim.py<lambda>#Nvim.from_session.<locals>.<lambda>\   s    )OAaD4I*J    s   nvim_get_api_infotypesr   idr   r   )error_wrapperrequestr   r   r   r   r   )clssession
channel_idmetadatar,   s        r(   from_sessionNvim.from_sessionT   s     !K&/CD
2 Wh'-vWh'-vWi(.
 788r+   c                    U " UR                   UR                  UR                  UR                  UR                  UR
                  5      $ )z5Create a new Nvim instance from an existing instance.)_sessionr2   r3   r,   _decode_err_cb)r0   nvims     r(   	from_nvimNvim.from_nvimi   s6     4==$//4==::t||T\\; 	;r+   Nc                8   Xl         X l        X0l        UR                  SSS05      n[	        S0 UD6U l        X@l        [        U S5      U l        [        U SSS5      U l
        [        U SS	S	5      U l        [        U S
S5      U l        [        U 5      U l        [        U S5      U l        [        U S5      U l        [%        U 5      U l        [)        U 5      U l        [-        U 5      U l        [1        U 5      U l        [4        U l        XPl        Uc	  S U l        g	X`l        g	)z>Initialize a new Nvim instance. This method is module-private.version	api_levelr   nvim_nvim_get_varnvim_set_varnvim_del_varnvim_get_vvarNnvim_get_optionnvim_set_optionnvim_list_winsnvim_list_tabpagesc                    g N )_s    r(   r)   Nvim.__init__.<locals>.<lambda>   s    4r+   rK   )r7   r2   r3   getr   r>   r,   r   apir   varsvvarsoptionsBuffersbuffersr   windowstabpagesCurrentcurrentCompatibilitySessionr1   FuncsfuncsLuaFuncsluar   errorr8   r9   )selfr1   r2   r3   r,   decodeerr_cbr>   s           r(   __init__Nvim.__init__o   s      $ ,,y;*:;&11
T7+dNNNS	t_dDA
 '8:KLt}/=dDT/U1?&2
 t}+D14[
D>
>1?DL!Lr+   c                B    U R                   R                  R                  $ )z)Get the event loop (exposed to rplugins).)r7   loop_loopr_   s    r(   re   	Nvim.loop   s     }}!!'''r+   c                    Uc  U R                   n[        U5      [        L a7  U R                  UR                     nU" XR                  UR
                  45      $ U(       a  [        X5      nU$ rJ   )r8   typer   r,   codedatar   )r_   objr`   r0   s       r(   
_from_nvimNvim._from_nvim   sX    >\\F9**SXX&Cthh122!#.C
r+   c                T    [        U[        5      (       a  [        UR                  6 $ U$ rJ   )
isinstancer   r   	code_data)r_   rm   s     r(   _to_nvimNvim._to_nvim   s#    c6""CMM**
r+   c                    [        U R                  SS5      (       d1  U R                  [        U R                  5        SU R                  l        [        U R                  SR                  U R                  5      5      $ )N_has_luaFTz
_pynvim_{})getattrr7   exec_lua
lua_moduler2   rv   r]   formatrg   s    r(   _get_lua_privateNvim._get_lua_private   sS    t}}j%88MM*doo6%)DMM"txx!4!4T__!EFFr+   c                   U R                   R                  b  [        R                  " 5       U R                   R                  :w  aT  SR	                  SR                  [        SS5      SS 5      5      nU R                  U R                  U5        [        S5      eUR                  SU R                  5      n[        U R                  U5      nU R                   R                  " U/UQ70 UD6n[        U R                  XeS9$ )	a  Send an API request or notification to nvim.

It is rarely needed to call this function directly, as most API
functions have python wrapper functions. The `api` object can
be also be used to call API functions as methods:

    vim.api.err_write('ERROR\n', async_=True)
    vim.current.buffer.api.get_mark('.')

is equivalent to

    vim.request('nvim_err_write', 'ERROR\n', async_=True)
    vim.request('nvim_buf_get_mark', vim.current.buffer, '.')


Normally a blocking request will be sent.  If the `async_` flag is
present and True, a asynchronous notification is sent instead. This
will never block, and the return value or error is ignored.
NzrRequest from non-main thread.
Requests from different threads should be wrapped with nvim.async_call(cb, ...) 
{}

   zrequest from non-main threadr`   )r`   )r7   _loop_thread	threadingcurrent_threadrz   joinr   
async_callr9   r   popr8   r   rs   r/   rn   )r_   nameargskwargsmsgr`   ress          r(   r/   Nvim.request   s    ( MM&&2,,.$--2L2LL: F499\$%:3B%?@A 
 OODLL#.:;;Hdll3DMM4(mm##D:4:6:DOOS88r+   c                r    U R                   R                  5       nU(       a  [        U R                  U5      $ g)zBlock until a message(request or notification) is available.

If any messages were previously enqueued, return the first in queue.
If not, run the event loop until one is received.
N)r7   next_messager   rn   )r_   r   s     r(   r   Nvim.next_message   s/     mm((*-- r+   c                   ^ ^^ Uc  [         R                  R                  nUT l        SUU 4S jjnSUU 4S jjnT R                  R                  XVU5        g)zRun the event loop to receive requests and notifications from Nvim.

This should not be called from a plugin running in the host, which
already runs the loop and dispatches events to plugins.
Nc                  > TR                  U 5      n [        TR                   U5      n T" X5      n[        TR                  U5      $ ! [         a.    SR                  X[	        S5      5      nTR                  U5        e f = f)Nz,error caught in request handler '{} {}'
{}

r&   )rn   r   	Exceptionrz   r   r9   rs   )r   r   resultr   
request_cbr_   s       r(   filter_request_cb(Nvim.run_loop.<locals>.filter_request_cb   s|    ??4(D.D#D/ v..  Ht?1+=> S!	s   A 8B c                   > TR                  U 5      n [        TR                   U5      n T" X5        g ! [         a.    SR                  X[	        S5      5      nTR                  U5        e f = f)Nz1error caught in notification handler '{} {}'
{}

r&   )rn   r   r   rz   r   r9   )r   r   r   notification_cbr_   s      r(   filter_notification_cb-Nvim.run_loop.<locals>.filter_notification_cb   se    ??4(D.D+ Mt?1+=> S!	s	   3 8A+)r   strr   r   returnr   )r   r   r   r   r   None)sysstderrwriter9   r7   run)r_   r   r   setup_cbra   r   r   s   ```    r(   run_loopNvim.run_loop   sK     >ZZ%%F
	/ 
	/		 		 	+XNr+   c                8    U R                   R                  5         g)z2Stop the event loop being started with `run_loop`.N)r7   stoprg   s    r(   	stop_loopNvim.stop_loop	  s    r+   c                8    U R                   R                  5         g)z1Close the nvim session and release its resources.N)r7   closerg   s    r(   r   
Nvim.close  s    r+   c                    U $ )z(Enter nvim session as a context manager.rK   rg   s    r(   	__enter__Nvim.__enter__  s    r+   c                $    U R                  5         g)z@Exit nvim session as a context manager.

Closes the event loop.
N)r   )r_   exc_infos     r(   __exit__Nvim.__exit__  s    
 	

r+   c                    [        U R                  U R                  U R                  U R                  XR
                  5      $ )zInitialize a new Nvim instance.)r!   r7   r2   r3   r,   r9   )r_   r`   s     r(   with_decodeNvim.with_decode  s0    DMM4??MM4::v||E 	Er+   c                :    UnUb  X5S'   U R                  SXU5      $ )zeRegister as a remote UI.

After this method is called, the client will receive redraw
notifications.
rgbnvim_ui_attachr/   )r_   widthheightr   r   rR   s         r(   	ui_attachNvim.ui_attach!  s)     ? EN||,eWEEr+   c                $    U R                  S5      $ )zUnregister as a remote UI.nvim_ui_detachr   rg   s    r(   	ui_detachNvim.ui_detach.  s    ||,--r+   c                &    U R                  SX5      $ )ziNotify nvim that the client window has resized.

If possible, nvim will send a redraw request to resize.
ui_try_resizer   )r_   r   r   s      r(   r   Nvim.ui_try_resize2  s    
 ||OU;;r+   c                &    U R                  SU5      $ )zSubscribe to a Nvim event.nvim_subscriber   r_   events     r(   	subscribeNvim.subscribe9  s    ||,e44r+   c                &    U R                  SU5      $ )zUnsubscribe to a Nvim event.nvim_unsubscriber   r   s     r(   unsubscribeNvim.unsubscribe=  s    ||.66r+   c                *    U R                   " SU40 UD6$ )zExecute a single ex command.nvim_commandr   r_   stringr   s      r(   commandNvim.commandA  s    ||NF=f==r+   c                &    U R                  SU5      $ )z2Execute a single ex command and return the output.nvim_command_outputr   r_   r   s     r(   command_outputNvim.command_outputE  s    ||16::r+   c                *    U R                   " SU40 UD6$ )z Evaluate a vimscript expression.	nvim_evalr   r   s      r(   eval	Nvim.evalI  s    ||K:6::r+   c                *    U R                   " SX40 UD6$ )zCall a vimscript function.nvim_call_functionr   )r_   r   r   r   s       r(   call	Nvim.callM  s    ||0$GGGr+   c                *    U R                   " SX40 UD6$ )a  Execute lua code.

Additional parameters are available as `...` inside the lua chunk.
Only statements are executed.  To evaluate an expression, prefix it
with `return`: `return my_function(...)`

There is a shorthand syntax to call lua functions with arguments:

    nvim.lua.func(1,2)
    nvim.lua.mymod.myfunction(data, async_=True)

is equivalent to

    nvim.exec_lua("return func(...)", 1, 2)
    nvim.exec_lua("mymod.myfunction(...)", data, async_=True)

Note that with `async_=True` there is no return value.
nvim_execute_luar   )r_   rk   r   r   s       r(   rx   Nvim.exec_luaQ  s    & ||.EfEEr+   c                &    U R                  SU5      $ )zSReturn the number of display cells `string` occupies.

Tab is counted as one cell.
nvim_strwidthr   r   s     r(   strwidthNvim.strwidthf  s    
 ||OV44r+   c                $    U R                  S5      $ )z=Return a list of paths contained in the 'runtimepath' option.nvim_list_runtime_pathsr   rg   s    r(   list_runtime_pathsNvim.list_runtime_pathsm  s    ||566r+   c                l    U R                  5        H  n U" U5      b    gM     g! [         a       gf = f)a<  Invoke `cb` for each path in 'runtimepath'.

Call the given callable for each path in 'runtimepath' until either
callable returns something but None, the exception is raised or there
are no longer paths. If stopped in case callable returned non-None,
vim.foreach_rtp function returns the value returned by callable.
N)r   r   )r_   cbpaths      r(   foreach_rtpNvim.foreach_rtpq  sB     ++-Dd8' ( .  s   	%
33c                <    [        U5        U R                  SU5      $ )z-Run os.chdir, then all appropriate vim stuff.nvim_set_current_dir)os_chdirr/   )r_   dir_paths     r(   chdir
Nvim.chdir  s    ||2H==r+   c                (    U R                  SXU5      $ )z&Push `keys` to Nvim user input buffer.nvim_feedkeysr   )r_   keysrR   
escape_csis       r(   feedkeysNvim.feedkeys  s    ||OTJGGr+   c                &    U R                  SU5      $ )zPush `bytes` to Nvim low level input buffer.

Unlike `feedkeys()`, this uses the lowest level input buffer and the
call is not deferred. It returns the number of bytes actually
written(which can be less than what was requested if the buffer is
full).

nvim_inputr   )r_   bytess     r(   input
Nvim.input  s     ||L%00r+   c                *    U R                  SUX#U5      $ )a  Replace any terminal code strings by byte sequences.

The returned sequences are Nvim's internal representation of keys,
for example:

<esc> -> '\x1b'
<cr>  -> '\r'
<c-l> -> '\x0c'
<up>  -> '\x80ku'

The returned sequences can be used as input to `feedkeys`.
nvim_replace_termcodesr   )r_   r   	from_partdo_ltspecials        r(   replace_termcodesNvim.replace_termcodes  s    & ||4f%g7 	7r+   c                *    U R                   " SU40 UD6$ )zaPrint `msg` as a normal message.

The message is buffered (won't display) until linefeed ("\n").
nvim_out_writer   r_   r   r   s      r(   	out_writeNvim.out_write  s    
 ||,c<V<<r+   c                    U R                  5       (       a  U R                  " U R                  U40 UD6  gU R                  " SU40 UD6$ )zaPrint `msg` as an error message.

The message is buffered (won't display) until linefeed ("\n").
Nnvim_err_write)_thread_invalidr   	err_writer/   r  s      r(   r  Nvim.err_write  sF    
 !! OODNNC:6:||,c<V<<r+   c                    U R                   R                  S L=(       a,    [        R                  " 5       U R                   R                  :g  $ rJ   )r7   r   r   r   rg   s    r(   r  Nvim._thread_invalid  s;    **$6 M,,.$--2L2LL	Nr+   c                H     U R                  U5        g! [         a     gf = f)zwSend a quit command to Nvim.

By default, the quit command is 'qa!' which will make Nvim quit without
saving anything.
N)r   OSError)r_   quit_commands     r(   quit	Nvim.quit  s'    	LL& 	 		s    
!!c                L    U R                   R                  R                  SSSS9$ )z4Return new src_id for use with Buffer.add_highlight. r   )src_id)rX   bufferadd_highlightrg   s    r(   new_highlight_sourceNvim.new_highlight_source  s$    ||""00Qq0AAr+   c                   ^ ^^^^ SR                  [        SS5      SS 5      mSUUUUU 4S jjnT R                  R                  U5        g)a2  Schedule `fn` to be called by the event loop soon.

This function is thread-safe, and is the only way code not
on the main thread could interact with nvim api objects.

This function can also be called in a synchronous
event handler, just before it returns, to defer execution
that shouldn't block neovim.
r  Nr   r   c                    >  T" T0 TD6  g ! [          a3  n SR                  U [        S5      T5      nTR                  U5        e S n A ff = f)NzSerror caught while executing async callback:
{!r}
{}
 
the call was requested at
{}r&   )r   rz   r   r9   )errr   r   
call_pointfnr   r_   s     r(   handler Nvim.async_call.<locals>.handler  sT    D#F# DsOA$6
C  S!s    
A	.AA	r   r   )r   r   r7   threadsafe_call)r_   r&  r   r   r'  r%  s   ```` @r(   r   Nvim.async_call  s?     WW\$23B78
	 	 	%%g.r+   )r8   r9   r7   rO   rT   r2   rX   r^   r[   r]   r3   rR   r1   rV   r,   rP   r>   rQ   rU   )r1   r   r   r!   )r:   r!   r   r!   )TN)r1   r   r2   intr3   zDict[str, Any]r,   zDict[int, Any]r`   r   ra   zOptional[Callable[[str], None]])r   zasyncio.AbstractEventLooprJ   )rm   r   r`   zOptional[TDecodeMode]r   r   )rm   r   r   r   )r   r\   )r   r   r   r   r   r   r   r   )r   r   )NN)
r   )Optional[Callable[[str, List[Any]], Any]]r   r-  r   zOptional[Callable[[], None]]ra   zOptional[Callable[[str], Any]]r   r   r)  )r   r!   )r   r   r   r   )T)r`   zLiteral[True]r   r!   )
r   r,  r   r,  r   zOptional[bool]r   r   r   r   )r   r,  r   r,  r   r   )r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   )rk   r   r   r   r   r   r   r   )r   r   r   r,  )r   z	List[str])r   zCallable[[str], Any]r   r   )r   r   r   r   )r  T)r   r   rR   r   r   boolr   r   )r   r   r   r,  )FTT)
r   r   r  r.  r  r.  r  r.  r   r   )r   r   r   r   r   r   )r   r.  )zqa!)r  r   r   r   r   r,  )r&  Callable[..., Any]r   r   r   r   r   r   ).__name__
__module____qualname____firstlineno____doc__classmethodr4   r;   rb   propertyre   rn   rs   r{   r/   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rx   r   r   r   r   r   r  r  r  r  r  r  r   r   __static_attributes__rK   r+   r(   r!   r!   =   s   , 9 9( ; ; #26"""" "" !	""
 "" "" 0""H ( (
G"9H. 2615'O='O C'O /	'O
 /'O 
'ORE >BFF"%F,:FMPF	F.<57>;;HF*57>
H1  77 7 	7
 7 
7,==NB/r+   c                  J    \ rS rSrSrS
S jrSS jrSS jrSS jrSS jr	Sr
g	)rS   i  zRemote NVim buffers.

Currently the interface for interacting with remote NVim buffers is the
`nvim_list_bufs` msgpack-rpc function. Most methods fetch the list of
buffers from NVim.

Conforms to *python-buffers*.
c                :    UR                   R                  U l        g)z4Initialize a Buffers object with Nvim object `nvim`.N)rO   	list_bufs_fetch_buffersr_   r:   s     r(   rb   Buffers.__init__  s    "hh00r+   c                4    [        U R                  5       5      $ )zReturn the count of buffers.)lenr<  rg   s    r(   __len__Buffers.__len__  s    4&&())r+   c                n    U R                  5        H  nUR                  U:X  d  M  Us  $    [        U5      e)z9Return the Buffer object matching buffer number `number`.)r<  numberKeyError)r_   rD  bs      r(   __getitem__Buffers.__getitem__  s3    $$&Axx6! ' vr+   c                H    [        U[        5      =(       a    UR                  $ )z2Return whether Buffer `b` is a known valid buffer.)rq   r   valid)r_   rF  s     r(   __contains__Buffers.__contains__  s    !V$00r+   c                4    [        U R                  5       5      $ )z,Return an iterator over the list of buffers.)iterr<  rg   s    r(   __iter__Buffers.__iter__	  s    D'')**r+   )r<  Nr:   r!   r/  )rD  r,  r   r   )rF  r   r   r.  )r   zIterator[Buffer])r1  r2  r3  r4  r5  rb   rA  rG  rK  rO  r8  rK   r+   r(   rS   rS     s     1*1+r+   rS   c                  "    \ rS rSrSrSS jrSrg)rY   i  z#Helper class for API compatibility.c                &    UR                   U l        g rJ   )r   r*  r=  s     r(   rb   CompatibilitySession.__init__  s    #r+   )r*  NrQ  )r1  r2  r3  r4  r5  rb   r8  rK   r+   r(   rY   rY     s
    -/r+   rY   c                  :   \ rS rSrSrSS jr\SS j5       r\R                  SS j5       r\R                  SS j5       r\SS j5       r
\
R                  SS j5       r
\SS	 j5       r\R                  SS
 j5       r\SS j5       r\R                  SS j5       rSrg)rW   i  z7Helper class for emulating vim.current from python-vim.c                    Xl         S U l        g rJ   r7   range)r_   r1   s     r(   rb   Current.__init__  s    
r+   c                8    U R                   R                  S5      $ )Nnvim_get_current_liner7   r/   rg   s    r(   lineCurrent.line      }}$$%<==r+   c                :    U R                   R                  SU5      $ )Nnvim_set_current_liner\  )r_   r]  s     r(   r]  r^  "  s    }}$$%<dCCr+   c                8    U R                   R                  S5      $ )Nnvim_del_current_liner\  rg   s    r(   r]  r^  &  r_  r+   c                8    U R                   R                  S5      $ )Nnvim_get_current_bufr\  rg   s    r(   r  Current.buffer*      }}$$%;<<r+   c                :    U R                   R                  SU5      $ )Nnvim_set_current_bufr\  )r_   r  s     r(   r  rf  .      }}$$%;VDDr+   c                8    U R                   R                  S5      $ )Nnvim_get_current_winr\  rg   s    r(   windowCurrent.window2  rg  r+   c                :    U R                   R                  SU5      $ )Nnvim_set_current_winr\  )r_   rm  s     r(   rm  rn  6  rj  r+   c                8    U R                   R                  S5      $ )Nnvim_get_current_tabpager\  rg   s    r(   tabpageCurrent.tabpage:  s    }}$$%?@@r+   c                :    U R                   R                  SU5      $ )Nnvim_set_current_tabpager\  )r_   rs  s     r(   rs  rt  >  s    }}$$%?IIr+   rW  N)r1   r!   )r   r   )r]  r   r   r   r)  )r   r   )r  zUnion[Buffer, int]r   r   )r   r   )rm  zUnion[Window, int]r   r   )r   r   )rs  zUnion[Tabpage, int]r   r   )r1  r2  r3  r4  r5  rb   r7  r]  setterdeleterr  rm  rs  r8  rK   r+   r(   rW   rW     s    A > > 
[[D D 
\\> > = = ]]E E = = ]]E E A A ^^J Jr+   rW   c                  ,    \ rS rSrSrSS jrSS jrSrg)	rZ   iC  z0Helper class for functional vimscript interface.c                    Xl         g rJ   _nvimr=  s     r(   rb   Funcs.__init__F  s    
r+   c                B    [        U R                  R                  U5      $ rJ   )r   r|  r   )r_   r   s     r(   __getattr__Funcs.__getattr__I  s    tzz--r+   r{  NrQ  )r   r   r   r0  )r1  r2  r3  r4  r5  rb   r  r8  rK   r+   r(   rZ   rZ   C  s    :.r+   rZ   c                  :    \ rS rSrSrSS	S jjrS
S jrSS jrSrg)r\   iM  z@Wrapper to allow lua functions to be called like python methods.c                    Xl         X l        g rJ   r|  r   )r_   r:   r   s      r(   rb   LuaFuncs.__init__P  s    
	r+   c                v    U R                   (       a  U R                   S-   OSn[        U R                  X!-   5      $ )z#Return wrapper to named api method..r  )r   r\   r|  )r_   r   prefixs      r(   r  LuaFuncs.__getattr__T  s*    $(IIS2

FM22r+   c                    SU;   a  [        S5      eUR                  SS5      nU(       d  SOSnUR                  U R                  5      nU R                  R
                  " U/UQ70 UD6$ )Nasyncz6"async" argument is not allowed. Use "async_" instead.async_Fzreturn {}(...)z{}(...))
ValueErrorrN   rz   r   r|  rx   )r_   r   r   r  patternrk   s         r(   __call__LuaFuncs.__call__Y  sg    f 5 6 6He,*0"i~~dii(zz""49$9&99r+   r  N)r  )r:   r!   r   r   )r   r   r   r\   )r   r   r   r   r   r   )	r1  r2  r3  r4  r5  rb   r  r  r8  rK   r+   r(   r\   r\   M  s    J3
:r+   r\   ):r5  
__future__r   asyncioosr   r   	functoolsr   	tracebackr   r,   r   typingr   r   r	   r
   r   r   r   r   r   msgpackr   pynvim.api.bufferr   pynvim.api.commonr   r   r   r   r   r   r   r   pynvim.api.tabpager   pynvim.api.windowr   pynvim.utilr   pynvim.msgpack_rpcr   version_infotyping_extensionsr    __all__r   r   ry   r!   objectrS   rY   rW   rZ   r\   rK   r+   r(   <module>r     s     "  	 
   " !* * *  $C C C & $ '*f)( 88
0k/ k/\ +f  +F/6 /*Jf *JZ. .: :r+   