diff --git a/dots/.nvim-environments/primary/config/after/ftplugin/rust.lua b/dots/.nvim-environments/primary/config/after/ftplugin/rust.lua deleted file mode 100644 index d23d99c0..00000000 --- a/dots/.nvim-environments/primary/config/after/ftplugin/rust.lua +++ /dev/null @@ -1,30 +0,0 @@ -vim.keymap.set("n", "fr", ":RustRunnables", { - buffer = true, -}) -vim.keymap.set("n", "fd", ":RustDebuggables", { - buffer = true, -}) -vim.keymap.set("n", "fp", ":RustParentModule", { - buffer = true, -}) -vim.keymap.set("n", "fJ", ":RustJoinLines", { - buffer = true, -}) -vim.keymap.set("n", "fh", ":RustHoverActions", { - buffer = true, -}) -vim.keymap.set("n", "fH", ":RustHoverRange", { - buffer = true, -}) -vim.keymap.set("n", "fm", ":RustExpandMacro", { - buffer = true, -}) -vim.keymap.set("n", "fc", ":RustOpenCargo", { - buffer = true, -}) -vim.keymap.set("n", "fk", ":RustMoveItemUp", { - buffer = true, -}) -vim.keymap.set("n", "fj", ":RustMoveItemDown", { - buffer = true, -}) diff --git a/dots/.nvim-environments/primary/config/lua/plugins/configs/lsp.lua b/dots/.nvim-environments/primary/config/lua/plugins/configs/lsp.lua index fc05ce57..e5e72152 100755 --- a/dots/.nvim-environments/primary/config/lua/plugins/configs/lsp.lua +++ b/dots/.nvim-environments/primary/config/lua/plugins/configs/lsp.lua @@ -24,20 +24,7 @@ local opts = { on_attach = on_attach, } --- INFO: RUST LSP --- In the scenario we're using rust it makes more sense to use rust-tools --- see: https://github.com/williamboman/nvim-lsp-installer/wiki/Rust --- --- NOTE: Requires rust_analyzer --- --- Dap installation, required vscode and the following extension to be installed: --- https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb --- --- locate it with `find ~/ -name ` -local extension_path = os.getenv("HOME") .. "/.vscode/extensions/vadimcn.vscode-lldb-1.6.10/" -local codelldb_path = extension_path .. "adapter/codelldb" -local liblldb_path = extension_path .. "lldb/lib/liblldb.dylib" - +local rust_tools = require("rust-tools") local rustopts = { server = opts, dap = { @@ -96,9 +83,58 @@ local rustopts = { hover_actions = { auto_focus = true, }, + + server = { + on_attach = function(client, bufnr) + vim.keymap.set("n", "fr", rust_tools.runnables.runnables, { + buffer = bufnr, + }) + + vim.keymap.set("n", "fd", rust_tools.debuggables.debuggables, { + buffer = bufnr, + }) + + vim.keymap.set("n", "fp", rust_tools.parent_module.parent_module, { + buffer = bufnr, + }) + + vim.keymap.set("n", "fJ", rust_tools.join_lines.join_lines, { + buffer = bufnr, + }) + + vim.keymap.set("n", "fH", rust_tools.hover_range.hover_range, { + buffer = bufnr, + }) + + vim.keymap.set("n", "fm", rust_tools.expand_macro.expand_macro, { + buffer = bufnr, + }) + + vim.keymap.set("n", "fc", rust_tools.open_cargo_toml.open_cargo_toml, { + buffer = bufnr, + }) + + vim.keymap.set("n", "fk", ":RustMoveItemUp", { + buffer = bufnr, + }) + + vim.keymap.set("n", "fj", ":RustMoveItemDown", { + buffer = bufnr, + }) + + vim.keymap.set("n", "fh", rust_tools.hover_actions.hover_actions, { + buffer = bufnr, + }) + + vim.keymap.set("n", "fa", rust_tools.code_action_group.code_action_group, { + buffer = bufnr, + }) + on_attach(client, bufnr) + end, + }, }, } -require("rust-tools").setup(rustopts) +rust_tools.setup(rustopts) -- NOTE: ANSIBLE LSP -- I use ansible a lot, define exceptions for servers that can use