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

Non actionable window #623

Open
madtrick opened this issue Nov 5, 2023 · 20 comments
Open

Non actionable window #623

madtrick opened this issue Nov 5, 2023 · 20 comments

Comments

@madtrick
Copy link

madtrick commented Nov 5, 2023

Describe the bug

I recently installed nvim-metals (with lazy.vim). Here's my config:

return {
  "scalameta/nvim-metals",
  config = function()
    local api = vim.api
    local metals_config = require("metals").bare_config()

    metals_config.settings = {
      showImplicitArguments = true,
      showInferredType = true,
      superMethodLensesEnabled = true,
      showImplicitConversionsAndClasses = true,
    }
    -- Autocmd that will actually be in charging of starting the whole thing
    local nvim_metals_group = api.nvim_create_augroup("nvim-metals", { clear = true })

    api.nvim_create_autocmd("FileType", {
      -- NOTE: You may or may not want java included here. You will need it if you
      -- want basic Java support but it may also conflict if you are using
      -- something like nvim-jdtls which also works on a java filetype autocmd.
      pattern = { "scala", "sbt", "java" },
      callback = function()
        require("metals").initialize_or_attach(metals_config)
      end,
      group = nvim_metals_group,
    })
  end,
}

Now, after saving a scala file, there's a brief moment where neovim is unresponsive after which a popup shows a timeout message and an overlay window shows a warning about scalafmt. My biggest issue at the time is that I can't find a way to take an action on that window. I can't select any of the options (can't even focus on it and change the selected option) and can't close it.

image

This might not be an issue with nvim-metals itself but you might be able to point me into the right direction 🙂

Expected behavior

  • There's no timeout and blocking after saving a scala file
  • The overlay window can be closed / acted upon

Operating system

macOS

Version of Metals

v1.1.0

Commit of nvim-metals

6692a65

@ckipp01
Copy link
Member

ckipp01 commented Nov 16, 2023

Hey @madtrick sorry for the late reply. Honestly it's really hard to tell. What I'd recommend is taking a very minimal config where you don't have any other plugins installed and only start with nvim-metals. Then see if you still have the issue. Start slowing adding plugins back in to see if there is maybe some interaction between plugins that isn't playing nicely.

@ckipp01
Copy link
Member

ckipp01 commented Dec 6, 2023

Since I've gotten no more info I'm going to go ahead and close. Feel free to report back if you're still having this issue and I can open back up.

@ckipp01 ckipp01 closed this as completed Dec 6, 2023
@ckipp01 ckipp01 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2023
@madtrick
Copy link
Author

madtrick commented Dec 8, 2023

Hey @ckipp01 apologies for not getting back to you earlier. For now I switched to VSCode to do some Scala. Will report back once I get back to nvim, if I keep having this issue.

@chetankokil
Copy link

I am also facing the same issue. If the .scalafmt file is not present, current buffer is almost useless as you cant see anything...

@chetankokil
Copy link

local lsp_group = vim.api.nvim_create_augroup("lsp", { clear = true })

return {
  "scalameta/nvim-metals",
  ft = { "scala", "sbt", "sc" },
  config = function()
    local metals_config = require("metals").bare_config()

    metals_config.settings = {
      showImplicitArguments = true,
      excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" },
    }
    metals_config.on_attach = function(client, bufnr)
      require("plugins.lsp.keys").setup(client, bufnr)
      vim.api.nvim_create_autocmd("CursorHold", {
        callback = vim.lsp.buf.document_highlight,
        buffer = bufnr,
        group = lsp_group,
      })
      vim.api.nvim_create_autocmd("CursorMoved", {
        callback = vim.lsp.buf.clear_references,
        buffer = bufnr,
        group = lsp_group,
      })
      vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, {
        callback = vim.lsp.codelens.refresh,
        buffer = bufnr,
        group = lsp_group,
      })
    end

    metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities()
    local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
    vim.api.nvim_create_autocmd("FileType", {
      pattern = { "scala", "sbt", "java" },
      callback = function()
        require("metals").initialize_or_attach(metals_config)
      end,
      group = nvim_metals_group,
    })
  end,
}

my config for metals.

@ckipp01
Copy link
Member

ckipp01 commented Dec 27, 2023

I am also facing the same issue. If the .scalafmt file is not present, current buffer is almost useless as you cant see anything...

Hey @chetankokil, could you expand a bit more on this? When this window pops up it should give you three options to choose between. Is there a reason you're unable to select any of the 3 options, or what is happening in your case?

@chetankokil
Copy link

chetankokil commented Dec 27, 2023

hey @ckipp01 when the window shows up, its not auto focused, is the first thing and the other thing is whatever you do, you cant even manually focus on that window. basically forcing one to close the buffer or possibly the window.

Probably the best way to reproduce is to have a project without .scalafmt file and then opening in with lazyvim.

@phrmendes
Copy link

phrmendes commented Jan 12, 2024

I'm facing the same problem. Any UI other than neovim's native UI stops responding in the same context.

I tried with these two plugins:

@phrmendes
Copy link

phrmendes commented Jan 12, 2024

@ckipp01 here's an example

With dressing.nvim enable:

Peek.2024-01-12.20-19.mp4

With dressing.nvim disable:

Peek.2024-01-12.20-21.mp4

@chetankokil
Copy link

Thanks @phrmendes . how did you disable dressing.nvim just for scala project ?

@ckipp01
Copy link
Member

ckipp01 commented Jan 15, 2024

So thanks a lot for the videos! I'm still having a hard time reproducing this. The funny thing is that I also use dressing and don't have any issues with this:

Screen.Recording.2024-01-15.at.09.52.37.mov

Are you able to try and create a minimal standalone config that only has nvim-metals and dressing and see if that has the same behavior? There could be some odd interaction going with another plugin that is causing this.

I'll go ahead and reopen this since multiple people in here seem to be hitting on this.

@ckipp01 ckipp01 reopened this Jan 15, 2024
@nathannli
Copy link

nathannli commented Mar 18, 2024

i had this problem as well. Here's some more info as to how i resolved it:

  1. i used the kitty terminal and the issue where when the popup came up about scalafmt, it would be in the center front of my nvim but would not be clickable or interactable. The only way i was able to remove it was to close the window if i was in tmux or close my terminal program entirely (on another attempt, I realized that I was able to enter into normal mode to quit neovim to get out of it instead). This happened regardless if I was ssh'd into another instance or via local, as long as it was in kitty terminal.
    I tried this in the default macos terminal and got the same problem as well. I did not attempt to try to find if other terminals had this issue as well.
    As recommended during my debugging, i disabled all my plugins. I am also using the lazyvim nvim editor (lazyvim.org).
    When i disabled { import = "lazyvim.plugins.extras.lang.scala" } under lazy.lua, the popup does not appear and all works fine (except the fact that all scala assistnace is also disabled). With the plugin re-enabled, the popup appears when scalafmt is not available on save and it causes the buffer to become unusable.

  2. i noticed in your video (@ckipp01 ), that you used wezterm. I installed that and reran the above tests and the scalafmt popup was interactiveable and closeable from the bare minimal config all the way to re-enabling all my original plugins.

OS: macOS 14.4
NVIM: v0.9.5
nvim-metals commit: 4f9bf0c

Edit:

  • I was able to give this a try on windows terminal (OS: windows 11), and the same issue occured where the floating popup is not interactable.

  • However, on ubuntu 23.04, default terminal, the floating popup was interactable.

  • I tried using windows terminal, and ssh'd into the ubuntu instance, same test, and the window is interactable. maybe its more on an OS level?

@fikovnik
Copy link

I'm also having the same issue. I'm on linux with customized st term.

@diphuaji
Copy link

diphuaji commented Apr 8, 2024

Having same issue:

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal

NVIM info:

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1692716794

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/__w/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Run :checkhealth for more info

And I am using built-in ubuntu terminal. I have the same issue with Iterm2 on MAC as well with the same nvim configs.

@benjstephenson
Copy link

I have the same issue on neovim nightly using telescope-ui-select

NVIM v0.10.0-dev-4461+gca735c755-Homebrew
Build type: Release
LuaJIT 2.1.1713773202

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/HEAD-ca735c7/share/nvim"

I've tried to reproduce using minimal.lua with the following lazy config

