Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay when inserting lines in Dart files using flutter-tools.nvim #2237

Closed
ellik159 opened this issue Jul 26, 2023 · 11 comments
Closed

Delay when inserting lines in Dart files using flutter-tools.nvim #2237

ellik159 opened this issue Jul 26, 2023 · 11 comments

Comments

@ellik159
Copy link

Describe the bug
Delay when inserting lines in Dart files using flutter-tools.nvim

To Reproduce

  1. Install flutter-tools
  2. Open a Dart file in a Flutter project.
  3. Try to insert a new line using the 'o' command in normal mode.

Expected behavior
I've been experiencing a specific performance issue with flutter-tools.nvim. While using other languages and plugins, everything works smoothly. However, when I'm working with Dart files in a Flutter context, there's a significant delay when I try to insert new lines.

Screenshots
Plugins file:

---@diagnostic disable: missing-fields
local overrides = require "custom.configs.overrides"

---@type NvPluginSpec[]
local plugins = {

  -- Override plugin definition options

  {
    "neovim/nvim-lspconfig",
    dependencies = {
      -- format & linting
      {
        "jose-elias-alvarez/null-ls.nvim",
        config = function()
          require "custom.configs.null-ls"
        end,
      },
    },
    config = function()
      require "plugins.configs.lspconfig"
      require "custom.configs.lspconfig"
    end, -- Override to setup mason-lspconfig
  },

  -- override plugin configs
  {
    "williamboman/mason.nvim",
    opts = overrides.mason,
  },

  {
    "nvim-treesitter/nvim-treesitter",
    opts = overrides.treesitter,
  },

  {
    "nvim-tree/nvim-tree.lua",
    opts = overrides.nvimtree,
  },

  -- Install a plugin
  {
    "max397574/better-escape.nvim",
    event = "InsertEnter",
    config = function()
      require("better_escape").setup()
    end,
  },
  {
    "folke/trouble.nvim",
    cmd = "TroubleToggle",
  },
  {
    "iamcco/markdown-preview.nvim",
    build = "cd app && npm install",
    ft = "markdown",
    config = function()
      vim.g.mkdp_auto_start = 1
    end,
  },
  {
    "ggandor/leap.nvim",
    lazy = false,
    name = "leap",
    config = function()
      require("leap").add_default_mappings()
      -- The below settings make Leap's highlighting closer to what you've been
      -- used to in Lightspeed.

      vim.api.nvim_set_hl(0, "LeapBackdrop", { link = "Comment" }) -- or some grey
      vim.api.nvim_set_hl(0, "LeapMatch", {
        -- For light themes, set to 'black' or similar.
        fg = "white",
        bold = true,
        nocombine = true,
      })

      -- Lightspeed colors
      -- primary labels: bg = "#f02077" (light theme) or "#ff2f87"  (dark theme)
      -- secondary labels: bg = "#399d9f" (light theme) or "#99ddff" (dark theme)
      -- shortcuts: bg = "#f00077", fg = "white"
      -- You might want to use either the primary label or the shortcut colors
      -- for Leap primary labels, depending on your taste.
      vim.api.nvim_set_hl(0, "LeapLabelPrimary", {
        fg = "red",
        bold = true,
        nocombine = true,
      })
      vim.api.nvim_set_hl(0, "LeapLabelSecondary", {
        fg = "blue",
        bold = true,
        nocombine = true,
      })
      -- Try it without this setting first, you might find you don't even miss it.
      require("leap").opts.highlight_unlabeled_phase_one_targets = true
    end,
  },
  {
    "mrjones2014/nvim-ts-rainbow",
    config = function() end,
  },
  { "mfussenegger/nvim-dap" },
  
  { "rcarriga/nvim-dap-ui", dependencies = {
    "mfussenegger/nvim-dap",
  } },
  {
    "akinsho/flutter-tools.nvim",
    lazy=false,
    dependencies = {
      "nvim-lua/plenary.nvim",
      "stevearc/dressing.nvim",
      "neovim/nvim-lspconfig",
      "mfussenegger/nvim-dap",
    }, -- optional for vim.ui.select
    config = function()
      local on_attach = require("plugins.configs.lspconfig").on_attach
      local capabilities = require("plugins.configs.lspconfig").capabilities
      require("flutter-tools").setup {
        -- flutter_path = "C:\\Users\\user\\flutter\\bin\\flutter",
        lsp = {
          on_attach = on_attach,
          capabilities = capabilities
        },
        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
          -- if empty dap will not stop on any exceptions, otherwise it will stop on those specified
          -- see |:help dap.set_exception_breakpoints()| for more info
          exception_breakpoints = {},
          register_configurations = function()
            local dap = require "dap"
            dap.adapters.dart = {
              type = "executable",
              command = "node",
              args = { "C:\\Users\\user\\Documents\\Dart-Code\\out\\dist\\debug.js", "flutter" },
            }
            dap.configurations.dart = {
              {
                type = "dart",
                request = "launch",
                name = "Launch flutter",
                -- dartSdkPath = "C:\\Users\\user\\flutter\\bin\\cache\\dart-sdk\\",
                -- flutterSdkPath = "C:\\Users\\user\\flutter\\bin\\flutter.bat",
                program = "${file}",
                cwd = "${workspaceFolder}",
              },
            }
          end,
        },
      }
    end,
  },

  -- To make a plugin not be loaded
  -- {
  --   "NvChad/nvim-colorizer.lua",
  --   enabled = false
  -- },

  -- All NvChad plugins are lazy-loaded by default
  -- For a plugin to be loaded, you will need to set either `ft`, `cmd`, `keys`, `event`, or set `lazy = false`
  -- If you want a plugin to load on startup, add `lazy = false` to a plugin spec, for example
  -- {
  --   "mg979/vim-visual-multi",
  --   lazy = false,
  -- }
}

