-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fixes #7119 - Add support for Facebook Flow language #7208
Conversation
a15fee2
to
1d4e1a5
Compare
this is great, thanks so much for creating a layer, I use flow every day and now I can switch back to Emacs for my web development 😄 Fwiw, I was only able to get the proper (remove-hook 'react-mode-hook 'tern-mode) Otherwise, it was only populating completions from tern instead of flow. |
@pheuter ah, I actually have tern disabled globally via If people are using tern, do you think they'd prefer to have flow completions or tern completions? I'm not sure how good tern completions usually are. (I'm also not sure how I'd disable tern based on the presence of the |
1d4e1a5
to
c8b1b67
Compare
Discovered that |
29287b7
to
6dcf42a
Compare
6dcf42a
to
f7394a5
Compare
f7394a5
to
a4b07a7
Compare
I've started a bounty for this feature in #7119 @aaronjensen pointed out that the "whole thing has suffered from feature creep, and it's unclear what the bounty is for". The bounty is for improving, and then merging, this pull request. Which effectively closes #7119. I suggest the following list to consider the bounty requirements satisfied:
With these it would become very comfortable working with flow in spacemacs. There are a bunch of interesting extras like |
This would require work in |
11ba499
to
1b2ece7
Compare
@evindor do you have a fuller example of highlighting not working with generics? They seem ok to me in js2-mode. |
@jdelStrother I've run a few experiments and looks like reduced the problem to a few edge cases: Argument type annotationsAdd some typing: Generic in the argument type annotation:export type Handler<T> = {
[key: string]: (state: T, action: Action<any>) => T,
} // ^^^ This is the troublemaker Let's break it: |
Yeah, I looked at the code the typescript package uses to produce that. It's... not trivial
|
@jdelStrother well, these are bells and whistles, can live w/o fancy colored eldoc. |
@jdelStrother for the same piece of code, tried Look like the highlight isn't screwed up anywhere! I've looked into react-mode and they don't define any extra syntax, only derive from Then I switched to |
Please excuse me for linking here cause it's not very readable, but I guess there should be some inspiration available here in web-mode |
I think fixing up js2-mode's highlighting for flow is probably beyond me - their parser is pretty terrifying. See mooz/js2-mode#224 for the relevant issue. However, I did manage to get highlighting working in eldoc using web-mode's highlighter - will push a fix for that later. |
2e4f84c
to
ad6d50e
Compare
How do I add this to my spacemacs setup? |
@z3t0 I personally just replaced my 2 year spacemacs confit with @aaronjensen 's setup and I'm loving life. Yeah a bit lazy and some of my custom stuff got bumped but for now it's a great way to go. Besides that there are several examples above. Would be happy to help. |
PS as a bonus w/ prettier auto formatting. That pretty much life changing and integrate with flow. |
@orther I'm not seeing the setup, could you share a link? thanks |
This is his repo I'm referring to. It also fixed my Elixir formatting. Not to meantion the rjsx mode for react and JS is better imo @z3t0 |
https://github.com/aaronjensen/spacemacs.d/pulls Sorry forgot link |
got it thanks |
Just set up flow-type-minor and it's working well with aaronjensen's rjsx mode. I do get a small lag for about a second just after opening a file. I can live with it for now though. My config's at https://github.com/skattyadz/dotfiles/tree/master/.spacemacs.d/layers in case you're interested in doing something similar |
@skattyadz Thank you for the link but I am getting the following error Sorry it's an image file because I couldn't figure out how to keep the error there long enough to copy it. |
I would like to add my grain of salt here. I have been playing with this PR for maybe one week. Before that I was using my mode which is mostly copy pasted code from you and aaronjensen. Your mode is pretty good for my use cases, but I would like to point out some of my pain points. Note: most of my testing was made with CompanyBy default with MajorI played with EldocEldoc is not present with |
FWIW I've started some work (we're tracking it antifuchs/rjsx-mode#1) to extend It will provide syntax highlighting as well just like |
Any news about this bounty ? @Fuco1 created a repository there: https://github.com/Fuco1/flow-js2-mode |
I don't know how to integrate it with spacemacs nor will I try to do that anytime soon but if anyone wants to use the package I've created feel free to do so. |
@jdelStrother I have merged the first draft version of your layer provided #10513. I think this should be working as a first draft however to get full ide features I would recommend adding a proper LSP server for this. Anyway this merge made this PR obsolete. |
Yeah, I've been experimenting with that recently - possibly we should just delete this layer entirely and suggest that people use: dotspacemacs-configuration-layers '(
(javascript :variables
javascript-backend 'lsp)) ? |
@jdelStrother - I think that sounds like a much better solution, FWIW. |
@jdelStrother @wukkuan ok so this is included in the current lsp implementation, I haven't been sure about this, then it would suffice to add some hints to the javascript layer's documentation and let users use lsp if they require flow support. Care to make a PR? |
@smile13241324 - I'll take a shot at figuring out how to set this up and then documenting it. |
@wukkuan - thanks for doing the PR :), and sorry for my late answer I am currently pretty busy at work so there is not as much time for spacemacs as I would like. |
👉 There is a bounty source opened on this issue, click on the badge for more info
Feature list in order to complete this PR and unlcok the bounty:
Auto-completion
company-flow
whenever the buffer begins with either of these lines:// @flow
/* @flow */
[Author note: It's currently enabled in all of react-mode and js2-mode, and I've not noticed any ill-effects in files where flow isn't present.]
Syntax Highlighting
flow
. Right now it's mostly ok inreact-mode
and quite bad injavascript-mode
(for instance, use of genericsMap<K, V>
breaks the syntax highlighting). There may be some inspiration inemacs-flow-jsx
,react-mode
andtypescript-mode
.Documentation
eldoc
-flow type-at-pos
should give the type.eldoc
like intypescript
.Code Navigation
flow get-def
andflow find-module
should enable amazing jump to definition functionality. I'd love to have them binded to g or d or at least local leader.Original message
Hi there - I've cobbled this together from the various flow-related things I've been using. There seems to be some interest in having a proper spacemacs flow layer (#7119), so thought I'd throw this out for discussion.
There's a few bits that might be somewhat targeted towards my own setup - for example, I chain the flow flychecker onto the eslint checker, but conceivably others might want to chain it onto jshint instead. How much of that would you want to see customizable before merging this?
EDIT: [@syl20bnr] changed title and message body to reflect the bounty source attached to it.