Compare commits

...

9 Commits

Author SHA1 Message Date
Tom Schafer 80c87d794b
Merge 3a30eb5a84 into 395a71bf53 2025-07-24 09:48:05 +02:00
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
Alexander Meinhardt Scheurer-Volkmann b01fbb4a22
Fix symlink directories in file explorer (#14028) 2025-07-21 14:10:06 -04:00
MrWheatley f75a26cb9b
added janet indents (#14020) 2025-07-21 14:07:11 -04:00
MrWheatley 21ae1c98fb
fix janet highlights (#14017) 2025-07-21 14:00:21 -04:00
Fea 7b8a4b7a51
feat: Add `kotlin-lsp` to `languages.toml` (#14021) 2025-07-21 14:00:08 -04:00
Yorick Peterse 715d4ae2d5
tree-sitter: update Inko grammar and queries (#14022) 2025-07-21 13:51:50 -04:00
Thomas Schafer 3a30eb5a84
Add absolute file path command expansion value 2025-02-28 13:19:38 +00:00
12 changed files with 86 additions and 21 deletions

View File

@ -46,6 +46,7 @@ The following variables are supported:
| `cursor_line` | The line number of the primary cursor in the currently focused document, starting at 1. | | `cursor_line` | The line number of the primary cursor in the currently focused document, starting at 1. |
| `cursor_column` | The column number of the primary cursor in the currently focused document, starting at 1. This is counted as the number of grapheme clusters from the start of the line rather than bytes or codepoints. | | `cursor_column` | The column number of the primary cursor in the currently focused document, starting at 1. This is counted as the number of grapheme clusters from the start of the line rather than bytes or codepoints. |
| `buffer_name` | The relative path of the currently focused document. `[scratch]` is expanded instead for scratch buffers. | | `buffer_name` | The relative path of the currently focused document. `[scratch]` is expanded instead for scratch buffers. |
| `file_path_absolute` | The absolute path of the currently focused document. For scratch buffers this will default to the current working directory. |
| `line_ending` | A string containing the line ending of the currently focused document. For example on Unix systems this is usually a line-feed character (`\n`) but on Windows systems this may be a carriage-return plus a line-feed (`\r\n`). The line ending kind of the currently focused document can be inspected with the `:line-ending` command. | | `line_ending` | A string containing the line ending of the currently focused document. For example on Unix systems this is usually a line-feed character (`\n`) but on Windows systems this may be a carriage-return plus a line-feed (`\r\n`). The line ending kind of the currently focused document can be inspected with the `:line-ending` command. |
| `language` | A string containing the language name of the currently focused document.| | `language` | A string containing the language name of the currently focused document.|
| `selection` | A string containing the contents of the primary selection of the currently focused document. | | `selection` | A string containing the contents of the primary selection of the currently focused document. |

View File

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

View File

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

View File

@ -31,6 +31,9 @@ pub enum Variable {
/// ///
/// This corresponds to `crate::Document::display_name`. /// This corresponds to `crate::Document::display_name`.
BufferName, BufferName,
/// The absolute path of the currently focused document. For scratch buffers this will default
/// to the current working directory.
FilePathAbsolute,
/// A string containing the line-ending of the currently focused document. /// A string containing the line-ending of the currently focused document.
LineEnding, LineEnding,
// The name of current buffers language as set in `languages.toml` // The name of current buffers language as set in `languages.toml`
@ -48,6 +51,7 @@ impl Variable {
Self::CursorLine, Self::CursorLine,
Self::CursorColumn, Self::CursorColumn,
Self::BufferName, Self::BufferName,
Self::FilePathAbsolute,
Self::LineEnding, Self::LineEnding,
Self::Language, Self::Language,
Self::Selection, Self::Selection,
@ -60,6 +64,7 @@ impl Variable {
Self::CursorLine => "cursor_line", Self::CursorLine => "cursor_line",
Self::CursorColumn => "cursor_column", Self::CursorColumn => "cursor_column",
Self::BufferName => "buffer_name", Self::BufferName => "buffer_name",
Self::FilePathAbsolute => "file_path_absolute",
Self::LineEnding => "line_ending", Self::LineEnding => "line_ending",
Self::Language => "language", Self::Language => "language",
Self::Selection => "selection", Self::Selection => "selection",
@ -73,6 +78,7 @@ impl Variable {
"cursor_line" => Some(Self::CursorLine), "cursor_line" => Some(Self::CursorLine),
"cursor_column" => Some(Self::CursorColumn), "cursor_column" => Some(Self::CursorColumn),
"buffer_name" => Some(Self::BufferName), "buffer_name" => Some(Self::BufferName),
"file_path_absolute" => Some(Self::FilePathAbsolute),
"line_ending" => Some(Self::LineEnding), "line_ending" => Some(Self::LineEnding),
"language" => Some(Self::Language), "language" => Some(Self::Language),
"selection" => Some(Self::Selection), "selection" => Some(Self::Selection),
@ -234,6 +240,15 @@ fn expand_variable(editor: &Editor, variable: Variable) -> Result<Cow<'static, s
Ok(Cow::Borrowed(crate::document::SCRATCH_BUFFER_NAME)) Ok(Cow::Borrowed(crate::document::SCRATCH_BUFFER_NAME))
} }
} }
Variable::FilePathAbsolute => {
let path = match doc.path() {
Some(path) => path.to_owned(),
None => helix_stdx::env::current_working_dir(),
}
.to_string_lossy()
.to_string();
Ok(Cow::Owned(path))
}
Variable::LineEnding => Ok(Cow::Borrowed(doc.line_ending.as_str())), Variable::LineEnding => Ok(Cow::Borrowed(doc.line_ending.as_str())),
Variable::Language => Ok(match doc.language_name() { Variable::Language => Ok(match doc.language_name() {
Some(lang) => Cow::Owned(lang.to_owned()), Some(lang) => Cow::Owned(lang.to_owned()),

View File

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

View File

@ -78,7 +78,7 @@
] @keyword.operator ] @keyword.operator
[ [
"class" "type"
"trait" "trait"
] @keyword.storage.type ] @keyword.storage.type

View File

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

View File

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

View File

@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))

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)