return plugins

Desktop:

  • Operating System -> Windows 10
  • Terminal -> Windows Terminal (PowerShell)
  • Version of Neovim 0.10.0

Additional context
Video :https://jiges-my.sharepoint.com/:v:/g/personal/mperez_jig_es/Ecx_C0qdjK9OoL3QlGsrGGgBfugZlHRrkCL6AJZOWSy0Wg?e=CgX2KM

@ellik159
Copy link
Author

Update -> Error only in windows.

@siduck
Copy link
Member

siduck commented Jul 26, 2023

your loading order of plugins seems to be problematic to me, i'll test it tomorrow

@minocrafft
Copy link

minocrafft commented Jul 27, 2023

The same thing happens to me.

  • macbook air - M1 / Ventura 13.4.1
  • iterm2
  • Neovim 0.9.0

Maybe it's not just about Windows

@siduck
Copy link
Member

siduck commented Jul 27, 2023

image

how do i installed dart lsp? i just installed the dart package from arch repos

@ellik159
Copy link
Author

ellik159 commented Jul 27, 2023

But in linux works fine with the same order of plugins,but i come from lunarvim , and the same config works.

@ellik159
Copy link
Author

There is the problem i think , this plugin use its own lsp integration

@siduck
Copy link
Member

siduck commented Jul 27, 2023

But in linux works fine with the same order of plugins,but i come from lunarvim , and the same config works.

looks like an issue related to your OS then, not a nvchad issue. open this issue if you're able to make it work with a non nvchad config

this is a minimal nvim config https://github.com/NvChad/basic-config

@siduck siduck closed this as completed Jul 27, 2023
@ellik159
Copy link
Author

The problem is treesitter

@ellik159
Copy link
Author

@minocrafft
Temp Fix.
Go to override file in custom and disable ident in dart.

 indent = {
    enable = true,
    disable = {
      "dart"
    },
  },
}
:Lazy sync

@siduck
Copy link
Member

siduck commented Jul 27, 2023

@ellik159 good catch!

@minocrafft
Copy link

I see, there is no delay anymore.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants