openvox-editor-services 3.0.0 → 3.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a11b61a4502f6605147bca3070cdd47616983975db602e69715a09fd2897182
4
- data.tar.gz: 7c34c875ca79bfbef62085b01980bb69ebc6a62dc8036b2aab281d33871bfedb
3
+ metadata.gz: cda59eba9edbedf441cecc12f6e9008896fe7cbebee4fa7f54973c24042f5190
4
+ data.tar.gz: 95b0094bfba3986aaa34b9672de8f606e49b54e7e78e98cbe8905e6236e61f1f
5
5
  SHA512:
6
- metadata.gz: e1302fd59a9aea8667414a48412e41bbdc295b786876a4dac32551e83e4627caa53b775ae70de4682b79518222864f26e43898bea5a15fe0e4d107c3eae5cbeb
7
- data.tar.gz: ab014705e00a74c804b0175c5f120f2171d668257257c3e8cf2cc52de500c6931a80fa079a52aec958dd3a0c09e2b3c420bd9fa29e6a463d7772d28d38f7b653
6
+ metadata.gz: 9f8a477f7f92a7cbd9ccd0f48678a94da073c1115dd2e2873a539349e57e6fa079ea91829350cd0db18aacddb7e5d7ffd6d64ca800ebf4aa61e4af8dfeaa8d56
7
+ data.tar.gz: 38d3f0bacdfa3cfcf46a66e702c17c95c1d7e83dd45501db9a0d540ea1c755a80d615d6d3d962fa7c18958dbbe8d663af71374abf8fbdac523ee1a4a205d7794
data/CHANGELOG.md CHANGED
@@ -1,8 +1,26 @@
1
1
  # Changelog
2
2
 
3
- ## [3.0.0](https://github.com/voxpupuli/openvox-editor-services/tree/3.0.0) (2026-07-02)
3
+ ## [3.1.0](https://github.com/voxpupuli/openvox-editor-services/tree/3.1.0) (2026-07-03)
4
4
 
