Add initialization_options to Sorbet LSP linter (#4954)

* Add initialization_options to Sorbet LSP linter

Using a predefined object will ensure that Sorbet always receives an
object instead of an array. LSP defines the initializationOptions as
anything. Unfortunately Sorbet is too strict and raises an error when
anything other than an object is passed which causes the linter to fail

* Document empty objects will prevent Sorbet from properly initializing
This commit is contained in:
Leo Correa
2025-07-20 12:13:33 +02:00
committed by GitHub
parent 9abe393961
commit c8890af8d4
3 changed files with 29 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ Before:
let g:ale_ruby_sorbet_executable = 'srb'
let g:ale_ruby_sorbet_options = ''
let g:ale_ruby_sorbet_enable_watchman = 0
let g:ale_ruby_sorbet_initialization_options = { 'highlightUntyped': v:false }
After:
call ale#assert#TearDownLinterTest()
@@ -32,3 +33,11 @@ Execute(Setting bundle appends 'exec srb tc'):
AssertLinter 'path to/bundle', ale#Escape('path to/bundle')
\ . ' exec srb'
\ . ' tc --lsp --disable-watchman'
Execute(Should use predetermined initialization_options by default):
AssertLSPOptions { 'highlightUntyped': v:false }
Execute(Should be able to set custom initialization_options):
let g:ale_ruby_sorbet_initialization_options = {'enableTypedFalse': v:true}
AssertLSPOptions {'enableTypedFalse': v:true}