-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rust IDE #16
Rust IDE #16
Conversation
|
Debugging in the config above only works when -- if you don't want all the parsers change this to a table of the ones you want
lvim.builtin.treesitter.ensure_installed = {
"lua",
"rust",
"toml",
}
lvim.builtin.dap.active = true
lvim.builtin.treesitter.highlight.enable = true
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "rust_analyzer" })
local formatters = require "lvim.lsp.null-ls.formatters"
formatters.setup {
{ command = "stylua", filetypes = { "lua" } },
}
-- CHANGED --
local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/")
local codelldb_adapter = {
type = "server",
port = "${port}",
executable = {
command = mason_path .. "bin/codelldb",
args = { "--port", "${port}" },
-- On windows you may have to uncomment this:
-- detached = false,
},
}
pcall(function()
require("rust-tools").setup {
tools = {
executor = require("rust-tools/executors").termopen, -- can be quickfix or termopen
reload_workspace_from_cargo_toml = true,
runnables = {
use_telescope = true,
},
inlay_hints = {
auto = true,
only_current_line = false,
show_parameter_hints = false,
parameter_hints_prefix = "<-",
other_hints_prefix = "=>",
max_len_align = false,
max_len_align_padding = 1,
right_align = false,
right_align_padding = 7,
highlight = "Comment",
},
hover_actions = {
border = "rounded",
},
on_initialized = function()
vim.api.nvim_create_autocmd({ "BufWritePost", "BufEnter", "CursorHold", "InsertLeave" }, {
pattern = { "*.rs" },
callback = function()
local _, _ = pcall(vim.lsp.codelens.refresh)
end,
})
end,
},
dap = {
adapter = codelldb_adapter,
},
server = {
on_attach = function(client, bufnr)
require("lvim.lsp").common_on_attach(client, bufnr)
local rt = require "rust-tools"
vim.keymap.set("n", "K", rt.hover_actions.hover_actions, { buffer = bufnr })
end,
capabilities = require("lvim.lsp").common_capabilities(),
settings = {
["rust-analyzer"] = {
lens = {
enable = true,
},
checkOnSave = {
enable = true,
command = "clippy",
},
},
},
},
}
end)
-- CHANGED --
lvim.builtin.dap.on_config_done = function(dap)
dap.adapters.codelldb = codelldb_adapter
dap.configurations.rust = {
{
name = "Launch file",
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
},
}
end
vim.api.nvim_set_keymap("n", "<m-d>", "<cmd>RustOpenExternalDocs<Cr>", { noremap = true, silent = true })
lvim.builtin.which_key.mappings["L"] = {
name = "Rust",
r = { "<cmd>RustRunnables<Cr>", "Runnables" },
t = { "<cmd>lua _CARGO_TEST()<cr>", "Cargo Test" },
m = { "<cmd>RustExpandMacro<Cr>", "Expand Macro" },
c = { "<cmd>RustOpenCargo<Cr>", "Open Cargo" },
p = { "<cmd>RustParentModule<Cr>", "Parent Module" },
d = { "<cmd>RustDebuggables<Cr>", "Debuggables" },
v = { "<cmd>RustViewCrateGraph<Cr>", "View Crate Graph" },
R = {
"<cmd>lua require('rust-tools/workspace_refresh')._reload_workspace_from_cargo_toml()<Cr>",
"Reload Workspace",
},
o = { "<cmd>RustOpenExternalDocs<Cr>", "Open External Docs" },
}
lvim.plugins = {
"simrat39/rust-tools.nvim",
{
"saecki/crates.nvim",
tag = "v0.3.0",
requires = { "nvim-lua/plenary.nvim" },
config = function()
require("crates").setup {
null_ls = {
enabled = true,
name = "crates.nvim",
},
}
end,
},
{
"j-hui/fidget.nvim",
config = function()
require("fidget").setup()
end,
},
} |
oooh |
I tried this conf but I'm still having issues running any of the mapped Rust commands (LEADER + L) |
actually I can just hover the main function, go to codelens and run debug with it it will recompile and run it automatically |
fixes #4
todo: