Skip to content

Commit 733c8f2

Browse files
committed
chore: merge main
2 parents 9f9cf9b + 6469ce3 commit 733c8f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2256
-446
lines changed

.github/workflows/pull_request.yml

+30-15
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ jobs:
3333
steps:
3434
- name: Checkout PR branch
3535
uses: actions/checkout@v4
36+
3637
- name: Free Disk Space
3738
uses: ./.github/actions/free-disk-space
39+
3840
- name: Install toolchain
3941
uses: moonrepo/setup-rust@v1
4042
with:
@@ -43,15 +45,23 @@ jobs:
4345
cache-base: main
4446
env:
4547
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46-
- name: Setup Biome
47-
uses: biomejs/setup-biome@v2
48-
with:
49-
version: latest
48+
49+
- name: Setup Bun
50+
uses: oven-sh/setup-bun@v2
51+
52+
- name: Install JS dependencies
53+
run: bun install
54+
55+
- name: Setup Just
56+
uses: extractions/setup-just@v3
57+
58+
- name: Echo Tool Versions
59+
run: |
60+
just format-ci-versions
61+
5062
- name: Run format
5163
run: |
52-
cargo fmt --all --check
53-
taplo format --check
54-
biome format
64+
just format-ci
5565
5666
actionlint:
5767
name: Lint GitHub Actions
@@ -96,17 +106,22 @@ jobs:
96106
- name: Setup sqlx-cli
97107
run: cargo install sqlx-cli
98108

99-
- name: Setup Biome
100-
uses: biomejs/setup-biome@v2
101-
with:
102-
version: latest
109+
- name: Setup Bun
110+
uses: oven-sh/setup-bun@v2
111+
112+
- name: Install JS dependencies
113+
run: bun install
114+
115+
- name: Setup Just
116+
uses: extractions/setup-just@v3
117+
118+
- name: Echo Tool Versions
119+
run: |
120+
just lint-ci-versions
103121
104122
- name: Run Lints
105123
run: |
106-
cargo sqlx prepare --check --workspace
107-
cargo clippy --fix
108-
cargo run -p rules_check
109-
biome lint --write
124+
just lint-ci
110125
111126
- name: Check for changes
112127
run: |

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
GITHUB_REPO: ${{ github.repository }}
132132

133133
- name: Ensure tag matches
134-
if: ${{ steps.create_changelog.outputs.version }} != ${{ needs.extract_version.outputs.version }}
134+
if: steps.create_changelog.outputs.version != needs.extract_version.outputs.version
135135
run: exit 1
136136

137137
- name: 👇 Download Artifacts

.sqlx/query-47bbad9dc2cec0231ef726790a9b0a5d9c628c6a2704f5523fb9ee45414350c7.json

+62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ homepage = "https://supabase.com/"
1010
keywords = ["linter", "typechecker", "postgres", "language-server"]
1111
license = "MIT"
1212
repository = "https://github.com/supabase-community/postgres-language-server"
13-
rust-version = "1.85.0"
13+
rust-version = "1.86.0"
1414

1515
[workspace.dependencies]
1616
# supporting crates unrelated to postgres

cliff.toml

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,17 @@ body = """
2727
{{ commit.message | upper_first }}\
2828
{% endfor %}
2929
{% endfor %}\n
30+
31+
## Contributors
32+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
33+
* @{{ contributor.username }} made their first contribution in #{{ contributor.pr_number }} 🎉
34+
{%- endfor -%}
35+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=false) %}
36+
* @{{ contributor.username }}
37+
{%- endfor -%}\n
3038
"""
3139
# template for the changelog footer
3240
footer = """
33-
<!-- generated by git-cliff -->
3441
"""
3542
# remove the leading and trailing s
3643
trim = true

crates/pgt_cli/src/cli_options.rs

-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ pub struct CliOptions {
1818
#[bpaf(long("use-server"), switch, fallback(false))]
1919
pub use_server: bool,
2020

21-
/// Skip connecting to the database and only run checks that don't require a database connection.
22-
#[bpaf(long("skip-db"), switch, fallback(false))]
23-
pub skip_db: bool,
24-
2521
/// Print additional diagnostics, and some diagnostics show more information. Also, print out what files were processed and which ones were modified.
2622
#[bpaf(long("verbose"), switch, fallback(false))]
2723
pub verbose: bool,

crates/pgt_cli/src/commands/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ pub(crate) trait CommandRunner: Sized {
307307
configuration,
308308
vcs_base_path,
309309
gitignore_matches,
310-
skip_db: cli_options.skip_db,
311310
})?;
312311

313312
let execution = self.get_execution(cli_options, console, workspace)?;

