summaryrefslogtreecommitdiff
path: root/doc/coding-style.asciidoc
blob: 2885a4ac021e41fa2594278428ee609fd48f963a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
C++ Coding Style
================

Kakoune is written in C++20, here are the main coding style points:

 * Avoid external dependencies besides posix/stdc++

 * 4 spaces for indentation, no tabs

 * public interface before private methods/data when defining a class

 * use +override+ keyword for overridden virtual methods

 * opening brackets on their own lines by default, except when declaring
   an object where the opening bracket follows the equal sign.

 * use alternative logical operator names (and, or, not instead of &&, ||, !)

-----
int func()
{
    if (condition)
    {
        ...
    }
    else
        statement;
}

int array[] = {
...
};
-----

 * End lines with an operator when continuing on the next line

----
if (condition1 or
    condition2)
----

 * Try to keep under 80 columns, even though this is not a strict limit.

 * CamelCase for types, snake_case for variables/function names

 * prefix fields with m_, static ones with ms_ except for dumb structs
   (struct with every field public) where these prefixes can be dropped.

 * use const and constexpr liberally