-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
use macros for projectRuffExecutablePath
#381
base: main
Are you sure you want to change the base?
Conversation
Thank you for creating the PR. |
Sorry for the delay. I checked the operation. |
@KotlinIsland The ruff binary file name includes the |
Ahh, good point, I didn't anticipate this complication. I see two possibilities:
|
It is certainly easier to save to file this way. However, for clarity regarding the display on the settings screen, it might be better to include up to .exe. |
I completely agree. Additionally, this PR contains only a rough draft, I couldn't figure out how to make macro fields work properly. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KotlinIsland
I made some modifications.
Add a logic to save to file also when path is overide if necessary, because the timing written to config is only when it should be applied in config panel.
I don't know why, but RuffConfigService can't take project: project in its constructor, so the code became quite complicated. I'd like to make it a little more transparent.
@@ -59,6 +59,7 @@ val RUFF_LSP_COMMAND = when { | |||
else -> "ruff-lsp" | |||
} | |||
const val WSL_RUFF_LSP_COMMAND = "ruff-lsp" | |||
const val PY_INTERPRETER_DIRECTORY_MACRO_NAME = "PY_INTERPRETER_DIRECTORY" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use Screaming snake case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private fun updateMacro(sdk: Sdk) { | ||
sdk.homeDirectory?.parent?.presentableUrl?.let { | ||
ruffMacroService.addMacroExpand(PY_INTERPRETER_DIRECTORY_MACRO_NAME, it) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timing of the sdk path change is
I want to fire this event there if and when the sdk path changes.
@State(name = "RuffConfigService", storages = [Storage("ruff.xml")]) | ||
@Service(Service.Level.PROJECT) | ||
class RuffConfigService : PersistentStateComponent<RuffConfigService> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I add the project: Project
in the argument, the service raises a null point exception.
I had no choice but to create RuffMacroService.
I did some more research. I think that before writing the Path to the config file, we can set the macro as inject and expand it again if we want to refer to it. |
@KotlinIsland |
@KotlinIsland |
Looks great! |
The code in here works, but is really bad. I couldn't figure out how to make macros work properly.
Currently the plugin always saves the full path to the config file. This makes it impossible to commit project config. In this change we collapse the venv dir before it is saved.