Skip to content

Instantly share code, notes, and snippets.

@dreamorosi
Created October 17, 2023 12:18
Show Gist options
  • Save dreamorosi/f33906eb5b338ed50daeefad8f712921 to your computer and use it in GitHub Desktop.
Save dreamorosi/f33906eb5b338ed50daeefad8f712921 to your computer and use it in GitHub Desktop.
Install neovim on Amazon Linux 2023

Build & Install neovim

AL2023 doesn't have a distribution for neovim, so you need to build it from source - for more info see here.

Install prerequisites:

sudo yum -y install ninja-build cmake gcc make unzip gettext curl git --allowerasing

Clone repository:

git clone https://github.com/neovim/neovim

Build from source:

cd neovim && git checkout stable && make CMAKE_BUILD_TYPE=RelWithDebInfo

Install:

sudo make install

Setup plugins w/ Packer

We are going to use Packer to manage the plugins and use Lua configs.

Create the following folder structure:

~/.config/
└── nvim/
    ├── init.lua
    └── lua
        └── plugins.lua

Using:

mkdir -p ~/.config/nvim/lua \
  && touch ~/.config/nvim/init.lua \
  && touch ~/.config/nvim/lua/plugins.lua

Next, open the ~/.config/nvim/lua/plugins.lua file and replace its content with:

local fn = vim.fn

-- Automatically install packer
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
	PACKER_BOOTSTRAP = fn.system({
		"git",
		"clone",
		"--depth",
		"1",
		"https://github.com/wbthomason/packer.nvim",
		install_path,
	})
	print("Installing packer close and reopen Neovim...")
	vim.cmd([[packadd packer.nvim]])
end

-- Autocommand that reloads neovim whenever you save the plugins.lua file
vim.cmd([[
  augroup packer_user_config
    autocmd!
    autocmd BufWritePost plugins.lua source <afile> | PackerSync
  augroup end
]])

-- Use a protected call so we don't error out on first use
local status_ok, packer = pcall(require, "packer")
if not status_ok then
	return
end

-- Have packer use a popup window
packer.init({
	display = {
		open_fn = function()
			return require("packer.util").float({ border = "rounded" })
		end,
	},
})

-- Install your plugins here
return packer.startup(function(use)
	use ("wbthomason/packer.nvim") -- Have packer manage itself	

  -- Your other plugins go here

	if PACKER_BOOTSTRAP then
		require("packer").sync()
	end
end)

Then, open the ~/.config/nvim/init.lua file and add the following line at the top of the file:

require("plugins")

Finally, open the plugins.lua file again (``nvim ~/.config/nvim/lua/plugins.lua) and then save with :w`, this will prompt packer to install the plugins listed in the file.

Install plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment