-
-
Notifications
You must be signed in to change notification settings - Fork 198
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(api): add vscode.get_status_item
#1576
Conversation
92dcb2f
to
2fbbfe9
Compare
status = vim.tbl_filter(function(i) | ||
return i ~= "" | ||
end, status) | ||
M.action("refresh-status-items", { args = { status } }) |
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.
Doing rpc work on a field assignment is rather surprising. I would suggest avoiding that kind of OOP cleverness. It doesn't really gain anything and adds uncertainty to the entire API. And it defeats the main benefit of having a table representation of the data: it's no longer data, it's a "live object"....
Instead I would suggest something like a set_status_...
function.
@@ -510,6 +511,20 @@ You can set `vscode.notify` as your default notify functions. | |||
vim.notify = vscode.notify | |||
``` | |||
|
|||
##### `vscode.get_status_item(id)` | |||
|
|||
Creates a status item |
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 have no idea what this does. Why is it needed? Why can't users use :echo
or something like that?
This looks like it might be an inner platform. We should avoid creating a third "plugin framework". Users already have 2 plugin frameworks: vscode and Nvim.
That seems like we're getting into rather "nice to have" territory, which can be a source of maintenance burden for little gain. |
I have tried to use "echo", but it doesn't works well.
This PR just provides an API for manipulating the statusBar in VSCode. |
That is what all Nvim plugins use. If it doesn't work well, that's an Nvim bug (or a bug in the UI protocol).
I'm strongly not in favor of that direction. Either we support Nvim plugins or we don't. Introducing a quasi-framework,
|
But most nvim plugins use temporary statusline or floating window to display prompt information. |
The implementation is very simple and the degree of coupling is also very low.
Anyway, many PRs are based on inconveniences I usually encounter. So the demand is there. |
? That sounds like an assumption. And it's not really an argument for introducing yet another interface.
All tech debt accumulates with that same local analysis, it ignores the long-term cost. |
refresh-status-items
StatusLineController
\n
with spacevscode.get_status_item(id)
id
(string): The identifier of the itemWhy not directly support
&statusline
?Firstly, changes to the
statusline
option need to be detected, and thennvim_eval_statusline
is used to obtain the content. This can be a bit tedious.If the
statusline
is used, debouncing is necessary to avoid unnecessary refreshes. However, debouncing also causes delays when content is actually refreshed.This API is intended to be used by plugin developers who want to be compatible with vscode-neovim, such as the prompt in
flash.nvim
. Ifstatusline
is used, the plugin needs to dynamically modifystatusline
, which obviously complicates simple things.flash.nvim demo