11# Rhai Language Support for JetBrains IDEs
22
3+ [ ![ Build Status] ( https://github.com/your-username/rhai-highlight-plugin/actions/workflows/ci.yml/badge.svg )] ( https://github.com/your-username/rhai-highlight-plugin/actions )
34[ ![ JetBrains Plugin] ( https://img.shields.io/badge/JetBrains-Plugin-orange )] ( https://plugins.jetbrains.com/ )
45[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-blue.svg )] ( LICENSE )
56
@@ -10,41 +11,87 @@ Full-featured language support for the [Rhai](https://rhai.rs/) scripting langua
1011### Syntax Highlighting
1112- Full syntax highlighting for Rhai scripts
1213- Customizable colors via ** Settings > Editor > Color Scheme > Rhai**
14+ - Semantic highlighting for functions, variables, parameters, and more
1315- Support for all Rhai constructs: functions, variables, strings, numbers, operators, etc.
1416
1517### Code Intelligence
16- - ** Code completion** for keywords, built-in functions, and user-defined symbols
18+ - ** Code completion** for:
19+ - Keywords with smart insertion (automatic spaces after modifiers)
20+ - 40+ built-in functions with documentation
21+ - Array methods (push, pop, map, filter, reduce, etc.)
22+ - String methods (trim, split, to_upper, etc.)
23+ - User-defined functions and variables
24+ - Cross-file symbols with automatic import generation
25+ - Registered functions from Rust (via registry system)
1726- ** Go to definition** (Ctrl+Click or Ctrl+B)
1827- ** Find usages** (Alt+F7)
1928- ** Parameter info** for function calls
20- - ** Documentation on hover**
29+ - ** Documentation on hover** for built-in and user-defined symbols
30+
31+ ### Refactoring
32+ - ** Rename refactoring** (Shift+F6) for:
33+ - Variables and constants
34+ - Functions
35+ - Function parameters
36+ - Closure parameters
37+ - For loop variables
38+ - Smart scope detection (local vs global)
39+ - Automatic update of all usages
2140
2241### Code Navigation
2342- ** Structure view** with filtering (Alt+7)
43+ - Functions (public/private/test indicators)
44+ - Constants
45+ - Variables
46+ - Modules
2447- ** Breadcrumb navigation**
2548- ** Go to Symbol** (Ctrl+Alt+Shift+N)
49+ - ** Line markers** for function definitions and usages
2650
2751### Code Editing
28- - ** Code folding** for functions, blocks, and comments
52+ - ** Code folding** for functions, blocks, comments, and imports
2953- ** Brace matching** and auto-closing
3054- ** Smart Enter** completion
3155- ** Comment/uncomment** (Ctrl+/)
32- - ** Surround with** templates (Ctrl+Alt+T)
56+ - ** Surround with** templates (Ctrl+Alt+T):
57+ - if, if-else, while, for, loop
58+ - try-catch, block
59+ - Parentheses
3360- ** Live templates** for common patterns
3461
62+ ### Code Formatting
63+ - ** Reformat code** (Ctrl+Alt+L)
64+ - Configurable spacing rules for:
65+ - Assignment, logical, equality, relational operators
66+ - Additive and multiplicative operators
67+ - Range and arrow operators
68+ - Commas, colons, semicolons
69+ - Braces, parentheses, brackets
70+ - Closure pipes
71+ - Automatic indentation for blocks
72+ - Alignment of multiline parameters and arguments
73+
3574### Code Quality
3675- ** Inspections:**
3776 - Unused variable detection
3877 - Unresolved reference detection
3978 - Duplicate function definition detection
40- - ** Quick fixes** for common issues
79+ - ** Quick fixes (Alt+Enter):**
80+ - ** Create function** - creates a new function stub for unresolved function calls
81+ - ** Create variable** - creates a variable declaration for unresolved references
82+ - ** Auto-import symbols** from other files
83+ - ** Import and prefix** with module name (e.g., ` module::symbol ` )
84+ - ** Rename to ` _name ` ** - marks unused variable as intentionally unused
85+ - ** Remove unused declaration** - deletes unused variable
86+ - ** Delete duplicate function** - removes duplicate function definition
87+ - ** Rename duplicate function** - renames to ` funcName_2 `
4188- ** Spell checking** in comments and strings
4289
4390### Run Configuration
4491- ** Run Rhai scripts** directly from the IDE
4592- ** Right-click to run** any ` .rhai ` file
4693- ** Run gutter icon** for quick execution
47- - Configurable interpreter path
94+ - Configurable interpreter path and arguments
4895
4996### Rust Integration
5097- ** Auto-detect Rhai registrations** from Rust source files
@@ -61,7 +108,7 @@ Full-featured language support for the [Rhai](https://rhai.rs/) scripting langua
611084 . Restart the IDE
62109
63110### Manual Installation
64- 1 . Download the plugin ` .zip ` from [ Releases] ( https://github.com/example /rhai-intellij -plugin/releases )
111+ 1 . Download the plugin ` .zip ` from [ Releases] ( https://github.com/your-username /rhai-highlight -plugin/releases )
651122 . Open ** Settings/Preferences > Plugins**
661133 . Click the gear icon and select ** Install Plugin from Disk...**
671144 . Select the downloaded ` .zip ` file
@@ -156,13 +203,25 @@ Type the following abbreviations and press Tab to expand:
156203| Abbreviation | Expands to |
157204| -------------| -----------|
158205| ` fn ` | Function definition |
206+ | ` pubfn ` | Public function definition |
159207| ` let ` | Variable declaration |
208+ | ` const ` | Constant declaration |
209+ | ` pubconst ` | Public constant declaration |
160210| ` if ` | If statement |
161211| ` ife ` | If-else statement |
162212| ` for ` | For loop |
213+ | ` fori ` | For loop with index (0..n) |
214+ | ` forr ` | For loop with range |
163215| ` while ` | While loop |
164216| ` loop ` | Infinite loop |
165- | ` match ` | Switch statement |
217+ | ` match ` | Switch expression |
218+ | ` trye ` | Try-catch block |
219+ | ` closure ` | Closure expression |
220+ | ` mape ` | Map expression |
221+ | ` filtere ` | Filter expression |
222+ | ` reducee ` | Reduce expression |
223+ | ` guard ` | Guard clause (if-return pattern) |
224+ | ` doc ` | Documentation comment |
166225
167226## File Templates
168227
@@ -175,22 +234,42 @@ Create new Rhai files with predefined templates:
175234Configure Rhai code style settings:
176235** Settings > Editor > Code Style > Rhai**
177236
178- Options include:
179- - Indentation (tabs vs spaces)
180- - Continuation indent
181- - Keep line breaks
237+ ### Spacing Options
238+ - Spaces around operators (assignment, logical, equality, relational, etc.)
239+ - Spaces around range and arrow operators
240+ - Spaces after/before commas, colons, semicolons
241+ - Spaces within parentheses, brackets, braces
242+ - Spaces within closure pipes
243+
244+ ### Brace & Wrapping Options
245+ - Space before function/if/loop/switch left brace
246+ - Align multiline parameters and arguments
247+ - Align multiline array elements and object fields
248+ - Keep trailing commas
249+
250+ ### Indentation Options
251+ - Indent size (default: 4)
252+ - Tab size (default: 4)
253+ - Continuation indent size (default: 4)
254+ - Use tabs or spaces
255+
256+ ### Blank Lines
257+ - Blank lines after imports
258+ - Blank lines around functions
259+ - Blank lines around modules
182260
183261## Requirements
184262
185263- IntelliJ IDEA 2023.1+ (or compatible JetBrains IDE)
264+ - Java 17+
186265- For running scripts: Rhai interpreter (` cargo install rhai-repl ` )
187266
188267## Building from Source
189268
190269``` bash
191270# Clone the repository
192- git clone https://github.com/example /rhai-intellij -plugin.git
193- cd rhai-intellij -plugin
271+ git clone https://github.com/your-username /rhai-highlight -plugin.git
272+ cd rhai-highlight -plugin
194273
195274# Build the plugin
196275./gradlew buildPlugin
@@ -209,6 +288,36 @@ cd rhai-intellij-plugin
209288
210289# Run linter
211290./gradlew detekt
291+
292+ # Verify plugin compatibility
293+ ./gradlew verifyPlugin
294+ ```
295+
296+ ### Project Structure
297+
298+ ```
299+ src/
300+ ├── main/
301+ │ ├── grammars/ # BNF grammar and JFlex lexer
302+ │ ├── kotlin/org/rhai/
303+ │ │ ├── features/ # Completion, folding, structure view, etc.
304+ │ │ ├── highlighting/ # Syntax highlighter
305+ │ │ ├── inspections/ # Code inspections and quick fixes
306+ │ │ ├── intentions/ # Intention actions
307+ │ │ ├── lang/ # Language and file type definitions
308+ │ │ ├── navigation/ # Go to declaration
309+ │ │ ├── parser/ # Parser definition
310+ │ │ ├── refactoring/ # Rename refactoring
311+ │ │ ├── registry/ # Rust integration registry
312+ │ │ ├── run/ # Run configuration
313+ │ │ ├── settings/ # Settings pages
314+ │ │ └── util/ # Utility classes
315+ │ └── resources/
316+ │ ├── META-INF/ # Plugin descriptor
317+ │ ├── icons/ # Plugin icons
318+ │ └── liveTemplates/ # Live template definitions
319+ └── test/
320+ └── kotlin/org/rhai/ # Unit tests
212321```
213322
214323## Contributing
@@ -217,8 +326,9 @@ Contributions are welcome! Please:
2173261 . Fork the repository
2183272 . Create a feature branch
2193283 . Make your changes
220- 4 . Run ` ./gradlew detekt ` to check code style
221- 5 . Submit a pull request
329+ 4 . Run ` ./gradlew test ` to ensure tests pass
330+ 5 . Run ` ./gradlew detekt ` to check code style
331+ 6 . Submit a pull request
222332
223333## License
224334
0 commit comments