Use rustaceanvim instead of rust-tools

main
Ensar Sarajčić 2024-01-19 11:37:39 +01:00
parent ce2915ca89
commit 227a9ab657
4 changed files with 31 additions and 45 deletions

View File

@ -147,7 +147,7 @@ return require("lazy").setup({
-- LSP language specific
"folke/neodev.nvim", -- Built-in Lua integration with LSP
"akinsho/flutter-tools.nvim", -- Additional flutter integrations
"simrat39/rust-tools.nvim", -- Additional rust integrations
{ "mrcjkb/rustaceanvim", ft = "rust" }, -- Additional rust integrations
{ "mfussenegger/nvim-jdtls", ft = "java" }, -- Additional java integrations
-- Lua support

View File

@ -39,6 +39,10 @@ local function on_attach(client, bufnr)
buffer = bufnr,
})
end
if vim.fn.has("nvim-0.10") then
vim.lsp.inlay_hint.enable(bufnr, true)
end
end
return {

View File

@ -35,24 +35,6 @@ local configuration_overrides = {
lemminx = {
cmd = { "lemminx" },
},
rust_analyzer = {
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
},
procMacro = {
enable = true,
},
hoverActions = {
enable = false,
},
cargo = {
loadOutDirsFromCheck = true,
},
},
},
},
lua_ls = {
settings = {
Lua = {
@ -97,20 +79,30 @@ end
-- Flutter tools
require("flutter-tools").setup({
lsp = common_config,
flutter_lookup_cmd = "asdf where flutter"
flutter_lookup_cmd = "asdf where flutter",
})
-- Rust tools
local rt = require("rust-tools")
rt.setup({
vim.g.rustaceanvim = {
server = vim.tbl_extend("force", common_config, {
on_attach = function(client, bufnr)
common_config.on_attach(client, bufnr)
-- Hover actions
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
end,
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
},
procMacro = {
enable = true,
},
hoverActions = {
enable = false,
},
cargo = {
loadOutDirsFromCheck = true,
},
},
},
}),
})
}

View File

@ -32,13 +32,13 @@ local edit_modes = {
}
local function update_colors()
local status_line_hl = vim.api.nvim_get_hl_by_name("StatusLine", true)
local bg = status_line_hl.foreground
local status_line_hl = vim.api.nvim_get_hl(0, { name = "StatusLine" })
local bg = status_line_hl.bg
local function set_user_highlight_based_on(user_hl_name, based_on)
local hl_based_on = vim.api.nvim_get_hl_by_name(based_on, true)
local hl_based_on = vim.api.nvim_get_hl(0, { name = based_on })
local user_config = {
foreground = hl_based_on.foreground,
foreground = hl_based_on.fg,
background = bg,
bold = true,
}
@ -138,7 +138,7 @@ end
local function get_current_override()
local bufnr = vim.fn.winbufnr(vim.g.statusline_winid)
return get_override(vim.api.nvim_buf_get_option(bufnr, "filetype"))
return get_override(vim.api.nvim_get_option_value("filetype", { buf = bufnr }))
end
local statuslines = {
@ -162,19 +162,9 @@ local statuslines = {
status = status .. get_paste_string()
-- Take just the first message which makes sense
local first_lsp_message = vim.tbl_filter(function(msg)
return not msg.done and msg.progress
end, vim.lsp.util.get_progress_messages())[1]
local first_lsp_message = vim.lsp.status()
if first_lsp_message then
status = status
.. " %2*"
.. "["
.. (first_lsp_message.name or "")
.. "]"
.. (first_lsp_message.percentage and "(" .. first_lsp_message.percentage .. "%%)" or "")
.. " "
.. (first_lsp_message.title or "")
.. "%*"
status = status .. " %2*" .. first_lsp_message .. "%*"
end
local build_status_last = require("devcontainer.status").find_build({ running = true })