|
|
|
@ -3,6 +3,7 @@ use crate::{
|
|
|
|
|
clipboard::{get_clipboard_provider, ClipboardProvider},
|
|
|
|
|
document::{DocumentSavedEventFuture, DocumentSavedEventResult, Mode},
|
|
|
|
|
graphics::{CursorKind, Rect},
|
|
|
|
|
icons::{self, Icons},
|
|
|
|
|
info::Info,
|
|
|
|
|
input::KeyEvent,
|
|
|
|
|
theme::{self, Theme},
|
|
|
|
@ -211,6 +212,27 @@ impl Default for FilePickerConfig {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
|
|
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
|
|
|
|
|
pub struct IconsConfig {
|
|
|
|
|
/// Enables icons in front of buffer names in bufferline. Defaults to `true`
|
|
|
|
|
pub bufferline: bool,
|
|
|
|
|
/// Enables icons in front of items in the picker. Defaults to `true`
|
|
|
|
|
pub picker: bool,
|
|
|
|
|
/// Enables icons in front of items in the statusline. Defaults to `true`
|
|
|
|
|
pub statusline: bool,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for IconsConfig {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
bufferline: true,
|
|
|
|
|
picker: true,
|
|
|
|
|
statusline: true,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
|
|
#[serde(rename_all = "kebab-case", default, deny_unknown_fields)]
|
|
|
|
|
pub struct Config {
|
|
|
|
@ -284,6 +306,8 @@ pub struct Config {
|
|
|
|
|
pub soft_wrap: SoftWrap,
|
|
|
|
|
/// Workspace specific lsp ceiling dirs
|
|
|
|
|
pub workspace_lsp_roots: Vec<PathBuf>,
|
|
|
|
|
/// Icons configuration
|
|
|
|
|
pub icons: IconsConfig,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
|
|
@ -753,6 +777,7 @@ impl Default for Config {
|
|
|
|
|
text_width: 80,
|
|
|
|
|
completion_replace: false,
|
|
|
|
|
workspace_lsp_roots: Vec::new(),
|
|
|
|
|
icons: IconsConfig::default(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -829,6 +854,8 @@ pub struct Editor {
|
|
|
|
|
/// The currently applied editor theme. While previewing a theme, the previewed theme
|
|
|
|
|
/// is set here.
|
|
|
|
|
pub theme: Theme,
|
|
|
|
|
pub icons: Icons,
|
|
|
|
|
pub icons_loader: Arc<icons::Loader>,
|
|
|
|
|
|
|
|
|
|
/// The primary Selection prior to starting a goto_line_number preview. This is
|
|
|
|
|
/// restored when the preview is aborted, or added to the jumplist when it is
|
|
|
|
@ -927,11 +954,14 @@ impl Editor {
|
|
|
|
|
pub fn new(
|
|
|
|
|
mut area: Rect,
|
|
|
|
|
theme_loader: Arc<theme::Loader>,
|
|
|
|
|
icons_loader: Arc<icons::Loader>,
|
|
|
|
|
syn_loader: Arc<syntax::Loader>,
|
|
|
|
|
config: Arc<dyn DynAccess<Config>>,
|
|
|
|
|
) -> Self {
|
|
|
|
|
let conf = config.load();
|
|
|
|
|
let auto_pairs = (&conf.auto_pairs).into();
|
|
|
|
|
let theme = theme_loader.default();
|
|
|
|
|
let icons = icons_loader.default(&theme);
|
|
|
|
|
|
|
|
|
|
// HAXX: offset the render area height by 1 to account for prompt/commandline
|
|
|
|
|
area.height -= 1;
|
|
|
|
@ -974,6 +1004,8 @@ impl Editor {
|
|
|
|
|
needs_redraw: false,
|
|
|
|
|
cursor_cache: Cell::new(None),
|
|
|
|
|
completion_request_handle: None,
|
|
|
|
|
icons,
|
|
|
|
|
icons_loader,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1074,6 +1106,9 @@ impl Editor {
|
|
|
|
|
}
|
|
|
|
|
ThemeAction::Set => {
|
|
|
|
|
self.last_theme = None;
|
|
|
|
|
// Reload the icons to apply default colors based on theme
|
|
|
|
|
self.icons.set_diagnostic_icons_base_style(&theme);
|
|
|
|
|
self.icons.set_symbolkind_icons_base_style(&theme);
|
|
|
|
|
self.theme = theme;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1081,6 +1116,11 @@ impl Editor {
|
|
|
|
|
self._refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn set_icons(&mut self, icons: Icons) {
|
|
|
|
|
self.icons = icons;
|
|
|
|
|
self._refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Refreshes the language server for a given document
|
|
|
|
|
pub fn refresh_language_server(&mut self, doc_id: DocumentId) -> Option<()> {
|
|
|
|
|
self.launch_language_server(doc_id)
|
|
|
|
|