Skip to content

Commit

Permalink
Merge branch 'main' into lsp-tree
Browse files Browse the repository at this point in the history
  • Loading branch information
osiewicz committed Jan 13, 2025
2 parents fb48b7b + 93f117b commit 0fa9656
Show file tree
Hide file tree
Showing 88 changed files with 2,235 additions and 1,316 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions assets/keymaps/default-macos.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,38 @@
"space": "project_panel::Open"
}
},
{
"context": "GitPanel && !CommitEditor",
"use_key_equivalents": true,
"bindings": {
"escape": "git_panel::Close"
}
},
{
"context": "GitPanel && ChangesList",
"use_key_equivalents": true,
"bindings": {
"up": "menu::SelectPrev",
"down": "menu::SelectNext",
"cmd-up": "menu::SelectFirst",
"cmd-down": "menu::SelectLast",
"enter": "menu::Confirm",
"space": "git::ToggleStaged",
"cmd-shift-space": "git::StageAll",
"ctrl-shift-space": "git::UnstageAll",
"alt-down": "git_panel::FocusEditor"
}
},
{
"context": "GitPanel && CommitEditor > Editor",
"use_key_equivalents": true,
"bindings": {
"alt-up": "git_panel::FocusChanges",
"escape": "git_panel::FocusChanges",
"cmd-enter": "git::CommitChanges",
"cmd-alt-enter": "git::CommitAllChanges"
}
},
{
"context": "CollabPanel && not_editing",
"use_key_equivalents": true,
Expand Down
61 changes: 59 additions & 2 deletions assets/keymaps/linux/emacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"ctrl-x b": "tab_switcher::Toggle", // switch-to-buffer
"alt-g g": "go_to_line::Toggle", // goto-line
"alt-g alt-g": "go_to_line::Toggle", // goto-line
//"ctrl-space": "editor::SetMark",
"ctrl-f": "editor::MoveRight", // forward-char
"ctrl-b": "editor::MoveLeft", // backward-char
"ctrl-n": "editor::MoveDown", // next-line
Expand Down Expand Up @@ -52,7 +51,65 @@
"alt->": "editor::MoveToEnd", // end-of-buffer
"ctrl-l": "editor::ScrollCursorCenterTopBottom", // recenter-top-bottom
"ctrl-s": "buffer_search::Deploy", // isearch-forward
"alt-^": "editor::JoinLines" // join-line
"alt-^": "editor::JoinLines", // join-line
"alt-/": "editor::ShowCompletions" // dabbrev-expand
}
},
// Extend selection with movement bindings
{
"context": "Editor && (mode == full) && selection",
"bindings": {
"right": "editor::SelectRight",
"left": "editor::SelectLeft",
"down": "editor::SelectDown",
"up": "editor::SelectUp",
"home": "editor::SelectToBeginningOfLine",
"end": "editor::SelectToEndOfLine",
"alt-left": "editor::SelectToPreviousWordStart",
"alt-right": "editor::SelectToNextWordEnd",
"pagedown": "editor::SelectPageDown",
"pageup": "editor::SelectPageUp",
"ctrl-f": "editor::SelectRight",
"ctrl-b": "editor::SelectLeft",
"ctrl-n": "editor::SelectDown",
"ctrl-p": "editor::SelectUp",
"ctrl-a": "editor::SelectToBeginningOfLine",
"ctrl-e": "editor::SelectToEndOfLine",
"alt-f": "editor::SelectToNextWordEnd",
"alt-b": "editor::SelectToPreviousSubwordStart",
"alt-<": "editor::SelectToBeginning",
"alt->": "editor::SelectToEnd",
"ctrl-space": "editor::Cancel" // clear mark
}
},
// Emacs set-mark-command emulation (ctrl-space + movement bindings)
{
"context": "Editor && (mode == full) && !selection",
"bindings": {
"ctrl-space right": "editor::SelectRight",
"ctrl-space left": "editor::SelectLeft",
"ctrl-space down": "editor::SelectDown",
"ctrl-space up": "editor::SelectUp",
"ctrl-space home": "editor::SelectToBeginningOfLine",
"ctrl-space end": "editor::SelectToEndOfLine",
"ctrl-space alt-left": "editor::SelectToPreviousWordStart",
"ctrl-space alt-right": "editor::SelectToNextWordEnd",
"ctrl-space pagedown": "editor::SelectPageDown",
"ctrl-space pageup": "editor::SelectPageUp",
"ctrl-space ctrl-f": "editor::SelectRight",
"ctrl-space ctrl-b": "editor::SelectLeft",
"ctrl-space ctrl-n": "editor::SelectDown",
"ctrl-space ctrl-p": "editor::SelectUp",
"ctrl-space ctrl-a": "editor::SelectToBeginningOfLine",
"ctrl-space ctrl-e": "editor::SelectToEndOfLine",
"ctrl-space alt-f": "editor::SelectToNextWordEnd",
"ctrl-space alt-b": "editor::SelectToPreviousWordStart",
"ctrl-space alt-<": "editor::SelectToBeginning",
"ctrl-space alt->": "editor::SelectToEnd",
"ctrl-space alt-v": "editor::SelectPageUp",
"ctrl-space ctrl-v": "editor::SelectPageDown",
"ctrl-space alt-{": "editor::SelectToStartOfParagraph",
"ctrl-space alt-}": "editor::SelectToEndOfParagraph"
}
},
{
Expand Down
61 changes: 59 additions & 2 deletions assets/keymaps/macos/emacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"ctrl-x b": "tab_switcher::Toggle", // switch-to-buffer
"alt-g g": "go_to_line::Toggle", // goto-line
"alt-g alt-g": "go_to_line::Toggle", // goto-line
//"ctrl-space": "editor::SetMark",
"ctrl-f": "editor::MoveRight", // forward-char
"ctrl-b": "editor::MoveLeft", // backward-char
"ctrl-n": "editor::MoveDown", // next-line
Expand Down Expand Up @@ -52,7 +51,65 @@
"alt->": "editor::MoveToEnd", // end-of-buffer
"ctrl-l": "editor::ScrollCursorCenterTopBottom", // recenter-top-bottom
"ctrl-s": "buffer_search::Deploy", // isearch-forward
"alt-^": "editor::JoinLines" // join-line
"alt-^": "editor::JoinLines", // join-line
"alt-/": "editor::ShowCompletions" // dabbrev-expand
}
},
// Extend selection with movement bindings
{
"context": "Editor && (mode == full) && selection",
"bindings": {
"right": "editor::SelectRight",
"left": "editor::SelectLeft",
"down": "editor::SelectDown",
"up": "editor::SelectUp",
"home": "editor::SelectToBeginningOfLine",
"end": "editor::SelectToEndOfLine",
"alt-left": "editor::SelectToPreviousWordStart",
"alt-right": "editor::SelectToNextWordEnd",
"pagedown": "editor::SelectPageDown",
"pageup": "editor::SelectPageUp",
"ctrl-f": "editor::SelectRight",
"ctrl-b": "editor::SelectLeft",
"ctrl-n": "editor::SelectDown",
"ctrl-p": "editor::SelectUp",
"ctrl-a": "editor::SelectToBeginningOfLine",
"ctrl-e": "editor::SelectToEndOfLine",
"alt-f": "editor::SelectToNextWordEnd",
"alt-b": "editor::SelectToPreviousSubwordStart",
"alt-<": "editor::SelectToBeginning",
"alt->": "editor::SelectToEnd",
"ctrl-space": "editor::Cancel" // clear mark
}
},
// Emacs set-mark-command emulation (ctrl-space + movement bindings)
{
"context": "Editor && (mode == full) && !selection",
"bindings": {
"ctrl-space right": "editor::SelectRight",
"ctrl-space left": "editor::SelectLeft",
"ctrl-space down": "editor::SelectDown",
"ctrl-space up": "editor::SelectUp",
"ctrl-space home": "editor::SelectToBeginningOfLine",
"ctrl-space end": "editor::SelectToEndOfLine",
"ctrl-space alt-left": "editor::SelectToPreviousWordStart",
"ctrl-space alt-right": "editor::SelectToNextWordEnd",
"ctrl-space pagedown": "editor::SelectPageDown",
"ctrl-space pageup": "editor::SelectPageUp",
"ctrl-space ctrl-f": "editor::SelectRight",
"ctrl-space ctrl-b": "editor::SelectLeft",
"ctrl-space ctrl-n": "editor::SelectDown",
"ctrl-space ctrl-p": "editor::SelectUp",
"ctrl-space ctrl-a": "editor::SelectToBeginningOfLine",
"ctrl-space ctrl-e": "editor::SelectToEndOfLine",
"ctrl-space alt-f": "editor::SelectToNextWordEnd",
"ctrl-space alt-b": "editor::SelectToPreviousWordStart",
"ctrl-space alt-<": "editor::SelectToBeginning",
"ctrl-space alt->": "editor::SelectToEnd",
"ctrl-space alt-v": "editor::SelectPageUp",
"ctrl-space ctrl-v": "editor::SelectPageDown",
"ctrl-space alt-{": "editor::SelectToStartOfParagraph",
"ctrl-space alt-}": "editor::SelectToEndOfParagraph"
}
},
{
Expand Down
6 changes: 3 additions & 3 deletions crates/assistant/src/assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub use context::*;
pub use context_store::*;
use feature_flags::FeatureFlagAppExt;
use fs::Fs;
use gpui::impl_actions;
use gpui::impl_internal_actions;
use gpui::{actions, AppContext, Global, SharedString, UpdateGlobal};
pub(crate) use inline_assistant::*;
use language_model::{
Expand Down Expand Up @@ -74,13 +74,13 @@ actions!(
]
);

#[derive(PartialEq, Clone, Deserialize)]
#[derive(PartialEq, Clone)]
pub enum InsertDraggedFiles {
ProjectPaths(Vec<PathBuf>),
ExternalFiles(Vec<PathBuf>),
}

impl_actions!(assistant, [InsertDraggedFiles]);
impl_internal_actions!(assistant, [InsertDraggedFiles]);

const DEFAULT_CONTEXT_LINES: usize = 50;

Expand Down
45 changes: 30 additions & 15 deletions crates/assistant/src/inline_assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ pub fn init(
) {
cx.set_global(InlineAssistant::new(fs, prompt_builder, telemetry));
cx.observe_new_views(|_, cx| {
let workspace = cx.view().clone();
InlineAssistant::update_global(cx, |inline_assistant, cx| {
inline_assistant.register_workspace(&workspace, cx)
});

cx.observe_flag::<Assistant2FeatureFlag, _>({
|is_assistant2_enabled, _view, cx| {
if is_assistant2_enabled {
// Assistant2 enabled, nothing to do for Assistant1.
} else {
let workspace = cx.view().clone();
InlineAssistant::update_global(cx, |inline_assistant, cx| {
inline_assistant.register_workspace(&workspace, cx)
})
}
InlineAssistant::update_global(cx, |inline_assistant, _cx| {
inline_assistant.is_assistant2_enabled = is_assistant2_enabled;
});
}
})
.detach();
Expand All @@ -102,6 +102,7 @@ pub struct InlineAssistant {
prompt_builder: Arc<PromptBuilder>,
telemetry: Arc<Telemetry>,
fs: Arc<dyn Fs>,
is_assistant2_enabled: bool,
}

impl Global for InlineAssistant {}
Expand All @@ -123,6 +124,7 @@ impl InlineAssistant {
prompt_builder,
telemetry,
fs,
is_assistant2_enabled: false,
}
}

Expand Down Expand Up @@ -183,15 +185,22 @@ impl InlineAssistant {
item: &dyn ItemHandle,
cx: &mut WindowContext,
) {
let is_assistant2_enabled = self.is_assistant2_enabled;

if let Some(editor) = item.act_as::<Editor>(cx) {
editor.update(cx, |editor, cx| {
editor.push_code_action_provider(
Rc::new(AssistantCodeActionProvider {
editor: cx.view().downgrade(),
workspace: workspace.downgrade(),
}),
cx,
);
if is_assistant2_enabled {
editor
.remove_code_action_provider(ASSISTANT_CODE_ACTION_PROVIDER_ID.into(), cx);
} else {
editor.add_code_action_provider(
Rc::new(AssistantCodeActionProvider {
editor: cx.view().downgrade(),
workspace: workspace.downgrade(),
}),
cx,
);
}
});
}
}
Expand Down Expand Up @@ -3437,7 +3446,13 @@ struct AssistantCodeActionProvider {
workspace: WeakView<Workspace>,
}

const ASSISTANT_CODE_ACTION_PROVIDER_ID: &str = "assistant";

impl CodeActionProvider for AssistantCodeActionProvider {
fn id(&self) -> Arc<str> {
ASSISTANT_CODE_ACTION_PROVIDER_ID.into()
}

fn code_actions(
&self,
buffer: &Model<Buffer>,
Expand Down
Loading

0 comments on commit 0fa9656

Please sign in to comment.