-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add initialization options (#6)
* feat: add initialization options * docs: add section about how to configure * refactor: clippy
- Loading branch information
Showing
6 changed files
with
108 additions
and
16 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,57 @@ | ||
/* | ||
* This file is part of discord-presence. Extension for Zed that adds support for Discord Rich Presence using LSP. | ||
* | ||
* Copyright (c) 2024 Steinhübl | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
*/ | ||
|
||
use serde_json::Value; | ||
|
||
#[derive(Debug)] | ||
pub struct Configuration { | ||
pub state: String, | ||
pub details: String, | ||
pub git_integration: bool, | ||
} | ||
|
||
impl Configuration { | ||
pub fn new() -> Self { | ||
Self { | ||
state: String::from("Working on {filename}"), | ||
details: String::from("In {workspace}"), | ||
git_integration: true, | ||
} | ||
} | ||
|
||
pub fn set(&mut self, initialization_options: Option<Value>) { | ||
if initialization_options.is_none() { | ||
return; | ||
} | ||
|
||
let initialization_options = initialization_options.unwrap(); | ||
|
||
if let Some(state) = initialization_options.get("state") { | ||
self.state = state.as_str().unwrap().to_string(); | ||
} | ||
|
||
if let Some(details) = initialization_options.get("details") { | ||
self.details = details.as_str().unwrap().to_string(); | ||
} | ||
|
||
if let Some(git_integration) = initialization_options.get("git_integration") { | ||
self.git_integration = git_integration.as_bool().unwrap_or(true); | ||
} | ||
} | ||
} |
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