-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config: Rename [terminal] to [editor] and pass it into Editor
- Loading branch information
Showing
7 changed files
with
60 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,26 @@ pub use helix_core::register::Registers; | |
use helix_core::syntax; | ||
use helix_core::Position; | ||
|
||
use serde::Deserialize; | ||
|
||
#[derive(Debug, Clone, PartialEq, Deserialize)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct Config { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
/// Padding to keep between the edge of the screen and the cursor when scrolling. Defaults to 5. | ||
pub scrolloff: usize, | ||
/// Mouse support. Defaults to true. | ||
pub mouse: bool, | ||
} | ||
|
||
impl Default for Config { | ||
fn default() -> Self { | ||
Self { | ||
scrolloff: 5, | ||
This comment has been minimized.
Sorry, something went wrong.
sudormrfbin
Member
|
||
mouse: true, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct Editor { | ||
pub tree: Tree, | ||
|
@@ -33,6 +53,8 @@ pub struct Editor { | |
pub theme_loader: Arc<theme::Loader>, | ||
|
||
pub status_msg: Option<(String, Severity)>, | ||
|
||
pub config: Config, | ||
} | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
|
@@ -48,6 +70,7 @@ impl Editor { | |
mut area: Rect, | ||
themes: Arc<theme::Loader>, | ||
config_loader: Arc<syntax::Loader>, | ||
config: Config, | ||
) -> Self { | ||
let language_servers = helix_lsp::Registry::new(); | ||
|
||
|
@@ -66,6 +89,7 @@ impl Editor { | |
registers: Registers::default(), | ||
clipboard_provider: get_clipboard_provider(), | ||
status_msg: None, | ||
config, | ||
} | ||
} | ||
|
||
|
@@ -108,7 +132,7 @@ impl Editor { | |
fn _refresh(&mut self) { | ||
for (view, _) in self.tree.views_mut() { | ||
let doc = &self.documents[view.doc]; | ||
view.ensure_cursor_in_view(doc) | ||
view.ensure_cursor_in_view(doc, self.config.scrolloff) | ||
} | ||
} | ||
|
||
|
@@ -267,7 +291,7 @@ impl Editor { | |
pub fn ensure_cursor_in_view(&mut self, id: ViewId) { | ||
let view = self.tree.get_mut(id); | ||
let doc = &self.documents[view.doc]; | ||
view.ensure_cursor_in_view(doc) | ||
view.ensure_cursor_in_view(doc, self.config.scrolloff) | ||
} | ||
|
||
pub fn document(&self, id: DocumentId) -> Option<&Document> { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This will actually error out if there's only one item from the struct in the config (when there's
scrolloff
only ormouse
only);#[serde(rename_all = "kebab-case", default)]
should solve the problem.