Skip to content
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

[discuss] send compilation warnings to :after-load #64

Closed
tiye opened this issue Jun 26, 2017 · 10 comments
Closed

[discuss] send compilation warnings to :after-load #64

tiye opened this issue Jun 26, 2017 · 10 comments

Comments

@tiye
Copy link
Collaborator

tiye commented Jun 26, 2017

Maybe I can grab the messages and render a warning by myself? Like Figwheel's warnings?

@thheller
Copy link
Owner

I'll probably implement the warning/errors HUD myself soon since its only a bit of HTML construction. The client already gets all the relevant data.

https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#L211-L234
https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/browser.cljs#L96-L97

Those are the messages currently handled by the browser client and the :build-complete message has all the interesting data (which files were compiled, warnings, etc). The :repl/* messages aren't very useful outside the REPL but you could probably do something with the :build-start and :build-complete messages.

Maybe a :build-update config entry which points to a function taking one argument which would just be the message off the websocket?

@tiye
Copy link
Collaborator Author

tiye commented Jun 26, 2017

I'm okay with a different name of that config entry.

If you are about to implement that, maybe make it pluggable? I mean I'm confident with my CSS skills so I can get a HUD message that I would like. Besides, in some cases you just can't be sure about the DOM structure, what it someone replaces content of the entire <body>, then where to put the HUD element?

@thheller
Copy link
Owner

thheller commented Jun 26, 2017

I just published shadow-cljs@0.16.1 which includes a rather simple HUD (far from final).

It is enabled by adding shadow.cljs.devtools.client.hud to :preloads as done here:

:preloads [shadow.cljs.devtools.client.hud]}}

It uses a new "listener" Websocket that receives the same messages the default websocket does but is independent. It currently only receives messages and does not answer any other messages.

I want to have a full remote API eventually but I'm still in the planning phase for that.

Things will probably change slightly over time but you can build something on top of this already as seen in the HUD. I'd be curious to see other implementations, I hate UI work so mine is ugly and doesn't have any of the nice features. I'll definitely add the click-to-open thingy soon.

@tiye
Copy link
Collaborator Author

tiye commented Jun 27, 2017

I'll definitely add the click-to-open thingy soon.

This is cool.

@thheller
Copy link
Owner

thheller commented Jun 27, 2017

Just pushed a new release with support for :open-file-command (top-level in shadow-cljs.edn). Supports :idea and :emacs by default but it should be possible to support any other editor as well.

Happy to add more defaults for editors if you can provide example command lines.

It uses a very basic templating syntax where :file :line :column :pwd are replaced by there respective values and nested vectors are converted to format calls.

["my-editor" :file :line :column]
# yields
my-editor /abs/path/to/file.cljs 12 1

["my-editor ["foo: %s :bar %d" :file :line]]
# yields, note the quotes
my-editor "foo: /abs/path/to/file.cljs :bar 12"

:file and :column default to 1 when not available.

Refer to the defaults for examples.

@thheller
Copy link
Owner

This currently assumes that be command exits fairly quickly after calling. Otherwise the editor process will be tied to the shadow-cljs server and will be killed if the server is killed.

@tiye
Copy link
Collaborator Author

tiye commented Jun 28, 2017

According to the docs of Sublime Text http://www.sublimetext.com/docs/command-line

sublimetext main.c:100:12

But in my laptop we use:

/Applications/Sublime\ Text.app/Contents/MacOS/Sublime\ Text package.json:9:9

People usually create alias for that file.


I remembered React Native has such feature: https://github.com/facebook/react-native/blob/992e37c8bcdb13c89cb680e385a0fb344137d0fa/local-cli/server/util/launchEditor.js#L90-L100

@thheller
Copy link
Owner

If you confirm that this works, I'll add it as a default template.

:open-file-command ["sublimetext" ["%s:%s:%s" :file :line :column]]

@thheller
Copy link
Owner

Not a fan of the react-native detection since it looks to be OSX only. I think its fine to ask for one little config entry and I want to have built-in defaults for all editors so you don't need to use the "complicated" template syntax unless you want to.

@thheller
Copy link
Owner

I'll close this for now and open more focused tickets around a formal API soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants