File tree Expand file tree Collapse file tree 2 files changed +42
-7
lines changed Expand file tree Collapse file tree 2 files changed +42
-7
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,36 @@ impl RubyLsp {
86
86
_ => None ,
87
87
}
88
88
}
89
+
90
+ pub fn language_server_initialization_options (
91
+ & self ,
92
+ language_server_id : & zed:: LanguageServerId ,
93
+ worktree : & zed:: Worktree ,
94
+ ) -> zed:: Result < Option < zed:: serde_json:: Value > > {
95
+ let mut initialization_options =
96
+ zed:: settings:: LspSettings :: for_worktree ( language_server_id. as_ref ( ) , worktree)
97
+ . ok ( )
98
+ . and_then ( |lsp_settings| lsp_settings. initialization_options . clone ( ) )
99
+ . unwrap_or_else ( || zed:: serde_json:: json!( { } ) ) ;
100
+
101
+ let options_obj = initialization_options
102
+ . as_object_mut ( )
103
+ . expect ( "initialization_options must be an object" ) ;
104
+
105
+ let enabled_features = options_obj
106
+ . entry ( "enabledFeatures" )
107
+ . or_insert_with ( || zed:: serde_json:: json!( { } ) ) ;
108
+
109
+ // Workaround ruby-lsp upstream issue
110
+ // https://github.com/zed-extensions/ruby/issues/38
111
+ if let Some ( features_obj) = enabled_features. as_object_mut ( ) {
112
+ features_obj
113
+ . entry ( "onTypeFormatting" )
114
+ . or_insert ( zed:: serde_json:: Value :: Bool ( false ) ) ;
115
+ }
116
+
117
+ Ok ( Some ( initialization_options) )
118
+ }
89
119
}
90
120
91
121
#[ cfg( test) ]
Original file line number Diff line number Diff line change @@ -82,13 +82,18 @@ impl zed::Extension for RubyExtension {
82
82
language_server_id : & zed:: LanguageServerId ,
83
83
worktree : & zed:: Worktree ,
84
84
) -> zed:: Result < Option < zed:: serde_json:: Value > > {
85
- let initialization_options =
86
- zed:: settings:: LspSettings :: for_worktree ( language_server_id. as_ref ( ) , worktree)
87
- . ok ( )
88
- . and_then ( |lsp_settings| lsp_settings. initialization_options . clone ( ) )
89
- . unwrap_or_default ( ) ;
90
-
91
- Ok ( Some ( zed:: serde_json:: json!( initialization_options) ) )
85
+ match language_server_id. as_ref ( ) {
86
+ RubyLsp :: SERVER_ID => {
87
+ let ruby = self . ruby_lsp . get_or_insert_with ( RubyLsp :: new) ;
88
+ ruby. language_server_initialization_options ( language_server_id, worktree)
89
+ }
90
+ _ => Ok ( Some (
91
+ zed:: settings:: LspSettings :: for_worktree ( language_server_id. as_ref ( ) , worktree)
92
+ . ok ( )
93
+ . and_then ( |lsp_settings| lsp_settings. initialization_options . clone ( ) )
94
+ . unwrap_or_default ( ) ,
95
+ ) ) ,
96
+ }
92
97
}
93
98
94
99
fn label_for_completion (
You can’t perform that action at this time.
0 commit comments