From 4ee307520fad7da1ae2f8067fe639abd39ab3156 Mon Sep 17 00:00:00 2001 From: Michael Mroczka Date: Sat, 11 Nov 2023 18:50:11 -0600 Subject: [PATCH] initial neovim customizations --- init.lua | 141 ++++++----------------------------------- lazy-lock.json | 30 +++++++++ lua/custom/keymaps.lua | 75 ++++++++++++++++++++++ lua/custom/options.lua | 54 ++++++++++++++++ 4 files changed, 178 insertions(+), 122 deletions(-) create mode 100644 lazy-lock.json create mode 100644 lua/custom/keymaps.lua create mode 100644 lua/custom/options.lua diff --git a/init.lua b/init.lua index 748e7f81..6fb0a408 100644 --- a/init.lua +++ b/init.lua @@ -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 as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) @@ -45,8 +5,6 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- [[ 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' if not vim.loop.fs_stat(lazypath) then vim.fn.system { @@ -152,15 +110,22 @@ require('lazy').setup({ }, }, - { - -- Theme inspired by Atom - 'navarasu/onedark.nvim', + { + "bluz71/vim-nightfly-colors", + name = "nightfly", + lazy = false, priority = 1000, config = function() - vim.cmd.colorscheme 'onedark' + vim.cmd.colorscheme 'nightfly' 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 'nvim-lualine/lualine.nvim', @@ -168,9 +133,9 @@ require('lazy').setup({ opts = { options = { icons_enabled = false, - theme = 'onedark', + theme = 'nightfly', component_separators = '|', - section_separators = '', + section_separators = ' ', }, }, }, @@ -183,6 +148,8 @@ require('lazy').setup({ main = 'ibl', opts = {}, }, + -- underline the word your cursor is on + { 'echasnovski/mini.cursorword', version = '*', opts = {} }, -- "gc" to comment visual regions/lines { 'numToStr/Comment.nvim', opts = {} }, @@ -232,62 +199,12 @@ require('lazy').setup({ -- { import = 'custom.plugins' }, }, {}) --- [[ Setting options ]] --- See `:help vim.o` --- 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 Vim Options ]] +require("custom.options") -- [[ Basic Keymaps ]] +require("custom.keymaps") --- Keymaps for better default experience --- See `:help vim.keymap.set()` -vim.keymap.set({ 'n', 'v' }, '', '', { 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', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) -- [[ 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, {}) --- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) -vim.keymap.set('n', '/', 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', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sG', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) -vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) - -- [[ Configure Treesitter ]] -- See `:help nvim-treesitter` -- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000..759692ba --- /dev/null +++ b/lazy-lock.json @@ -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" } +} \ No newline at end of file diff --git a/lua/custom/keymaps.lua b/lua/custom/keymaps.lua new file mode 100644 index 00000000..f3f32d87 --- /dev/null +++ b/lua/custom/keymaps.lua @@ -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", "nh", ":nohl") + +-- when deleting a single character, don't save that character to the register +k.set("n", "x", '"_x') + +-- [[ Manage Splits ]] +k.set("n", "sv", "v", { desc = "Split window Vertically" }) +k.set("n", "sh", "s", { desc = "Split window Horitonzally" }) +k.set("n", "se", "=", { desc = "Split Equally" }) +k.set("n", "sx", ":close", { desc = "Split close" }) + +-- [[ Manage Tabs ]] +k.set("n", "to", ":tabnew", { desc = "Open new tab" }) +k.set("n", "tx", ":tabclose", { desc = "Close current tab" }) +k.set("n", "tn", ":tabn", { desc = "Go to next tab" }) +k.set("n", "tp", ":tabp", { desc = "Go to previous tab" }) + +-- [[ Annoyances in Vim ]] +-- make space be a no-opt in visual and normal mode +k.set({ 'n', 'v' }, '', '', { 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', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +k.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) + + +-- [[==== PLUGIN KEYMAPS ====]] + +-- vim-maximizer +-- keymap.set("n", "sm", ":MaximizerToggle") + +-- [[ Configure Oil ]] +k.set("n", "-", "Oil", { desc = "Open parent directory" }) + +-- [[ Configure Telescope ]] +-- keymap.set("n", "ff", "Telescope find_files") -- find files in current project +-- keymap.set("n", "fs", "Telescope live_grep") -- find text in current project +-- keymap.set("n", "fc", "Telescope grep_string") -- find current string cursor is on in current project +-- keymap.set("n", "fb", "Telescope buffers") -- show active buffers +-- keymap.set("n", "fh", "Telescope help_tags") -- show help tags + +-- See `:help telescope.builtin` +k.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) +k.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +k.set('n', '/', 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', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) +k.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) +k.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) +k.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) +k.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) +k.set('n', 'sG', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) +k.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +k.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) + diff --git a/lua/custom/options.lua b/lua/custom/options.lua new file mode 100644 index 00000000..60fbd89e --- /dev/null +++ b/lua/custom/options.lua @@ -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 +