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

Support range formatting #120

Merged
merged 1 commit into from
Dec 9, 2024
Merged

Support range formatting #120

merged 1 commit into from
Dec 9, 2024

Conversation

fredrikekre
Copy link
Owner

@fredrikekre fredrikekre commented Dec 6, 2024

This patch implements the --lines=a:b command line argument for
limiting the formatting to the line range a:b. Multiple ranges are
supported. Close #114.

Examples:

$ cat main.jl
function f(a,b,c,d)
  a  +  b  +  c  +  d
end

$ ./bin/runic --lines=1:1 main.jl
function f(a, b, c, d)
  a  +  b  +  c  +  d
end

$ ./bin/runic --lines=2:2 main.jl
function f(a,b,c,d)
    return a + b + c + d
end

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 96.73913% with 3 lines in your changes missing coverage. Please review.

Project coverage is 93.91%. Comparing base (d66286d) to head (78cbef2).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/main.jl 91.30% 2 Missing ⚠️
src/Runic.jl 98.52% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #120      +/-   ##
==========================================
+ Coverage   93.84%   93.91%   +0.06%     
==========================================
  Files           8        8              
  Lines        3687     3778      +91     
==========================================
+ Hits         3460     3548      +88     
- Misses        227      230       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fredrikekre
Copy link
Owner Author

cc @maleadt

Do you envision having some wrapper around this for figuring out what to pass similar to git-clang-format?

@maleadt
Copy link
Contributor

maleadt commented Dec 6, 2024

Thanks! I was working with the following wrapper, based on git-clang-format: https://gist.github.com/maleadt/13c760a7318c502f7bd45ce82b92f072

@fredrikekre
Copy link
Owner Author

Cool. I wonder if it can be distributed by Runic? Perhaps a CLI flag that outputs that file to stdout? I have thought about having a flag to output a bash shim for runic too.

@maleadt
Copy link
Contributor

maleadt commented Dec 6, 2024

Where would you install it though? You 'simply' need git-runic with the above contents on PATH, so the file could just reside in res here, but it's not going to be easy to figure out a user-writable PATH entry without dealing with a whole lot...

@fredrikekre
Copy link
Owner Author

I had something like this in mind:

$ runic --output-bin=git-runic > ~/.local/bin/git-runic

$ chmod +x ~/.local/bin/git-runic

@maleadt
Copy link
Contributor

maleadt commented Dec 6, 2024

That, or runic setup-git --path=~/.local/bin

In any case, it'd be nice if the file could be kept up to date, so that updating Runic.jl also updates the git integration.

@fredrikekre
Copy link
Owner Author

That would probably be much simpler after JuliaLang/Pkg.jl#3772. Runic would then provide two installable and upgradable apps: runic and runic-git.

In any case I think it would be good to include that file in the repo here and keep it up to date (although it probably wouldn't change much?).

This patch implements the `--lines=a:b` command line argument for
limiting the formatting to the line range `a:b`. Multiple ranges are
supported. Closes #114.
@fredrikekre fredrikekre marked this pull request as ready for review December 9, 2024 09:39
@fredrikekre fredrikekre merged commit 93593dd into master Dec 9, 2024
10 checks passed
@fredrikekre fredrikekre deleted the fe/lines branch December 9, 2024 09:59
@fredrikekre fredrikekre mentioned this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: --lines to support partial formatting
2 participants