-
-
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: handle nvim statusline #1895
feat: handle nvim statusline #1895
Conversation
8c48219
to
f568553
Compare
Why is this needed? Can users use
Please, no.
Premature optimization. RPC calls are cheap. |
There are two differences:
My personal understanding is that I am neutral about this PR |
Alternatively, after this PR, can we remove |
I suggest not. There are already plugins using this API. 😶 |
That really doesn't matter. The worst case scenario is simply that people get the default statusline. That doesn't break anyone. We need to focus on simplifying this codebase. |
Let's keep this for now, because it's indeed more convenient compared to statusline. Here are the current use cases. It would be difficult to achieve the same effect without letting users configure it if we were to use statusline. |
How is it more convenient? Nvim 'statusline' allows users to configure their statusline. If users want to set the vscode statusline, they could just configure the Nvim 'statusline'.
? folke/flash.nvim#269 is just setting the |
f568553
to
b39cd30
Compare
After careful consideration, you are correct. I was thinking from the perspective of a vscode-neovim user and being familiar with the |
d5cf8cc
to
2e1155e
Compare
2e1155e
to
35b0785
Compare
4083ffe
to
1760250
Compare
let sl = (await this.client.lua(` | ||
if vim.o.laststatus == 0 then return "" end | ||
return vim.api.nvim_eval_statusline(vim.o.statusline, {}).str | ||
`)) as any as string; |
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.
Just FYI: after the next node-client release, the as any
can be dropped. neovim/node-client#353
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.
Beautiful!
BREAKING CHANGE: vscode.get_status_item has been removed.
1760250
to
f6dd0ef
Compare
const refreshNvimStatusLineTimer = setInterval(async () => { | ||
let sl = (await this.client.lua(` | ||
if vim.o.laststatus == 0 then return "" end | ||
return vim.api.nvim_eval_statusline(vim.o.statusline, {}).str |
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.
When 'statusline' option is blank, Nvim still shows a statusline. In that case, the vscode statusline will be blank even though Nvim's rendered statusline is not blank.
That's a historical quirk of Vim, not really up to vscode-neovim to work around it. Tracking issue: neovim/neovim#28444
OTOH, it's probably good that users can disable this vscode-neovim behavior by setting 'statusline' to empty. We can just mention in the docs that if they want the default statusline, they can set it as follows:
set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
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.
When 'statusline' option is blank, Nvim still shows a statusline. In that case, the vscode statusline will be blank even though Nvim's rendered statusline is not blank.
I thought about this, I don't think anyone needs this default statusline
OTOH, it's probably good that users can disable this vscode-neovim behavior by setting 'statusline' to empty
Yes. So I removed the settings for the laststatus and statusline options instead of setting a default value :)
Resolve #1809
"get_status_item" has been removed.
This is a relatively simple implementation at the moment, with a few points to discuss:
Setting a different background color.Be simpleMaking the refresh interval configurable.Be simpleIn nvim, detecting changes in the statusline and then notifying vscode for updates can reduce RPC calls and make refreshes more timely. However, this approach leads to less concise code.RPC calls are cheap.