Ask HN: What code editors or IDEs are easily scriptable?
I want to build a deeper relationship with an editor or IDE that's designed to be extended or scripted.
I'd prefer to use an everyday-language I work in for scripting, which rules out Vimscript, Lua or Lisp. I'd be most happy with any of Ruby, Python, Go or Rust. Ideas?
67 comments
[ 2.3 ms ] story [ 146 ms ] threadShould be unnecessary (and might be outdated unless meticulously maintained) IF one chooses to just follow the VSC API docs' `yo code` approach. Which generates the project structure with a simple hello `extension.ts` IIRC.
I may give it a spin myself as I am pretty heavy user of IntelliJ.
By the way, I think Fleet, the new "Beta" editor by Jetbrains, is currently designing a custom plugin system to make it "nicer" to write plugins than for IntelliJ, but apparently it's not yet open for trials: https://www.jetbrains.com/help/fleet/managing-plugins.html
"I'd prefer to use an everyday-language I work in for scripting, which rules out Vimscript, Lua or Lisp."
Maybe if you’re a seasoned terminal veteran it will make more sense to you right outta the gate. I started using Kakoune not long after I started using the terminal much more heavily, so it was a bit difficult at first, but it has been and continues to be rewarding.
For example, select some text and press the pipe character, and then you can enter a script or shell command (sort, uniq, fmt, etc.). The selected text will be fed to stdin of the command, and then will be replaced with the output.
Combine this power with multiselections, which can be operated on in separate contexts, and you’ve got a stew going.
https://github.com/orgs/neovim/repositories?type=all&q=Clien...
> read other's code
I'll second this: there are so many really good packages out there that it makes it easy to find something to get some pointers on how to proceed.
alright I'll put all the filenames in the buffer
I'll run an awk one-liner to print the filename and date seperated by a tab I don't want that long path I know, I'll sort them by build date Oh yuck 4 space tabs don't do it> Plain old vim
By this, do you mean this is only available in vim, not NeoVim?
I will say that Lua is extremely easy to pick up, and as far as hacking on an IDE I think that simplicity might make it an ideal language.
Personally I use macros in an editor for "text manipulation", and drop to Python/sed/awk for "text processing". I don't find I have a need for anything in-between.
I used just a little bit of code to make it so when I command-click a filepath anywhere, it opens in IntelliJ. This works in the browser, on chrome links, (github, gitlab, jenkins, error pages, etc) and also in iTerm on stack traces, spec/test paths. I made a chrome plugin, a shell script, and used the remote control plugin (not mine). The result was super-satisfying. I'll probably open source the bits soon. Now, I didn't script the IDE myself--the Remote Control Plugin did that work, but for an open source solution, I wouldn't mind building a remote control plugin myself.
Making this work got me wondering about doing the same with an open-source editor. I also would like to drive things internally, but I want it to be easy so I get a good return on the effort.
If on MacOS and you are using the apple native build, 'open -a gVim file' opens each file in the same editor.
If you want to do that on X11 (even macos X11.app) or MS Windows:
https://vimhelp.org/remote.txt.html#remote.txt
Basically (or gvim, yu might want --remote-silent too):
The end of that doc explain you can use either Windows messages or OLE.But the same doc explains how you can completely script vim from the command line:
Tell the remote server "foo" to write all files and exit: vim --servername foo --remote-send '<C-\><C-N>:wqa<CR>'
^\^N is what you press on a keyboard to enter normal mode from every mode except ex mode without a beep.
:wqa means do the command Write All and Quit.
so with --remote-send you can send any sequence of key-strokes to act on buffers.
You probably want to read from https://vimhelp.org/intro.txt.html#notation to learn the fundamentals.
I'd avoid neovim initially until you learn enough to decided if you want it - pros and cons both ways.
What I like about it is how it exposes pretty much all capabilities with no chance of breaking the editor host itself. Just the right balance of constrained-enough-but-seemingly-unconstrained.
You can develop these extensions in JS/TS super-smoothly inside VSC and run-with-F5 to open a new window with your extension running.
But frankly for small-script purposes, it's a bit overkill, unless/until you have enough of those that bundling them all up into one "my extension with all the Foos I demand" begins to make sense.
Unfortunately local-only, private one-off extensions aren't installed as trivially as dumping just-a-script-file in some dot folder and calling it done. I mean it almost is with `~/.vscode/extensions/my-ext/` but not 100% reliable. I have 2 custom exts in there that are always available but 1 that inexplicably never is (but builds & runs error/warning-free with F5). The official installation story is a "vsx package" (probably just a ZIP but haven't looked into it yet).
VSCode is a joke, you can't use javascript, worse, you need to compile your scripts, and you need to restart the editor whenever you change your "scripts"
You can use Javascript, you don’t need to compile your scripts if you do you javascript, and you don’t need to restart the editor when you change your scripts. You do have to restart the extension host, but that’s not the same thing.
I'm still a happy camper on VSCode but if it ever begins to crumble/rot/overbloat (by subjective criteria), I'd hop onto that. Lua is (for my purposes here) no better/worse than JS/TS. Save for those darned 1-based array indexings!
LSP-capable too, last I heard, else it'd be a non-option for me in 2024. https://orbitalquark.github.io/textadept/
0. Go to https://RTCode.io/x/
1. Type a number
2. Select the number
3. Press ↑/↓ keys
3. Open the context menu (right click/long tap)
4. Mess with Selections: or Eval menu items
Claude has helped with the selection actions!
See https://diff.rt.ht which is also built on Monaco!
For more advanced stuff visit: https://go.rt.ht and select the Backend or PDF starters and hover over the attributes!
Feel free to view the sources to see how I script it!
See this presentation by a core Neovim maintainer that explains why Lua was chosen https://www.youtube.com/watch?v=IP3J56sKtn0.
See also http://lua-users.org/wiki/MechanismNotPolicy to understand Lua's core design.
Now admittedly this is never as sleek or uniform as an actual Integrated Development Environment, but the extensibility, well the extensibility is unmatched. you can even have an ide in your ide.