aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/rust_analyzer.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/lspconfig/rust_analyzer.lua')
-rw-r--r--lua/lspconfig/rust_analyzer.lua57
1 files changed, 29 insertions, 28 deletions
diff --git a/lua/lspconfig/rust_analyzer.lua b/lua/lspconfig/rust_analyzer.lua
index 20f35706..34c6420f 100644
--- a/lua/lspconfig/rust_analyzer.lua
+++ b/lua/lspconfig/rust_analyzer.lua
@@ -1,22 +1,23 @@
-local configs = require 'lspconfig/configs'
-local util = require 'lspconfig/util'
+local configs = require "lspconfig/configs"
+local util = require "lspconfig/util"
local lsp = vim.lsp
local function reload_workspace(bufnr)
bufnr = util.validate_bufnr(bufnr)
- lsp.buf_request(bufnr, 'rust-analyzer/reloadWorkspace', nil,
- function(err, _, result, _)
- if err then error(tostring(err)) end
- vim.notify("Cargo workspace reloaded")
- end)
+ lsp.buf_request(bufnr, "rust-analyzer/reloadWorkspace", nil, function(err, _, result, _)
+ if err then
+ error(tostring(err))
+ end
+ vim.notify "Cargo workspace reloaded"
+ end)
end
configs.rust_analyzer = {
default_config = {
- cmd = {"rust-analyzer"};
- filetypes = {"rust"};
+ cmd = { "rust-analyzer" },
+ filetypes = { "rust" },
root_dir = function(fname)
- local cargo_crate_dir = util.root_pattern("Cargo.toml")(fname)
+ local cargo_crate_dir = util.root_pattern "Cargo.toml"(fname)
local cmd = "cargo metadata --no-deps --format-version 1"
if cargo_crate_dir ~= nil then
cmd = cmd .. " --manifest-path " .. util.path.join(cargo_crate_dir, "Cargo.toml")
@@ -26,37 +27,37 @@ configs.rust_analyzer = {
if vim.v.shell_error == 0 then
cargo_workspace_dir = vim.fn.json_decode(cargo_metadata)["workspace_root"]
end
- return cargo_workspace_dir or
- cargo_crate_dir or
- util.root_pattern("rust-project.json")(fname) or
- util.find_git_ancestor(fname)
- end;
+ return cargo_workspace_dir
+ or cargo_crate_dir
+ or util.root_pattern "rust-project.json"(fname)
+ or util.find_git_ancestor(fname)
+ end,
settings = {
- ["rust-analyzer"] = {}
- };
- };
+ ["rust-analyzer"] = {},
+ },
+ },
commands = {
CargoReload = {
function()
reload_workspace(0)
- end;
- description = "Reload current cargo workspace"
- }
- };
+ end,
+ description = "Reload current cargo workspace",
+ },
+ },
docs = {
- package_json = "https://raw.githubusercontent.com/rust-analyzer/rust-analyzer/master/editors/code/package.json";
+ package_json = "https://raw.githubusercontent.com/rust-analyzer/rust-analyzer/master/editors/code/package.json",
description = [[
https://github.com/rust-analyzer/rust-analyzer
rust-analyzer (aka rls 2.0), a language server for Rust
See [docs](https://github.com/rust-analyzer/rust-analyzer/tree/master/docs/user#settings) for extra settings.
- ]];
+ ]],
default_config = {
- root_dir = [[root_pattern("Cargo.toml", "rust-project.json")]];
- };
- };
-};
+ root_dir = [[root_pattern("Cargo.toml", "rust-project.json")]],
+ },
+ },
+}
configs.rust_analyzer.reload_workspace = reload_workspace
-- vim:et ts=2 sw=2