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

ruff formatter: Fix bug running non-stdin version #239

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autoload/codefmt/ruff.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let s:plugin = maktaba#plugin#Get('codefmt')
function! s:FormatWithArgs(args) abort
let l:executable = s:plugin.Flag('ruff_executable')
let l:lines = getline(1, line('$'))
let l:cmd = [l:executable, 'format'] + a:args
let l:cmd = [l:executable, 'format'] + a:args + ['-']
snu5mumr1k marked this conversation as resolved.
Show resolved Hide resolved
if !empty(@%)
let l:cmd += ['--stdin-filename=' . @%]
endif
Expand Down
8 changes: 4 additions & 4 deletions vroom/ruff.vroom
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ system.
:silent file somefile.py
% f()
:FormatCode ruff
! ruff format --stdin-filename=somefile.py.*
! ruff format - --stdin-filename=somefile.py.*
snu5mumr1k marked this conversation as resolved.
Show resolved Hide resolved
$ f()

The name or path of the ruff executable can be configured via the
ruff_executable flag if the default of "ruff" doesn't work.

:Glaive codefmt ruff_executable='/somepath/ruff'
:FormatCode ruff
! /somepath/ruff format.*
! /somepath/ruff format -.*
$ f()
:Glaive codefmt ruff_executable='ruff'

Expand All @@ -40,7 +40,7 @@ You can format any buffer with ruff specifying the formatter explicitly.
% if True: pass

:FormatCode ruff
! ruff format.*
! ruff format -.*
$ if True:
$ pass
if True:
Expand All @@ -55,7 +55,7 @@ It can format specific line ranges of code using :FormatLines.
|else: bar-=1;

:2,3FormatLines ruff
! ruff format .*--range=2:3.*
! ruff format .*--range=2:3 -.*
$ some_tuple=( 1,2, 3,'a' );
$ if bar:
$ bar += 1
Expand Down
Loading