Use proper NodeRuntime in the formatter interface

This commit is contained in:
Kirill Bulatov
2023-10-11 12:56:28 +03:00
parent a420d9cdc7
commit a8387b8b19
10 changed files with 71 additions and 20 deletions
+1
View File
@@ -10,6 +10,7 @@ path = "src/prettier.rs"
language = { path = "../language" }
gpui = { path = "../gpui" }
fs = { path = "../fs" }
node_runtime = { path = "../node_runtime"}
serde.workspace = true
serde_derive.workspace = true
@@ -0,0 +1 @@
node_modules/
+29
View File
@@ -0,0 +1,29 @@
{
"name": "prettier_server",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "prettier_server",
"version": "1.0.0",
"dependencies": {
"prettier": "^3.0.3"
}
},
"node_modules/prettier": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz",
"integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==",
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
}
}
}
+12 -9
View File
@@ -1,11 +1,14 @@
{
"name": "prettier_server",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"start": "node src/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Zed Industries"
"name": "prettier_server",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"start": "node src/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Zed Industries",
"dependencies": {
"prettier": "^3.0"
}
}
@@ -17,6 +17,7 @@ function handleData() {
const length = buffer.readUInt32LE(0);
console.log(length);
console.log(buffer.toString());
if (buffer.length < 4 + length) {
return;
}
+4 -5
View File
@@ -1,18 +1,17 @@
use std::collections::{HashMap, VecDeque};
pub use std::path::{Path, PathBuf};
pub use std::sync::Arc;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use anyhow::Context;
use fs::Fs;
use gpui::ModelHandle;
use language::{Buffer, Diff};
use node_runtime::NodeRuntime;
pub struct Prettier {
_private: (),
}
pub struct NodeRuntime;
#[derive(Debug)]
pub struct LocateStart {
pub worktree_root_path: Arc<Path>,
@@ -143,7 +142,7 @@ impl Prettier {
}
}
pub async fn start(prettier_path: &Path, node: Arc<NodeRuntime>) -> anyhow::Result<Self> {
pub async fn start(prettier_path: &Path, node: Arc<dyn NodeRuntime>) -> anyhow::Result<Self> {
todo!()
}