Skip to content

Commit

Permalink
Update leap add config for set marker background color and char color
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Apr 2, 2023
1 parent b8c345f commit f088aba
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 16 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,13 @@ Based on [vim-leap](https://github.com/ggandor/leap.nvim) and configured through

| Setting | Description | Type | Default Value | Value |
| --------------------------- | -------------------------------------------- | ------- | ------------------------------ | ------------------ |
| vim.leap | Enable/disable leap plugin | Boolean | false | |
| vim.leapShowMarkerPosition | Set the position of the marker point display | String | "after" | "after" , "target" |
| vim.leapLabels | The characters used for jump marker name | String | "sklyuiopnm,qwertzxcvbahdgjf;" | |
| vim.leapCaseSensitive | Whether to consider case in search patterns | Boolean | false | |
| vim.leapBidirectionalSearch | Enable/disable bidirectional search | Boolean | false | |
| vim.leap.enable | Enable/disable leap plugin | Boolean | false | |
| vim.leap.showMarkerPosition | Set the position of the marker point display | String | "after" | "after" , "target" |
| vim.leap.labels | The characters used for jump marker name | String | "sklyuiopnm,qwertzxcvbahdgjf;" | |
| vim.leap.laseSensitive | Whether to consider case in search patterns | Boolean | false | |
| 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" |

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
19 changes: 16 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,21 +631,34 @@
"markdownDescription": "Set the position of the marker point display for Leap markers",
"default": "after"
},
"vim.leap.labels":{
"vim.leap.labels": {
"type": "string",
"markdownDescription": "Set the characters used for jump marker label.",
"default": "sklyuiopnm,qwertzxcvbahdgjf;"
},
"vim.leap.caseSensitive":{
"vim.leap.caseSensitive": {
"type": "boolean",
"markdownDescription": "Set to consider case sensitive in search patterns",
"default": false
},
"vim.leap.bidirectionalSearch":{
"vim.leap.bidirectionalSearch": {
"type": "boolean",
"markdownDescription": "Set to bidirectional search",
"default": false
},
"vim.leap.marker.backgroundColors": {
"type": "array",
"markdownDescription": "The background colors of the marker box",
"default": [
"#ccff88",
"#99ccff"
]
},
"vim.leap.marker.charColor": {
"type": "string",
"markdownDescription": "The color of the marker char",
"default": "#000000"
},
"vim.easymotion": {
"type": "boolean",
"markdownDescription": "Enable the [EasyMotion](https://github.com/easymotion/vim-easymotion) plugin for Vim.",
Expand Down
5 changes: 2 additions & 3 deletions src/actions/plugins/leap/Marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class MarkerDecoration {
private range: vscode.Range | undefined;
private textEditorDecorationType: vscode.TextEditorDecorationType;

private static backgroundColors = ['#ccff88', '#99ccff'];
constructor(editor: vscode.TextEditor, marker: Marker) {
this.editor = editor;
this.marker = marker;
Expand Down Expand Up @@ -75,7 +74,7 @@ class MarkerDecoration {
}
}

return MarkerDecoration.backgroundColors[index];
return configuration.leap.marker.backgroundColors[index]
}

show() {
Expand All @@ -87,7 +86,7 @@ class MarkerDecoration {
before: {
contentText: this.marker.label,
backgroundColor: this.calcDecorationBackgroundColor(),
color: '#000000',
color: configuration.leap.marker.charColor,
margin: `0 -1ch 0 0;
position: absolute;
font-weight: normal;`,
Expand Down
6 changes: 5 additions & 1 deletion src/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,15 @@ class Configuration implements IConfiguration {
easymotionJumpToAnywhereRegex = '\\b[A-Za-z0-9]|[A-Za-z0-9]\\b|_.|#.|[a-z][A-Z]';

leap: ILeapConfiguration = {
enable: true,
enable: false,
showMarkerPosition: 'after',
labels: 'sklyuiopnm,qwertzxcvbahdgjf;',
caseSensitive: false,
bidirectionalSearch: false,
marker: {
backgroundColors: ['#ccff88', '#99ccff'],
charColor: '#000000',
},
};

targets: ITargetsConfiguration = {
Expand Down
12 changes: 8 additions & 4 deletions src/configuration/iconfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,16 @@ export interface ITargetsConfiguration {
smartQuotes: ISmartQuotesConfiguration;
}

export interface ILeapConfiguration{
export interface ILeapConfiguration {
enable: boolean;
showMarkerPosition:'after' | 'target'
labels:string;
showMarkerPosition: 'after' | 'target';
labels: string;
caseSensitive: boolean;
bidirectionalSearch:boolean
bidirectionalSearch: boolean;
marker: {
backgroundColors: string[];
charColor: string;
};
}

export interface IConfiguration {
Expand Down
4 changes: 4 additions & 0 deletions test/testConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export class Configuration implements IConfiguration {
labels: 'sklyuiopnm,qwertzxcvbahdgjf;',
caseSensitive: false,
bidirectionalSearch: false,
marker: {
backgroundColors: ['#ccff88', '#99ccff'],
charColor:"#000000"
},
};
surround = false;
argumentObjectSeparators = [','];
Expand Down

0 comments on commit f088aba

Please sign in to comment.