Unnamed repository; edit this file 'description' to name the repository.
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
//! Implementation of the Chalk `Interner` trait, which allows customizing the
//! representation of the various objects Chalk deals with (types, goals etc.).

use crate::{chalk_db, tls, GenericArg};
use base_db::salsa::InternId;
use chalk_ir::{Goal, GoalData};
use hir_def::{
    intern::{impl_internable, InternStorage, Internable, Interned},
    type_ref::ConstScalar,
    TypeAliasId,
};
use smallvec::SmallVec;
use std::{fmt, sync::Arc};

#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
pub struct Interner;

#[derive(PartialEq, Eq, Hash)]
pub struct InternedWrapper<T>(T);

impl<T: fmt::Debug> fmt::Debug for InternedWrapper<T> {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt::Debug::fmt(&self.0, f)
    }
}

impl<T> std::ops::Deref for InternedWrapper<T> {
    type Target = T;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl_internable!(
    InternedWrapper<Vec<chalk_ir::VariableKind<Interner>>>,
    InternedWrapper<SmallVec<[GenericArg; 2]>>,
    InternedWrapper<chalk_ir::TyData<Interner>>,
    InternedWrapper<chalk_ir::LifetimeData<Interner>>,
    InternedWrapper<chalk_ir::ConstData<Interner>>,
    InternedWrapper<ConstScalar>,
    InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Interner>>>,
    InternedWrapper<Vec<chalk_ir::ProgramClause<Interner>>>,
    InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Interner>>>,
    InternedWrapper<Vec<chalk_ir::Variance>>,
);

impl chalk_ir::interner::Interner for Interner {
    type InternedType = Interned<InternedWrapper<chalk_ir::TyData<Interner>>>;
    type InternedLifetime = Interned<InternedWrapper<chalk_ir::LifetimeData<Self>>>;
    type InternedConst = Interned<InternedWrapper<chalk_ir::ConstData<Self>>>;
    type InternedConcreteConst = ConstScalar;
    type InternedGenericArg = chalk_ir::GenericArgData<Self>;
    type InternedGoal = Arc<GoalData<Self>>;
    type InternedGoals = Vec<Goal<Self>>;
    type InternedSubstitution = Interned<InternedWrapper<SmallVec<[GenericArg; 2]>>>;
    type InternedProgramClause = chalk_ir::ProgramClauseData<Self>;
    type InternedProgramClauses = Interned<InternedWrapper<Vec<chalk_ir::ProgramClause<Self>>>>;
    type InternedQuantifiedWhereClauses =
        Interned<InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Self>>>>;
    type InternedVariableKinds = Interned<InternedWrapper<Vec<chalk_ir::VariableKind<Interner>>>>;
    type InternedCanonicalVarKinds =
        Interned<InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Self>>>>;
    type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
    type InternedVariances = Interned<InternedWrapper<Vec<chalk_ir::Variance>>>;
    type DefId = InternId;
    type InternedAdtId = hir_def::AdtId;
    type Identifier = TypeAliasId;
    type FnAbi = ();

    fn debug_adt_id(
        type_kind_id: chalk_db::AdtId,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt)))
    }

    fn debug_trait_id(
        type_kind_id: chalk_db::TraitId,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        tls::with_current_program(|prog| Some(prog?.debug_trait_id(type_kind_id, fmt)))
    }

    fn debug_assoc_type_id(
        id: chalk_db::AssocTypeId,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        tls::with_current_program(|prog| Some(prog?.debug_assoc_type_id(id, fmt)))
    }

    fn debug_alias(
        alias: &chalk_ir::AliasTy<Interner>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        use std::fmt::Debug;
        match alias {
            chalk_ir::AliasTy::Projection(projection_ty) => {
                Interner::debug_projection_ty(projection_ty, fmt)
            }
            chalk_ir::AliasTy::Opaque(opaque_ty) => Some(opaque_ty.fmt(fmt)),
        }
    }

    fn debug_projection_ty(
        proj: &chalk_ir::ProjectionTy<Interner>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        tls::with_current_program(|prog| Some(prog?.debug_projection_ty(proj, fmt)))
    }

    fn debug_opaque_ty(
        opaque_ty: &chalk_ir::OpaqueTy<Interner>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", opaque_ty.opaque_ty_id))
    }

    fn debug_opaque_ty_id(
        opaque_ty_id: chalk_ir::OpaqueTyId<Self>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "OpaqueTy#{}", opaque_ty_id.0))
    }

    fn debug_ty(ty: &chalk_ir::Ty<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", ty.data(&Interner)))
    }

    fn debug_lifetime(
        lifetime: &chalk_ir::Lifetime<Interner>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", lifetime.data(&Interner)))
    }

    fn debug_generic_arg(
        parameter: &GenericArg,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", parameter.data(&Interner).inner_debug()))
    }

    fn debug_goal(goal: &Goal<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
        let goal_data = goal.data(&Interner);
        Some(write!(fmt, "{:?}", goal_data))
    }

    fn debug_goals(
        goals: &chalk_ir::Goals<Interner>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", goals.debug(&Interner)))
    }

    fn debug_program_clause_implication(
        pci: &chalk_ir::ProgramClauseImplication<Interner>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", pci.debug(&Interner)))
    }

    fn debug_substitution(
        substitution: &chalk_ir::Substitution<Interner>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", substitution.debug(&Interner)))
    }

    fn debug_separator_trait_ref(
        separator_trait_ref: &chalk_ir::SeparatorTraitRef<Interner>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", separator_trait_ref.debug(&Interner)))
    }

    fn debug_fn_def_id(
        fn_def_id: chalk_ir::FnDefId<Self>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        tls::with_current_program(|prog| Some(prog?.debug_fn_def_id(fn_def_id, fmt)))
    }
    fn debug_const(
        constant: &chalk_ir::Const<Self>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", constant.data(&Interner)))
    }
    fn debug_variable_kinds(
        variable_kinds: &chalk_ir::VariableKinds<Self>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", variable_kinds.as_slice(&Interner)))
    }
    fn debug_variable_kinds_with_angles(
        variable_kinds: &chalk_ir::VariableKinds<Self>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", variable_kinds.inner_debug(&Interner)))
    }
    fn debug_canonical_var_kinds(
        canonical_var_kinds: &chalk_ir::CanonicalVarKinds<Self>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", canonical_var_kinds.as_slice(&Interner)))
    }
    fn debug_program_clause(
        clause: &chalk_ir::ProgramClause<Self>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", clause.data(&Interner)))
    }
    fn debug_program_clauses(
        clauses: &chalk_ir::ProgramClauses<Self>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", clauses.as_slice(&Interner)))
    }
    fn debug_quantified_where_clauses(
        clauses: &chalk_ir::QuantifiedWhereClauses<Self>,
        fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        Some(write!(fmt, "{:?}", clauses.as_slice(&Interner)))
    }

    fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType {
        let flags = kind.compute_flags(self);
        Interned::new(InternedWrapper(chalk_ir::TyData { kind, flags }))
    }

    fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> {
        &ty.0
    }

    fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime {
        Interned::new(InternedWrapper(lifetime))
    }

    fn lifetime_data<'a>(
        &self,
        lifetime: &'a Self::InternedLifetime,
    ) -> &'a chalk_ir::LifetimeData<Self> {
        &lifetime.0
    }

    fn intern_const(&self, constant: chalk_ir::ConstData<Self>) -> Self::InternedConst {
        Interned::new(InternedWrapper(constant))
    }

    fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> {
        &constant.0
    }

    fn const_eq(
        &self,
        _ty: &Self::InternedType,
        c1: &Self::InternedConcreteConst,
        c2: &Self::InternedConcreteConst,
    ) -> bool {
        match (c1, c2) {
            (&ConstScalar::Usize(a), &ConstScalar::Usize(b)) => a == b,
            // we were previously assuming this to be true, I'm not whether true or false on
            // unknown values is safer.
            (_, _) => true,
        }
    }

    fn intern_generic_arg(
        &self,
        parameter: chalk_ir::GenericArgData<Self>,
    ) -> Self::InternedGenericArg {
        parameter
    }

    fn generic_arg_data<'a>(
        &self,
        parameter: &'a Self::InternedGenericArg,
    ) -> &'a chalk_ir::GenericArgData<Self> {
        parameter
    }

    fn intern_goal(&self, goal: GoalData<Self>) -> Self::InternedGoal {
        Arc::new(goal)
    }

    fn intern_goals<E>(
        &self,
        data: impl IntoIterator<Item = Result<Goal<Self>, E>>,
    ) -> Result<Self::InternedGoals, E> {
        data.into_iter().collect()
    }

    fn goal_data<'a>(&self, goal: &'a Self::InternedGoal) -> &'a GoalData<Self> {
        goal
    }

    fn goals_data<'a>(&self, goals: &'a Self::InternedGoals) -> &'a [Goal<Interner>] {
        goals
    }

    fn intern_substitution<E>(
        &self,
        data: impl IntoIterator<Item = Result<GenericArg, E>>,
    ) -> Result<Self::InternedSubstitution, E> {
        Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
    }

    fn substitution_data<'a>(
        &self,
        substitution: &'a Self::InternedSubstitution,
    ) -> &'a [GenericArg] {
        &substitution.as_ref().0
    }

    fn intern_program_clause(
        &self,
        data: chalk_ir::ProgramClauseData<Self>,
    ) -> Self::InternedProgramClause {
        data
    }

    fn program_clause_data<'a>(
        &self,
        clause: &'a Self::InternedProgramClause,
    ) -> &'a chalk_ir::ProgramClauseData<Self> {
        clause
    }

    fn intern_program_clauses<E>(
        &self,
        data: impl IntoIterator<Item = Result<chalk_ir::ProgramClause<Self>, E>>,
    ) -> Result<Self::InternedProgramClauses, E> {
        Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
    }

    fn program_clauses_data<'a>(
        &self,
        clauses: &'a Self::InternedProgramClauses,
    ) -> &'a [chalk_ir::ProgramClause<Self>] {
        clauses
    }

    fn intern_quantified_where_clauses<E>(
        &self,
        data: impl IntoIterator<Item = Result<chalk_ir::QuantifiedWhereClause<Self>, E>>,
    ) -> Result<Self::InternedQuantifiedWhereClauses, E> {
        Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
    }

    fn quantified_where_clauses_data<'a>(
        &self,
        clauses: &'a Self::InternedQuantifiedWhereClauses,
    ) -> &'a [chalk_ir::QuantifiedWhereClause<Self>] {
        clauses
    }

    fn intern_generic_arg_kinds<E>(
        &self,
        data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>,
    ) -> Result<Self::InternedVariableKinds, E> {
        Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
    }

    fn variable_kinds_data<'a>(
        &self,
        parameter_kinds: &'a Self::InternedVariableKinds,
    ) -> &'a [chalk_ir::VariableKind<Self>] {
        &parameter_kinds.as_ref().0
    }

    fn intern_canonical_var_kinds<E>(
        &self,
        data: impl IntoIterator<Item = Result<chalk_ir::CanonicalVarKind<Self>, E>>,
    ) -> Result<Self::InternedCanonicalVarKinds, E> {
        Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
    }

    fn canonical_var_kinds_data<'a>(
        &self,
        canonical_var_kinds: &'a Self::InternedCanonicalVarKinds,
    ) -> &'a [chalk_ir::CanonicalVarKind<Self>] {
        canonical_var_kinds
    }

    fn intern_constraints<E>(
        &self,
        data: impl IntoIterator<Item = Result<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>, E>>,
    ) -> Result<Self::InternedConstraints, E> {
        data.into_iter().collect()
    }

    fn constraints_data<'a>(
        &self,
        constraints: &'a Self::InternedConstraints,
    ) -> &'a [chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
        constraints
    }
    fn debug_closure_id(
        _fn_def_id: chalk_ir::ClosureId<Self>,
        _fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        None
    }
    fn debug_constraints(
        _clauses: &chalk_ir::Constraints<Self>,
        _fmt: &mut fmt::Formatter<'_>,
    ) -> Option<fmt::Result> {
        None
    }

    fn intern_variances<E>(
        &self,
        data: impl IntoIterator<Item = Result<chalk_ir::Variance, E>>,
    ) -> Result<Self::InternedVariances, E> {
        Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
    }

    fn variances_data<'a>(
        &self,
        variances: &'a Self::InternedVariances,
    ) -> &'a [chalk_ir::Variance] {
        variances
    }
}

impl chalk_ir::interner::HasInterner for Interner {
    type Interner = Self;
}

#[macro_export]
macro_rules! has_interner {
    ($t:ty) => {
        impl HasInterner for $t {
            type Interner = crate::Interner;
        }
    };
}
{ margin: 0; padding: 0; background-color: transparent; border: none; } pre { line-height: 125%; } td.linenos .normal { color: #8a919966; background-color: transparent; padding-left: 5px; padding-right: 5px; } span.linenos { color: #8a919966; background-color: transparent; padding-left: 5px; padding-right: 5px; } td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #363C48 } .highlight .c { color: #6E7C8E } /* Comment */ .highlight .err { color: #FF6666 } /* Error */ .highlight .g { color: #CCCAC2 } /* Generic */ .highlight .k { color: #FFAD66 } /* Keyword */ .highlight .o { color: #F29E74 } /* Operator */ .highlight .ch { color: #6E7C8E } /* Comment.Hashbang */ .highlight .cm { color: #6E7C8E; font-style: italic } /* Comment.Multiline */ .highlight .cp { color: #FFAD66 } /* Comment.Preproc */ .highlight .cpf { color: #D5FF80 } /* Comment.PreprocFile */ .highlight .c1 { color: #6E7C8E; font-style: italic } /* Comment.Single */ .highlight .cs { color: #6E7C8E } /* Comment.Special */ .highlight .gd { color: #F27983 } /* Generic.Deleted */ .highlight .ge { color: #FFD173; font-style: italic } /* Generic.Emph */ .highlight .gr { color: #FF6666 } /* Generic.Error */ .highlight .gh { color: #FFD173; font-weight: bold } /* Generic.Heading */ .highlight .gi { color: #87D96C } /* Generic.Inserted */ .highlight .go { color: #D5FF80 } /* Generic.Output */ .highlight .gp { color: #F29E74 } /* Generic.Prompt */ .highlight .gs { color: #FFD173; font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #CCCAC2 } /* Generic.Subheading */ .highlight .gt { color: #FF6666 } /* Generic.Traceback */ .highlight .kc { color: #DFBFFF } /* Keyword.Constant */ .highlight .kd { color: #FFCC66 } /* Keyword.Declaration */ .highlight .kn { color: #FFAD66 } /* Keyword.Namespace */ .highlight .kp { color: #FFAD66 } /* Keyword.Pseudo */ .highlight .kr { color: #FFAD66 } /* Keyword.Reserved */ .highlight .kt { color: #73D0FF } /* Keyword.Type */ .highlight .m { color: #DFBFFF } /* Literal.Number */ .highlight .s { color: #D5FF80 } /* Literal.String */ .highlight .na { color: #FFD173 } /* Name.Attribute */ .highlight .nb { color: #F28779 } /* Name.Builtin */ .highlight .nc { color: #5CCFE6 } /* Name.Class */ .highlight .no { color: #DFBFFF } /* Name.Constant */ .highlight .nd { color: #FFDFB3 } /* Name.Decorator */ .highlight .nf { color: #FFD173 } /* Name.Function */ .highlight .nt { color: #5CCFE6 } /* Name.Tag */ .highlight .ow { color: #F29E74 } /* Operator.Word */ .highlight .w { color: #CCCAC2 } /* Text.Whitespace */ .highlight .mb { color: #DFBFFF } /* Literal.Number.Bin */ .highlight .mf { color: #DFBFFF } /* Literal.Number.Float */ .highlight .mh { color: #DFBFFF } /* Literal.Number.Hex */ .highlight .mi { color: #DFBFFF } /* Literal.Number.Integer */ .highlight .mo { color: #DFBFFF } /* Literal.Number.Oct */ .highlight .sa { color: #D5FF80 } /* Literal.String.Affix */ .highlight .sb { color: #F29E74 } /* Literal.String.Backtick */ .highlight .sc { color: #D5FF80 } /* Literal.String.Char */ .highlight .dl { color: #D5FF80 } /* Literal.String.Delimiter */ .highlight .sd { color: #95E6CB; font-style: italic } /* Literal.String.Doc */ .highlight .s2 { color: #D5FF80 } /* Literal.String.Double */ .highlight .se { color: #D5FF80 } /* Literal.String.Escape */ .highlight .sh { color: #D5FF80 } /* Literal.String.Heredoc */ .highlight .si { color: #D5FF80 } /* Literal.String.Interpol */ .highlight .sx { color: #D5FF80 } /* Literal.String.Other */ .highlight .sr { color: #95E6CB } /* Literal.String.Regex */ .highlight .s1 { color: #D5FF80 } /* Literal.String.Single */ .highlight .ss { color: #D5FF80 } /* Literal.String.Symbol */ .highlight .bp { color: #F28779 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #FFD173 } /* Name.Function.Magic */ .highlight .vi { color: #FFCC66 } /* Name.Variable.Instance */ .highlight .vm { color: #5CCFE6; font-style: italic } /* Name.Variable.Magic */ .highlight .il { color: #DFBFFF } /* Literal.Number.Integer.Long */

Helix

[![Build status](https://github.com/helix-editor/helix/actions/workflows/build.yml/badge.svg)](https://github.com/helix-editor/helix/actions) [![GitHub Release](https://img.shields.io/github/v/release/helix-editor/helix)](https://github.com/helix-editor/helix/releases/latest) [![Documentation](https://shields.io/badge/-documentation-452859)](https://docs.helix-editor.com/) [![GitHub contributors](https://img.shields.io/github/contributors/helix-editor/helix)](https://github.com/helix-editor/helix/graphs/contributors) [![Matrix Space](https://img.shields.io/matrix/helix-community:matrix.org)](https://matrix.to/#/#helix-community:matrix.org)

Screenshot

A Kakoune / Neovim inspired editor, written in Rust.

The editing model is very heavily based on Kakoune; during development I found myself agreeing with most of Kakoune's design decisions.

For more information, see the website or documentation.

All shortcuts/keymaps can be found in the documentation on the website.

Troubleshooting

Features

It's a terminal-based editor first, but I'd like to explore a custom renderer (similar to Emacs) in wgpu or skulpin.

Note: Only certain languages have indentation definitions at the moment. Check runtime/queries/<lang>/ for indents.scm.

Installation

Packages are available for various distributions (see Installation docs).

If you would like to build from source:

git clone https://github.com/helix-editor/helix
cd helix
cargo install --path helix-term

This will install the hx binary to $HOME/.cargo/bin and build tree-sitter grammars in ./runtime/grammars.

Helix needs its runtime files so make sure to copy/symlink the runtime/ directory into the config directory (for example ~/.config/helix/runtime on Linux/macOS, or %AppData%/helix/runtime on Windows).

OS Command
Windows (Cmd) xcopy /e /i runtime %AppData%\helix\runtime
Windows (PowerShell) xcopy /e /i runtime $Env:AppData\helix\runtime
Linux / macOS ln -s $PWD/runtime ~/.config/helix/runtime

Starting with Windows Vista you can also create symbolic links on Windows. Note that this requires elevated privileges - i.e. PowerShell or Cmd must be run as administrator.

PowerShell:

New-Item -ItemType SymbolicLink -Target "runtime" -Path "$Env:AppData\helix\runtime"

Cmd:

cd %appdata%\helix
mklink /D runtime "<helix-repo>\runtime"

The runtime location can be overridden via the HELIX_RUNTIME environment variable.

NOTE: if HELIX_RUNTIME is set prior to calling cargo install --path helix-term, tree-sitter grammars will be built in $HELIX_RUNTIME/grammars.

If you plan on keeping the repo locally, an alternative to copying/symlinking runtime files is to set HELIX_RUNTIME=/path/to/helix/runtime (HELIX_RUNTIME=$PWD/runtime if you're in the helix repo directory).

Packages already solve this for you by wrapping the hx binary with a wrapper that sets the variable to the install dir.

NOTE: running via cargo also doesn't require setting explicit HELIX_RUNTIME path, it will automatically detect the runtime directory in the project root.

If you want to customize your languages.toml config, tree-sitter grammars may be manually fetched and built with hx --grammar fetch and hx --grammar build.

In order to use LSP features like auto-complete, you will need to install the appropriate Language Server for a language.

Packaging status

Adding Helix to your desktop environment

If installing from source, to use Helix in desktop environments that supports XDG desktop menu, including Gnome and KDE, copy the provided .desktop file to the correct folder:

cp contrib/Helix.desktop ~/.local/share/applications

To use another terminal than the default, you will need to modify the .desktop file. For example, to use kitty:

sed -i "s|Exec=hx %F|Exec=kitty hx %F|g" ~/.local/share/applications/Helix.desktop
sed -i "s|Terminal=true|Terminal=false|g" ~/.local/share/applications/Helix.desktop

Please note: there is no icon for Helix yet, so the system default will be used.

macOS

Helix can be installed on macOS through homebrew:

brew install helix

Contributing

Contributing guidelines can be found here.

Getting help

Your question might already be answered on the FAQ.

Discuss the project on the community Matrix Space (make sure to join #helix-editor:matrix.org if you're on a client that doesn't support Matrix Spaces yet).

Credits

Thanks to @JakeHL for designing the logo!