Skip to content
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: fully support the "guicursor" option #1876

Open
3 tasks done
tmpm697 opened this issue Apr 6, 2024 · 5 comments
Open
3 tasks done

feat: fully support the "guicursor" option #1876

tmpm697 opened this issue Apr 6, 2024 · 5 comments

Comments

@tmpm697
Copy link

tmpm697 commented Apr 6, 2024

Check the following:

  • I have checked the behavior after setting "vscode-neovim.neovimClean" in VSCode settings.
  • I have read the vscode-neovim docs.
  • I have searched existing issues.

Neovim version (nvim -v)

NVIM v0.9.4

Operating system/version

macos ventura 13.6.6

Describe the bug

I have this option: vim.o.guicursor = "a:ver100", epxect all cursor shape of all modes will be | but the visual/selecting mode still have block cursor shape.

Steps To Reproduce

just have above option in neovim config

Expected Behavior

epxect all cursor shape of all modes will be |

@tmpm697 tmpm697 added the bug Something isn't working label Apr 6, 2024
@justinmk
Copy link
Collaborator

justinmk commented Apr 7, 2024

confirmed w/ NVIM v0.10.0 9765efb40f5

@justinmk justinmk changed the title bug: cursor shape does not change for all modes? bug: 'guicursor' cursor shape not respected for visual/select mode Apr 7, 2024
@theol0403
Copy link
Member

It's because we hardcode the cursor style in visual mode. It is a "fake" cursor that is shown through the highlight provider, not the cursor provider.

fake_cursor = api.nvim_buf_set_extmark(0, fake_cursor_ns, line - 1, col - 1, {

I'm not even sure if the highlight API allows for cursor-like highlights.

@tmpm697

This comment was marked as off-topic.

@theol0403
Copy link
Member

@tmpm697 the primary cursor is the real cursor rendered in VSCode, which is actually the "primary selection" with 0 width. In vim visual mode, the selection and the cursor are two separate entities. To select the correct text, the vscode cursor is used for the selection, and a fake cursor is shown to represent the vim cursor.

We keep track of user's cursor settings for the main cursor:

this.cursorModes.set(mode.name, { cursorShape: mode.cursor_shape });

const modeConf = this.cursorModes.get(modeName);
if (!modeConf) {
return;
}
let style: TextEditorCursorStyle;
if (modeName == "visual") {
// in visual mode, we try to hide the cursor because we only use it for selections
style = TextEditorCursorStyle.LineThin;
} else if (modeConf.cursorShape === "block") {
style = TextEditorCursorStyle.Block;
} else if (modeConf.cursorShape === "horizontal") {
style = TextEditorCursorStyle.Underline;
} else {
style = TextEditorCursorStyle.Line;
}

@xiyaowong
Copy link
Collaborator

Currently, it's difficult to find a concise implementation method. "fake_cursor" is essentially just a special "highlight" without targeted handling logic in vscode. To fully support the "guicursor" option, we'd need to maintain a vscode decorator serving as the cursor, updating its color, shape, position, etc.

@xiyaowong xiyaowong changed the title bug: 'guicursor' cursor shape not respected for visual/select mode feat: fully support the "guicursor" option Apr 21, 2024
@xiyaowong xiyaowong removed the bug Something isn't working label Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants