aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules4
m---------helix-syntax/languages/tree-sitter-elixir0
-rw-r--r--helix-syntax/src/lib.rs1
-rw-r--r--helix-term/src/compositor.rs2
-rw-r--r--helix-term/src/main.rs22
-rw-r--r--helix-tui/src/terminal.rs8
-rw-r--r--languages.toml9
-rw-r--r--runtime/queries/elixir/highlights.scm146
8 files changed, 177 insertions, 15 deletions
diff --git a/.gitmodules b/.gitmodules
index f4d6456c..a90766d4 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -82,3 +82,7 @@
path = helix-syntax/languages/tree-sitter-toml
url = https://github.com/ikatyang/tree-sitter-toml
shallow = true
+[submodule "helix-syntax/languages/tree-sitter-elixir"]
+ path = helix-syntax/languages/tree-sitter-elixir
+ url = https://github.com/IceDragon200/tree-sitter-elixir
+ shallow = true
diff --git a/helix-syntax/languages/tree-sitter-elixir b/helix-syntax/languages/tree-sitter-elixir
new file mode 160000
+Subproject 295e62a43b92cea909cfabe57e8818d177f4857
diff --git a/helix-syntax/src/lib.rs b/helix-syntax/src/lib.rs
index 79c1c1f5..bb0b2ec6 100644
--- a/helix-syntax/src/lib.rs
+++ b/helix-syntax/src/lib.rs
@@ -72,6 +72,7 @@ mk_langs!(
(CSharp, tree_sitter_c_sharp),
(Cpp, tree_sitter_cpp),
(Css, tree_sitter_css),
+ (Elixir, tree_sitter_elixir),
(Go, tree_sitter_go),
// (Haskell, tree_sitter_haskell),
(Html, tree_sitter_html),
diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs
index 3a17904d..7753e0a5 100644
--- a/helix-term/src/compositor.rs
+++ b/helix-term/src/compositor.rs
@@ -122,7 +122,9 @@ impl Compositor {
}
pub fn render(&mut self, cx: &mut Context) {
+ self.terminal.autoresize().unwrap();
let area = self.size();
+
let surface = self.terminal.current_buffer_mut();
for layer in &self.layers {
diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs
index e3304312..da03569d 100644
--- a/helix-term/src/main.rs
+++ b/helix-term/src/main.rs
@@ -8,6 +8,8 @@ mod ui;
use application::Application;
+use helix_core::config_dir;
+
use std::path::PathBuf;
use anyhow::{Context, Result};
@@ -27,8 +29,6 @@ fn setup_logging(verbosity: u64) -> Result<()> {
_3_or_more => base_config.level(log::LevelFilter::Trace),
};
- let home = dirs_next::home_dir().context("can't find the home directory")?;
-
// Separate file config so we can include year, month and day in file logs
let file_config = fern::Dispatch::new()
.format(|out, message, record| {
@@ -40,7 +40,7 @@ fn setup_logging(verbosity: u64) -> Result<()> {
message
))
})
- .chain(fern::log_file(home.join("helix.log"))?);
+ .chain(fern::log_file(config_dir().join("helix.log"))?);
base_config.chain(file_config).apply()?;
@@ -51,7 +51,8 @@ pub struct Args {
files: Vec<PathBuf>,
}
-fn main() -> Result<()> {
+#[tokio::main]
+async fn main() -> Result<()> {
let help = format!(
"\
{} {}
@@ -89,6 +90,12 @@ FLAGS:
verbosity = 1;
}
+ let conf_dir = config_dir();
+
+ if !conf_dir.exists() {
+ std::fs::create_dir(&conf_dir);
+ }
+
setup_logging(verbosity).context("failed to initialize logging")?;
let args = Args {
@@ -96,7 +103,6 @@ FLAGS:
};
// initialize language registry
- use helix_core::config_dir;
use helix_core::syntax::{Loader, LOADER};
// load $HOME/.config/helix/languages.toml, fallback to default config
@@ -108,13 +114,9 @@ FLAGS:
let config = toml::from_slice(toml).context("Could not parse languages.toml")?;
LOADER.get_or_init(|| Loader::new(config));
- let runtime = tokio::runtime::Runtime::new().context("unable to start tokio runtime")?;
-
// TODO: use the thread local executor to spawn the application task separately from the work pool
let mut app = Application::new(args).context("unable to create new appliction")?;
- runtime.block_on(async move {
- app.run().await;
- });
+ app.run().await;
Ok(())
}
diff --git a/helix-tui/src/terminal.rs b/helix-tui/src/terminal.rs
index 7346d66d..1a0cae3e 100644
--- a/helix-tui/src/terminal.rs
+++ b/helix-tui/src/terminal.rs
@@ -138,11 +138,9 @@ where
/// Queries the backend for size and resizes if it doesn't match the previous size.
pub fn autoresize(&mut self) -> io::Result<()> {
- if self.viewport.resize_behavior == ResizeBehavior::Auto {
- let size = self.size()?;
- if size != self.viewport.area {
- self.resize(size)?;
- }
+ let size = self.size()?;
+ if size != self.viewport.area {
+ self.resize(size)?;
};
Ok(())
}
diff --git a/languages.toml b/languages.toml
index 87f03d06..6b80763f 100644
--- a/languages.toml
+++ b/languages.toml
@@ -18,6 +18,15 @@ roots = []
indent = { tab-width = 2, unit = " " }
[[language]]
+name = "elixir"
+scope = "source.elixir"
+injection-regex = "elixir"
+file-types = ["ex", "exs"]
+roots = []
+
+indent = { tab-width = 2, unit = " " }
+
+[[language]]
name = "json"
scope = "source.json"
injection-regex = "json"
diff --git a/runtime/queries/elixir/highlights.scm b/runtime/queries/elixir/highlights.scm
new file mode 100644
index 00000000..b9ec0210
--- /dev/null
+++ b/runtime/queries/elixir/highlights.scm
@@ -0,0 +1,146 @@
+["when" "and" "or" "not in" "not" "in" "fn" "do" "end" "catch" "rescue" "after" "else"] @keyword
+
+[(true) (false) (nil)] @constant.builtin
+
+(keyword
+ [(keyword_literal)
+ ":"] @tag)
+
+(keyword
+ (keyword_string
+ [(string_start)
+ (string_content)
+ (string_end)] @tag))
+
+[(atom_literal)
+ (atom_start)
+ (atom_content)
+ (atom_end)] @tag
+
+(comment) @comment
+
+(escape_sequence) @escape
+
+(call function: (function_identifier) @keyword
+ (#match? @keyword "^(defmodule|defexception|defp|def|with|case|cond|raise|import|require|use|defmacrop|defmacro|defguardp|defguard|defdelegate|defstruct|alias|defimpl|defprotocol|defoverridable|receive|if|for|try|throw|unless|reraise|super|quote|unquote|unquote_splicing)$"))
+
+(call function: (function_identifier) @keyword
+ [(call
+ function: (function_identifier) @function
+ (arguments
+ [(identifier) @variable.parameter
+ (_ (identifier) @variable.parameter)
+ (_ (_ (identifier) @variable.parameter))
+ (_ (_ (_ (identifier) @variable.parameter)))
+ (_ (_ (_ (_ (identifier) @variable.parameter))))
+ (_ (_ (_ (_ (_ (identifier) @variable.parameter)))))]))
+ (binary_op
+ left:
+ (call
+ function: (function_identifier) @function
+ (arguments
+ [(identifier) @variable.parameter
+ (_ (identifier) @variable.parameter)
+ (_ (_ (identifier) @variable.parameter))
+ (_ (_ (_ (identifier) @variable.parameter)))
+ (_ (_ (_ (_ (identifier) @variable.parameter))))
+ (_ (_ (_ (_ (_ (identifier) @variable.parameter)))))]))
+ operator: "when")
+ (binary_op
+ left: (identifier) @variable.parameter
+ operator: _ @function
+ right: (identifier) @variable.parameter)]
+ (#match? @keyword "^(defp|def|defmacrop|defmacro|defguardp|defguard|defdelegate)$")
+ (#match? @variable.parameter "^[^_]"))
+
+(call (function_identifier) @keyword
+ [(call
+ function: (function_identifier) @function)
+ (identifier) @function
+ (binary_op
+ left:
+ [(call
+ function: (function_identifier) @function)
+ (identifier) @function]
+ operator: "when")]
+ (#match? @keyword "^(defp|def|defmacrop|defmacro|defguardp|defguard|defdelegate)$"))
+
+(anonymous_function
+ (stab_expression
+ left: (bare_arguments
+ [(identifier) @variable.parameter
+ (_ (identifier) @variable.parameter)
+ (_ (_ (identifier) @variable.parameter))
+ (_ (_ (_ (identifier) @variable.parameter)))
+ (_ (_ (_ (_ (identifier) @variable.parameter))))
+ (_ (_ (_ (_ (_ (identifier) @variable.parameter)))))]))
+ (#match? @variable.parameter "^[^_]"))
+
+(unary_op
+ operator: "@"
+ (call (identifier) @attribute
+ (heredoc
+ [(heredoc_start)
+ (heredoc_content)
+ (heredoc_end)] @doc))
+ (#match? @attribute "^(doc|moduledoc)$"))
+
+(module) @type
+
+(unary_op
+ operator: "@" @attribute
+ [(call
+ function: (function_identifier) @attribute)
+ (identifier) @attribute])
+
+(unary_op
+ operator: _ @operator)
+
+(binary_op
+ operator: _ @operator)
+
+(heredoc
+ [(heredoc_start)
+ (heredoc_content)
+ (heredoc_end)] @string)
+
+(string
+ [(string_start)
+ (string_content)
+ (string_end)] @string)
+
+(sigil_start) @string.special
+(sigil_content) @string
+(sigil_end) @string.special
+
+(interpolation
+ "#{" @punctuation.special
+ "}" @punctuation.special)
+
+[
+ ","
+ "->"
+ "."
+] @punctuation.delimiter
+
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+ "<<"
+ ">>"
+] @punctuation.bracket
+
+[(identifier) @function.special
+ (#match? @function.special "^__.+__$")]
+
+[(remote_identifier) @function.special
+ (#match? @function.special "^__.+__$")]
+
+[(identifier) @comment
+ (#match? @comment "^_")]
+
+(ERROR) @warning