LightTable/LightTable — pull request #1684 by cldwalker (2014-10-21 06:04:30+00:00)
Title: Add user plugin

As discussed in #1653, here are the tasks to make settings a User plugin:

* [X] Add example files: plugin.edn, project.clj, src/lt/plugins/user.cljs
* [X] Copy them using settings/create-user-settings behavior
* [X] Make this work with plugins.cljs :fireworks:
* [X] Installing, removing, updating, refreshing plugins must sync to plugin.edn
* [X] Command to open user.cljs
* [X] Command to add User plugin to current workspace
* [ ] Fix bug where user.cljs can't load-js first time LT copies user.cljs to settings/

I QAed all features and confirmed plugin.edn updates :dependencies beautifully! I also verified a User plugin with 20+ dependencies does correctly repopulate an empty plugins/. We can now reliably clone someone's complete LT configuration :)

For user.cljs I decided to include an example behavior and command (same ones as the lt-plugin template). My rationale is a user.cljs with a working example is more helpful to users than an empty one. user.behaviors has 2 new behaviors - one to add js from the cljs plugin and another for the example behavior. While new users will get this for free, existing users will need to place these into their existing user.behaviors.

There is one outstanding issue noted above. For a new or existing user, the first time LT copies user.cljs from deploy/core/settings - `lt.objs.plugins/load-js` fails to load user_compiled.js due to looking for it in the wrong path. I believe this problem occurs because the plugin behaviors are loaded before LT has copied over the User plugin. But even after copying, subsequent behavior reloads fail to load user_compiled.js. The issue there seems to be with `(::dir object/*behavior-meta*)` continues to be nil in [adjust-path](https://github.com/LightTable/LightTable/blob/407e8a9f2395474c2494cb332a37df35d7ed5196/src/lt/objs/plugins.cljs#L49-Lundefined). If I restart LT, all these problems go away and user_compiled.js is correctly loaded.

@ibdknox Any thoughts on how to copy the User plugin over before plugin behaviors are loaded? Alternatively, how could I fix `object/*behavior-meta*` to have the correct ::dir for User plugin after it has been copied over?

Two usability questions:
* The User plugin is currently in settings/ which means the names don't match and could cause confusion. For example, with the new command `Add User plugin to workspace`, a user would execute the command and then see settings/ when expecting to see User/ in their workspace. What do you all think about renaming settings/ to User/? I'd have to migrate existing users by copying their existing settings/* to User/*.
* I described the user.cljs command with `User clojurescript`. I could also go with something more descriptive e.g. `User commands and behaviors` but that could be misleading since user.cljs can contain more than that e.g. objects and defuis. Any preferences?