From 36bd3ea0e9f09ad4369083f66ac633e3ce673c6a Mon Sep 17 00:00:00 2001 From: Maciej Jur Date: Mon, 10 Jul 2023 14:30:11 +0200 Subject: [PATCH] Add rust tools --- nvim/lazy-lock.json | 1 + nvim/lua/configs/rust-tools.lua | 23 +++++++++++++++++++++++ nvim/lua/global.lua | 7 +++++++ nvim/lua/plugins.lua | 4 ++++ 4 files changed, 35 insertions(+) create mode 100644 nvim/lua/configs/rust-tools.lua diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index b9fd292..51979b1 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -7,5 +7,6 @@ "nvim-web-devicons": { "branch": "master", "commit": "9ab9b0b894b2388a9dbcdee5f00ce72e25d85bf9" }, "plenary.nvim": { "branch": "master", "commit": "bda256fab0eb66a15e8190937e417e6a14ee5d72" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, + "rust-tools.nvim": { "branch": "master", "commit": "71d2cf67b5ed120a0e31b2c8adb210dd2834242f" }, "telescope.nvim": { "branch": "master", "commit": "276362a8020c6e94c7a76d49aa00d4923b0c02f3" } } \ No newline at end of file diff --git a/nvim/lua/configs/rust-tools.lua b/nvim/lua/configs/rust-tools.lua new file mode 100644 index 0000000..7d949f0 --- /dev/null +++ b/nvim/lua/configs/rust-tools.lua @@ -0,0 +1,23 @@ +return function() + local rt = require "rust-tools" + rt.setup({ + server = { + on_attach = function(client, bufnr) + vim.keymap.set('n', "", rt.hover_actions.hover_actions, { buffer = bufnr }) + vim.keymap.set('n', "a", rt.code_action_group.code_action_group, { buffer = bufnr }) + + local buf_opts = { noremap = true, silent = true, buffer = buf_number } + vim.keymap.set('n', 'K', vim.lsp.buf.hover, buf_opts) + end, + ["rust-analyzer"] = { + cargo = { allFeatures = true }, + checkOnSave = { + -- default: `cargo check` + command = "clippy", + allFeatures = true, + } + } + } + }) +end + diff --git a/nvim/lua/global.lua b/nvim/lua/global.lua index 8e0a1de..1df3303 100644 --- a/nvim/lua/global.lua +++ b/nvim/lua/global.lua @@ -17,3 +17,10 @@ vim.filetype.add({ } }) +-- Workaround: https://github.com/neovim/neovim/issues/21856 +vim.api.nvim_create_autocmd({ "VimLeave" }, { + callback = function() + vim.fn.jobstart('notify-send "hello"', {detach=true}) + end, +}) + diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index ffe3ce2..2e9288a 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -7,6 +7,10 @@ return { "neovim/nvim-lspconfig", config = require "configs/lspconfig", }, + { + "simrat39/rust-tools.nvim", + config = require "configs/rust-tools", + }, { "nvim-treesitter/nvim-treesitter", config = require "configs/treesitter",