Skip to content

Best method of changing target during runtime? #147

Answered by mrcjkb
FlippingBinary asked this question in Q&A
Discussion options

You must be logged in to vote

Hey 👋

This plugin evaluates vim.g.rustaceanvim only once, during initialization.
It's not meant to be modified at runtime.

It does, however, allow the settings field to be a function.
For example:

vim.g.rustaceanvim = {
  server = {
    ---@param project_root string
    settings = function(project_root)
      return {
        if type(vim.g.rust_analyzer_cargo_target) ~= 'string' then
          -- Fall back to the default implementation if no valid target has been set
          return require('rustaceanvim.config.server').load_rust_analyzer_settings(project_root)
        end
        ["rust-analyzer"] = {
          cargo = {
            target = vim.g.rust_analyzer_cargo_target, -- set this…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@FlippingBinary
Comment options

@mrcjkb
Comment options

@mrcjkb
Comment options

@FlippingBinary
Comment options

@mrcjkb
Comment options

Answer selected by FlippingBinary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants