diff --git a/README.md b/README.md index a1281e711e9..3ee78bdea73 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,19 @@ We have removed this option, due to it making VSCodeVim's performance suffer imm * In visual mode, start a search with * or # using the current selection * Type: Boolean (Default: `false`) +#### `"vim.cursorStylePerMode"` +* Configure a specific cursor style per mode, any modes omitted will use default cursor type +* Modes available are normal, insert, replace, visual, visualline, and visualblock +* Cursors available are line, block, underline, line-thin, block-outline, and underline-thin + +``` + "vim.cursorStylePerMode" : { + "normal": "underline", + "insert": "line-thin", + "replace": "block-outline" + } +``` + ### Neovim Integration We now have neovim integration for Ex-commands. If you want to take advantage of this integration, set `"vim.enableNeovim"` to `true`, and set your `"vim.neovimPath"`. If you don't have neovim installed, [install neovim here](https://github.com/neovim/neovim/wiki/Installing-Neovim). If you don't want to install neovim, all of the old functionality should still work as is (we would really suggest neovim installing though. The new Ex support is super cool, and we'd like to integrate neovim more in the future). diff --git a/package.json b/package.json index 009cbeb9dfa..af2d4096c25 100644 --- a/package.json +++ b/package.json @@ -542,6 +542,10 @@ "type": "boolean", "description": "Automatically apply the global flag, /g, to substitute commands. When set to true, use /g to mean only first match should be replaced.", "default": "false" + }, + "vim.cursorStylePerMode": { + "type": "object", + "description": "Customize cursor style per mode" } } } diff --git a/src/configuration/configuration.ts b/src/configuration/configuration.ts index ac4731abe9b..7c7cb49725e 100644 --- a/src/configuration/configuration.ts +++ b/src/configuration/configuration.ts @@ -12,13 +12,13 @@ export interface IHandleKeys { [key: string]: boolean; } -export interface IStatusBarColors { - normal: string; - insert: string; - visual: string; - visualline: string; - visualblock: string; - replace: string; +export interface IModeSpecificStrings { + normal: string | undefined; + insert: string | undefined; + visual: string | undefined; + visualline: string | undefined; + visualblock: string | undefined; + replace: string | undefined; } /** @@ -79,6 +79,9 @@ class ConfigurationClass { .getConfiguration() .get('editor.cursorStyle') as string; this.userCursor = this.cursorStyleFromString(cursorStyleString); + if (this.userCursor === undefined) { + this.userCursor = this.cursorStyleFromString('line'); + } // Get configuration setting for handled keys, this allows user to disable // certain key comboinations @@ -113,7 +116,7 @@ class ConfigurationClass { } } - private cursorStyleFromString(cursorStyle: string): vscode.TextEditorCursorStyle { + public cursorStyleFromString(cursorStyle: string): vscode.TextEditorCursorStyle | undefined { const cursorType = { line: vscode.TextEditorCursorStyle.Line, block: vscode.TextEditorCursorStyle.Block, @@ -126,7 +129,7 @@ class ConfigurationClass { if (cursorType[cursorStyle] !== undefined) { return cursorType[cursorStyle]; } else { - return vscode.TextEditorCursorStyle.Line; + return undefined; } } @@ -233,7 +236,7 @@ class ConfigurationClass { /** * Status bar colors to change to based on mode */ - statusBarColors: IStatusBarColors = { + statusBarColors: IModeSpecificStrings = { normal: '#005f5f', insert: '#5f0000', visual: '#5f00af', @@ -256,7 +259,7 @@ class ConfigurationClass { /** * Type of cursor user is using native to vscode */ - userCursor: number; + userCursor: number | undefined; /** * Use spaces when the user presses tab? @@ -309,6 +312,18 @@ class ConfigurationClass { * Automatically apply the /g flag to substitute commands. */ substituteGlobalFlag = false; + + /** + * Cursor style to set based on mode + */ + cursorStylePerMode: IModeSpecificStrings = { + normal: undefined, + insert: undefined, + visual: undefined, + visualline: undefined, + visualblock: undefined, + replace: undefined, + }; } function overlapSetting(args: { diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index 6fce5450fcb..be9c6981bf6 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -1845,10 +1845,21 @@ export class ModeHandler implements vscode.Disposable { cursorStyle = vscode.TextEditorCursorStyle.Underline; break; case VSCodeVimCursorType.Native: - cursorStyle = Configuration.userCursor; + if (Configuration.userCursor !== undefined) { + cursorStyle = Configuration.userCursor; + } break; } + const optionalCursorStyle = + Configuration.cursorStylePerMode[this._vimState.currentModeName().toLowerCase()]; + if (optionalCursorStyle !== undefined) { + const cursorStyleNum = Configuration.cursorStyleFromString(optionalCursorStyle); + if (cursorStyleNum !== undefined) { + cursorStyle = cursorStyleNum; + } + } + let options = this._vimState.editor.options; options.cursorStyle = cursorStyle; this._vimState.editor.options = options;