diff --git a/README.md b/README.md index c3c1144..32f58df 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ A starting point for Neovim that is: This repo is meant to be used as by **YOU** to begin your Neovim journey; remove the things you don't use and add what you miss. +Distribution Alternatives: +- [LazyVim](https://www.lazyvim.org/): A delightful distribution maintained by @folke (the author of lazy.nvim, the package manager used here) + ### Installation Kickstart.nvim targets *only* the latest ['stable'](https://github.com/neovim/neovim/releases/tag/stable) and latest ['nightly'](https://github.com/neovim/neovim/releases/tag/nightly) of Neovim. If you are experiencing issues, please make sure you have the latest versions. @@ -34,6 +37,7 @@ Additional system requirements: * Then there are two primary configuration options available: * Include the `lua/kickstart/plugins/*` files in your configuration. * Add new configuration in `lua/custom/plugins/*` files, which will be auto sourced using `lazy.nvim` + * NOTE: To enable this, you need to uncomment `{ import = 'custom.plugins' }` in your `init.lua` You can also merge updates/changes from the repo back into your fork, to keep up-to-date with any changes for the default configuration @@ -62,7 +66,7 @@ In the file: `lua/custom/plugins/filetree.lua`, add: ```lua return { "nvim-neo-tree/neo-tree.nvim", - branch = "v2.x", + version = "*", dependencies = { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended diff --git a/init.lua b/init.lua index 20a5e36..a3cf24b 100644 --- a/init.lua +++ b/init.lua @@ -4,8 +4,26 @@ ==================== 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 the help for the section for more information. +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 @@ -16,7 +34,6 @@ 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 @@ -65,12 +82,9 @@ require('lazy').setup({ 'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim', - { -- Useful status updates for LSP - 'j-hui/fidget.nvim', - config = function() - require('fidget').setup() - end, - }, + -- Useful status updates for LSP + -- NOTE: `opt = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', opts = {} }, -- Additional lua configuration, makes nvim stuff amazing! 'folke/neodev.nvim', @@ -82,81 +96,66 @@ require('lazy').setup({ dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, }, - { -- Useful plugin to show you pending keybinds. - 'folke/which-key.nvim', - config = function() - vim.o.timeout = true - vim.o.timeoutlen = 300 - require('which-key').setup {} - end, - }, - + -- Useful plugin to show you pending keybinds. + { 'folke/which-key.nvim', opt = {} }, { -- Adds git releated signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', - config = function() + opt = { -- See `:help gitsigns.txt` - require('gitsigns').setup { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - } - end, + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + }, }, { -- Theme inspired by Atom 'navarasu/onedark.nvim', + priority = 1000, config = function() vim.cmd.colorscheme 'onedark' end, }, - { -- Fancier statusline + { -- Set lualine as statusline 'nvim-lualine/lualine.nvim', - config = function() - -- Set lualine as statusline - -- See `:help lualine.txt` - require('lualine').setup { - options = { - icons_enabled = false, - theme = 'onedark', - component_separators = '|', - section_separators = '', - }, - } - end, + -- See `:help lualine.txt` + opt = { + options = { + icons_enabled = false, + theme = 'onedark', + component_separators = '|', + section_separators = '', + }, + }, }, { -- Add indentation guides even on blank lines 'lukas-reineke/indent-blankline.nvim', - config = function() - -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help indent_blankline.txt` - require('indent_blankline').setup { - char = '┊', - show_trailing_blankline_indent = false, - } - end, + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help indent_blankline.txt` + opt = { + char = '┊', + show_trailing_blankline_indent = false, + }, }, - { -- "gc" to comment visual regions/lines - 'numToStr/Comment.nvim', - config = function() - require('Comment').setup() - end, - }, + -- "gc" to comment visual regions/lines + { 'numToStr/Comment.nvim', opt = {} }, -- Fuzzy Finder (files, lsp, etc) - { 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim' } }, + { 'nvim-telescope/telescope.nvim', version = '*', dependencies = { 'nvim-lua/plenary.nvim' } }, -- Fuzzy Finder Algorithm which requires local dependencies to be built. -- Only load if `make` is available. Make sure you have the system -- requirements installed. { 'nvim-telescope/telescope-fzf-native.nvim', + -- NOTE: If you are having trouble with this installation, + -- refer to the README for telescope-fzf-native for more instructions. build = 'make', cond = function() return vim.fn.executable 'make' == 1 @@ -174,12 +173,19 @@ 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', - -- NOTE: Add your own custom plugins to `lua/custom/plugins/*.lua` - -- There are examples in the README.md for kickstar.nvim + -- 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 + -- up-to-date with whatever is in the kickstart repo. + -- -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins + -- + -- An additional note is that if you only copied in the `init.lua`, you can just comment this line + -- to get rid of the warning telling you that there are not plugins in `lua/custom/plugins/`. { import = 'custom.plugins' }, }, {}) @@ -205,9 +211,13 @@ vim.o.undofile = true 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.wo.signcolumn = 'yes' +vim.o.timeout = true +vim.o.timeoutlen = 300 -- Set completeopt to have a better completion experience vim.o.completeopt = 'menuone,noselect' diff --git a/lua/kickstart/plugins/autoformat.lua b/lua/kickstart/plugins/autoformat.lua index 855f350..bc56b15 100644 --- a/lua/kickstart/plugins/autoformat.lua +++ b/lua/kickstart/plugins/autoformat.lua @@ -5,7 +5,6 @@ return { 'neovim/nvim-lspconfig', - config = function() -- Switch for controlling whether you want autoformatting. -- Use :KickstartFormatToggle to toggle autoformatting on or off @@ -29,9 +28,11 @@ return { return _augroups[client.id] end + -- Whenever an LSP attaches to a buffer, we will run this function. + -- + -- See `:help LspAttach` for more information about this autocmd event. vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('kickstart-lsp-attach-format', { clear = true }), - -- This is where we attach the autoformatting for reasonable clients callback = function(args) local client_id = args.data.client_id @@ -49,6 +50,8 @@ return { return end + -- Create an autocmd that will run *before* we save the buffer. + -- Run the formatting command for the LSP that has just attached. vim.api.nvim_create_autocmd('BufWritePre', { group = get_augroup(client), buffer = bufnr, @@ -57,7 +60,12 @@ return { return end - vim.lsp.buf.format { async = false } + vim.lsp.buf.format { + async = false, + filter = function(c) + return c.id == client.id + end, + } end, }) end,