5
- [Full Changelog](https://github.com/voxpupuli/openvox-editor-services/compare/v2.0.4...3.0.0)
5
+ [Full Changelog](https://github.com/voxpupuli/openvox-editor-services/compare/v3.0.0...3.1.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - feat: add document formatter [\#6](https://github.com/voxpupuli/openvox-editor-services/pull/6) ([rwaffen](https://github.com/rwaffen))
10
+
11
+ **Fixed bugs:**
12
+
13
+ - fix: patch startup problems with rvm rubies vs agent ruby [\#7](https://github.com/voxpupuli/openvox-editor-services/pull/7) ([rwaffen](https://github.com/rwaffen))
14
+
15
+ **Merged pull requests:**
16
+
17
+ - ci: add test suite verfication step, move markdownlint into ci [\#12](https://github.com/voxpupuli/openvox-editor-services/pull/12) ([rwaffen](https://github.com/rwaffen))
18
+ - feat: add markdown lint, labeler, release docu, update markdown files [\#11](https://github.com/voxpupuli/openvox-editor-services/pull/11) ([rwaffen](https://github.com/rwaffen))
19
+ - CI: pin external workflows [\#5](https://github.com/voxpupuli/openvox-editor-services/pull/5) ([bastelfreak](https://github.com/bastelfreak))
20
+
21
+ ## [v3.0.0](https://github.com/voxpupuli/openvox-editor-services/tree/v3.0.0) (2026-07-02)
22
+
23
+ [Full Changelog](https://github.com/voxpupuli/openvox-editor-services/compare/v2.0.4...v3.0.0)
6
24
 
7
25
  **Implemented enhancements:**
8
26
 
data/README.md CHANGED
@@ -1,20 +1,43 @@
1
1
  # OpenVox Editor Services
2
2
 
3
- A Ruby implementation of a [Language Server](https://github.com/Microsoft/language-server-protocol) and [Debug Server](https://github.com/microsoft/debug-adapter-protocol) for OpenVox. The internal `Puppet` Ruby namespace and `puppet/*` protocol methods are retained for compatibility.
3
+ A Ruby implementation of a [Language Server](https://github.com/Microsoft/language-server-protocol) and [Debug Server](https://github.com/microsoft/debug-adapter-protocol) for OpenVox.
4
+ The internal `Puppet` Ruby namespace and `puppet/*` protocol methods are retained for compatibility.
5
+
6
+ - [OpenVox Editor Services](#openvox-editor-services)
7
+ - [Requirements](#requirements)
8
+ - [Setting up editor services for development](#setting-up-editor-services-for-development)
9
+ - [Language Server](#language-server)
10
+ - [How to run the Language Server for Development](#how-to-run-the-language-server-for-development)
11
+ - [How to run the Language Server in Production](#how-to-run-the-language-server-in-production)
12
+ - [Command line arguments](#command-line-arguments)
13
+ - [Language Server Sidecar](#language-server-sidecar)
14
+ - [How to run the Language Server Sidecar for Development](#how-to-run-the-language-server-sidecar-for-development)
15
+ - [Example usage](#example-usage)
16
+ - [Confirm that the Sidecar loads correctly](#confirm-that-the-sidecar-loads-correctly)
17
+ - [Output all default Puppet Types](#output-all-default-puppet-types)
18
+ - [Output all default Puppet Functions with a different puppet configuration, and debug information](#output-all-default-puppet-functions-with-a-different-puppet-configuration-and-debug-information)
19
+ - [Output all Puppet Classes in a workspace directory](#output-all-puppet-classes-in-a-workspace-directory)
20
+ - [Command line arguments for the Language Server Sidecar](#command-line-arguments-for-the-language-server-sidecar)
21
+ - [Debug Server](#debug-server)
22
+ - [How to run the Debug Server for Development](#how-to-run-the-debug-server-for-development)
23
+ - [How to run the Debug Server for Production](#how-to-run-the-debug-server-for-production)
24
+ - [Command line arguments for the Debug Server](#command-line-arguments-for-the-debug-server)
25
+ - [License](#license)
26
+ - [Other information](#other-information)
27
+ - [Reporting bugs](#reporting-bugs)
28
+ - [Development](#development)
29
+ - [Why are there vendored gems and why only native ruby](#why-are-there-vendored-gems-and-why-only-native-ruby)
4
30
 
5
31
  ## Requirements
6
32
 
7
- * OpenVox 8 or above
8
-
9
- * Ruby 3.1 or above
33
+ - OpenVox 8 or above
34
+ - Ruby 3.1 or above
10
35
 
11
36
  ## Setting up editor services for development
12
37
 
13
- * Ensure a modern ruby is installed (3.1+)
14
-
15
- The editor services support OpenVox 8.0.0 and above.
16
-
17
- * Clone this repository
38
+ - Ensure a modern ruby is installed (3.4+)
39
+ - The editor services support OpenVox 8.0.0 and above.
40
+ - Clone this repository
18
41
 
19
42
  ```bash
20
43
  > git clone https://github.com/voxpupuli/openvox-editor-services.git
@@ -22,7 +45,7 @@ A Ruby implementation of a [Language Server](https://github.com/Microsoft/langua
22
45
  > cd openvox-editor-services
23
46
  ```
24
47
 
25
- * Bundle the development gems
48
+ - Bundle the development gems
26
49
 
27
50
  ```bash
28
51
  > bundle install
@@ -30,7 +53,7 @@ A Ruby implementation of a [Language Server](https://github.com/Microsoft/langua
30
53
  ... < lots of text >
31
54
  ```
32
55
 
33
- * Installed vendored gems
56
+ - Installed vendored gems
34
57
 
35
58
  ```bash
36
59
  > bundle exec rake gem_revendor
@@ -38,9 +61,9 @@ A Ruby implementation of a [Language Server](https://github.com/Microsoft/langua
38
61
  ... < lots of text >
39
62
  ```
40
63
 
41
- # Language Server
64
+ ## Language Server
42
65
 
43
- ## How to run the Language Server for Development
66
+ ### How to run the Language Server for Development
44
67
 
45
68
  By default the language server will stop if no connection is made within 10 seconds and will also stop after a client disconnects. Adding `--debug=stdout` will log messages to the console
46
69
 
@@ -107,14 +130,14 @@ D, [2018-12-05T15:20:56.374333 #29752] DEBUG -- : TCPSRV: Started listening on l
107
130
  ...
108
131
  ```
109
132
 
110
- ## How to run the Language Server in Production
133
+ ### How to run the Language Server in Production
111
134
 
112
- * Ensure that Puppet Agent is installed
113
- * [Linux](https://puppet.com/docs/puppet/latest/install_agents.html#install_nix_agents)
114
- * [Windows](https://puppet.com/docs/puppet/latest/install_agents.html#install_windows_agents)
115
- * [macOS](https://puppet.com/docs/puppet/latest/install_agents.html#install_mac_agents)
135
+ - Ensure that Puppet Agent is installed
136
+ - [Linux](https://puppet.com/docs/puppet/latest/install_agents.html#install_nix_agents)
137
+ - [Windows](https://puppet.com/docs/puppet/latest/install_agents.html#install_windows_agents)
138
+ - [macOS](https://puppet.com/docs/puppet/latest/install_agents.html#install_mac_agents)
116
139
 
117
- * Run the `puppet-languageserver` with ruby
140
+ - Run the `puppet-languageserver` with ruby
118
141
 
119
142
  > On Windows you need to run ruby with the `Puppet Command Prompt` which can be found in the Start Menu. This enables the Puppet Agent ruby environment.
120
143
 
@@ -125,7 +148,9 @@ LANGUAGE SERVER RUNNING 127.0.0.1:55086
125
148
 
126
149
  > Note the language server will stop after 10 seconds if no client connection is made.
127
150
 
128
- Note that the Language Server will use TCP as the default transport on `localhost` at a random port. The IP Address and Port can be changed using the `--ip` and `--port` arguments respectively. For example to listen on all interfaces on port 9000;
151
+ Note that the Language Server will use TCP as the default transport on `localhost` at a random port.
152
+ The IP Address and Port can be changed using the `--ip` and `--port` arguments respectively.
153
+ For example to listen on all interfaces on port 9000;
129
154
 
130
155
  ```bash
131
156
  > ruby ./puppet-languageserver --ip=0.0.0.0 --port=9000
@@ -133,7 +158,7 @@ Note that the Language Server will use TCP as the default transport on `localhos
133
158
 
134
159
  To change the protocol to STDIO, that is using STDOUT and STDIN, use the `--stdio` argument.
135
160
 
136
- ## Command line arguments
161
+ ### Command line arguments
137
162
 
138
163
  ```bash
139
164
  Usage: puppet-languageserver.rb [options]
@@ -155,15 +180,18 @@ Usage: puppet-languageserver.rb [options]
155
180
  -v, --version Prints the Langauge Server version
156
181
  ```
157
182
 
158
- # Language Server Sidecar
183
+ ## Language Server Sidecar
159
184
 
160
- ## How to run the Language Server for Development
185
+ ### How to run the Language Server Sidecar for Development
161
186
 
162
- The Language Server Sidecar is a process used by the Language Server to get information about Puppet's environment, for example, all available functions, classes, and custom types. This tool is typically only run by the Language Server itself, but it can be used to diagnose issues.
187
+ The Language Server Sidecar is a process used by the Language Server to get information about Puppet's environment, for example, all available functions, classes, and custom types.
188
+ This tool is typically only run by the Language Server itself, but it can be used to diagnose issues.
163
189
 
164
- The sidecar is told to perform an action (using the `action`) parameter and then, by default, outputs the JSON encoded result to STDOUT. This can be changed to a text file using the `--output=PATH` argument.
190
+ The sidecar is told to perform an action (using the `action`) parameter and then, by default, outputs the JSON encoded result to STDOUT.
191
+ This can be changed to a text file using the `--output=PATH` argument.
165
192
 
166
- Note that using the `--debug=STDOUT` option without directing the output to a text file will generate output on STDOUT which cannot be deserialized correctly. Typically this only used by a developer to inspect what the Sidecar is doing.
193
+ Note that using the `--debug=STDOUT` option without directing the output to a text file will generate output on STDOUT which cannot be deserialized correctly.
194
+ Typically this only used by a developer to inspect what the Sidecar is doing.
167
195
 
168
196
  ### Example usage
169
197
 
@@ -203,11 +231,12 @@ D, [2018-12-05T15:42:56.752804 #51864] DEBUG -- : [PuppetLanguageServerSidecar::
203
231
  [{"key":"sqlserver::config","calling_source":"C:/Source/puppetlabs-sqlserver/manifests/config.pp","source":"C:/Source/puppetlabs-sqlserver/manifests/config.pp","line":25,"ch...
204
232
  ```
205
233
 
206
- ## Command line arguments
234
+ ### Command line arguments for the Language Server Sidecar
207
235
 
208
236
  ```bash
209
237
  Usage: puppet-languageserver-sidecar.rb [options]
210
- -a, --action=NAME The action for the sidecar to take. Expected ["noop", "default_classes", "default_functions", "default_types", "node_graph", "resource_list", "workspace_classes", "workspace_functions", "workspace_types"]
238
+ -a, --action=NAME The action for the sidecar to take. Expected ["noop", "default_classes", "default_functions",
239
+ "default_types", "node_graph", "resource_list", "workspace_classes", "workspace_functions", "workspace_types"]
211
240
  -c, --action-parameters=JSON JSON Encoded string containing the parameters for the sidecar action
212
241
  -w, --local-workspace=PATH The workspace or file path that will be used to provide module-specific functionality. Default is no workspace path
213
242
  -o, --output=PATH The file to save the output from the sidecar. Default is output to STDOUT
@@ -219,11 +248,12 @@ Usage: puppet-languageserver-sidecar.rb [options]
219
248
  -v, --version Prints the Langauge Server version
220
249
  ```
221
250
 
222
- # Debug Server
251
+ ## Debug Server
223
252
 
224
- ## How to run the Debug Server for Development
253
+ ### How to run the Debug Server for Development
225
254
 
226
- By default the debug server will stop if no connection is made within 10 seconds and will also stop after a client disconnects. Adding `--debug=stdout` will log messages to the console
255
+ By default the debug server will stop if no connection is made within 10 seconds and will also stop after a client disconnects.
256
+ Adding `--debug=stdout` will log messages to the console
227
257
 
228
258
  ```bash
229
259
  > bundle exec ruby ./puppet-debugserver --debug=stdout
@@ -256,16 +286,13 @@ D, [2018-04-17T14:21:10.546834 #12424] DEBUG -- : TCPSRV: Started listening on 1
256
286
  ...
257
287
  ```
258
288
 
259
- ## How to run the Debug Server for Production
289
+ ### How to run the Debug Server for Production
260
290
 
261
- * Ensure that Puppet Agent is installed
262
- * [Linux](https://puppet.com/docs/puppet/latest/install_agents.html#install_nix_agents)
263
- * [Windows](https://puppet.com/docs/puppet/latest/install_agents.html#install_windows_agents)
264
- * [macOS](https://puppet.com/docs/puppet/latest/install_agents.html#install_mac_agents)
291
+ - Ensure that OpenVox Agent is installed
292
+ - Run the `puppet-debugserver` with ruby
265
293
 
266
- * Run the `puppet-debugserver` with ruby
267
-
268
- > On Windows you need to run ruby with the `Puppet Command Prompt` which can be found in the Start Menu. This enables the Puppet Agent ruby environment.
294
+ On Windows you need to run ruby with the `OpenVox Command Prompt` which can be found in the Start Menu.
295
+ This enables the OpenVox Agent ruby environment.
269
296
 
270
297
  ```bash
271
298
  > ruby puppet-debugserver
@@ -274,7 +301,7 @@ DEBUG SERVER RUNNING 127.0.0.1:8082
274
301
 
275
302
  Note the debug server will stop after 10 seconds if no client connection is made.
276
303
 
277
- ## Command line arguments
304
+ ### Command line arguments for the Debug Server
278
305
 
279
306
  ```bash
280
307
  Usage: puppet-debugserver.rb [options]
@@ -290,16 +317,23 @@ Usage: puppet-debugserver.rb [options]
290
317
 
291
318
  This codebase is licensed under Apache 2.0. However, the open source dependencies included in this codebase might be subject to other software licenses such as AGPL, GPL2.0, and MIT.
292
319
 
293
- # Other information
320
+ ## Other information
294
321
 
295
- ## Reporting bugs
322
+ ### Reporting bugs
296
323
 
297
- If you find a bug in puppet-editor-services or its results, please create an issue in the [repo issues tracker](https://github.com/puppetlabs/puppet-editor-services/issues). Bonus points will be awarded if you also include a patch that fixes the issue.
324
+ If you find a bug in puppet-editor-services or its results, please create an issue in the [repo issues tracker](https://github.com/voxpupulo/openvox-editor-services/issues).
325
+ Bonus points will be awarded if you also include a patch that fixes the issue.
298
326
 
299
327
  ## Development
300
328
 
301
- If you run into an issue with this tool or would like to request a feature you can raise a PR with your suggested changes. Alternatively, you can raise a Github issue with a feature request or to report any bugs. Every other Tuesday the DevX team holds office hours in the Puppet Community Slack, where you can ask questions about this and any other supported tools. This session runs at 15:00 (GMT) for about an hour.
329
+ If you run into an issue with this tool or would like to request a feature you can raise a PR with your suggested changes.
330
+ Alternatively, you can raise a Github issue with a feature request or to report any bugs.
331
+ Every other Tuesday the DevX team holds office hours in the Puppet Community Slack, where you can ask questions about this and any other supported tools.
332
+ This session runs at 15:00 (GMT) for about an hour.
302
333
 
303
334
  ## Why are there vendored gems and why only native ruby
304
335
 
305
- When used by editors this language server will be running using the Ruby runtime provided by Puppet Agent. That means no native extensions and no bundler. Also, only the gems provided by Puppet Agent would be available by default. To work around this limitation all runtime dependencies should be re-vendored and then the load path modified appropriately.
336
+ When used by editors this language server will be running using the Ruby runtime provided by Puppet Agent.
337
+ That means no native extensions and no bundler.
338
+ Also, only the gems provided by Puppet Agent would be available by default.
339
+ To work around this limitation all runtime dependencies should be re-vendored and then the load path modified appropriately.
data/RELEASE.md ADDED
@@ -0,0 +1,36 @@
1
+ # Release
2
+
3
+ ## On a fork
4
+
5
+ Please follow these instructions carefully.
6
+ Ensure that you name the branch precisely as `release-vX.Y.Z`
7
+ since this nomenclature is crucial for obtaining the `future_version` in the changelog.
8
+ Edit `lib/puppet_editor_services/version.rb` to set the version to the new release version.
9
+ Your attention to this specific branch naming convention is essential for accurate version tracking in the changelog.
10
+
11
+ ```shell
12
+ export RELEASE_VERSION="X.Y.Z"
13
+ git switch main
14
+ git pull --rebase
15
+ git switch --create release-v$RELEASE_VERSION
16
+
17
+ bundle config set --local path vendor/bundle
18
+ bundle config set --local with 'release'
19
+ bundle install
20
+
21
+ CHANGELOG_GITHUB_TOKEN="token_MC_tokenface" bundle exec rake changelog
22
+
23
+ git commit --all --signoff --message "Release v${RELEASE_VERSION}"
24
+ git push --set-upstream origin HEAD
25
+ ```
26
+
27
+ Then open a PR, discuss and merge.
28
+
29
+ ## After the merge, as a maintainer on upstream
30
+
31
+ ```shell
32
+ git switch main
33
+ git pull --rebase
34
+ git tag v$RELEASE_VERSION --message "v$RELEASE_VERSION"
35
+ git push --tags
36
+ ```
@@ -1,6 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ root_dir = File.directory?(File.join(__dir__, 'lib')) ? __dir__ : File.expand_path('..', __dir__)
5
+ $LOAD_PATH.unshift(File.join(root_dir, 'lib'))
6
+
7
+ require 'openvox_agent_rubygems'
8
+ OpenVoxAgentRubygems.activate!
4
9
  require 'puppet_debugserver'
5
10
 
6
11
  options = PuppetDebugServer::CommandLineParser.parse(ARGV)
@@ -1,6 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ root_dir = File.directory?(File.join(__dir__, 'lib')) ? __dir__ : File.expand_path('..', __dir__)
5
+ $LOAD_PATH.unshift(File.join(root_dir, 'lib'))
6
+ $LOAD_PATH.unshift(File.join(root_dir, 'vendor', 'puppet-lint', 'lib'))
7
+ Dir[File.join(root_dir, 'vendor', 'puppet-lint-*', 'lib')].sort.each { |path| $LOAD_PATH.unshift(path) }
8
+ $LOAD_PATH.unshift(File.join(root_dir, 'vendor', 'molinillo', 'lib'))
9
+ $LOAD_PATH.unshift(File.join(root_dir, 'vendor', 'puppetfile-resolver', 'lib'))
10
+
11
+ require 'openvox_agent_rubygems'
12
+ OpenVoxAgentRubygems.activate!
4
13
  require 'puppet_languageserver'
5
14
 
6
15
  options = PuppetLanguageServer::CommandLineParser.parse(ARGV)
@@ -1,6 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ root_dir = File.directory?(File.join(__dir__, 'lib')) ? __dir__ : File.expand_path('..', __dir__)
5
+ $LOAD_PATH.unshift(File.join(root_dir, 'lib'))
6
+ $LOAD_PATH.unshift(File.join(root_dir, 'vendor', 'hiera-eyaml', 'lib'))
7
+ $LOAD_PATH.unshift(File.join(root_dir, 'vendor', 'openvox-strings', 'lib'))
8
+ $LOAD_PATH.unshift(File.join(root_dir, 'vendor', 'rgen', 'lib'))
9
+ $LOAD_PATH.unshift(File.join(root_dir, 'vendor', 'yard', 'lib'))
10
+
11
+ require 'openvox_agent_rubygems'
12
+ OpenVoxAgentRubygems.activate!
4
13
  require 'puppet_languageserver_sidecar'
5
14
 
6
15
  options = PuppetLanguageServerSidecar::CommandLineParser.parse(ARGV)
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'openvox_agent_rubygems'
4
+
3
5
  # Activates the OpenFact gem while retaining its Facter-compatible Ruby API.
4
6
  # OpenFact intentionally provides `require 'facter'`, the `Facter` namespace,
5
7
  # and the `facter` executable.
@@ -7,7 +9,9 @@ module OpenFactRuntime
7
9
  GEM_NAME = 'openfact'
8
10
 
9
11
  def self.activate!
12
+ OpenVoxAgentRubygems.activate!
10
13
  gem(GEM_NAME)
14
+ OpenVoxAgentRubygems.restore_paths!
11
15
  require 'syslog' unless Gem.win_platform?
12
16
  require 'facter'
13
17
  @runtime_specification = Gem.loaded_specs[GEM_NAME]
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rbconfig'
4
+
5
+ module OpenVoxAgentRubygems
6
+ def self.activate!
7
+ return false unless packaged_agent_ruby?
8
+
9
+ unless ENV.key?('GEM_HOME') || ENV.key?('GEM_PATH')
10
+ restore_paths!
11
+ return !@gem_paths.nil?
12
+ end
13
+
14
+ original_paths = Gem.path
15
+ ENV.delete('GEM_HOME')
16
+ ENV.delete('GEM_PATH')
17
+ Gem.clear_paths
18
+
19
+ agent_paths = Gem.path.reject { |path| user_ruby_path?(path) }
20
+ preserved_paths = original_paths.reject { |path| user_ruby_path?(path) }
21
+ combined_paths = (preserved_paths + agent_paths).uniq
22
+ @gem_home = combined_paths.first
23
+ @gem_paths = combined_paths
24
+ restore_paths!
25
+ add_gem_require_paths!(preserved_paths)
26
+ true
27
+ end
28
+
29
+ def self.restore_paths!
30
+ return false unless packaged_agent_ruby?
31
+ return false if @gem_paths.nil?
32
+
33
+ Gem.use_paths(@gem_home, @gem_paths) unless Gem.path == @gem_paths
34
+ true
35
+ end
36
+
37
+ def self.add_gem_require_paths!(gem_paths)
38
+ gem_paths.each do |gem_path|
39
+ specification_dir = File.join(gem_path, 'specifications')
40
+ next unless Dir.exist?(specification_dir)
41
+
42
+ Dir[File.join(specification_dir, '*.gemspec')].sort.each do |specification_path|
43
+ specification = Gem::Specification.load(specification_path)
44
+ next if specification.nil?
45
+ next if specification.name == 'openvox-editor-services'
46
+
47
+ specification.full_require_paths.reverse_each do |require_path|
48
+ $LOAD_PATH.unshift(require_path) unless $LOAD_PATH.include?(require_path)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ private_class_method :add_gem_require_paths!
54
+
55
+ def self.packaged_agent_ruby?
56
+ [RbConfig::CONFIG['prefix'], Gem.default_dir].compact.any? do |path|
57
+ normalized_path(path).include?('/puppetlabs/puppet')
58
+ end
59
+ end
60
+ private_class_method :packaged_agent_ruby?
61
+
62
+ def self.normalized_path(path)
63
+ File.expand_path(path.to_s).tr('\\', '/').downcase
64
+ end
65
+ private_class_method :normalized_path
66
+
67
+ def self.user_ruby_path?(path)
68
+ normalized = normalized_path(path)
69
+ home = begin
70
+ Dir.home
71
+ rescue StandardError
72
+ nil
73
+ end
74
+
75
+ return false if home.nil? || home.empty?
76
+
77
+ normalized_home = normalized_path(home)
78
+ normalized.start_with?(File.join(normalized_home, '.rvm')) ||
79
+ normalized.start_with?(File.join(normalized_home, '.gem'))
80
+ end
81
+ private_class_method :user_ruby_path?
82
+ end
@@ -1,14 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'openvox_agent_rubygems'
4
+
3
5
  module OpenVoxRuntime
4
6
  GEM_NAME = 'openvox'
5
7
 
6
8
  def self.activate!(version = nil)
9
+ OpenVoxAgentRubygems.activate!
7
10
  specification = select_specification(version)
8
11
  raise Gem::LoadError, "Unable to find the #{GEM_NAME} gem#{version.nil? ? '' : " version #{version}"}" if specification.nil?
9
12
 
10
13
  if Gem::Specification.find_all_by_name(GEM_NAME).include?(specification)
11
14
  version.nil? || version.empty? ? gem(GEM_NAME) : gem(GEM_NAME, version)
15
+ OpenVoxAgentRubygems.restore_paths!
12
16
  else
13
17
  # OpenVox agent packages may retain a puppet-<version>.gemspec filename.
14
18
  # RubyGems ignores that file for lookup by the declared `openvox` name,
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'puppet-languageserver/manifest/format_on_type_provider'
4
+ require 'puppet-languageserver/puppet_lint'
5
+
6
+ module PuppetLanguageServer
7
+ module Manifest
8
+ class DocumentFormattingProvider
9
+ class << self
10
+ def instance
11
+ @instance ||= new
12
+ end
13
+ end
14
+
15
+ def format(content, formatting_options, max_filesize = 4096)
16
+ return [] unless formatting_options['insertSpaces'] == true
17
+ return [] if !max_filesize.zero? && (content.length > max_filesize)
18
+
19
+ lexer = PuppetLint::Lexer.new
20
+ tokens = lexer.tokenise(content)
21
+ edits = {}
22
+
23
+ tokens.select { |token| token.type == :FARROW }.each do |token|
24
+ FormatOnTypeProvider.instance.format(
25
+ content,
26
+ token.line - 1,
27
+ token.column,
28
+ '>',
29
+ formatting_options,
30
+ max_filesize
31
+ ).each do |edit|
32
+ edits[edit.to_h] = edit
33
+ end
34
+ end
35
+
36
+ edits.values.sort_by do |edit|
37
+ [edit.range.start.line, edit.range.start.character, edit.range.end.line, edit.range.end.character]
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -243,6 +243,25 @@ module PuppetLanguageServer
243
243
  nil
244
244
  end
245
245
 
246
+ def request_textdocument_formatting(_, json_rpc_message)
247
+ file_uri = json_rpc_message.params['textDocument']['uri']
248
+ content = documents.document_content(file_uri)
249
+
250
+ case documents.document_type(file_uri)
251
+ when :manifest
252
+ PuppetLanguageServer::Manifest::DocumentFormattingProvider.instance.format(
253
+ content,
254
+ json_rpc_message.params['options'],
255
+ language_client.format_on_type_filesize_limit
256
+ )
257
+ else
258
+ raise "Unable to format document on #{file_uri}"
259
+ end
260
+ rescue StandardError => e
261
+ PuppetLanguageServer.log_message(:error, "(textDocument/formatting) #{e}")
262
+ nil
263
+ end
264
+
246
265
  def request_textdocument_ontypeformatting(_, json_rpc_message)
247
266
  return nil unless language_client.format_on_type
248
267
 
@@ -4,6 +4,7 @@
4
4
  epp/validation_provider
5
5
  manifest/completion_provider
6
6
  manifest/definition_provider
7
+ manifest/document_formatting_provider
7
8
  manifest/document_symbol_provider
8
9
  manifest/folding_provider
9
10
  manifest/format_on_type_provider
@@ -19,6 +19,7 @@ module PuppetLanguageServer
19
19
  'triggerCharacters' => ['>', '$', '[', '=']
20
20
  },
21
21
  'definitionProvider' => true,
22
+ 'documentFormattingProvider' => true,
22
23
  'documentSymbolProvider' => true,
23
24
  'workspaceSymbolProvider' => true,
24
25
  'signatureHelpProvider' => {
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PuppetEditorServices
4
- PUPPETEDITORSERVICESVERSION = '3.0.0' unless defined? PUPPETEDITORSERVICESVERSION
4
+ PUPPETEDITORSERVICESVERSION = '3.1.0' unless defined? PUPPETEDITORSERVICESVERSION
5
5
 
6
6
  # @api public
7
7
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openvox-editor-services
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenVox Project contributors
@@ -130,6 +130,7 @@ files:
130
130
  - Gemfile
131
131
  - LICENSE
132
132
  - README.md
133
+ - RELEASE.md
133
134
  - Rakefile
134
135
  - bin/openvox-debugserver
135
136
  - bin/openvox-languageserver
@@ -158,6 +159,7 @@ files:
158
159
  - lib/lsp/lsp_protocol_workspacefolders.rb
159
160
  - lib/lsp/lsp_types.rb
160
161
  - lib/openfact_runtime.rb
162
+ - lib/openvox_agent_rubygems.rb
161
163
  - lib/openvox_runtime.rb
162
164
  - lib/puppet-debugserver/debug_session/break_points.rb
163
165
  - lib/puppet-debugserver/debug_session/flow_control.rb
@@ -191,6 +193,7 @@ files:
191
193
  - lib/puppet-languageserver/global_queues/validation_queue.rb
192
194
  - lib/puppet-languageserver/manifest/completion_provider.rb
193
195
  - lib/puppet-languageserver/manifest/definition_provider.rb
196
+ - lib/puppet-languageserver/manifest/document_formatting_provider.rb
194
197
  - lib/puppet-languageserver/manifest/document_symbol_provider.rb
195
198
  - lib/puppet-languageserver/manifest/folding_provider.rb
196
199
  - lib/puppet-languageserver/manifest/format_on_type_provider.rb