mirror of https://github.com/helix-editor/helix
Compare commits
10 Commits
79e8653623
...
99af00026d
Author | SHA1 | Date |
---|---|---|
|
99af00026d | |
|
395a71bf53 | |
|
1e4bf6704a | |
|
b01fbb4a22 | |
|
f75a26cb9b | |
|
21ae1c98fb | |
|
7b8a4b7a51 | |
|
715d4ae2d5 | |
|
22b184b570 | |
|
033e449d8f |
|
@ -112,8 +112,8 @@
|
||||||
| iex | ✓ | | | | |
|
| iex | ✓ | | | | |
|
||||||
| ini | ✓ | | | | |
|
| ini | ✓ | | | | |
|
||||||
| ink | ✓ | | | | |
|
| ink | ✓ | | | | |
|
||||||
| inko | ✓ | ✓ | ✓ | | |
|
| inko | ✓ | ✓ | ✓ | ✓ | |
|
||||||
| janet | ✓ | | | | |
|
| janet | ✓ | | ✓ | | |
|
||||||
| java | ✓ | ✓ | ✓ | | `jdtls` |
|
| java | ✓ | ✓ | ✓ | | `jdtls` |
|
||||||
| javascript | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` |
|
| javascript | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` |
|
||||||
| jinja | ✓ | | | | |
|
| jinja | ✓ | | | | |
|
||||||
|
|
|
@ -29,7 +29,7 @@ use helix_view::{
|
||||||
graphics::{Color, CursorKind, Modifier, Rect, Style},
|
graphics::{Color, CursorKind, Modifier, Rect, Style},
|
||||||
input::{KeyEvent, MouseButton, MouseEvent, MouseEventKind},
|
input::{KeyEvent, MouseButton, MouseEvent, MouseEventKind},
|
||||||
keyboard::{KeyCode, KeyModifiers},
|
keyboard::{KeyCode, KeyModifiers},
|
||||||
Document, Editor, Theme, View,
|
Document, DocumentId, Editor, Theme, View,
|
||||||
};
|
};
|
||||||
use std::{mem::take, num::NonZeroUsize, ops, path::PathBuf, rc::Rc};
|
use std::{mem::take, num::NonZeroUsize, ops, path::PathBuf, rc::Rc};
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ pub struct EditorView {
|
||||||
pub(crate) last_insert: (commands::MappableCommand, Vec<InsertEvent>),
|
pub(crate) last_insert: (commands::MappableCommand, Vec<InsertEvent>),
|
||||||
pub(crate) completion: Option<Completion>,
|
pub(crate) completion: Option<Completion>,
|
||||||
spinners: ProgressSpinners,
|
spinners: ProgressSpinners,
|
||||||
|
bufferline_info: BufferLineInfo,
|
||||||
/// Tracks if the terminal window is focused by reaction to terminal focus events
|
/// Tracks if the terminal window is focused by reaction to terminal focus events
|
||||||
terminal_focused: bool,
|
terminal_focused: bool,
|
||||||
}
|
}
|
||||||
|
@ -66,6 +67,7 @@ impl EditorView {
|
||||||
last_insert: (commands::MappableCommand::normal_mode, Vec::new()),
|
last_insert: (commands::MappableCommand::normal_mode, Vec::new()),
|
||||||
completion: None,
|
completion: None,
|
||||||
spinners: ProgressSpinners::default(),
|
spinners: ProgressSpinners::default(),
|
||||||
|
bufferline_info: BufferLineInfo::default(),
|
||||||
terminal_focused: true,
|
terminal_focused: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -559,7 +561,7 @@ impl EditorView {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Render bufferline at the top
|
/// Render bufferline at the top
|
||||||
pub fn render_bufferline(editor: &Editor, viewport: Rect, surface: &mut Surface) {
|
pub fn render_bufferline(&mut self, editor: &Editor, viewport: Rect, surface: &mut Surface) {
|
||||||
let scratch = PathBuf::from(SCRATCH_BUFFER_NAME); // default filename to use for scratch buffer
|
let scratch = PathBuf::from(SCRATCH_BUFFER_NAME); // default filename to use for scratch buffer
|
||||||
surface.clear_with(
|
surface.clear_with(
|
||||||
viewport,
|
viewport,
|
||||||
|
@ -582,6 +584,8 @@ impl EditorView {
|
||||||
let mut x = viewport.x;
|
let mut x = viewport.x;
|
||||||
let current_doc = view!(editor).doc;
|
let current_doc = view!(editor).doc;
|
||||||
|
|
||||||
|
self.bufferline_info.clear();
|
||||||
|
|
||||||
for doc in editor.documents() {
|
for doc in editor.documents() {
|
||||||
let fname = doc
|
let fname = doc
|
||||||
.path()
|
.path()
|
||||||
|
@ -601,9 +605,14 @@ impl EditorView {
|
||||||
let used_width = viewport.x.saturating_sub(x);
|
let used_width = viewport.x.saturating_sub(x);
|
||||||
let rem_width = surface.area.width.saturating_sub(used_width);
|
let rem_width = surface.area.width.saturating_sub(used_width);
|
||||||
|
|
||||||
|
let start_x = x;
|
||||||
x = surface
|
x = surface
|
||||||
.set_stringn(x, viewport.y, text, rem_width as usize, style)
|
.set_stringn(x, viewport.y, text, rem_width as usize, style)
|
||||||
.0;
|
.0;
|
||||||
|
let end_x = x.min(surface.area.right());
|
||||||
|
|
||||||
|
self.bufferline_info
|
||||||
|
.add_buffer_info(doc.id(), start_x..end_x);
|
||||||
|
|
||||||
if x >= surface.area.right() {
|
if x >= surface.area.right() {
|
||||||
break;
|
break;
|
||||||
|
@ -1125,6 +1134,14 @@ impl EditorView {
|
||||||
MouseEventKind::Down(MouseButton::Left) => {
|
MouseEventKind::Down(MouseButton::Left) => {
|
||||||
let editor = &mut cxt.editor;
|
let editor = &mut cxt.editor;
|
||||||
|
|
||||||
|
if is_bufferline_visible(editor) && row == 0 {
|
||||||
|
if let Some(buffer_info) = self.bufferline_info.get_clicked_buffer(column) {
|
||||||
|
editor.switch(buffer_info.document_id, helix_view::editor::Action::Replace);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EventResult::Consumed(None);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some((pos, view_id)) = pos_and_view(editor, row, column, true) {
|
if let Some((pos, view_id)) = pos_and_view(editor, row, column, true) {
|
||||||
let prev_view_id = view!(editor).id;
|
let prev_view_id = view!(editor).id;
|
||||||
let doc = doc_mut!(editor, &view!(editor, view_id).doc);
|
let doc = doc_mut!(editor, &view!(editor, view_id).doc);
|
||||||
|
@ -1493,13 +1510,7 @@ impl Component for EditorView {
|
||||||
surface.set_style(area, cx.editor.theme.get("ui.background"));
|
surface.set_style(area, cx.editor.theme.get("ui.background"));
|
||||||
let config = cx.editor.config();
|
let config = cx.editor.config();
|
||||||
|
|
||||||
// check if bufferline should be rendered
|
let use_bufferline = is_bufferline_visible(cx.editor);
|
||||||
use helix_view::editor::BufferLine;
|
|
||||||
let use_bufferline = match config.bufferline {
|
|
||||||
BufferLine::Always => true,
|
|
||||||
BufferLine::Multiple if cx.editor.documents.len() > 1 => true,
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
|
|
||||||
// -1 for commandline and -1 for bufferline
|
// -1 for commandline and -1 for bufferline
|
||||||
let mut editor_area = area.clip_bottom(1);
|
let mut editor_area = area.clip_bottom(1);
|
||||||
|
@ -1511,7 +1522,7 @@ impl Component for EditorView {
|
||||||
cx.editor.resize(editor_area);
|
cx.editor.resize(editor_area);
|
||||||
|
|
||||||
if use_bufferline {
|
if use_bufferline {
|
||||||
Self::render_bufferline(cx.editor, area.with_height(1), surface);
|
self.render_bufferline(cx.editor, area.with_height(1), surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (view, is_focused) in cx.editor.tree.views() {
|
for (view, is_focused) in cx.editor.tree.views() {
|
||||||
|
@ -1606,6 +1617,48 @@ impl Component for EditorView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
struct BufferLineInfo {
|
||||||
|
visible_buffers: Vec<BufferInfo>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BufferLineInfo {
|
||||||
|
fn clear(&mut self) {
|
||||||
|
self.visible_buffers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_buffer_info(&mut self, document_id: DocumentId, columns: std::ops::Range<u16>) {
|
||||||
|
self.visible_buffers.push(BufferInfo {
|
||||||
|
document_id,
|
||||||
|
columns,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_clicked_buffer(&self, column: u16) -> Option<&BufferInfo> {
|
||||||
|
self.visible_buffers
|
||||||
|
.iter()
|
||||||
|
.find(|cell| cell.columns.contains(&column))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct BufferInfo {
|
||||||
|
document_id: DocumentId,
|
||||||
|
// The bufferline column span used to show the document name
|
||||||
|
columns: std::ops::Range<u16>,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_bufferline_visible(editor: &Editor) -> bool {
|
||||||
|
use helix_view::editor::BufferLine;
|
||||||
|
let config = editor.config();
|
||||||
|
|
||||||
|
match config.bufferline {
|
||||||
|
BufferLine::Always => true,
|
||||||
|
BufferLine::Multiple => editor.documents.len() > 1,
|
||||||
|
BufferLine::Never => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn canonicalize_key(key: &mut KeyEvent) {
|
fn canonicalize_key(key: &mut KeyEvent) {
|
||||||
if let KeyEvent {
|
if let KeyEvent {
|
||||||
code: KeyCode::Char(_),
|
code: KeyCode::Char(_),
|
||||||
|
|
|
@ -356,7 +356,7 @@ fn directory_content(path: &Path) -> Result<Vec<(PathBuf, bool)>, std::io::Error
|
||||||
.map(|entry| {
|
.map(|entry| {
|
||||||
(
|
(
|
||||||
entry.path(),
|
entry.path(),
|
||||||
entry.file_type().is_ok_and(|file_type| file_type.is_dir()),
|
std::fs::metadata(entry.path()).is_ok_and(|metadata| metadata.is_dir()),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
@ -65,6 +65,7 @@ julia = { command = "julia", timeout = 60, args = [ "--startup-file=no", "--hist
|
||||||
just-lsp = { command = "just-lsp" }
|
just-lsp = { command = "just-lsp" }
|
||||||
koka = { command = "koka", args = ["--language-server", "--lsstdio"] }
|
koka = { command = "koka", args = ["--language-server", "--lsstdio"] }
|
||||||
koto-ls = { command = "koto-ls" }
|
koto-ls = { command = "koto-ls" }
|
||||||
|
kotlin-lsp = { command = "kotlin-lsp", args = ["--stdio"] }
|
||||||
kotlin-language-server = { command = "kotlin-language-server" }
|
kotlin-language-server = { command = "kotlin-language-server" }
|
||||||
lean = { command = "lean", args = [ "--server", "--memory=1024" ] }
|
lean = { command = "lean", args = [ "--server", "--memory=1024" ] }
|
||||||
ltex-ls = { command = "ltex-ls" }
|
ltex-ls = { command = "ltex-ls" }
|
||||||
|
@ -1021,6 +1022,7 @@ shebangs = []
|
||||||
comment-token = "#"
|
comment-token = "#"
|
||||||
language-servers = [ "nil", "nixd" ]
|
language-servers = [ "nil", "nixd" ]
|
||||||
indent = { tab-width = 2, unit = " " }
|
indent = { tab-width = 2, unit = " " }
|
||||||
|
formatter = { command = "nixfmt" }
|
||||||
|
|
||||||
[[grammar]]
|
[[grammar]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
|
@ -3068,7 +3070,7 @@ formatter = { command = "inko", args = ["fmt", "-"] }
|
||||||
|
|
||||||
[[grammar]]
|
[[grammar]]
|
||||||
name = "inko"
|
name = "inko"
|
||||||
source = { git = "https://github.com/inko-lang/tree-sitter-inko", rev = "7860637ce1b43f5f79cfb7cc3311bf3234e9479f" }
|
source = { git = "https://github.com/inko-lang/tree-sitter-inko", rev = "f58a87ac4dc6a7955c64c9e4408fbd693e804686" }
|
||||||
|
|
||||||
[[language]]
|
[[language]]
|
||||||
name = "bicep"
|
name = "bicep"
|
||||||
|
@ -4242,10 +4244,11 @@ comment-token = "#"
|
||||||
block-comment-tokens = ["#-", "-#"]
|
block-comment-tokens = ["#-", "-#"]
|
||||||
indent = { tab-width = 2, unit = " " }
|
indent = { tab-width = 2, unit = " " }
|
||||||
language-servers = ["koto-ls"]
|
language-servers = ["koto-ls"]
|
||||||
|
formatter = {command = "koto", args = ["--format"]}
|
||||||
|
|
||||||
[[grammar]]
|
[[grammar]]
|
||||||
name = "koto"
|
name = "koto"
|
||||||
source = { git = "https://github.com/koto-lang/tree-sitter-koto", rev = "b420f7922d0d74905fd0d771e5b83be9ee8a8a9a" }
|
source = { git = "https://github.com/koto-lang/tree-sitter-koto", rev = "2ffc77c14f0ac1674384ff629bfc207b9c57ed89" }
|
||||||
|
|
||||||
[[language]]
|
[[language]]
|
||||||
name = "gpr"
|
name = "gpr"
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
] @keyword.operator
|
] @keyword.operator
|
||||||
|
|
||||||
[
|
[
|
||||||
"class"
|
"type"
|
||||||
"trait"
|
"trait"
|
||||||
] @keyword.storage.type
|
] @keyword.storage.type
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
(class
|
||||||
|
name: _ @definition.struct)
|
||||||
|
|
||||||
|
(trait
|
||||||
|
name: _ @definition.interface)
|
||||||
|
|
||||||
|
(external_function
|
||||||
|
name: _ @definition.function)
|
||||||
|
|
||||||
|
(method
|
||||||
|
name: _ @definition.function)
|
||||||
|
|
||||||
|
(define_constant
|
||||||
|
name: _ @definition.constant)
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,28 @@
|
||||||
|
; aligns forms to the second position if there's two in a line:
|
||||||
|
; (-> 10
|
||||||
|
; (* 2)
|
||||||
|
; (print))
|
||||||
|
(par_tup_lit . (sym_lit) @first . (_) @anchor
|
||||||
|
(#set! "scope" "tail")
|
||||||
|
(#same-line? @first @anchor)
|
||||||
|
; anything that doesn't match should be indented normally
|
||||||
|
; from https://github.com/janet-lang/spork/blob/5601dc883535473bca28351cc6df04ed6c656c65/spork/fmt.janet#L87C12-L93C38
|
||||||
|
(#not-match? @first "^(fn|match|with|with-dyns|def|def-|var|var-|defn|defn-|varfn|defmacro|defmacro-|defer|edefer|loop|seq|tabseq|catseq|generate|coro|for|each|eachp|eachk|case|cond|do|defglobal|varglobal|if|when|when-let|when-with|while|with-syms|with-vars|if-let|if-not|if-with|let|short-fn|try|unless|default|forever|upscope|repeat|forv|compwhen|compif|ev/spawn|ev/do-thread|ev/spawn-thread|ev/with-deadline|label|prompt|forever)$")) @align
|
||||||
|
|
||||||
|
; everything else should be indented normally:
|
||||||
|
;
|
||||||
|
; (let [foo 10]
|
||||||
|
; (print foo))
|
||||||
|
;
|
||||||
|
; (foo
|
||||||
|
; bar)
|
||||||
|
(par_tup_lit . (sym_lit)) @indent
|
||||||
|
|
||||||
|
; for `{}` and `[]`:
|
||||||
|
; {:foo 10
|
||||||
|
; :bar 20}
|
||||||
|
(struct_lit . (_) @anchor) @align
|
||||||
|
|
||||||
|
; [foo
|
||||||
|
; bar]
|
||||||
|
(sqr_tup_lit . (_) @anchor) @align
|
|
@ -0,0 +1,2 @@
|
||||||
|
((comment) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
|
@ -5,11 +5,13 @@
|
||||||
"*"
|
"*"
|
||||||
"/"
|
"/"
|
||||||
"%"
|
"%"
|
||||||
|
"^"
|
||||||
"+="
|
"+="
|
||||||
"-="
|
"-="
|
||||||
"*="
|
"*="
|
||||||
"/="
|
"/="
|
||||||
"%="
|
"%="
|
||||||
|
"^="
|
||||||
"=="
|
"=="
|
||||||
"!="
|
"!="
|
||||||
"<"
|
"<"
|
||||||
|
@ -99,12 +101,18 @@
|
||||||
(export
|
(export
|
||||||
(identifier) @namespace)
|
(identifier) @namespace)
|
||||||
|
|
||||||
(call
|
(chain
|
||||||
function: (identifier) @function.method)
|
start: (identifier) @function)
|
||||||
|
|
||||||
(chain
|
(chain
|
||||||
lookup: (identifier) @variable.other.member)
|
lookup: (identifier) @variable.other.member)
|
||||||
|
|
||||||
|
(call
|
||||||
|
function: (identifier)) @function
|
||||||
|
|
||||||
|
(call_arg
|
||||||
|
(identifier) @variable.other.member)
|
||||||
|
|
||||||
[
|
[
|
||||||
(true)
|
(true)
|
||||||
(false)
|
(false)
|
||||||
|
@ -139,13 +147,10 @@
|
||||||
|
|
||||||
(self) @variable.builtin
|
(self) @variable.builtin
|
||||||
|
|
||||||
(variable
|
(type
|
||||||
type: (identifier) @type)
|
_ @type)
|
||||||
|
|
||||||
(arg
|
(arg
|
||||||
(_ (identifier) @variable.parameter))
|
(_ (identifier) @variable.parameter))
|
||||||
|
|
||||||
(ellipsis) @variable.parameter
|
(ellipsis) @variable.parameter
|
||||||
|
|
||||||
(function
|
|
||||||
output_type: (identifier) @type)
|
|
||||||
|
|
|
@ -11,10 +11,6 @@
|
||||||
(call_args
|
(call_args
|
||||||
((call_arg) @parameter.inside . ","? @parameter.around) @parameter.around)
|
((call_arg) @parameter.inside . ","? @parameter.around) @parameter.around)
|
||||||
|
|
||||||
(chain
|
|
||||||
call: (tuple
|
|
||||||
((element) @parameter.inside . ","? @parameter.around) @parameter.around))
|
|
||||||
|
|
||||||
(map
|
(map
|
||||||
((entry_inline) @entry.inside . ","? @entry.around) @entry.around)
|
((entry_inline) @entry.inside . ","? @entry.around) @entry.around)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue