From 2c3654c950d609988d341ac96c3bba1898aa310a Mon Sep 17 00:00:00 2001 From: cfsanderson-fulcrum Date: Tue, 4 Apr 2023 23:37:31 -0400 Subject: [PATCH] refactors init.lua - moves options to custom/options.lua and adds my options --- init.lua | 135 +++++++++++------------------------------ lua/custom/options.lua | 56 +++++++++++++++++ 2 files changed, 91 insertions(+), 100 deletions(-) create mode 100644 lua/custom/options.lua diff --git a/init.lua b/init.lua index 72890326..9ba23ca7 100644 --- a/init.lua +++ b/init.lua @@ -1,48 +1,14 @@ ---[[ - -===================================================================== -==================== 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, and understand - what your configuration is doing. - - 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` - - -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) +------------------------------------------------------ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' +require 'custom.options' + +------------------------------------------------------ -- Install package manager +------------------------------------------------------ -- https://github.com/folke/lazy.nvim -- `:help lazy.nvim.txt` for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' @@ -58,11 +24,14 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) +------------------------------------------------------ -- NOTE: Here is where you install your plugins. -- You can configure plugins using the `config` key. -- -- You can also configure plugins after the setup call, -- as they will be available in your neovim runtime. +------------------------------------------------------ + require('lazy').setup({ -- NOTE: First, some plugins that don't require any configuration @@ -73,9 +42,10 @@ require('lazy').setup({ -- Detect tabstop and shiftwidth automatically 'tpope/vim-sleuth', - -- NOTE: This is where your plugins related to LSP can be installed. - -- The configuration is done below. Search for lspconfig to find it below. - { -- LSP Configuration & Plugins + -- NOTE: plugins related to LSP + -- The configuration is done below. Search for lspconfig to find it below. + { + -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs to stdpath for neovim @@ -91,14 +61,16 @@ require('lazy').setup({ }, }, - { -- Autocompletion + { + -- Autocompletion 'hrsh7th/nvim-cmp', dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, }, -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, - { -- Adds git releated signs to the gutter, as well as utilities for managing changes + { 'folke/which-key.nvim', opts = {} }, + { + -- Adds git releated signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', opts = { -- See `:help gitsigns.txt` @@ -112,28 +84,29 @@ require('lazy').setup({ }, }, - { -- Theme inspired by Atom - 'navarasu/onedark.nvim', + { + -- Theme + 'sainnhe/gruvbox-material', priority = 1000, config = function() - vim.cmd.colorscheme 'onedark' + vim.cmd.colorscheme 'gruvbox-material' end, }, - - { -- Set lualine as statusline + { 'nvim-lualine/lualine.nvim', -- See `:help lualine.txt` opts = { options = { icons_enabled = false, - theme = 'onedark', + theme = 'gruvbox-material', component_separators = '|', section_separators = '', }, }, }, - { -- Add indentation guides even on blank lines + { + -- Add indentation guides even on blank lines 'lukas-reineke/indent-blankline.nvim', -- Enable `lukas-reineke/indent-blankline.nvim` -- See `:help indent_blankline.txt` @@ -144,7 +117,7 @@ require('lazy').setup({ }, -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, + { 'numToStr/Comment.nvim', opts = {} }, -- Fuzzy Finder (files, lsp, etc) { 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } }, @@ -162,7 +135,8 @@ require('lazy').setup({ end, }, - { -- Highlight, edit, and navigate code + { + -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', dependencies = { 'nvim-treesitter/nvim-treesitter-textobjects', @@ -173,10 +147,8 @@ require('lazy').setup({ }, -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart - -- These are some example plugins that I've included in the kickstart repository. - -- Uncomment any of the lines below to enable them. - -- require 'kickstart.plugins.autoformat', - -- require 'kickstart.plugins.debug', + require 'kickstart.plugins.autoformat', + require 'kickstart.plugins.debug', -- NOTE: The import below automatically adds your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping @@ -189,48 +161,9 @@ require('lazy').setup({ { import = 'custom.plugins' }, }, {}) --- [[ Setting options ]] --- See `:help vim.o` - --- 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.timeout = true -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 ]] +------------------------------------------------------ -- Keymaps for better default experience -- See `:help vim.keymap.set()` @@ -284,7 +217,9 @@ vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { de vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +------------------------------------------------------ -- [[ Configure Treesitter ]] +------------------------------------------------------ -- See `:help nvim-treesitter` require('nvim-treesitter.configs').setup { -- Add languages to be installed here that you want installed for treesitter diff --git a/lua/custom/options.lua b/lua/custom/options.lua new file mode 100644 index 00000000..8dfe7ea9 --- /dev/null +++ b/lua/custom/options.lua @@ -0,0 +1,56 @@ +print("hello from options.lua") +-- [[ Setting options ]] +-- See `:help vim.o` +-- See also https://vimdoc.sourceforge.net/htmldoc/options.html#'incsearch' + +-- options +vim.o.hlsearch = false +vim.o.mouse = 'a' +vim.o.clipboard = 'unnamedplus' +vim.o.breakindent = true +vim.o.undofile = true +vim.o.ignorecase = true +vim.o.smartcase = true +vim.o.updatetime = 250 +vim.o.timeout = true +vim.o.timeoutlen = 300 +vim.o.completeopt = 'menuone,noselect' +vim.o.termguicolors = true + +-- window-local options +vim.wo.conceallevel = 0 +vim.wo.cursorline = false +vim.wo.number = true +vim.wo.numberwidth = 4 +vim.wo.relativenumber = true +vim.wo.signcolumn = 'yes' +vim.wo.wrap = false + +-- buffer-local options +vim.bo.autoindent = true +vim.bo.expandtab = true +vim.bo.fileencoding = "utf-8" +vim.bo.shiftwidth = 4 +vim.bo.smartindent = true +vim.bo.softtabstop = 2 +vim.bo.swapfile = false +vim.bo.syntax = "ON" +vim.bo.tabstop = 8 + +-- global options +vim.g.background = 'dark' +vim.g.backup = true +vim.g.belloff = "all" +vim.g.cmdheight = 2 -- more space in the neovim command line for displaying messages +vim.g.compatible = false +vim.g.errorbells = false +vim.g.guifont = "monospace:h17" +vim.g.incsearch = true +vim.g.pumheight = 10 +vim.g.scrolloff = 5 +vim.g.showtabline = 2 +vim.g.sidescrolloff = 5 +vim.g.splitbelow = true +vim.g.splitright = true +vim.g.undodir = '~/.vim/undodir' +vim.g.writebackup = false