sminez / ad

an adaptable text editor
https://crates.io/crates/ad-editor
MIT License
264 stars 10 forks source link

User contributed scripts #47

Closed davcam closed 3 weeks ago

davcam commented 3 weeks ago

Please describe the change / addition you'd like to see made

One of the great things about "ad" is how easy it is to write little scripts to adapt how the editor works. Some of these will be very bespoke to the user, others will be scripts that many users could be interested in and could avoid "reinventing the wheel"

for example a script to comment out lines of code (a simple adaption to the indent script)

#!/usr/bin/env bash
source "$HOME/.ad/lib/ad.sh"

requireAd
id="$(currentBufferId)"
addr="$(bufRead "$id" addr | sed -E 's/(.+):.+,(.+):.+/\1,\2/')"
# append comment for sh, python or R
adEdit '. x/.+/ s/^/#/'
echo "$addr" | bufWrite "$id" addr

Could there be a discoverable way for users to contribute scripts like this to ad? Say in a "contrib" directory?

Is this a feature you have seen in other text editors?

This isn't an example for a text editor but plan9 has a "contrib" directory. Listed here https://plan9.io/wiki/plan9/Contrib_index/index.html

Other editors Emacs, Vim, VSCode have package repositories such as MELPA for emacs https://melpa.org/

A package repository is very likely overkill for ad but a place to contribute and find useful scripts such as in plan9 might be useful?

sminez commented 3 weeks ago

I'd be very happy to have users contribute scripts in this way. I think the best thing would be to place them in a new data/contrib directory I think, so if you don't want to raise a PR with scripts like the one you are showing here then please do 🙂