Skip to content
Rohit Pradhan edited this page Feb 5, 2022 · 20 revisions

Build Instructions

Windows

You need:

  • A compiler that supports C++20 (at least the parts that are used), I use Clang
  • CMake (> 3.19)
  • A generator, I use Ninja

Instructions:
Note: Use cmd as the shell for these commands.
git clone https://github.com/rohit-px2/nvui.git --recurse-submodules
cd nvui
cmake -B build . -DCMAKE_TOOLCHAIN_FILE=.\vcpkg\scripts\buildsystems\vcpkg.cmake -DCMAKE_BUILD_TYPE=(build type) -G (generator)
cmake --build build --target nvui --config (build type)

If you use MSVC / Visual Studio, by default the folder where the executable is built will be a subdirectory of the build directory.
This causes nvui to not be able to find the assets and the runtime vim file, since it expects the assets to be in "../assets" (where ../ is the parent directory of where the executable currently is) and the vim files to be in "../vim".

Linux

You need:

  • Make
  • A C++ compiler that supports C++20, I use clang-12

git clone https://github.com/rohit-px2/nvui.git --recurse-submodules
cd nvui

For the next part you have two options.

Using vcpkg

Install these packages from the system package manager (example using Ubuntu):
sudo apt-get install gperf autoconf build-essential libtool libgl1-mesa-dev libxi-dev libx11-dev libxext-dev libxkbcommon-x11-dev libglu1-mesa-dev libx11-xcb-dev '^libxcb.*-dev' libxrender-dev ninja-build curl zip unzip tar autopoint python

cmake -B build . -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build --target nvui --config Release

Without using vcpkg

You need these packages:

  • Boost
  • fmt
  • Qt5 (5.15.2)
  • msgpack C++ libraries
  • Catch2 (only if building tests)

cmake -B build . -DCMAKE_BUILD_TYPE=Release
cmake --build build --target nvui --config Release

Arch Linux

  1. Dependencies
sudo pacman -Sy
sudo pacman -S clang make boost fmt hicolor-icon-theme msgpack-cxx qt5-base qt5-svg catch2 cmake ninja git curl wget --needed
  1. Clone
git clone https://github.com/rohit-px2/nvui.git --recurse-submodules
cd nvui
  1. Build
cmake -B build . -DCMAKE_BUILD_TYPE=Release
cmake --build build --target nvui --config Release
  1. Install

nvui needs to read the asserts and vim directories at parent directory. So I make a script to call it, not put it directly in the /bin.

Also the path ~/.local can be replace with /usr/local to use nvui system wide.

mkdir -p ~/.local/share/nvui/bin
mkdir -p ~/.local/bin
cp ./build/nvui ~/.local/share/nvui/bin
cp -r ./vim ~/.local/share/nvui/vim
cp -r ./asserts ~/.local/share/nvui/asserts
echo -e '#!/bin/bash\n\n$HOME/.local/share/nvui/bin/nvui "$@"' > ~/.local/bin/nvui
chmod +x ~/.local/bin/nvui

macOS

You need:

  • Homebrew
  • A C++20 compiler

git clone https://github.com/rohit-px2/nvui.git --recurse-submodules
cd nvui
brew install fmt boost qt@5 msgpack-cxx catch2
export Qt5_DIR=/usr/local/Cellar/qt@5/5.15.2/lib/cmake/Qt5 (or wherever your Qt5 installation is)
cmake -B build . -DCMAKE_BUILD_TYPE=Release
cmake --build build --target nvui --config Release


Configuration Options

Command Line

nvui [--ext_multigrid[=[true | false]]] [--ext_popupmenu[=[true | false]]] [--ext_cmdline[=[true | false]]] [--ext_hlstate[=[true | false]]] [--nvim=/path/to/nvim] [--detached] [--titlebar[=[true | false]] [-- [args_to_nvim...]]

--ext_multigrid
Enables the ext_multigrid feature, allowing for grid movement and scrolling animations.
If specified with =false, the feature is disabled.
Default: Disabled

--ext_popupmenu
Enables the ext_popupmenu feature, using an external popup menu widget.
If specified with =false, the feature is disabled.
Default: Disabled

--ext_cmdline
Enables the ext_cmdline feature, which uses a custom command line widget.
If specified with =false, the feature is disabled.
Default: Disabled

--ext_hlstate
Enables the ext_hlstate feature, which gives more information about highlights to nvui.
If specified with =false, this feature is disabled.
Note: Enabling this feature has been known to cause crashes and has no effect on the application, so it should be kept disabled.
Default: Disabled

--nvim=/path/to/nvim
Specifies where the location of the nvim executable is for nvui to use.
If this flag is not set, or the file at the specified path is not executable,
nvui defaults to the nvim executable in your PATH, and will show an error message if it could not be found.

--titlebar
Enables the custom title bar.
For more information about the custom title bar and customization options, see :h nvui-titlebar.
The custom title bar may have issues and is disabled by default.

-- [args_to_nvim...]
When you specify the -- flag, any arguments after this flag will be forwarded to Neovim.

--detached
Detaches the process from your terminal, so you can use your terminal for other things while running nvui.
For Windows, this isn't needed since nvui auto-detaches (in release builds only).

Configuration in Vim

nvui defines the variable g:nvui=1 so you can hide your configuration behind an existence check of this variable.
An example would be

" Other configuration
if exists('g:nvui')
  " Configure nvui
  NvuiCmdFontFamily Jetbrains Mono
  NvuiCmdFontSize 25.0
  NvuiScrollAnimationDuration 0.2
endif

Or in Lua:

if vim.g.nvui then
  -- Configure through vim commands
  vim.cmd [[NvuiCmdFontFamily Jetbrains Mono]]
end

Font Fallback

nvui offers font fallback by setting multiple fonts. For example,
set guifont=Consolas:h12,JetbrainsMono\ NF,Meiryo\ UI will have this effect:

  • Use "Consolas" as the primary font with point size 12,
  • Look in "JetbrainsMono NF" if a symbol is not found in "Consolas",
  • Look in "Meiryo UI" if a symbol is not found in "JetbrainsMono NF".

The font options are set by the first font i.e. to set the font size you would write
set guifont=First\ Font:h{size},Second\ Font,Third\ Font...
There can not be any spaces between the commas separating each font.

IMEs

nvui supports IMEs, and offers some commands to disable/enable IME support at runtime.
One case you may have is if you wish to use an IME in Insert mode, but disable it while in other modes.
In this case, you can define some autocmds to disable/enable the IME accordingly:

autocmd InsertEnter * NvuiIMEEnable
autocmd InsertLeave * NvuiIMEDisable

You can also see :h nvui-ime for more information.

Customizing the title bar text

You can change what the title bar displays by overriding the Vim function NvuiGetTitle() to return a different string.
By default the NvuiGetTitle() function returns "nvui", and the tails of the directory you are in and the current file.
One example of overriding this would be to display only the full path of the current file you are on:

" Titlebar text will be something like "nvui • D:\Dev\file.txt"
function! NvuiGetTitle()
  return join(split("nvui," . expand("%:p"), ","), g:nvui_tb_separator)
endfunction
Clone this wiki locally