Compare commits

...

8 Commits

Author SHA1 Message Date
Riccardo Ferretti
eb74e57a9e v0.18.4 2022-06-03 16:41:19 +02:00
Riccardo Ferretti
a01cf8ec8d Preparation for next release 2022-06-03 16:40:18 +02:00
allcontributors[bot]
5b63fa8108 docs: add Lauviah0622 as a contributor for code (#1000)
* docs: update docs/index.md [skip ci]

* docs: update readme.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2022-05-30 13:14:25 +02:00
Lauviah0622
ddf7ddf7b3 Jump after the closing brackets (]]) on autocomplete (#998)
* feat: jump to bracket of the end

* fix: jump cursor except commit with #

* feat: add | to link and section commit char
2022-05-30 13:13:39 +02:00
memeplex
4b263667ea Some link highlighting improvements (#890) 2022-05-09 14:22:49 +02:00
allcontributors[bot]
309194b3c3 docs: add drewtyler as a contributor for doc (#992)
* docs: update docs/index.md [skip ci]

* docs: update readme.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2022-04-28 17:25:26 +02:00
Drew Tyler
c4f35b7649 Adding reference to the vscode key binding command (#989)
When setting up my foam workspace, it took me a bit to find this command. Calling it out here to make it easier for the next person.
2022-04-28 17:24:51 +02:00
Riccardo Ferretti
b9e18de7e7 Removed reference to no longer existing file in docs 2022-04-20 15:45:45 +01:00
12 changed files with 135 additions and 36 deletions

View File

@@ -869,6 +869,24 @@
"contributions": [
"code"
]
},
{
"login": "drewtyler",
"name": "Drew Tyler",
"avatar_url": "https://avatars.githubusercontent.com/u/5640816?v=4",
"profile": "http://www.drewtyler.com",
"contributions": [
"doc"
]
},
{
"login": "Lauviah0622",
"name": "Lauviah0622",
"avatar_url": "https://avatars.githubusercontent.com/u/43416399?v=4",
"profile": "https://github.com/Lauviah0622",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,

View File

@@ -1,7 +1,7 @@
# Creating New Notes
- Write out a new `[[wikilink]]` and `Cmd` + `Click` to create a new file and enter it.
- For keyboard navigation, use the 'Follow Definition' key `F12` (or [remap key binding](https://code.visualstudio.com/docs/getstarted/keybindings) to something more ergonomic)
- For keyboard navigation, use the 'Follow Definition' key `F12` (or [remap the 'editor.action.revealDefinition' key binding](https://code.visualstudio.com/docs/getstarted/keybindings) to something more ergonomic)
- `Cmd` + `Shift` + `P` (`Ctrl` + `Shift` + `P` for Windows), execute `Foam: Create New Note` and enter a **Title Case Name** to create `Title Case Name.md`
- Add a keyboard binding to make creating new notes easier.
- The [[note-templates]] used by this command can be customized.

View File

@@ -31,8 +31,6 @@ You can use **Foam** for organising your research, keeping re-discoverable notes
**Foam** is a tool that supports creating relationships between thoughts and information to help you think better.
![Foam kitchen sink, showing a few of the key features](assets/images/foam-features-dark-mode-demo.png)
Whether you want to build a [Second Brain](https://www.buildingasecondbrain.com/) or a [Zettelkasten](https://zettelkasten.de/posts/overview/), write a book, or just get better at long-term learning, **Foam** can help you organise your thoughts if you follow these simple rules:
1. Create a single **Foam** workspace for all your knowledge and research following the [Getting started](#getting-started) guide.
@@ -229,6 +227,8 @@ If that sounds like something you're interested in, I'd love to have you along o
<td align="center"><a href="http://Cliffordfajardo.com"><img src="https://avatars.githubusercontent.com/u/6743796?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Clifford Fajardo </b></sub></a><br /><a href="#tool-cliffordfajardo" title="Tools">🔧</a></td>
<td align="center"><a href="http://cu-dev.ca"><img src="https://avatars.githubusercontent.com/u/6589365?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Chris Usick</b></sub></a><br /><a href="https://github.com/foambubble/foam/commits?author=chrisUsick" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/josephdecock"><img src="https://avatars.githubusercontent.com/u/1145533?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Joe DeCock</b></sub></a><br /><a href="https://github.com/foambubble/foam/commits?author=josephdecock" title="Code">💻</a></td>
<td align="center"><a href="http://www.drewtyler.com"><img src="https://avatars.githubusercontent.com/u/5640816?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Drew Tyler</b></sub></a><br /><a href="https://github.com/foambubble/foam/commits?author=drewtyler" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/Lauviah0622"><img src="https://avatars.githubusercontent.com/u/43416399?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Lauviah0622</b></sub></a><br /><a href="https://github.com/foambubble/foam/commits?author=Lauviah0622" title="Code">💻</a></td>
</tr>
</table>

View File

@@ -4,5 +4,5 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.18.3"
"version": "0.18.4"
}

View File

@@ -4,6 +4,12 @@ All notable changes to the "foam-vscode" extension will be documented in this fi
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
## [0.18.4] - 2022-06-03
Fixes and Improvements:
- move past `]]` when writing wikilinks (#998 - thanks @Lauviah0622)
- highlight improvements (#890 - thanks @memeplex)
## [0.18.3] - 2022-04-17
Fixes and Improvements:

View File

@@ -8,7 +8,7 @@
"type": "git"
},
"homepage": "https://github.com/foambubble/foam",
"version": "0.18.3",
"version": "0.18.4",
"license": "MIT",
"publisher": "foam",
"engines": {
@@ -146,6 +146,10 @@
{
"command": "foam-vscode.open-resource",
"when": "false"
},
{
"command": "foam-vscode.completion-move-cursor",
"when": "false"
}
]
},
@@ -213,6 +217,10 @@
{
"command": "foam-vscode.create-new-template",
"title": "Foam: Create New Template"
},
{
"command": "foam-vscode.completion-move-cursor",
"title": "Foam: Move cursor after completion"
}
],
"configuration": {
@@ -265,11 +273,6 @@
"type": "boolean",
"default": true
},
"foam.decorations.links.enable": {
"description": "Enable decorations for links",
"type": "boolean",
"default": true
},
"foam.openDailyNote.onStartup": {
"type": "boolean",
"default": false

View File

@@ -1,18 +1,12 @@
import { debounce } from 'lodash';
import * as vscode from 'vscode';
import { FoamFeature } from '../types';
import {
ConfigurationMonitor,
monitorFoamVsCodeConfig,
} from '../services/config';
import { ResourceParser } from '../core/model/note';
import { FoamWorkspace } from '../core/model/workspace';
import { Foam } from '../core/model/foam';
import { Range } from '../core/model/range';
import { fromVsCodeUri } from '../utils/vsc-utils';
export const CONFIG_KEY = 'decorations.links.enable';
const placeholderDecoration = vscode.window.createTextEditorDecorationType({
rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed,
textDecoration: 'none',
@@ -21,15 +15,10 @@ const placeholderDecoration = vscode.window.createTextEditorDecorationType({
});
const updateDecorations = (
areDecorationsEnabled: () => boolean,
parser: ResourceParser,
workspace: FoamWorkspace
) => (editor: vscode.TextEditor) => {
if (
!editor ||
!areDecorationsEnabled() ||
editor.document.languageId !== 'markdown'
) {
if (!editor || editor.document.languageId !== 'markdown') {
return;
}
const note = parser.parse(
@@ -43,9 +32,9 @@ const updateDecorations = (
placeholderRanges.push(
Range.create(
link.range.start.line,
link.range.start.character + 2,
link.range.start.character + (link.type === 'wikilink' ? 2 : 0),
link.range.end.line,
link.range.end.character - 2
link.range.end.character - (link.type === 'wikilink' ? 2 : 0)
)
);
}
@@ -58,14 +47,10 @@ const feature: FoamFeature = {
context: vscode.ExtensionContext,
foamPromise: Promise<Foam>
) => {
const areDecorationsEnabled: ConfigurationMonitor<boolean> = monitorFoamVsCodeConfig(
CONFIG_KEY
);
const foam = await foamPromise;
let activeEditor = vscode.window.activeTextEditor;
const immediatelyUpdateDecorations = updateDecorations(
areDecorationsEnabled,
foam.services.parser,
foam.workspace
);
@@ -78,7 +63,6 @@ const feature: FoamFeature = {
immediatelyUpdateDecorations(activeEditor);
context.subscriptions.push(
areDecorationsEnabled,
placeholderDecoration,
vscode.window.onDidChangeActiveTextEditor(editor => {
activeEditor = editor;

View File

@@ -13,11 +13,12 @@ import backlinks from './backlinks';
import utilityCommands from './utility-commands';
import hoverProvider from './hover-provider';
import previewNavigation from './preview-navigation';
import completionProvider from './link-completion';
import completionProvider, { completionCursorMove } from './link-completion';
import tagCompletionProvider from './tag-completion';
import linkDecorations from './document-decorator';
import navigationProviders from './navigation-provider';
import wikilinkDiagnostics from './wikilink-diagnostics';
// import completionMoveCursor from './completion-cursor-move';
import refactor from './refactor';
import { FoamFeature } from '../types';
@@ -43,4 +44,5 @@ export const features: FoamFeature[] = [
previewNavigation,
completionProvider,
tagCompletionProvider,
completionCursorMove,
];

View File

@@ -7,6 +7,14 @@ import { FoamFeature } from '../types';
import { getNoteTooltip, mdDocSelector } from '../utils';
import { fromVsCodeUri, toVsCodeUri } from '../utils/vsc-utils';
export const linkCommitCharacters = ['#', '|'];
export const sectionCommitCharacters = ['|'];
const COMPLETION_CURSOR_MOVE = {
command: 'foam-vscode.completion-move-cursor',
title: 'Foam: Move cursor after completion',
};
export const WIKILINK_REGEX = /\[\[[^[\]]*(?!.*\]\])/;
export const SECTION_REGEX = /\[\[([^[\]]*#(?!.*\]\]))/;
@@ -31,6 +39,65 @@ const feature: FoamFeature = {
},
};
/**
* always jump to the closing bracket, but jump back the cursor when commit
* by alias divider `|` and section divider `#`
* See https://github.com/foambubble/foam/issues/962,
*/
export const completionCursorMove: FoamFeature = {
activate: (context: vscode.ExtensionContext, foamPromise: Promise<Foam>) => {
context.subscriptions.push(
vscode.commands.registerCommand(
COMPLETION_CURSOR_MOVE.command,
async () => {
const activeEditor = vscode.window.activeTextEditor;
const document = activeEditor.document;
const currentPosition = activeEditor.selection.active;
const cursorChange = vscode.window.onDidChangeTextEditorSelection(
async e => {
const changedPosition = e.selections[0].active;
const preChar = document
.lineAt(changedPosition.line)
.text.charAt(changedPosition.character - 1);
const {
character: selectionChar,
line: selectionLine,
} = e.selections[0].active;
const {
line: completionLine,
character: completionChar,
} = currentPosition;
const inCompleteBySectionDivider =
linkCommitCharacters.includes(preChar) &&
selectionLine === completionLine &&
selectionChar === completionChar + 1;
cursorChange.dispose();
if (inCompleteBySectionDivider) {
await vscode.commands.executeCommand('cursorMove', {
to: 'left',
by: 'character',
value: 2,
});
}
}
);
await vscode.commands.executeCommand('cursorMove', {
to: 'right',
by: 'character',
value: 2,
});
}
)
);
},
};
export class SectionCompletionProvider
implements vscode.CompletionItemProvider<vscode.CompletionItem> {
constructor(private ws: FoamWorkspace) {}
@@ -70,6 +137,8 @@ export class SectionCompletionProvider
);
item.sortText = String(b.range.start.line).padStart(5, '0');
item.range = replacementRange;
item.commitCharacters = sectionCommitCharacters;
item.command = COMPLETION_CURSOR_MOVE;
return item;
});
return new vscode.CompletionList(items);
@@ -104,12 +173,12 @@ export class CompletionProvider
// Requires autocomplete only if cursorPrefix matches `[[` that NOT ended by `]]`.
// See https://github.com/foambubble/foam/pull/596#issuecomment-825748205 for details.
const requiresAutocomplete = cursorPrefix.match(WIKILINK_REGEX);
if (!requiresAutocomplete || requiresAutocomplete[0].indexOf('#') >= 0) {
return null;
}
const text = requiresAutocomplete[0];
const replacementRange = new vscode.Range(
position.line,
position.character - (text.length - 2),
@@ -126,7 +195,8 @@ export class CompletionProvider
item.filterText = resource.uri.getName();
item.insertText = this.ws.getIdentifier(resource.uri);
item.range = replacementRange;
item.commitCharacters = ['#'];
item.command = COMPLETION_CURSOR_MOVE;
item.commitCharacters = linkCommitCharacters;
return item;
});
const placeholders = Array.from(this.graph.placeholders.values()).map(
@@ -136,6 +206,7 @@ export class CompletionProvider
vscode.CompletionItemKind.Interface
);
item.insertText = uri.path;
item.command = COMPLETION_CURSOR_MOVE;
item.range = replacementRange;
return item;
}

View File

@@ -128,7 +128,14 @@ export class NavigationProvider
: Range.createFromPosition(targetRange.start);
const result: vscode.LocationLink = {
originSelectionRange: toVsCodeRange(targetLink.range),
originSelectionRange: new vscode.Range(
targetLink.range.start.line,
targetLink.range.start.character +
(targetLink.type === 'wikilink' ? 2 : 0),
targetLink.range.end.line,
targetLink.range.end.character -
(targetLink.type === 'wikilink' ? 2 : 0)
),
targetUri: toVsCodeUri(uri.asPlain()),
targetRange: toVsCodeRange(targetRange),
targetSelectionRange: toVsCodeRange(targetSelectionRange),

View File

@@ -1,11 +1,17 @@
{
"scopeName": "foam.wikilink.injection",
"injectionSelector": "L:meta.paragraph.markdown",
"injectionSelector": "L:meta.paragraph.markdown, L:markup.heading.markdown",
"patterns": [
{
"contentName": "string.other.link.title.markdown.foam",
"begin": "\\[\\[",
"end": "\\]\\]"
"beginCaptures": {
"0": { "name": "punctuation.definition.metadata.markdown.foam" }
},
"end": "\\]\\]",
"endCaptures": {
"0": { "name": "punctuation.definition.metadata.markdown.foam" }
}
}
]
}

View File

@@ -5,7 +5,7 @@
👀*This is an early stage project under rapid development. For updates join the [Foam community Discord](https://foambubble.github.io/join-discord/g)! 💬*
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-94-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-96-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
[![Discord Chat](https://img.shields.io/discord/729975036148056075?color=748AD9&label=discord%20chat&style=flat-square)](https://foambubble.github.io/join-discord/g)
@@ -317,6 +317,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="http://Cliffordfajardo.com"><img src="https://avatars.githubusercontent.com/u/6743796?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Clifford Fajardo </b></sub></a><br /><a href="#tool-cliffordfajardo" title="Tools">🔧</a></td>
<td align="center"><a href="http://cu-dev.ca"><img src="https://avatars.githubusercontent.com/u/6589365?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Chris Usick</b></sub></a><br /><a href="https://github.com/foambubble/foam/commits?author=chrisUsick" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/josephdecock"><img src="https://avatars.githubusercontent.com/u/1145533?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Joe DeCock</b></sub></a><br /><a href="https://github.com/foambubble/foam/commits?author=josephdecock" title="Code">💻</a></td>
<td align="center"><a href="http://www.drewtyler.com"><img src="https://avatars.githubusercontent.com/u/5640816?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Drew Tyler</b></sub></a><br /><a href="https://github.com/foambubble/foam/commits?author=drewtyler" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/Lauviah0622"><img src="https://avatars.githubusercontent.com/u/43416399?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Lauviah0622</b></sub></a><br /><a href="https://github.com/foambubble/foam/commits?author=Lauviah0622" title="Code">💻</a></td>
</tr>
</table>