Skip to content

Commit

Permalink
0.1.1: Add SCLS_CONFIG_SUBDIRECTORY to override default lookup dir
Browse files Browse the repository at this point in the history
  • Loading branch information
osiewicz committed Jun 19, 2024
1 parent 63b5781 commit 8c1b315
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# 0.1.1
- Added support for SCLS_CONFIG_SUBDIRECTORY to override default lookup directory for snippets.
# 0.0.1
- Initial release as a fork under zed-industries.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ language-servers = [ "scls" ]

Read snippets from dir `~/.config/helix/snippets` or specify snippets path via `SNIPPETS_PATH` env.

Default lookup directory can be overriden via `SCLS_CONFIG_SUBDIRECTORY` as well (e.g. when SCLS_CONFIG_SUBDIRECTORY = `vim`, SCLS will perform it's lookups in `~/.config/vim` instead)

Currently, it supports our own `toml` format and vscode `json` (a basic effort).

Filename used as snippet scope (language), filename `snippets.(toml|json)` will not attach scope to snippets.
Expand Down
12 changes: 7 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use etcetera::base_strategy::{choose_base_strategy, BaseStrategy};
use std::collections::HashMap;
use std::{collections::HashMap, path::PathBuf};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use xshell::{cmd, Shell};

Expand Down Expand Up @@ -132,7 +132,9 @@ async fn main() {

let strategy = choose_base_strategy().expect("Unable to find the config directory!");
let mut config_dir = strategy.config_dir();
config_dir.push("helix");
let config_subdirectory_name =
std::env::var("SCLS_CONFIG_SUBDIRECTORY").unwrap_or_else(|_| "helix".to_owned());
config_dir.push(config_subdirectory_name);

let start_options = StartOptions {
home_dir: etcetera::home_dir()
Expand All @@ -141,21 +143,21 @@ async fn main() {
.expect("Unable to get home dir as string!")
.to_string(),
snippets_path: std::env::var("SNIPPETS_PATH")
.map(std::path::PathBuf::from)
.map(PathBuf::from)
.unwrap_or_else(|_| {
let mut filepath = config_dir.clone();
filepath.push("snippets");
filepath
}),
external_snippets_config_path: std::env::var("EXTERNAL_SNIPPETS_CONFIG")
.map(std::path::PathBuf::from)
.map(PathBuf::from)
.unwrap_or_else(|_| {
let mut filepath = config_dir.clone();
filepath.push("external-snippets.toml");
filepath
}),
unicode_input_path: std::env::var("UNICODE_INPUT_PATH")
.map(std::path::PathBuf::from)
.map(PathBuf::from)
.unwrap_or_else(|_| {
let mut filepath = config_dir.clone();
filepath.push("unicode-input");
Expand Down

0 comments on commit 8c1b315

Please sign in to comment.