Skip to content

Commit

Permalink
build-debug
Browse files Browse the repository at this point in the history
  • Loading branch information
mcecode committed Dec 24, 2024
1 parent 0535b80 commit 68b2314
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 5 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build-debug-harper-ls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build Debug

on:
push:
branches: ["build-debug-harper-ls"]

jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: x86_64-unknown-linux-gnu
- name: Build
run: cargo +stable build --locked --profile dev --bin harper-ls --target x86_64-unknown-linux-gnu
- name: Archive
run: |
cd target/x86_64-unknown-linux-gnu/debug
tar -czf ../../../harper-ls.tar.gz harper-ls
cd -
- name: Upload
uses: actions/upload-artifact@v4
with:
name: debug-build
path: harper-ls.tar.gz
66 changes: 61 additions & 5 deletions harper-ls/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ use tower_lsp::jsonrpc::Result;
use tower_lsp::lsp_types::notification::PublishDiagnostics;
use tower_lsp::lsp_types::{
CodeActionOrCommand, CodeActionParams, CodeActionProviderCapability, CodeActionResponse,
Command, ConfigurationItem, Diagnostic, DidChangeConfigurationParams,
Command, ConfigurationItem, DeleteFilesParams, Diagnostic, DidChangeConfigurationParams,
DidChangeTextDocumentParams, DidCloseTextDocumentParams, DidOpenTextDocumentParams,
DidSaveTextDocumentParams, ExecuteCommandOptions, ExecuteCommandParams, InitializeParams,
InitializeResult, InitializedParams, MessageType, PublishDiagnosticsParams, Range,
ServerCapabilities, TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions,
TextDocumentSyncSaveOptions, Url,
DidSaveTextDocumentParams, ExecuteCommandOptions, ExecuteCommandParams, FileOperationFilter,
FileOperationPattern, FileOperationPatternKind, FileOperationRegistrationOptions,
InitializeParams, InitializeResult, InitializedParams, MessageType, PublishDiagnosticsParams,
Range, ServerCapabilities, TextDocumentSyncCapability, TextDocumentSyncKind,
TextDocumentSyncOptions, TextDocumentSyncSaveOptions, Url,
WorkspaceFileOperationsServerCapabilities, WorkspaceServerCapabilities,
};
use tower_lsp::{Client, LanguageServer};
use tracing::{error, info};
Expand Down Expand Up @@ -361,6 +363,32 @@ impl LanguageServer for Backend {
save: Some(TextDocumentSyncSaveOptions::Supported(true)),
},
)),
workspace: Some(WorkspaceServerCapabilities {
workspace_folders: None,
file_operations: Some(WorkspaceFileOperationsServerCapabilities {
did_delete: Some(FileOperationRegistrationOptions {
filters: vec![
FileOperationFilter {
scheme: Some("file".to_owned()),
pattern: FileOperationPattern {
glob: "**/*".to_owned(),
matches: Some(FileOperationPatternKind::File),
options: None,
},
},
FileOperationFilter {
scheme: Some("file".to_owned()),
pattern: FileOperationPattern {
glob: "**/*".to_owned(),
matches: Some(FileOperationPatternKind::Folder),
options: None,
},
},
],
}),
..Default::default()
}),
}),
..Default::default()
},
})
Expand Down Expand Up @@ -407,6 +435,34 @@ impl LanguageServer for Backend {

async fn did_close(&self, _params: DidCloseTextDocumentParams) {}

async fn did_delete_files(&self, params: DeleteFilesParams) {
let mut doc_lock = self.doc_state.lock().await;
let mut urls_to_clear = Vec::new();

for file in params.files {
doc_lock.retain(|url, _| {
// `file.uri` could be a directory so use `starts_with` rather than `==`
let to_remove = url.to_string().starts_with(&file.uri);

if to_remove {
urls_to_clear.push(url.clone());
}

!to_remove
});
}

for url in &urls_to_clear {
self.client
.send_notification::<PublishDiagnostics>(PublishDiagnosticsParams {
uri: url.clone(),
diagnostics: vec![],
version: None,
})
.await;
}
}

async fn execute_command(&self, params: ExecuteCommandParams) -> Result<Option<Value>> {
let mut string_args = params
.arguments
Expand Down

0 comments on commit 68b2314

Please sign in to comment.