From 3c7da27ebd8f2cf1a3b12b15b144f7e003aefd56 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 19 Jun 2024 11:34:08 +0200 Subject: [PATCH] 0.1.1: Add SCLS_CONFIG_SUBDIRECTORY to override default lookup dir --- CHANGELOG.md | 3 ++- Cargo.lock | 2 +- Cargo.toml | 13 +++++++++---- README.md | 2 ++ src/main.rs | 12 +++++++----- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b92192..dcd8f36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. - diff --git a/Cargo.lock b/Cargo.lock index 3ed8771..edb1c67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -655,7 +655,7 @@ dependencies = [ [[package]] name = "simple-completion-language-server" -version = "0.1.0" +version = "0.1.1" dependencies = [ "aho-corasick", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 256617d..be8ed7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "simple-completion-language-server" -version = "0.1.0" +version = "0.1.1" edition = "2021" [[bin]] @@ -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" } @@ -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"] } diff --git a/README.md b/README.md index 81cc272..927fbc7 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/main.rs b/src/main.rs index 8a9d612..850732b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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}; @@ -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() @@ -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");