From ec11b85df73cce4edb2925cb7f1d0e8db3a07b1c Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Sat, 3 Jul 2021 14:45:08 -0700 Subject: ci: lint and format with stylua --- lua/lspconfig/rust_analyzer.lua | 57 +++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'lua/lspconfig/rust_analyzer.lua') 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 -- cgit v1.2.3-70-g09d2