lazy.setup({
    {
        "nvim-lua/telescope.nvim",
        dependencies = {
            "nvim-telescope/telescope-ui-select.nvim",
        },
        config = function()
            local telescope = require("telescope")
            local themes = require("telescope.themes")

            telescope.setup({
                extensions = {
                    ["ui-select"] = themes.get_cursor(),
                },
            })

            telescope.load_extension("ui-select")
        end
    },
    {
        "scalameta/nvim-metals",
        dependencies = { "nvim-lua/plenary.nvim", },
        ft = { "scala", "sbt", "java" },
        opts = function()
            local metals_config = require("metals").bare_config()
            metals_config.settings = {
                showImplicitArguments = true,
                excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" },
            }

            return metals_config
        end,
        config = function(self, metals_config)
            local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
            vim.api.nvim_create_autocmd("FileType", {
                pattern = self.ft,
                callback = function()
                    require("metals").initialize_or_attach(metals_config)
                end,
                group = nvim_metals_group,
            })
        end
    }
}, { root = data_path, state = data_path .. '/lazy-state.json', lockfile = data_path .. '/lazy-lock.json' })

This seems to work and I don't get the unresponsive window behaviour anymore so will try and narrow down what part of my config could be causing the problem.

@clemus90
Copy link
Contributor

I have the same issue on Neovim v0.10.0 on Mac using Wezterm, I got to reproduce the issue using the plugins:

  • Lazy
  • telescope-ui-select.nvim
  • conform

This is my init.lua

local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
  local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
  vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)

require('lazy').setup {
  {
    'nvim-telescope/telescope.nvim',
    event = 'VimEnter',
    branch = '0.1.x',
    dependencies = {
      'nvim-lua/plenary.nvim',
      { 'nvim-telescope/telescope-ui-select.nvim' },
    },
    config = function()
      require('telescope').setup {
        extensions = {
          ['ui-select'] = {
            require('telescope.themes').get_dropdown(),
          },
        },
      }

      pcall(require('telescope').load_extension, 'ui-select')
    end,
  },
  {
    'scalameta/nvim-metals',
    dependencies = {
      'nvim-lua/plenary.nvim',
    },
    ft = { 'scala', 'sbt' },
    opts = function()
      local metals_config = require('metals').bare_config()

      metals_config.settings = {
        showImplicitArguments = true,
      }

      metals_config.on_attach = function() end

      return metals_config
    end,
    config = function(self, metals_config)
      local nvim_metals_group = vim.api.nvim_create_augroup('nvim-metals', { clear = true })
      vim.api.nvim_create_autocmd('FileType', {
        pattern = self.ft,
        callback = function()
          require('metals').initialize_or_attach(metals_config)
        end,
        group = nvim_metals_group,
      })
    end,
  },
  {
    'stevearc/conform.nvim',
    opts = {
      format_on_save = function(bufnr)
        return {
          lsp_fallback = true,
        }
      end,
    },
  },

So if I try to save a change to any file on a scala project that doesn't have scalafmt.conf the popup appears but Neovim is in insert mode and there is no way to interact with the popup (as others have shown in this thread).

For now, to circumvent this issue I am running :lua vim.lsp.buf.format() before saving, this shows the popup but this time, I can interact with it.

@VersBinarii
Copy link

VersBinarii commented Jun 18, 2024

I'm experiencing the same problem when opening project without scalafmt.conf.

I'm on MacOS Sonoma 14.0
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713484068

Using Lazy and Iterm2.

Also happens on Alacritty with tmux

@jim-miller
Copy link

Seeing this as well using LazyVim and iTerm2

It seems triggering a format on save brings up the floating window which hangs until an LSP timeout reported ("Warning [LSP][metals] timeout") and the buffer drops down into insert mode.

A workaround is to trigger :lua vim.lsp.buf.format() manually (or via the LazyVim template mapping of leader, c, f) When triggered manually,the timeout still happens, but the hover window stays open and eventually unfreezes allowing interaction and creation of a default .scalafmt.conf file.

@Psuedoo
Copy link

Psuedoo commented Aug 25, 2024

Seeing this as well using LazyVim and iTerm2

It seems triggering a format on save brings up the floating window which hangs until an LSP timeout reported ("Warning [LSP][metals] timeout") and the buffer drops down into insert mode.

A workaround is to trigger :lua vim.lsp.buf.format() manually (or via the LazyVim template mapping of leader, c, f) When triggered manually,the timeout still happens, but the hover window stays open and eventually unfreezes allowing interaction and creation of a default .scalafmt.conf file.

I'm also dealing with this problem and this workaround worked for me.

My neovim config: https://github.com/Psuedoo/kickstart.nvim/

liancheng added a commit to liancheng/lazyvim-starter that referenced this issue Sep 24, 2024
There is an annoying nvim-metals bug:
scalameta/nvim-metals#623
@AlexandrosAlexiou
Copy link

Same here, lazy and wezterm.

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

No branches or pull requests