-
Notifications
You must be signed in to change notification settings - Fork 595
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
Added a script to generate autocomplete files using EmmyLua annotations #2530
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2530 +/- ##
==========================================
- Coverage 27.22% 25.73% -1.49%
==========================================
Files 180 177 -3
Lines 36148 35239 -909
==========================================
- Hits 9841 9069 -772
+ Misses 26307 26170 -137 |
Interesting. I probably won't be able to test this for a few days (my current go to editor, BBEdit, doesn't support lsp servers, so I'm going to have to take a look at Nova or VSCode). Just to make sure I understand, I only need to run the python script once to build the stubs each time the supplied |
That is correct! Ive also added an entry for it to the Makefile. $ make build/stubs |
With the new improvements, auto completion works pretty much everywhere. For more info, see the updated description 🔝 |
Just added stub generating for spoons as well |
Does the python script require any special packages to be installed or will it run with the stock macOS installation of python? |
Standard python |
I will try and review this week (got sidetracked multiple times since I last posted here), but I am wondering if this might be better as a Spoon? Since it can be built by anyone with the stock macOS python and the json file... I don't think there is anything that requires it to be part of a release build, but correct me if I'm wrong... a little file date checking and it a spoon could trigger a rebuild for you when Hammerspoon is updated. At any rate, I'll give this a closer look soon. |
That's actually a great idea. Since the Another benefit is that auto completion would also work for non-official spoons, since we can generate the stubs on the fly when needed. Is this something you would be interested to have as part of the official spoons? If so, what name would you suggest? |
@folke apologies for not being involved in this PR so far. I think having it as a Spoon is a great idea, and I would definitely accept it into the official repo. Regarding the name - I wonder if we could come up with something a little more specific than |
@cmsj ok, great. Will create a Spoon once I have some time. Thanks! |
f.write(ret) | ||
else: | ||
print( | ||
"Warning: invalid function definition:\n " + |
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.
W504 line break after binary operator
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.
This pull request does not contain a valid label. Please add one of the following labels: pr-fix, pr-change, pr-feature, pr-maintenance
@cmsj I created a Spoon as discussed. The implementation is now also fully in Lua, so Python is no longer needed. |
Any word on this PR? |
I've created a python script that uses
build/docs.json
to generate Hammerspoon API stubs using EmmyLua annotationsThese kinds of annotations are supported by the following lsp servers:
Plugins exist for VScode, IntelliJ, vim, Emacs, ... to work with those lsp servers
Let me know your thoughts!
✅ TODO
types
directory or including it as a library📦 Building and using the Hammerspoon stubs
Checkout this branch and run the following:
You now have two options to start using the stubs:
.hammerspoon
directory (or any other project where you need hs complation to work)build/stubs
folder as an external library. For lua-language-server, add the folllowing to your workspace settings in vscode:❗ Don't just symlink the
stubs
in your project directory! In at least lua-language-server, there's an issue with symlinked source roots and autocompletion won't work.❓ FAQ
Why not just add
/Applications/Hammerspoon.app/Contents/Resources/extensions/
as an external library to the lsp config?Simply adding the hammerspoon
extensions
directory as an external library doesn't work for a couple of reasons:_coresetup
populates thehs[string]
table with all modules. LSP servers have a hard time dealing with this and think all functions/methods/variables anywhere are valid auto completions for every module. With the generated stubs, auto completion works for all HS functionality.How could this be distributed?
Hammerspoon.app
. For example/Applications/Hammerspoon.app/Contents/Resources/stubs
🎨 Screenshots
Completion for Spoons