Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added flags for editing language configurations viewing the log file. #1797

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ To override global configuration parameters, create a `config.toml` file located
* Linux and Mac: `~/.config/helix/config.toml`
* Windows: `%AppData%\helix\config.toml`

> Note: You may use `hx --edit-config` to create and edit the `config.toml` file.
> Note: You may use `hx --edit-config` to create and edit `config.toml`.

Example config:

Expand Down
2 changes: 2 additions & 0 deletions book/src/languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Language-specific settings and settings for particular language servers can be c

Changes made to the `languages.toml` file in a user's [configuration directory](./configuration.md) are merged with helix's defaults on start-up, such that a user's settings will take precedence over defaults in the event of a collision. For example, the default `languages.toml` sets rust's `auto-format` to `true`. If a user wants to disable auto-format, they can change the `languages.toml` in their [configuration directory](./configuration.md) to make the rust entry read like the example below; the new key/value pair `auto-format = false` will override the default when the two sets of settings are merged on start-up:

> Note: You may use `hx --edit-lang-config` to create and edit `languages.toml`.

```toml
# in <config_dir>/helix/languages.toml

Expand Down
13 changes: 8 additions & 5 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ impl Application {
let mut compositor = Compositor::new()?;
let size = compositor.size();

let conf_dir = helix_loader::config_dir();

let theme_loader =
std::sync::Arc::new(theme::Loader::new(&conf_dir, &helix_loader::runtime_dir()));
std::sync::Arc::new(theme::Loader::new(&helix_loader::config_dir(), &helix_loader::runtime_dir()));

let true_color = config.editor.true_color || crate::true_color();
let theme = config
Expand Down Expand Up @@ -114,8 +112,13 @@ impl Application {
// Unset path to prevent accidentally saving to the original tutor file.
doc_mut!(editor).set_path(None)?;
} else if args.edit_config {
let path = conf_dir.join("config.toml");
editor.open(path, Action::VerticalSplit)?;
editor.open(helix_loader::config_file(), Action::VerticalSplit)?;
} else if args.edit_lang_config {
// What if multiple from {--edit-config, --edit-lang-config, --view-log} are passed?
editor.open(helix_loader::lang_config_file(), Action::VerticalSplit)?;
} else if args.view_log {
// Can this be viewed in read-only mode?
editor.open(helix_loader::log_file(), Action::VerticalSplit)?;
} else if !args.files.is_empty() {
let first = &args.files[0].0; // we know it's not empty
if first.is_dir() {
Expand Down
4 changes: 4 additions & 0 deletions helix-term/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub struct Args {
pub verbosity: u64,
pub files: Vec<(PathBuf, Position)>,
pub edit_config: bool,
pub edit_lang_config: bool,
pub view_log: bool
}

impl Args {
Expand All @@ -30,6 +32,8 @@ impl Args {
"--help" => args.display_help = true,
"--tutor" => args.load_tutor = true,
"--edit-config" => args.edit_config = true,
"--edit-lang-config" => args.edit_lang_config = true,
"--view-log" => args.view_log = true,
"--health" => {
args.health = true;
args.health_arg = argv.next_if(|opt| !opt.starts_with('-'));
Expand Down
4 changes: 3 additions & 1 deletion helix-term/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ ARGS:

FLAGS:
-h, --help Prints help information
--edit-config Opens the helix config file
--edit-config Opens the helix configuration file
--edit-lang-config Opens the helix languages configuration file
--view-log Opens the helix log file for viewing
--tutor Loads the tutorial
--health [LANG] Checks for potential errors in editor setup
If given, checks for config errors in language LANG
Expand Down