diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..759c3c9 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,16 @@ +require("blakeridgway.plugins-setup") +require("blakeridgway.core.options") +require("blakeridgway.core.keymaps") +require("blakeridgway.core.colorscheme") +require("blakeridgway.plugins.comment") +require("blakeridgway.plugins.nvim-tree") +require("blakeridgway.plugins.lualine") +require("blakeridgway.plugins.telescope") +require("blakeridgway.plugins.nvim-cmp") +require("blakeridgway.plugins.lsp.mason") +require("blakeridgway.plugins.lsp.lspconfig") +require("blakeridgway.plugins.lsp.null-ls") +require("blakeridgway.plugins.autopairs") +require("blakeridgway.plugins.treesitter") +require("blakeridgway.plugins.gitsigns") +require("blakeridgway.plugins.discord") diff --git a/nvim/lua/blakeridgway/core/colorscheme.lua b/nvim/lua/blakeridgway/core/colorscheme.lua new file mode 100644 index 0000000..1526426 --- /dev/null +++ b/nvim/lua/blakeridgway/core/colorscheme.lua @@ -0,0 +1,7 @@ +-- set colorscheme to nightfly with protected call +-- in case it isn't installed +local status, _ = pcall(vim.cmd, "colorscheme nightfly") +if not status then + print("Colorscheme not found!") -- print error if colorscheme not installed + return +end diff --git a/nvim/lua/blakeridgway/core/keymaps.lua b/nvim/lua/blakeridgway/core/keymaps.lua new file mode 100644 index 0000000..c268b7c --- /dev/null +++ b/nvim/lua/blakeridgway/core/keymaps.lua @@ -0,0 +1,55 @@ +-- set leader key to space +vim.g.mapleader = " " + +local keymap = vim.keymap -- for conciseness + +--------------------- +-- General Keymaps +--------------------- + +-- use jk to exit insert mode +keymap.set("i", "jk", "") + +-- clear search highlights +keymap.set("n", "nh", ":nohl") + +-- delete single character without copying into register +keymap.set("n", "x", '"_x') + +-- increment/decrement numbers +keymap.set("n", "+", "") -- increment +keymap.set("n", "-", "") -- decrement + +-- window management +keymap.set("n", "sv", "v") -- split window vertically +keymap.set("n", "sh", "s") -- split window horizontally +keymap.set("n", "se", "=") -- make split windows equal width & height +keymap.set("n", "sx", ":close") -- close current split window + +keymap.set("n", "to", ":tabnew") -- open new tab +keymap.set("n", "tx", ":tabclose") -- close current tab +keymap.set("n", "tn", ":tabn") -- go to next tab +keymap.set("n", "tp", ":tabp") -- go to previous tab + +---------------------- +-- Plugin Keybinds +---------------------- + +-- vim-maximizer +keymap.set("n", "sm", ":MaximizerToggle") -- toggle split window maximization + +-- nvim-tree +keymap.set("n", "e", ":NvimTreeToggle") -- toggle file explorer + +-- telescope +keymap.set("n", "ff", "Telescope find_files") -- find files within current working directory, respects .gitignore +keymap.set("n", "fs", "Telescope live_grep") -- find string in current working directory as you type +keymap.set("n", "fc", "Telescope grep_string") -- find string under cursor in current working directory +keymap.set("n", "fb", "Telescope buffers") -- list open buffers in current neovim instance +keymap.set("n", "fh", "Telescope help_tags") -- list available help tags + +-- telescope git commands +keymap.set("n", "gc", "Telescope git_commits") -- list all git commits (use to checkout) ["gc" for git commits] +keymap.set("n", "gfc", "Telescope git_bcommits") -- list git commits for current file/buffer (use to checkout) ["gfc" for git file commits] +keymap.set("n", "gb", "Telescope git_branches") -- list git branches (use to checkout) ["gb" for git branch] +keymap.set("n", "gs", "Telescope git_status") -- list current changes per file with diff preview ["gs" for git status] diff --git a/nvim/lua/blakeridgway/core/options.lua b/nvim/lua/blakeridgway/core/options.lua new file mode 100644 index 0000000..1aac738 --- /dev/null +++ b/nvim/lua/blakeridgway/core/options.lua @@ -0,0 +1,41 @@ +local opt = vim.opt -- for conciseness + +-- line numbers +opt.relativenumber = true -- show relative line numbers +opt.number = true -- shows absolute line number on cursor line (when relative number is on) + +-- tabs & indentation +opt.tabstop = 2 -- 2 spaces for tabs (prettier default) +opt.shiftwidth = 2 -- 2 spaces for indent width +opt.expandtab = true -- expand tab to spaces +opt.autoindent = true -- copy indent from current line when starting new one + +-- line wrapping +opt.wrap = false -- disable line wrapping + +-- search settings +opt.ignorecase = true -- ignore case when searching +opt.smartcase = true -- if you include mixed case in your search, assumes you want case-sensitive + +-- cursor line +opt.cursorline = true -- highlight the current cursor line + +-- appearance + +-- turn on termguicolors for nightfly colorscheme to work +-- (have to use iterm2 or any other true color terminal) +opt.termguicolors = true +opt.background = "dark" -- colorschemes that can be light or dark will be made dark +opt.signcolumn = "yes" -- show sign column so that text doesn't shift + +-- backspace +opt.backspace = "indent,eol,start" -- allow backspace on indent, end of line or insert mode start position + +-- clipboard +opt.clipboard:append("unnamedplus") -- use system clipboard as default register + +-- split windows +opt.splitright = true -- split vertical window to the right +opt.splitbelow = true -- split horizontal window to the bottom + +opt.iskeyword:append("-") -- consider string-string as whole word diff --git a/nvim/lua/blakeridgway/plugins-setup.lua b/nvim/lua/blakeridgway/plugins-setup.lua new file mode 100644 index 0000000..157ad00 --- /dev/null +++ b/nvim/lua/blakeridgway/plugins-setup.lua @@ -0,0 +1,109 @@ +-- 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("nvim-lua/plenary.nvim") -- lua functions that many plugins use + + use("bluz71/vim-nightfly-guicolors") -- preferred colorscheme + + use("christoomey/vim-tmux-navigator") -- tmux & split window navigation + + use("szw/vim-maximizer") -- maximizes and restores current window + + -- essential plugins + use("tpope/vim-surround") -- add, delete, change surroundings (it's awesome) + use("inkarkat/vim-ReplaceWithRegister") -- replace with register contents using motion (gr + motion) + + -- commenting with gc + use("numToStr/Comment.nvim") + + -- file explorer + use("nvim-tree/nvim-tree.lua") + + -- vs-code like icons + use("nvim-tree/nvim-web-devicons") + + -- statusline + use("nvim-lualine/lualine.nvim") + + -- fuzzy finding w/ telescope + use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" }) -- dependency for better sorting performance + use({ "nvim-telescope/telescope.nvim", tag = "0.1.0" }) -- fuzzy finder + + -- autocompletion + use("hrsh7th/nvim-cmp") -- completion plugin + use("hrsh7th/cmp-buffer") -- source for text in buffer + use("hrsh7th/cmp-path") -- source for file system paths + + -- snippets + use("L3MON4D3/LuaSnip") -- snippet engine + use("saadparwaiz1/cmp_luasnip") -- for autocompletion + use("rafamadriz/friendly-snippets") -- useful snippets + + -- managing & installing lsp servers, linters & formatters + use("williamboman/mason.nvim") -- in charge of managing lsp servers, linters & formatters + use("williamboman/mason-lspconfig.nvim") -- bridges gap b/w mason & lspconfig + + -- configuring lsp servers + use("neovim/nvim-lspconfig") -- easily configure language servers + use("hrsh7th/cmp-nvim-lsp") -- for autocompletion + use({ "glepnir/lspsaga.nvim", branch = "main" }) -- enhanced lsp uis + use("jose-elias-alvarez/typescript.nvim") -- additional functionality for typescript server (e.g. rename file & update imports) + use("onsails/lspkind.nvim") -- vs-code like icons for autocompletion + + -- formatting & linting + use("jose-elias-alvarez/null-ls.nvim") -- configure formatters & linters + use("jayp0521/mason-null-ls.nvim") -- bridges gap b/w mason & null-ls + + -- treesitter configuration + use({ + "nvim-treesitter/nvim-treesitter", + run = function() + local ts_update = require("nvim-treesitter.install").update({ with_sync = true }) + ts_update() + end, + }) + + -- auto closing + use("windwp/nvim-autopairs") -- autoclose parens, brackets, quotes, etc... + use({ "windwp/nvim-ts-autotag", after = "nvim-treesitter" }) -- autoclose tags + + -- git integration + use("lewis6991/gitsigns.nvim") -- show line modifications on left hand side + + -- discord rpc + use("andweeb/presence.nvim") + + if packer_bootstrap then + require("packer").sync() + end +end) diff --git a/nvim/lua/blakeridgway/plugins/autopairs.lua b/nvim/lua/blakeridgway/plugins/autopairs.lua new file mode 100644 index 0000000..ec6312a --- /dev/null +++ b/nvim/lua/blakeridgway/plugins/autopairs.lua @@ -0,0 +1,29 @@ +local autopairs_setup, autopairs = pcall(require, "nvim-autopairs") +if not autopairs_setup then + return +end + +-- configure autopairs +autopairs.setup({ + check_ts = true, -- enable treesitter + ts_config = { + lua = { "string" }, -- don't add pairs in lua string treesitter nodes + javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes + java = false, -- don't check treesitter on java + }, +}) + +-- import nvim-autopairs completion functionality safely +local cmp_autopairs_setup, cmp_autopairs = pcall(require, "nvim-autopairs.completion.cmp") +if not cmp_autopairs_setup then + return +end + +-- import nvim-cmp plugin safely (completions plugin) +local cmp_setup, cmp = pcall(require, "cmp") +if not cmp_setup then + return +end + +-- make autopairs and completion work together +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) diff --git a/nvim/lua/blakeridgway/plugins/comment.lua b/nvim/lua/blakeridgway/plugins/comment.lua new file mode 100644 index 0000000..527672d --- /dev/null +++ b/nvim/lua/blakeridgway/plugins/comment.lua @@ -0,0 +1,8 @@ +-- import comment +local setup, comment = pcall(require, "Comment") +if not setup then + return +end + +-- enable comment +comment.setup() diff --git a/nvim/lua/blakeridgway/plugins/discord.lua b/nvim/lua/blakeridgway/plugins/discord.lua new file mode 100644 index 0000000..2349af0 --- /dev/null +++ b/nvim/lua/blakeridgway/plugins/discord.lua @@ -0,0 +1,23 @@ +require("presence"):setup({ + -- General options + auto_update = true, -- Update activity based on autocmd events (if `false`, map or manually execute `:lua package.loaded.presence:update()`) + neovim_image_text = "The One True Text Editor", -- Text displayed when hovered over the Neovim image + main_image = "neovim", -- Main image display (either "neovim" or "file") + client_id = "793271441293967371", -- Use your own Discord application client id (not recommended) + log_level = nil, -- Log messages at or above this level (one of the following: "debug", "info", "warn", "error") + debounce_timeout = 10, -- Number of seconds to debounce events (or calls to `:lua package.loaded.presence:update(, true)`) + enable_line_number = false, -- Displays the current line number instead of the current project + blacklist = {}, -- A list of strings or Lua patterns that disable Rich Presence if the current file name, path, or workspace matches + buttons = true, -- Configure Rich Presence button(s), either a boolean to enable/disable, a static table (`{{ label = "