Skip to content

Commit 7d13af9

Browse files
committed
Initial commit
0 parents  commit 7d13af9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1668
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore .bak files
2+
*.bak

.stylua.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
column_width = 140
2+
line_endings = "Unix"
3+
indent_type = "Spaces"
4+
indent_width = 2
5+

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Geoff Ball
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# nvim-config
2+
3+
This repo contains my Neovim config, which has been adapted / inspired largely from the work of:
4+
5+
- [TJ DeVries](https://github.com/tjdevries/config_manager)
6+
- [Josean Martinez](https://github.com/josean-dev/dev-environment-files)
7+
8+
## Getting started
9+
10+
I've been inspired by a large number of Neovim configs over the years, but have always found that adopting someone else's config as my own never worked out. Rather than using this repo as-is, I'd suggest drawing inspiration from bits and pieces as needed.
11+
12+
That said, this repo should work as-is on Mac or Linux (other than the Homebrew comment below). If you're using Windows, you'd need to modify where your nvim config goes.
13+
14+
1. Install the latest stable build of [Neovim](https://github.com/neovim/neovim) (I use Homebrew on Mac, but installing from source will work as well).
15+
2. Backup ~/.config/nvim and then delete the directory.
16+
3. In your terminal, you can either:
17+
a. Run `nvim --headless "+Lazy! sync" +qa` to get everything set up, or
18+
b. Open Neovim (`nvim`), let the package manager install everything, and then quit.
19+
4. In either case, Neovim will now be ready to go, and can be started by running `nvim`.

after/plugin/autocommands.lua

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
local autocmd = vim.api.nvim_create_autocmd
2+
3+
-- Highlight on yank
4+
-- See `:help vim.highlight.on_yank()`
5+
local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
6+
vim.api.nvim_create_autocmd("TextYankPost", {
7+
callback = function()
8+
vim.highlight.on_yank()
9+
end,
10+
group = highlight_group,
11+
pattern = "*",
12+
})
13+
14+
-- Prevent comments from carrying over to new lines
15+
autocmd("BufEnter", {
16+
callback = function()
17+
vim.opt.formatoptions:remove({ "r", "o" })
18+
end,
19+
})
20+
21+
-- Open the tree when vim starts if the current buffer is a directory
22+
autocmd("VimEnter", {
23+
callback = function(data)
24+
-- buffer is a directory
25+
local directory = vim.fn.isdirectory(data.file) == 1
26+
27+
-- change to the directory
28+
if directory then
29+
vim.cmd.cd(data.file)
30+
-- open the tree
31+
require("nvim-tree.api").tree.open()
32+
end
33+
end,
34+
})

after/queries/ecma/textobjects.scm

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
; extends
2+
(object
3+
(pair
4+
key: (_) @property.lhs
5+
value: (_) @property.inner @property.rhs) @property.outer)

init.lua

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
vim.g.mapleader = " "
2+
vim.g.maplocalleader = ","
3+
4+
require("geoff.core")
5+
require("geoff.lazy")
6+
7+
-- The `modeline`. See `:help modeline`
8+
-- vim: ts=2 sts=2 sw=2 et

lazy-lock.json

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
3+
"LuaSnip": { "branch": "master", "commit": "80a8528f084a97b624ae443a6f50ff8074ba486b" },
4+
"advanced-git-search.nvim": { "branch": "main", "commit": "79c9aab7aa1cf08c2a25d931719bcb408b381ed2" },
5+
"bufferline.nvim": { "branch": "main", "commit": "6ecd37e0fa8b156099daedd2191130e083fb1490" },
6+
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
7+
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
8+
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
9+
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
10+
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
11+
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
12+
"conform.nvim": { "branch": "master", "commit": "f7766d2fbe23f0f22a3db1513beba7d03a8dc261" },
13+
"copilot.vim": { "branch": "release", "commit": "f6d1124a12ca76731313eb0e7ec9562ee6f12e73" },
14+
"diffview.nvim": { "branch": "main", "commit": "d38c1b5266850f77f75e006bcc26213684e1e141" },
15+
"dressing.nvim": { "branch": "master", "commit": "1f2d1206a03bd3add8aedf6251e4534611de577f" },
16+
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
17+
"flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
18+
"gitsigns.nvim": { "branch": "main", "commit": "af0f583cd35286dd6f0e3ed52622728703237e50" },
19+
"harpoon": { "branch": "master", "commit": "c1aebbad9e3d13f20bedb8f2ce8b3a94e39e424a" },
20+
"indent-blankline.nvim": { "branch": "master", "commit": "29be0919b91fb59eca9e90690d76014233392bef" },
21+
"lazy.nvim": { "branch": "main", "commit": "16603c6917435d8446f7357cb61095138a417085" },
22+
"lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" },
23+
"lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" },
24+
"mason-lspconfig.nvim": { "branch": "main", "commit": "40301e1c74bc0946eece13edf2b1c561cc497491" },
25+
"mason-nvim-dap.nvim": { "branch": "main", "commit": "f0cd12f7a8a310c58cecebddb6b219ffad1cfd0f" },
26+
"mason-tool-installer.nvim": { "branch": "main", "commit": "e4f34741daa9cf95de68a603d3e7a6844a69fdf0" },
27+
"mason.nvim": { "branch": "main", "commit": "cd7835b15f5a4204fc37e0aa739347472121a54c" },
28+
"neodev.nvim": { "branch": "main", "commit": "0491a9c7a1775fa5380ecf38d79de1a32f68cc52" },
29+
"neogit": { "branch": "master", "commit": "05899be06d611c485cfb6e17ef6e3b695de67b62" },
30+
"nvim-autopairs": { "branch": "master", "commit": "0f04d78619cce9a5af4f355968040f7d675854a1" },
31+
"nvim-bqf": { "branch": "main", "commit": "8784eebf34371049b641646d00232c2603215297" },
32+
"nvim-cmp": { "branch": "main", "commit": "51260c02a8ffded8e16162dcf41a23ec90cfba62" },
33+
"nvim-dap": { "branch": "master", "commit": "79dbc70eb79271ad801e4ff293887cde324c28d0" },
34+
"nvim-dap-go": { "branch": "main", "commit": "a5cc8dcad43f0732585d4793deb02a25c4afb766" },
35+
"nvim-dap-ui": { "branch": "master", "commit": "34160a7ce6072ef332f350ae1d4a6a501daf0159" },
36+
"nvim-lint": { "branch": "master", "commit": "962a76877a4479a535b935bd7ef35ad41ba308b2" },
37+
"nvim-lsp-file-operations": { "branch": "master", "commit": "1e0ffa0acc92f88f9f2b68df47ccbe1917653a42" },
38+
"nvim-lspconfig": { "branch": "master", "commit": "d0467b9574b48429debf83f8248d8cee79562586" },
39+
"nvim-neoclip.lua": { "branch": "main", "commit": "4e406ae0f759262518731538f2585abb9d269bac" },
40+
"nvim-surround": { "branch": "main", "commit": "4f0e1f470595af067eca9b872778d83c7f52f134" },
41+
"nvim-tree.lua": { "branch": "master", "commit": "7e3c0bee7b246ca835d5f7453db6fa19de359bab" },
42+
"nvim-treesitter": { "branch": "master", "commit": "a8c14d68b024ffc20baec92d1acc91796bcfb485" },
43+
"nvim-treesitter-context": { "branch": "master", "commit": "2806d83e3965017382ce08792ee527e708fa1bd4" },
44+
"nvim-treesitter-textobjects": { "branch": "master", "commit": "e69a504baf2951d52e1f1fbb05145d43f236cbf1" },
45+
"nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" },
46+
"nvim-web-devicons": { "branch": "master", "commit": "5de460ca7595806044eced31e3c36c159a493857" },
47+
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
48+
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
49+
"telescope-live-grep-args.nvim": { "branch": "master", "commit": "20656efd7a0dbb4483290649c9671af14b0cfb0d" },
50+
"telescope.nvim": { "branch": "0.1.x", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" },
51+
"treesj": { "branch": "main", "commit": "070e6761d0b11a55446d988a69908f7a0928dbab" },
52+
"trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" },
53+
"undotree": { "branch": "master", "commit": "170aa9e516b6926e6bddfe21bbf01f2283a00e7d" },
54+
"vim-fugitive": { "branch": "master", "commit": "46eaf8918b347906789df296143117774e827616" },
55+
"vim-nightfly-guicolors": { "branch": "master", "commit": "9053e99131731f268258ab4d35d4841c3126ff9a" },
56+
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
57+
}

