nvim

[!NOTE|label:references:]

install

[!NOTE]

dependencies

  • osx

    • gettext : GNU internationalization (i18n) and localization (l10n) library

    • libtermkey : Library for processing keyboard entry from the terminal

    • libuv : Multi-platform support library with a focus on asynchronous I/O

    • libvterm : C99 library which implements a VT220 or xterm terminal emulator

    • luajit : Just-In-Time Compiler (JIT) for the Lua programming language

    • luv : Bare libuv bindings for lua

    • msgpack : Library for a binary-based efficient data interchange format

    • tree-sitter : Parser generator tool and incremental parsing library

    • unibilium: Very basic terminfo library

    $ brew deps --tree neovim
    neovim
    ├── gettext
    ├── libtermkey
       └── unibilium
    ├── libuv
    ├── libvterm
    ├── luajit
    ├── luv
       └── libuv
    ├── msgpack
    ├── tree-sitter
    └── unibilium

  • tarball

    [!TIP]

    • osx: avoid unknown developer warning

      $ xattr -c ./nvim-macos.tar.gz
      # or
      $ xattr -p com.apple.quarantine ./nvim-macos.tar.gz
    $ curl -fsSL https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz | tar xzf - -C /opt/nvim
    $ /opt/nvim/nvim-macos/bin/nvim
    $ sudo ln -sf /opt/nvim/nvim-macos /usr/local/nvim
    
    $ export NVIM_HOME=/usr/local/nvim
    $ export PATH=$NVIM_HOME/bin:$PATH

building from source

[!NOTE|label:references:]

osx

[!NOTE|label:issue with wget certificate]

# prepare
$ xcode-select --install
$ brew install ninja libtool automake cmake pkg-config gettext curl
# or
$ brew install cmake gettext lpeg luarocks luajit luv msgpack tree-sitter unibilium \
               libtermkey libuv libvterm

# download
$ git clone --recurse-submodules git@github.com:neovim/neovim.git /opt/neovim && cd $_

# build
$ cmake -S . \
        -B build \
        -DCMAKE_INSTALL_PREFIX=/usr/local/neovim \
        -DLUV_LIBRARY=/usr/local/opt/luv/lib/libluv.dylib \
        -DLIBUV_LIBRARY=/usr/local/opt/libuv/lib/libuv.dylib \
        -DLPEG_LIBRARY=/usr/local/opt/lpeg/lib/liblpeg.dylib \
        -DCMAKE_INSTALL_LIBDIR=lib \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_FIND_FRAMEWORK=LAST \
        -DCMAKE_VERBOSE_MAKEFILE=ON \
        -Wno-dev \
        -DBUILD_TESTING=OFF \
        -DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path)
$ cmake --build build
$ sudo cmake --install build

# verify
$ /usr/local/neovim/bin/nvim -V1 -v
NVIM v0.10.0-dev-2869+g4459e0cee
Build type: Release
LuaJIT 2.1.1710088188

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

Run :checkhealth for more info

# environment setup
$ NVIM_HOME=/usr/local/neovim
$ PATH=$NVIM_HOME/bin:$PATH
$ export NVIM_HOME PATH
# https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/n/neovim.rb
$ cmake -S . \
        -B build \
        -DCMAKE_INSTALL_PREFIX=/usr/local/neovim \
        -DLUV_LIBRARY=/usr/local/opt/luv/lib/libluv.dylib \
        -DLIBUV_LIBRARY=/usr/local/opt/libuv/lib/libuv.dylib \
        -DLPEG_LIBRARY=/usr/local/opt/lpeg/lib/liblpeg.dylib \
        -DCMAKE_INSTALL_LIBDIR=lib \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_FIND_FRAMEWORK=LAST \
        -DCMAKE_VERBOSE_MAKEFILE=ON \
        -Wno-dev \
        -DBUILD_TESTING=OFF \
        -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk
