obsidian-execute-code icon indicating copy to clipboard operation
obsidian-execute-code copied to clipboard

[Feature] Allow loading of injected/preamble code from files

Open dpowers opened this issue 2 years ago • 5 comments

Idea

Allow loading of injection code from files. Currently code for some languages (ex: Rust) can be prefixed by adding it to a text box in the settings. This makes editing that code error-prone and difficult. Further, the code is not a normal file, and cannot be easily backed up or version controlled. Changing this to an optional path would fix that.

dpowers avatar Jan 25 '23 17:01 dpowers

Are you able to make a separate file then import it inside the settings text box? Also, if you have a plugin like obsidian git, it should backup and version all your settings.

milan338 avatar Feb 11 '23 11:02 milan338

All of that is possible, and it covers the utility I need. I still weakly claim that it would be a bit easier to just point it to a file path.

dpowers avatar Feb 15 '23 19:02 dpowers

Do you have an example of where this might be easier?

milan338 avatar Feb 17 '23 03:02 milan338

@dpowers You can use the normal import mechanism of each language to include any arbitrary bit of code in your code blocks. How would a new feature be better than the default mechanisms of each language?

twibiral avatar Feb 23 '23 23:02 twibiral

Some languages, Rust in particular for me, don't have a canonical "include this file" style of import and rely on their broader build system to do the work. Technically, Rust has https://doc.rust-lang.org/stable/std/macro.include.html, and I'll use that here, but it's generally discouraged. That said, the automated prelude of the plugin isn't canonical either :)

dpowers avatar Feb 24 '23 00:02 dpowers