]> git.huck.website - nvim.git/commitdiff
added: rust tools
authorHuck Boles <huck@huck.website>
Sat, 17 Jun 2023 02:39:43 +0000 (21:39 -0500)
committerHuck Boles <huck@huck.website>
Sat, 17 Jun 2023 02:39:43 +0000 (21:39 -0500)
lua/plugins/lsp.lua

index 763d5629b74784cac8db8b3ac744d051d50df820..467ea009052cd80d6095b727dad5a96f601e3686 100644 (file)
@@ -78,44 +78,44 @@ return {
         config = function()
             -- servers to setup
             local lsp = require("lspconfig")
-            lsp.rust_analyzer.setup({
-                settings = {
-                    ['rust-analyzer'] = {
-                        completion = {
-                            privateEditable = true,
-                            completionItem = {
-                                preselectSupport = true,
-                                snippetSupport = true,
-                            }
-                        },
-                        hover = {
-                            actions = {
-                                enable = true,
-                                references = true,
-                            }
-                        },
-                        imports = {
-                            granularity = {
-                                enforce = true,
-                            },
-                            group = true,
-                            prefix = "self",
-                        },
-                        inlayHints = {
-                            closureCaptureHints       = true,
-                            closureReturnTypeHints    = true,
-                            lifetimeElisionHints      = true,
-                            discriminantHints         = true,
-                            expressionAdjustmentHints = { enable = true, mode = "postfix" },
-                            closingBraceHints         = { enable = true, minLines = 1 },
-                        },
-                        highlightRelated = { enable = true },
-                        magicCompletions = { enable = true },
-                        procMacro = {
-                            enable = true
-                        } }
-                }
-            })
+            -- lsp.rust_analyzer.setup({
+            --     settings = {
+            --         ['rust-analyzer'] = {
+            --             completion = {
+            --                 privateEditable = true,
+            --                 completionItem = {
+            --                     preselectSupport = true,
+            --                     snippetSupport = true,
+            --                 }
+            --             },
+            --             hover = {
+            --                 actions = {
+            --                     enable = true,
+            --                     references = true,
+            --                 }
+            --             },
+            --             imports = {
+            --                 granularity = {
+            --                     enforce = true,
+            --                 },
+            --                 group = true,
+            --                 prefix = "self",
+            --             },
+            --             inlayHints = {
+            --                 closureCaptureHints       = true,
+            --                 closureReturnTypeHints    = true,
+            --                 lifetimeElisionHints      = true,
+            --                 discriminantHints         = true,
+            --                 expressionAdjustmentHints = { enable = true, mode = "postfix" },
+            --                 closingBraceHints         = { enable = true, minLines = 1 },
+            --             },
+            --             highlightRelated = { enable = true },
+            --             magicCompletions = { enable = true },
+            --             procMacro = {
+            --                 enable = true
+            --             } }
+            --     }
+            -- })
             lsp.awk_ls.setup({})
             lsp.bashls.setup({})
             lsp.clangd.setup({})
@@ -170,4 +170,46 @@ return {
             })
         end,
     },
+
+    {
+        'simrat39/rust-tools.nvim',
+        ft = "rust",
+        config = function()
+            local rust = require("rust-tools")
+
+            rust.setup(
+                {
+                    tools = {
+                        inlay_hints = {
+                            only_current_line = true,
+                            parameter_hints_prefix = "",
+                            other_hints_prefix = "< "
+                        },
+                        hover_actions = {
+                            border = {
+                                { "┏", "FloatBorder" },
+                                { "━", "FloatBorder" },
+                                { "┓", "FloatBorder" },
+                                { "┃", "FloatBorder" },
+                                { "┛", "FloatBorder" },
+                                { "━", "FloatBorder" },
+                                { "┗", "FloatBorder" },
+                                { "┃", "FloatBorder" },
+                            },
+                            auto_focus = true
+                        }
+                    },
+                    server = {
+                        on_attach = function(_, bufnr)
+                            vim.keymap.set('n', '<LEADER>k', rust.hover_actions.hover_actions, { buffer = bufnr })
+                            vim.keymap.set('n', '<LEADER>a', rust.code_action_group.code_action_group, { buffer = bufnr })
+                            vim.keymap.set('n', '<LEADER>m', rust.expand_macro.expand_macro, { buffer = bufnr })
+                            vim.keymap.set('n', '<LEADER>c', rust.open_cargo_toml.open_cargo_toml, { buffer = bufnr })
+                            vim.keymap.set('n', '<LEADER>P', rust.parent_module.parent_module, { buffer = bufnr })
+                        end
+                    }
+                }
+            )
+        end
+    },
 }