$ /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc \
    -O2 -g -Og -g -flto=thin \
    -Wall \
    -Wextra -pedantic \
    -Wno-unused-parameter \
    -Wstrict-prototypes -std=gnu99 \
    -Wshadow \
    -Wconversion \
    -Wvla \
    -Wdouble-promotion \
    -Wmissing-noreturn \
    -Wmissing-format-attribute \
    -Wmissing-prototypes -fsigned-char -fstack-protector-strong \
    -Wimplicit-fallthrough -fdiagnostics-color=always \
    -Wl,-export_dynamic \
    -DUNIT_TESTING \
    -DHAVE_UNIBILIUM \
    -D_GNU_SOURCE \
    -DINCLUDE_GENERATED_DECLARATIONS \
    -I/Users/runner/work/neovim/neovim/.deps/usr/include/luajit-2.1 \
    -I/Users/runner/work/neovim/neovim/.deps/usr/include \
    -I/Users/runner/work/neovim/neovim/build/src/nvim/auto \
    -I/Users/runner/work/neovim/neovim/build/include \
    -I/Users/runner/work/neovim/neovim/build/cmake.config \
    -I/Users/runner/work/neovim/neovim/src \
    -I/Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include

# details
$ /usr/local/bin/nvim -V1 -v
NVIM v0.10.0-dev-2867+g7aa56370f
Build type: RelWithDebInfo
LuaJIT 2.1.1710088188
Compilation: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -O2 -g -Og -g -flto=thin -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fsigned-char -fstack-protector-strong -Wimplicit-fallthrough -fdiagnostics-color=always -Wl,-export_dynamic -DUNIT_TESTING -DHAVE_UNIBILIUM -D_GNU_SOURCE -DINCLUDE_GENERATED_DECLARATIONS -I/Users/runner/work/neovim/neovim/.deps/usr/include/luajit-2.1 -I/Users/runner/work/neovim/neovim/.deps/usr/include -I/Users/runner/work/neovim/neovim/build/src/nvim/auto -I/Users/runner/work/neovim/neovim/build/include -I/Users/runner/work/neovim/neovim/build/cmake.config -I/Users/runner/work/neovim/neovim/src -I/Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include

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

Run :checkhealth for more info
  • build with older MacOS

    $ make CMAKE_BUILD_TYPE=Release \
           MACOSX_DEPLOYMENT_TARGET=10.13 \
           DEPS_CMAKE_FLAGS="-DCMAKE_CXX_COMPILER=$(xcrun -find c++)"
  • more settings

    $ brew unlink neovim
    $ /usr/bin/env /bin/ln -h -s -f /usr/local/neovim/bin/nvim /usr/local/bin/nvim
    $ /usr/bin/env /bin/ln -h -s -f /usr/local/neovim/bin/nvim /usr/local/bin/neovim
    $ /usr/bin/env /bin/ln -h -s -f /usr/local/neovim/lib/nvim /usr/local/lib/nvim
    $ /usr/bin/env /bin/ln -h -s -f /usr/local/neovim/share/nvim /usr/local/share/nvim

brew install -v --debug

# download
$ /usr/bin/env /usr/local/Homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.2.17-33-g1bbfe76\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 14.4.1\)\ curl/8.4.0 --header Accept-Language:\ en --retry 3 --fail --location --silent --head https://raw.githubusercontent.com/Homebrew/homebrew-core/841811d678fcfef856f693a2ec90add1625a4c12/Formula/n/neovim.rb
$ /usr/bin/env /usr/local/Homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.2.17-33-g1bbfe76\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 14.4.1\)\ curl/8.4.0 --header Accept-Language:\ en --retry 3 --fail --location --silent --head --request GET https://raw.githubusercontent.com/Homebrew/homebrew-core/841811d678fcfef856f693a2ec90add1625a4c12/Formula/n/neovim.rb
# clone
$ /usr/bin/env git --git-dir /Users/marslo/Library/Caches/Homebrew/neovim--git/.git status -s
$ /usr/bin/env git checkout -f master --
$ /usr/bin/env git --git-dir /Users/marslo/Library/Caches/Homebrew/neovim--git/.git rev-parse --short=7 HEAD
$ /usr/bin/env git --git-dir /Users/marslo/Library/Caches/Homebrew/neovim--git/.git show -s --format=\%cD
Wed, 10 Apr 2024 07:08:49 +0800

