Skip to content

Instantly share code, notes, and snippets.

@benkant
Created January 18, 2024 02:49
Show Gist options
  • Save benkant/d32d4ab32dc6ac08fad860ced82e7bba to your computer and use it in GitHub Desktop.
Save benkant/d32d4ab32dc6ac08fad860ced82e7bba to your computer and use it in GitHub Desktop.
Basic nvim config for CEF/Chromium work
#!/bin/bash
# WARNING: installs nvim and ALE
# Install nvim plugins suitable for working with Chromium/CEF codebase:
# - shfmt
# - clang-format
# - eslint
# - yapf (PEP 8)
set -euo pipefail
readonly DNF_PACKAGES="shfmt clang clang-tools-extra nodejs npm python3-pip neovim"
readonly NPM_PACKAGES="eslint"
readonly PIP_PACKAGES="cpplint yapf"
readonly NVIM_CONFIG_DIR="$HOME/.config/nvim"
readonly NVIM_INIT_FILE="$NVIM_CONFIG_DIR/init.vim"
update_and_install_dependencies() {
echo "Updating and installing dependencies..."
sudo dnf update -y
sudo dnf install -y "${DNF_PACKAGES}"
}
install_npm_packages() {
echo "Installing eslint globally..."
sudo npm install -g "${NPM_PACKAGES}"
}
install_pip_packages() {
echo "Installing cpplint and yapf..."
pip3 install --user "${PIP_PACKAGES}"
}
install_vim_plug() {
echo "Installing Vim-Plug for Neovim..."
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
}
configure_neovim() {
echo "Configuring Neovim..."
mkdir -p "${NVIM_CONFIG_DIR}"
cat << EOF > "${NVIM_INIT_FILE}"
call plug#begin('~/.local/share/nvim/plugged')
" Asynchronous linting/fixing
Plug 'dense-analysis/ale'
call plug#end()
" ALE configuration
let g:ale_fixers = {
\ 'sh': ['shfmt'],
\ 'cpp': ['clang-format'],
\ 'javascript': ['eslint'],
\ 'python': ['yapf'],
\ }
let g:ale_linters = {
\ 'cpp': ['cpplint'],
\ }
let g:ale_fix_on_save = 1
EOF
echo "Neovim is configured. Open Neovim and run :PlugInstall to install the plugins."
}
main() {
update_and_install_dependencies
install_npm_packages
install_pip_packages
install_vim_plug
configure_neovim
echo "Done."
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment