Skip to content

stuff for sublime#2144

Open
kutu wants to merge 2 commits into
DanielXMoore:mainfrom
kutu:sublime
Open

stuff for sublime#2144
kutu wants to merge 2 commits into
DanielXMoore:mainfrom
kutu:sublime

Conversation

@kutu

@kutu kutu commented Jun 6, 2026

Copy link
Copy Markdown
Contributor
  • added build file, so you can execute currently open civet file
  • added keymap file, when you type $ inside backticks it becomes ${}
  • added indentation rules generated from vscode civet-configuration.json file
  • added Comments file, when pressing "comment line" keybind
  • added simple snippets files
  • fixed source.js.regexp -> source.regexp.js in syntax file generation

@greptile-apps

greptile-apps Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds Sublime Text editor support for Civet: a build system, $${} keymap for template strings, indentation rules generated from the VS Code config, comment preferences, and basic snippets. It also fixes a source.js.regexpsource.regexp.js grammar include that was previously incorrect.

  • build.civet is extended to copy all new assets into dist/, but the cpSync calls reference "Snippets" and "Preferences" (capital first letter) while the actual source directories are snippets and preferences — this will cause ENOENT failures on Linux.
  • indentation-rules.civet exports makeIndentationRules and also calls it unconditionally at module level; when imported by build.civet this runs wastefully before build() immediately deletes the output with rmSync.
  • The content() function in indentation-rules.civet interpolates regex patterns into plist XML without XML-escaping, which would produce malformed output if a future pattern contains <, >, or &.

Confidence Score: 3/5

The grammar fix and static asset files are safe, but the build script will throw on Linux due to a directory-name case mismatch, meaning Snippets and Preferences would never be copied to dist.

The case-sensitivity mismatch in build.civet will cause cpSync to throw ENOENT on any case-sensitive filesystem, so the Sublime package produced on Linux would be missing those assets entirely. The static files and grammar fix are otherwise clean.

lsp/sublime/build.civet (case-sensitive directory names) and lsp/sublime/indentation-rules.civet (module-level side effect on import)

Important Files Changed

Filename Overview
lsp/sublime/build.civet Adds copy steps for new Sublime assets; source paths use capitalized "Snippets"/"Preferences" that don't match the lowercase on-disk directories — will fail with ENOENT on Linux. Also fixes source.js.regexp → source.regexp.js grammar include.
lsp/sublime/indentation-rules.civet New script converting VS Code indentation rules to Sublime plist; calls makeIndentationRules() at module level unconditionally (runs wasted on import), and interpolates pattern strings into XML without escaping.
lsp/sublime/Civet.sublime-build New Sublime build system; correctly uses civet.cmd on Windows and plain civet elsewhere, with a file_regex for error output navigation.
lsp/sublime/Default.sublime-keymap Adds $ → ${...} snippet expansion inside Civet template strings, scoped correctly to avoid firing outside backtick strings.
lsp/sublime/preferences/Comments.tmPreferences Defines TM_COMMENT_START/END variables for // line comments and /* */ block comments in Civet files.
lsp/sublime/snippets/Console Log.tmSnippet Simple console.log snippet triggered by "log"; cursor placed after the call with $0.
lsp/sublime/snippets/Function.tmSnippet Function snippet with name/arguments/return-type placeholders, triggered by "fun".
lsp/sublime/snippets/If.tmSnippet If-block snippet triggered by "if"; straightforward and scoped to source.civet.
lsp/sublime/tsconfig.json Minimal tsconfig that extends the root config; no issues.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[build.civet] -->|import| B[indentation-rules.civet\nmodule level: makeIndentationRules runs]
    A --> C[build function]
    C --> D[rmSync dist/]
    D --> E[mkdirSync dist/]
    E --> F[Parse + normalize grammar\nwrite Civet.tmLanguage]
    F --> G[makeIndentationRules\ncreates dist/Preferences/]
    G --> H[copyFileSync Civet.sublime-build]
    H --> I[copyFileSync Default.sublime-keymap]
    I --> J["cpSync 'Snippets' → dist/Snippets ⚠️ case mismatch"]
    J --> K["cpSync 'Preferences' → dist/Preferences ⚠️ case mismatch"]
Loading

Reviews (1): Last reviewed commit: "stuff for sublime" | Re-trigger Greptile

Comment thread lsp/sublime/build.civet
Comment on lines +22 to +25
<key>decreaseIndentPattern</key>
<string>${rules.decreaseIndentPattern}</string>
<key>increaseIndentPattern</key>
<string>${rules.increaseIndentPattern}</string>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The regex patterns are interpolated directly into the XML string without any escaping. The current patterns in civet-configuration.json happen to be safe, but <, >, and & in future patterns would produce malformed plist XML. The sibling build.civet already has an escapeXml helper for exactly this purpose.

Suggested change
<key>decreaseIndentPattern</key>
<string>${rules.decreaseIndentPattern}</string>
<key>increaseIndentPattern</key>
<string>${rules.increaseIndentPattern}</string>
<key>decreaseIndentPattern</key>
<string>${rules.decreaseIndentPattern.replace /[&<>]/g, (c) => c is "&" ? "&amp;" : c is "<" ? "&lt;" : "&gt;"}</string>
<key>increaseIndentPattern</key>
<string>${rules.increaseIndentPattern.replace /[&<>]/g, (c) => c is "&" ? "&amp;" : c is "<" ? "&lt;" : "&gt;"}</string>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't matter in sublime

Comment thread lsp/sublime/indentation-rules.civet Outdated
@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4097b93) to head (4907aaf).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2144   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           57        57           
  Lines        27764     27764           
  Branches      5220      5219    -1     
=========================================
  Hits         27764     27764           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kutu kutu deployed to build June 6, 2026 14:42 — with GitHub Actions Active
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.

1 participant