2013-10-10 19:59:32 +02:00
|
|
|
Kakoune design
|
|
|
|
==============
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
This document describes the design goals for Kakoune, including rationale.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
|
|
|
Interactivity
|
|
|
|
-------------
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
Unlike Vim, Kakoune does not have an underlying line-oriented editor. It is
|
|
|
|
always expected to be used in an interactive fashion, displaying edited text in
|
|
|
|
real time. That should not prevent Kakoune from being used non-interactively
|
|
|
|
(executing a macro for example), but priority should be given to ease of
|
|
|
|
interactive use.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
|
|
|
Limited scope
|
|
|
|
-------------
|
|
|
|
|
|
|
|
Kakoune is a code editor. It is not an IDE, not a file browser, not a word
|
2021-03-18 03:10:20 +01:00
|
|
|
processor and not a window manager. It should be very efficient at editing code.
|
|
|
|
As a side effect, it should be very efficient at editing text in general.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
|
|
|
Composability
|
|
|
|
-------------
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
Being limited in scope to code editing should not isolate Kakoune from its
|
2017-04-21 12:32:47 +02:00
|
|
|
environment. On the contrary, Kakoune is expected to run on a Unix-like
|
2021-03-18 03:10:20 +01:00
|
|
|
system alongside a lot of text-based tools, and should make it easy to
|
2013-10-10 19:59:32 +02:00
|
|
|
interact with these tools.
|
|
|
|
|
|
|
|
For example, sorting lines should be done using the Unix sort command, not
|
|
|
|
with an internal implementation. Kakoune should make it easy to do that,
|
2018-05-11 00:58:13 +02:00
|
|
|
hence the +|+ command for piping selected text through a filter.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
The modern Unix environment is not limited to text filters. Most people use
|
2013-10-10 19:59:32 +02:00
|
|
|
a graphical interface nowadays, and Kakoune should be able to take advantage
|
2021-03-18 03:10:20 +01:00
|
|
|
of that without hindering text mode support. For example, Kakoune enables
|
|
|
|
multiple windows by supporting many clients on the same editing session,
|
|
|
|
not by reimplementing tiling and tabbing. Those responsibilities are left
|
|
|
|
to the system window manager.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
|
|
|
Orthogonality
|
|
|
|
-------------
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
Kakoune features should be as orthogonal as possible. For example, in Vim,
|
|
|
|
there are many ways to modify the buffer: Through normal/insert
|
|
|
|
mode, command mode, and Vim scripts. In Kakoune, modifying the buffer is
|
|
|
|
only the job of normal/insert mode.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
|
|
|
That means there should be clear separation of concerns between modes:
|
|
|
|
|
|
|
|
* normal mode is for manipulating the selection and the selection contents.
|
|
|
|
|
|
|
|
* insert mode is for interactive insertion into the buffer.
|
|
|
|
|
|
|
|
* command mode is for non-editing features (opening a file, setting
|
|
|
|
options...).
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
Orthogonality is an ideal; it should not forbid common sense pragmatism.
|
|
|
|
The +gf+ and +ga+ commands are not strictly selection manipulation commands,
|
|
|
|
but they do fit nicely with other +goto+ commands, so they are acceptable in
|
2014-04-25 19:43:55 +02:00
|
|
|
normal mode even though they could arguably be moved to command mode.
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
Modes should be orthogonal, as should commands within modes. For
|
|
|
|
example, Vim uses both +d+ and +x+ to delete text, with minor differences. In
|
2016-12-08 10:48:08 +01:00
|
|
|
Kakoune only +d+ exists, and the design ensures that +x+ is not needed.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
|
|
|
Speed
|
|
|
|
-----
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
Kakoune should be fast -- fast to use, as in a lot of editing in a few
|
2013-10-10 19:59:32 +02:00
|
|
|
keystrokes, and fast to execute.
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
* Vim is the benchmark here. Most editing tasks should be doable in fewer
|
|
|
|
or the same number of keystrokes as Vim.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
* Kakoune is designed with asynchronicity in mind. Launching a background
|
2017-04-21 12:32:47 +02:00
|
|
|
process and using its result when available should not block the editor.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
* Kakoune should be implemented with speed in mind. A slow editor is a
|
2013-10-10 19:59:32 +02:00
|
|
|
useless one.
|
|
|
|
|
|
|
|
Simplicity
|
|
|
|
----------
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
Simplicity is nice. Simplicity correlates with orthogonality and speed. It makes
|
2013-10-10 19:59:32 +02:00
|
|
|
things easier to understand, bugs easier to fix, and code easier to change.
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
* *No threading*: multithreading is a hard problem and is not well suited
|
2013-10-10 19:59:32 +02:00
|
|
|
to a text editor:
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
- When we want a direct result, we need to be synchronous with
|
|
|
|
the user. A 4x speed improvement is meaningless; we need to have an
|
2023-04-06 12:27:41 +02:00
|
|
|
algorithm which appears instantaneous to the user.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
- When we want an asynchronous result, the processing is best left
|
2013-10-10 19:59:32 +02:00
|
|
|
to a helper command which can be reused with other Unix tools.
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
* *No binary plugins*: shared objects by themselves add a lot of
|
|
|
|
complexity. Plugins add another interface to Kakoune and go against
|
|
|
|
orthogonality. The +%sh{ ... }+ and socket interfaces should be made good
|
2013-10-10 19:59:32 +02:00
|
|
|
enough for most plugin use cases.
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
- Rather than writing a plugin for intelligent code completion or source
|
|
|
|
code navigation, it is better to write an independent helper tool that can
|
|
|
|
interact with Kakoune through the shell.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
|
|
|
* *No integrated scripting language*: for the same reason as binary plugins.
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
* *Limited smartness*: Kakoune should not try to be too smart. Being smart
|
|
|
|
is often unpredictable for the user and makes things context-dependent.
|
|
|
|
When Kakoune tries to be smart, it should provide the alternative,
|
|
|
|
'non-smart' version. For instance, +\*+ tries to detect word boundaries on
|
|
|
|
the selection, but +alt-*+ opts out of this behavior.
|
2017-12-13 23:24:31 +01:00
|
|
|
|
|
|
|
Unified interactive use and scripting
|
|
|
|
-------------------------------------
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
As an effect of both Orthogonality and Simplicity, normal mode is not
|
|
|
|
a layer of keys bound to a text editing language layer. Normal mode *is*
|
|
|
|
the text editing language.
|
2017-12-13 23:24:31 +01:00
|
|
|
|
|
|
|
That means there is no +delete-selected-text+ command that +d+ is bound
|
2021-03-18 03:10:20 +01:00
|
|
|
to. +d+ *is* the +delete selected text+ command.
|
2017-12-13 23:24:31 +01:00
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
This permits both scripting and interactive use cases to share the same text
|
|
|
|
editing language. Both use normal mode to express complex editing.
|
2017-12-13 23:24:31 +01:00
|
|
|
|
|
|
|
Besides promoting simplicity by avoiding the introduction of another
|
2021-03-18 03:10:20 +01:00
|
|
|
layer, this helps ensure the interactive editing language is expressive
|
|
|
|
enough to handle complex use cases, such as indentation hooks.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
Language-agnostic
|
2013-10-10 19:59:32 +02:00
|
|
|
-----------------
|
|
|
|
|
2015-06-24 09:06:32 +02:00
|
|
|
Kakoune should not be tailored for writing in a specific programming
|
2013-10-10 19:59:32 +02:00
|
|
|
language. Support for different languages should be provided by a kak script
|
2021-03-18 03:10:20 +01:00
|
|
|
file. Built-in language support should be avoided.
|
2013-10-10 19:59:32 +02:00
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
Self-documenting
|
2014-04-25 19:43:55 +02:00
|
|
|
----------------
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
Kakoune should be able to document its features. Live documentation, along
|
|
|
|
with an extensive suggestion/completion system, provides the discoverability
|
|
|
|
which is often lacking in non-GUI tools. As much as possible, documentation
|
|
|
|
should be integrated with the code so that it stays up to date.
|
2014-04-25 19:43:55 +02:00
|
|
|
|
2013-10-10 19:59:32 +02:00
|
|
|
Vim compatibility
|
|
|
|
-----------------
|
|
|
|
|
2021-03-18 03:10:20 +01:00
|
|
|
Kakoune is inspired by Vim and should try to keep its commands similar to
|
|
|
|
Vim's if there are no compelling reasons to deviate. However, self-consistency
|
2013-10-10 19:59:32 +02:00
|
|
|
is more important than Vim compatibility.
|