Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vim plugin #62

Closed
bricoletc opened this issue Sep 5, 2020 · 3 comments
Closed

Vim plugin #62

bricoletc opened this issue Sep 5, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@bricoletc
Copy link
Collaborator

As part of adding editor integration, could make a vim plugin as in black

@bricoletc bricoletc added the enhancement New feature or request label Sep 5, 2020
@ashwinvis
Copy link

Perhaps configuring in some popular plugin would do? For example:

@bricoletc
Copy link
Collaborator Author

@ashwinvis there is now a self-contained vim plugin: https://github.com/snakemake/snakefmt/blob/master/docs/editor_integration.md#vim.

However, it could be interesting to add support for vim-autoformat in the future. I guess one option is just writing up a section in the editor_integration document saying i)Set up filetype detection ii)Setup formatters and formatdef for the snakemake file type as per https://github.com/chiel92/vim-autoformat#basic-definitions
Another option would be a PR to vim-autoformat itself, but not sure if can add filetype detection for snakemake files there.

@ashwinvis
Copy link

ashwinvis commented Nov 13, 2020

I use neoformat and I realized it is as simple as copying black's definition. The only difference was there is no -q / --quiet flag in snakefmt, but it does not seem to matter. It works:

let g:black_linelength=82
let g:neoformat_snakemake_snakefmt = {
        \ 'exe': 'snakefmt',
        \ 'args': ['-l '.g:black_linelength, '-'],
        \ 'stdin': 1,
        \ }

let g:neoformat_enabled_snakemake = ['snakefmt']

To make it work I run :Neoformat in any open file buffer. If you want to mimic this in your plugin you could:

if exists(":Neoformat")
  command! Snakefmt :Neoformat! snakemake snakefmt
endif

Or contribute it upstream into the neoformat repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants