Plugins mini FAQ

A post was split to a new topic: How to use cryptomator?

Thanks for that.
@argentum it would be great to see this added to the bottom of the mini FAQ how to develop in a ‘how to debug’ line :slight_smile:

Hey @Artemgy, I haven’t maintained this FAQ a lot, but this reply from @pjeby should probably help: How to get started with developing a custom Plugin? - #7 by pjeby

1 Like
  • @zephraph put together some tools for programmatically working with plugins. There’s also an unofficial collection of CLI tools that helps you build plugins for Obsidian. Apparently it’ll prompt you for which vault you want to develop in (via a select list; it finds all your vaults), sets up and automatically copies over built code, and prompts to you to install the hot-reload plugin if you haven’t already (it’ll do that for you automatically too). It’ll even copy over the manifest file if any changes happen to that.
1 Like

I tried to make a as-simple-as-possible-but-no-simpler set of instructions for getting started with plugins. (The idea here is to give you everything you need to be able to do things with plugin development, and nothing more than that.)

A rough guide on getting started fiddling with plugins

  • Download VS Code
  • Set up Node.js and NPM
  • Find a simple plugin on GitHub (the sample plugin is a potential one, but it doesn’t really do anything—maybe look for something that provides functionality similar to what you’d like to build)
  • Download the plugin into a folder on your desktop by cloning it
  • Compile the downloaded plugin code
    • Open your terminal
    • Open the folder for the newly-downloaded plugin in the terminal (If you need help with the terminal, search the web for advice for your platform—the exact commands can be different depending on whether you’re using macOS/Windows/Linux/etc.
    • Run npm i in the plugin folder
    • Run npm run dev and the terminal will re-compile whenever the .ts file has changes saved
  • Open up the plugin’s folder in VS Code
  • Open the file main.ts and start changing things
  • Refer to the Obsidian API to understand what you can use
    • In VS Code, you can hover over/select API elements and look up their definitions
  • Use console.log(object) or console.log(variable) to check the state/functioning of your plugin (see debugging below)
  • Drag the newly-created main.js and manifest.json files from the plugin folder into Your-Vault/.obsidian/plugins/Some-Plugin-Folder
  • (If loading the plugin for the first time, reload—or quit and relaunch—Obsidian)
  • (Unload and re)load the plugin in Obsidian’s Preferences → Community Plugins → the appropriate plugin toggle
  • Test it by invoking the features you’ve played with
  • Debug by using the Console tab in Obsidian’s Developer Tools (open dev tools with cmd/ctrl+shift+i, then select the console tab)
11 Likes

While I am not sensing this is or has been a contentious issue, I was wondering what the general consensus is on Obsidian, down the line, implementing features that have already been dutifully addressed by one or more plugins. While I understand that this likely would not affect a user’s ability to install a that plugin, I can imagine that most people might switch over to using the core feature or core plugin. My question exempts major features that are on the roadmap, as the plugin developer will not have been caught off guard.

I am wondering whether the Obsidian developers might opt to keep certain plugins plugins, when eventually they could be implemented as core without too much difficulty. This would likely support the thriving plugin ecosystem and also not divert the user base of hardworking plugin developers. I realize now that I guess my question may not fit the topic of FAQ, but does anyone else hope that the developers would perhaps work with the plugin developers to implement their work or just hopefully feel perfectly comfortable implementing something as core on their own even if it already has been addressed and hasn’t been on the roadmap?

By the way, for the record, I love Obsidian and genuinely feel that the developers will make the right decision. I am just not sure what it is. Regardless of how things go, I think 99% of the community will be with them, and that really does provide a lot of freedom, which evidently is helpful.

Thanks.