Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
observerw committed Jun 24, 2024
0 parents commit bb08ede
Show file tree
Hide file tree
Showing 50 changed files with 6,025 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
tab_width = 4
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/

main.js
23 changes: 23 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"env": { "node": true },
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
"@typescript-eslint/ban-ts-comment": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-function": "off"
}
}
34 changes: 34 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release Obsidian plugin

on:
push:
tags:
- "*"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"

- name: Build plugin
run: |
npm install
npm run build
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${GITHUB_REF#refs/tags/}"
gh release create "$tag" \
--title="$tag" \
--draft \
main.js manifest.json styles.css
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# vscode
.vscode

# Intellij
*.iml
.idea

# npm
node_modules

# Don't include the compiled main.js file in the repo.
# They should be uploaded to GitHub releases instead.
main.js

# Exclude sourcemaps
*.map

# obsidian
data.json

# Exclude macOS Finder (System Explorer) View States
.DS_Store

tree-sitter*
!tree-sitter-patch*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tag-version-prefix=""
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Obsidian Code Link

Display code everywhere, and only the parts you're interested in!

![](./assets/main.png)

# Usage

1. First of all, please create a special folder in the repository for storing your code projects, the default path is "/project".
2. Open Command Palette and run `Code Link: Import project`, select the project folder you want to import, then the project will be imported into your Obsidian vault.
3. Open editor, link to the code file just like linking to a note, then you can preview the code in the editor. **Make sure that Settings - Files and Links - Detect all types of files are opened.**

# Preview

Supports hover preview and embed preview.

# Tag Search

<div style="display: flex; justify-content: center;">
<img src="./assets/tag-search.png" width="50%">
</div>

When a tag search link is previewing, you can click on the tag list to display any parent tags.

Use [TreeSitter](https://tree-sitter.github.io/tree-sitter/) and [.scm files from zed editor](https://zed.dev/).

# Import Project Into Obsidian Vault

`Code Link: Import project`

Create a symlink to the project folder in your Obsidian vault.

Note that symlinks are just a reference to the original file, so if you delete the original file, the symlink will be broken.
Binary file added assets/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/tag-search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";
import inlineImportPlugin from 'esbuild-plugin-inline-import'

const banner =
`/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;

const prod = (process.argv[2] === "production");

const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ["src/main.ts"],
bundle: true,
external: [
"obsidian",
"electron",
"@codemirror/autocomplete",
"@codemirror/collab",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins],
plugins: [
inlineImportPlugin(),
],
format: "cjs",
target: "esnext",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
platform: "node",
});

if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}
11 changes: 11 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "obsidian-code-link",
"name": "Code Link",
"version": "1.0.0",
"minAppVersion": "0.15.0",
"description": "Link to code files in your notes",
"author": "observerw",
"authorUrl": "https://obsidian.md",
"fundingUrl": "https://obsidian.md/pricing",
"isDesktopOnly": true
}
39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "obsidian-sample-plugin",
"version": "1.0.0",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs && git add manifest.json versions.json"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"@codemirror/view": "^6.28.1",
"@types/node": "^16.11.6",
"@types/tar": "^6.1.13",
"@typescript-eslint/eslint-plugin": "7.13.0",
"@typescript-eslint/parser": "7.13.0",
"builtin-modules": "3.3.0",
"esbuild": "0.17.3",
"esbuild-plugin-inline-import": "^1.0.4",
"node-addon-api": "^8.0.0",
"obsidian": "latest",
"tslib": "2.4.0",
"typescript": "5.4.5"
},
"dependencies": {
"@electron/remote": "^2.1.2",
"@popperjs/core": "^2.11.8",
"fastest-levenshtein": "^1.0.16",
"glob": "^10.4.2",
"globby": "^14.0.1",
"iconify-icon": "^2.1.0",
"ignore": "^5.3.1",
"node-gyp-build": "^4.8.1",
"tar": "^7.2.0"
}
}
Loading

0 comments on commit bb08ede

Please sign in to comment.