Detailed changes
@@ -7989,6 +7989,16 @@ dependencies = [
"tree-sitter",
]
+[[package]]
+name = "tree-sitter-elm"
+version = "5.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ec83a2e1cfc69d03c8e73636e95662d6c6728539538d341b21251a77039fb94e"
+dependencies = [
+ "cc",
+ "tree-sitter",
+]
+
[[package]]
name = "tree-sitter-embedded-template"
version = "0.20.0"
@@ -7999,6 +8009,15 @@ dependencies = [
"tree-sitter",
]
+[[package]]
+name = "tree-sitter-glsl"
+version = "0.1.4"
+source = "git+https://github.com/theHamsta/tree-sitter-glsl?rev=2a56fb7bc8bb03a1892b4741279dd0a8758b7fb3#2a56fb7bc8bb03a1892b4741279dd0a8758b7fb3"
+dependencies = [
+ "cc",
+ "tree-sitter",
+]
+
[[package]]
name = "tree-sitter-go"
version = "0.19.1"
@@ -9552,7 +9571,9 @@ dependencies = [
"tree-sitter-cpp",
"tree-sitter-css",
"tree-sitter-elixir",
+ "tree-sitter-elm",
"tree-sitter-embedded-template",
+ "tree-sitter-glsl",
"tree-sitter-go",
"tree-sitter-heex",
"tree-sitter-html",
@@ -112,7 +112,9 @@ tree-sitter-c = "0.20.1"
tree-sitter-cpp = "0.20.0"
tree-sitter-css = { git = "https://github.com/tree-sitter/tree-sitter-css", rev = "769203d0f9abe1a9a691ac2b9fe4bb4397a73c51" }
tree-sitter-elixir = { git = "https://github.com/elixir-lang/tree-sitter-elixir", rev = "4ba9dab6e2602960d95b2b625f3386c27e08084e" }
+tree-sitter-elm = "5.6.4"
tree-sitter-embedded-template = "0.20.0"
+tree-sitter-glsl = { git = "https://github.com/theHamsta/tree-sitter-glsl", rev = "2a56fb7bc8bb03a1892b4741279dd0a8758b7fb3" }
tree-sitter-go = { git = "https://github.com/tree-sitter/tree-sitter-go", rev = "aeb2f33b366fd78d5789ff104956ce23508b85db" }
tree-sitter-heex = { git = "https://github.com/phoenixframework/tree-sitter-heex", rev = "2e1348c3cf2c9323e87c2744796cf3f3868aa82a" }
tree-sitter-json = { git = "https://github.com/tree-sitter/tree-sitter-json", rev = "40a81c01a40ac48744e0c8ccabbaba1920441199" }
@@ -528,6 +528,8 @@
"cmd-alt-c": "project_panel::CopyPath",
"alt-cmd-shift-c": "project_panel::CopyRelativePath",
"f2": "project_panel::Rename",
+ "enter": "project_panel::Rename",
+ "space": "project_panel::Open",
"backspace": "project_panel::Delete",
"alt-cmd-r": "project_panel::RevealInFinder",
"alt-shift-f": "project_panel::NewSearchInDirectory"
@@ -1,6 +1,6 @@
use anyhow::Result;
use collections::HashMap;
-use git2::{BranchType, ErrorCode};
+use git2::{BranchType, StatusShow};
use parking_lot::Mutex;
use rpc::proto;
use serde_derive::{Deserialize, Serialize};
@@ -10,6 +10,7 @@ use std::{
os::unix::prelude::OsStrExt,
path::{Component, Path, PathBuf},
sync::Arc,
+ time::SystemTime,
};
use sum_tree::{MapSeekTarget, TreeMap};
use util::ResultExt;
@@ -27,8 +28,25 @@ pub trait GitRepository: Send {
fn reload_index(&self);
fn load_index_text(&self, relative_file_path: &Path) -> Option<String>;
fn branch_name(&self) -> Option<String>;
- fn statuses(&self) -> TreeMap<RepoPath, GitFileStatus>;
- fn status(&self, path: &RepoPath) -> Result<Option<GitFileStatus>>;
+
+ /// Get the statuses of all of the files in the index that start with the given
+ /// path and have changes with resepect to the HEAD commit. This is fast because
+ /// the index stores hashes of trees, so that unchanged directories can be skipped.
+ fn staged_statuses(&self, path_prefix: &Path) -> TreeMap<RepoPath, GitFileStatus>;
+
+ /// Get the status of a given file in the working directory with respect to
+ /// the index. In the common case, when there are no changes, this only requires
+ /// an index lookup. The index stores the mtime of each file when it was added,
+ /// so there's no work to do if the mtime matches.
+ fn unstaged_status(&self, path: &RepoPath, mtime: SystemTime) -> Option<GitFileStatus>;
+
+ /// Get the status of a given file in the working directory with respect to
+ /// the HEAD commit. In the common case, when there are no changes, this only
+ /// requires an index lookup and blob comparison between the index and the HEAD
+ /// commit. The index stores the mtime of each file when it was added, so there's
+ /// no need to consider the working directory file if the mtime matches.
+ fn status(&self, path: &RepoPath, mtime: SystemTime) -> Option<GitFileStatus>;
+
fn branches(&self) -> Result<Vec<Branch>>;
fn change_branch(&self, _: &str) -> Result<()>;
fn create_branch(&self, _: &str) -> Result<()>;
@@ -40,7 +58,6 @@ impl std::fmt::Debug for dyn GitRepository {
}
}
-#[async_trait::async_trait]
impl GitRepository for LibGitRepository {
fn reload_index(&self) {
if let Ok(mut index) = self.index() {
@@ -78,37 +95,67 @@ impl GitRepository for LibGitRepository {
Some(branch.to_string())
}
- fn statuses(&self) -> TreeMap<RepoPath, GitFileStatus> {
+ fn staged_statuses(&self, path_prefix: &Path) -> TreeMap<RepoPath, GitFileStatus> {
let mut map = TreeMap::default();
- if let Some(statuses) = self.statuses(None).log_err() {
- for status in statuses
- .iter()
- .filter(|status| !status.status().contains(git2::Status::IGNORED))
- {
- let path = RepoPath(PathBuf::from(OsStr::from_bytes(status.path_bytes())));
- let Some(status) = read_status(status.status()) else {
- continue
- };
- map.insert(path, status)
+ let mut options = git2::StatusOptions::new();
+ options.pathspec(path_prefix);
+ options.show(StatusShow::Index);
+
+ if let Some(statuses) = self.statuses(Some(&mut options)).log_err() {
+ for status in statuses.iter() {
+ let path = RepoPath(PathBuf::from(OsStr::from_bytes(status.path_bytes())));
+ let status = status.status();
+ if !status.contains(git2::Status::IGNORED) {
+ if let Some(status) = read_status(status) {
+ map.insert(path, status)
+ }
+ }
}
}
map
}
- fn status(&self, path: &RepoPath) -> Result<Option<GitFileStatus>> {
- let status = self.status_file(path);
- match status {
- Ok(status) => Ok(read_status(status)),
- Err(e) => {
- if e.code() == ErrorCode::NotFound {
- Ok(None)
- } else {
- Err(e.into())
- }
- }
+ fn unstaged_status(&self, path: &RepoPath, mtime: SystemTime) -> Option<GitFileStatus> {
+ // If the file has not changed since it was added to the index, then
+ // there can't be any changes.
+ if matches_index(self, path, mtime) {
+ return None;
}
+
+ let mut options = git2::StatusOptions::new();
+ options.pathspec(&path.0);
+ options.disable_pathspec_match(true);
+ options.include_untracked(true);
+ options.recurse_untracked_dirs(true);
+ options.include_unmodified(true);
+ options.show(StatusShow::Workdir);
+
+ let statuses = self.statuses(Some(&mut options)).log_err()?;
+ let status = statuses.get(0).and_then(|s| read_status(s.status()));
+ status
}
+
+ fn status(&self, path: &RepoPath, mtime: SystemTime) -> Option<GitFileStatus> {
+ let mut options = git2::StatusOptions::new();
+ options.pathspec(&path.0);
+ options.disable_pathspec_match(true);
+ options.include_untracked(true);
+ options.recurse_untracked_dirs(true);
+ options.include_unmodified(true);
+
+ // If the file has not changed since it was added to the index, then
+ // there's no need to examine the working directory file: just compare
+ // the blob in the index to the one in the HEAD commit.
+ if matches_index(self, path, mtime) {
+ options.show(StatusShow::Index);
+ }
+
+ let statuses = self.statuses(Some(&mut options)).log_err()?;
+ let status = statuses.get(0).and_then(|s| read_status(s.status()));
+ status
+ }
+
fn branches(&self) -> Result<Vec<Branch>> {
let local_branches = self.branches(Some(BranchType::Local))?;
let valid_branches = local_branches
@@ -151,6 +198,21 @@ impl GitRepository for LibGitRepository {
}
}
+fn matches_index(repo: &LibGitRepository, path: &RepoPath, mtime: SystemTime) -> bool {
+ if let Some(index) = repo.index().log_err() {
+ if let Some(entry) = index.get_path(&path, 0) {
+ if let Some(mtime) = mtime.duration_since(SystemTime::UNIX_EPOCH).log_err() {
+ if entry.mtime.seconds() == mtime.as_secs() as i32
+ && entry.mtime.nanoseconds() == mtime.subsec_nanos()
+ {
+ return true;
+ }
+ }
+ }
+ }
+ false
+}
+
fn read_status(status: git2::Status) -> Option<GitFileStatus> {
if status.contains(git2::Status::CONFLICTED) {
Some(GitFileStatus::Conflict)
@@ -200,18 +262,24 @@ impl GitRepository for FakeGitRepository {
state.branch_name.clone()
}
- fn statuses(&self) -> TreeMap<RepoPath, GitFileStatus> {
+ fn staged_statuses(&self, path_prefix: &Path) -> TreeMap<RepoPath, GitFileStatus> {
let mut map = TreeMap::default();
let state = self.state.lock();
for (repo_path, status) in state.worktree_statuses.iter() {
- map.insert(repo_path.to_owned(), status.to_owned());
+ if repo_path.0.starts_with(path_prefix) {
+ map.insert(repo_path.to_owned(), status.to_owned());
+ }
}
map
}
- fn status(&self, path: &RepoPath) -> Result<Option<GitFileStatus>> {
+ fn unstaged_status(&self, _path: &RepoPath, _mtime: SystemTime) -> Option<GitFileStatus> {
+ None
+ }
+
+ fn status(&self, path: &RepoPath, _mtime: SystemTime) -> Option<GitFileStatus> {
let state = self.state.lock();
- Ok(state.worktree_statuses.get(path).cloned())
+ state.worktree_statuses.get(path).cloned()
}
fn branches(&self) -> Result<Vec<Branch>> {
@@ -2162,10 +2162,18 @@ impl BackgroundScannerState {
let path = entry.path.clone();
let ignore_stack = self.snapshot.ignore_stack_for_abs_path(&abs_path, true);
let mut ancestor_inodes = self.snapshot.ancestor_inodes_for_path(&path);
- let containing_repository = self
- .snapshot
- .local_repo_for_path(&path)
- .map(|(path, repo)| (path, repo.repo_ptr.lock().statuses()));
+ let mut containing_repository = None;
+ if !ignore_stack.is_all() {
+ if let Some((workdir_path, repo)) = self.snapshot.local_repo_for_path(&path) {
+ if let Ok(repo_path) = path.strip_prefix(&workdir_path.0) {
+ containing_repository = Some((
+ workdir_path,
+ repo.repo_ptr.clone(),
+ repo.repo_ptr.lock().staged_statuses(repo_path),
+ ));
+ }
+ }
+ }
if !ancestor_inodes.contains(&entry.inode) {
ancestor_inodes.insert(entry.inode);
scan_job_tx
@@ -2355,8 +2363,7 @@ impl BackgroundScannerState {
.repository_entries
.update(&work_dir, |entry| entry.branch = branch.map(Into::into));
- let statuses = repository.statuses();
- self.update_git_statuses(&work_dir, &statuses);
+ self.update_git_statuses(&work_dir, &*repository);
}
}
}
@@ -2381,7 +2388,11 @@ impl BackgroundScannerState {
&mut self,
dot_git_path: Arc<Path>,
fs: &dyn Fs,
- ) -> Option<(RepositoryWorkDirectory, TreeMap<RepoPath, GitFileStatus>)> {
+ ) -> Option<(
+ RepositoryWorkDirectory,
+ Arc<Mutex<dyn GitRepository>>,
+ TreeMap<RepoPath, GitFileStatus>,
+ )> {
log::info!("build git repository {:?}", dot_git_path);
let work_dir_path: Arc<Path> = dot_git_path.parent().unwrap().into();
@@ -2413,27 +2424,28 @@ impl BackgroundScannerState {
},
);
- let statuses = repo_lock.statuses();
- self.update_git_statuses(&work_directory, &statuses);
+ let staged_statuses = self.update_git_statuses(&work_directory, &*repo_lock);
drop(repo_lock);
self.snapshot.git_repositories.insert(
work_dir_id,
LocalRepositoryEntry {
git_dir_scan_id: 0,
- repo_ptr: repository,
+ repo_ptr: repository.clone(),
git_dir_path: dot_git_path.clone(),
},
);
- Some((work_directory, statuses))
+ Some((work_directory, repository, staged_statuses))
}
fn update_git_statuses(
&mut self,
work_directory: &RepositoryWorkDirectory,
- statuses: &TreeMap<RepoPath, GitFileStatus>,
- ) {
+ repo: &dyn GitRepository,
+ ) -> TreeMap<RepoPath, GitFileStatus> {
+ let staged_statuses = repo.staged_statuses(Path::new(""));
+
let mut changes = vec![];
let mut edits = vec![];
@@ -2446,7 +2458,10 @@ impl BackgroundScannerState {
continue;
};
let repo_path = RepoPath(repo_path.to_path_buf());
- let git_file_status = statuses.get(&repo_path).copied();
+ let git_file_status = combine_git_statuses(
+ staged_statuses.get(&repo_path).copied(),
+ repo.unstaged_status(&repo_path, entry.mtime),
+ );
if entry.git_status != git_file_status {
entry.git_status = git_file_status;
changes.push(entry.path.clone());
@@ -2456,6 +2471,7 @@ impl BackgroundScannerState {
self.snapshot.entries_by_path.edit(edits, &());
util::extend_sorted(&mut self.changed_paths, changes, usize::MAX, Ord::cmp);
+ staged_statuses
}
}
@@ -3517,10 +3533,19 @@ impl BackgroundScanner {
}
} else {
child_entry.is_ignored = ignore_stack.is_abs_path_ignored(&child_abs_path, false);
-
- if let Some((repository_dir, statuses)) = &job.containing_repository {
- if let Ok(repo_path) = child_entry.path.strip_prefix(&repository_dir.0) {
- child_entry.git_status = statuses.get(&RepoPath(repo_path.into())).copied();
+ if !child_entry.is_ignored {
+ if let Some((repository_dir, repository, staged_statuses)) =
+ &job.containing_repository
+ {
+ if let Ok(repo_path) = child_entry.path.strip_prefix(&repository_dir.0) {
+ let repo_path = RepoPath(repo_path.into());
+ child_entry.git_status = combine_git_statuses(
+ staged_statuses.get(&repo_path).copied(),
+ repository
+ .lock()
+ .unstaged_status(&repo_path, child_entry.mtime),
+ );
+ }
}
}
}
@@ -3630,13 +3655,10 @@ impl BackgroundScanner {
if let Some((work_dir, repo)) =
state.snapshot.local_repo_for_path(&path)
{
- if let Ok(path) = path.strip_prefix(work_dir.0) {
- fs_entry.git_status = repo
- .repo_ptr
- .lock()
- .status(&RepoPath(path.into()))
- .log_err()
- .flatten()
+ if let Ok(repo_path) = path.strip_prefix(work_dir.0) {
+ let repo_path = RepoPath(repo_path.into());
+ let repo = repo.repo_ptr.lock();
+ fs_entry.git_status = repo.status(&repo_path, fs_entry.mtime);
}
}
}
@@ -3990,7 +4012,11 @@ struct ScanJob {
scan_queue: Sender<ScanJob>,
ancestor_inodes: TreeSet<u64>,
is_external: bool,
- containing_repository: Option<(RepositoryWorkDirectory, TreeMap<RepoPath, GitFileStatus>)>,
+ containing_repository: Option<(
+ RepositoryWorkDirectory,
+ Arc<Mutex<dyn GitRepository>>,
+ TreeMap<RepoPath, GitFileStatus>,
+ )>,
}
struct UpdateIgnoreStatusJob {
@@ -4317,3 +4343,22 @@ impl<'a> TryFrom<(&'a CharBag, proto::Entry)> for Entry {
}
}
}
+
+fn combine_git_statuses(
+ staged: Option<GitFileStatus>,
+ unstaged: Option<GitFileStatus>,
+) -> Option<GitFileStatus> {
+ if let Some(staged) = staged {
+ if let Some(unstaged) = unstaged {
+ if unstaged != staged {
+ Some(GitFileStatus::Modified)
+ } else {
+ Some(staged)
+ }
+ } else {
+ Some(staged)
+ }
+ } else {
+ unstaged
+ }
+}
@@ -125,6 +125,7 @@ actions!(
Paste,
Delete,
Rename,
+ Open,
ToggleFocus,
NewSearchInDirectory,
]
@@ -146,6 +147,7 @@ pub fn init(assets: impl AssetSource, cx: &mut AppContext) {
cx.add_action(ProjectPanel::rename);
cx.add_async_action(ProjectPanel::delete);
cx.add_async_action(ProjectPanel::confirm);
+ cx.add_async_action(ProjectPanel::open_file);
cx.add_action(ProjectPanel::cancel);
cx.add_action(ProjectPanel::cut);
cx.add_action(ProjectPanel::copy);
@@ -560,15 +562,20 @@ impl ProjectPanel {
fn confirm(&mut self, _: &Confirm, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
if let Some(task) = self.confirm_edit(cx) {
- Some(task)
- } else if let Some((_, entry)) = self.selected_entry(cx) {
+ return Some(task);
+ }
+
+ None
+ }
+
+ fn open_file(&mut self, _: &Open, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
+ if let Some((_, entry)) = self.selected_entry(cx) {
if entry.is_file() {
self.open_entry(entry.id, true, cx);
}
- None
- } else {
- None
}
+
+ None
}
fn confirm_edit(&mut self, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
@@ -2382,7 +2389,7 @@ mod tests {
toggle_expand_dir(&panel, "src/test", cx);
select_path(&panel, "src/test/first.rs", cx);
- panel.update(cx, |panel, cx| panel.confirm(&Confirm, cx));
+ panel.update(cx, |panel, cx| panel.open_file(&Open, cx));
cx.foreground().run_until_parked();
assert_eq!(
visible_entries_as_strings(&panel, 0..10, cx),
@@ -2410,7 +2417,7 @@ mod tests {
ensure_no_open_items_and_panes(window_id, &workspace, cx);
select_path(&panel, "src/test/second.rs", cx);
- panel.update(cx, |panel, cx| panel.confirm(&Confirm, cx));
+ panel.update(cx, |panel, cx| panel.open_file(&Open, cx));
cx.foreground().run_until_parked();
assert_eq!(
visible_entries_as_strings(&panel, 0..10, cx),
@@ -568,7 +568,7 @@ impl BufferSearchBar {
}
fn select_all_matches(&mut self, _: &SelectAllMatches, cx: &mut ViewContext<Self>) {
- if !self.dismissed {
+ if !self.dismissed && self.active_match_index.is_some() {
if let Some(searchable_item) = self.active_searchable_item.as_ref() {
if let Some(matches) = self
.searchable_items_with_matches
@@ -1175,9 +1175,16 @@ mod tests {
.await
.unwrap();
search_bar.update(cx, |search_bar, cx| {
+ cx.focus(search_bar.query_editor.as_any());
search_bar.activate_current_match(cx);
});
+ cx.read_window(window_id, |cx| {
+ assert!(
+ !editor.is_focused(cx),
+ "Initially, the editor should not be focused"
+ );
+ });
let initial_selections = editor.update(cx, |editor, cx| {
let initial_selections = editor.selections.display_ranges(cx);
assert_eq!(
@@ -1191,7 +1198,16 @@ mod tests {
});
search_bar.update(cx, |search_bar, cx| {
+ cx.focus(search_bar.query_editor.as_any());
search_bar.select_all_matches(&SelectAllMatches, cx);
+ });
+ cx.read_window(window_id, |cx| {
+ assert!(
+ editor.is_focused(cx),
+ "Should focus editor after successful SelectAllMatches"
+ );
+ });
+ search_bar.update(cx, |search_bar, cx| {
let all_selections =
editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
assert_eq!(
@@ -1199,8 +1215,6 @@ mod tests {
expected_query_matches_count,
"Should select all `a` characters in the buffer, but got: {all_selections:?}"
);
- });
- search_bar.update(cx, |search_bar, _| {
assert_eq!(
search_bar.active_match_index,
Some(0),
@@ -1210,6 +1224,14 @@ mod tests {
search_bar.update(cx, |search_bar, cx| {
search_bar.select_next_match(&SelectNextMatch, cx);
+ });
+ cx.read_window(window_id, |cx| {
+ assert!(
+ editor.is_focused(cx),
+ "Should still have editor focused after SelectNextMatch"
+ );
+ });
+ search_bar.update(cx, |search_bar, cx| {
let all_selections =
editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
assert_eq!(
@@ -1221,8 +1243,6 @@ mod tests {
all_selections, initial_selections,
"Next match should be different from the first selection"
);
- });
- search_bar.update(cx, |search_bar, _| {
assert_eq!(
search_bar.active_match_index,
Some(1),
@@ -1231,7 +1251,16 @@ mod tests {
});
search_bar.update(cx, |search_bar, cx| {
+ cx.focus(search_bar.query_editor.as_any());
search_bar.select_all_matches(&SelectAllMatches, cx);
+ });
+ cx.read_window(window_id, |cx| {
+ assert!(
+ editor.is_focused(cx),
+ "Should focus editor after successful SelectAllMatches"
+ );
+ });
+ search_bar.update(cx, |search_bar, cx| {
let all_selections =
editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
assert_eq!(
@@ -1239,8 +1268,6 @@ mod tests {
expected_query_matches_count,
"Should select all `a` characters in the buffer, but got: {all_selections:?}"
);
- });
- search_bar.update(cx, |search_bar, _| {
assert_eq!(
search_bar.active_match_index,
Some(1),
@@ -1250,6 +1277,14 @@ mod tests {
search_bar.update(cx, |search_bar, cx| {
search_bar.select_prev_match(&SelectPrevMatch, cx);
+ });
+ cx.read_window(window_id, |cx| {
+ assert!(
+ editor.is_focused(cx),
+ "Should still have editor focused after SelectPrevMatch"
+ );
+ });
+ let last_match_selections = search_bar.update(cx, |search_bar, cx| {
let all_selections =
editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
assert_eq!(
@@ -1261,13 +1296,41 @@ mod tests {
all_selections, initial_selections,
"Previous match should be the same as the first selection"
);
- });
- search_bar.update(cx, |search_bar, _| {
assert_eq!(
search_bar.active_match_index,
Some(0),
"Match index should be updated to the previous one"
);
+ all_selections
+ });
+
+ search_bar
+ .update(cx, |search_bar, cx| {
+ cx.focus(search_bar.query_editor.as_any());
+ search_bar.search("abas_nonexistent_match", None, cx)
+ })
+ .await
+ .unwrap();
+ search_bar.update(cx, |search_bar, cx| {
+ search_bar.select_all_matches(&SelectAllMatches, cx);
+ });
+ cx.read_window(window_id, |cx| {
+ assert!(
+ !editor.is_focused(cx),
+ "Should not switch focus to editor if SelectAllMatches does not find any matches"
+ );
+ });
+ search_bar.update(cx, |search_bar, cx| {
+ let all_selections =
+ editor.update(cx, |editor, cx| editor.selections.display_ranges(cx));
+ assert_eq!(
+ all_selections, last_match_selections,
+ "Should not select anything new if there are no matches"
+ );
+ assert!(
+ search_bar.active_match_index.is_none(),
+ "For no matches, there should be no active match index"
+ );
});
}
}
@@ -109,7 +109,9 @@ tree-sitter-c.workspace = true
tree-sitter-cpp.workspace = true
tree-sitter-css.workspace = true
tree-sitter-elixir.workspace = true
+tree-sitter-elm.workspace = true
tree-sitter-embedded-template.workspace = true
+tree-sitter-glsl.workspace = true
tree-sitter-go.workspace = true
tree-sitter-heex.workspace = true
tree-sitter-json.workspace = true
@@ -152,7 +152,10 @@ pub fn init(languages: Arc<LanguageRegistry>, node_runtime: Arc<NodeRuntime>) {
tree_sitter_php::language(),
vec![Arc::new(php::IntelephenseLspAdapter::new(node_runtime))],
);
- language("nix", tree_sitter_nix::language(), vec![])
+
+ language("elm", tree_sitter_elm::language(), vec![]);
+ language("glsl", tree_sitter_glsl::language(), vec![]);
+ language("nix", tree_sitter_nix::language(), vec![]);
}
#[cfg(any(test, feature = "test-support"))]
@@ -0,0 +1,11 @@
+name = "Elm"
+path_suffixes = ["elm"]
+line_comment = "-- "
+block_comment = ["{- ", " -}"]
+brackets = [
+ { start = "{", end = "}", close = true, newline = true },
+ { start = "[", end = "]", close = true, newline = true },
+ { start = "(", end = ")", close = true, newline = true },
+ { start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },
+ { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
+]
@@ -0,0 +1,72 @@
+[
+ "if"
+ "then"
+ "else"
+ "let"
+ "in"
+ (case)
+ (of)
+ (backslash)
+ (as)
+ (port)
+ (exposing)
+ (alias)
+ (import)
+ (module)
+ (type)
+ (arrow)
+ ] @keyword
+
+[
+ (eq)
+ (operator_identifier)
+ (colon)
+] @operator
+
+(type_annotation(lower_case_identifier) @function)
+(port_annotation(lower_case_identifier) @function)
+(function_declaration_left(lower_case_identifier) @function.definition)
+
+(function_call_expr
+ target: (value_expr
+ name: (value_qid (lower_case_identifier) @function)))
+
+(exposed_value(lower_case_identifier) @function)
+(exposed_type(upper_case_identifier) @type)
+
+(field_access_expr(value_expr(value_qid)) @identifier)
+(lower_pattern) @variable
+(record_base_identifier) @identifier
+
+[
+ "("
+ ")"
+] @punctuation.bracket
+
+[
+ "|"
+ ","
+] @punctuation.delimiter
+
+(number_constant_expr) @constant
+
+(type_declaration(upper_case_identifier) @type)
+(type_ref) @type
+(type_alias_declaration name: (upper_case_identifier) @type)
+
+(value_expr(upper_case_qid(upper_case_identifier)) @type)
+
+[
+ (line_comment)
+ (block_comment)
+] @comment
+
+(string_escape) @string.escape
+
+[
+ (open_quote)
+ (close_quote)
+ (regular_string_part)
+ (open_char)
+ (close_char)
+] @string
@@ -0,0 +1,2 @@
+((glsl_content) @content
+ (#set! "language" "glsl"))
@@ -0,0 +1,22 @@
+(type_declaration
+ (type) @context
+ (upper_case_identifier) @name) @item
+
+(type_alias_declaration
+ (type) @context
+ (alias) @context
+ name: (upper_case_identifier) @name) @item
+
+(type_alias_declaration
+ typeExpression:
+ (type_expression
+ part: (record_type
+ (field_type
+ name: (lower_case_identifier) @name) @item)))
+
+(union_variant
+ name: (upper_case_identifier) @name) @item
+
+(value_declaration
+ functionDeclarationLeft:
+ (function_declaration_left(lower_case_identifier) @name)) @item
@@ -0,0 +1,9 @@
+name = "GLSL"
+path_suffixes = ["vert", "frag", "tesc", "tese", "geom", "comp"]
+line_comment = "// "
+block_comment = ["/* ", " */"]
+brackets = [
+ { start = "{", end = "}", close = true, newline = true },
+ { start = "[", end = "]", close = true, newline = true },
+ { start = "(", end = ")", close = true, newline = true },
+]
@@ -0,0 +1,118 @@
+"break" @keyword
+"case" @keyword
+"const" @keyword
+"continue" @keyword
+"default" @keyword
+"do" @keyword
+"else" @keyword
+"enum" @keyword
+"extern" @keyword
+"for" @keyword
+"if" @keyword
+"inline" @keyword
+"return" @keyword
+"sizeof" @keyword
+"static" @keyword
+"struct" @keyword
+"switch" @keyword
+"typedef" @keyword
+"union" @keyword
+"volatile" @keyword
+"while" @keyword
+
+"#define" @keyword
+"#elif" @keyword
+"#else" @keyword
+"#endif" @keyword
+"#if" @keyword
+"#ifdef" @keyword
+"#ifndef" @keyword
+"#include" @keyword
+(preproc_directive) @keyword
+
+"--" @operator
+"-" @operator
+"-=" @operator
+"->" @operator
+"=" @operator
+"!=" @operator
+"*" @operator
+"&" @operator
+"&&" @operator
+"+" @operator
+"++" @operator
+"+=" @operator
+"<" @operator
+"==" @operator
+">" @operator
+"||" @operator
+
+"." @delimiter
+";" @delimiter
+
+(string_literal) @string
+(system_lib_string) @string
+
+(null) @constant
+(number_literal) @number
+(char_literal) @number
+
+(call_expression
+ function: (identifier) @function)
+(call_expression
+ function: (field_expression
+ field: (field_identifier) @function))
+(function_declarator
+ declarator: (identifier) @function)
+(preproc_function_def
+ name: (identifier) @function.special)
+
+(field_identifier) @property
+(statement_identifier) @label
+(type_identifier) @type
+(primitive_type) @type
+(sized_type_specifier) @type
+
+((identifier) @constant
+ (#match? @constant "^[A-Z][A-Z\\d_]*$"))
+
+(identifier) @variable
+
+(comment) @comment
+; inherits: c
+
+[
+ "in"
+ "out"
+ "inout"
+ "uniform"
+ "shared"
+ "layout"
+ "attribute"
+ "varying"
+ "buffer"
+ "coherent"
+ "readonly"
+ "writeonly"
+ "precision"
+ "highp"
+ "mediump"
+ "lowp"
+ "centroid"
+ "sample"
+ "patch"
+ "smooth"
+ "flat"
+ "noperspective"
+ "invariant"
+ "precise"
+] @type.qualifier
+
+"subroutine" @keyword.function
+
+(extension_storage_class) @storageclass
+
+(
+ (identifier) @variable.builtin
+ (#match? @variable.builtin "^gl_")
+)