Compare commits

...

5 Commits

Author SHA1 Message Date
Ayyan d3667cc04c
Merge 4855426278 into 395a71bf53 2025-07-24 09:57:21 +05:30
kiara 395a71bf53
languages: nix formatter (#14046) 2025-07-23 12:51:17 -04:00
Ian Hobson 1e4bf6704a
Update Koto grammar and queries, add formatter (#14049) 2025-07-23 12:47:47 -04:00
Ayyan 4855426278
Merge branch 'helix-editor:master' into bufferline_sep 2025-03-18 16:40:43 -04:00
ayn2op 1958efb9e6 feat: render bufferline separator
Closes #11372
2024-09-16 00:20:50 +05:30
5 changed files with 62 additions and 33 deletions

View File

@ -582,7 +582,7 @@ impl EditorView {
let mut x = viewport.x; let mut x = viewport.x;
let current_doc = view!(editor).doc; let current_doc = view!(editor).doc;
for doc in editor.documents() { for (idx, doc) in editor.documents().enumerate() {
let fname = doc let fname = doc
.path() .path()
.unwrap_or(&scratch) .unwrap_or(&scratch)
@ -597,6 +597,16 @@ impl EditorView {
bufferline_inactive bufferline_inactive
}; };
// Render the separator before the text if the current document is not first.
if idx > 0 {
let used_width = viewport.x.saturating_sub(x);
let rem_width = surface.area.width.saturating_sub(used_width);
let sep = &editor.config().bufferline.separator;
x = surface
.set_stringn(x, viewport.y, sep, rem_width as usize, bufferline_inactive)
.0;
}
let text = format!(" {}{} ", fname, if doc.is_modified() { "[+]" } else { "" }); let text = format!(" {}{} ", fname, if doc.is_modified() { "[+]" } else { "" });
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);
@ -1494,10 +1504,10 @@ impl Component for EditorView {
let config = cx.editor.config(); let config = cx.editor.config();
// check if bufferline should be rendered // check if bufferline should be rendered
use helix_view::editor::BufferLine; use helix_view::editor::BufferLineRenderMode;
let use_bufferline = match config.bufferline { let use_bufferline = match config.bufferline.render_mode {
BufferLine::Always => true, BufferLineRenderMode::Always => true,
BufferLine::Multiple if cx.editor.documents.len() > 1 => true, BufferLineRenderMode::Multiple if cx.editor.documents.len() > 1 => true,
_ => false, _ => false,
}; };

View File

@ -318,6 +318,8 @@ pub struct Config {
/// Whether to display infoboxes. Defaults to true. /// Whether to display infoboxes. Defaults to true.
pub auto_info: bool, pub auto_info: bool,
pub file_picker: FilePickerConfig, pub file_picker: FilePickerConfig,
/// Configuration of the bufferline
pub bufferline: BufferLineConfig,
/// Configuration of the statusline elements /// Configuration of the statusline elements
pub statusline: StatusLineConfig, pub statusline: StatusLineConfig,
/// Shape for cursor in each mode /// Shape for cursor in each mode
@ -335,8 +337,6 @@ pub struct Config {
pub rulers: Vec<u16>, pub rulers: Vec<u16>,
#[serde(default)] #[serde(default)]
pub whitespace: WhitespaceConfig, pub whitespace: WhitespaceConfig,
/// Persistently display open buffers along the top
pub bufferline: BufferLine,
/// Vertical indent width guides. /// Vertical indent width guides.
pub indent_guides: IndentGuidesConfig, pub indent_guides: IndentGuidesConfig,
/// Whether to color modes with different colors. Defaults to `false`. /// Whether to color modes with different colors. Defaults to `false`.
@ -502,6 +502,35 @@ pub struct SearchConfig {
pub wrap_around: bool, pub wrap_around: bool,
} }
/// bufferline render modes
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum BufferLineRenderMode {
/// Don't render bufferline
#[default]
Never,
/// Always render
Always,
/// Only if multiple buffers are open
Multiple,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct BufferLineConfig {
pub render_mode: BufferLineRenderMode,
pub separator: String,
}
impl Default for BufferLineConfig {
fn default() -> Self {
Self {
render_mode: BufferLineRenderMode::default(),
separator: String::from(""),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)] #[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
pub struct StatusLineConfig { pub struct StatusLineConfig {
@ -684,19 +713,6 @@ impl Default for CursorShapeConfig {
} }
} }
/// bufferline render modes
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum BufferLine {
/// Don't render bufferline
#[default]
Never,
/// Always render
Always,
/// Only if multiple buffers are open
Multiple,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub enum LineNumber { pub enum LineNumber {
@ -1022,6 +1038,7 @@ impl Default for Config {
completion_trigger_len: 2, completion_trigger_len: 2,
auto_info: true, auto_info: true,
file_picker: FilePickerConfig::default(), file_picker: FilePickerConfig::default(),
bufferline: BufferLineConfig::default(),
statusline: StatusLineConfig::default(), statusline: StatusLineConfig::default(),
cursor_shape: CursorShapeConfig::default(), cursor_shape: CursorShapeConfig::default(),
true_color: false, true_color: false,
@ -1031,7 +1048,6 @@ impl Default for Config {
terminal: get_terminal_provider(), terminal: get_terminal_provider(),
rulers: Vec::new(), rulers: Vec::new(),
whitespace: WhitespaceConfig::default(), whitespace: WhitespaceConfig::default(),
bufferline: BufferLine::default(),
indent_guides: IndentGuidesConfig::default(), indent_guides: IndentGuidesConfig::default(),
color_modes: false, color_modes: false,
soft_wrap: SoftWrap { soft_wrap: SoftWrap {

View File

@ -1022,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"
@ -4243,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"

View File

@ -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)

View File

@ -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)