Skip to content

Commit f19ce46

Browse files
author
André Sá
authored
Merge pull request #1 from helix-editor/master
Update from forked repo
2 parents 906259c + dad6d0f commit f19ce46

27 files changed

+285
-75
lines changed

book/src/configuration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Statusline elements can be defined as follows:
6262
[editor.statusline]
6363
left = ["mode", "spinner"]
6464
center = ["file-name"]
65-
right = ["diagnostics", "selections", "position", "file-encoding", "file-type"]
65+
right = ["diagnostics", "selections", "position", "file-encoding", "file-line-ending", "file-type"]
6666
```
6767

6868
The following elements can be configured:
@@ -73,6 +73,7 @@ The following elements can be configured:
7373
| `spinner` | A progress spinner indicating LSP activity |
7474
| `file-name` | The path/name of the opened file |
7575
| `file-encoding` | The encoding of the opened file if it differs from UTF-8 |
76+
| `file-line-ending` | The file line endings (CRLF or LF) |
7677
| `file-type` | The type of the opened file |
7778
| `diagnostics` | The number of warnings and/or errors |
7879
| `selections` | The number of active selections |

book/src/generated/lang-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
| git-diff || | | |
3131
| git-ignore || | | |
3232
| git-rebase || | | |
33-
| gleam ||| | |
33+
| gleam ||| | `gleam` |
3434
| glsl |||| |
3535
| go |||| `gopls` |
3636
| gomod || | | `gopls` |

book/src/keymap.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ This layer is a kludge of mappings, mostly pickers.
238238
| ----- | ----------- | ------- |
239239
| `f` | Open file picker | `file_picker` |
240240
| `b` | Open buffer picker | `buffer_picker` |
241+
| `j` | Open jumplist picker | `jumplist_picker` |
241242
| `k` | Show documentation for item under cursor in a [popup](#popup) (**LSP**) | `hover` |
242243
| `s` | Open document symbol picker (**LSP**) | `symbol_picker` |
243244
| `S` | Open workspace symbol picker (**LSP**) | `workspace_symbol_picker` |

docs/releases.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## Checklist
2+
3+
Helix releases are versioned in the Calendar Versioning scheme:
4+
`YY.0M(.MICRO)`, for example `22.05` for May of 2022. In these instructions
5+
we'll use `<tag>` as a placeholder for the tag being published.
6+
7+
* Merge the changelog PR
8+
* Tag and push
9+
* `git tag -s -m "<tag>" -a <tag> && git push`
10+
* Make sure to switch to master and pull first
11+
* Edit the `VERSION` file and change the date to the next planned release
12+
* Releases are planned to happen every two months, so `22.05` would change to `22.07`
13+
* Wait for the Release CI to finish
14+
* It will automatically turn the git tag into a GitHub release when it uploads artifacts
15+
* Edit the new release
16+
* Use `<tag>` as the title
17+
* Link to the changelog and release notes
18+
* Merge the release notes PR
19+
* Download the macos and linux binaries and update the `sha256`s in the [homebrew formula]
20+
* Use `sha256sum` on the downloaded `.tar.xz` files to determine the hash
21+
* Link to the release notes in this-week-in-rust
22+
* [Example PR](https://github.com/rust-lang/this-week-in-rust/pull/3300)
23+
* Post to reddit
24+
* [Example post](https://www.reddit.com/r/rust/comments/uzp5ze/helix_editor_2205_released/)
25+
26+
[homebrew formula]: https://github.com/helix-editor/homebrew-helix/blob/master/Formula/helix.rb
27+
28+
## Changelog Curation
29+
30+
The changelog is currently created manually by reading through commits in the
31+
log since the last release. GitHub's compare view is a nice way to approach
32+
this. For example when creating the 22.07 release notes, this compare link
33+
may be used
34+
35+
```
36+
https://github.com/helix-editor/helix/compare/22.05...master
37+
```
38+
39+
Either side of the triple-dot may be replaced with an exact revision, so if
40+
you wish to incrementally compile the changelog, you can tackle a weeks worth
41+
or so, record the revision where you stopped, and use that as a starting point
42+
next week:
43+
44+
```
45+
https://github.com/helix-editor/helix/compare/7706a4a0d8b67b943c31d0c5f7b00d357b5d838d...master
46+
```
47+
48+
A work-in-progress commit for a changelog might look like
49+
[this example](https://github.com/helix-editor/helix/commit/831adfd4c709ca16b248799bfef19698d5175e55).
50+
51+
Not every PR or commit needs a blurb in the changelog. Each release section
52+
tends to have a blurb that links to a GitHub comparison between release
53+
versions for convenience:
54+
55+
> As usual, the following is a summary of each of the changes since the last
56+
> release. For the full log, check out the git log.
57+
58+
Typically, small changes like dependencies or documentation updates, refactors,
59+
or meta changes like GitHub Actions work are left out.

helix-core/src/syntax.rs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -328,29 +328,15 @@ fn read_query(language: &str, filename: &str) -> String {
328328

329329
let query = load_runtime_file(language, filename).unwrap_or_default();
330330

331-
// TODO: the collect() is not ideal
332-
let inherits = INHERITS_REGEX
333-
.captures_iter(&query)
334-
.flat_map(|captures| {
331+
// replaces all "; inherits <language>(,<language>)*" with the queries of the given language(s)
332+
INHERITS_REGEX
333+
.replace_all(&query, |captures: &regex::Captures| {
335334
captures[1]
336335
.split(',')
337-
.map(str::to_owned)
338-
.collect::<Vec<_>>()
336+
.map(|language| format!("\n{}\n", read_query(language, filename)))
337+
.collect::<String>()
339338
})
340-
.collect::<Vec<_>>();
341-
342-
if inherits.is_empty() {
343-
return query;
344-
}
345-
346-
let mut queries = inherits
347-
.iter()
348-
.map(|language| read_query(language, filename))
349-
.collect::<Vec<_>>();
350-
351-
queries.push(query);
352-
353-
queries.concat()
339+
.to_string()
354340
}
355341

356342
impl LanguageConfiguration {

helix-term/src/commands.rs

Lines changed: 115 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ impl MappableCommand {
264264
file_picker_in_current_directory, "Open file picker at current working directory",
265265
code_action, "Perform code action",
266266
buffer_picker, "Open buffer picker",
267+
jumplist_picker, "Open jumplist picker",
267268
symbol_picker, "Open symbol picker",
268269
select_references_to_symbol_under_cursor, "Select symbol references",
269270
workspace_symbol_picker, "Open workspace symbol picker",
@@ -2270,6 +2271,87 @@ fn buffer_picker(cx: &mut Context) {
22702271
cx.push_layer(Box::new(overlayed(picker)));
22712272
}
22722273

2274+
fn jumplist_picker(cx: &mut Context) {
2275+
struct JumpMeta {
2276+
id: DocumentId,
2277+
path: Option<PathBuf>,
2278+
selection: Selection,
2279+
text: String,
2280+
is_current: bool,
2281+
}
2282+
2283+
impl ui::menu::Item for JumpMeta {
2284+
type Data = ();
2285+
2286+
fn label(&self, _data: &Self::Data) -> Spans {
2287+
let path = self
2288+
.path
2289+
.as_deref()
2290+
.map(helix_core::path::get_relative_path);
2291+
let path = match path.as_deref().and_then(Path::to_str) {
2292+
Some(path) => path,
2293+
None => SCRATCH_BUFFER_NAME,
2294+
};
2295+
2296+
let mut flags = Vec::new();
2297+
if self.is_current {
2298+
flags.push("*");
2299+
}
2300+
2301+
let flag = if flags.is_empty() {
2302+
"".into()
2303+
} else {
2304+
format!(" ({})", flags.join(""))
2305+
};
2306+
format!("{} {}{} {}", self.id, path, flag, self.text).into()
2307+
}
2308+
}
2309+
2310+
let new_meta = |view: &View, doc_id: DocumentId, selection: Selection| {
2311+
let doc = &cx.editor.documents.get(&doc_id);
2312+
let text = doc.map_or("".into(), |d| {
2313+
selection
2314+
.fragments(d.text().slice(..))
2315+
.map(Cow::into_owned)
2316+
.collect::<Vec<_>>()
2317+
.join(" ")
2318+
});
2319+
2320+
JumpMeta {
2321+
id: doc_id,
2322+
path: doc.and_then(|d| d.path().cloned()),
2323+
selection,
2324+
text,
2325+
is_current: view.doc == doc_id,
2326+
}
2327+
};
2328+
2329+
let picker = FilePicker::new(
2330+
cx.editor
2331+
.tree
2332+
.views()
2333+
.flat_map(|(view, _)| {
2334+
view.jumps
2335+
.get()
2336+
.iter()
2337+
.map(|(doc_id, selection)| new_meta(view, *doc_id, selection.clone()))
2338+
})
2339+
.collect(),
2340+
(),
2341+
|cx, meta, action| {
2342+
cx.editor.switch(meta.id, action);
2343+
let (view, doc) = current!(cx.editor);
2344+
doc.set_selection(view.id, meta.selection.clone());
2345+
},
2346+
|editor, meta| {
2347+
let doc = &editor.documents.get(&meta.id)?;
2348+
let line = meta.selection.primary().cursor_line(doc.text().slice(..));
2349+
Some((meta.path.clone()?, Some((line, line))))
2350+
},
2351+
);
2352+
cx.push_layer(Box::new(overlayed(picker)));
2353+
}
2354+
22732355
impl ui::menu::Item for MappableCommand {
22742356
type Data = ReverseKeymap;
22752357

@@ -2974,14 +3056,18 @@ pub mod insert {
29743056

29753057
pub fn delete_char_backward(cx: &mut Context) {
29763058
let count = cx.count();
2977-
let (view, doc) = current!(cx.editor);
3059+
let (view, doc) = current_ref!(cx.editor);
29783060
let text = doc.text().slice(..);
29793061
let indent_unit = doc.indent_unit();
29803062
let tab_size = doc.tab_width();
3063+
let auto_pairs = doc.auto_pairs(cx.editor);
29813064

29823065
let transaction =
29833066
Transaction::change_by_selection(doc.text(), doc.selection(view.id), |range| {
29843067
let pos = range.cursor(text);
3068+
if pos == 0 {
3069+
return (pos, pos, None);
3070+
}
29853071
let line_start_pos = text.line_to_char(range.cursor_line(text));
29863072
// consider to delete by indent level if all characters before `pos` are indent units.
29873073
let fragment = Cow::from(text.slice(line_start_pos..pos));
@@ -3029,14 +3115,36 @@ pub mod insert {
30293115
(start, pos, None) // delete!
30303116
}
30313117
} else {
3032-
// delete char
3033-
(
3034-
graphemes::nth_prev_grapheme_boundary(text, pos, count),
3035-
pos,
3036-
None,
3037-
)
3118+
match (
3119+
text.get_char(pos.saturating_sub(1)),
3120+
text.get_char(pos),
3121+
auto_pairs,
3122+
) {
3123+
(Some(_x), Some(_y), Some(ap))
3124+
if range.is_single_grapheme(text)
3125+
&& ap.get(_x).is_some()
3126+
&& ap.get(_x).unwrap().close == _y =>
3127+
// delete both autopaired characters
3128+
{
3129+
(
3130+
graphemes::nth_prev_grapheme_boundary(text, pos, count),
3131+
graphemes::nth_next_grapheme_boundary(text, pos, count),
3132+
None,
3133+
)
3134+
}
3135+
_ =>
3136+
// delete 1 char
3137+
{
3138+
(
3139+
graphemes::nth_prev_grapheme_boundary(text, pos, count),
3140+
pos,
3141+
None,
3142+
)
3143+
}
3144+
}
30383145
}
30393146
});
3147+
let (view, doc) = current!(cx.editor);
30403148
doc.apply(&transaction, view.id);
30413149

30423150
lsp::signature_help_impl(cx, SignatureHelpInvoked::Automatic);
@@ -4001,13 +4109,11 @@ fn split(cx: &mut Context, action: Action) {
40014109
let (view, doc) = current!(cx.editor);
40024110
let id = doc.id();
40034111
let selection = doc.selection(view.id).clone();
4004-
let offset = view.offset;
40054112

40064113
cx.editor.switch(id, action);
40074114

40084115
// match the selection in the previous view
40094116
let (view, doc) = current!(cx.editor);
4010-
view.offset = offset;
40114117
doc.set_selection(view.id, selection);
40124118
}
40134119

helix-term/src/commands/typed.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,11 @@ fn set_line_ending(
413413

414414
// Attempt to parse argument as a line ending.
415415
let line_ending = match arg {
416-
// We check for CR first because it shares a common prefix with CRLF.
417-
#[cfg(feature = "unicode-lines")]
418-
arg if arg.starts_with("cr") => CR,
419416
arg if arg.starts_with("crlf") => Crlf,
420417
arg if arg.starts_with("lf") => LF,
421418
#[cfg(feature = "unicode-lines")]
419+
arg if arg.starts_with("cr") => CR,
420+
#[cfg(feature = "unicode-lines")]
422421
arg if arg.starts_with("ff") => FF,
423422
#[cfg(feature = "unicode-lines")]
424423
arg if arg.starts_with("nel") => Nel,

helix-term/src/keymap/default.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
205205
"f" => file_picker,
206206
"F" => file_picker_in_current_directory,
207207
"b" => buffer_picker,
208+
"j" => jumplist_picker,
208209
"s" => symbol_picker,
209210
"S" => workspace_symbol_picker,
210211
"g" => diagnostics_picker,

helix-term/src/ui/statusline.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ where
138138
helix_view::editor::StatusLineElement::Spinner => render_lsp_spinner,
139139
helix_view::editor::StatusLineElement::FileName => render_file_name,
140140
helix_view::editor::StatusLineElement::FileEncoding => render_file_encoding,
141+
helix_view::editor::StatusLineElement::FileLineEnding => render_file_line_ending,
141142
helix_view::editor::StatusLineElement::FileType => render_file_type,
142143
helix_view::editor::StatusLineElement::Diagnostics => render_diagnostics,
143144
helix_view::editor::StatusLineElement::Selections => render_selections,
@@ -280,6 +281,31 @@ where
280281
}
281282
}
282283

284+
fn render_file_line_ending<F>(context: &mut RenderContext, write: F)
285+
where
286+
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
287+
{
288+
use helix_core::LineEnding::*;
289+
let line_ending = match context.doc.line_ending {
290+
Crlf => "CRLF",
291+
LF => "LF",
292+
#[cfg(feature = "unicode-lines")]
293+
VT => "VT", // U+000B -- VerticalTab
294+
#[cfg(feature = "unicode-lines")]
295+
FF => "FF", // U+000C -- FormFeed
296+
#[cfg(feature = "unicode-lines")]
297+
CR => "CR", // U+000D -- CarriageReturn
298+
#[cfg(feature = "unicode-lines")]
299+
Nel => "NEL", // U+0085 -- NextLine
300+
#[cfg(feature = "unicode-lines")]
301+
LS => "LS", // U+2028 -- Line Separator
302+
#[cfg(feature = "unicode-lines")]
303+
PS => "PS", // U+2029 -- ParagraphSeparator
304+
};
305+
306+
write(context, format!(" {} ", line_ending), None);
307+
}
308+
283309
fn render_file_type<F>(context: &mut RenderContext, write: F)
284310
where
285311
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,

helix-view/src/document.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::{DocumentId, Editor, ViewId};
2727
/// 8kB of buffer space for encoding and decoding `Rope`s.
2828
const BUF_SIZE: usize = 8192;
2929

30-
const DEFAULT_INDENT: IndentStyle = IndentStyle::Spaces(4);
30+
const DEFAULT_INDENT: IndentStyle = IndentStyle::Tabs;
3131

3232
pub const SCRATCH_BUFFER_NAME: &str = "[scratch]";
3333

0 commit comments

Comments
 (0)