diff options
author | Dmitry Sharshakov | 2021-08-28 11:59:26 +0000 |
---|---|---|
committer | Dmitry Sharshakov | 2021-08-28 11:59:26 +0000 |
commit | e3153946311b189bd5e10e816acbdda508ded31c (patch) | |
tree | 304e0b8c0b869cc239d8c0ce9b0f328fe589bd93 /helix-term/src | |
parent | 8df6739759396b45d06356dd78c39117590b062b (diff) | |
parent | d6a9c2c0f6f4af98146b52d1c886a1ca99d15676 (diff) |
Merge remote-tracking branch 'origin/master' into debug
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/application.rs | 21 | ||||
-rw-r--r-- | helix-term/src/commands.rs | 2 | ||||
-rw-r--r-- | helix-term/src/keymap.rs | 2 | ||||
-rw-r--r-- | helix-term/src/ui/editor.rs | 8 | ||||
-rw-r--r-- | helix-term/src/ui/menu.rs | 7 | ||||
-rw-r--r-- | helix-term/src/ui/mod.rs | 3 | ||||
-rw-r--r-- | helix-term/src/ui/prompt.rs | 20 |
7 files changed, 39 insertions, 24 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 17c762da..9aa98271 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -1,4 +1,4 @@ -use helix_core::{syntax, Range, Selection}; +use helix_core::{merge_toml_values, syntax, Range, Selection}; use helix_dap::Payload; use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap}; use helix_view::{theme, Editor}; @@ -66,11 +66,16 @@ impl Application { let theme_loader = std::sync::Arc::new(theme::Loader::new(&conf_dir, &helix_core::runtime_dir())); - // load $HOME/.config/helix/languages.toml, fallback to default config - let lang_conf = std::fs::read(conf_dir.join("languages.toml")); - let lang_conf = lang_conf - .as_deref() - .unwrap_or(include_bytes!("../../languages.toml")); + // load default and user config, and merge both + let def_lang_conf: toml::Value = toml::from_slice(include_bytes!("../../languages.toml")) + .expect("Could not parse built-in languages.toml, something must be very wrong"); + let user_lang_conf: Option<toml::Value> = std::fs::read(conf_dir.join("languages.toml")) + .ok() + .map(|raw| toml::from_slice(&raw).expect("Could not parse user languages.toml")); + let lang_conf = match user_lang_conf { + Some(value) => merge_toml_values(def_lang_conf, value), + None => def_lang_conf, + }; let theme = if let Some(theme) = &config.theme { match theme_loader.load(theme) { @@ -84,7 +89,9 @@ impl Application { theme_loader.default() }; - let syn_loader_conf = toml::from_slice(lang_conf).expect("Could not parse languages.toml"); + let syn_loader_conf: helix_core::syntax::Configuration = lang_conf + .try_into() + .expect("Could not parse merged (built-in + user) languages.toml"); let syn_loader = std::sync::Arc::new(syntax::Loader::new(syn_loader_conf)); let mut editor = Editor::new( diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 5eb51965..e5db1624 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2369,7 +2369,7 @@ mod cmd { }, TypableCommand { name: "vsplit", - alias: Some("vsp"), + alias: Some("vs"), doc: "Open the file in a vertical split.", fun: vsplit, completer: Some(completers::filename), diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index d16c9a3a..2aa3f9f3 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -541,6 +541,8 @@ impl Default for Keymaps { "home" => goto_line_start, "end" => goto_line_end, "esc" => exit_select_mode, + + "v" => normal_mode, })); let insert = keymap!({ "Insert mode" "esc" => normal_mode, diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 1f4fc1c5..6428870e 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -508,7 +508,13 @@ impl EditorView { } else { let line = match config.line_number { LineNumber::Absolute => line + 1, - LineNumber::Relative => abs_diff(current_line, line), + LineNumber::Relative => { + if current_line == line { + line + 1 + } else { + abs_diff(current_line, line) + } + } }; format!("{:>5}", line) }; diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index a56cf19b..24dd3e61 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -259,8 +259,11 @@ impl<T: Item + 'static> Component for Menu<T> { // TODO: required size should re-trigger when we filter items so we can draw a smaller menu fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) { - let style = cx.editor.theme.get("ui.text"); - let selected = cx.editor.theme.get("ui.menu.selected"); + let theme = &cx.editor.theme; + let style = theme + .try_get("ui.menu") + .unwrap_or_else(|| theme.get("ui.text")); + let selected = theme.get("ui.menu.selected"); let scroll = self.scroll; diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index e4871312..f3f8670e 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -228,7 +228,8 @@ pub mod completers { let end = input.len()..; - let mut files: Vec<_> = WalkBuilder::new(dir.clone()) + let mut files: Vec<_> = WalkBuilder::new(&dir) + .hidden(false) .max_depth(Some(1)) .build() .filter_map(|file| { diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 19986b5c..7197adea 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -400,18 +400,6 @@ impl Component for Prompt { }))); match event { - // char or shift char - KeyEvent { - code: KeyCode::Char(c), - modifiers: KeyModifiers::NONE, - } - | KeyEvent { - code: KeyCode::Char(c), - modifiers: KeyModifiers::SHIFT, - } => { - self.insert_char(c); - (self.callback_fn)(cx, &self.line, PromptEvent::Update); - } KeyEvent { code: KeyCode::Char('c'), modifiers: KeyModifiers::CONTROL, @@ -539,6 +527,14 @@ impl Component for Prompt { code: KeyCode::Char('q'), modifiers: KeyModifiers::CONTROL, } => self.exit_selection(), + // any char event that's not combined with control or mapped to any other combo + KeyEvent { + code: KeyCode::Char(c), + modifiers, + } if !modifiers.contains(KeyModifiers::CONTROL) => { + self.insert_char(c); + (self.callback_fn)(cx, &self.line, PromptEvent::Update); + } _ => (), }; |