Skip to content

Commit abf4c85

Browse files
committed
chore!: factor lsp-server and clean up VS Code plugin
1 parent ef43ddb commit abf4c85

File tree

33 files changed

+1150
-1448
lines changed

33 files changed

+1150
-1448
lines changed

Cargo.lock

Lines changed: 26 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[workspace]
22

33
resolver = "2"
4-
members = ["core/compiler", "core/gui", "core/lsp-server"]
4+
members = ["core/compiler", "core/gui", "core/lang-server"]
55

66
[workspace.dependencies]
77
anyhow = "1"

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ cargo b --release
4848
Add the following to your Neovim Lua configuration:
4949

5050
```lua
51-
vim.g.argon_lsp = {
51+
vim.g.argon = {
5252
argon_repo_path = '<absolute_path_to_argon_repo>'
5353
}
54-
vim.opt.runtimepath:append(vim.g.argon_lsp.argon_repo_path .. '/plugins/nvim')
54+
vim.opt.runtimepath:append(vim.g.argon.argon_repo_path .. '/plugins/nvim')
5555
vim.cmd([[autocmd BufRead,BufNewFile *.ar setfiletype argon]])
5656
```
5757

@@ -61,7 +61,7 @@ To open an example Argon workspace, run the following from the root directory of
6161
vim core/compiler/examples/argon_workspace/lib.ar
6262
```
6363

64-
Start the GUI by running `:ArgonLsp startGui`.
64+
Start the GUI by running `:Argon startGui`.
6565

6666
From within the GUI, type `:openCell test()` to open the `test` cell. You should now be able to edit layouts
6767
in both Neovim and the GUI.
@@ -76,7 +76,7 @@ Add the following key:
7676

7777
```json
7878
{
79-
"argonLsp.argonRepoDir": "<absolute_path_to_argon_repo>"
79+
"argon.argonRepoDir": "<absolute_path_to_argon_repo>"
8080
}
8181
```
8282

@@ -107,7 +107,7 @@ With this alias defined, you can now run:
107107
codear core/compiler/examples/argon_workspace
108108
```
109109

110-
Open the `lib.ar` file within the workspace. You can then start the GUI by running `Command Palette > Argon LSP: Start GUI`.
110+
Open the `lib.ar` file within the workspace. You can then start the GUI by running `Command Palette > Argon: Start GUI`.
111111

112112
> [!WARNING]
113113
> If you cannot find the command for starting the GUI but did not notice any obvious errors, you may be on an old version of VS Code.
@@ -205,7 +205,7 @@ constituent rectangles.
205205
## Logs
206206

