All Projects → dkandalov → Live Plugin

dkandalov / Live Plugin

IntelliJ plugin for writing plugins at runtime

Programming Languages

kotlin
9241 projects
groovy
2714 projects

Projects that are alternatives of or similar to Live Plugin

Acejump
🅰️ single character search, select, and jump
Stars: ✭ 786 (+69.4%)
Mutual labels:  ide, intellij-plugin
Arrow Meta
Functional companion to Kotlin's Compiler
Stars: ✭ 246 (-46.98%)
Mutual labels:  ide, intellij-plugin
Intellij Emmylua
Lua IDE/Debugger Plugin for IntelliJ IDEA
Stars: ✭ 1,311 (+182.54%)
Mutual labels:  ide, intellij-plugin
Intellij
IntelliJ plugin for Bazel projects
Stars: ✭ 500 (+7.76%)
Mutual labels:  ide, intellij-plugin
android-studio-plugin
Integrate your Android project with Crowdin
Stars: ✭ 52 (-88.79%)
Mutual labels:  ide, intellij-plugin
Intellij Elixir
Elixir plugin for JetBrain's IntelliJ Platform (including Rubymine)
Stars: ✭ 1,488 (+220.69%)
Mutual labels:  ide, intellij-plugin
Intellij Makefile
Makefile support for IntelliJ-based IDEs
Stars: ✭ 164 (-64.66%)
Mutual labels:  ide, intellij-plugin
lottie-idea
Android Studio and IntelliJ IDEA viewer plugin for Lottie animations
Stars: ✭ 36 (-92.24%)
Mutual labels:  ide, intellij-plugin
AppleScript-IDEA
AppleScript support for IntelliJ IDEs
Stars: ✭ 21 (-95.47%)
Mutual labels:  ide, intellij-plugin
intellij-zig
The IntelliJ IDEA plugin for the Zig programming language ┗😃┛ ┏😃┓ ┗😃┛ ┏😃┓
Stars: ✭ 85 (-81.68%)
Mutual labels:  ide, intellij-plugin
intellij-ui-test-robot
The library allows you to write and execute UI tests among IntelliJ IDEA. You can test your Plugin.
Stars: ✭ 60 (-87.07%)
Mutual labels:  ide, intellij-plugin
intellij-autohotkey
AutoHotkey plugin for the Jetbrain's IntelliJ platform
Stars: ✭ 30 (-93.53%)
Mutual labels:  ide, intellij-plugin
Julia Intellij
💻 Julia Plugin for IntelliJ IDEA ┗😃┛ ┏😃┓ ┗😃┛
Stars: ✭ 258 (-44.4%)
Mutual labels:  ide, intellij-plugin
Eclipsecodeformatter
IntelliJ plugin - Allows using Eclipse's code formatter directly from IntelliJ. https://plugins.jetbrains.com/plugin/6546-eclipse-code-formatter
Stars: ✭ 390 (-15.95%)
Mutual labels:  intellij-plugin
Onepanel
The open and extensible integrated development environment (IDE) for computer vision with built-in modules for model building, automated labeling, data processing, model training, hyperparameter tuning and workflow orchestration.
Stars: ✭ 428 (-7.76%)
Mutual labels:  ide
Atom Languageclient
Language Server Protocol support for Atom (the basis of Atom-IDE)
Stars: ✭ 385 (-17.03%)
Mutual labels:  ide
Buidl
A browser-based IDE for creating, deploying, and sharing blockchain apps (DApps, or decentralized apps). Publish your first blockchain DApps in 5 minutes! Here is how: https://docs.secondstate.io/buidl-developer-tool/getting-started
Stars: ✭ 376 (-18.97%)
Mutual labels:  ide
Vim Ide
VIM configured as powerful IDE (Integrated Development Environment)
Stars: ✭ 441 (-4.96%)
Mutual labels:  ide
Deepxde
Deep learning library for solving differential equations and more
Stars: ✭ 420 (-9.48%)
Mutual labels:  ide
Wedatasphere
WeDataSphere is a financial level one-stop open-source suitcase for big data platforms. Currently the source code of Scriptis and Linkis has already been released to the open-source community. WeDataSphere, Big Data Made Easy!
Stars: ✭ 372 (-19.83%)
Mutual labels:  ide

Build Status

LivePlugin

This is a plugin for IntelliJ IDEs to write plugins at runtime using Groovy and Kotlin. To install search for "LivePlugin" in IDE Preferences -> Plugins -> Marketplace. See also plugin repository page.

demo

Why?

There is great Internal Reprogrammability blog post on this topic by Martin Fowler.