crates/pgt_cli/src/execute/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ pub enum TraversalMode {
7676
Dummy,
7777
/// This mode is enabled when running the command `check`
7878
Check {
79-
/// The type of fixes that should be applied when analyzing a file.
80-
///
81-
/// It's [None] if the `check` command is called without `--apply` or `--apply-suggested`
82-
/// arguments.
79+
// The type of fixes that should be applied when analyzing a file.
80+
//
81+
// It's [None] if the `check` command is called without `--apply` or `--apply-suggested`
82+
// arguments.
8383
// fix_file_mode: Option<FixFileMode>,
84-
8584
/// An optional tuple.
8685
/// 1. The virtual path to the file
8786
/// 2. The content of the file

crates/pgt_completions/src/builder.rs

+72-27
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,92 @@
1-
use crate::item::CompletionItem;
1+
use crate::{
2+
CompletionItemKind, CompletionText,
3+
context::CompletionContext,
4+
item::CompletionItem,
5+
relevance::{filtering::CompletionFilter, scoring::CompletionScore},
6+
};
27

3-
pub(crate) struct CompletionBuilder {
4-
items: Vec<CompletionItem>,
8+
pub(crate) struct PossibleCompletionItem<'a> {
9+
pub label: String,
10+
pub description: String,
11+
pub kind: CompletionItemKind,
12+
pub score: CompletionScore<'a>,
13+
pub filter: CompletionFilter<'a>,
14+
pub completion_text: Option<CompletionText>,
515
}
616

7-
impl CompletionBuilder {
8-
pub fn new() -> Self {
9-
CompletionBuilder { items: vec![] }
17+
pub(crate) struct CompletionBuilder<'a> {
18+
items: Vec<PossibleCompletionItem<'a>>,
19+
ctx: &'a CompletionContext<'a>,
20+
}
21+
22+
impl<'a> CompletionBuilder<'a> {
23+
pub fn new(ctx: &'a CompletionContext) -> Self {
24+
CompletionBuilder { items: vec![], ctx }
1025
}
1126

12-
pub fn add_item(&mut self, item: CompletionItem) {
27+
pub fn add_item(&mut self, item: PossibleCompletionItem<'a>) {
1328
self.items.push(item);
1429
}
1530

16-
pub fn finish(mut self) -> Vec<CompletionItem> {
17-
self.items
18-
.sort_by(|a, b| b.score.cmp(&a.score).then_with(|| a.label.cmp(&b.label)));
31+
pub fn finish(self) -> Vec<CompletionItem> {
32+
let mut items: Vec<PossibleCompletionItem> = self
33+
.items
34+
.into_iter()
35+
.filter(|i| i.filter.is_relevant(self.ctx).is_some())
36+
.collect();
37+
38+
for item in items.iter_mut() {
39+
item.score.calc_score(self.ctx);
40+
}
41+
42+
items.sort_by(|a, b| {
43+
b.score
44+
.get_score()
45+
.cmp(&a.score.get_score())
46+
.then_with(|| a.label.cmp(&b.label))
47+
});
1948

20-
self.items.dedup_by(|a, b| a.label == b.label);
21-
self.items.truncate(crate::LIMIT);
49+
items.dedup_by(|a, b| a.label == b.label);
50+
items.truncate(crate::LIMIT);
2251

23-
let should_preselect_first_item = self.should_preselect_first_item();
52+
let should_preselect_first_item = should_preselect_first_item(&items);
2453

25-
self.items
54+
/*
55+
* LSP Clients themselves sort the completion items.
56+
* They'll use the `sort_text` property if present (or fallback to the `label`).
57+
* Since our items are already sorted, we're 'hijacking' the sort_text.
58+
* We're simply adding the index of the item, padded by zeroes to the max length.
59+
*/
60+
let max_padding = items.len().to_string().len();
61+
62+
items
2663
.into_iter()
2764
.enumerate()
28-
.map(|(idx, mut item)| {
29-
if idx == 0 {
30-
item.preselected = should_preselect_first_item;
65+
.map(|(idx, item)| {
66+
let preselected = idx == 0 && should_preselect_first_item;
67+
68+
CompletionItem {
69+
description: item.description,
70+
kind: item.kind,
71+
label: item.label,
72+
preselected,
73+
74+
// wonderous Rust syntax ftw
75+
sort_text: format!("{:0>padding$}", idx, padding = max_padding),
76+
completion_text: item.completion_text,
3177
}
32-
item
3378
})
3479
.collect()
3580
}
81+
}
3682

37-
fn should_preselect_first_item(&mut self) -> bool {
38-
let mut items_iter = self.items.iter();
39-
let first = items_iter.next();
40-
let second = items_iter.next();
83+
fn should_preselect_first_item(items: &Vec<PossibleCompletionItem>) -> bool {
84+
let mut items_iter = items.iter();
85+
let first = items_iter.next();
86+
let second = items_iter.next();
4187

42-
first.is_some_and(|f| match second {
43-
Some(s) => (f.score - s.score) > 10,
44-
None => true,
45-
})
46-
}
88+
first.is_some_and(|f| match second {
89+
Some(s) => (f.score.get_score() - s.score.get_score()) > 15,
90+
None => true,
91+
}) && items.len() >= 10
4792
}

crates/pgt_completions/src/complete.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn complete(params: CompletionParams) -> Vec<CompletionItem> {
2727

2828
let ctx = CompletionContext::new(&sanitized_params);
2929

30-
let mut builder = CompletionBuilder::new();
30+
let mut builder = CompletionBuilder::new(&ctx);
3131

3232
complete_tables(&ctx, &mut builder);
3333
complete_functions(&ctx, &mut builder);

0 commit comments

Comments
 (0)