Live data from Hacker News

Ki Editor - an editor that operates on the AST

ki-editor.org

31–40 of 154 posts

Re: Ki Editor - an editor that operates on the AST

#31
post #4

Earlier quoted context omitted.

4. All of the above. Which is Emacs.

I know, I use Emacs+Evil. I'm going to give Ki a try and, in case of success, to think about writing Ki binding for Emacs.

emacs already has structural editing packages like combobulate

Re: Ki Editor - an editor that operates on the AST

#33

The "First-class syntactic selection" reminds me of my most used shortcut(s) in Jetbrains IDEs: the Expand / Shrink Selection. Ctrl + W Ctrl + Shift + W https://www.jetbrains.com/help/idea/working-with-source-code... It really changed my perspective on interacting with the 'text' of a file. VS Code, Zed, etc. have similar operations, but in my experience they expand and shrink too coarsely.

I agree, top feature. Combined with things like "extract method" makes mundane refactorings super fast.

Re: Ki Editor - an editor that operates on the AST

#34
I can't wait to try it. Love that it's keyboard layout agnostic. A lot of other good sounding ideas in the docs. Especially inspiration from Emacs as everything being an editable buffer. There's always some massive tradeoffs between editors though. Guess I'll have to see.

Re: Ki Editor - an editor that operates on the AST

#35
post #30
post #4

Earlier quoted context omitted.

4. All of the above. Which is Emacs.

Right, but we are discussing editors here.

Hold on. Operating systems and long-running esoteric history are always on topic here, right?

(This is spoken with something close to affection; I look fondly on my former Emacs days. I'm probably more likely than not to enjoy the company of a human who has at least tried Emacs and had some thoughtful reaction to it. I may not use it now, but the ideas live on in how I think and what I expect. Editors that push the limits, whatever those limits are, are part of the old school ethos I love about programming.)

Re: Ki Editor - an editor that operates on the AST

#36
I didn't fully understand until I saw the examples

> First-class syntactic modification

> Notice the comma between the current and the next node is also deleted. > Notice how comma is added automatically.

This is awesome! And I bet it arguably requires less logic to do so as well. Cool stuff.

Now I'm wondering how much effort it would be to get a ki integration (or at least an AST-first rewrite) in Zed

Re: Ki Editor - an editor that operates on the AST

#37
post #12

Why not a vim plugin

It's funny you mention that. I am currently working on a neovim plugin which implements the ki-editor keymap.

https://codeberg.org/alicealysia/ki-bindings.nvim

Unfortunately however, there's some shortcomings of neovim which make its control scheme impossible (at least not without some workarounds)

One of the biggest is ki's momentary layers feature.

Ki uses the kitty keyboard protocol to detect when a key is being held and when it is released in order to allow for unique actions when multiple keys are pressed simultaneously, and this functionality is a big part of what makes it so ergonomic.

For example, tapping c will copy the currently highlighted text, but pressing c and k simultaneously will duplicate the currently selected text to a new line below the current line.

While I'm currently chipping away at a pull request to introduce similar functionality to neovim itself, in the meantime, I'm needing to work around the issue by making a lot of concessions.

Re: Ki Editor - an editor that operates on the AST

#38
I feel so illiterate when it comes to AST editing sometimes. I understand what an AST is from a computer science perspective. But I've never worked on a huge software refactor before that required direct AST textobject editing. Maybe an indication of my skill level...

The extent of my usage is having nice textobjects to easily interact with arglists and functions which aren't native to (neo)vim. Very cute and nice to just write "daf" somewhere in a function and just have it "just delete". Or hook it up with basic macros: search for regex, "daf".

I guess it's hard for me to edit things that I don't see right in front of me or aren't super simple changes (like name changes). Or at least, basic things I can reason about (such as finding by regex then deleting by textobject or something).

As for LSP's, I do use go to definition and rename all references, which is nice. But the huge structural refactoring part I have never really done. I don't really use many LSP features besides those two either...

Basically, I gotta up my editor game.

Re: Ki Editor - an editor that operates on the AST

#39
post #12

Why not a vim plugin

> Note that the Ki keybindings cannot be simply implemented in Vim/Helix via key- remapping, due to the lack of the concept of Selection Mode, and implementing that requires major architectural changes in the core.

Not by default, and it's not a neat and tidy solution, but you can rebind keys as a result of inputing other keys in neovim via a callback (and edit the statusbar ofc to display said selection mode)

This, alongside the use of a variable means you can, in fact, build your own selection modes! Likewise, nvim does have a seperate select and visual mode.

This is primarily designed as an option to replicate the more traditional shift+movement selection and type to replace functionality of something like vscode or notepad, however it can be exploited as an additional layer for storing keybinds in a pinch

Re: Ki Editor - an editor that operates on the AST

#40
post #15

I made the vscode integration for this. I feel bad that I haven’t contributed much since, it’s a really cool project. IMO it’s important to try to innovate in the foundational tools of our craft (editors, languages, tooling, OS, etc) which Ki does.

This one?

https://marketplace.visualstudio.com/items?itemName=ki-edito...

Post reply on HN