Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Yet Another Remote Plugin Framework for Neovim

License

NotificationsYou must be signed in to change notification settings

roxma/nvim-yarp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is my attempt on writing a remote plugin framework without:UpdateRemotePlugins.

Requirements

  • has('python3')
  • For Vim 8:

Installation

WithVim-Plug, use:

" Required for vim 8    Plug'roxma/vim-hug-neovim-rpc'" Install this plugin    Plug'roxma/nvim-yarp', {'do':'pip install -r requirements.txt' }

Use case

Usage

pythonx/hello.py

importvim,timedefgreet():time.sleep(3)vim.command('echo "Hello world"')

plugin/hello.vim

" Create a python3 process running the hello module. The process is lazy load.lets:hello=yarp#py3('hello')com HelloSynccalls:hello.request('greet')com HelloAsynccalls:hello.notify('greet')" You could type :Hello greetcom -nargs=1 Hellocalls:hello.request(<f-args>)

Debugging

Add logging settigns to your vimrc. Log files will be generated with prefix/tmp/nvim_log. An alternative is to export environment variables beforestarting vim/nvim.

let$NVIM_PYTHON_LOG_FILE="/tmp/nvim_log"let$NVIM_PYTHON_LOG_LEVEL="DEBUG"

Options

let s:yarp.on_load = function('your_handler')

A handler that is called after your python module is loaded. It is notconsidered ready for request or notification from vimscript during loadingstage.s:yarp.request ands:yarp.notify internally wait untilon_loadbefore sending actual request and notification.

Methods

call s:yarp.reqeust({event}, [, {args}...])

Similiar to:help rpcrequest. It sends a request to the rpc channel andreturns the result of your python method.

call s:yarp.rpcnotify({event}, [, {args}...])

Similiar to:help rpcnotify. It sends a notification to the rpc channel andreturns immediately.

call s:yarp.error(msg)

Print error message.

call s:yarp.warn(msg)

Print warning message.

Example for existing neovim rplugin porting to Vim 8

More realistic examples could be found atnvim-typescript#84,deoplete#553,callmekohei/quickdebug.

Now let's consider the following simple rplugin.

AfterUpdateRemotePlugins and restarting neovim, you getfoobar by:echo Bar().

# rplugin/python3/foo.pyimportpynvim@pynvim.pluginclassFoo(object):def__init__(self,vim):self._vim=vim@pynvim.function("Bar",sync=True)defbar(self,args):return'hello'+str(args)

For working on Vim 8, you need to add these two files:

" plugin/foo.vimifhas('nvim')finishendiflets:foo=yarp#py3('foo_wrap')func!Bar(v)returns:foo.call('bar',a:v)endfunc
# pythonx/foo_wrap.pyfromfooimportFooas_Fooimportvim_obj=_Foo(vim)defbar(*args):return_obj.bar(args)

How to use

$ vim: echo bar('world')hello('world',)

About

Yet Another Remote Plugin Framework for Neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors4

  •  
  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp