Live data from Hacker News

Ask HN: What code editors or IDEs are easily scriptable?

news.ycombinator.com

51–60 of 68 posts

Re: Ask HN: What code editors or IDEs are easily scriptable?

#51
post #21
post #16

VSCode has a comprehensive API that you can create scripts for in Typescript

It's pretty rad really: https://code.visualstudio.com/api/ 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 purpo…

Perhaps try diffing the auto-generated output from installing the vsix via the official means vs your nonfunctional dev-repo?

Re: Ask HN: What code editors or IDEs are easily scriptable?

#52
Some people live in their editor and occasionally drop into a shell. I've personally found a lot less friction in doing the opposite. Live in the shell, and occasionally drop into your editor.

I used to think that it would be better to have a lot of scripting and automation built into my editor, but there are so many well-built, connect-able tools already available in a unix shell that it's usually easier to write scripts in that context, instead. There are often easy ways to pull the outputs of those scripts into your editor or use your editor as a thin, pass-thru layer to run shell scripts on certain selected bits of text in a file.

Re: Ask HN: What code editors or IDEs are easily scriptable?

#53

Sublime Text could have been perfect, it uses python and it is hot-reloadable, but the API is limited, you can't extend the interface _at all_, want tabs in the build/task panel? nope, want to customize your status bar with clickeable elements? nope 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"

> 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.

Re: Ask HN: What code editors or IDEs are easily scriptable?

#56

Of the “preferred not” languages you listed, Lisp and Lisp-derivatives are easily the most pragmatic languages you will see doing “real” work outside of the scripting environment. So, given the dearth of good scriptable editors using other languages, why not give Emacs a try? I will grant that Elisp is a bit of an odd dialect, but a lot of what you learn from learning Elisp will transfer to understanding other langua…

Emacs Lisp is my first Lisp, so I don't even really notice how supposedly weird it is. It's a fine language, don't let it get in your way, and it's just as important to be able to read other's code than it is to write your own. Unless you have all the time in the world, you want to use as much of other people's work as possible. Would I have preferred an editor written in Ruby? Sure. But I think I was right to not worry about that.

Re: Ask HN: What code editors or IDEs are easily scriptable?

#57

Plain old vim doesn't only do vimscript, you can also script it in Perl, Python, TCL, Lua and maybe one more I cannot remember. See e.g. this python howto: http://codeseekah.com/2012/03/04/vim-scripting-with-python-l...

also the way you can use shell - hmmm I'd like all the build timestamps of my 6.4 bootroms...

alright I'll put all the filenames in the buffer

    ls /tftp/bootroms/foobar/foobar_6.4_*.bin | gvim -
I'll run an awk one-liner to print the filename and date seperated by a tab

    :%!awk '{ printf("\%s\t", $0); system("strings " $0 " | grep '\''20[0-2][0-9],'\''") }'
I don't want that long path

    :1,$s:.*/::
I know, I'll sort them by build date

    :%!sort -r -k4 -k2M -k3n -k5
Oh yuck 4 space tabs don't do it

    :set ts=16
    :set expandtab
    :retab

Re: Ask HN: What code editors or IDEs are easily scriptable?

#58
I'll echo others' comments that you should consider not completely ruling out Lua. I'm a Neovim user almost exclusively, and knew no Lua at all coming in to it. In less than a day I was up to speed enough to be able to write complex extensions in it, and honestly didn't struggle much with the language itself in getting to that point. Most of my time was spent learning the APIs, not the language.

That said, while I've not done so, it _is_ possible to write Neovim extensions in Python. Check out this project for details: https://github.com/neovim/pynvim

While there are obviously many editors out there these days, IMO the ubiquity of [n]vim and emacs make them strong leaders. Convincing me to use anything else would be difficult.

I love Neovim, and it fits my needs well - but my choosing it over emacs was largely arbitrary. Now I'm in a position where I understand Neovim very well but lack that knowledge of emacs. As far as I know they're on par with each other.

Re: Ask HN: What code editors or IDEs are easily scriptable?

#59

Some people live in their editor and occasionally drop into a shell. I've personally found a lot less friction in doing the opposite. Live in the shell, and occasionally drop into your editor. I used to think that it would be better to have a lot of scripting and automation built into my editor, but there are so many well-built, connect-able tools already available in a unix shell that it's usually easier to write sc…

This is mostly how I work as well, and has the advantage that when I need to poke around on servers and appliances on which I do not have my vim setup, I can still use a lot of my regular “tricks” because they are shell-based.

Sure, sure, I do miss tpope’s surround and repeat plugins, but I have shell muscle memory and am happy(ish).

IMHO, of course, YMMV. :-)

Re: Ask HN: What code editors or IDEs are easily scriptable?

#60
Well, every IDE is designed to be extended. Unfortunately neither Go nor Rust are really intended for the extension use case. Sublime Text supports Python scripting but isn't an IDE.

I think the best IDE scripting experience I know of right now is IntelliJ (or other Jetbrains IDEs) with the Live Plugin extension. You can write simple scripts in Kotlin or Groovy. They're similar langs but the latter is dynamically typed. And then you can just do things like register menu items, explore the language AST, edit buffers, trigger refactorings, access remote machines. Anything, really.

As your script gets too big, you just convert it to a 'real' plugin project with multiple files, can use libraries, etc.

Then you can upload it to the Marketplace so people can find it.

And if your plugin ends up being really good, Jetbrains run a monetization system so you can sell it easily. They handle all the billing, tax, licensing etc for you, so you can focus on your plugin.

It's pretty rad. That said, in years of working with IntelliJ I never felt a need to extend it for my own personal use. It's not like emacs where every user ends up with piles of elisp. The defaults are pretty good, and many features where in other IDEs you'd be forced to write a script can be done entirely via the GUI. For example if you want to define templates that auto-expand and where the cursor moves between 'slots', you can do that using a mini templating language without needing to do any coding. There's a thing called Structural Search & Replace which is similar - it lets you create templates that match against ASTs and do transforms on them.

Post reply on HN