From a0ebc042c8c4d705438abd32cbd64ae8e617d092 Mon Sep 17 00:00:00 2001 From: Nick Zana Date: Mon, 15 Nov 2021 02:29:21 -0500 Subject: [PATCH] Revert "Remove rust-specific features" This reverts commit 0fd1209ff6a53662c898136752156691260ada64. --- lua/keybindings.lua | 4 ++++ lua/lsp.lua | 19 +++++++++++++++++++ lua/plugins.lua | 7 +++++++ 3 files changed, 30 insertions(+) diff --git a/lua/keybindings.lua b/lua/keybindings.lua index 5257273..95786f1 100644 --- a/lua/keybindings.lua +++ b/lua/keybindings.lua @@ -84,4 +84,8 @@ local on_attach = function(client, bufnr) end +-- Code actions +-- TODO: Generalize to LSP or only attach on Rust buffers +map('n', 't', 'RustTest', options) -- Run test under cursor + return { on_attach = on_attach } diff --git a/lua/lsp.lua b/lua/lsp.lua index efa2098..b885621 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -1,3 +1,22 @@ local on_attach = require'keybindings'.on_attach local capabilities = require'cmp_nvim_lsp'.update_capabilities(vim.lsp.protocol.make_client_capabilities()) local cmp = require'nvim-cmp-cfg'.cmp + +-- SERVERS +-- rust_analyzer +vim.g.rustfmt_autosave = 1 +require'lspconfig'.rust_analyzer.setup{ + on_attach = on_attach, + capabilities = capabilities, + settings = { + ["rust-analyzer"] = { + procMacro = { + enable = true, + }, + checkOnSave = { + command = 'clippy', + extraArgs = "-W clippy::pedantic" + }, + } + } +} diff --git a/lua/plugins.lua b/lua/plugins.lua index 8762a60..d14f765 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -31,9 +31,16 @@ local plugins = require('packer').startup(function(use) use 'hrsh7th/cmp-vsnip' use 'hrsh7th/vim-vsnip' + -- Language Specfic + use 'rust-lang/rust.vim' + if packer_bootstrap then require('packer').sync() end end) +-- Required for rust.vim +-- TODO: Convert to lua +vim.cmd([[filetype plugin indent on]]) + return plugins