Can't open links to non-markdown local files
- Foam version: v0.17.3
- Platform: Mac
- Issue occur on the foam template repo: Yes
Summary
I'd like to be able to link to arbitrary local files within my workspace from Foam notes. Because VSCode supports go-to-definition in other contexts, I'd expect that activating a link in a markdown file would follow that link (same as with http links), but instead, when option-clicking a link to a local file that is not a Markdown file, Foam defaults to trying to create a new note with that file's name instead of opening the existing file.
It would be useful to be able to write, for example in a Markdown file in the foam-template repo:
[[assets/css/style.scss]]
To link to an arbitrary file in the workspace. I'd particularly like to use this for PDF files, but I imagine it would be useful for e.g. source code as well.
The same issue occurs with other link format styles (e.g. [](assets/css/style.css)).
When using the file url scheme (e.g. [](file://absolute/path/to/style.css)), the behaviour is slightly different: the "create note" dialog is not presented, but the file is not opened. The VSCode developer console shows a "No file system provider found for resource" error in this case.
Steps to reproduce:
- In a markdown file, create a link to a local file that is not a Markdown file
- Try to open the file by activating the link
Expected behaviour: The linked file is opened in VSCode Actual behaviour: Foams "enter filename for new note" dialog is displayed. If a filename is entered, the new note creation fails silently.
From what I can tell this is because Foam doesn't have a provider that supports the kinds of links I'm using, so it defaults to generating a placeholder URI for the linked resource, which is then interpreted as a request to create a new note.
See link resolver in workspace.ts and open-uri command in commands.ts
From what I can tell this is because Foam doesn't have a provider that supports the kinds of links I'm using, so it defaults to generating a placeholder URI for the linked resource, which is then interpreted as a request to create a new note.
This is correct, I agree we should support files with other extensions so we could have an "attachment provider" to address that.
My use case: I have old notes in org-mode files I would like to refer to easily.
We do have an attachment provider now, but I guess it doesn't support the org-mode file. Thinking about it, org files should probably be treated as notes, not attachments? I don't use them, so I am not sure what the workflow would be lik
I notice this issue has been solved in v0.20.0, but it doesn't work well for me.
- foam version: v0.20.2
- vscode version: 1.72.2
- platform: windows
Attachments like [[foo.pdf]], [[foo.txt]], [[foo.doc]] work fine, but attachments like [[foo.vimrc]], [[foo.css]], [[foo.py]] still be recognized as placeholders instead of attachments, though I have added the extentions to settings.json like:
{
"foam.files.attachmentExtensions": "vimrc py css pdf mp3 webm wav m4a mp4 avi mov rtf txt doc docx pages xls xlsx numbers ppt pptm pptx",
}
It looks like changing the foam.files.attachmentExtensions setting does not really take effects. When I click on [[foo.css]], it will ask to create a new note.
Could you check it again? @riccardoferretti
I just tested it now and it seems to work. Make sure you reload the workspace after updating these (maybe I should make that automatic). And if you are still having the issue, please attach a small repo to reproduce the problem so I can look deeper into it, thanks!
I just tested it now and it seems to work. Make sure you reload the workspace after updating these (maybe I should make that automatic). And if you are still having the issue, please attach a small repo to reproduce the problem so I can look deeper into it, thanks!
Thanks a lot, it does need to reload window after changing this setting item, it's perfect now. Thanks for your reply.