1

I am trying to disable the cursor (guicursor) while in insert mode in NeoVim to emulate a typewriter style environment.

To that effect I set guicursor (default is vim.opt.guicursor="n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20" ) to i:ver0 and i:nil. The first I inferred from the docs while the latter was a stab in the dark.

Using i:ver0 returns "invalid percentage," while i:nil also outputs an error message. Neither works.

I asked at NeoVim's GitHub and they suggested to send an event from the UI, namely:

["busy_start"] ["busy_stop"] Indicates to the UI that it must stop rendering the cursor. This event is misnamed and does not actually have anything to do with busyness.

My issue is I am at a loss as to how to accomplish that. Tried setting the usual vim.opt but they don't seem to take.

Also, if you have any idea on how to trigger that event only when entering insert mode, it would be greatly greatly appreciated.

2
  • I've made some small edits, but I don't think neovim.io is the "wiki." Would you mind linking to (a) the page that suggested the default guicursor (probably :help guicursor?) and (b) the GitHub conversation?
    – D. Ben Knoble
    Commented Aug 9, 2023 at 16:06
  • Added the links. Apologies for not including them right from the get-go.
    – Anthony
    Commented Aug 9, 2023 at 16:11

1 Answer 1

1
-- typewriter.lua

local ffi = require("ffi")

ffi.cdef([[
void ui_busy_start(void);
void ui_busy_stop(void);
]])

vim.api.nvim_create_autocmd({"InsertEnter"}, {
  callback = function()
    ffi.C.ui_busy_start()
  end
})

vim.api.nvim_create_autocmd({"InsertLeave"}, {
  callback = function()
    ffi.C.ui_busy_stop()
  end
})

Answer provided not by me but by ad-chaos over at https://github.com/neovim/neovim/discussions/24612#discussioncomment-6683538

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.