# build
$ cmake -S . -B build -DLUV_LIBRARY=/usr/local/opt/luv/lib/libluv.dylib -DLIBUV_LIBRARY=/usr/local/opt/libuv/lib/libuv.dylib -DLPEG_LIBRARY=/usr/local/opt/lpeg/lib/liblpeg.dylib -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/neovim/HEAD-f494084 -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev -DBUILD_TESTING=OFF -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk
$ cmake --build build
$ cmake --install build

uninstall

$ sudo cmake --build build/ --target uninstall

package manager

# osx
$ brew install nvim

# nvim nightly
$ brew install --HEAD utf8proc
$ brew install --HEAD neovim

# ubuntu
$ sudo add-apt-repository ppa:neovim-ppa/unstable
$ sudo add-apt-repository ppa:neovim-ppa/stable
$ sudo apt update
$ sudo apt install neovim
$ apt-cache madison neovim
    neovim | 0.10.0~ubuntu1+git202401142109-310fb2efc-c60402a16-3c3072a0a~ubuntu20.04.1 | https://ppa.launchpadcontent.net/neovim-ppa/unstable/ubuntu focal/main amd64 Packages
    neovim | 0.7.2-3~bpo22.04.1~ppa1 | https://ppa.launchpadcontent.net/neovim-ppa/stable/ubuntu jammy/main amd64 Packages
    neovim | 0.6.1-3 | http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages

