stan-language-server 0.1.0-beta.13
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/CHANGELOG.md +154 -0
- package/LICENSE +21 -0
- package/README.md +46 -0
- package/dist/server.js +89754 -0
- package/package.json +69 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased] - Production Ready Release
|
|
9
|
+
|
|
10
|
+
### Summary
|
|
11
|
+
Complete Language Server Protocol implementation for Stan with all core features:
|
|
12
|
+
- **Completion**: Keywords, distributions, functions, datatypes, constraints
|
|
13
|
+
- **Hover**: Function and distribution documentation
|
|
14
|
+
- **Diagnostics**: Compiler errors and warnings
|
|
15
|
+
- **Formatting**: Stan code formatting via native compiler
|
|
16
|
+
- **Include Resolution**: Comprehensive #include handling
|
|
17
|
+
|
|
18
|
+
Current status: 109 tests passing across 14 test files with production-ready stability.
|
|
19
|
+
|
|
20
|
+
### Added - Complete Feature Set
|
|
21
|
+
- **Formatting System**: Full document formatting using Stan compiler
|
|
22
|
+
- `src/handlers/formatting.ts`: LSP protocol conversion for formatting requests
|
|
23
|
+
- `src/language/formatting/provider.ts`: Pure formatting provider using Stan compiler
|
|
24
|
+
- `src/types/formatting.ts`: Domain types for formatting context and results
|
|
25
|
+
- Comprehensive formatting tests with includes integration
|
|
26
|
+
- Support for both `.stan` and `.stanfunctions` files
|
|
27
|
+
- **Enhanced Include Resolution**: Robust #include file handling
|
|
28
|
+
- Workspace document prioritization with filesystem fallback
|
|
29
|
+
- Proper error handling for missing include files
|
|
30
|
+
- Support for relative and absolute include paths
|
|
31
|
+
- Integration with all language features (completion, hover, diagnostics, formatting)
|
|
32
|
+
|
|
33
|
+
### Changed - Architecture Refinements
|
|
34
|
+
- **Unified Compiler Integration**: Consolidated Stan compiler usage across all features
|
|
35
|
+
- `src/stanc/provider.ts`: Unified provider interface for compilation tasks
|
|
36
|
+
- Consistent compilation handling for diagnostics and formatting
|
|
37
|
+
- Improved error handling and type safety for compiler results
|
|
38
|
+
- **Enhanced Handler System**: All LSP features follow consistent patterns
|
|
39
|
+
- `src/handlers/completion.ts`: Completion provider to LSP conversion
|
|
40
|
+
- `src/handlers/hover.ts`: Hover provider to LSP conversion
|
|
41
|
+
- `src/handlers/diagnostics.ts`: Diagnostic provider to LSP conversion
|
|
42
|
+
- `src/handlers/formatting.ts`: Formatting provider to LSP conversion
|
|
43
|
+
- `src/handlers/compilation/`: Dedicated compilation utilities
|
|
44
|
+
|
|
45
|
+
### Fixed - Production Stability
|
|
46
|
+
- **Include Resolution**: Fixed filesystem fallback when workspace documents unavailable
|
|
47
|
+
- **Test Isolation**: Enhanced test cleanup preventing cross-test interference
|
|
48
|
+
- **Type Safety**: Improved TypeScript strict mode compliance across all modules
|
|
49
|
+
- **Error Handling**: Robust error handling for edge cases in all language features
|
|
50
|
+
- All 109 tests passing with comprehensive coverage of core functionality
|
|
51
|
+
|
|
52
|
+
### Technical Improvements - Production Quality
|
|
53
|
+
- **Clean Architecture**: Complete separation of language logic from LSP protocol
|
|
54
|
+
- **Type Safety**: Comprehensive TypeScript types for all domain objects
|
|
55
|
+
- **Testability**: Pure functions with no external dependencies in language layer
|
|
56
|
+
- **Maintainability**: Clear module boundaries and single responsibility principle
|
|
57
|
+
- **Performance**: Efficient include resolution with workspace/filesystem caching
|
|
58
|
+
- **Consistency**: All features follow identical architectural patterns
|
|
59
|
+
- **Documentation**: Comprehensive inline documentation and type definitions
|
|
60
|
+
|
|
61
|
+
## [v0.5.0] - Compilation Handler Refactoring
|
|
62
|
+
|
|
63
|
+
### Changed
|
|
64
|
+
- **BREAKING**: Refactored compilation architecture to improve modularity and maintainability
|
|
65
|
+
- Replaced direct `compile()` usage with `handleCompilation()` throughout codebase
|
|
66
|
+
- Moved compilation logic from scattered locations into dedicated handlers
|
|
67
|
+
- Centralized include file resolution and compilation handling
|
|
68
|
+
- Improved integration between compilation and include resolution systems
|
|
69
|
+
|
|
70
|
+
### Added
|
|
71
|
+
- New compilation handler system in `src/handlers/compilation/`:
|
|
72
|
+
- `src/handlers/compilation/compilation.ts`: Main compilation handler with `handleCompilation()` function
|
|
73
|
+
- `src/handlers/compilation/includes.ts`: Dedicated include file resolution handler
|
|
74
|
+
- Proper TypeScript types for Stan compiler integration (`StancReturn`, `StancSuccess`, `StancFailure`)
|
|
75
|
+
- Enhanced compilation workflow:
|
|
76
|
+
- Integrated include file resolution directly into compilation process
|
|
77
|
+
- Configurable Stan compiler arguments and options
|
|
78
|
+
- Support for both `.stan` and `.stanfunctions` file types
|
|
79
|
+
|
|
80
|
+
### Technical Improvements
|
|
81
|
+
- **Modularity**: Compilation logic properly encapsulated in dedicated handlers
|
|
82
|
+
- **Maintainability**: Clear separation between compilation, includes, and diagnostics
|
|
83
|
+
- **Consistency**: All features now follow same handler-based architectural pattern
|
|
84
|
+
- **Type Safety**: Better TypeScript integration with Stan compiler results
|
|
85
|
+
- **Code Quality**: Eliminated duplicate compilation logic across codebase
|
|
86
|
+
|
|
87
|
+
## [v0.4.0] - Diagnostic System Implementation
|
|
88
|
+
|
|
89
|
+
### Added
|
|
90
|
+
- New diagnostic system architecture following completion handler pattern:
|
|
91
|
+
- `src/types/common.ts`: Shared `Position` interface used by both completion and diagnostics
|
|
92
|
+
- `src/types/diagnostics.ts`: Domain types (`Range`, `DiagnosticSeverity`, `StanDiagnostic`)
|
|
93
|
+
- `src/language/diagnostics/provider.ts`: Pure diagnostic provider returning domain types
|
|
94
|
+
- `src/language/diagnostics/linter.ts`: Message processing utilities
|
|
95
|
+
- `src/language/diagnostics/index.ts`: Barrel exports for diagnostic functionality
|
|
96
|
+
- `src/handlers/diagnostics.ts`: LSP protocol conversion layer for diagnostics
|
|
97
|
+
- Server capabilities now include `diagnosticProvider` for LSP compliance
|
|
98
|
+
|
|
99
|
+
### Changed
|
|
100
|
+
- **BREAKING**: Refactored diagnostic architecture to implement LSP-compliant diagnostics
|
|
101
|
+
- Removed automatic validation on document content changes (performance improvement)
|
|
102
|
+
- Implemented proper `textDocument/diagnostic` request handler following LSP specification
|
|
103
|
+
- Language diagnostic functions now return domain types (`StanDiagnostic[]`) instead of LSP types
|
|
104
|
+
- Eliminated LSP dependencies from language layer diagnostic code
|
|
105
|
+
|
|
106
|
+
### Technical Improvements
|
|
107
|
+
- **Performance**: Diagnostics no longer run on every keystroke, only when explicitly requested
|
|
108
|
+
- **LSP Compliance**: Proper `textDocument/diagnostic` request handling instead of automatic publishing
|
|
109
|
+
- **Resource Efficiency**: Significantly reduced CPU usage during active editing
|
|
110
|
+
- **Clean Architecture**: Complete separation between diagnostic domain logic and LSP protocol
|
|
111
|
+
|
|
112
|
+
## [v0.3.0] - Hover System Implementation
|
|
113
|
+
|
|
114
|
+
### Added
|
|
115
|
+
- Pure hover providers in `src/language/hover/`:
|
|
116
|
+
- `provider.ts`: Main hover provider that coordinates function and distribution hover
|
|
117
|
+
- `functions.ts`: Function name extraction from call contexts
|
|
118
|
+
- `distributions.ts`: Distribution function mapping from sampling contexts
|
|
119
|
+
- `util.ts`: Text parsing utilities
|
|
120
|
+
- `src/handlers/hover.ts`: LSP protocol conversion for hover responses
|
|
121
|
+
|
|
122
|
+
### Changed
|
|
123
|
+
- **BREAKING**: Refactored hover functionality following same pattern as completion
|
|
124
|
+
- Separated function hover and distribution hover logic
|
|
125
|
+
- Created shared utilities for text parsing and word boundary detection
|
|
126
|
+
|
|
127
|
+
## [v0.2.0] - Completion System Refactoring
|
|
128
|
+
|
|
129
|
+
### Changed
|
|
130
|
+
- **BREAKING**: Refactored completion providers to return domain types (`Keyword[]`, `Distribution[]`, etc.)
|
|
131
|
+
- Created handlers layer for LSP protocol conversion
|
|
132
|
+
- Established clean dependency flow: `server.ts` → `handlers` → `language/providers`
|
|
133
|
+
- Removed LSP dependencies from `src/language` modules
|
|
134
|
+
|
|
135
|
+
### Added
|
|
136
|
+
- New completion handler system in `src/handlers/`:
|
|
137
|
+
- `src/handlers/completion.ts`: Converts provider results to LSP `CompletionItem[]`
|
|
138
|
+
- `src/handlers/index.ts`: Barrel export for all handlers
|
|
139
|
+
- Common completion utilities in `src/language/completion/util.ts`
|
|
140
|
+
- Comprehensive test suite for completion utilities
|
|
141
|
+
|
|
142
|
+
### Technical Improvements
|
|
143
|
+
- **Type Safety**: Leverages existing types from `src/types/completion.ts`
|
|
144
|
+
- **Testability**: Pure functions that don't depend on LSP infrastructure
|
|
145
|
+
- **Maintainability**: Clear boundaries and single responsibility principle
|
|
146
|
+
|
|
147
|
+
## [v0.1.0] - Initial Implementation
|
|
148
|
+
|
|
149
|
+
### Added
|
|
150
|
+
- Basic LSP server implementation using `vscode-languageserver`
|
|
151
|
+
- Stan compiler integration with TypeScript types
|
|
152
|
+
- Initial completion providers for keywords, distributions, functions, datatypes, constraints
|
|
153
|
+
- Basic include file resolution
|
|
154
|
+
- Test framework with Bun
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jens Kouros
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# stan-language-server
|
|
2
|
+
|
|
3
|
+
A language server for the Stan probabilistic programming language written in TypeScript and using Bun to build an executable binary. This is work in progress.
|
|
4
|
+
|
|
5
|
+
To install dependencies:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun install
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
To run the language server:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
bun run src/server.ts
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Building a binary executable:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bun build server.ts --compile --outfile stan-language-server
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
### Sublime Text 4
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"clients": {
|
|
29
|
+
"stan-lsp": {
|
|
30
|
+
"enabled": true,
|
|
31
|
+
"command": ["/YOUR/PATH/TO/stan-language-server"],
|
|
32
|
+
"selector": "source.stan | source.stanfunctions",
|
|
33
|
+
"initializationOptions": {}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Emacs (eglot)
|
|
40
|
+
|
|
41
|
+
Assuming you are using stan-ts-mode:
|
|
42
|
+
```elisp
|
|
43
|
+
(with-eval-after-load 'eglot
|
|
44
|
+
(add-to-list 'eglot-server-programs
|
|
45
|
+
'(stan-ts-mode . ("/YOUR/PATH/TO/stan-language-server"))))
|
|
46
|
+
```
|