Closed pcoves closed 1 year ago
Commenting out the VeryLazy
setting solves the issue.
Not sure what to make of it, but hey, it works as planned.
Hop, I was wrong.
Works for default setting, ad-hoc lua
settings, but not for rust-tools
.
Here is a minimal example using lazy
:
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
"neovim/nvim-lspconfig",
name = "lspconfig",
lazy = false,
dependencies = {
{ "simrat39/rust-tools.nvim", name = "rust-tools" },
{ "williamboman/mason-lspconfig.nvim", name = "mason-lspconfig" },
{ "williamboman/mason.nvim", name = "mason" },
},
config = function()
local lspconfig = require("lspconfig")
local mason = require("mason")
local mason_lspconfig = require("mason-lspconfig")
mason.setup({})
local servers = { "rust_analyzer" }
mason_lspconfig.setup({ ensure_installed = servers })
local function on_attach(_, _)
print("Attached")
end
mason_lspconfig.setup_handlers({
function(server_name) lspconfig[server_name].setup({ on_attach = on_attach, }) end,
-- ["rust_analyzer"] = function() require("rust-tools").setup({ on_attach = on_attach }) end
})
end
},
})
Opening a rust
file will print Attached
unless the rust-tools
line is uncommented.
Even with lazy = false
.
Pretty much the same behavior with packer
, but I'm not sure that I'm using it the right way, as plugins and the config
function are not automatically installed/called:
local ensure_packer = function()
local fn = vim.fn
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
vim.cmd [[packadd packer.nvim]]
return true
end
return false
end
local packer_bootstrap = ensure_packer()
return require("packer").startup(function(use)
use "wbthomason/packer.nvim"
if packer_bootstrap then require("packer").sync() end
use {
"neovim/nvim-lspconfig",
opt = false,
requires = {
"williamboman/mason-lspconfig.nvim",
"williamboman/mason.nvim",
"simrat39/rust-tools.nvim",
},
config = function()
local lspconfig = require("lspconfig")
local mason = require("mason")
local mason_lspconfig = require("mason-lspconfig")
mason.setup()
local servers = { "rust_analyzer" }
mason_lspconfig.setup({ ensure_installed = servers })
local function on_attach(_, _) print("Attached") end
mason_lspconfig.setup_handlers({
function(server_name) lspconfig[server_name].setup({ on_attach = on_attach, }) end,
-- ["rust_analyzer"] = function() require("rust-tools").setup({ on_attach = on_attach }) end
})
end
}
end)
Okay, this one is on me, as usual.
I wrote :
require("rust-tools").setup({ on_attach = on_attach })
Instead of :
require("rust-tools").setup({server = { on_attach = on_attach }})
Hey there.
Rust-tools
used to startrust-analyzer
on my machine. It's not the case anymore.The whole config can be found here: https://gitlab.com/pcoves/nvim/-/tree/main I use
lazy
and the points of interest are:rust-analyzer
https://gitlab.com/pcoves/nvim/-/blob/fd4d0f14e7ebcf2da34cc9727541d45589f2c7d8/.config/nvim/lua/plugins/lsp-config.lua#L12-12rust-tools
should handle the rest: https://gitlab.com/pcoves/nvim/-/blob/fd4d0f14e7ebcf2da34cc9727541d45589f2c7d8/.config/nvim/lua/plugins/lsp-config.lua#L71-76I removed the whole
~/.local/share/nvim
and~/.local/state/nvim
and tried again so consider the latest versions of all plugins.If I simply attach
rust-analyzer
, I get the LSP features. But I kind of love what you added on top :-)Hope I provide enough information to help troubleshoot this 🙏