:echo has('python')
and/or :echo has('python3')
from Vim)Omnipytent is a plugin for creating and running project-specific, user-specific tasks. Programmers should know enough about to programming to be able to script their own workflow - and Omnipytent aims to make this as simple, as accessible and as out-of-your-way as possible. Omnipytent is the successor to Integrake, and follows a similar design - but in Python, so it could be used in neovim(which did not have Ruby support at the time)
Blog posts:
omnipytent.ext
module. Also useful for importing common sets of tasks.Set the file prefix and default python version in your .vimrc
- something like:
let g:omnipytent_filePrefix = '.moshecohen' " Replace with your own (user)name
let g:omnipytent_defaultPythonVersion = 3 " Or 2, if you want to use Python 2
Open Vim in the root directory of your project - let's assume it's a C project with a Makefile. To create a tasks file for this project, run:
:OPedit build
This will generate a brand new tasks file that looks like this:
import vim
from omnipytent import *
To create your first task, run:
:OPedit build
This will append a new task to the tasks file:
@task
def build(ctx):
<cursor here in insert mode>
Now write the body of the task:
@task
def build(ctx):
CMD.make('--quiet')
Omnipytent's CMD
object can be used to run Vim commands - so this task will
run the Vim command :make --quiet
and build your project. To activate it, run:
:OP build
Let's create more tasks. You don't have to use :OPedit
- you can just
copy-paste the build
task and modify it:
@task
def run(ctx):
BANG('./a.out', 'hello', 'world')
@task
def debug(ctx):
TERMINAL_PANEL('gdb', './a.out')
BANG
can be used to run shell command - so running this task with :OP run
is the same as running:
:!./a.out hello world
Because gdb
is an interactive program, we can't run it with regular :!
- we
need :terminal
- so we use TERMINAL_PANEL
. There is also TERMINAL_TAB
that opens the terminal in another tab.
And that's it - you have a tasks file with three tasks to build, run and debug your code. You can add more tasks that do different things.
Few important usability notes:
:OP
without arguments to get a prompt for picking the task you
want to run.:OPedit
again to go back to the tasks file.:OPedit build
will not create a new task - it will jump to the
existing build
task instead.For advanced usage tips, refer to the wiki.
For more detailed documentation, refer to :help omnipytent
.