Skip to content

Commit 25eac11

Browse files
jyn514dianqk
andauthored
use lua locals
Co-authored-by: DianQK <[email protected]>
1 parent 39667c5 commit 25eac11

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: src/doc/rustc-dev-guide/src/building/suggested.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,23 @@ configuration. The following code will work for any checkout of rust-lang/rust (
125125
```lua
126126
lspconfig.rust_analyzer.setup {
127127
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()
129129
-- the default root detection uses the cargo workspace root.
130130
-- but for rust-lang/rust, the standard library is in its own workspace.
131131
-- 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")
133133
if vim.fs.basename(default) == "library" and vim.uv.fs_stat(compiler_config) then
134134
return vim.fs.dirname(default)
135135
end
136136
return default
137137
end,
138138
on_init = function(client)
139139
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")
141141
if vim.uv.fs_stat(config) then
142142
-- 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"))
145145
client.config.settings["rust-analyzer"] = json.lsp["rust-analyzer"].initialization_options
146146
client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
147147
end

0 commit comments

Comments
 (0)