akinsho / toggleterm.nvim

A neovim lua plugin to help easily manage multiple terminal windows
GNU General Public License v3.0
4.38k stars 176 forks source link

Error using mapping to toggle terminal #323

Closed jayceekay closed 2 years ago

jayceekay commented 2 years ago

here's the stack trace:

stack traceback:
    [C]: in function '__newindex'
    .../pack/packer/start/toggleterm.nvim/lua/toggleterm/ui.lua:123: in function 'hl_term'
    ...packer/start/toggleterm.nvim/lua/toggleterm/terminal.lua:471: in function 'open'
    ...vim/pack/packer/start/toggleterm.nvim/lua/toggleterm.lua:56: in function 'smart_toggle'
    ...vim/pack/packer/start/toggleterm.nvim/lua/toggleterm.lua:261: in function 'toggle'
    ...vim/pack/packer/start/toggleterm.nvim/lua/toggleterm.lua:234: in function 'toggle_command'
    ...vim/pack/packer/start/toggleterm.nvim/lua/toggleterm.lua:371: in function <...vim/pack/packer/start/toggleterm.nvim/lua/toggleterm.lua:371>

here's the minimal config i used: https://github.com/jayceekay/minimal-neovim-init/blob/toggle-term/init.lua

to reproduce: trigger c-\

akinsho commented 2 years ago

I'm unable to reproduce this using your minimal configuration. Can you please add additional information about what version of neovim you a re using and on what system etc. This plugin will not support very old versions of neovim i.e. anything before 0.7 is old btw.

jayceekay commented 2 years ago

i forgot to mention i started it using ./start. tried to keep it self contained but i might have messed something up.

here's :version:

NVIM v0.8.0-dev+1519-gf3e99e691
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by justin@Justins-MacBook-Pro.local

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-f3e99e6/share/nvim"

Run :checkhealth for more info

here's :checkhealth:

nvim: health#nvim#check
========================================================================
## Configuration
  - WARNING: Missing user config file: ./config/nvim/init.vim
    - ADVICE:
      - :help |init.vim|

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $TERM_PROGRAM='Apple_Terminal'

provider: health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: pbcopy

## Python 3 provider (optional)
  - INFO: pyenv: Path: /usr/local/Cellar/pyenv/2.3.3/libexec/pyenv
  - INFO: pyenv: Root: /Users/justin/.pyenv
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Executable: /Users/justin/.pyenv/versions/3.9.2/bin/python3
  - INFO: Python version: 3.9.2
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Ruby: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]
  - INFO: Host: /Users/justin/.gem/ruby/3.1.2/bin/neovim-ruby-host
  - OK: Latest "neovim" gem is installed: 0.9.0

## Node.js provider (optional)
  - INFO: Node.js: v16.17.0
  - WARNING: Missing "neovim" npm (or yarn) package.
    - ADVICE:
      - Run in shell: npm install -g neovim
      - Run in shell (if you use yarn): yarn global add neovim
      - You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim

## Perl provider (optional)
  - WARNING: "Neovim::Ext" cpan module is not installed
    - ADVICE:
      - See :help |provider-perl| for more information.
      - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim

vim.lsp: require("vim.lsp.health").check()
========================================================================
  - INFO: LSP log level : WARN
  - INFO: Log path: ./cache/nvim/lsp.log
  - INFO: Log size: 0 KB

vim.treesitter: require("vim.treesitter.health").check()
========================================================================
  - INFO: Runtime ABI version : 14
jayceekay commented 2 years ago

here's a gif of what i'm seeing with a fresh clone/checkout of my test repo: toggleterm

akinsho commented 2 years ago

@jayceekay I genuinely have no idea why this happening. The line that is mentioned in your stack trace is just setting the winhighlight for the window. It shouldn't be throwing an error in a recent version of neovim.

https://github.com/akinsho/toggleterm.nvim/blob/2a787c426ef00cb3488c11b14f5dcf892bbd0bda/lua/toggleterm/ui.lua#L123

My guess is that something about your environment is causing this issue, since I can't reproduce this on my side and AFAIK no one else is reporting this issue.

jayceekay commented 2 years ago

no worries, i appreciate you trying to help. is there a discord or gitter i can join to maybe find help debugging this? it'd be cool to step through the plugin, which i tried but the debugger kept disconnecting.

akinsho commented 2 years ago

@jayceekay there's no discord or gitter it's essentially just me maintaining this plugin. Rather than going through convoluted debugger setups which is not so straightforward for an nvim plugin, I recommend just going into your local copy of the plugin and maybe printing out some of the variable around the line I linked to see what those values are as that might indicate why they are erroring for you.

YasserKa commented 2 years ago

I get similar behavior when direction isn't float

akinsho commented 2 years ago

@YasserKa what I need to fix this is clear minimal reproduction that works for me, that it also affects you, is unfortunately not particularly useful information. Presumably, both of your setups are doing something different than mine. Can you both try nvim 0.8 stable and see if this issue still occurs there. I wonder if you are using outdated nvim nightly versions

YasserKa commented 2 years ago

nvim --version

NVIM v0.8.0-dev+237-g6e414b698
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=malloc -Wsuggest-attribute=cold -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az379-903

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

The error doesn't occur with the stable version.

akinsho commented 2 years ago

That's good to know, well ultimately nightly is unstable, so I don't guarantee things will work with nightly. If things work in stable then that's good enough from my perspective

akinsho commented 2 years ago

If it's confirmed to work in stable I consider this issue closed then as the problem is with some commit in nightly I have no way of knowing where exactly your build came from was it old or new etc. but as long as stable is not affected then that's fine.

jayceekay commented 2 years ago

yes, the same happened to me. last night i decided to uninstall and reinstall neovim and the error went away. thanks everyone!