Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ Based on [vim-leap](https://github.com/ggandor/leap.nvim) and configured through
| vim.leap.bidirectionalSearch | Enable/disable bidirectional search | Boolean | false | |
| vim.leap.marker.backgroundColors | The background colors of the marker box. | Array | ['#ccff88', '#99ccff'] |
| vim.leap.marker.charColor | The color of the marker char. | String | "#000000" |
| vim.leap.dim | Enable/Disable dim for leap | Boolean | true | |
| vim.leap.dimColor | The dim color | String | "#777777" | |

Once leap is active, initiate motions using the following commands.After you initiate the motion, text decorators/markers will be displayed and you can press the keys displayed to jump to that position. For visual mode leap uses x instead of s because s is already taken by the surround plugin.

Expand Down
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,16 @@
"markdownDescription": "The color of the marker char",
"default": "#000000"
},
"vim.leap.dim": {
"type": "boolean",
"default": true,
"markdownDescription": "Enable the dimming of characters when using Leap"
},
"vim.leap.dimColor": {
"type": "string",
"default": "#777777",
"markdownDescription": "Set a custom color for the leap dimmed characters when `#vim.leap.dim#` is set to true."
},
"vim.easymotion": {
"type": "boolean",
"markdownDescription": "Enable the [EasyMotion](https://github.com/easymotion/vim-easymotion) plugin for Vim.",
Expand Down Expand Up @@ -1238,4 +1248,4 @@
"*.{ts,js,json,md,yml}": "prettier --write",
"*.ts": "tslint --fix"
}
}
}
1 change: 1 addition & 0 deletions src/actions/plugins/leap/LeapAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class LeapPrepareAction extends BaseCommand {
);

leap.showMarkers();
leap.setDimmingZones();
await vimState.setCurrentMode(Mode.LeapPrepareMode);
}

Expand Down
28 changes: 27 additions & 1 deletion src/actions/plugins/leap/leap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { VimState } from '../../../state/vimState';
import { LeapAction } from './LeapAction';
import { Position } from 'vscode';
import { configuration } from '../../../configuration/configuration';
import * as vscode from 'vscode';

export enum LeapSearchDirection {
Forward = -1,
Expand All @@ -21,6 +22,10 @@ export class Leap {
direction?: LeapSearchDirection;
leapAction?: LeapAction;
firstSearchString?: string;
dimmingZone = vscode.window.createTextEditorDecorationType({
// to prevent empty string of dimColor
color: configuration.leap.dimColor || '#777777',
});

constructor(vimState: VimState) {
this.vimState = vimState;
Expand All @@ -37,6 +42,21 @@ export class Leap {
return this.markers;
}

public setDimmingZones() {
if (!configuration.leap.dim) return;
const dimmingZones: vscode.DecorationOptions[] = [];
const dimmingRenderOptions: vscode.ThemableDecorationRenderOptions = {
// we update the color here again in case the configuration has changed
color: configuration.leap.dimColor || '#777777',
};
dimmingZones.push({
// fill the whole document
range: new vscode.Range(0, 0, this.vimState.editor.document.lineCount, 0),
renderOptions: dimmingRenderOptions,
});
this.vimState.editor.setDecorations(this.dimmingZone, dimmingZones);
}

private setMarkersName() {
const map: Map<string, Marker[]> = new Map();

Expand Down Expand Up @@ -147,6 +167,11 @@ export class Leap {
this.markers = [];
}

public cleanupDimmingZones() {
if (!configuration.leap.dim) return;
this.vimState.editor.setDecorations(this.dimmingZone, []);
}

public showMarkers() {
this.markers.forEach((marker) => {
marker.show();
Expand Down Expand Up @@ -236,5 +261,6 @@ export function getLeapInstance(): Leap {
}

export function disposeLeap() {
leap?.cleanupMarkers()
leap?.cleanupMarkers();
leap?.cleanupDimmingZones();
}
2 changes: 2 additions & 0 deletions src/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ class Configuration implements IConfiguration {
backgroundColors: ['#ccff88', '#99ccff'],
charColor: '#000000',
},
dim: true,
dimColor: '#777777',
};

targets: ITargetsConfiguration = {
Expand Down
2 changes: 2 additions & 0 deletions src/configuration/iconfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export interface ILeapConfiguration {
backgroundColors: string[];
charColor: string;
};
dim: boolean;
dimColor: string;
}

export interface IConfiguration {
Expand Down
4 changes: 3 additions & 1 deletion test/testConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ export class Configuration implements IConfiguration {
bidirectionalSearch: false,
marker: {
backgroundColors: ['#ccff88', '#99ccff'],
charColor:"#000000"
charColor: '#000000',
},
dim: true,
dimColor: '#777777',
};
surround = false;
argumentObjectSeparators = [','];
Expand Down