@@ -125,23 +125,23 @@ configuration. The following code will work for any checkout of rust-lang/rust (
125
125
``` lua
126
126
lspconfig .rust_analyzer .setup {
127
127
root_dir = function ()
128
- default = lspconfig .rust_analyzer .config_def .default_config .root_dir ()
128
+ local default = lspconfig .rust_analyzer .config_def .default_config .root_dir ()
129
129
-- the default root detection uses the cargo workspace root.
130
130
-- but for rust-lang/rust, the standard library is in its own workspace.
131
131
-- use the git root instead.
132
- compiler_config = vim .fs .joinpath (default , " ../src/bootstrap/defaults/config.compiler.toml" )
132
+ local compiler_config = vim .fs .joinpath (default , " ../src/bootstrap/defaults/config.compiler.toml" )
133
133
if vim .fs .basename (default ) == " library" and vim .uv .fs_stat (compiler_config ) then
134
134
return vim .fs .dirname (default )
135
135
end
136
136
return default
137
137
end ,
138
138
on_init = function (client )
139
139
local path = client .workspace_folders [1 ].name
140
- config = vim .fs .joinpath (path , " src/etc/rust_analyzer_zed.json" )
140
+ local config = vim .fs .joinpath (path , " src/etc/rust_analyzer_zed.json" )
141
141
if vim .uv .fs_stat (config ) then
142
142
-- load rust-lang/rust settings
143
- file = io.open (config )
144
- json = vim .json .decode (file :read (" *a" ))
143
+ local file = io.open (config )
144
+ local json = vim .json .decode (file :read (" *a" ))
145
145
client .config .settings [" rust-analyzer" ] = json .lsp [" rust-analyzer" ].initialization_options
146
146
client .notify (" workspace/didChangeConfiguration" , { settings = client .config .settings })
147
147
end
0 commit comments