cordx56/rustowl

how to use in nvim

Closed this issue Β· 15 comments

I installed the plugin and the rustowl via curl but now how to use it ? there is no rustowl nvim commands or keybinds ?

so how to make it work please ?

I am using Lazyvim and had to do:

return {
  {
    "cordx56/rustowl",
    dependencies = { "neovim/nvim-lspconfig" }
    config = function()
      local lspconfig = require("lspconfig")
      lspconfig.rustowlsp.setup({})
    end,
  },
}

Not sure if that's the best way.

Hi! This config looks fine.

I added description to README.
2cbda7f

If you still have any problems, maybe there are some errors.
Currently I did not implement error message and log. Wait a moment.

Can confirm this works. Also works as expected when combined with mason-lspconfig, rust_analyzer and rustaceanvim using lazy

here is my lsp config for ref

What would be nice though is a way to toggle it. Currently when in a fn that is very large the ctx is lost when scrolling to the end of a fn, because neovim will move the cursor away from the variable when moving the viewport

Others also want this to be toggleable. I will implement it in the future.

thanks now it works, but it seems like it doesn't when there is an error on the code

If there are syntax or type errors, RustOwl cannot visualize lifetimes. However, lifetime errors are fine.

I added a build step to make it build during installation (you're probably better off doing this manually, but I like having my neovim config be self-sufficient):

return {
    { -- INFO: Visualizes ownership movement and lifetimes of variables
        "cordx56/rustowl",
        dependencies = { "neovim/nvim-lspconfig" },
        -- need to cd first to ensure cargo honors rust-toolchain.toml
        build = "cd rustowl && cargo install --path . --locked && cargo clean",
        ft = { "rust" },
        config = function()
            local lspconfig = require("lspconfig")
            lspconfig.rustowlsp.setup({})
        end,
    },
}

This required increasing the timeout of lazy as the default of 2 mins wasn't enough for the build to complete (lots of stuff to download):

require("lazy").setup({
    spec = "aksh1618.plugins",
    change_detection = { notify = false },
    git = {
        timeout = 600, -- increased from default 120 in order to allow larger build times for plugins like rustowl
    }
})

@aksh1618 I kinda like that. Does that mean that when using the neovim plugin with you setup I would not need to install the CLI in addition (as documented with the install.sh script)?

@aksh1618 I kinda like that. Does that mean that when using the neovim plugin with you setup I would not need to install the CLI in addition (as documented with the install.sh script)?

Yes, that's correct. Ideally I would like to have Mason manage the actual lsp installation, update etc., but since rustowl is not in Mason yet this is the next best setup IMO.

The only caveat I can think of is the installation steps themselves changing, which for such a rust project seems unlikely to me unless the directory structure itself is modified. You could also directly put sh ./rustowl/install.sh as the build step, but I prefer building from source.

Does someone have a conf with Nvchad I'm not that good with configuration at the moment

  {
    "cordx56/rustowl",
    dependencies = { "neovim/nvim-lspconfig" }
    config = function()
      local lspconfig = require("lspconfig")
      lspconfig.rustowlsp.setup({})
    end
  },

@pro470 you add this plugin with that config on the custom/plugins folder in nvchad

 {
    "cordx56/rustowl",
    dependencies = { "neovim/nvim-lspconfig" }
    config = function()
      local lspconfig = require("lspconfig")
      lspconfig.rustowlsp.setup({})
    end
  },

I'm using nvchad and I also added this but when I open a rust file I get the error

[lspconfig] config "rustowlsp" not found. Ensure it is listed in configs.md or added as a custom server

This required increasing the timeout of lazy as the default of 2 mins wasn't enough for the build to complete (lots of stuff to download):

require("lazy").setup({
spec = "aksh1618.plugins",
change_detection = { notify = false },
git = {
timeout = 600, -- increased from default 120 in order to allow larger build times for plugins like rustowl
}
})

Thanks for this tip. I had to apply this setting to my neovim configuration otherwise rustowl build was failing due to timeout. Might be worth adding a note to the readme about this.

Now we provide prebuilt binary so you may not need to build RustOwl yourself.
But I don’t know the best practice to download them in Neovim plugin. I would like to provide installation script but I’m busy now. So I would appreciate if someone make PRs.