# or
$ curl -fsSL -O http://archive.ubuntu.com/ubuntu/pool/universe/n/neovim/neovim_0.9.5-6ubuntu2_amd64.deb
$ sudo dpkg -i neovim_0.9.5-6ubuntu2_amd64.deb
  • brew install --head

    [!NOTE|label:references:]

    $ brew install --HEAD utf8proc
    $ brew install nvim --HEAD --debug -v
    
    # verify
    $ $(brew --cellar nvim)/*/bin/nvim -V1 -v
    NVIM v0.10.0-dev-2889+gf064e72b9-Homebrew
    Build type: Release
    LuaJIT 2.1.1710088188
    
       system vimrc file: "$VIM/sysinit.vim"
      fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-f064e72/share/nvim"
    
    Run :checkhealth for more info

    [!NOTE|label:to get macOS SDK:]

    # handle tree-sitter-c-0.23.0.tar.gz
    $ /usr/bin/env tar --extract --no-same-owner --file /Users/marslo/Library/Caches/Homebrew/downloads/7afcc045b55375a996ccb8e98606e426e9c8a5465e82babf7997513a7763e077--tree-sitter-c-0.23.0.tar.gz --directory /private/tmp/homebrew-unpack20241014-59765-o7ouz3
    $ /usr/bin/env cp -al /private/tmp/homebrew-unpack20241014-59765-o7ouz3/tree-sitter-c-0.23.0 /private/tmp/treesitter-c-20241014-59765-41iwid
    
    # deps: treesitter-c
    $ cmake -S        /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/src/treesitter-c -B /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-c -DPARSERLANG=c -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/neovim/HEAD-4846bf0_1 -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=/usr/local/Homebrew/Library/Homebrew/cmake/trap_fetchcontent_provider.cmake -Wno-dev -DBUILD_TESTING=OFF -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk
    $ cmake --build   /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-c
    $ cmake --install /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-c
    
    # deps: treesitter-lua
    $ cmake -S        /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/src/treesitter-lua -B /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-lua -DPARSERLANG=lua -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/neovim/HEAD-4846bf0_1 -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=/usr/local/Homebrew/Library/Homebrew/cmake/trap_fetchcontent_provider.cmake -Wno-dev -DBUILD_TESTING=OFF -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk
    $ cmake --build   /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-lua
    $ cmake --install /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-lua
    
    # deps: treesitter-vim
    $ cmake -S        /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/src/treesitter-vim -B /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-vim -DPARSERLANG=vim -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/neovim/HEAD-4846bf0_1 -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=/usr/local/Homebrew/Library/Homebrew/cmake/trap_fetchcontent_provider.cmake -Wno-dev -DBUILD_TESTING=OFF -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk
    $ cmake --build   /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-vim
    $ cmake --install /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-vim
    
    # deps: treesitter-vimdoc
    $ cmake -S /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/src/treesitter-vimdoc -B /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-vimdoc -DPARSERLANG=vimdoc -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/neovim/HEAD-4846bf0_1 -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=/usr/local/Homebrew/Library/Homebrew/cmake/trap_fetchcontent_provider.cmake -Wno-dev -DBUILD_TESTING=OFF -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk
    $ cmake --build /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-vimdoc
    $ cmake --install /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-vimdoc
    
    # deps: treesitter-query
    $ cmake -S /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/src/treesitter-query -B /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-query -DPARSERLANG=query -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/neovim/HEAD-4846bf0_1 -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=/usr/local/Homebrew/Library/Homebrew/cmake/trap_fetchcontent_provider.cmake -Wno-dev -DBUILD_TESTING=OFF -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk
    $ cmake --build /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-query
    $ cmake --install /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-query
    
    # deps: treesitter-markdown
    $ cmake -S /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/src/treesitter-markdown -B /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-markdown -DPARSERLANG=markdown -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/neovim/HEAD-4846bf0_1 -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=/usr/local/Homebrew/Library/Homebrew/cmake/trap_fetchcontent_provider.cmake -Wno-dev -DBUILD_TESTING=OFF -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk
    $ cmake --build /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-markdown
    $ cmake --install /private/tmp/neovim-20241014-59765-vs8k2v/deps-build/build/treesitter-markdown
    
    # nvim
    $ cmake -S . \
            -B build \
            -DLUV_LIBRARY=/usr/local/opt/luv/lib/libluv.dylib \
            -DLIBUV_LIBRARY=/usr/local/opt/libuv/lib/libuv.dylib \
            -DLPEG_LIBRARY=/usr/local/opt/lpeg/lib/liblpeg.dylib \
            -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/neovim/HEAD-4846bf0_1 \
            -DCMAKE_INSTALL_LIBDIR=lib \
            -DCMAKE_BUILD_TYPE=Release \
            -DCMAKE_FIND_FRAMEWORK=LAST \
            -DCMAKE_VERBOSE_MAKEFILE=ON \
            -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=/usr/local/Homebrew/Library/Homebrew/cmake/trap_fetchcontent_provider.cmake \
            -Wno-dev \
            -DBUILD_TESTING=OFF \
            -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk
    $ cmake --build build

windows

  • dependencies

    [!NOTE|label:references:]

    • C Compiler

      • llvm

        # C:\Program Files\LLVM\bin
        > choco install llvm
        
        # https://gist.github.com/mcandre/5ceb67ad44f6b974d33bcddedcb16e89
        > choco install cmake
      • mingw

        [!TIP|label:packages:]

        # C:\ProgramData\mingw64\mingw64
        > choco install mingw
      • msvc

        [!TIP|label:packages:]

        # C:\Program Files (x86)\Microsoft Visual Studio\Installer
        > choco install visualstudio2022buildtools
        
        # former version
        > choco install visualstudio2019buildtools
        
        # for clang/llvm installation
        # C:\Program Files (x86)\Microsoft Visual Studio\Installer
        > choco install visualstudio-installer
  • nvim

    > curl -fsSL -O https://github.com/neovim/neovim/releases/latest/download/nvim-win64.msi
    REM install via msiexec as administrator
    > msiexec /i nvim-setup.exe [/quiet] [/passive] [/norestart] [/log <log file>] [/l* <log file>]

neovim-nightly

[!NOTE|label:references:]

$ brew unlink neovim
Unlinking /usr/local/Cellar/neovim/HEAD-f494084... 35 symlinks removed.

$ brew tap benjiwolff/neovim-nightly
$ brew install neovim-nightly [ -v --debug ]

# verify
$ /usr/local/Caskroom/neovim-nightly/nightly-7aa5637/nvim-macos-x86_64/bin/nvim -V1 -v
NVIM v0.10.0-dev-2867+g7aa56370f
Build type: RelWithDebInfo
LuaJIT 2.1.1710088188
Compilation: /Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -O2 -g -Og -g -flto=thin -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fsigned-char -fstack-protector-strong -Wimplicit-fallthrough -fdiagnostics-color=always -Wl,-export_dynamic -DUNIT_TESTING -DHAVE_UNIBILIUM -D_GNU_SOURCE -DINCLUDE_GENERATED_DECLARATIONS -I/Users/runner/work/neovim/neovim/.deps/usr/include/luajit-2.1 -I/Users/runner/work/neovim/neovim/.deps/usr/include -I/Users/runner/work/neovim/neovim/build/src/nvim/auto -I/Users/runner/work/neovim/neovim/build/include -I/Users/runner/work/neovim/neovim/build/cmake.config -I/Users/runner/work/neovim/neovim/src -I/Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include

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

Run :checkhealth for more info
  • No such file or directory @ rb_file_s_rename

    [!TIP|label:failure details]

    error: benjiwolff/neovim-nightly/neovim-nightly: No such file or directory @ rb_file_s_rename - (/usr/local/Caskroom/neovim-nightly/nightly-7aa5637, /usr/local/Caskroom/neovim-nightly/nightly-7aa5637.upgrading)
    # solution
    $ brew remove neovim-nightly
    $ rm -rf /usr/local/Caskroom/neovim-nightly
    
    $ brew install neovim-nightly [ -v --debug --display-times ]

initialize and configure

[!TIP]

:checkhealth

$ python3 -m pip install --user --upgrade pynvim
$ gem install neovim
$ npm install -g neovim
  • for venv

    $ python3 -m pip install --upgrade pynvim
    # if necesssary
    $ python3 -m pip  install --upgrade greenlet
    
    # verify
    $ command python3 -c 'import sys; sys.path = [p for p in sys.path if p != ""]; import neovim; print(neovim.__file__)'
    
    # to list all packages
    $ pip list -v

init.vim/init.lua

[!NOTE|label:references:]

  • create init.vim

    :exe 'edit '.stdpath('config').'/init.vim'
    :write ++p
  • init.lua

    -- ~/.config/nvim/init.lua
    vim.cmd( 'set runtimepath^=~/.vim runtimepath+=~/.vim/after' )
    vim.cmd( 'let &packpath = &runtimepath' )
    vim.cmd( 'source ~/.vimrc' )
    vim.cmd( 'autocmd TextYankPost * silent! lua vim.highlight.on_yank {on_visual=false}' )
  • init.vim

    # ~/.config/nvim/init.vim
    set runtimepath^=~/.vim runtimepath+=~/.vim/after
    let &packpath = &runtimepath
    source ~/.vimrc
    autocmd TextYankPost * silent! lua vim.highlight.on_yank {on_visual=false}

config

[!NOTE|label:references:]

  • check status

    :checkhealth

config.lua

[!NOTE|label:references:]

$ cat ~/.config/nvim/lua/config.lua
lua require('config')

standard-path

[!NOTE|label:references:]

  • get data

    :echo stdpath("xxx")
    
    " i.e.:
    :echo stdpath('config')
    /Users/marslo/.config/nvim
  • using in init.lua

    -- ~/.config/nvim/init.lua
    -- to setup undodir to `$HOME/.config/nvim/undo`. debug via `:verbose set undodir`
    vim.opt.undodir = vim.fn.stdpath('config') .. '/undo'
    -- or specific path
    vim.opt.undodir = vim.fn.expand( '~/.vim/undo' )

list parser paths

:echo nvim_get_runtime_file('parser/*.so', v:true)
['/Users/marslo/.vim/plugged/nvim-treesitter/parser/bash.so', '/Users/marslo/.vim/plugged/nvim-treesitt
er/parser/c.so', '/Users/marslo/.vim/plugged/nvim-treesitter/parser/cmake.so', '/Users/marslo/.vim/plug
ged/nvim-treesitter/parser/css.so', '/Users/marslo/.vim/plugged/nvim-treesitter/parser/diff.so', '/User
s/marslo/.vim/plugged/nvim-treesitter/parser/dockerfile.so', '/Users/marslo/.vim/plugged/nvim-treesitte
r/parser/gitcommit.so', '/Users/marslo/.vim/plugged/nvim-treesitter/parser/gitignore.so', '/Users/marsl
o/.vim/plugged/nvim-treesitter/parser/git_config.so', '/Users/marslo/.vim/plugged/nvim-treesitter/parse
r/groovy.so', '/Users/marslo/.vim/plugged/nvim-treesitter/parser/ini.so', '/Users/marslo/.vim/plugged/n
vim-treesitter/parser/java.so', '/Users/marslo/.vim/plugged/nvim-treesitter/parser/jq.so', '/Users/mars
lo/.vim/plugged/nvim-treesitter/parser/json.so', '/Users/marslo/.vim/plugged/nvim-treesitter/parser/lua
.so', '/Users/marslo/.vim/plugged/nvim-treesitter/parser/markdown.so', '/Users/marslo/.vim/plugged/nvim
-treesitter/parser/python.so', '/Users/marslo/.vim/plugged/nvim-treesitter/parser/query.so', '/Users/ma
rslo/.vim/plugged/nvim-treesitter/parser/ssh_config.so', '/Users/marslo/.vim/plugged/nvim-treesitter/pa
rser/vim.so', '/Users/marslo/.vim/plugged/nvim-treesitter/parser/vimdoc.so', '/Users/marslo/.vim/plugge
d/nvim-treesitter/parser/xml.so', '/Users/marslo/.vim/plugged/nvim-treesitter/parser/yaml.so', '/usr/lo
cal/Caskroom/neovim-nightly/latest/nvim-macos-x86_64/lib/nvim/parser/c.so', '/usr/local/Caskroom/neovim
-nightly/latest/nvim-macos-x86_64/lib/nvim/parser/lua.so', '/usr/local/Caskroom/neovim-nightly/latest/n
vim-macos-x86_64/lib/nvim/parser/markdown.so', '/usr/local/Caskroom/neovim-nightly/latest/nvim-macos-x8
6_64/lib/nvim/parser/markdown_inline.so', '/usr/local/Caskroom/neovim-nightly/latest/nvim-macos-x86_64/
lib/nvim/parser/query.so', '/usr/local/Caskroom/neovim-nightly/latest/nvim-macos-x86_64/lib/nvim/parser
/vim.so', '/usr/local/Caskroom/neovim-nightly/latest/nvim-macos-x86_64/lib/nvim/parser/vimdoc.so']

lua

[!NOTE|label:references]

:lua vim.print(package.loaded)

:lua print(_VERSION)
Lua 5.1

:lua =jit.version
LuaJIT 2.1.1703358377

true color

[!NOTE|label:references:]

:echo &termguicolors
1
$ echo $TERM $COLORTERM
xterm-256color truecolor
  • force 16 colors

    $ TERM= COLORTERM= nvim

config path

[!NOTE]

  • SYNTAX FILES: ~/.config/nvim/syntax

  • ruby : ~/.config/nvim/ruby

math

:echo abs(1.456)
1.456
:echo abs(-5.456)
5.456

:echo acos(0)
1.570796
:echo acos(-0.5)
2.094395

:echo asin(0.8)
0.927295
:echo asin(-0.5)
-0.523599

:echo cosh(0.5)
1.127626
:echo cosh(-0.5)
1.127626

" exponential
:echo exp(2)
7.389056
:echo exp(-1)
0.367879

" x/y
:echo fmod(12.33, 1.22)
0.13

" smallest integral value greater than or equal to {expr} as a Float
:echo ceil(1.456)
2.0
:echo ceil(-5.456)
-5.0

" largest integral value less than or equal to
:echo floor(1.856)
1.0
:echo floor(-5.456)
-6.0

assert

:echo assert_equal('foo', 'bar')
1

:echo assert_match('^f.*o$', 'foobar')
1

list

:echo blob2list(0z0102.0304)
[1, 2, 3, 4]
:echo blob2list(0z)
[]
  • exists

    :let l = [1, 2, 3]
    :echo exists("l[5]")
    0
    :echo exists("l[2]")
    1
  • basic

    :let newlist = [1, 2, 3] + [4, 5]
    :echo newlist
    [1, 2, 3, 4, 5]
    :call extend(newlist, [2, 3], 1)
    :echo newlist
    [1, 2, 3, 2, 3, 4, 5]
    
    " sort
    :echo sort(extend(newlist, [7, 5]))
    [1, 2, 3, 4, 5, 5, 7]
    
    " flatten
    :echo flatten([1, [2, [3, 4]], 5])
    [1, 2, 3, 4, 5]
    :echo flatten([1, [2, [3, 4]], 5], 1)
    [1, 2, [3, 4], 5]

system

  • api info

    :lua vim.print(vim.fn.api_info())
    {
      error_types = {
        Exception = {
          id = 0
        },
        Validation = {
          id = 1
        }
      },
      ...
    }
  • exists

    :echo exists("&mouse")
    1
    :echo exists("$HOSTNAME")
    0
    :echo exists("*strftime")
    1
    :echo exists("*s:MyFunc")
    0
    :echo exists("*MyFunc")
    0
    :echo exists("*v:lua.Func")
    0
    :echo exists("bufcount")
    0
    :echo exists(":Make")
    0
    :echo exists(":make")
    2
    :echo exists("#CursorHold")
    1
    :echo exists("#BufReadPre#*.gz")
    1
    :echo exists("#filetypeindent")
    1
    :echo exists("#filetypeindent#FileType")
    1
    :echo exists("#filetypeindent#FileType#*")
    1
    :echo exists("##ColorScheme")
    1
  • file

    :echo filereadable('~/.vimrc')
    0
    :echo filereadable(expand('~/.vimrc'))
    1
    
    " get first line
    :getline(1)
    <!-- START doctoc generated TOC please keep comment here to allow auto update -->
    " get current line
    :echo getline(".")
    
    " get matches
    :echo getmatches()
    " more
    :let m = getmatches()
    :call clearmatches()
    :echo getmatches()
  • returns the character index of the column position

    "                + cursor
    "                v
    :echo charcol('.')
    22
    :echo col('.')
    22
  • line length

    " corsor can be anywhere of following line
    :echo col("$")
    17
  • env

    :echo has_key(environ(), 'HOME')
    1
    :echo index(keys(environ()), 'HOME', 0, 1) != -1
    1
    
    :echo escape('c:\program files\vim', ' \')
    c:\\program\ files\\vim
  • execute

    :echo execute('echon "foo"')
    foo
    
    :echo execute(['echon "foo"', 'echon "bar"'])
    foobar
    
    :echo execute('args')->split("\n")
    ['[nvim.md] ']
  • path

    :echo expandcmd('make %<.o')
    make nvim.o
    :echo expandcmd('make %<.o', {'errmsg': v:true})
    make nvim.o
    
    :echo fnameescape('+some str%nge|name')
    \+some\ str\%nge\|name
    :let fname = '+some str%nge|name'
    :exe "edit " .. fnameescape(fname)
    
    :echo fnamemodify("main.c", ":p:h")
    /home/marslo/ibook/docs/vim

others

  • buffer name

    :echo bufname("#")
    nvim.md
    
    :echo bufname("#")
    cmd
  • buffer number

    :echo "A window containing buffer 1 is " .. (bufwinnr(1))
    A window containing buffer 1 is 1
    
    :echo "A window containing buffer 1 is " .. (bufwinid(1))
    A window containing buffer 1 is 1000
  • others

    :echo byteidx('a😊😊', 2)
    5
    :echo byteidx('a😊😊', 2, 1)
    1
    :echo byteidx('a😊😊', 3, 1)
    5
    
    :let s = 'e' .. nr2char(0x301)
    :echo byteidx(s, 1)
    3
    :echo byteidxcomp(s, 1)
    1
    :echo byteidxcomp(s, 2)
    3

Last updated