Skip to content

Commit

Permalink
refactor version matching logic
Browse files Browse the repository at this point in the history
  • Loading branch information
washanhanzi committed Nov 16, 2024
1 parent 62b41a6 commit 584fad2
Show file tree
Hide file tree
Showing 15 changed files with 1,238 additions and 874 deletions.
914 changes: 593 additions & 321 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 10 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,25 @@ repository = "https://github.com/washanhanzi/cargo-appraiser"

[dependencies]
serde_json = "1.0"
taplo = "0.13.2"
taplo = "0.13"
tokio = { version = "1.41", features = ["full", "macros", "rt-multi-thread"] }
lsp-async-stub = "0.6.4"
serde = { version = "1.0", features = ["derive"] }
parking_lot = "0.12.3"
parking_lot = "0.12"
anyhow = "1.0"
clap = { version = "4.5.20", features = ["derive"] }
once_cell = "1.20.2"
semver = "1.0.23"
tracing-subscriber = "0.3.18"
futures = "0.3.31"
clap = { version = "4.5", features = ["derive"] }
once_cell = "1.20"
semver = "1.0"
tracing-subscriber = "0.3"
futures = "0.3"
tracing = "0"
openssl = { version = '0.10', optional = true }
reqwest = { version = "0.12.8", features = ["json"] }
thiserror = "1.0.64"
unicode-xid = "0.2.6"
executable_path_finder = "0"
internment = "0.8"
thiserror = "2.0"
executable_path_finder = "0.0.5"
petgraph = "0.6.5"
tokio-util = { version = "0.7.12", features = ["time"] }

unicode-xid = "0.2.6"

cargo = { package = "my-cargo", git = "https://github.com/washanhanzi/cargo.git", branch = "master" }
tower-lsp = { git = "https://github.com/washanhanzi/tower-lsp", branch = "master", features = [
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
- hover on git dependency will show the git reference and commit
- hover on `features` will show available features, hover on a feature name
will show its values
- code action for dependency version
- code action on version
- `cargo update` command on version's code action

# Config

Expand Down
8 changes: 4 additions & 4 deletions editor/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cargo-appraiser",
"displayName": "cargo-appraiser",
"description": "LSP for Cargo.toml",
"version": "0.0.5",
"version": "0.0.6",
"icon": "image/icon.webp",
"publisher": "washan",
"license": "SEE LICENSE IN LICENSE",
Expand Down Expand Up @@ -61,17 +61,17 @@
"test": "pnpm vitest"
},
"devDependencies": {
"@types/node": "~20.16.11",
"@types/node": "~20.16.15",
"@types/semver": "^7.5.8",
"@types/vscode": "^1.90.0",
"@types/vscode": "1.90.0",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@vscode/test-cli": "^0.0.9",
"@vscode/test-electron": "^2.4.1",
"esbuild": "^0.21.5",
"eslint": "^8.57.1",
"npm-run-all": "^4.1.5",
"typescript": "^5.6.2",
"typescript": "^5.6.3",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
},
Expand Down
412 changes: 215 additions & 197 deletions editor/code/pnpm-lock.yaml

Large diffs are not rendered by default.

23 changes: 11 additions & 12 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ use once_cell::sync::Lazy;
use serde::Deserialize;
use std::sync::RwLock;

use crate::decoration::DecorationFormatter;
use crate::decoration::{CompiledFormatter, DecorationFormatter};

#[derive(Default, Debug, Deserialize, Clone)]
#[derive(Default, Debug, Clone)]
pub struct Config {
pub decoration_formatter: CompiledFormatter,
}

#[derive(Default, Debug, Deserialize, Clone)]
pub struct UserConfig {
#[serde(flatten)]
pub renderer: RendererConfig,
}
Expand All @@ -19,15 +24,9 @@ pub struct RendererConfig {

pub static GLOBAL_CONFIG: Lazy<RwLock<Config>> = Lazy::new(|| RwLock::new(Config::default()));

pub fn initialize_config(mut config: Config) {
let mut global_config = GLOBAL_CONFIG.write().unwrap();
*global_config = config;
}

pub fn update_config<F>(update_fn: F)
where
F: FnOnce(&mut Config),
{
pub fn initialize_config(config: UserConfig) {
let mut global_config = GLOBAL_CONFIG.write().unwrap();
update_fn(&mut global_config);
*global_config = Config {
decoration_formatter: config.renderer.decoration_formatter.compile(),
};
}
Loading

0 comments on commit 584fad2

Please sign in to comment.