zedx 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/generator.js CHANGED
@@ -13,8 +13,20 @@ async function renderTemplate(templatePath, data) {
13
13
  }
14
14
  export async function generateExtension(options, targetDir) {
15
15
  await fs.ensureDir(targetDir);
16
- const extToml = await renderTemplate(path.join(TEMPLATE_DIR, 'base/extension.toml.ejs'), options);
16
+ const extData = {
17
+ ...options,
18
+ grammarRepo: options.grammarRepo || '',
19
+ grammarRev: options.grammarRev || '',
20
+ languageName: options.languageName || 'My Language'
21
+ };
22
+ const extToml = await renderTemplate(path.join(TEMPLATE_DIR, 'base/extension.toml.ejs'), extData);
17
23
  await fs.writeFile(path.join(targetDir, 'extension.toml'), extToml);
24
+ const readmeData = {
25
+ ...extData,
26
+ languageId: options.languageId || 'my-language'
27
+ };
28
+ const readme = await renderTemplate(path.join(TEMPLATE_DIR, 'base/readme.md.ejs'), readmeData);
29
+ await fs.writeFile(path.join(targetDir, 'README.md'), readme);
18
30
  const licensePath = path.join(TEMPLATE_DIR, 'base/licenses', options.license);
19
31
  let licenseContent = await fs.readFile(licensePath, 'utf-8');
20
32
  licenseContent = licenseContent.replaceAll('{{YEAR}}', new Date().getFullYear().toString());
@@ -43,7 +55,12 @@ async function generateTheme(options, targetDir) {
43
55
  async function generateLanguage(options, targetDir) {
44
56
  const languageDir = path.join(targetDir, 'languages', options.languageId);
45
57
  await fs.ensureDir(languageDir);
46
- const configToml = await renderTemplate(path.join(TEMPLATE_DIR, 'language/config.toml.ejs'), options);
58
+ const data = {
59
+ ...options,
60
+ pathSuffixes: options.pathSuffixes || [],
61
+ lineComments: options.lineComments || ['//', '#']
62
+ };
63
+ const configToml = await renderTemplate(path.join(TEMPLATE_DIR, 'language/config.toml.ejs'), data);
47
64
  await fs.writeFile(path.join(languageDir, 'config.toml'), configToml);
48
65
  const queryFiles = [
49
66
  'highlights.scm',
@@ -60,7 +77,7 @@ async function generateLanguage(options, targetDir) {
60
77
  const templatePath = path.join(TEMPLATE_DIR, 'language', file);
61
78
  if (await fs.pathExists(templatePath)) {
62
79
  let content = await fs.readFile(templatePath, 'utf-8');
63
- content = ejs.render(content, options);
80
+ content = ejs.render(content, data);
64
81
  await fs.writeFile(path.join(languageDir, file), content);
65
82
  }
66
83
  }
package/dist/prompts.js CHANGED
@@ -138,12 +138,7 @@ export async function promptLanguageDetails() {
138
138
  }
139
139
  const result = {
140
140
  languageName: String(languageName),
141
- languageId: String(languageName).toLowerCase().replace(/\s+/g, '-'),
142
- pathSuffixes: [],
143
- lineComments: [],
144
- grammarRepo: '',
145
- grammarRev: '',
146
- hasLsp: false
141
+ languageId: String(languageName).toLowerCase().replace(/\s+/g, '-')
147
142
  };
148
143
  return result;
149
144
  }
@@ -9,12 +9,15 @@ repository = "<%= repository %>"
9
9
  <% if (types.includes('language') && grammarRepo) { %>
10
10
  [grammars.<%= languageId %>]
11
11
  repository = "<%= grammarRepo %>"
12
- rev = "<%= grammarRev %>"
12
+ rev = "<%= grammarRev || 'main' %>"
13
+ <% } else if (types.includes('language')) { %>
14
+ # [grammars.<%= languageId %>]
15
+ # repository = "https://github.com/user/tree-sitter-<%= languageId %>"
16
+ # rev = "main"
13
17
  <% } %>
14
- <% if (hasLsp && lspServerName) { %>
15
- [language_servers.<%= lspServerName %>]
16
- name = "<%= lspServerName %>"
17
- languages = ["<%= languageName %>"]
18
18
 
19
- [languages."<%= languageName %>"]
19
+ <% if (types.includes('language')) { %>
20
+ # [language_servers.my-lsp]
21
+ # name = "My Language LSP"
22
+ # languages = ["<%= languageName %>"]
20
23
  <% } %>
@@ -0,0 +1,34 @@
1
+ <%= name %>
2
+ <%= "=".repeat(name.length) %>
3
+
4
+ <%= description %>
5
+
6
+ ## Installation
7
+
8
+ 1. Open Zed
9
+ 2. Run `Extensions > Install Dev Extension`
10
+ 3. Select the folder for this extension
11
+
12
+ ## Development
13
+
14
+ ### Themes
15
+
16
+ Edit `themes/<%= id %>.json` to customize colors. See [Zed Theme Documentation](https://zed.dev/docs/themes) for available tokens.
17
+
18
+ ### Languages
19
+
20
+ Edit `languages/<%= languageId %>/config.toml`.
21
+
22
+ #### Tree-sitter Grammar
23
+
24
+ To add syntax highlighting, you'll need a Tree-sitter grammar:
25
+
26
+ 1. Find or create a grammar repo. Try [tree-sitter](https://github.com/tree-sitter/tree-sitter)
27
+ 2. Uncomment and fill in the `[grammars.<%= languageId %>]` section in `extension.toml`
28
+ 3. Edit the `.scm` files in `languages/<%= languageId %>/`
29
+
30
+ See [Zed Documentation](https://zed.dev/docs/extensions/languages) for details.
31
+
32
+ ## Publishing
33
+
34
+ Run `zedx version patch|minor|major` to bump the version, then create a GitHub release.
@@ -1,29 +1,26 @@
1
- <%= languageName %>
2
- <%= "=".repeat(languageName.length) %>
3
-
4
- ; name (required): The human readable name shown in the Select Language dropdown
1
+ # name (required): The human readable name shown in the Select Language dropdown
5
2
  name = "<%= languageName %>"
6
3
 
7
- ; grammar (required): The name of a Tree-sitter grammar (must match grammar registration in extension.toml)
4
+ # grammar (required): The name of a Tree-sitter grammar (must match grammar registration in extension.toml)
8
5
  grammar = "<%= languageId %>"
9
6
 
10
- ; path_suffixes: Array of file suffixes associated with this language (e.g., ["myl", "my"])
11
- ; Unlike file_types in settings, this does not support glob patterns
12
- path_suffixes = <%- pathSuffixes.length > 0 ? JSON.stringify(pathSuffixes) : '[""]' %>
7
+ # path_suffixes: Array of file suffixes associated with this language (e.g., ["myl", "my"])
8
+ # Unlike file_types in settings, this does not support glob patterns
9
+ # path_suffixes = []
13
10
 
14
- ; line_comments: Array of strings used to identify line comments
15
- ; Used for editor::ToggleComments keybind (cmd-/ or ctrl-/)
16
- line_comments = <%- lineComments.length > 0 ? JSON.stringify(lineComments) : '[""]' %>
11
+ # line_comments: Array of strings used to identify line comments
12
+ # Used for editor::ToggleComments keybind (cmd-/ or ctrl-/)
13
+ # line_comments = ["// ", "# "]
17
14
 
18
- ; tab_size: The indentation/tab size used for this language (default is 4)
19
- ; tab_size = 4
15
+ # tab_size: The indentation/tab size used for this language (default is 4)
16
+ # tab_size = 4
20
17
 
21
- ; hard_tabs: Whether to indent with tabs (true) or spaces (false, the default)
22
- ; hard_tabs = false
18
+ # hard_tabs: Whether to indent with tabs (true) or spaces (false, the default)
19
+ # hard_tabs = false
23
20
 
24
- ; first_line_pattern: A regular expression to match files based on their first line
25
- ; Useful for identifying files by shebang (e.g., "^#!.*\\bbash\\b" for shell scripts)
26
- ; first_line_pattern = ""
21
+ # first_line_pattern: A regular expression to match files based on their first line
22
+ # Useful for identifying files by shebang (e.g., "^#!.*\\bbash\\b" for shell scripts)
23
+ # first_line_pattern = ""
27
24
 
28
- ; debuggers: Array of debugger identifiers for ordering in the New Process Modal
29
- ; debuggers = []
25
+ # debuggers: Array of debugger identifiers for ordering in the New Process Modal
26
+ # debuggers = []
@@ -17,11 +17,11 @@ export interface ThemeOptions extends ExtensionOptions {
17
17
  export interface LanguageOptions extends ExtensionOptions {
18
18
  languageName: string;
19
19
  languageId: string;
20
- pathSuffixes: string[];
21
- lineComments: string[];
22
- grammarRepo: string;
23
- grammarRev: string;
24
- hasLsp: boolean;
20
+ pathSuffixes?: string[];
21
+ lineComments?: string[];
22
+ grammarRepo?: string;
23
+ grammarRev?: string;
24
+ hasLsp?: boolean;
25
25
  lspServerName?: string;
26
26
  lspCommand?: string;
27
27
  lspArgs?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zedx",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Boilerplate generator for Zed Edittor extensions.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",