Skip to content

Commit

Permalink
feat: decorator for Python files in project tree (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuxsoger authored Feb 25, 2024
1 parent ef8ff34 commit 9cb298a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.github.catppuccin.jetbrains_icons

import com.github.catppuccin.jetbrains_icons.settings.PluginSettingsState
import com.intellij.ide.projectView.ProjectViewNode
import com.intellij.ide.projectView.PresentationData
import com.intellij.ide.projectView.ProjectViewNodeDecorator
import com.intellij.packageDependencies.ui.PackageDependenciesNode
import com.intellij.ui.ColoredTreeCellRenderer

// hack: pycharm python plugin overrides .py icons in files tree
// by using ProjectViewNodeDecorator we can override it with our icon
class ProjectViewNodeDecorator: ProjectViewNodeDecorator {
private var icons = Icons(PluginSettingsState.instance.variant)

override fun decorate(node: ProjectViewNode<*>, data: PresentationData) {
val file_type = node.getVirtualFile()?.name?.split(".")?.last()

if (file_type.equals("py")) {
data.setIcon(icons.EXT_TO_ICONS["py"])
}
}

// deprecated
override fun decorate(node: PackageDependenciesNode, cellRender: ColoredTreeCellRenderer) {
}
}
4 changes: 4 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ For further help, see also:
order="first"
id="IconProvider"
/>
<projectViewNodeDecorator
implementation="com.github.catppuccin.jetbrains_icons.ProjectViewNodeDecorator"
id="ProjectViewNodeDecorator"
/>
<applicationConfigurable
parentId="appearance"
groupId="com.github.catppuccin.jetbrains_icons"
Expand Down

0 comments on commit 9cb298a

Please sign in to comment.