lua/geoff/core/init.lua

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require("geoff.core.keymaps")
2+
require("geoff.core.options")

lua/geoff/core/keymaps.lua

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
-- See `:help vim.keymap.set()`
2+
vim.keymap.set({ "n", "v" }, "<Space>", "<Nop>", { silent = true })
3+
4+
-- Don't let me use shift-arrows in insert mode
5+
vim.keymap.set("i", "<S-Up>", "<Nop>", { silent = true })
6+
vim.keymap.set("i", "<S-Down>", "<Nop>", { silent = true })
7+
8+
-- Remap for dealing with word wrap
9+
vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
10+
vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
11+
12+
-- Toggle word wrap
13+
vim.keymap.set("n", "<leader>w", ":set wrap!<cr>", { desc = "Toggle word wrap" })
14+
15+
-- Better indenting in visual mode
16+
vim.keymap.set("v", ">", ">gv")
17+
vim.keymap.set("v", "<", "<gv")
18+
19+
-- Clear highlights
20+
-- I don't use this anymore because I have `hlsearch` set to false
21+
-- Also, <leader>h is used by Harpoon
22+
-- vim.keymap.set("n", "<leader>h", vim.cmd.nohl, { desc = "Remove highlight" })
23+
vim.keymap.set("n", "<esc>", vim.cmd.nohl)
24+
25+
-- Move highlighted text around
26+
vim.keymap.set("v", "J", ":m '>+1<cr>gv=gv")
27+
vim.keymap.set("v", "K", ":m '<-2<cr>gv=gv")
28+
29+
-- Keep cursor in place when joining lines
30+
vim.keymap.set("n", "J", "mzJ`z")
31+
32+
-- Keep cursor vertically centered when scrolling the buffer
33+
vim.keymap.set("n", "<c-d>", "<c-d>zz")
34+
vim.keymap.set("n", "<c-u>", "<c-u>zz")
35+
36+
-- Keep search term in the vertical center of the screen when jumping with n and N
37+
vim.keymap.set("n", "n", "nzzzv")
38+
vim.keymap.set("n", "N", "Nzzzv")
39+
40+
-- Deleting with x and X should go to the black hole register
41+
vim.keymap.set("n", "x", '"_x')
42+
vim.keymap.set("n", "X", '"_X')
43+
44+
-- Paste from system clipboard
45+
vim.keymap.set("n", "<localleader>p", '"*p', { desc = "Paste from system clipboard" })
46+
vim.keymap.set("n", "<localleader>P", '"*P', { desc = "Paste from system clipboard" })
47+
48+
-- Yank to system clipboard
49+
vim.keymap.set({ "n", "v" }, "<localleader>y", '"+y', { desc = "Yank to system clipboard" })
50+
vim.keymap.set("n", "<localleader>Y", '"+Y', { desc = "Yank to system clipboard" })
51+
52+
-- Paste without losing original copied term
53+
vim.keymap.set("x", "<localleader>p", '"_dP', { desc = "Keep original term when pasting" })
54+
55+
-- Make Y work like C and D
56+
vim.keymap.set("n", "Y", "yg$")
57+
58+
-- Delete to void register
59+
vim.keymap.set({ "n", "v" }, "<localleader>d", '"_d', { desc = "Delete to black hole register" })
60+
61+
-- Make Q a no-op
62+
vim.keymap.set("n", "Q", "<nop>")
63+
64+
-- Replace term under cursor
65+
vim.keymap.set(
66+
"n",
67+
"<leader>rp",
68+
[[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]],
69+
{ desc = "Replace via Substitution" }
70+
)
71+
72+
-- Buffer keymaps
73+
vim.keymap.set("n", "<leader>bc", vim.cmd.bdelete, { desc = "Close buffer" })
74+
vim.keymap.set("n", "<leader>bn", vim.cmd.bnext, { desc = "Next buffer" })
75+
vim.keymap.set("n", "<leader>bp", vim.cmd.bprevious, { desc = "Previous buffer" })
76+
vim.keymap.set("n", "<leader>bl", "<cmd>BufferLinePick<cr>", { desc = "Pick buffer from list" })
77+
vim.keymap.set("n", "<leader>bL", "<cmd>BufferLinePickClose<cr>", { desc = "Close buffer from list" })
78+
vim.keymap.set("n", "[b", "<cmd>BufferLineCyclePrev<cr>", { desc = "Previous buffer" })
79+
vim.keymap.set("n", "]b", "<cmd>BufferLineCycleNext<cr>", { desc = "Next buffer" })
80+
81+
-- Diagnostic keymaps
82+
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Previous diagnostic" })
83+
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Next diagnostic" })
84+
vim.keymap.set("n", "<leader>e", "<cmd>Telescope diagnostics bufnr=0<CR>", { desc = "Show buffer diagnostics" })
85+
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostics list" })
86+
87+
-- Fold keymaps
88+
local toggleFoldColumn = function()
89+
if vim.api.nvim_get_option_value("foldcolumn", {}) == "0" then
90+
vim.cmd("set foldcolumn=1")
91+
else
92+
vim.cmd("set foldcolumn=0")
93+
end
94+
vim.api.nvim_echo({ { "Fold column is set to " .. vim.api.nvim_get_option_value("foldcolumn", {}) } }, false, {})
95+
end
96+
97+
vim.keymap.set("n", "<space>z", toggleFoldColumn, { desc = "Toggle fold" })
98+
99+
-- Diffview keymaps
100+
local toggleDiffview = function()
101+
if vim.bo.filetype == "DiffviewFiles" then
102+
vim.cmd("DiffviewClose")
103+
else
104+
vim.cmd("DiffviewOpen")
105+
end
106+
end
107+
vim.keymap.set("n", "<leader>gd", toggleDiffview, { desc = "Toggle diffview" })
108+
-- See :h wildcharm for why <C-Z> is used
109+
vim.keymap.set("n", "<leader>gD", ":Diffview<C-Z>", { desc = "Trigger :Diffview in command line" })
110+
111+
-- Flash keymaps
112+
vim.keymap.set("n", "<leader>jf", function()
113+
require("flash").jump()
114+
end, { desc = "Flash jump" })
115+
vim.keymap.set("n", "<leader>jt", function()
116+
require("flash").treesitter()
117+
end, { desc = "Flash current node" })
118+
vim.keymap.set("n", "<leader>jr", function()
119+
require("flash").treesitter_search()
120+
end, { desc = "Flash search current view" })