207207
<!-- TODO: Implement commands to open GUI log -->
208-
Argon writes log messages to `~/.local/state/argon/lsp.log` (LSP server) and `~/local/state/argon/gui.log` (GUI).
208+
Argon writes log messages to `~/.local/state/argon/lang-server.log` (language server) and `~/local/state/argon/gui.log` (GUI).
209209
Log level can be set using the `ARGON_LOG` environment variable
210210
or in editor-specific configuration. If no configuration is specified, only errors will be logged.
211211
Log level configuration follows [`RUST_LOG`](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/index.html#filtering-events-with-environment-variables) syntax.
@@ -214,34 +214,34 @@ For performance, it is recommended to use `ARGON_LOG=warn` or `ARGON_LOG=error`
214214

215215
### Neovim
216216

217-
While the LSP is running, you can open the LSP logs using the `:ArgonLsp log` command
217+
While the language server is running, you can open the language server logs using the `:Argon log` command
218218

219-
To configure the log level, you can use the `vim.g.argon_lsp.log.level` key:
219+
To configure the log level, you can use the `vim.g.argon.log.level` key:
220220

221221
```lua
222-
vim.g.argon_lsp = {
222+
vim.g.argon = {
223223
-- ...
224224
log = {
225225
level = "debug"
226226
}
227227
}
228228
```
229229

230-
The Neovim plugin will then supply `ARGON_LOG=debug` when starting the LSP server and GUI.
230+
The Neovim plugin will then supply `ARGON_LOG=debug` when starting the language server and GUI.
231231

232232
### VS Code
233233

234-
While the LSP is running, you can open the LSP logs using the `Command Palette > Argon LSP: Open Log` command.
234+
While the language is running, you can open the language logs using the `Command Palette > Argon: Open Log` command.
235235

236-
To configure the log level, you can use the `argonLsp.log.level` key:
236+
To configure the log level, you can use the `argon.log.level` key:
237237

238238
```json
239239
{
240-
"argonLsp.log.level": "debug"
240+
"argon.log.level": "debug"
241241
}
242242
```
243243

244-
The VS Code plugin will then supply `ARGON_LOG=debug` when starting the LSP server and GUI.
244+
The VS Code plugin will then supply `ARGON_LOG=debug` when starting the language server and GUI.
245245

246246
## Contributing
247247

core/gui/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
edition = "2024"
55

66
[dependencies]
7-
lsp-server = { path = "../lsp-server" }
7+
lang-server = { path = "../lang-server" }
88
compiler = { path = "../compiler" }
99
gpui = { git = "https://github.com/ucb-substrate/zed", branch = "argon-dev" }
1010
smallvec = "1"

core/gui/src/editor/canvas.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use gpui::{
2020
};
2121
use indexmap::IndexSet;
2222
use itertools::Itertools;
23-
use lsp_server::rpc::DimensionParams;
23+
use lang_server::rpc::DimensionParams;
2424
use tower_lsp::lsp_types::MessageType;
2525

2626
use crate::{
@@ -1293,7 +1293,7 @@ impl LayoutCanvas {
12931293
.find(|name| !names.contains(name))
12941294
.unwrap();
12951295

1296-
state.lsp_client.draw_rect(
1296+
state.lang_server_client.draw_rect(
12971297
scope.span.clone(),
12981298
rect_name,
12991299
compile::BasicRect {
@@ -1319,14 +1319,14 @@ impl LayoutCanvas {
13191319
rect_tool.p0 = Some(p0);
13201320
}
13211321
} else {
1322-
state.lsp_client.show_message(
1322+
state.lang_server_client.show_message(
13231323
MessageType::ERROR,
13241324
"Cannot draw on an invisible layer.",
13251325
);
13261326
}
13271327
} else {
13281328
state
1329-
.lsp_client
1329+
.lang_server_client
13301330
.show_message(MessageType::ERROR, "No layer has been selected.");
13311331
}
13321332
}
@@ -1527,7 +1527,7 @@ impl LayoutCanvas {
15271527

15281528
let value = format!("{:?}", edge.2.stop - edge.2.start);
15291529
state
1530-
.lsp_client
1530+
.lang_server_client
15311531
.draw_dimension(
15321532
cell.output.cells[&selected_scope_addr.cell].scopes
15331533
[&selected_scope_addr.scope]
@@ -1582,7 +1582,7 @@ impl LayoutCanvas {
15821582
format!("- {}", intended_coord - coord)
15831583
};
15841584
let value = format!("{:?}", right.2.coord - left.2.coord);
1585-
state.lsp_client.draw_dimension(
1585+
state.lang_server_client.draw_dimension(
15861586
cell.output.cells[&selected_scope_addr.cell].scopes
15871587
[&selected_scope_addr.scope]
15881588
.span
@@ -1653,7 +1653,7 @@ impl LayoutCanvas {
16531653
)
16541654
};
16551655
state
1656-
.lsp_client
1656+
.lang_server_client
16571657
.draw_dimension(
16581658
cell.output.cells[&selected_scope_addr.cell].scopes
16591659
[&selected_scope_addr.scope]
@@ -1719,7 +1719,10 @@ impl LayoutCanvas {
17191719
}
17201720
if let Some(span) = selected_obj {
17211721
select_tool.selected_obj = Some(span.clone());
1722-
self.state.read(cx).lsp_client.select_rect(span.clone());
1722+
self.state
1723+
.read(cx)
1724+
.lang_server_client
1725+
.select_rect(span.clone());
17231726
} else {
17241727
select_tool.selected_obj = None;
17251728
}

core/gui/src/editor/input.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl TextInput {
256256
&& self
257257
.state
258258
.read(cx)
259-
.lsp_client
259+
.lang_server_client
260260
.edit_dimension(dim.clone(), self.content.to_string())
261261
.is_some()
262262
{
@@ -271,7 +271,10 @@ impl TextInput {
271271
#[allow(clippy::single_match)]
272272
match command.trim_start_matches(":") {
273273
"openCell" => {
274-
self.state.read(cx).lsp_client.open_cell(rest.to_string());
274+
self.state
275+
.read(cx)
276+
.lang_server_client
277+
.open_cell(rest.to_string());
275278
return true;
276279
}
277280
_ => {} // TODO: support other commands, reduce redundancy with rpc.rs

core/gui/src/editor/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ use compiler::compile::{
1111
use geometry::transform::TransformationMatrix;
1212
use gpui::*;
1313
use indexmap::{IndexMap, IndexSet};
14-
use lsp_server::rpc::GuiToLspAction;
14+
use lang_server::rpc::LangServerAction;
1515
use rgb::Rgb;
1616
use toolbars::{HierarchySideBar, LayerSideBar, TitleBar, ToolBar};
1717
use tower_lsp::lsp_types::MessageType;
1818

1919
use crate::{
2020
actions::{Redo, Undo},
2121
editor::{canvas::ToolState, input::TextInput},
22-
rpc::SyncGuiToLspClient,
22+
rpc::SyncLangServerClient,
2323
theme::{DARK_THEME, LIGHT_THEME, Theme},
2424
};
2525

@@ -74,7 +74,7 @@ pub struct EditorState {
7474
pub solved_cell: Entity<Option<CompileOutputState>>,
7575
pub hide_external_geometry: bool,
7676
pub layers: Entity<Layers>,
77-
pub lsp_client: SyncGuiToLspClient,
77+
pub lang_server_client: SyncLangServerClient,
7878
pub subscriptions: Vec<Subscription>,
7979
pub(crate) tool: Entity<ToolState>,
8080
}
@@ -234,7 +234,7 @@ impl EditorState {
234234
.iter()
235235
.any(|e| matches!(e.kind, ExecErrorKind::InvalidCell))
236236
{
237-
self.lsp_client
237+
self.lang_server_client
238238
.show_message(MessageType::ERROR, "Open cell is invalid");
239239
return;
240240
}
@@ -311,8 +311,8 @@ impl EditorState {
311311
}
312312

313313
impl Editor {
314-
pub fn new(cx: &mut Context<Self>, window: &mut Window, lsp_addr: SocketAddr) -> Self {
315-
let lsp_client = SyncGuiToLspClient::new(cx.to_async(), lsp_addr);
314+
pub fn new(cx: &mut Context<Self>, window: &mut Window, lang_server_addr: SocketAddr) -> Self {
315+
let lang_server_client = SyncLangServerClient::new(cx.to_async(), lang_server_addr);
316316
let solved_cell = cx.new(|_cx| None);
317317
let tool = cx.new(|_cx| ToolState::default());
318318
let layers = cx.new(|_cx| Layers {
@@ -332,7 +332,7 @@ impl Editor {
332332
tool,
333333
layers,
334334
subscriptions,
335-
lsp_client: lsp_client.clone(),
335+
lang_server_client: lang_server_client.clone(),
336336
}
337337
});
338338
let title_bar = cx.new(|_cx| TitleBar::new(&state));
@@ -362,7 +362,7 @@ impl Editor {
362362
canvas,
363363
text_input,
364364
};
365-
lsp_client.register_server(editor.clone());
365+
lang_server_client.register_server(editor.clone());
366366

367367
editor
368368
}
@@ -425,15 +425,15 @@ impl Editor {
425425
fn on_undo(&mut self, _: &Undo, _window: &mut Window, cx: &mut Context<Self>) {
426426
self.state
427427
.read(cx)
428-
.lsp_client
429-
.dispatch_action(GuiToLspAction::Undo);
428+
.lang_server_client
429+
.dispatch_action(LangServerAction::Undo);
430430
}
431431

432432
fn on_redo(&mut self, _: &Redo, _window: &mut Window, cx: &mut Context<Self>) {
433433
self.state
434434
.read(cx)
435-
.lsp_client
436-
.dispatch_action(GuiToLspAction::Redo);
435+
.lang_server_client
436+
.dispatch_action(LangServerAction::Redo);
437437
}
438438

439439
fn theme(&self, cx: &mut Context<Self>) -> &'static Theme {

core/gui/src/editor/toolbars.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use gpui::prelude::*;
55
use gpui::*;
66
use indexmap::{IndexMap, IndexSet};
77
use itertools::Itertools;
8-
use lsp_server::rpc::GuiToLspAction;
8+
use lang_server::rpc::LangServerAction;
99

1010
use crate::{
1111
actions::{DrawDim, DrawRect, SelectMode},
@@ -83,8 +83,8 @@ impl Render for ToolBar {
8383
Arc::new(|state, cx| {
8484
state
8585
.read(cx)
86-
.lsp_client
87-
.dispatch_action(GuiToLspAction::Undo);
86+
.lang_server_client
87+
.dispatch_action(LangServerAction::Undo);
8888
}),
8989
)),
9090
Some((
@@ -94,8 +94,8 @@ impl Render for ToolBar {
9494
Arc::new(|state, cx| {
9595
state
9696
.read(cx)
97-
.lsp_client
98-
.dispatch_action(GuiToLspAction::Redo);
97+
.lang_server_client
98+
.dispatch_action(LangServerAction::Redo);
9999
}),
100100
)),
101101
None,

0 commit comments

Comments
 (0)