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 c2c81d7 commit 3c098ca
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 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: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "simple-completion-language-server"
version = "0.1.0"
version = "0.1.1"
edition = "2021"

[[bin]]
Expand All @@ -11,7 +11,12 @@ path = "src/main.rs"
anyhow = "1.0"
ropey = "1.6"
aho-corasick = "1.1"
tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-std", "macros"] }
tokio = { version = "1", features = [
"rt",
"rt-multi-thread",
"io-std",
"macros",
] }
tower-lsp = { version = "0.20", features = ["runtime-tokio"] }
serde = { version = "1", features = ["serde_derive"] }
serde_json = { version = "1" }
Expand All @@ -21,8 +26,8 @@ etcetera = "0.8"
xshell = "0.2"

tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
tracing-appender = "0.2"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }
tracing-appender = "0.2"

[dev-dependencies]
test-log = { version = "0.2", default-features = false, features = ["trace"] }
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 3c098ca

Please sign in to comment.