Create a plugin to run Python Doctest in Vim (2)

Introduction

This is a continuation of "Create a plugin to execute Python Doctest with Vim (1)". We have created a plug-in that works as it is, so we will publish it.

https://github.com/daizutabi/unite-greater3

The screenshot is shown below.

スクリーンショット

greater3 plugin

This plugin is named greater3. The following is an excerpt from the help.

The greater3 plugin runs the Python doctest. Since it also supports standard output and standard error output, it can also be used to execute Python modules.

Overview

greater3 is a Vim plugin that runs doctest on the Python file you are editing. The results of the executed doctest are listed using the Unite interface. You can jump to the doctest of the original file from the list, or use the output of doctest to rewrite the source code of the original file. In addition, the standard output stdout and standard error output stderr are also displayed on the Unite interface, so they can be used instead of QuickRun. Since the module specified in the import statement is not imported for each execution, the startup time can be expected to be shortened.

Requirements: --Vim 7.4 or later --Python 3.5 or later

Latest edition: http://github.com/daizutabi/unite-greater3

Run current buffer

:Unite greater3

Shortcut key assignment. Example: When assigning to F10. With ~ / vimfiles / after / ftplugin / python.vim etc.

nnoremap <silent> <buffer> <F10> :<C-u>Unite greater3<CR>

Working with the Unite buffer

Key mapping

You can assign the execution of Unite greater3 to a shortcut key. With ~ / vimfiles / after / ftplugin / python.vim etc.

	nnoremap <silent> <buffer> <F10> :<C-u>Unite greater3<CR>

will do.

Key mapping in the Unite buffer is done by setting an alias for the standard action. Specifically, the alias_table of the greater3 source is set as follows.

alias_table = {'*': {'delete': 'toggle', 'bookmark': 'toggle_entire',
\                    'edit': 'entire', 'yank': 'replace'}}

This setting can be changed with g: greater3.alias.

Setting

You can customize the behavior using the global variable g: greater3. The default settings are executed when the Python file is first loaded. To overwrite it, write a setting to overwrite it in ~ / vimfiles / after / ftplugin / python.vim etc.

Cooperation with status line plugin

Use g: greater3.statusline to set the linkage with the statusline plugin. Currently, it supports cooperation with lightline.

By setting g: greater3.statusline ='lighline', the cooperation with lightline becomes effective. Specifically, the result of doctest is displayed in color on the status line. In practice, the above settings are done by default.

Please set as follows in the .vimrc / _vimrc file.

"Prohibits Unite from overwriting the status line.
let g:unite_force_overwrite_statusline = 0

" g:Wherever you like the acitve element of the lightline'greater3'Place.
"For example
let g:lightline = {
\ 'colorscheme': 'solarized',
\ 'mode_map': {'c': 'NORMAL'},
\ 'active': {
\   'left': [['mode', 'paste'],
\            ['fugitive', 'filename', 'greater3']],
\  }
 \}

'greater3' is treated as the expansion component of lightline.

Recommended Posts

Create a plugin to run Python Doctest in Vim (2)
Create a plugin to run Python Doctest in Vim (1)
Write a vim plugin in Python
Write a simple Vim Plugin in Python 3
I want to create a window in Python
How to create a JSON file in Python
Create a Wox plugin (Python)
Create a shortcut to run a Python file in VScode on your terminal
Create a function in Python
Create a dictionary in Python
A memorandum to run a python script in a bat file
Create a DI Container in Python
Create a binary file in Python
Create a Kubernetes Operator in Python
5 Ways to Create a Python Chatbot
Run a simple algorithm in Python
Create a random string in Python
Create a tool to check scraping rules (robots.txt) in Python
Create a simple GUI app in Python
Create a shell script to run the python file multiple times
Create a JSON object mapper in Python
How to create a heatmap with an arbitrary domain in Python
Run the Python interpreter in a script
How to get a stacktrace in python
[GPS] Create a kml file in Python
How to run a Maya Python script
I made a plugin to generate Markdown table from csv in Vim
[Python] [Word] [python-docx] Try to create a template of a word sentence in Python using python-docx
What is the fastest way to create a reverse dictionary in python?
[Python] List Comprehension Various ways to create a list
Edit Excel from Python to create a PivotTable
Try to calculate a statistical problem in Python
How to create a Python virtual environment (venv)
To execute a Python enumerate function in JavaScript
How to embed a variable in a python string
Type Python scripts to run in QGIS Processing
Create a standard normal distribution graph in Python
Create a virtual environment with conda in Python
A clever way to time processing in Python
Steps to develop a web application in Python
Steps to create a Twitter bot with python
To add a module to python put in Julialang
Create a simple momentum investment model in Python
How to notify a Discord channel in Python
Split files when writing vim plugin in python
I want to create a plug-in type implementation
Create a new page in confluence with Python
A Vim plugin that automatically formats Python styles
Create a datetime object from a string in Python (Python 3.3)
How to run Leap Motion in non-Apple Python
Create a package containing global commands in Python
[Python] How to draw a histogram in Matplotlib
How to create a Rest Api in Django
Create a MIDI file in Python using pretty_midi
Create a loop antenna pattern in Python in KiCad
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Create a Python module
Create a Python environment
Write your blackbird plugin # 001
Write your blackbird plugin # 003
Write a vim plugin in Python
Write a simple Vim Plugin in Python 3
I tried to create a class that can easily serialize Json in Python
I want to create a priority queue that can be updated in Python (2.7)