Skip to content

Commit

Permalink
Merge pull request #96 from koxudaxi/detect_project_ruff_after_packag…
Browse files Browse the repository at this point in the history
…es_refreshed

Detect project ruff after packages refreshed
  • Loading branch information
koxudaxi authored Feb 17, 2023
2 parents 39d0cff + 4b1f0ae commit d8506c3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<projectListeners>
<listener class="com.koxudaxi.ruff.RuffFileDocumentManagerListener"
topic="com.intellij.openapi.fileEditor.FileDocumentManagerListener"/>
<listener class="com.koxudaxi.ruff.RuffPackageManagerListener"
topic="com.jetbrains.python.packaging.PyPackageManager$Listener"/>
</projectListeners>
<actions>
<action id="ExecuteRuff" class="com.koxudaxi.ruff.RuffRun" text="Run Ruff"
Expand Down
12 changes: 12 additions & 0 deletions src/com/koxudaxi/ruff/RuffPackageManagerListener.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.koxudaxi.ruff

import com.intellij.openapi.project.Project
import com.intellij.openapi.projectRoots.Sdk
import com.jetbrains.python.packaging.PyPackageManager

class RuffPackageManagerListener(project: Project) : PyPackageManager.Listener {
private val ruffConfigService = RuffConfigService.getInstance(project)
override fun packagesRefreshed(sdk: Sdk) {
ruffConfigService.projectRuffExecutablePath = findRuffExecutableInSDK(sdk)?.absolutePath
}
}

0 comments on commit d8506c3

Please sign in to comment.