Skip to content

amirali/yapf.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

yapf.nvim

NeoVim Yapf formatter plugin

Requirements

Yapf

pip install yapf

plenary.nvim

use 'nvim-lua/plenary.nvim'

Installation

-- using packer
use {
  'amirali/yapf.nvim',
  requires = {'nvim-lua/plenary.nvim'},
  config = function()
    require('yapf').setup {}
  end,
}

Configuration

...
  config = function
    require('yapf').setup {
      command = 'custom_yapf_command',
      style = 'your_preferred_style_or_path_to_config_file',
    }
  end,
...

Styles

You can choose whatever style or config file that yapf supports
Checkout here

Usage

Using command

You can run :Yapf whenever you want to format the current buffer

Automation

You can add the line below to your config file to run formatter on save

-- in lua
vim.command [[autocmd BufWritePre *.py :Yapf]]
" in vim
autocmd BufWritePre *.py :Yapf

Keybind

-- in lua
vim.api.nvim_set_keymap('n', '<leader>y', ':Yapf<CR>', {})
" in vim
nmap <leader>y :Yapf<CR>

About

Yapf plugin for NeoVim

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published