Ki Editor - an editor that operates on the AST

ki-editor.org

342 points by ravenical 13 hours ago


scriptsmith - 11 hours ago

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.

__MatrixMan__ - 39 minutes ago

I think the challenge with AST editing is discoverability. Like, I know what I want to select, I can see it there on the screen, but I don't know its name.

I've been dreaming of writing a plugin that surrounded the cursor in differently colored scopes. So instead of "next function" I'd be thinking "next blue" (blue being the color that functions are currently painted in).

radford-neal - 5 hours ago

Many years ago, I created an editor operating on syntax trees that I think is more "hard-core" than this - that is, only tree-oriented operations are done. There is no parsing of text, since entering plain text, rather than a tree, is impossible. Hence, there can be no syntactically invalid programs.

The challenge is getting this to be a useable way of entering programs. I think I made progress on this, but the feasibility varies with the programming language.

I can't run it any more, since the display hardware it assumed is no longer available, but you can read about it at https://ucalgary.scholaris.ca/items/da8b823b-c344-4ffb-aa37-...

sigbottle - 8 hours ago

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.

shashurup - 11 hours ago

In my classification of editors:

1. Orthodox. Mostly focused on looks and integrations.

2. Modal, Vim improvement. Focus on keeping basic Vim keybindings with minor improvements.

3. Modal, rethinking Vim approach.

Ki falls into the third category which I constantly monitor.

arikrahman - 26 minutes ago

A great addition to the helix workflow, I knew something was missing from the movement -> action approach. This completes the trifecta.

evelant - 10 hours ago

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.

ramon156 - 9 hours ago

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

muixoozie - 9 hours ago

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.

dataangel - 5 hours ago

As always emacs has it already

https://github.com/mickeynp/combobulate

lorenzohess - 7 hours ago

This is like slurp, barf, splice, raise, kill, cut, yank for lisps.

kfse - 6 hours ago

How does this work in the many cases where in-progress edits result in an unparseable structure?

armchairhacker - 12 hours ago

Vim-like (terminal and VSCode extension) that prioritizes syntax-based navigation.

Comparison to Vim and Helix: https://ki-editor.org/docs/comparison#user-content-fn-1

Myzel394 - 10 hours ago

I'll wait till an Emacs package is available

readitalready - 4 hours ago

The problem with editors is that each one has a huge cognitive load for minimal benefit. I can't imagine learning this one just to be able to move blocks around easier.

At this point you can just let your IDE's AI refactor any code by just telling it what you want to do.

messh - 7 hours ago

I don't like the positional keybindings. There is no real difference from regular keybindings configured with profiles for Qwerty, Dvorak, etc. In practice, it just means presenting them drawn into keyboards in a way that is hard to quickly search or use in the terminal and anywhere really. Where's the "line" key? Search the drawing! (Oh... it is there in th top left corner, but which exact key?) I prefer a list. So, really, it is not even that big of a "special thing" except the presentation.

rmetzler - 3 hours ago

I misread this a little bit, as KI is the German equivalent of AI (Artificial Intelligence = Künstliche Intelligenz).

alfanick - 8 hours ago

There was some Show HN some weeks ago on VCS/diff that operates on AST instead of lines/chars, anyone remembers its name?

shashurup - 7 hours ago

First impression. Muscle memory is a problem :(

Vim's j moves down.

Ki's j in line mode moves up...

Cannot figure how to create new file

nine_k - 6 hours ago

/* A source code editor that operates directly on the AST, and affords different visual representations on top of it, was the topic of my (unfinished) PhD thesis about 30 years ago. */

gigatexal - 2 hours ago

Ok ok all talk of the giant heavy java written jet brains IDE which I’m sure is great. What about all the experiences of using Ki and similar editors?

arikrahman - 4 hours ago

I highly appreciate the Nix-first approach

- 9 hours ago
[deleted]
groundzeros2015 - 10 hours ago

Have you seen any of the lisp tree editing modes for eMacs or vim?

mgaunard - 7 hours ago

Does it support C++?

hwhshs - 10 hours ago

Why not a vim plugin

irenetusuq - 9 hours ago

[dead]