diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..72db25b --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,9 @@ +-- ~/.config/nvim/init.lua +-- +-- Charles Danesi (https://github.com/cdanesi) + +-- Settings +require("plugins-setup") +require("core.options") +require("core.keymaps") +require("core.colorscheme") diff --git a/.config/nvim/lua/core/colorscheme.lua b/.config/nvim/lua/core/colorscheme.lua new file mode 100644 index 0000000..deadd16 --- /dev/null +++ b/.config/nvim/lua/core/colorscheme.lua @@ -0,0 +1,6 @@ +-- set colorscheme if it's installed +local status, _ = pcall(vim.cmd, "colorscheme onenord") +if not status then + print("Color scheme not found!") + return +end diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua new file mode 100644 index 0000000..36b2980 --- /dev/null +++ b/.config/nvim/lua/core/keymaps.lua @@ -0,0 +1,4 @@ +-- set leader key to space +vim.g.mapleader = " " + +local keymap = vim.keymap diff --git a/.config/nvim/lua/core/options.lua b/.config/nvim/lua/core/options.lua new file mode 100644 index 0000000..5410524 --- /dev/null +++ b/.config/nvim/lua/core/options.lua @@ -0,0 +1,38 @@ +local opt = vim.opt + +-- line numbers +opt.number = true +opt.relativenumber = true + +-- tabs & indents +opt.tabstop = 3 +opt.shiftwidth = 3 +opt.expandtab = true +opt.autoindent = true + +-- disable line wrapping +opt.wrap = false + +-- search +opt.ignorecase = true +opt.smartcase = true + +-- cursor line +opt.cursorline = true + +-- appearance +opt.termguicolors = false +opt.background = "dark" +opt.signcolumn = "yes" + +-- backspace +opt.backspace = "indent,eol,start" + +-- clipboard +opt.clipboard:append("unnamedplus") -- use system clipboard as the default register + +-- split windows +opt.splitright = true +opt.splitbelow = true + +opt.iskeyword:append("-") -- consider string-string as a whole word diff --git a/.config/nvim/lua/plugins-setup.lua b/.config/nvim/lua/plugins-setup.lua new file mode 100644 index 0000000..9f092b8 --- /dev/null +++ b/.config/nvim/lua/plugins-setup.lua @@ -0,0 +1,37 @@ +-- auto install packer if not installed +local ensure_packer = function() + local fn = vim.fn + local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }) + vim.cmd([[packadd packer.nvim]]) + return true + end + return false +end +local packer_bootstrap = ensure_packer() + +-- autoreload +vim.cmd([[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins-setup.lua source | PackerSync + augroup end +]]) + +-- import packer safely +local status, packer = pcall(require, "packer") +if not status then + return +end + +-- enable plugins +return packer.startup(function(use) + use("wbthomason/packer.nvim") + use("nvim-lua/plenary.nvim") + use("rmehri01/onenord.nvim") -- preferred colorscheme + + if packer_bootstrap then + require("packer").sync() + end +end)