-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
feat!: Lua API #1532
feat!: Lua API #1532
Conversation
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.
Looks great!
- `has_config` - `get_config` - `update_config`
Avoid duplicate definitions
a9ddf8d
to
2a2916e
Compare
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.
I'm not sure about the hooks functionality. I think it is code we don't need. I had thought the vscode.on()
was for subscribing to eventBus
, which also is probably not useful.
init
can be observed by VimEnter
or something similar.
For #434, we should add specific code that calls doau FocusGained
etc, and let users use autocommands. We should not reinvent any mechanisms we don't need to.
I don't think implicit doautocmd is better. Users can do it themselves. Using on can handle bidirectional synchronization more conveniently, such as editor.options(&ts, &sw)). This PR is feat, not fix. Not only solve the linked issues. This mechanism is useful and common. Many nvim plug-ins have some hooks |
This comment was marked as outdated.
This comment was marked as outdated.
I'm not sure what you mean, currently
Can you explain further? Sure, I agree that hooks are useful, but I think all the hooks implemented so far can be better done using built-in neovim mechanisms that work out of the box with other nvim code. |
May not work as expected. When the window state changes, the internal state of vscode may also change. But I'm not sure, but I think there will be a lot of edge cases. We can add this to docs: You can trigger FocusGained/FocusLost on "window_state_changed" vscode.on("window_state_changed", function(focused)
vim.cmd.doautocmd(focused and "FocusGained" or "FocusLost")
end)
For example: For internal use
As a demonstration, I will use it to support #1530. We can hook more useful vscode events so that users can write plugins for vscode-neovim. |
Example that supports modeline, and synchronize all editor options(tab options and number style) xiyaowong/vscode-neovim@feat/vscode-action...xiyaowong:vscode-neovim:tmp/support-modeline |
This comment was marked as resolved.
This comment was marked as resolved.
It should be decided by the users themselves.Or provide a configuration item, which is obviously unnecessary. |
Sure |
removed unnecessary hooks: init, window_stated_changed
I am happy with this PR, pending readme documentation and ideally examples. |
36c7f8a
to
bfe6fca
Compare
bfe6fca
to
bea97ef
Compare
1c6d28d
to
e9f60f5
Compare
454b15b
to
16af402
Compare
Ready to merge⚡️ |
Thank you for your hard work! |
@xiyaowong looking forward to seeing the settings sync PR |
VimScript functions
No changes.
Lua
API
The original APIs have all been removed or modified. The new APIs are as follows:
Load module:
local vscode = require("vscode-neovim")
vscode.action
for asynchronous execution of actions.vscode.call
for synchronous execution of actions.vscode.on
for adding hook functions.vscode.has_config
check if a configuration existsvscode.get_config
get a configuration valuevscode.update_config
update a configurationvscode.notify
likevim.notify
Usage
Actions
Now, two built-in actions are provided for testing purposes:
_ping
returns"pong"
_wait
waits for the specified milliseconds and then returns"ok"
Hooks
Currently no available events for user use.
Integration of VSCode Settings
Notifications
You set these as your default notify functions.
Others