From b11874e3806f97a721e962125e64848c85b74fc0 Mon Sep 17 00:00:00 2001 From: Jonathan DeMasi Date: Thu, 29 Jun 2023 21:08:40 -0600 Subject: add nvim config --- nvim/init.lua | 5 ++++ nvim/lua/jonathan/core/colorscheme.lua | 5 ++++ nvim/lua/jonathan/core/keymaps.lua | 0 nvim/lua/jonathan/core/options.lua | 30 +++++++++++++++++++ nvim/lua/jonathan/plugins-setup.lua | 38 +++++++++++++++++++++++ nvim/lua/jonathan/plugins/nvim-tree.lua | 53 +++++++++++++++++++++++++++++++++ 6 files changed, 131 insertions(+) create mode 100644 nvim/init.lua create mode 100644 nvim/lua/jonathan/core/colorscheme.lua create mode 100644 nvim/lua/jonathan/core/keymaps.lua create mode 100644 nvim/lua/jonathan/core/options.lua create mode 100644 nvim/lua/jonathan/plugins-setup.lua create mode 100644 nvim/lua/jonathan/plugins/nvim-tree.lua diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..3c57d0f --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,5 @@ +require("jonathan.plugins-setup") +require("jonathan.core.options") +require("jonathan.core.keymaps") +require("jonathan.core.colorscheme") +require("jonathan.plugins.nvim-tree") diff --git a/nvim/lua/jonathan/core/colorscheme.lua b/nvim/lua/jonathan/core/colorscheme.lua new file mode 100644 index 0000000..9faed16 --- /dev/null +++ b/nvim/lua/jonathan/core/colorscheme.lua @@ -0,0 +1,5 @@ +local status, _ = pcall(vim.cmd, "colorscheme elflord") +if not status then + print("Colorscheme not found!") + return +end diff --git a/nvim/lua/jonathan/core/keymaps.lua b/nvim/lua/jonathan/core/keymaps.lua new file mode 100644 index 0000000..e69de29 diff --git a/nvim/lua/jonathan/core/options.lua b/nvim/lua/jonathan/core/options.lua new file mode 100644 index 0000000..dc50863 --- /dev/null +++ b/nvim/lua/jonathan/core/options.lua @@ -0,0 +1,30 @@ +local opt = vim.opt + +-- line numbers +-- opt.relativenumber = true +-- opt.numer = true + + +-- tab & indent +opt.tabstop = 4 +opt.shiftwidth = 4 +opt.expandtab = true +opt.autoindent = false + +-- line wrapping +opt.wrap = false + + +-- search settings +opt.ignorecase = true +opt.smartcase = true + + +--opt.termguicolors = true +opt.background = "dark" + +-- jthan, plz +opt.backspace = "indent,eol,start" +-- opt.clipboard:append("unnamedplus") + +opt.mouse = "" diff --git a/nvim/lua/jonathan/plugins-setup.lua b/nvim/lua/jonathan/plugins-setup.lua new file mode 100644 index 0000000..400b1d8 --- /dev/null +++ b/nvim/lua/jonathan/plugins-setup.lua @@ -0,0 +1,38 @@ +-- 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() -- true if packer was just installed + +-- autocommand that reloads neovim and installs/updates/removes plugins +-- when file is saved +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 + +-- add list of plugins to install +return packer.startup(function(use) + -- packer can manage itself + use("wbthomason/packer.nvim") + use("bluz71/vim-nightfly-guicolors") -- preferred colorscheme + use("nvim-tree/nvim-tree.lua") + + if packer_bootstrap then + require("packer").sync() + end +end) diff --git a/nvim/lua/jonathan/plugins/nvim-tree.lua b/nvim/lua/jonathan/plugins/nvim-tree.lua new file mode 100644 index 0000000..fc551e1 --- /dev/null +++ b/nvim/lua/jonathan/plugins/nvim-tree.lua @@ -0,0 +1,53 @@ +-- import nvim-tree plugin safely +local setup, nvimtree = pcall(require, "nvim-tree") +if not setup then + return +end + +-- recommended settings from nvim-tree documentation +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +-- change color for arrows in tree to light blue +vim.cmd([[ highlight NvimTreeIndentMarker guifg=#3FC5FF ]]) + +-- configure nvim-tree +nvimtree.setup({ + -- disable window_picker for + -- explorer to work well with + -- window splits + actions = { + open_file = { + window_picker = { + enable = false, + }, + }, + }, + -- git = { + -- ignore = false, + -- }, +}) + +-- open nvim-tree on setup + +local function open_nvim_tree(data) + -- buffer is a [No Name] + local no_name = data.file == "" and vim.bo[data.buf].buftype == "" + + -- buffer is a directory + local directory = vim.fn.isdirectory(data.file) == 1 + + if not no_name and not directory then + return + end + + -- change to the directory + if directory then + vim.cmd.cd(data.file) + end + + -- open the tree + require("nvim-tree.api").tree.open() +end + +vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) -- cgit v1.2.3