-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version of a simple Python plugin.
A simple Python remote plugin for Neovim. Is working for Neovim: NVIM 0.0.0-alpha+201507262350 (compiled Jul 29 2015 22:40:18)
- Loading branch information
1 parent
ce84b93
commit 12daa7b
Showing
7 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Example Python Plugin for Neovim | ||
|
||
As part of the changes included in Neovim there is a new plugin model where | ||
plugins are separate processes which Neovim communicates to using the | ||
MessagePack protocol. | ||
|
||
Since plugins are distinct from the Neovim process, it is possible to write | ||
plugins in many languages. | ||
|
||
This is a minimal example of a Python plugin. You should be able to (and feel | ||
free to) copy this repository, rename a couple files, include the plugin in | ||
your Vim config and see something happen. | ||
|
||
## Making a New Plugin | ||
|
||
The intention of this repository is to make it quick and easy to start a new | ||
plugin. It is just enough to show how to make the basics work. | ||
|
||
```Bash | ||
git clone --depth 1 https://github.com/jacobsimpson/nvim-example-python-plugin ~/.vim/bundles | ||
rm -Rf ~/.vim/bundles/nvim-example-python-plugin/.git | ||
``` | ||
|
||
## Configuring Vim | ||
|
||
I use NeoBundle so this is an example of how to load this plugin in NeoBundle. | ||
|
||
```VimL | ||
" Required: | ||
call neobundle#begin(expand('~/.vim/bundle/')) | ||
" Let NeoBundle manage NeoBundle | ||
" Required: | ||
NeoBundleFetch 'Shougo/neobundle.vim' | ||
" You probably have a number of other plugins listed here. | ||
" Add this line to make your new plugin load, assuming you haven't renamed it. | ||
NeoBundle 'nvim-example-python-plugin' | ||
call neobundle#end() | ||
``` | ||
|
||
## Confirming the Plugin Loaded | ||
|
||
There is some VimL in the plugin that will print when Neovim is starting up: | ||
|
||
Starting the example Python Plugin | ||
|
||
That will confirm that the VimL portions of the plugin are loading correctly. | ||
That does not guarantee that the Python portions of the plugin are loading. | ||
|
||
It should create a function that can be called. | ||
|
||
```VimL | ||
:exec DoItVimL() | ||
``` | ||
|
||
```VimL | ||
:exec DoItPython() | ||
``` | ||
|
||
It should add some mapped key handlers. | ||
|
||
## Changing the Interface | ||
|
||
Neovim includes a process whereby the interface of the remote plugin are cached | ||
for Neovim. | ||
|
||
```VimL | ||
:UpdateRemotePlugins | ||
``` | ||
|
||
Run this command for *every* change in the plugin interface. Without this, you | ||
may see errors on from Neovim telling you methods are missing from your plugin. | ||
Or the new functionality you are trying to add just won't work. | ||
|
||
## Troubleshooting | ||
|
||
### Python Client Log File | ||
|
||
Define this environment variable to get output logged from your Python client. | ||
|
||
```Bash | ||
export NVIM_PYTHON_LOG_FILE=${HOME}/.nvim-python.log | ||
``` | ||
|
||
The output files will have a number appended, and should be visible with this: | ||
|
||
```Bash | ||
ls ${HOME}/.nvim-python.log* | ||
``` | ||
|
||
### Neovim Log File | ||
|
||
```Bash | ||
ls ~/.nvimlog | ||
``` | ||
|
||
### Neovim Library | ||
|
||
I found that the Python neovim module was not installed on my system. I didn't | ||
see any great errors that lead me to that conclusion, so it is worth checking: | ||
|
||
```Bash | ||
python -c "import neovim" | ||
``` | ||
|
||
Should execute without an error. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
*nvim-example-python-plugin.txt* A template of a remote Python plugin. | ||
|
||
Example Remote Python Plugin | ||
|
||
============================================================================== | ||
|
||
CONTENTS *nvim-example-python-plugin-contents* | ||
|
||
1. Introduction .................... |nvim-example-python-plugin-intro| | ||
|
||
|
||
Original Author: Jacob Simpson | ||
License: The Unlicense | ||
|
||
INTRODUCTION *nvim-example-python-plugin-intro* | ||
|
||
A very simple example of a Python plugin in the new remote plugin style used by | ||
Neovim. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
nvim-example-python-plugin-contents nvim-example-python-plugin.txt /*nvim-example-python-plugin-contents* | ||
nvim-example-python-plugin-intro nvim-example-python-plugin.txt /*nvim-example-python-plugin-intro* | ||
nvim-example-python-plugin.txt nvim-example-python-plugin.txt /*nvim-example-python-plugin.txt* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
echo "Starting the example Python Plugin" | ||
|
||
function DoItVimL() | ||
echo "DoItVimL" | ||
endfunction |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Autocmd: Called file: nvim-example-python-plugin.py |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import neovim | ||
|
||
@neovim.plugin | ||
class Limit(object): | ||
def __init__(self, vim): | ||
self.vim = vim | ||
|
||
@neovim.function('DoItPython') | ||
def function_handler(self, args): | ||
self.vim.command('echo "hello"') | ||
|
Binary file not shown.