Comments (19)
@lpla Yes, there is some progress, you can configure the formatter to keep constant indent independent on section keyword length. To do this:
- Uncheck checkbox
PyCharm | Preferences | Editor | Code Style | Python | Wrapping and Braces | Method call args | Align when multiline
reformat code will behave like:
The formatter is still not ideal, but to my mind, it works quite ok and this issue isn't critical at the moment.
from snakecharm.
Snakemake specific codestyle settings paged added in coming 0.9.0
from snakecharm.
@winni2k At the moment you cannot change that. You get 5 space indentation because """cats"""
is aligned relative to shell
keyword end offset. I also don't like that section arguments get different indentation depending on it's section name length (e.g. resources
vs input
)
This issue is likely to be connected with #16. Snakemake language support reuses parts of Python
plugin parser and code formater and at some points we cannot tune python
code formatter to process snakemake
syntax in the way which we want.
We are going to work on these 2 issues during this summer.
from snakecharm.
yes please.
from snakecharm.
:)
from snakecharm.
Now next line is aligned relative to ':' and no line continuation is inserted. I think better to align rule parameter values relative to rule parameter name start pos + indent, but not clear how to fix this at the moment.
from snakecharm.
Hey, I am not sure I understand everything, but this looks like it might be useful!
Just to re-iterate what I would expect to happen:
On a line that ends with a colon, when I hit enter, my cursor is sent to the next line and indented by four spaces compared to the previous line.
from snakecharm.
Let me show you an example:
rule all:
wildcard_constraints:<caret> fooo=".*"
After my previous commit. If you press 'Enter', you will get
rule all:
wildcard_constraints:
<caret>fooo=".*"
instead of
rule all:
wildcard_constraints:\
<caret>fooo=".*"
On a line that ends with a colon, when I hit enter, my cursor is sent to the next line and indented by four spaces compared to the previous line.
Yes, agree, I'd like to get:
rule all:
wildcard_constraints:
<caret>fooo=".*"
P.S: Example updated, the initial version was incorrect
from snakecharm.
Hmmm, that may be worse than before?
from snakecharm.
I think not worse because we don't need '\' here and moving caret back to prev line to delete '\' is more annoying.
from snakecharm.
Hmm, currently when I start with this:
rule all:
wildcard_constraints:<caret>
and hit enter, I get this:
rule all:
wildcard_constraints:
<caret>
I then have to hit space four times to get a sensible indent. Am I on an outdated version of the plugin?
from snakecharm.
Ok, correct my minimal example was too minimal, indeed for
rule all:
wildcard_constraints:<caret>
you will get
rule all:
wildcard_constraints:
<caret>
I was talking about the case:
rule all:
wildcard_constraints:<caret> fooo=".*"
or
rule all:
wildcard_constraints:<caret>
fooo=".*"
When I want to add new param to the existing single line definition, I don't want to get \
char on Enter
rule all:
wildcard_constraints: \
fooo=".*"
And the desired behavior should be
rule all:
wildcard_constraints:
fooo=".*"
At the moment I've implemented a partial fix which doesn't insert line continuation \
, but unfortunately aligns text relatively to ':'
rule all:
wildcard_constraints:
<caret>fooo=".*"
from snakecharm.
Ah! Yes, that's an improvement :D
from snakecharm.
@winni2k Updated plugin is available in JetBrains Plugins Repository and could be installed using Preferences|Plugins
from snakecharm.
Just a bit of feedback on our conversation above: I've started using this version of the plugin, and I love that the code -> reformat code
option now works!
from snakecharm.
I am still quite happy with this plugin, but I have a request for an improvement:
When I use code -> reformat code
on the this code (note the indentation of two spaces before """cats"""):
rule bla:
shell:
"""cats"""
then the code is reformatted as:
rule bla:
shell:
"""cats"""
with an indentation of five spaces.
I see this happening a lot. Is there any way to constrain the indents to be four spaces?
from snakecharm.
Hi! Any progress on this?
from snakecharm.
Thanks for the workaround! This has been driving me insane.
from snakecharm.
Related API docs - https://www.jetbrains.org/intellij/sdk/docs/reference_guide/custom_language_support/code_formatting.html
We need own formatting model builder base extending com.jetbrains.python.formatter.PythonFormattingModelBuilder
and com.jetbrains.python.formatter.PyBlock
. E.g. add support for Snakemake specific PSI + change some rules for py arg lists inside snakemake sections
Also we want to get Uncheck checkbox PyCharm | Preferences | Editor | Code Style | Python | Wrapping and Braces | Method call args | Align when multiline
behaviour w/o modifiying python formatting settings.
See tests examples in PyFormatterTest
from snakecharm.
Related Issues (20)
- Current version of SnakeCharm is incompatible with PyCharm 2023.1 HOT 2
- Exception: "Access is allowed from write thread only" creating project in dumb mode HOT 2
- PyCharm 2023.3 Support
- Show notice on deprecated features HOT 1
- Unresolved reference warning when iterating over 'input' key-value pairs using '.items()'
- [7.11] Resources scopes support
- Unresolved reference 'snakemake' HOT 3
- Wildcard not defined in output of Target Rule HOT 3
- PyCharm 2024.1 support HOT 5
- Improve parser error message when rule/module is declared with name but lacks ':'
- Completion for wrapper names rarely works
- Section names cannot be resolved for rules after inheritance using use
- After using import, fuctions from other smk files are not detected HOT 1
- Importing rules using github function does not work
- Gitfile command is not recognized by snakecharm
- Snakecharm does not recognize localrule directive
- Cache and bechmark are not reported as an error
- Multiple functions are not recognized by snakecharm
- Snakecharm marks error on comment in last line HOT 1
- Improve target rules support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from snakecharm.