akinsho / flutter-tools.nvim

Tools to help create flutter apps in neovim using the native lsp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] Is there a way to setup the flutter-tools lsp to `autostart`?

aap01 opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

image

I suspect that the LSP, setup by flutter-tools is not automatically starting when I enter a dart file.

So, when I am interacting with code actions initially it takes around a minute to list all the code actions.
But after that, every interaction with code actions is very fast.

Expected Behavior

autostart true

Steps To Reproduce

My config

vim.list_extend(
  lvim.lsp.automatic_configuration.skipped_servers,
  { "dartls" }
)
require("flutter-tools").setup {
  widget_guides = {
    enabled = false,
  },
  outline = {
    open_cmd = "30vnew", -- command to use to open the outline buffer
    auto_open = false,   -- if true this will open the outline automatically when it is first populated
  },
  -- flutter_path = "<full/path/if/needed>", -- <-- this takes priority over the lookup
  -- flutter_lookup_cmd = "$(which flutter)", -- example "dirname $(which flutter)" or "asdf where flutter"
  fvm = true,
  dev_log = {
    enabled = false,
    notify_errors = true, -- if there is an error whilst running then notify the user
    open_cmd = "tabedit", -- command to use to open the log buffer
  },
  debugger = {
    -- integrate with nvim dap + install dart code debugger
    enabled = true,
    run_via_dap = true, -- use dap instead of a plenary job to run flutter apps
    register_configurations = function(_)
      require("dap").configurations.dart = {}
      require("dap.ext.vscode").load_launchjs()
    end,
  },
  lsp = {
    color = {
      -- show the derived colours for dart variables
      enabled = true, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
      background = false, -- highlight the background
      background_color = nil, -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},)
      foreground = false, -- highlight the foreground
      virtual_text = true, -- show the highlight using virtual text
      virtual_text_str = "", -- the virtual text character to highlight
    },
    on_attach = lvim.lsp.on_attach_callback,
    capabilitites = vim.lsp.protocol.make_client_capabilities,
    settings = {
      autostart = true,
      showTodos = true,
      completeFunctionCalls = true,
      -- analysisExcludedFolders = { "<path-to-flutter-sdk-packages>" },
      renameFilesWithClasses = "always", -- "prompt"
      enableSnippets = true,
      updateImportsOnRename = true,      -- Whether to update imports and other directives when files are renamed. Required for `FlutterRename` command.
    },
  }
}

Environment

- OS: macOS 14.0(m1)
- Flutter version: 3.13.1
- Is flutter in $PATH: yes
- neovim version: 0.9.4

Anything else?

No response

commented

@aap01 it does in fact auto start. The moment you enter a dart file the client is initialised. It is slow on initial startup which is outside of this plugin's control. I don't know how the LSP info thing decides if a server is autostarted or not but since this plugin handles all the details itself I wouldn't depend too much on what is said there.

Thanks for the clarification.
Is there a way to track the loading-progress of the lsp?

commented

There are plugins you can install which do that like folke's noice.nvim or lsp progress, quite a few if you search on github/reddit you'll find some

Thanks for the information.

Let me take a moment to appreciate what you have done for me.

I use 'flutter-tools.nvim' for my daily development workflow.
When I was a beginner neovim user this plugin solved all of my flutter development problems and helped me stick to neovim.

Thank you and the contributors for all the efforts.