Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

add features "choice module to use" and "support float notify window" #382

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,21 @@ local opts = {
name = "rt_lldb",
},
},

-- choice module you use to speed up setuptime
open = {
crate_graph = true,
expand_macro = true,
external_docs = true,
debuggables = true,
hover_range = true,
workspace_refresh = true,
move_item = true,
standalone = true,
dap = true,
parent_module = true,
runnables = true,
},
}

require('rust-tools').setup(opts)
Expand Down
20 changes: 18 additions & 2 deletions lua/rust-tools/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ _G.rust_tools_get_graphviz_backends = function()
end

local defaults = {
tools = { -- rust-tools options
tools = {
-- rust-tools options

-- how to execute terminal commands
-- options right now: termopen / quickfix
Expand Down Expand Up @@ -60,7 +61,6 @@ local defaults = {

-- options same as lsp hover / vim.lsp.util.open_floating_preview()
hover_actions = {

-- the border that is used for the hover window
-- see vim.api.nvim_open_win()
border = {
Expand Down Expand Up @@ -180,12 +180,28 @@ local defaults = {
name = "rt_lldb",
},
},

-- choice module you use
open = {
crate_graph = true,
expand_macro = true,
external_docs = true,
debuggables = true,
hover_range = true,
workspace_refresh = true,
move_item = true,
standalone = true,
dap = true,
parent_module = true,
runnables = true,
},
}

M.options = {
tools = {},
server = {},
dap = {},
open = {},
}

function M.setup(options)
Expand Down
83 changes: 56 additions & 27 deletions lua/rust-tools/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ local M = {
}

function M.setup(opts)
if opts.open == nil then
opts.open = {}
end

local code_action_group = require("rust-tools.code_action_group")
M.code_action_group = code_action_group

Expand All @@ -39,27 +43,37 @@ function M.setup(opts)

local config = require("rust-tools.config")
M.config = config
config.setup(opts)

local crate_graph = require("rust-tools.crate_graph")
M.crate_graph = crate_graph
local open = M.config.options.open

local rt_dap = require("rust-tools.dap")
M.dap = rt_dap
if open.crate_graph ~= false then
local crate_graph = require("rust-tools.crate_graph")
M.crate_graph = crate_graph
end

local debuggables = require("rust-tools.debuggables")
M.debuggables = debuggables
if open.debuggables ~= false then
local debuggables = require("rust-tools.debuggables")
M.debuggables = debuggables
end

local expand_macro = require("rust-tools.expand_macro")
M.expand_macro = expand_macro
if open.expand_macro ~= false then
local expand_macro = require("rust-tools.expand_macro")
M.expand_macro = expand_macro
end

local external_docs = require("rust-tools.external_docs")
M.external_docs = external_docs
if open.external_docs ~= false then
local external_docs = require("rust-tools.external_docs")
M.external_docs = external_docs
end

local hover_actions = require("rust-tools.hover_actions")
M.hover_actions = hover_actions

local hover_range = require("rust-tools.hover_range")
M.hover_range = hover_range
if open.hover_actions ~= false then
local hover_range = require("rust-tools.hover_range")
M.hover_range = hover_range
end

local inlay = require("rust-tools.inlay_hints")
local hints = inlay.new()
Expand All @@ -84,45 +98,60 @@ function M.setup(opts)
end,
}

local join_lines = require("rust-tools.join_lines")
M.join_lines = join_lines
if open.join_lines ~= false then
local join_lines = require("rust-tools.join_lines")
M.join_lines = join_lines
end

local lsp = require("rust-tools.lsp")
M.lsp = lsp

local move_item = require("rust-tools.move_item")
M.move_item = move_item
if open.move_item ~= false then
local move_item = require("rust-tools.move_item")
M.move_item = move_item
end

local open_cargo_toml = require("rust-tools.open_cargo_toml")
M.open_cargo_toml = open_cargo_toml

local parent_module = require("rust-tools.parent_module")
M.parent_module = parent_module
if open.parent_module ~= false then
local parent_module = require("rust-tools.parent_module")
M.parent_module = parent_module
end

local runnables = require("rust-tools.runnables")
M.runnables = runnables
if open.runnables ~= false then
local runnables = require("rust-tools.runnables")
M.runnables = runnables
end

local server_status = require("rust-tools.server_status")
M.server_status = server_status

local ssr = require("rust-tools.ssr")
M.ssr = ssr

local standalone = require("rust-tools.standalone")
M.standalone = standalone
if open.standalone ~= false then
local standalone = require("rust-tools.standalone")
M.standalone = standalone
end

local workspace_refresh = require("rust-tools.workspace_refresh")
M.workspace_refresh = workspace_refresh
if open.workspace_refresh ~= false then
local workspace_refresh = require("rust-tools.workspace_refresh")
M.workspace_refresh = workspace_refresh
end

local utils = require("rust-tools.utils.utils")
M.utils = utils

config.setup(opts)
lsp.setup()
commands.setup_lsp_commands()

if pcall(require, "dap") then
rt_dap.setup_adapter()
if opts.open.dap ~= false then
local rt_dap = require("rust-tools.dap")
M.dap = rt_dap
if pcall(require, "dap") then
rt_dap.setup_adapter()
end
end
end

Expand Down
Loading