diff --git a/README.md b/README.md index 4d8edd6..6249782 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,17 @@ -# Line Note +# Line Note Plus -Line Note is VSCode extension to add notes to the line of code. +Line Note Plus is a VSCode extension to add Markdown notes to your code +that are visible when hovering over the noted line. -[VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=tkrkt.linenote) +[VSCode Marketplace](https://marketplace.visualstudio.com/items?itemName=prmichaelsen.linenoteplus) ## Features -Select lines and invoke `Add note at current position` from the command palette or context menu. +Invoke `Add note at current position` from the command palette or context menu. You can see the note you wrote as hover text. -Notes are saved in `$PROJECT_ROOT/.vscode/linenote` like `.vscode/linenote/path/to/code.js#L13-L42.md`. +Notes are saved in `$PROJECT_ROOT/.vscode/linenoteplus` like `.vscode/linenoteplus/.md`. -![example](https://i.imgur.com/KlQtCsL.gif) - -Tips: You can put hyperlinks in notes by writing `#L42` or `../foo.js#L12-L15`. +### Demo +* Adding and removeing notes: https://storage.googleapis.com/com-f5-parm.appspot.com/parm/images/XK7AHFrBrfD7LpliwDX5.quicktime +* Notes move with code: https://storage.googleapis.com/com-f5-parm.appspot.com/parm/images/KbetjziHdRWmfHpJu5FN.quicktime \ No newline at end of file diff --git a/package.json b/package.json index a4c7855..9575a2f 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "linenote", - "displayName": "Line Note", + "name": "linenoteplus", + "displayName": "Line Note Plus", "description": "Add notes to the line of source code", - "version": "1.2.1", - "publisher": "tkrkt", + "version": "1.2.2", + "publisher": "prmichaelsen", "engines": { "vscode": "^1.30.0" }, @@ -17,12 +17,14 @@ ], "repository": { "type": "git", - "url": "https://github.com/tkrkt/linenote.git" + "url": "https://github.com/prmichaelsen/linenoteplus.git" }, "keywords": [ "vscode", "note", "comment", + "notataion", + "annotation", "line", "tooltip" ], @@ -30,58 +32,58 @@ "contributes": { "commands": [ { - "command": "linenote.addNote", + "command": "linenoteplus.addNote", "title": "%command.addNote.title%" }, { - "command": "linenote.openNote", + "command": "linenoteplus.openNote", "title": "%command.openNote.title%" }, { - "command": "linenote.revealLine", + "command": "linenoteplus.revealLine", "title": "%command.revealLine.title%" }, { - "command": "linenote.removeNote", + "command": "linenoteplus.removeNote", "title": "%command.removeNote.title%" } ], "menus": { "editor/context": [ { - "command": "linenote.addNote" + "command": "linenoteplus.addNote" }, { - "command": "linenote.revealLine", + "command": "linenoteplus.revealLine", "when": "isActiveEditorNote" } ] }, "configuration": { "type": "object", - "title": "Line Note", + "title": "Line Note Plus", "properties": { - "linenote.lineColor": { + "linenoteplus.lineColor": { "type": "string", "default": "rgba(255, 255, 0, 0.05)", "description": "%configuration.lineColor.description%" }, - "linenote.rulerColor": { + "linenoteplus.rulerColor": { "type": "string", "default": "rgba(255, 255, 0, 0.4)", "description": "%configuration.rulerColor.description%" }, - "linenote.cleanUpOrphanedNotesInterval": { + "linenoteplus.cleanUpOrphanedNotesInterval": { "type": "integer", "default": 60000, "description": "%configuration.cleanUpOrphanedNotesInterval.description%" }, - "linenote.showGutterIcon": { + "linenoteplus.showGutterIcon": { "type": "boolean", "default": true, "description": "%configuration.showGutterIcon.description%" }, - "linenote.gutterIconPath": { + "linenoteplus.gutterIconPath": { "type": [ "string", "null" @@ -89,7 +91,7 @@ "default": "images/gutter.png", "description": "%configuration.gutterIconPath.description%" }, - "linenote.cleanUpOrphanedNotes": { + "linenoteplus.cleanUpOrphanedNotes": { "type": [ "on-save", "on-interval", @@ -99,11 +101,11 @@ "default": "on-save-and-on-interval", "description": "%configuration.cleanUpOrphanedNotes.description%" }, - "linenote.includePaths": { + "linenoteplus.includePaths": { "type": "array", "default": [ "**/src/**/*", - "**/.vscode/linenote/**/*" + "**/.vscode/linenoteplus/**/*" ], "description": "%configuration.includePaths.description%" } @@ -111,11 +113,11 @@ } }, "scripts": { - "vscode:prepublish": "yarn run compile", + "vscode:prepublish": "npm run compile", "compile": "tsc -p ./", "watch": "tsc -watch -p ./", "postinstall": "node ./node_modules/vscode/bin/install", - "test": "yarn run compile && node ./node_modules/vscode/bin/test" + "test": "npm run compile && node ./node_modules/vscode/bin/test" }, "devDependencies": { "@types/chokidar": "^1.7.5", diff --git a/package.nls.json b/package.nls.json index cc88046..7c36090 100644 --- a/package.nls.json +++ b/package.nls.json @@ -1,8 +1,8 @@ { - "command.addNote.title": "Line Note: Add note at current position", + "command.addNote.title": "Line Note Plus: Add note at current position", "command.openNote.title": "Line Note: Edit note at current position", - "command.revealLine.title": "Line Note: Reveal line in notated file", - "command.removeNote.title": "Line Note: Remove note at current position", + "command.revealLine.title": "Line Note Plus: Reveal line in notated file", + "command.removeNote.title": "Line Note Plus: Remove note at current position", "configuration.cleanUpOrphanedNotesInterval.description": "Interval at which to clean up unused notes in the background in ms. Only applies if cleanupOprhanedNotes is set to 'on-interval' or 'on-save-and-on-interval'. Default: 60000 (60s). For performance, a large value is recommended. In order to determine if a note has a corresponding marker, the entire project directory must be scanned.", "configuration.cleanUpOrphanedNotes.description": "Whether to cleanup orphaned notes on save file, on change file, on an interval, or never. Default: 'on-save'. Warning: On change file will provide more realtime updates but may affect performance and will delete note files instantly if not found in the changed file. Requires reload.", "configuration.includePaths.description": "File pattern globs to scan for note markers. Unmatched directories will be ignored.", diff --git a/src/DocumentLinkProvider.ts b/src/DocumentLinkProvider.ts index d3d2697..671e28b 100644 --- a/src/DocumentLinkProvider.ts +++ b/src/DocumentLinkProvider.ts @@ -17,7 +17,7 @@ export class NoteLinkProvider implements DocumentLinkProvider { const editEndPosition = new Position(line.lineNumber, editIndex + editText.length); const editRange = new Range(editPosition, editEndPosition); const editUri = Uri.parse( - `command:linenote.openNote?${encodeURIComponent( + `command:linenoteplus.openNote?${encodeURIComponent( JSON.stringify(uuid) )}` ); @@ -26,7 +26,7 @@ export class NoteLinkProvider implements DocumentLinkProvider { const removeEndPosition = new Position(line.lineNumber, removeIndex + removeText.length); const removeRange = new Range(removePosition, removeEndPosition); const removeUri = Uri.parse( - `command:linenote.removeNote?${encodeURIComponent( + `command:linenoteplus.removeNote?${encodeURIComponent( JSON.stringify(uuid) )}` ); diff --git a/src/decorator.ts b/src/decorator.ts index c1519e7..7231f2a 100644 --- a/src/decorator.ts +++ b/src/decorator.ts @@ -30,23 +30,23 @@ export class Decorator { const gutterProp: vscode.DecorationRenderOptions = {}; // set line color - const line: string | undefined = config.get("linenote.lineColor"); + const line: string | undefined = config.get("linenoteplus.lineColor"); if (line && line.trim().length) { noteMarkerProp.backgroundColor = line.trim(); } // set ruler color - const ruler: string | undefined = config.get("linenote.rulerColor"); + const ruler: string | undefined = config.get("linenoteplus.rulerColor"); if (ruler && ruler.trim().length) { noteMarkerProp.overviewRulerLane = vscode.OverviewRulerLane.Right; noteMarkerProp.overviewRulerColor = ruler.trim(); } const showGutterIcon: boolean | undefined = config.get( - "linenote.showGutterIcon" + "linenoteplus.showGutterIcon" ); if (showGutterIcon) { - let iconPath: string | null = config.get("linenote.gutterIconPath")!; + let iconPath: string | null = config.get("linenoteplus.gutterIconPath")!; if (iconPath) { gutterProp.gutterIconPath = iconPath; } else { diff --git a/src/editorUtil.ts b/src/editorUtil.ts index 8a0a9b6..a8701e7 100644 --- a/src/editorUtil.ts +++ b/src/editorUtil.ts @@ -46,7 +46,7 @@ export const onDidSaveTextDocument = async (document: vscode.TextDocument) => { // decorate call is debounced. uuidsToDelete.forEach(async uuid => { if (uuid) { - await vscode.commands.executeCommand('linenote.removeNote', uuid); + await vscode.commands.executeCommand('linenoteplus.removeNote', uuid); } }); } diff --git a/src/extension.ts b/src/extension.ts index 3e02389..ae3bbbd 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -33,7 +33,7 @@ export const activate = (context: vscode.ExtensionContext) => { const exclude: any = conf.get('files.exclude'); const excludeFiles = { ...exclude, - ['.vscode/linenout']: true, + ['.vscode/linenoteplus']: true, }; conf.update('files.exclude', excludeFiles); @@ -46,7 +46,7 @@ export const activate = (context: vscode.ExtensionContext) => { } const interval = vscode.workspace .getConfiguration() - .get("linenote.cleanUpOrphanedNotesInterval"); + .get("linenoteplus.cleanUpOrphanedNotesInterval"); if (typeof interval === "number" && interval >= 0) { const start = +new Date(); await cleanUpOrphanedNotes(); @@ -65,7 +65,7 @@ export const activate = (context: vscode.ExtensionContext) => { // set cleanup orphaned nodes logic // based on conf const cleanupOrphanedNodes = - conf.get('linenote.cleanUpOrphanedNotes')!; + conf.get('linenoteplus.cleanUpOrphanedNotes')!; switch (cleanupOrphanedNodes) { case 'on-save': cleanupOnSave(); @@ -138,23 +138,23 @@ export const activate = (context: vscode.ExtensionContext) => { const note = globalActiveNoteMarkers[uuid]; const body = await note.read(); if (!body.trim().length) { - await vscode.commands.executeCommand('linenote.removeNote', uuid); + await vscode.commands.executeCommand('linenoteplus.removeNote', uuid); } }), vscode.workspace.onDidChangeConfiguration(async event => { if ( - event.affectsConfiguration("linenote.lineColor") || - event.affectsConfiguration("linenote.rulerColor") || - event.affectsConfiguration("linenote.cleanupOrphanedNotes") || - event.affectsConfiguration("linenote.cleanupOrphanedNotesInterval") + event.affectsConfiguration("linenoteplus.lineColor") || + event.affectsConfiguration("linenoteplus.rulerColor") || + event.affectsConfiguration("linenoteplus.cleanupOrphanedNotes") || + event.affectsConfiguration("linenoteplus.cleanupOrphanedNotesInterval") ) { decorator.reload(); decorator.decorate(); } }), - registerCommand('linenote.addNote', async (_uuid?: string) => { + registerCommand('linenoteplus.addNote', async (_uuid?: string) => { const editor = getEditor(); const filePath = editor.document.uri.fsPath; const noteDir = getNotesDir(editor.document.fileName); @@ -194,7 +194,7 @@ export const activate = (context: vscode.ExtensionContext) => { await note.open(); }), - registerCommand('linenote.openNote', async (uuid?: string) => { + registerCommand('linenoteplus.openNote', async (uuid?: string) => { const editor = getEditor(); const filePath = editor.document.uri.fsPath; const noteDir = getNotesDir(editor.document.fileName); @@ -230,7 +230,7 @@ export const activate = (context: vscode.ExtensionContext) => { }), registerCommand( - "linenote.removeNote", + "linenoteplus.removeNote", async (uuid?: string) => { const _uuid = uuid || Note.matchUuidOnActiveLine(getEditor()); if (_uuid) { @@ -251,7 +251,7 @@ export const activate = (context: vscode.ExtensionContext) => { } ), - registerCommand("linenote.revealLine", async () => { + registerCommand("linenoteplus.revealLine", async () => { const editor = getEditor(); const filePath = editor.document.uri.fsPath; if (!isNotePath(filePath)) { diff --git a/src/note.ts b/src/note.ts index c5a77a5..5f79a07 100644 --- a/src/note.ts +++ b/src/note.ts @@ -30,7 +30,7 @@ export class Note implements Props { constructor(props: ConstructorProps) { this.filePath = props.filePath; this.uuid = props.uuid, - // e.g. $PROJECT_ROOT/.vscode/linenote/73WakrfVbNJBaAmhQtEeDv.md + // e.g. $PROJECT_ROOT/.vscode/linenoteplus/73WakrfVbNJBaAmhQtEeDv.md this.notePath = path.join(props.noteDir, this.uuid + '.md'); this.line = props.line; } @@ -130,12 +130,12 @@ export class Note implements Props { // create footer const edit = `[Edit](${vscode.Uri.parse( - `command:linenote.openNote?${encodeURIComponent( + `command:linenoteplus.openNote?${encodeURIComponent( JSON.stringify(this.uuid) )}` )})`; const remove = `[Remove](${vscode.Uri.parse( - `command:linenote.removeNote?${encodeURIComponent( + `command:linenoteplus.removeNote?${encodeURIComponent( JSON.stringify(this.uuid) )}` )})`; diff --git a/src/noteUtil.ts b/src/noteUtil.ts index 613aa1c..e23fb84 100644 --- a/src/noteUtil.ts +++ b/src/noteUtil.ts @@ -45,7 +45,7 @@ export const cleanUpOrphanedNotes = async () => { } await Promise.all(uuidsToDelete.map(async uuid => { if (uuid) { - await vscode.commands.executeCommand('linenote.removeNote', uuid); + await vscode.commands.executeCommand('linenoteplus.removeNote', uuid); } })); } diff --git a/src/util.ts b/src/util.ts index bb12d78..0eb0333 100644 --- a/src/util.ts +++ b/src/util.ts @@ -21,7 +21,7 @@ export const getUuidFromNotePath = (notePath: string) => { return uuid; } -export const relNotesDir = '.vscode/linenote'; +export const relNotesDir = '.vscode/linenoteplus'; export const getNotesDir = (filePath: string) => { const workspaceFolders = vscode.workspace.workspaceFolders!; for (const folder of workspaceFolders) { @@ -56,7 +56,7 @@ export const getIncludedFilePaths = async (): Promise => { const fNames: string[] = []; const includePaths = vscode.workspace .getConfiguration() - .get('linenote.includePaths')!; + .get('linenoteplus.includePaths')!; for (const pattern of includePaths) { const files = await vscode.workspace.findFiles(pattern, ''); for (const file of files) { @@ -66,12 +66,12 @@ export const getIncludedFilePaths = async (): Promise => { return fNames; }; -// convert from $PROJECT_ROOT to $PROJECT_ROOT/.vscode/linenote +// convert from $PROJECT_ROOT to $PROJECT_ROOT/.vscode/linenoteplus export const fromProjectRootToNoteRoot = (projectRoot: string): string => { - return path.join(projectRoot, ".vscode", "linenote"); + return path.join(projectRoot, ".vscode", "linenoteplus"); }; -// get [projectRoot, noteRoot(=projectRot/.vscode/linenote)] from file path. +// get [projectRoot, noteRoot(=projectRot/.vscode/linenoteplus)] from file path. export const getRootFolders = async ( fsPath: string ): Promise<[string, string]> => {