[
  {
    "path": ".gitignore",
    "content": ".sw?\n.*.sw?\n*.pyc\n"
  },
  {
    "path": "LICENSE",
    "content": "This is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or\ndistribute this software, either in source code form or as a compiled\nbinary, for any purpose, commercial or non-commercial, and by any\nmeans.\n\nIn jurisdictions that recognize copyright laws, the author or authors\nof this software dedicate any and all copyright interest in the\nsoftware to the public domain. We make this dedication for the benefit\nof the public at large and to the detriment of our heirs and\nsuccessors. We intend this dedication to be an overt act of\nrelinquishment in perpetuity of all present and future rights to this\nsoftware under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to <http://unlicense.org>\n\n"
  },
  {
    "path": "README.md",
    "content": "# Example Neovim Python Plugin\n\n- [Introduction](#introduction)\n- [Installing](#installing)\n    - [Downloading](#downloading)\n    - [Configuring Vim](#configuring-vim)\n    - [Python Version](#python_version)\n    - [Initializing Vim with Remote Plugin](#initializing)\n    - [Testing the New Plugin](#testing)\n- [Development](#development)\n    - [Debugging](#debugging)\n    - [Plugin Interface Changes](#changing-interface)\n- [Troubleshooting](#troubleshooting)\n    - [Refreshing the Manifest File](#refreshing-manifest)\n    - [Python Client Log File](#client-log-file)\n    - [Neovim Log File](#neovim-log-file)\n    - [Neovim Library](#neovim-library)\n- [References](#references)\n\n## <a id=\"introduction\"></a>Introduction\n\nAs part of the changes included in Neovim there is a new plugin model where\nplugins are separate processes which Neovim communicates to using the\nMessagePack protocol.\n\nSince plugins are distinct from the Neovim process, it is possible to write\nplugins in many languages.\n\nThis is a minimal example of a Python plugin. When you want to create a new\nPython plugin, you should be able to (and feel free to) copy this repository,\nrename a couple files, include the plugin in your Vim config and see something\nhappen.\n\n## <a id=\"installing\"></a>Installing\n\n### <a id=\"downloading\"></a>Downloading\n\nThe intention of this repository is to make it quick and easy to start a new\nplugin. It is just enough to show how to make the basics work.\n\n```Bash\ngit clone --depth 1 https://github.com/jacobsimpson/nvim-example-python-plugin ~/.vim/bundle/nvim-example-python-plugin\nrm -Rf ~/.vim/bundle/nvim-example-python-plugin/.git\n```\n\n### <a id=\"configuring-vim\"></a>Configuring Vim\n\nI use NeoBundle so this is an example of how to load this plugin in NeoBundle.\n\n```VimL\n\" Required:\ncall neobundle#begin(expand('~/.vim/bundle/'))\n\n    \" Let NeoBundle manage NeoBundle\n    \" Required:\n    NeoBundleFetch 'Shougo/neobundle.vim'\n\n    \" You probably have a number of other plugins listed here.\n\n    \" Add this line to make your new plugin load, assuming you haven't renamed it.\n    NeoBundle 'nvim-example-python-plugin'\ncall neobundle#end()\n```\n\nIf you use vim-plug, you can add this line to your plugin section:\n\n```VimL\nPlug 'jacobsimpson/nvim-example-python-plugin'\n```\n\nAfter running `:PlugInstall`, the files should appear in your `~/.config/nvim/plugged` directory (or whatever path you have configured for plugins).\n\n### <a id=\"python_version\"></a>Python Version\n\nThis plugin code works with Python 2. You can make it work with Python 3 by changing the `rplugin/python` directory to be `rplugin/python3`. See the [python-client remote plugin documentation](https://github.com/neovim/python-client#remote-new-style-plugins) for more information.\n\n### <a id=\"initializing\"></a>Initializing Vim with Remote Plugin\n\nThe next thing to do is to initialize the manifest for the Python part of the\nplugin. The manifest is a cache that Vim keeps of the interface implemented by\nthe Python part of the plugin. The functions and commands it implements.\n\nTo initialize the manifest, execute:\n\n```VimL\n:UpdateRemotePlugins\n```\n\n**NOTE:** After initializing the manifest, you must restart neovim for the python\nfunctions be be available.\n\n### <a id=\"testing\"></a>Testing the New Plugin\n\nThere is some VimL in the plugin that will print when Neovim is starting up:\n\n    Starting the example Python Plugin\n\nThat will confirm that the VimL portions of the plugin are loading correctly.\n\nThere is a function defined in the VimL portion of the plugin which echos some\ntext. You can execute the function like this:\n\n```VimL\n:exec DoItVimL()\n```\n\nNow that the manifest is initialized, it should be possible to invoke the\nfunction defined in the Python part of the plugin. Look in \\_\\_init\\_\\_ to see\nthe implementation.\n\n```VimL\n:exec DoItPython()\n```\n\n## <a id=\"development\"></a>Development\n\nOn it's own, this plugin doesn't do anything interesting, so the expectation is\nthat you will want to modify it.\n\n### <a id=\"debugging\"></a>Debugging\n\nIn order to take advantage of the Python REPL and make it easier to test changes in your Python code, I usually take the following steps:\n\n1. Open a Neovim instance.\n2. Open a terminal inside Neovim. (:term)\n3. Start the Python, or IPython, interpreter in the Neovim terminal. (python, ipython)\n4. Execute this code in the Python interpreter:\n```Python\nimport neovim\nimport os\n\nnvim = neovim.attach('socket', path=os.environ['NVIM_LISTEN_ADDRESS'])\n```\n\nAt this point, you can either execute commands directly against Neovim, to test the behavior of the interface:\n\n```Python\nnvim.current.buffer.name\n```\n\nor load your own plugin class and work with it directly.\n\n```Python\n%run \"rplugin/python/nvim-example-python-plugin.py\"\nm = Main(nvim)\nm.doItPython([])\n```\n\n### <a id=\"changing-interface\"></a>Plugin Interface Changes\n\nNeovim includes a step where the interface of the remote plugin is cached for\nNeovim, so that Neovim knows what functions and commands your plugin is making\navailable without having to wait while the external process containing the\nplugin is started.\n\n```VimL\n:UpdateRemotePlugins\n```\n\nRun this command for *every* change in the plugin interface. Without this, you\nmay see errors on from Neovim telling you methods are missing from your plugin.\nOr the new functionality you are trying to add just won't work.\n\n## <a id=\"troubleshooting\"></a>Troubleshooting\n\n### <a id=\"refreshing-manifest\"></a>Refreshing the Manifest File\n\nFor each change to the interface of the Python plugin, that is to say, any\nalterations to the @neovim decorators, you need to update Neovim's manifest\nfile:\n\n```VimL\n:UpdateRemotePlugins\n```\n\nRestart Neovim after you update to make the changes take effect.\n\nIf there is a syntax error in the Python file, it may result in the plugin not\nloading. There may be no visible error. If you run the update command, and the\ncommands and functions defined in the remote plugin are not available, the next\nuseful troubleshooting step is to load your plugin directly in a Python\ninterpreter to see if it works.\n\n### <a id=\"client-log-file\"></a>Python Client Log File\n\nDefine this environment variable to get output logged from your Python client.\n\n```Bash\nexport NVIM_PYTHON_LOG_FILE=${HOME}/.nvim-python.log\n```\n\nThe output files will have a number appended, and should be visible with this:\n\n```Bash\nls ${HOME}/.nvim-python.log*\n```\n\n### <a id=\"neovim-log-file\"></a>Neovim Log File\n\n```Bash\nls ~/.nvimlog\n```\n\n### <a id=\"neovim-library\"></a>Neovim Library\n\nOne problem I encountered when I was first getting started was the Python\nneovim module was not installed on my system. I didn't see any great errors\nthat lead me to that conclusion, so it is worth checking:\n\n```Bash\npython -c \"import neovim\"\n```\n\nShould execute without an error.\n\n## <a id=\"references\"></a>References\n- [Neovim Remote Plugin Documentation](http://neovim.io/doc/user/remote_plugin.html)\n\nThe Neovim docs for remote plugins. It's a little sparse, but captures the core\ndetail.\n\n- [Neovim Python Client](https://github.com/neovim/python-client)\n\nThe Neovim Python client is the Python API that wraps the MessagePack protocol\nNeovim uses to communicate with remote plugins. If you are looking for more\ninformation on how to use the vim parameter to the main object to control\nNeovim, this is the place to go.\n"
  },
  {
    "path": "doc/nvim-example-python-plugin.txt",
    "content": "*nvim-example-python-plugin.txt* A template of a remote Python plugin.\n\n                  Example Remote Python Plugin\n\n==============================================================================\n\nCONTENTS                                 *nvim-example-python-plugin-contents*\n\n    1. Introduction .................... |nvim-example-python-plugin-intro|\n\n\nOriginal Author:    Jacob Simpson\nLicense:            The Unlicense\n\nINTRODUCTION                                *nvim-example-python-plugin-intro*\n\nA very simple example of a Python plugin in the new remote plugin style used by\nNeovim.\n\n"
  },
  {
    "path": "doc/tags",
    "content": "nvim-example-python-plugin-contents\tnvim-example-python-plugin.txt\t/*nvim-example-python-plugin-contents*\nnvim-example-python-plugin-intro\tnvim-example-python-plugin.txt\t/*nvim-example-python-plugin-intro*\nnvim-example-python-plugin.txt\tnvim-example-python-plugin.txt\t/*nvim-example-python-plugin.txt*\n"
  },
  {
    "path": "plugin/nvim-example-python-plugin.vim",
    "content": "\n\" The VimL/VimScript code is included in this sample plugin to demonstrate the\n\" two different approaches but it is not required you use VimL. Feel free to\n\" delete this code and proceed without it.\n\necho \"Starting the example Python Plugin\"\n\nfunction DoItVimL()\n    echo \"hello from DoItVimL\"\nendfunction\n"
  },
  {
    "path": "rplugin/python/nvim-example-python-plugin.py",
    "content": "import neovim\n\n@neovim.plugin\nclass Main(object):\n    def __init__(self, vim):\n        self.vim = vim\n\n    @neovim.function('DoItPython')\n    def doItPython(self, args):\n        self.vim.command('echo \"hello from DoItPython\"')\n\n"
  }
]