Skip to content

Commit f113ec7

Browse files
authored
chore: postgrestools.jsonc -> postgres-language-server.jsonc (#559)
- primary config file is now `postgres-language-server.jsonc` - we still support `postgrestools.jsonc` as a fallback - added warnings to lsp (via message) and cli if deprecated config file is used - updated all references in the documentation <img width="1920" height="186" alt="Screenshot 2025-10-18 at 20 47 22" src="https://github.com/user-attachments/assets/babbd438-72f9-442a-98bb-5ae0cc134213" /> <img width="1920" height="173" alt="Screenshot 2025-10-18 at 21 22 45" src="https://github.com/user-attachments/assets/cfeda8c0-c83c-4e76-973f-31c64fe1a0a0" />
1 parent a1f1818 commit f113ec7

File tree

23 files changed

+293
-169
lines changed

23 files changed

+293
-169
lines changed

crates/pgt_analyse/src/options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl AnalyserRules {
4545
/// A set of information useful to the analyser infrastructure
4646
#[derive(Debug, Default)]
4747
pub struct AnalyserOptions {
48-
/// A data structured derived from the [`postgrestools.jsonc`] file
48+
/// A data structured derived from the [`postgres-language-server.jsonc`] file
4949
pub rules: AnalyserRules,
5050
}
5151

crates/pgt_analyser/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Let's assume that the rule we implement support the following options:
8181
- `threshold`: an integer between 0 and 255;
8282
- `behaviorExceptions`: an array of strings.
8383

84-
We would like to set the options in the `postgrestools.jsonc` configuration file:
84+
We would like to set the options in the `postgres-language-server.jsonc` configuration file:
8585

8686
```json
8787
{
@@ -143,9 +143,9 @@ We currently require implementing _serde_'s traits `Deserialize`/`Serialize`.
143143

144144
Also, we use other `serde` macros to adjust the JSON configuration:
145145

146-
- `rename_all = "camelCase"`: it renames all fields in camel-case, so they are in line with the naming style of the `postgrestools.jsonc`.
146+
- `rename_all = "camelCase"`: it renames all fields in camel-case, so they are in line with the naming style of the `postgres-language-server.jsonc`.
147147
- `deny_unknown_fields`: it raises an error if the configuration contains extraneous fields.
148-
- `default`: it uses the `Default` value when the field is missing from `postgrestools.jsonc`. This macro makes the field optional.
148+
- `default`: it uses the `Default` value when the field is missing from `postgres-language-server.jsonc`. This macro makes the field optional.
149149

150150
You can simply use a derive macros:
151151

crates/pgt_cli/src/cli_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub struct CliOptions {
2222
#[bpaf(long("verbose"), switch, fallback(false))]
2323
pub verbose: bool,
2424

25-
/// Set the file path to the configuration file, or the directory path to find `postgrestools.jsonc`.
25+
/// Set the file path to the configuration file, or the directory path to find `postgres-language-server.jsonc`.
2626
/// If used, it disables the default configuration file resolution.
2727
#[bpaf(long("config-path"), argument("PATH"), optional)]
2828
pub config_path: Option<String>,

crates/pgt_cli/src/commands/init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ pub(crate) fn init(mut session: CliSession) -> Result<(), CliDiagnostic> {
88
let fs = &mut session.app.fs;
99
let config = &mut PartialConfiguration::init();
1010
create_config(fs, config)?;
11-
let file_created = ConfigName::pgt_jsonc();
11+
let file_created = ConfigName::pgls_jsonc();
1212
session.app.console.log(markup! {
1313
"
14-
Welcome to the Postgres Language Tools! Let's get you started...
14+
Welcome to the Postgres Language Server! Let's get you started...
1515
1616
"<Info><Emphasis>"Files created "</Emphasis></Info>"
1717

crates/pgt_cli/src/commands/mod.rs

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use crate::{
77
};
88
use bpaf::Bpaf;
99
use pgt_configuration::{PartialConfiguration, partial_configuration};
10-
use pgt_console::Console;
11-
use pgt_fs::FileSystem;
10+
use pgt_console::{Console, ConsoleExt, markup};
11+
use pgt_fs::{ConfigName, FileSystem};
1212
use pgt_workspace::PartialConfigurationExt;
1313
use pgt_workspace::configuration::{LoadedConfiguration, load_configuration};
1414
use pgt_workspace::workspace::{RegisterProjectFolderParams, UpdateSettingsParams};
@@ -58,7 +58,7 @@ pub enum PgtCommand {
5858
changed: bool,
5959

6060
/// Use this to specify the base branch to compare against when you're using the --changed
61-
/// flag and the `defaultBranch` is not set in your `postgrestools.jsonc`
61+
/// flag and the `defaultBranch` is not set in your `postgres-language-server.jsonc`
6262
#[bpaf(long("since"), argument("REF"))]
6363
since: Option<String>,
6464

@@ -91,8 +91,13 @@ pub enum PgtCommand {
9191
)]
9292
log_path: PathBuf,
9393
/// Allows to set a custom file path to the configuration file,
94-
/// or a custom directory path to find `postgrestools.jsonc`
95-
#[bpaf(env("PGT_LOG_PREFIX_NAME"), long("config-path"), argument("PATH"))]
94+
/// or a custom directory path to find `postgres-language-server.jsonc`
95+
#[bpaf(
96+
env("PGT_LOG_PREFIX_NAME"),
97+
env("PGLS_LOG_PREFIX_NAME"),
98+
long("config-path"),
99+
argument("PATH")
100+
)]
96101
config_path: Option<PathBuf>,
97102
},
98103

@@ -127,8 +132,13 @@ pub enum PgtCommand {
127132
)]
128133
log_path: PathBuf,
129134
/// Allows to set a custom file path to the configuration file,
130-
/// or a custom directory path to find `postgrestools.jsonc`
131-
#[bpaf(env("PGT_CONFIG_PATH"), long("config-path"), argument("PATH"))]
135+
/// or a custom directory path to find `postgres-language-server.jsonc`
136+
#[bpaf(
137+
env("PGT_CONFIG_PATH"),
138+
env("PGLS_CONFIG_PATH"),
139+
long("config-path"),
140+
argument("PATH")
141+
)]
132142
config_path: Option<PathBuf>,
133143
/// Bogus argument to make the command work with vscode-languageclient
134144
#[bpaf(long("stdio"), hide, hide_usage, switch)]
@@ -183,8 +193,13 @@ pub enum PgtCommand {
183193
#[bpaf(long("stop-on-disconnect"), hide_usage)]
184194
stop_on_disconnect: bool,
185195
/// Allows to set a custom file path to the configuration file,
186-
/// or a custom directory path to find `postgrestools.jsonc`
187-
#[bpaf(env("PGT_CONFIG_PATH"), long("config-path"), argument("PATH"))]
196+
/// or a custom directory path to find `postgres-language-server.jsonc`
197+
#[bpaf(
198+
env("PGT_CONFIG_PATH"),
199+
env("PGLS_CONFIG_PATH"),
200+
long("config-path"),
201+
argument("PATH")
202+
)]
188203
config_path: Option<PathBuf>,
189204
},
190205
#[bpaf(command("__print_socket"), hide)]
@@ -295,6 +310,19 @@ pub(crate) trait CommandRunner: Sized {
295310
let loaded_configuration =
296311
load_configuration(fs, cli_options.as_configuration_path_hint())?;
297312

313+
// Check for deprecated config filename
314+
if let Some(config_path) = &loaded_configuration.file_path {
315+
if let Some(file_name) = config_path.file_name().and_then(|n| n.to_str()) {
316+
if ConfigName::is_deprecated(file_name) {
317+
console.log(markup! {
318+
<Warn>"Warning: "</Warn>"You are using the deprecated config filename '"<Emphasis>"postgrestools.jsonc"</Emphasis>"'. \
319+
Please rename it to '"<Emphasis>"postgres-language-server.jsonc"</Emphasis>"'. \
320+
Support for the old filename will be removed in a future version.\n"
321+
});
322+
}
323+
}
324+
}
325+
298326
let configuration_path = loaded_configuration.directory_path.clone();
299327
let configuration = self.merge_configuration(loaded_configuration, fs, console)?;
300328
let vcs_base_path = configuration_path.or(fs.working_directory());

crates/pgt_cli/src/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub enum CliDiagnostic {
4747
IoError(IoDiagnostic),
4848
/// The daemon is not running
4949
ServerNotRunning(ServerNotRunning),
50-
/// The end configuration (`postgrestools.jsonc` + other options) is incompatible with the command
50+
/// The end configuration (`postgres-language-server.jsonc` + other options) is incompatible with the command
5151
IncompatibleEndConfiguration(IncompatibleEndConfiguration),
5252
/// No files processed during the file system traversal
5353
NoFilesWereProcessed(NoFilesWereProcessed),
@@ -390,7 +390,7 @@ impl CliDiagnostic {
390390
Self::ServerNotRunning(ServerNotRunning)
391391
}
392392

393-
/// Emitted when the end configuration (`postgrestools.jsonc` file + CLI arguments + LSP configuration)
393+
/// Emitted when the end configuration (`postgres-language-server.jsonc` file + CLI arguments + LSP configuration)
394394
/// results in a combination of options that doesn't allow to run the command correctly.
395395
///
396396
/// A reason needs to be provided

crates/pgt_configuration/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! This module contains the configuration of `postgrestools.jsonc`
1+
//! This module contains the configuration of `postgres-language-server.jsonc`
22
//!
33
//! The configuration is divided by "tool".
44

crates/pgt_configuration/src/vcs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct VcsConfiguration {
2828
pub use_ignore_file: bool,
2929

3030
/// The folder where we should check for VCS files. By default, we will use the same
31-
/// folder where `postgrestools.jsonc` was found.
31+
/// folder where `postgres-language-server.jsonc` was found.
3232
///
3333
/// If we can't find the configuration, it will attempt to use the current working directory.
3434
/// If no current working directory can't be found, we won't use the VCS integration, and a diagnostic

crates/pgt_fs/src/fs.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ mod os;
1919
pub struct ConfigName;
2020

2121
impl ConfigName {
22-
const PGT_JSONC: [&'static str; 1] = ["postgrestools.jsonc"];
22+
const PGLS_JSONC: [&'static str; 2] = ["postgres-language-server.jsonc", "postgrestools.jsonc"];
2323

24-
pub const fn pgt_jsonc() -> &'static str {
25-
Self::PGT_JSONC[0]
24+
pub fn is_deprecated(file_name: &str) -> bool {
25+
file_name == Self::PGLS_JSONC[1]
2626
}
2727

28-
pub const fn file_names() -> [&'static str; 1] {
29-
Self::PGT_JSONC
28+
pub const fn pgls_jsonc() -> &'static str {
29+
Self::PGLS_JSONC[0]
30+
}
31+
32+
pub const fn file_names() -> [&'static str; 2] {
33+
Self::PGLS_JSONC
3034
}
3135
}
3236

crates/pgt_fs/src/path.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::ConfigName;
2121
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
2222
// NOTE: The order of the variants is important, the one on the top has the highest priority
2323
pub enum FileKind {
24-
/// A configuration file has the highest priority. It's usually `postgrestools.jsonc`
24+
/// A configuration file has the highest priority. It's usually `postgres-language-server.jsonc`
2525
///
2626
/// Other third-party configuration files might be added in the future
2727
Config,
@@ -173,10 +173,10 @@ impl PgTPath {
173173
}
174174

175175
/// The priority of the file.
176-
/// - `postgrestools.jsonc` has the highest priority
176+
/// - `postgres-language-server.jsonc` has the highest priority
177177
/// - Other files are considered as files to handle
178178
fn priority(file_name: &OsStr) -> FileKinds {
179-
if file_name == ConfigName::pgt_jsonc() {
179+
if ConfigName::file_names().iter().any(|f| *f == file_name) {
180180
FileKind::Config.into()
181181
} else {
182182
FileKind::Handleable.into()

0 commit comments

Comments
 (0)