Skip to content

playwmadness/pyformat.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

pyformat.nvim

A combination of black and isort python formatters for Neovim.

Installation

Prerequisites

  • If you're not using venv, I would recommend creating one
mkdir -p ~/.local/venv && cd ~/.local/venv
python3 -m venv nvim
nvim/bin/pip install -U pynvim black isort
  • Then in your init.lua
vim.g.python3_host_prog = vim.env.HOME .. '/.local/venv/nvim/bin/python'

Plugin manager

lazy.nvim:

{
  'playwmadness/pyformat.nvim',
  build = { ':UpdateRemotePlugins' },
  ft = { 'python' },
}

Usage

Call :PyFormat to format current buffer.

Alternatively there is synchronous :PyFormatSync which can be used with autocmd like

au BufWritePre *.py,*.pyi silent! PyFormatSync

to format your python files before writing them

Configuration

Defaults:

vim.g['pyformat#black#settings'] = {
    line_length = 88,
    fast = false,
}

About

isort + black python formatting for Neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages