ayamir / nvimdots

A well configured and structured Neovim.
BSD 3-Clause "New" or "Revised" License
2.93k stars 467 forks source link

open vim in nvim terminal will causing error #668

Closed Saafo closed 1 year ago

Saafo commented 1 year ago

Version confirmation

Following prerequisites

Neovim version

0.9.0

Operating system/version

macOS 13.2.1

Terminal name/version

Warp

$TERM environment variable

xterm-256color

Branch info

main (Default/Latest)

Fetch Preferences

HTTPS (use_ssh = false)

How to reproduce the issue

  1. open terminal in nvim using M-d (floating terminal) or vertical or horizontal
  2. open vim in terminal
  3. before vim open, some error will print

Expected behavior

no error should print before open vim

Actual behavior

error printed before open vim:

> vim
Error detected while processing /Users/saafo/.vimrc[2]../opt/homebrew/Cellar/neovim/0.9.0/share/nvim/runtime/s
yntax/syntax.vim:
line   43:
E216: No such group or event: filetypedetect BufRead
Error detected while processing /opt/homebrew/Cellar/neovim/0.9.0/share/nvim/runtime/plugin/rplugin.vim[66]..f
unction <SNR>13_LoadRemotePlugins[1]..<SNR>13_GetManifest[1]..<SNR>13_GetManifestPath:
line    7:
E117: Unknown function: stdpath
Press ENTER or type command to continue

Additional information

No response

CharlesChiuGit commented 1 year ago

Can u reproduce it on other terminal emulator? Warp has it's own layout, some like tmux or nvim might have issue with it.

Saafo commented 1 year ago

@CharlesChiuGit Yes, I can reproduce it on iTerm2

CharlesChiuGit commented 1 year ago

This is very weird, BufRead autocmd is in the doc for a very long time. I think sth is wrong with the nvim u use. How did u install nvim 0.9?

Saafo commented 1 year ago

Well, I install and upgrade neovim through brew.

Saafo commented 1 year ago

I revert all my changes in local (reset to current main branch), and the problem still exist

CharlesChiuGit commented 1 year ago

Can u try this version? https://github.com/neovim/neovim/releases/tag/stable

Saafo commented 1 year ago

Yes I'm currently using this version. Do you mean I should uninstall nvim and install it through this way?

Download nvim-macos.tar.gz
Run xattr -c ./nvim-macos.tar.gz (to avoid "unknown developer" warning)
Extract: tar xzvf nvim-macos.tar.gz
Run ./nvim-macos/bin/nvim
CharlesChiuGit commented 1 year ago

ys!

Saafo commented 1 year ago

I run ./nvim-macos/bin/nvim and still can reproduce...

CharlesChiuGit commented 1 year ago

wait, u mean u want to open vim inside nvim's term mode?

Saafo commented 1 year ago

I'm not sure whether it's related to my .vimrc, since I delete my .vimrc, the error message changed:

❯ vim
E1187: Failed to source defaults.vim
Error detected while processing /Users/saafo/Downloads/nvim-macos/share/nvim/runtime/plugin/rplugin.vim[66]..f
unction <SNR>9_LoadRemotePlugins[1]..<SNR>9_GetManifest[1]..<SNR>9_GetManifestPath:
line    7:
E117: Unknown function: stdpath
--- Autocommands ---
Error detected while processing /Users/saafo/Downloads/nvim-macos/share/nvim/runtime/plugin/shada.vim:
line    9:
E10: \ should be followed by /, ? or &
line   10:
E10: \ should be followed by /, ? or &
line   11:
E10: \ should be followed by /, ? or &
--- Autocommands ---
line   13:
E10: \ should be followed by /, ? or &
line   14:
E10: \ should be followed by /, ? or &
--- Autocommands ---
line   16:
E10: \ should be followed by /, ? or &
line   17:
E10: \ should be followed by /, ? or &
line   18:
E10: \ should be followed by /, ? or &
line   19:
E10: \ should be followed by /, ? or &
line   20:
E35: No previous regular expression
line   21:
E10: \ should be followed by /, ? or &
line   22:
E10: \ should be followed by /, ? or &
--- Autocommands ---
line   24:
E10: \ should be followed by /, ? or &
line   25:
E10: \ should be followed by /, ? or &
line   26:
E10: \ should be followed by /, ? or &
line   27:
E10: \ should be followed by /, ? or &
line   28:
E10: \ should be followed by /, ? or &
line   29:
E10: \ should be followed by /, ? or &
--- Autocommands ---
line   31:
E10: \ should be followed by /, ? or &
line   32:
E10: \ should be followed by /, ? or &
line   33:
E10: \ should be followed by /, ? or &
line   34:
E10: \ should be followed by /, ? or &
line   35:
E10: \ should be followed by /, ? or &
line   36:
E10: \ should be followed by /, ? or &
--- Autocommands ---
line   38:
E10: \ should be followed by /, ? or &
Press ENTER or type command to continue

my original .vimrc:

set nocompatible
syntax on
set showmode
set laststatus=2
set showcmd
set mouse=a
set encoding=utf-8
set t_Co=256
filetype indent on

set autoindent
set tabstop=2
set shiftwidth=4
set expandtab
set softtabstop=2

set number
set cursorline
set textwidth=120
set wrap
set linebreak
set wrapmargin=2
set scrolloff=3
set sidescrolloff=5
set ruler

set showmatch
set hlsearch
set incsearch
set ignorecase
set smartcase

set visualbell
set autoread
set listchars=tab:»■,trail:■
set list

set wildmenu
set wildmode=longest:list,full

if has('clipboard')
    if has('unnamedplus')  " When possible use + register for copy-paste
        set clipboard=unnamed,unnamedplus
    else         " On mac and Windows, use * register for copy-paste
        set clipboard=unnamed
    endif
endif
Saafo commented 1 year ago

wait, u mean u want to open vim inside nvim's term mode?

Yes exactly! open vim in nvim's emulate terminal

CharlesChiuGit commented 1 year ago

Can reproduce in ubuntu22.04. 圖片

CharlesChiuGit commented 1 year ago

I think this is basically impossible to do. It's not a nvim config issue. I tried with nvim --clean and the result is still the same. So I think using vim inside nvim is forbidden by god. But u can try nested nvim if u know how to use rpc correctly.

CharlesChiuGit commented 1 year ago

Fell free to comment if u have some new insights!

Jint-lzxy commented 1 year ago

This is expected, since $VIMRUNTIME is set to Neovim's runtime. Please unset it before running vim in :terminal. Remember that vim and nvim share the vast majority of options.

cc @Saafo @CharlesChiuGit

Saafo commented 1 year ago

I argue this problem because I use Lazygit in nvim's terminal, and when I wrote commit message, it will open editor.

I'll try to set $EDITOR env to nvim to avoid open vim in nvim.

Jint-lzxy commented 1 year ago

I argue this problem because I use Lazygit in nvim's terminal, and when I wrote commit message, it will open editor.

I'll try to set $EDITOR env to nvim to avoid open vim in nvim.

Yep this will do the trick 👍

CharlesChiuGit commented 1 year ago

This is expected, since $VIMRUNTIME is set to Neovim's runtime. Please unset it before running vim in :terminal. Remember that vim and nvim share the vast majority of options.

cc @Saafo @CharlesChiuGit

圖片

No luck for me. QAQ

Jint-lzxy commented 1 year ago

@CharlesChiuGit u need to set VIMRUNTIME=vim, back to the defaults 😄

CharlesChiuGit commented 1 year ago

圖片 圖片 圖片

Jint-lzxy commented 1 year ago

Looks like you need to manually specify rtp for vim:

export VIMRUNTIME=/usr/share/vim/vim90 # replace this with your vim rtp
unset VIM
CharlesChiuGit commented 1 year ago

圖片

It can enter vim after pressing enter, but it's too much work to do lol

CharlesChiuGit commented 1 year ago

I argue this problem because I use Lazygit in nvim's terminal, and when I wrote commit message, it will open editor. I'll try to set $EDITOR env to nvim to avoid open vim in nvim.

That's what i did too lol

Jint-lzxy commented 1 year ago

It can enter vim after pressing enter, but it's too much work to do lol

Yep nvim -u ~/.vimrc would suffice if the user insists on wanting vim's behavior lol

Jint-lzxy commented 1 year ago

Closing as the original issue has been resolved.