Hyper: Vim (neovim) cursor shape does not change (BLOCK to VLINE shape).

Created on 19 Jul 2016  路  11Comments  路  Source: vercel/hyper

On the terminal itself the cursor works fine and changes to BLOCK shape to VLINE shape but inside VIM its simple does not work.

Follow my configuration for the cursor shape on my .zshrc file:

        vicmd)      print -n -- "\E]50;CursorShape=0\C-G";;  # block cursor
        viins|main) print -n -- "\E]50;CursorShape=1\C-G";;  # line cursor

I've try all different bellow configurations on VIM without success:
http://stackoverflow.com/questions/6488683/how-do-i-change-the-vim-cursor-in-insert-normal-mode
http://vim.wikia.com/wiki/Change_cursor_shape_in_different_modes

For example, I can change the shape on iTerm2/VIM with the follow setup:

let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"

Appreciate any help at all.

Thanks!

help wanted Compatibility

Most helpful comment

Not sure if this is helpful, but it looks like something is causing the app to not recognise the cursor style (which is evaluating to 5):

image

Interestingly, I鈥檓 not able to find the code shown in the above bundle.js anywhere in Hyperterm鈥檚 source code, and it鈥檚 not coming from any of my plugins. 馃

This is the relevant section of my init.vim for Neovim (running on macOS), which accomplishes the same thing as @henryoliver鈥檚 setup above (see here for documentation from Neovim):

let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 " Cursor is pipe in Insert, block in Normal

All 11 comments

Btw for whoever submits a pull request to fix this, here's some CSS that will make the cursor a vertical line:

    // custom css to embed in the terminal window
    termCSS: '\
    .cursor-node {\
        background: none !important;\
        border: none !important;\
        border-left: 1px solid rgba(255, 255, 255, 0.7) !important;\
    }',

Not sure if this is helpful, but it looks like something is causing the app to not recognise the cursor style (which is evaluating to 5):

image

Interestingly, I鈥檓 not able to find the code shown in the above bundle.js anywhere in Hyperterm鈥檚 source code, and it鈥檚 not coming from any of my plugins. 馃

This is the relevant section of my init.vim for Neovim (running on macOS), which accomplishes the same thing as @henryoliver鈥檚 setup above (see here for documentation from Neovim):

let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 " Cursor is pipe in Insert, block in Normal

It's in the hterm-umdjs dependency.

It looks like there are actually two different sets of cursor changing escape codes. The first is ^[[50;CursorShape=1. That's what many people configure their Vim to use. The other one, which Neovim uses, is ^[[5 q. I think the reason Neovim uses this one is because it lets you specify that the cursor should blink. However, hterm only partially supports it. Block and underline cursors are supported, both blinking and not blinking, but I-beam cursors are not.

Fixing this would require fixing hterm, and should be as easy as a quick pull request. Unfortunately, hterm is part of the Chromium OS codebase, and Google does not make anything that easy when it comes to their open-source projects. If someone else can figure out how to contribute code to Chromium, they'd just have to add a few cases here.

Here's the iTerm2 pull request that added these escape sequences:

https://github.com/gnachman/iTerm2/pull/92

Interestingly, the neovim special cursor for replace mode does work. It's an underline which hterm does support.

Nice detective work, @tbodt! Hope this helps for future improvements. 馃暤馃徎

It looks like hterm is such a pain in the ass to contribute to that Hyper is already monkey patching it. I'm gonna pull request this.

Fixed in pull request #1286.

Having this issue in the latest version of canary, is it a regression from the change to xterm?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rauchg picture rauchg  路  3Comments

legomushroom picture legomushroom  路  3Comments

weabot picture weabot  路  3Comments

alejandrofloresm picture alejandrofloresm  路  3Comments

stan-stripe picture stan-stripe  路  3Comments