From b283ad761e6ba2ccd8cf31bcd0e2196d12403b2a Mon Sep 17 00:00:00 2001 From: Prashantha T P Date: Sun, 29 Aug 2021 21:46:52 +0530 Subject: [PATCH] (bugfix) fix #5, set cursor shape to vertical bar on leaving vim why: to distinguish between command and normal modes of vi mode in powershell how: using VimLeave event and guicursor option misc: see :help guicursor links: - https://github.com/neovim/neovim/issues/4867 - https://github.com/microsoft/terminal/issues/4335 tags: cursor,cursor-shape fixes #5 --- nvim/general/augroups.vim | 23 +++++++++++++++++++++++ nvim/general/cursor.vim | 23 +++++++++++++++++++++++ nvim/init.vim | 28 ++++------------------------ 3 files changed, 50 insertions(+), 24 deletions(-) create mode 100644 nvim/general/cursor.vim diff --git a/nvim/general/augroups.vim b/nvim/general/augroups.vim index e8beaa7..ad09b52 100644 --- a/nvim/general/augroups.vim +++ b/nvim/general/augroups.vim @@ -26,11 +26,34 @@ augroup END " --- }}} " Cursor management --- {{{ +"https://github.com/microsoft/terminal/issues/4335 +" +" https//vim.fandom.com/wiki/Configuring_the_cursor +" 1 or 0 -> blinking block +" 2 solid block +" 3 -> blinking underscore +" 4 solid underscore +" Recent versions of xterm (282 or above) also support +" 5 -> blinking vertical bar +" 6 -> solid vertical bar +" augroup CURSOR_MANAGEMENT autocmd! + +" powershell requires different format for escape codes +" see : +" (i) https://docs.microsoft.com/en-us/powershell/module/psreadline/set-psreadlineoption?view=powershell-5.1#example-6--use-vimodechangehandler-to-display-vi-mode-changes +" (ii) https://github.com/microsoft/terminal/issues/1604 +if has('win32') + "https://github.com/neovim/neovim/issues/4867#issuecomment-291249173" + autocmd VimEnter * silent !echo -ne "\e[2 q" + autocmd VimLeave * set guicursor=a:ver25 + +else autocmd VimEnter * silent !echo -ne "\e[2 q" autocmd VimLeave * silent !echo -ne "\e[6 q" " autocmd VimLeave * let &t_me="\]50;CursorShape=1\x7" " autocmd VimLeave * let &t_SI.="\[6 q" +endif augroup END " }} diff --git a/nvim/general/cursor.vim b/nvim/general/cursor.vim new file mode 100644 index 0000000..4640c59 --- /dev/null +++ b/nvim/general/cursor.vim @@ -0,0 +1,23 @@ +" also see augroups.vim +" cursor ----- {{{ +" Cursor in terminal +" https//vim.fandom.com/wiki/Configuring_the_cursor +" 1 or 0 -> blinking block +" 2 solid block +" 3 -> blinking underscore +" 4 solid underscore +" Recent versions of xterm (282 or above) also support +" 5 -> blinking vertical bar +" 6 -> solid vertical bar +if &term =~ '^xterm' + " normal mode || + " .= means shorthand for appending : see help .= + let &t_EI .= "\[1 q" + " replace mode _ + let &t_SR .= "\e[4 q" + " insert mode | + let &t_SI .= "\[6 q" +endif +" +" }}} + diff --git a/nvim/init.vim b/nvim/init.vim index 55590df..b88620f 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -1,41 +1,21 @@ let mapleader = "\" source $LOCALAPPDATA/nvim/general/augroups.vim + source $LOCALAPPDATA/nvim/plugs/plugins.vim source $LOCALAPPDATA/nvim/plugs/coc.vim source $LOCALAPPDATA/nvim/plugs/lightline_v1.vim source $LOCALAPPDATA/nvim/plugs/telescope_plug.vim source $LOCALAPPDATA/nvim/plugs/firenvim.vim source $LOCALAPPDATA/nvim/plugs/markdown.vim + +source $LOCALAPPDATA/nvim/general/cursor.vim source $LOCALAPPDATA/nvim/general/general.vim source $LOCALAPPDATA/nvim/general/leader.vim source $LOCALAPPDATA/nvim/general/keybindings.vim + source $LOCALAPPDATA/nvim/languages/languages.vim "set path+=** hi Normal ctermbg=none guibg=none -"wrap backspace -set backspace=indent,eol,start hi Comment gui=italic cterm=italic hi htmlArg gui=italic cterm=italic -" cursor ----- {{{ -" Cursor in terminal -" https//vim.fandom.com/wiki/Configuring_the_cursor -" 1 or 0 -> blinking block -" 2 solid block -" 3 -> blinking underscore -" 4 solid underscore -" Recent versions of xterm (282 or above) also support -" 5 -> blinking vertical bar -" 6 -> solid vertical bar -if &term =~ '^xterm' -" normal mode || -let &t_EI .= "\[1 q" -" replace mode _ -let &t_SR.="\e[4 q" -" insert mode | -let &t_SI .= "\[6 q" -endif -" -" }}} - -