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 -- LSP language specific
"folke/neodev.nvim", -- Built-in Lua integration with LSP "folke/neodev.nvim", -- Built-in Lua integration with LSP
"akinsho/flutter-tools.nvim", -- Additional flutter integrations "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 { "mfussenegger/nvim-jdtls", ft = "java" }, -- Additional java integrations
-- Lua support -- Lua support

View File

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

View File

@ -35,24 +35,6 @@ local configuration_overrides = {
lemminx = { lemminx = {
cmd = { "lemminx" }, cmd = { "lemminx" },
}, },
rust_analyzer = {
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
},
procMacro = {
enable = true,
},
hoverActions = {
enable = false,
},
cargo = {
loadOutDirsFromCheck = true,
},
},
},
},
lua_ls = { lua_ls = {
settings = { settings = {
Lua = { Lua = {
@ -97,20 +79,30 @@ end
-- Flutter tools -- Flutter tools
require("flutter-tools").setup({ require("flutter-tools").setup({
lsp = common_config, lsp = common_config,
flutter_lookup_cmd = "asdf where flutter" flutter_lookup_cmd = "asdf where flutter",
}) })
-- Rust tools -- Rust tools
local rt = require("rust-tools") vim.g.rustaceanvim = {
rt.setup({
server = vim.tbl_extend("force", common_config, { server = vim.tbl_extend("force", common_config, {
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
common_config.on_attach(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, 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 function update_colors()
local status_line_hl = vim.api.nvim_get_hl_by_name("StatusLine", true) local status_line_hl = vim.api.nvim_get_hl(0, { name = "StatusLine" })
local bg = status_line_hl.foreground local bg = status_line_hl.bg
local function set_user_highlight_based_on(user_hl_name, based_on) 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 = { local user_config = {
foreground = hl_based_on.foreground, foreground = hl_based_on.fg,
background = bg, background = bg,
bold = true, bold = true,
} }
@ -138,7 +138,7 @@ end
local function get_current_override() local function get_current_override()
local bufnr = vim.fn.winbufnr(vim.g.statusline_winid) 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 end
local statuslines = { local statuslines = {
@ -162,19 +162,9 @@ local statuslines = {
status = status .. get_paste_string() status = status .. get_paste_string()
-- Take just the first message which makes sense -- Take just the first message which makes sense
local first_lsp_message = vim.tbl_filter(function(msg) local first_lsp_message = vim.lsp.status()
return not msg.done and msg.progress
end, vim.lsp.util.get_progress_messages())[1]
if first_lsp_message then if first_lsp_message then
status = status status = status .. " %2*" .. first_lsp_message .. "%*"
.. " %2*"
.. "["
.. (first_lsp_message.name or "")
.. "]"
.. (first_lsp_message.percentage and "(" .. first_lsp_message.percentage .. "%%)" or "")
.. " "
.. (first_lsp_message.title or "")
.. "%*"
end end
local build_status_last = require("devcontainer.status").find_build({ running = true }) local build_status_last = require("devcontainer.status").find_build({ running = true })