numToStr / FTerm.nvim

:fire: No-nonsense floating terminal plugin for neovim :fire:
MIT License
721 stars 24 forks source link

Sometimes it shows this error when using with `fzf-lua`. #44

Closed nyngwang closed 2 years ago

nyngwang commented 2 years ago
E5108: Error executing lua ...site/pack/packer/start/FTerm.nvim/lua/FTerm/terminal.lua:97: Window was closed immediately
stack traceback:
        [C]: in function 'nvim_open_win'
        ...site/pack/packer/start/FTerm.nvim/lua/FTerm/terminal.lua:97: in function 'create_win'
        ...site/pack/packer/start/FTerm.nvim/lua/FTerm/terminal.lua:163: in function 'open'
        ...site/pack/packer/start/FTerm.nvim/lua/FTerm/terminal.lua:208: in function 'toggle'
        ...are/nvim/site/pack/packer/start/FTerm.nvim/lua/FTerm.lua:37: in function 'toggle'
        [string ":lua"]:1: in main chunk

I encountered this error when using fzf-lua's git_status function. I pressed <ESC> after I finished reading the git diff of files.

numToStr commented 2 years ago

This is bizarre 😄. Can you paste your config for FTerm and fzf-lua?

nyngwang commented 2 years ago

To be specific the problem occurs on two shortcuts <C-F> and <C-G> as shown in the following settings.

FTerm

  config = function()
    require'FTerm'.setup {
      border = 'single',
      hl = 'Normal',
      blend = 25, -- transparency
      dimensions = {
        height = 0.6,
        width = 1,
        x = 0,
        y = 1,
      }
    }
  end,
}
vim.api.nvim_set_keymap('n', '<M-Tab>', '<cmd>lua require("FTerm").toggle()<CR>', NOREF_NOERR_TRUNC)
vim.api.nvim_set_keymap('t', '<M-Tab>', '<cmd>lua require("FTerm").toggle()<CR>', NOREF_NOERR_TRUNC)

fzf-lua

  config = function()
    require'fzf-lua'.setup {
      winopts = {
        border =  { '╭', '─', '╮', '│', '╯', '─', '╰', '│' },
        height = 0.65,
        width = 0.7,
        row = 0.9,
        col = 200,
        preview = {
          default = 'bat',
          title = false,
          wrap = 'nowrap',
          vertical = 'up:80%',
          layout = 'vertical'
        }
      },
      files = {
        prompt = ' File $ ',
        -- WARNING: Run `brew install bat` to install bat.
        cmd = 'fd -H',
      },
      grep = {
        prompt = ' Word $ ',
        -- WARNING: Run `brew install ripgrep` to install ripgrep.
        cmd = "rg --vimgrep -g '!{.git,node_modules,package-lock.json,yarn.lock,Library,tags}'",
        color_icons = false,
        file_icons = false,
      },
      previewers = {
        cat = {
          cmd = "cat",
          args = ""
        }
      }
    }
    local nnoremap = vim.keymap.nnoremap
    nnoremap { '<Leader>gs', function() require'fzf-lua'.git_status() end }
    nnoremap { '<Leader>gl', function() require'fzf-lua'.git_commits() end }
    nnoremap { '<Leader>gb', function() require'fzf-lua'.git_branches() end }
    nnoremap { '<Leader>gp', function() require'fzf-lua'.git_files() end }
    ------------------------------------------------------------------------------------------------
    nnoremap { '<Leader>h', function() require'fzf-lua'.command_history() end }
    nnoremap { '<Leader>c', function() require'fzf-lua'.colorschemes() end }
    ------------------------------------------------------------------------------------------------
    nnoremap { '<C-F>', function() require'fzf-lua'.live_grep() end }
    nnoremap { '<C-G>', function() require'fzf-lua'.files() end }
  end
}
numToStr commented 2 years ago

I tried and I couldn't reproduce the error. Would you mind telling me the exact steps?

numToStr commented 2 years ago

I am closing this as I don't think this is related to this plugin.