-
Notifications
You must be signed in to change notification settings - Fork 19
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
Make crystal tool expand work on project files. #18
Conversation
Perhaps the target files from |
@RX14 Hmm. Interesting. Sadly, there doesn't seem to exist a well maintained yaml parser for elisp. The only I've found is a libyaml binding that doesn't seem to be maintained, and that isn't packaged. It seems targets is only inserted into shard.yml when using |
Starting from a spec suite file is probably more robust. |
Like I think I figured out the flycheck options, but I noticed that the show implementation doesn't work properly - it doesn't crash as before, it just can't find any implementation or call. |
Nah, any old |
I'm afraid I don't see the logic behind that. Either there is some central file that requires everything, and then |
@yxhuvud yeah fair enough, I was working under the assumption that each spec file required the whole application which is wrong... |
@yxhuvud Although there is no good yaml parser available in elisp, crystal's YAML module can be used. |
crystal-mode.el
Outdated
@@ -2757,5 +2767,6 @@ directory of the current file." | |||
(add-to-list 'interpreter-mode-alist (cons (purecopy name) 'crystal-mode))) | |||
|
|||
(provide 'crystal-mode) | |||
(provide 'crystal-tool--project-name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function export?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plan was to not have to have the same function defined in both this and the flycheck file. Perhaps there is a better way to do it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yxhuvud provide and require are an alternative to autoload for loading files automatically. They work in terms of named features. Autoloading is triggered by calling a specific function, but a feature is loaded the first time another program asks for it by name.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Named-Features.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I had some issues before but they don't seem to happen anymore so I removed it and the require statement as the latter seems to break byte compilation for me.
@brantou BTW, how would I do that? While |
@yxhuvud |
@yxhuvud The code that parses yaml must be very short, it can be stored directly as a string, and written to a temporary file when executed. Then use call-process to call |
So I finally got the time to investigate a bit, and running
outputs
I feel the added delay makes that path to improve this a nonstarter. (A precompiled version takes a much more reasonable 0.004s) |
Additionally, I tried to add the |
This do a best effort solution for the case where a project has a root file that require all other files, and then a macro is expanded in a project file that make use of something that is defined in a different file. Is it a perfect solution? No, especially not for app projects having multiple compile targets. But it works for libraries created with "crystal init lib".
(updated the flyckeck file to handle the conflict that had arisen against the master branch). |
I did a quick attempt at the flycheck mode too (which would need a very similar fix), but didn't manage to do it the seemingly obvious way.
It would have been nice to be able to get a proper list of compile targets somehow :/
EDIT: Figured out how to make flycheck happy.