From 227a9ab657c38756a1a4f13dbc0e1631dfa7ab4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Fri, 19 Jan 2024 11:37:39 +0100 Subject: [PATCH] Use rustaceanvim instead of rust-tools --- .../config/nvim/lua/esensar/init/plugins.lua | 2 +- .../nvim/lua/esensar/lsp/server_config.lua | 4 ++ .../config/nvim/lua/esensar/lsp/servers.lua | 46 ++++++++----------- .../config/nvim/lua/esensar/ui/statusline.lua | 24 +++------- 4 files changed, 31 insertions(+), 45 deletions(-) diff --git a/symlinks/config/nvim/lua/esensar/init/plugins.lua b/symlinks/config/nvim/lua/esensar/init/plugins.lua index 8748a8e..e9fd3f0 100644 --- a/symlinks/config/nvim/lua/esensar/init/plugins.lua +++ b/symlinks/config/nvim/lua/esensar/init/plugins.lua @@ -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 diff --git a/symlinks/config/nvim/lua/esensar/lsp/server_config.lua b/symlinks/config/nvim/lua/esensar/lsp/server_config.lua index aeb8f68..e08bbe4 100644 --- a/symlinks/config/nvim/lua/esensar/lsp/server_config.lua +++ b/symlinks/config/nvim/lua/esensar/lsp/server_config.lua @@ -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 { diff --git a/symlinks/config/nvim/lua/esensar/lsp/servers.lua b/symlinks/config/nvim/lua/esensar/lsp/servers.lua index 80fcf01..8ad9135 100644 --- a/symlinks/config/nvim/lua/esensar/lsp/servers.lua +++ b/symlinks/config/nvim/lua/esensar/lsp/servers.lua @@ -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", "", rt.hover_actions.hover_actions, { buffer = bufnr }) - -- Code action groups - vim.keymap.set("n", "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, + }, + }, + }, }), -}) +} diff --git a/symlinks/config/nvim/lua/esensar/ui/statusline.lua b/symlinks/config/nvim/lua/esensar/ui/statusline.lua index b3824ce..06c69b3 100644 --- a/symlinks/config/nvim/lua/esensar/ui/statusline.lua +++ b/symlinks/config/nvim/lua/esensar/ui/statusline.lua @@ -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 })