initial neovim customizations

This commit is contained in:
Michael Mroczka 2023-11-11 18:50:11 -06:00
parent a005f15cec
commit 4ee307520f
4 changed files with 178 additions and 122 deletions

141
init.lua
View File

@ -1,43 +1,3 @@
--[[
=====================================================================
==================== READ THIS BEFORE CONTINUING ====================
=====================================================================
Kickstart.nvim is *not* a distribution.
Kickstart.nvim is a template for your own configuration.
The goal is that you can read every line of code, top-to-bottom, understand
what your configuration is doing, and modify it to suit your needs.
Once you've done that, you should start exploring, configuring and tinkering to
explore Neovim!
If you don't know anything about Lua, I recommend taking some time to read through
a guide. One possible example:
- https://learnxinyminutes.com/docs/lua/
And then you can explore or search through `:help lua-guide`
- https://neovim.io/doc/user/lua-guide.html
Kickstart Guide:
I have left several `:help X` comments throughout the init.lua
You should run that command and read that help section for more information.
In addition, I have some `NOTE:` items throughout the file.
These are for you, the reader to help understand what is happening. Feel free to delete
them once you know what you're doing, but they should serve as a guide for when you
are first encountering a few different constructs in your nvim config.
I hope you enjoy your Neovim journey,
- TJ
P.S. You can delete this when you're done too. It's your config now :)
--]]
-- Set <space> as the leader key -- Set <space> as the leader key
-- See `:help mapleader` -- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
@ -45,8 +5,6 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' ' vim.g.maplocalleader = ' '
-- [[ Install `lazy.nvim` plugin manager ]] -- [[ Install `lazy.nvim` plugin manager ]]
-- https://github.com/folke/lazy.nvim
-- `:help lazy.nvim.txt` for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
vim.fn.system { vim.fn.system {
@ -152,15 +110,22 @@ require('lazy').setup({
}, },
}, },
{ {
-- Theme inspired by Atom "bluz71/vim-nightfly-colors",
'navarasu/onedark.nvim', name = "nightfly",
lazy = false,
priority = 1000, priority = 1000,
config = function() config = function()
vim.cmd.colorscheme 'onedark' vim.cmd.colorscheme 'nightfly'
end, end,
}, },
-- File system plugin that allows editing and manipulating files in buffers
{
'stevearc/oil.nvim',
opts = {},
-- Optional dependencies
dependencies = { "nvim-tree/nvim-web-devicons" },
},
{ {
-- Set lualine as statusline -- Set lualine as statusline
'nvim-lualine/lualine.nvim', 'nvim-lualine/lualine.nvim',
@ -168,9 +133,9 @@ require('lazy').setup({
opts = { opts = {
options = { options = {
icons_enabled = false, icons_enabled = false,
theme = 'onedark', theme = 'nightfly',
component_separators = '|', component_separators = '|',
section_separators = '', section_separators = ' ',
}, },
}, },
}, },
@ -183,6 +148,8 @@ require('lazy').setup({
main = 'ibl', main = 'ibl',
opts = {}, opts = {},
}, },
-- underline the word your cursor is on
{ 'echasnovski/mini.cursorword', version = '*', opts = {} },
-- "gc" to comment visual regions/lines -- "gc" to comment visual regions/lines
{ 'numToStr/Comment.nvim', opts = {} }, { 'numToStr/Comment.nvim', opts = {} },
@ -232,62 +199,12 @@ require('lazy').setup({
-- { import = 'custom.plugins' }, -- { import = 'custom.plugins' },
}, {}) }, {})
-- [[ Setting options ]] -- [[ Basic Vim Options ]]
-- See `:help vim.o` require("custom.options")
-- NOTE: You can change these options as you wish!
-- Set highlight on search
vim.o.hlsearch = false
-- Make line numbers default
vim.wo.number = true
-- Enable mouse mode
vim.o.mouse = 'a'
-- Sync clipboard between OS and Neovim.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
vim.o.clipboard = 'unnamedplus'
-- Enable break indent
vim.o.breakindent = true
-- Save undo history
vim.o.undofile = true
-- Case-insensitive searching UNLESS \C or capital in search
vim.o.ignorecase = true
vim.o.smartcase = true
-- Keep signcolumn on by default
vim.wo.signcolumn = 'yes'
-- Decrease update time
vim.o.updatetime = 250
vim.o.timeoutlen = 300
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
-- NOTE: You should make sure your terminal supports this
vim.o.termguicolors = true
-- [[ Basic Keymaps ]] -- [[ Basic Keymaps ]]
require("custom.keymaps")
-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
-- Remap for dealing with word wrap
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
-- [[ Highlight on yank ]] -- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()` -- See `:help vim.highlight.on_yank()`
@ -352,26 +269,6 @@ end
vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
-- See `:help telescope.builtin`
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to telescope to change theme, layout, etc.
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = '[/] Fuzzily search in current buffer' })
vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sG', ':LiveGrepGitRoot<cr>', { desc = '[S]earch by [G]rep on Git Root' })
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })
-- [[ Configure Treesitter ]] -- [[ Configure Treesitter ]]
-- See `:help nvim-treesitter` -- See `:help nvim-treesitter`
-- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' -- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}'

30
lazy-lock.json Normal file
View File

@ -0,0 +1,30 @@
{
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
"LuaSnip": { "branch": "master", "commit": "46c91e814732c1630b8a8b50d04acbf54b8320fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
"friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" },
"gitsigns.nvim": { "branch": "main", "commit": "af0f583cd35286dd6f0e3ed52622728703237e50" },
"indent-blankline.nvim": { "branch": "master", "commit": "29be0919b91fb59eca9e90690d76014233392bef" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "6eb8cae80f2e4322ec82cd9f8fa423f6d1eb02c3" },
"mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" },
"mini.cursorword": { "branch": "main", "commit": "066770d17218d783dc76abde80fde89967f94907" },
"neodev.nvim": { "branch": "main", "commit": "20f1e5d3c143333bdf5ea48729f7b50660135cb3" },
"nightfly": { "branch": "master", "commit": "06ad2689ebd251a71c6caeb9fb47e231773c9b47" },
"nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" },
"nvim-lspconfig": { "branch": "master", "commit": "b0852218bc5fa6514a71a9da6d5cfa63a263c83d" },
"nvim-treesitter": { "branch": "master", "commit": "075a64addc33390028ea124a1046a43497f05cd1" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "dbcd9388e3b119a87c785e10a00d62876077d23d" },
"nvim-web-devicons": { "branch": "master", "commit": "9ac70581e294c0aa0e6adf8b2106f932fe06e616" },
"oil.nvim": { "branch": "master", "commit": "3727410e4875ad8ba339c585859a9391d643b9ed" },
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
"telescope.nvim": { "branch": "0.1.x", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" },
"vim-fugitive": { "branch": "master", "commit": "46eaf8918b347906789df296143117774e827616" },
"vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" },
"vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
}

75
lua/custom/keymaps.lua Normal file
View File

@ -0,0 +1,75 @@
-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
local k = vim.keymap -- for conciseness
-- [[==== GENERAL KEYMAPS ====]]
-- [[ Search ]]
-- after search highlights everything and you hit enter
-- the highlights are "stuck". To clear them, use leader + nh ("no highlight")
k.set("n", "<leader>nh", ":nohl<CR>")
-- when deleting a single character, don't save that character to the register
k.set("n", "x", '"_x')
-- [[ Manage Splits ]]
k.set("n", "<leader>sv", "<C-w>v", { desc = "Split window Vertically" })
k.set("n", "<leader>sh", "<C-w>s", { desc = "Split window Horitonzally" })
k.set("n", "<leader>se", "<C-w>=", { desc = "Split Equally" })
k.set("n", "<leader>sx", ":close<CR>", { desc = "Split close" })
-- [[ Manage Tabs ]]
k.set("n", "<leader>to", ":tabnew<CR>", { desc = "Open new tab" })
k.set("n", "<leader>tx", ":tabclose<CR>", { desc = "Close current tab" })
k.set("n", "<leader>tn", ":tabn<CR>", { desc = "Go to next tab" })
k.set("n", "<leader>tp", ":tabp<CR>", { desc = "Go to previous tab" })
-- [[ Annoyances in Vim ]]
-- make space be a no-opt in visual and normal mode
k.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
-- Remap for dealing with word wrap
k.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
k.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
-- [[ Diagnostics ]]
k.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' })
k.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
k.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
k.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
-- [[==== PLUGIN KEYMAPS ====]]
-- vim-maximizer
-- keymap.set("n", "<leader>sm", ":MaximizerToggle<CR>")
-- [[ Configure Oil ]]
k.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
-- [[ Configure Telescope ]]
-- keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>") -- find files in current project
-- keymap.set("n", "<leader>fs", "<cmd>Telescope live_grep<cr>") -- find text in current project
-- keymap.set("n", "<leader>fc", "<cmd>Telescope grep_string<cr>") -- find current string cursor is on in current project
-- keymap.set("n", "<leader>fb", "<cmd>Telescope buffers<cr>") -- show active buffers
-- keymap.set("n", "<leader>fh", "<cmd>Telescope help_tags<cr>") -- show help tags
-- See `:help telescope.builtin`
k.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
k.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
k.set('n', '<leader>/', function()
-- You can pass additional configuration to telescope to change theme, layout, etc.
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = '[/] Fuzzily search in current buffer' })
k.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' })
k.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
k.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
k.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
k.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
k.set('n', '<leader>sG', ':LiveGrepGitRoot<cr>', { desc = '[S]earch by [G]rep on Git Root' })
k.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
k.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' })

54
lua/custom/options.lua Normal file
View File

@ -0,0 +1,54 @@
-- [[ Setting options ]]
-- See `:help vim.o`
-- NOTE: You can change these options as you wish!
local opt = vim.opt -- for conciseness
-- [[ LINE NUMBERS ]]
-- -- Make line numbers default
opt.number = true
opt.relativenumber = true
opt.cursorline = true
-- [[ LINE WRAPPING ]]
opt.wrap = false
-- [[ BACKSPACE ]]
opt.backspace = "indent,eol,start"
-- [[ MOUSE ]]
-- Enable mouse mode
opt.mouse = 'a'
-- [[ CLIPBOARD ]]
-- Sync clipboard between OS and Neovim.
opt.clipboard:append("unnamedplus")
-- [[ UNDO HISTORY ]]
-- Save undo history
opt.undofile = true
-- [[ SEARCH ]]
-- Case-insensitive searching UNLESS \C or capital in search
-- -- searching with lowercase 'hello' will highlight all cases: 'Hello', 'heLLo', 'hello'
opt.ignorecase = true
-- -- searching with uppercase 'Hello' will highlight only exact matches of 'Hello"
opt.smartcase = true
-- Decrease update time
opt.updatetime = 250
opt.timeoutlen = 300
-- [[ AUTO COMPLETE ]]
-- Set completeopt to have a better completion experience
opt.completeopt = 'menuone,noselect'
-- [[ APPEARANCE ]]
-- NOTE: NOT ALL TERMINALS SUPPORT THIS!
opt.termguicolors = true
opt.background = 'dark'
-- Keep signcolumn on by default
opt.signcolumn = 'yes'
-- Enable break indent
opt.breakindent = true