-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make the LSP options configurable Take into account the configuration sent by the client through [`InitializeParams.initializationOptions`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#initializeParams). This is currently used to set the limits for the background evaluation, although it also creates the infrastructure for setting more things. * Fix the doc comments for the config * Remove a useless explicit Default instance Replace it by the derived one (thanks clippy) * Comment fixes Co-Authored-By: Yann Hamdaoui <yann.hamdaoui@tweag.io> * Simplify the nls config definition `#[serde(default)]` applied to a whole struct is enough for it to do the right thing with the `Default` trait. Makes the module significantly nicer to read. --------- Co-authored-by: Yann Hamdaoui <yann.hamdaoui@tweag.io>
- Loading branch information
1 parent
af5d1b5
commit 32a4b67
Showing
7 changed files
with
146 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//! Configuration for the Nickel Language Server | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use std::time::Duration; | ||
|
||
/** | ||
Limits to appy to the LSP background evaluator. | ||
If an evaluation reaches one of these limits, it will be canceled and the offending file will be | ||
temporarily blacklisted. | ||
*/ | ||
#[derive(Debug, Deserialize, Serialize)] | ||
#[serde(default)] | ||
pub struct LspEvalLimits { | ||
/// Time out at which to cancel the background evaluation | ||
pub timeout: Duration, | ||
/// The maximum recursion level to allow in the background evaluator | ||
pub recursion_limit: usize, | ||
} | ||
impl Default for LspEvalLimits { | ||
fn default() -> Self { | ||
LspEvalLimits { | ||
timeout: Duration::from_secs(1), | ||
recursion_limit: 128, | ||
} | ||
} | ||
} | ||
|
||
/// The configuration of the LSP evaluator | ||
#[derive(Debug, Deserialize, Serialize)] | ||
#[serde(default)] | ||
pub struct LspEvalConfig { | ||
pub eval_limits: LspEvalLimits, | ||
/// The duration during which a file that broke the background evaluator will be blacklisted | ||
/// from it | ||
pub blacklist_duration: Duration, | ||
} | ||
|
||
impl Default for LspEvalConfig { | ||
fn default() -> Self { | ||
LspEvalConfig { | ||
eval_limits: Default::default(), | ||
blacklist_duration: Duration::from_secs(30), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize, Default)] | ||
#[serde(default)] | ||
pub struct LspConfig { | ||
/// Configuration for the background evaluator in the LSP | ||
pub eval_config: LspEvalConfig, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters