Skip to content

feat(config): configurable workspace scan extensions and excludes - #58

Merged
AlexanderBrevig merged 2 commits into
mainfrom
feat/workspace-scan-config
Aug 31, 2026
Merged

feat(config): configurable workspace scan extensions and excludes#58
AlexanderBrevig merged 2 commits into
mainfrom
feat/workspace-scan-config

Conversation

@AlexanderBrevig

Copy link
Copy Markdown
Owner

Closes #51.

Problem

.fs files (F#, GLSL fragment shaders) were unconditionally scanned and indexed as Forth, because the recognised extensions were hardcoded in main.rs with no way to opt out. There was also no way to exclude a folder from scanning.

Change

Adds a [workspace] section to .forth-lsp.toml, using the config machinery that already exists (Config::load_from_workspace):

[workspace]
# Extensions (without the dot) treated as Forth source and indexed.
# Drop "fs" here if it collides with F# / fragment shaders.
extensions = ["f", "fth", "fs", "4th", "forth", "frt"]

# Folder/file names to skip while scanning. Matches a single path
# component, supports `*` and `?` wildcards.
exclude = [".git", "target", "node_modules"]
  • extensions — the primary fix for the .fs clash: redefine the set without "fs".
  • exclude — skip folders/files; excluding a folder prunes its whole subtree. Matching is per-path-component (not full paths), so a project living under a path that merely contains target isn't wrongly skipped. Kept dependency-free with a tiny */? glob matcher.

Backward compatibility

  • No config, or a config without [workspace], behaves as before — the defaults reproduce the historical extension list exactly (case-insensitive).
  • Defaults additionally skip .git, target, and node_modules, so scanning is strictly faster than the old "descend into everything" behaviour.

Scope / notes

  • This governs the server's workspace scan/index. Whether an editor attaches forth-lsp to an already-open .fs buffer is client-side (filetype → languageId) and out of scope here.
  • Config is loaded once at init; this is a static filter, not live-reload.

Tests

5 new tests (252 total pass): legacy-default parity, default noise-dir exclusion + the root-path false-positive guard, extensions override dropping .fs, exclude override with globs, and the glob matcher itself. cargo clippy --all-targets is clean.

🤖 Generated with Claude Code

AlexanderBrevig and others added 2 commits August 31, 2026 10:56
Adds a [workspace] section to .forth-lsp.toml:

  - extensions: file extensions treated as Forth source. Lets users drop
    "fs" when it collides with F# or GLSL fragment shaders.
  - exclude: folder/file name patterns to skip while scanning, matched per
    path component with * and ? wildcards.

Defaults reproduce the previous hardcoded extension list, so existing
setups are unaffected, and additionally skip .git, target and node_modules
so scanning is strictly faster than before.

Closes #51

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replaces the bespoke * / ? matcher with glob::Pattern — a small, well-known
rust-lang crate (no extra transitive deps). Less code to reason about, and
standard shell-glob semantics including character classes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@AlexanderBrevig
AlexanderBrevig merged commit 34678d4 into main Aug 31, 2026
1 check failed
@AlexanderBrevig
AlexanderBrevig deleted the feat/workspace-scan-config branch August 31, 2026 09:03
AlexanderBrevig added a commit that referenced this pull request Aug 31, 2026
Fixes a formatting deviation merged in #58 that left `cargo fmt --all
--check` (and therefore main's CI) red.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
AlexanderBrevig added a commit that referenced this pull request Aug 31, 2026
* fix(completion): suppress completions inside comments

Typing inside a \ line comment or ( ... ) comment no longer triggers
word/colon completions. A ':' typed in a comment is prose, not the start
of a colon definition, so offering ':' / ':NONAME' there was misleading
(and made the popup in #41 look server-driven).

handle_completion now lexes the document and returns no completions when
the cursor's byte offset falls within a Comment or StackComment token.
The end offset is inclusive so completions are also suppressed while
appending to the end of a comment.

Adds unit tests for position_in_comment and an end-to-end regression test
(tests/repro_issue_41.rs) that drives the real binary over stdio and
asserts completion is empty inside a comment and formatting never injects
a stray semicolon.

Refs #41

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* style: rustfmt the workspace-config test closure

Fixes a formatting deviation merged in #58 that left `cargo fmt --all
--check` (and therefore main's CI) red.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Excluding folders or files

1 participant