Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b40d370
delete compiled files from repository
elazarcoh Jan 12, 2022
a6afe15
init
elazarcoh Jan 13, 2022
e631dbb
change Style to DecorationRenderOptions
elazarcoh Jan 14, 2022
93b79d7
make configurations more sensible
elazarcoh Jan 16, 2022
6b22074
Correct small typo on README.md
jonz94 Mar 29, 2022
3b8805c
Bump terser from 5.7.2 to 5.14.2
dependabot[bot] Jul 20, 2022
2fa1ffa
Merge pull request #53 from jgclark/dependabot/npm_and_yarn/terser-5.…
jgclark Jul 20, 2022
01e5ae3
Bump nth-check from 2.0.0 to 2.1.1
dependabot[bot] Jul 20, 2022
fcab1bf
Bump ansi-regex from 3.0.0 to 3.0.1
dependabot[bot] Jul 20, 2022
40c1bd0
Merge pull request #55 from jgclark/dependabot/npm_and_yarn/ansi-rege…
jgclark Jul 20, 2022
e45e20b
Merge pull request #54 from jgclark/dependabot/npm_and_yarn/nth-check…
jgclark Jul 20, 2022
1923482
creates diagnostics for open files
farwyler Oct 28, 2022
bf54e46
Merge pull request #58 from farwyler/enable-diagnostics
jgclark Oct 29, 2022
700c865
Bump nanoid and mocha
dependabot[bot] Oct 29, 2022
06d929f
Bump markdown-it and vsce
dependabot[bot] Oct 29, 2022
be55281
Followup: Fix wrong syntax
alkatar21 Oct 29, 2022
7f11abb
Merge pull request #60 from jgclark/dependabot/npm_and_yarn/nanoid-an…
jgclark Oct 29, 2022
9354cfa
Merge pull request #61 from jgclark/dependabot/npm_and_yarn/markdown-…
jgclark Oct 29, 2022
a75054a
Merge pull request #51 from jonz94/master
jgclark Oct 29, 2022
a523a5f
Merge pull request #62 from alkatar21/patch-1
jgclark Oct 29, 2022
db9898b
Merge pull request #46 from elazarcoh/master
jgclark Oct 29, 2022
98cabca
Merge branch 'to-ts'
elazarcoh Nov 2, 2022
4e1b4aa
update config
elazarcoh Nov 2, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
HOWTO-publish.md
.vscode/tasks.json
node_modules/
dist/
.vsixmanifest
vsc-todo-highlight.code-workspace
todo-highlight.code-workspace
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
],
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "npm: webpack"
}
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
"npm.packageManager": "npm",
}
2 changes: 0 additions & 2 deletions dist/extension.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/extension.js.map

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
"scripts": {
"vscode:prepublish": "webpack --mode production",
"webpack": "webpack --mode development",
"webpack-dev": "webpack --mode development --watch",
"postinstall": "node ./node_modules/vscode/bin/install"
"webpack-dev": "webpack --mode development --watch"
},
"badges": [
{
Expand Down Expand Up @@ -272,9 +271,10 @@
"devDependencies": {
"@types/mocha": "^2.2.32",
"@types/node": "^6.0.40",
"@types/vscode": "^1.0.0",
"@types/vscode": "^1.63.1",
"eslint": "^7.18.0",
"mocha": "^8.2.0",
"ts-loader": "^9.2.6",
"typescript": "^4.1.2",
"webpack-cli": "^4.x.x"
},
Expand Down
151 changes: 151 additions & 0 deletions src/config-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import { ConfigurationScope, ConfigurationTarget, workspace } from 'vscode';

type InspectReturnValue<C extends { [key: string]: any }, K extends keyof C> = {
key: string;
defaultValue?: C[K];
globalValue?: C[K];
workspaceValue?: C[K];
workspaceFolderValue?: C[K];
defaultLanguageValue?: C[K];
globalLanguageValue?: C[K];
workspaceLanguageValue?: C[K];
workspaceFolderLanguageValue?: C[K];
languageIds?: string[];
};

export function ConfigurationGetter<C extends { [key: string]: any }>(
section: string
) {
return <K extends keyof C>(
subsection: K,
scope?: ConfigurationScope | null,
defaultValue?: C[K]
) => {
const config = workspace.getConfiguration(section, scope);
// @ts-expect-error subsection is always of type string, though the compiler doesn't see it
return config.get<C[K] | undefined>(subsection, defaultValue);
};
}

export function ConfigurationInspector<C extends { [key: string]: any }>(
section: string
) {
return <K extends keyof C>(
subsection: K,
scope?: ConfigurationScope | null
): InspectReturnValue<C, K> => {
const config = workspace.getConfiguration(section, scope);
// @ts-expect-error subsection is always of type string, though the compiler doesn't see it
return config.inspect(subsection);
};
}

export function ConfigurationSetter<C extends { [key: string]: any }>(
section: string
) {
return <K extends keyof C>(
subsection: K,
value: C[K],
scope?: ConfigurationScope | null,
configurationTarget?: boolean | ConfigurationTarget | null,
overrideInLanguage?: boolean
) => {
const config = workspace.getConfiguration(section, scope);
return config.update(
// @ts-expect-error subsection is always of type string, though the compiler doesn't see it
subsection,
value,
configurationTarget,
overrideInLanguage
);
};
}

interface IGet<C extends { [key: string]: any }> {
get<K extends keyof C>(
subsection: K,
scope?: ConfigurationScope | null
): C[K] | undefined;
get<K extends keyof C>(
subsection: K,
scope: ConfigurationScope | null | undefined,
defaultValue: C[K]
): C[K];
}

interface IInspect<C extends { [key: string]: any }> {
inspect<K extends keyof C>(
subsection: K
): InspectReturnValue<C, K> | undefined;
}

interface IUpdate<C extends { [key: string]: any }> {
update<K extends keyof C>(
subsection: K,
value: C[K],
scope?: ConfigurationScope,
configurationTarget?: boolean | ConfigurationTarget,
overrideInLanguage?: boolean
): Thenable<void>;
}

export class VSCodeConfigurations<C extends { [key: string]: any }>
implements IGet<C>, IUpdate<C>, IInspect<C>
{
private _get: <K extends keyof C>(
subsection: K,
scope?: ConfigurationScope | null,
defaultValue?: C[K]
) => C[K] | undefined;
private _inspect: <K extends keyof C>(
subsection: K
) => InspectReturnValue<C, K>;
private _update: <K extends keyof C>(
subsection: K,
value: C[K],
scope?: ConfigurationScope | null,
configurationTarget?: boolean | ConfigurationTarget | null,
overrideInLanguage?: boolean
) => Thenable<void>;

constructor(readonly section: string) {
this._get = ConfigurationGetter<C>(section);
this._update = ConfigurationSetter<C>(section);
this._inspect = ConfigurationInspector<C>(section);
}

update<K extends keyof C>(
subsection: K,
value: C[K],
scope?: ConfigurationScope,
configurationTarget?: boolean | ConfigurationTarget,
overrideInLanguage?: boolean
): Thenable<void> {
return this._update(
subsection,
value,
scope,
configurationTarget,
overrideInLanguage
);
}

inspect<K extends keyof C>(
subsection: K
): InspectReturnValue<C, K> | undefined {
return this._inspect(subsection);
}

get<K extends keyof C>(
subsection: K,
scope?: ConfigurationScope | null
): C[K] | undefined;
get<K extends keyof C>(
subsection: K,
scope: ConfigurationScope | null | undefined,
defaultValue: C[K]
): C[K];
get(subsection: any, scope?: any, defaultValue?: any) {
return this._get(subsection, scope, defaultValue);
}
}
93 changes: 93 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { ConfigurationScope, ConfigurationTarget, workspace } from 'vscode';
import { VSCodeConfigurations } from './config-utils';

export interface Style {
Comment thread
elazarcoh marked this conversation as resolved.
Outdated
/**
* The background color for the highlight.
*/
backgroundColor?: string;
/**
* The border style for the highlight, as a CSS string.
*/
border?: string;
/**
* The text color.
*/
color?: string;
/**
* The style for the cursor shown over the highlight, as a CSS property.
*/
cursor?: string;
/**
* If true, then the whole line is highlighted, not just the matching text.
*/
isWholeLine?: boolean;
/**
* The color of the ruler mark on the scroll bar.
*/
overviewRulerColor?: string;
}

export interface TextKeyword extends Style {
/**
* Custom text to be highlighted.
*/
text: string;
}
export interface RegExpKeyword extends Style {
/**
* name of the regexp keyword.
*/
text: string;
regex: {
/**
* The RegEx pattern to use for matching instead of the text value. REMEMBER to escape any backslashes in your regexp (using \\ instead of single backslash).
*/
pattern: string;
};
}

export type Keyword = TextKeyword | RegExpKeyword;

export interface TODOHighlightConfig {
/**
* Enable or disable the highlighting
*/
isEnable: boolean;
/**
* Specify whether the keywords are case sensitive or not
*/
isCaseSensitive: boolean;
/**
* If the file path within the output channel is not clickable, set this to true to toggle the path patten between `<path>#<line>` and `<path>:<line>:<column>`
*/
toggleURI: boolean;
/*
* An array of keywords, and their CSS to customise how they look. See all available properties in the [VSCode doc on DecorationRenderOptions](https://code.visualstudio.com/api/references/vscode-api#DecorationRenderOptions) section.
*/
keywords: (string | Keyword)[];
/**
* Specify keywords via RegExp instead of `todohighlight.keywords` one by one. NOTE that if this present, `todohighlight.keywords` will be ignored. REMEMBER to escapse any backslashes in your regexp (using \\ instead of single backslash).
*/
keywordsPattern: string;
/**
* Default style for all customized keywords. See all available properties in the [VSCode doc on DecorationRenderOptions](https://code.visualstudio.com/api/references/vscode-api#DecorationRenderOptions) section.
*/
defaultStyle: Style;
/**
* Glob patterns that defines the files to search for. Only include files you need, DO NOT USE `{** /*.*}` for both performance and to avoid binary files.
*/
include: string[];
/**
* Glob pattern that defines files and folders to exclude while listing annotations.
*/
exclude: string[];
/**
* Max files for searching
*/
maxFilesForSearch: number;
}


const EXTENSION = 'todohighlight';
export const configurations = new VSCodeConfigurations<TODOHighlightConfig>(EXTENSION);
Loading