Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 2.07 KB

README.md

File metadata and controls

44 lines (35 loc) · 2.07 KB

djist plugin for neovim

djist.nvim

A collection of Django niceties for Neovim. (Mostly based off of django-extensions.)

It currently offers following functionalities:

  • showViewURLS - A Flask like view of your views where the URLs corresponding to a view are shown on the side of the view. Only supports class based views for now. Example:
class ForumList(...) /forums/
...                  ^^^^^^^^
...

djist-working

Install

Install using your favorite plugin manager. For example, if you use vim-plug, put:

Plug 'pulsar17/djist'

in your vimrc, then :PlugInstall the plugin.

Usage

The DJANGO_SETTINGS_MODULE environment variable must be set to the correct settings module before running this plugin. This can be done by setting it while launching Neovim as follows:

$ DJANGO_SETTINGS_MODULE='<myproject>.settings' nvim

Note: Neovim must be started at the project root, as djist adds the current working directory to Python's sys.path so the settings module can be imported. Starting the editor at the project root is a good practice anyways.

For showViewURLS

Go anywhere inside the view and run :lua require'djist'.showViewURLS()

Inner Workings

For showViewURLS

  • djist first parses the current buffer and extracts the name of the view using treesitter.
  • After that djist detects the current virtual environment(using the VIRTUAL_ENV environment variable).
  • Then it launches the venv's Python interpreter with a script and provides the viewName as one of the arguments.
  • The script then finds the corresponding URLs for the view and prints them on its stdout which is monitored by djist (stdout is actually created and passed to the Python process by djist)
  • The launching of Python and monitoring of stdout is asynchronous, thanks to luvit (libuv bindings for Lua) provided by Neovim.