The reasons LivePlugin exists are along the same lines:

  • minimal setup to start writing plugin. LivePlugins can always be edited/executed in LivePlugin toolwindow regardless of the current project in IDE. This takes much less effort than creating new project configured for plugin development.
  • fast feedback loop. LivePlugins are run in the same JVM instance, so there is no need to restart IDE. Typical plugin development involves starting new instance of IDE and restarting it on most code changes. (There is a caveat that some parts of IDE API are not designed to be reconfigured without JVM restart. This is unfortunate and will hopefully change sometime in the future.)
  • customizable IDE. Majority of the development tools are difficult to customize. This plugin is an attempt to improve the situation.

Practical use cases:

  • prototyping of IntelliJ plugins
  • experimenting with IntelliJ API
  • project-specific workflow automation
  • integrating shell scripts with IDE

Plugin Examples

Hello world:

import static liveplugin.PluginUtil.show
show("Hello world") // shows balloon message with "Hello world" text

Insert New Line Above Action:

import com.intellij.openapi.actionSystem.AnActionEvent
import static liveplugin.PluginUtil.*

// This action inserts new line above current line.
// It's a follow-up for these posts:
//   http://martinfowler.com/bliki/InternalReprogrammability.html
//   http://nealford.com/memeagora/2013/01/22/why_everyone_eventually_hates_maven.html
// Note that there is "Start New Line Before Current" action (ctrl + alt + enter) which does almost the same thing.

registerAction("InsertNewLineAbove", "alt shift ENTER") { AnActionEvent event ->
	runDocumentWriteAction(event.project) {
		currentEditorIn(event.project).with {
			def offset = caretModel.offset
			def currentLine = caretModel.logicalPosition.line
			def lineStartOffset = document.getLineStartOffset(currentLine)

			document.insertString(lineStartOffset, "\n")
			caretModel.moveToOffset(offset + 1)
		}
	}
}
show("Loaded 'InsertNewLineAbove' action<br/>Use 'Alt+Shift+Enter' to run it")

How to start writing plugins

  • open Plugins tool window
  • select one of the plugin entries in the panel
    (entries are folders, and plugin.groovy are startup scripts for plugins)
  • click Run icon to execute plugin (or use keyboard shortcuts alt+C, alt+E or ctrl+shift+L)

If the above worked fine:

  • modify plugin.groovy and rerun plugin to see results
  • add built-in plugin examples and experiment with them (in Plugins toolwindow header + button -> Examples)

If something doesn't work, report an issue.

(To use alt+... shortcuts on OSX you might need a workaround, please see this wiki page .)

The main idea

LivePlugin basically runs Groovy or Kotlin code in JVM. Conceptually it's quite simple:

ClassLoader classLoader = createClassLoader(ideClassloader, ...);
GroovyScriptEngine scriptEngine = new GroovyScriptEngine(pluginFolderUrl, classLoader);
scriptEngine.run(mainScriptUrl, createGroovyBinding(binding));

This means that your code is executed in the same environment as IDE internal code. You can use any internal API and observe/change state of any object inside IDE. There are some limitations of course, like final fields and complex APIs not designed to be re-initialized.

To simplify usage of IntelliJ API for practical purposes some parts of IntelliJ API are wrapped in PluginUtil class. This is essentially a layer on top standard IntelliJ API. If you find yourself writing interesting IDE scripts, feel free to create pull request or send a gist to include your code into PluginUtil. This is experimental API and there is no intention to keep it minimal. PluginUtil is not required though and you can always use IntelliJ classes directly.

Also note that:

  • plugins are evaluated with new classloader on each run
  • plugins are stored in $HOME/.$INTELLIJ_VERSION/config/live-plugins (on Mac $HOME/Library/Application Support/IntelliJIdea15/live-plugins) Note that you can use ctrl+shift+C shortcut to copy file/folder path.
  • if available, Groovy library bundled with IDE is used

Misc tips

  • if your plugins are stable enough, you can enable Settings -> Run All Live Plugins on IDE Startup option. If some of the plugins are not meant to be executed at startup, add if (isIdeStartup) return statement at the top.
  • it helps to have JetGroovy plugin installed (only available in IDEs with Java support)
  • you can get auto-completion and code navigation in plugins code
    • install/enable Groovy plugin
    • Plugin toolwindow -> Settings -> Add LivePlugin and IDE Jars to Project
      (adding jars unrelated to your project is a hack but there seems to be no major problems with it)
  • it helps to be familiar with IntelliJ API
  • when plugin seems to be big enough, you can move it to proper plugin project and still use live plugin See liveplugin as an entry point for standard plugins.

More examples

Similar plugins

The idea of running code inside IntelliJ is not original. There are/were similar plugins:

Contributing

Please see CONTRIBUTING.md.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].