in the leptos-start example project, neovim will mark the SSR main function as dead code:
the rust-analyzer LSP client inside nvim thinks the SSR flag is disabled by default.
one way to fix this is to pass the "ssr" flag to rust-analyzer globally. neovim LSP lets us define settings for specific language servers.
Warning
this will mean the "ssr" flag gets provided to EVERY rust project you open in neovim! be careful. you may get startup errors when you open any projects that don't support the ssr flag.
according to rust-analyzer docs, the option we should pass is called rust-analyzer.cargo.features
. we'll pass it an array containing the string "ssr"
.
my neovim setup is based on nvim-basic-ide, so my LSP settings go in nvim/lua/user/lsp/settings/rust_analyzer.lua
. you may have to write your settings in a different place.
in here we add a table with the key ["rust-analyzer"]
, and inside that we write a structure representing the rest of the key (rust-analyzer.cargo.features
).
return {
settings = {
["rust-analyzer"] = {
cargo = {
features = { "ssr" } -- features = ssr, for LSP support in leptos SSR functions
}
}
}
}
in vscode, this can be done globally or per-project by putting the following into a .vscode/settings.json
file:
{
"rust-analyzer.cargo.features": ["ssr"],
}
Hey, thanks for your reply! That stackoverflow post seems promising. I will try it out tomorrow and report back.