diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-09-08 21:55:30 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-09-08 21:55:30 +0800 |
| commit | 758d808513dc014849cf8e51b7bc870b5acf46f2 (patch) | |
| tree | 526c025c40ecd82ae4784ae78b15603259c0ae8d /dot-scls | |
| parent | 0b74e0e163246d92a2295b6c79e3a1413b3a20b8 (diff) | |
new: helix
Diffstat (limited to 'dot-scls')
| -rw-r--r-- | dot-scls/external-snippets.toml | 303 | ||||
| m--------- | dot-scls/external-snippets/friendly-snippets | 0 | ||||
| -rw-r--r-- | dot-scls/run.js | 101 |
3 files changed, 404 insertions, 0 deletions
diff --git a/dot-scls/external-snippets.toml b/dot-scls/external-snippets.toml new file mode 100644 index 00000000..c99d5e66 --- /dev/null +++ b/dot-scls/external-snippets.toml @@ -0,0 +1,303 @@ +[[sources]] +name = "friendly-snippets" +git = "https://github.com/rafamadriz/friendly-snippets.git" + +[[sources.paths]] +scope = ["python"] +path = "snippets/python/python.json" + +[[sources.paths]] +scope = ["asciidoc"] +path = "snippets/asciidoc.json" + +[[sources.paths]] +scope = ["beancount"] +path = "snippets/beancount.json" + +[[sources.paths]] +scope = ["c"] +path = "snippets/c" + +[[sources.paths]] +scope = ["cmake"] +path = "snippets/cmake.json" + +[[sources.paths]] +scope = ["cobol"] +path = "snippets/cobol" + +[[sources.paths]] +scope = ["cpp", "c++", "cplusplus", "cc"] +path = "snippets/cpp" + +[[sources.paths]] +scope = ["csharp", "cs", "dotnet"] +path = "snippets/csharp" + +[[sources.paths]] +scope = ["css"] +path = "snippets/css.json" + +[[sources.paths]] +scope = ["dart"] +path = "snippets/dart.json" + +[[sources.paths]] +scope = ["docker", "dockerfile", "containerfile"] +path = "snippets/docker" + +[[sources.paths]] +scope = ["editorconfig"] +path = "snippets/editorconfig.json" + +[[sources.paths]] +scope = ["eelixir"] +path = "snippets/eelixir.json" + +[[sources.paths]] +scope = ["elixir"] +path = "snippets/elixir.json" + +[[sources.paths]] +scope = ["erb"] +path = "snippets/erb.json" + +[[sources.paths]] +scope = ["erlang"] +path = "snippets/erlang.json" + +[[sources.paths]] +scope = ["fennel"] +path = "snippets/fennel.json" + +[[sources.paths]] +scope = ["fortran"] +path = "snippets/fortran.json" + +[[sources.paths]] +scope = ["frameworks"] +path = "snippets/frameworks" + +[[sources.paths]] +scope = ["fsh"] +path = "snippets/fsh.json" + +[[sources.paths]] +scope = ["gdscript"] +path = "snippets/gdscript.json" + +[[sources.paths]] +scope = ["gitcommit"] +path = "snippets/gitcommit.json" + +[[sources.paths]] +scope = ["gleam"] +path = "snippets/gleam.json" + +[[sources.paths]] +scope = ["global"] +path = "snippets/global.json" + +[[sources.paths]] +scope = ["glsl"] +path = "snippets/glsl.json" + +[[sources.paths]] +scope = ["go", "golang"] +path = "snippets/go.json" + +[[sources.paths]] +scope = ["haskell"] +path = "snippets/haskell.json" + +[[sources.paths]] +scope = ["html"] +path = "snippets/html.json" + +[[sources.paths]] +scope = ["java"] +path = "snippets/java" + +[[sources.paths]] +scope = ["javascript", "js", "node"] +path = "snippets/javascript" + +[[sources.paths]] +scope = ["julia"] +path = "snippets/julia.json" + +[[sources.paths]] +scope = ["kivy"] +path = "snippets/kivy.json" + +[[sources.paths]] +scope = ["kotlin", "kt"] +path = "snippets/kotlin" + +[[sources.paths]] +scope = ["kubernetes", "k8s"] +path = "snippets/kubernetes.json" + +[[sources.paths]] +scope = ["latex"] +path = "snippets/latex" + +[[sources.paths]] +scope = ["latex"] +path = "snippets/latex.json" + +[[sources.paths]] +scope = ["license"] +path = "snippets/license.json" + +[[sources.paths]] +scope = ["liquid"] +path = "snippets/liquid.json" + +[[sources.paths]] +scope = ["loremipsum"] +path = "snippets/loremipsum.json" + +[[sources.paths]] +scope = ["lua"] +path = "snippets/lua" + +[[sources.paths]] +scope = ["make", "makefile"] +path = "snippets/make.json" + +[[sources.paths]] +scope = ["markdown", "md"] +path = "snippets/markdown.json" + +[[sources.paths]] +scope = ["mint"] +path = "snippets/mint.json" + +[[sources.paths]] +scope = ["nix"] +path = "snippets/nix.json" + +[[sources.paths]] +scope = ["norg"] +path = "snippets/norg.json" + +[[sources.paths]] +scope = ["nushell", "nu"] +path = "snippets/nushell.json" + +[[sources.paths]] +scope = ["objc", "objective-c"] +path = "snippets/objc.json" + +[[sources.paths]] +scope = ["ocaml"] +path = "snippets/ocaml" + +[[sources.paths]] +scope = ["org"] +path = "snippets/org.json" + +[[sources.paths]] +scope = ["perl"] +path = "snippets/perl.json" + +[[sources.paths]] +scope = ["php"] +path = "snippets/php" + +[[sources.paths]] +scope = ["plantuml"] +path = "snippets/plantuml.json" + +[[sources.paths]] +scope = ["powershell", "pwsh"] +path = "snippets/PowerShell.json" + +[[sources.paths]] +scope = ["purescript"] +path = "snippets/purescript.json" + +[[sources.paths]] +scope = ["python"] +path = "snippets/python" + +[[sources.paths]] +scope = ["quarto"] +path = "snippets/quarto.json" + +[[sources.paths]] +scope = ["reason"] +path = "snippets/reason.json" + +[[sources.paths]] +scope = ["rescript"] +path = "snippets/rescript.json" + +[[sources.paths]] +scope = ["r"] +path = "snippets/r.json" + +[[sources.paths]] +scope = ["rmarkdown", "rmd"] +path = "snippets/rmarkdown.json" + +[[sources.paths]] +scope = ["rst", "restructuredtext"] +path = "snippets/rst.json" + +[[sources.paths]] +scope = ["ruby"] +path = "snippets/ruby" + +[[sources.paths]] +scope = ["rust"] +path = "snippets/rust" + +[[sources.paths]] +scope = ["scala"] +path = "snippets/scala.json" + +[[sources.paths]] +scope = ["shell", "sh", "bash", "zsh", "fish"] +path = "snippets/shell" + +[[sources.paths]] +scope = ["solidity"] +path = "snippets/solidity.json" + +[[sources.paths]] +scope = ["sql"] +path = "snippets/sql.json" + +[[sources.paths]] +scope = ["svelte"] +path = "snippets/svelte.json" + +[[sources.paths]] +scope = ["swift"] +path = "snippets/swift.json" + +[[sources.paths]] +scope = ["systemverilog", "sv"] +path = "snippets/systemverilog.json" + +[[sources.paths]] +scope = ["tcl"] +path = "snippets/tcl.json" + +[[sources.paths]] +scope = ["terraform", "tf", "hcl"] +path = "snippets/terraform.json" + +[[sources.paths]] +scope = ["verilog"] +path = "snippets/verilog.json" + +[[sources.paths]] +scope = ["vhdl"] +path = "snippets/vhdl.json" + +[[sources.paths]] +scope = ["zig"] +path = "snippets/zig.json" diff --git a/dot-scls/external-snippets/friendly-snippets b/dot-scls/external-snippets/friendly-snippets new file mode 160000 +Subproject 572f5660cf05f8cd8834e096d7b4c921ba18e17 diff --git a/dot-scls/run.js b/dot-scls/run.js new file mode 100644 index 00000000..119592d1 --- /dev/null +++ b/dot-scls/run.js @@ -0,0 +1,101 @@ +/* + +写 Rust 真的是浪费生命!!! + +*/ +const { homedir } = require('os') +const { join, parse } = require('path') +const { execSync } = require('child_process') +const fs = require('fs') + +const rootDir = join(homedir(), '.scls') +const cfgFile = join(rootDir, 'external-snippets.toml') +const externalSnippets = join(rootDir, 'external-snippets') + +function clone(url, destination) { + const cmd = `git clone ${url} ${destination}` + console.log(cmd) + execSync(cmd, { cwd: externalSnippets }) +} + +function mkdirp(path) { + if (fs.existsSync(path)) { + return + } + mkdirp(join(path, '..')) + fs.mkdirSync(path) +} + +function isDir(path) { + return fs.existsSync(path) && fs.lstatSync(path).isDirectory() +} + +function realName(filename) { + return parse(filename).name +} + +/** + * 生成配置文件 + * @param {string} file + * @param {string} workspace + */ +function createConfigFile(file, workspace) { + let content = `[[sources]] +name = "friendly-snippets" +git = "https://github.com/rafamadriz/friendly-snippets.git" +` + + function addSnippet(lang, path) { +return ` +[[sources.paths]] +scope = ["${lang}"] +path = "snippets/${path}" +` + } + + const frameworks = 'frameworks' + + function append(workspace, always = false) { + fs.readdirSync(workspace).forEach(filename=> { + if (filename.startsWith('.') || (filename == frameworks && !always)) return + let name = realName(filename) + const filepath = join(workspace, filename) + if (!isDir(filepath)) { + if (always) { + filename = join(frameworks, filename) + } + content += addSnippet(name, filename) + } else { + fs.readdirSync(filepath).forEach(subname=> { + let filepath = join(filename, subname) + if (always) { + filepath = join(frameworks, filepath) + } + content += addSnippet(filename, filepath) + }) + } + }) + } + + append(workspace) + append(join(workspace, frameworks), true) + + fs.writeFileSync(file, content) +} + + +function main() { + mkdirp(externalSnippets) + const name = 'friendly-snippets' + const workspace = join(externalSnippets, name) + if (!fs.existsSync(workspace)) { + clone('https://github.com/rafamadriz/friendly-snippets', name) + if (!fs.existsSync(workspace)) { + throw new Error('Failed to clone external snippets') + } + } + if (fs.existsSync(cfgFile)) return + createConfigFile(cfgFile, join(workspace, 'snippets')) +} + +main()
\ No newline at end of file |
