diff --git a/.github/workflows/build-debug-harper-ls.yml b/.github/workflows/build-debug-harper-ls.yml new file mode 100644 index 00000000..e0362782 --- /dev/null +++ b/.github/workflows/build-debug-harper-ls.yml @@ -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 diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rs index b29d082f..63cf0ab7 100644 --- a/harper-ls/src/backend.rs +++ b/harper-ls/src/backend.rs @@ -22,6 +22,8 @@ use tower_lsp::lsp_types::{ InitializeResult, InitializedParams, MessageType, PublishDiagnosticsParams, Range, ServerCapabilities, TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, TextDocumentSyncSaveOptions, Url, + DocumentDiagnosticParams, DocumentDiagnosticReportResult, DocumentDiagnosticReport, + RelatedFullDocumentDiagnosticReport, FullDocumentDiagnosticReport, }; use tower_lsp::{Client, LanguageServer}; use tracing::{error, info}; @@ -163,6 +165,14 @@ impl Backend { let mut doc_lock = self.doc_state.lock().await; let config_lock = self.config.read().await; + let mut m = "true"; + if doc_lock.contains_key(&url.clone()) == false { + m = "false" + } + self.client + .log_message(MessageType::INFO, m) + .await; + let dict = Arc::new(self.generate_file_dictionary(url).await?); let doc_state = doc_lock.entry(url.clone()).or_insert(DocumentState { @@ -172,6 +182,8 @@ impl Backend { ..Default::default() }); + doc_state.linter = LintGroup::new(config_lock.lint_config, dict.clone()); + if doc_state.dict != dict { doc_state.dict = dict.clone(); doc_state.linter = LintGroup::new(config_lock.lint_config, dict.clone()); @@ -481,6 +493,29 @@ impl LanguageServer for Backend { self.update_config_from_obj(params.settings).await; } + async fn diagnostic( + &self, + params: DocumentDiagnosticParams, + ) -> Result { + let _ = self + .update_document_from_file(¶ms.text_document.uri, None) + .await; + let diagnostics = self.generate_diagnostics(¶ms.text_document.uri).await; + + Ok(DocumentDiagnosticReportResult::Report( + DocumentDiagnosticReport::Full( + RelatedFullDocumentDiagnosticReport { + full_document_diagnostic_report: FullDocumentDiagnosticReport { + items: diagnostics, + ..Default::default() + }, + ..Default::default() + } + ) + ) + ) + } + async fn code_action(&self, params: CodeActionParams) -> Result> { let actions = self .generate_code_actions(¶ms.text_document.uri, params.range)