lua/geoff/core/options.lua

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
-- vim.g.mapleader and vim.g.maplocalleader are set in init.lua
2+
3+
-- Highlight the current term when searching...
4+
vim.o.hlcursearch = true
5+
-- ...but not the rest of them
6+
vim.o.hlsearch = false
7+
8+
-- termguicolors are needed for some color schemes
9+
vim.opt.termguicolors = true
10+
11+
-- if the color scheme offers dark mode, use it
12+
vim.opt.background = "dark"
13+
14+
-- Make line numbers default
15+
vim.wo.number = true
16+
vim.wo.relativenumber = true
17+
18+
-- Enable mouse mode
19+
vim.o.mouse = "a"
20+
21+
-- Sync clipboard between OS and Neovim.
22+
-- Remove this option if you want your OS clipboard to remain independent.
23+
-- See `:help 'clipboard'`
24+
-- vim.o.clipboard = 'unnamedplus'
25+
26+
-- Enable break indent
27+
vim.o.breakindent = true
28+
vim.o.autoindent = true
29+
30+
-- line wrapping
31+
vim.opt.wrap = true
32+
33+
-- Backspace handling
34+
vim.opt.backspace = "indent,eol,start" -- allow backspace on indent, end of line, or insert mode start position
35+
36+
-- Set tabs to always be 2 spaces
37+
vim.o.tabstop = 2
38+
vim.o.shiftwidth = 2
39+
vim.o.shiftround = true
40+
vim.o.expandtab = true
41+
vim.bo.softtabstop = 2
42+
43+
-- Add a wrap column
44+
-- vim.o.colorcolumn = "80"
45+
46+
-- Start scrolling near edge of window
47+
vim.o.scrolloff = 6
48+
vim.o.sidescroll = 6
49+
50+
-- Save undo history
51+
vim.o.swapfile = false
52+
vim.o.backup = false
53+
vim.o.undofile = true
54+
55+
-- Case insensitive searching UNLESS /C or capital in search
56+
vim.o.ignorecase = true
57+
vim.o.smartcase = true
58+
59+
-- Keep signcolumn on by default
60+
vim.wo.signcolumn = "yes"
61+
62+
-- Make dash part of a word
63+
vim.opt.iskeyword:append("-")
64+
65+
-- Decrease update time
66+
vim.o.updatetime = 250
67+
vim.o.timeout = true
68+
vim.o.timeoutlen = 300

lua/geoff/lazy.lua

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
2+
if not vim.loop.fs_stat(lazypath) then
3+
vim.fn.system({
4+
"git",
5+
"clone",
6+
"--filter=blob:none",
7+
"https://github.com/folke/lazy.nvim.git",
8+
"--branch=stable", -- latest stable release
9+
lazypath,
10+
})
11+
end
12+
vim.opt.rtp:prepend(lazypath)
13+
14+
require("lazy").setup({ { import = "geoff.plugins" }, { import = "geoff.plugins.lsp" } }, {
15+
install = {
16+
colorscheme = { "nightfly" },
17+
},
18+
checker = {
19+
enabled = true,
20+
notify = false,
21+
},
22+
change_detection = {
23+
notify = false,
24+
},
25+
})

lua/geoff/plugins/better-quickfix.lua

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
return {
2+
-- TODO: Review https://github.com/kevinhwang91/nvim-bqf to figure out how this works
3+
"kevinhwang91/nvim-bqf",
4+
opts = {},
5+
}

0 commit comments

Comments
 (0)