Skip to content

Commit 450b347

Browse files
committed
Update the explanations and docs
1 parent 4d5b90f commit 450b347

1 file changed

Lines changed: 42 additions & 38 deletions

File tree

init.lua

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ vim.g.maplocalleader = ' '
9797
vim.g.have_nerd_font = false
9898

9999
-- [[ Setting options ]]
100-
-- See `:help vim.o`
100+
-- See `:help vim.o`
101101
-- NOTE: You can change these options as you wish!
102102
-- For more options, you can see `:help option-list`
103103

@@ -233,18 +233,17 @@ vim.api.nvim_create_autocmd('TextYankPost', {
233233
callback = function() vim.hl.on_yank() end,
234234
})
235235

236-
-- [[ Configure and install plugins with `vim.pack` ]]
236+
-- [[ Install plugins with `vim.pack` ]]
237+
-- See `:help vim.pack`, `:help vim.pack-examples` or
238+
-- the excellent blog post from the creator of mini.nvim https://echasnovski.com/blog/2026-03-13-a-guide-to-vim-pack
237239
--
238240
-- To inspect plugin state and pending updates, run
239241
-- :lua vim.pack.update(nil, { offline = true })
240242
--
241243
-- To update plugins, run
242244
-- :lua vim.pack.update()
243-
--
244-
-- NOTE: Here is where you install your plugins.
245-
local gh = function(repo) return 'https://github.com/' .. repo end
246245

247-
local run_build = function(name, cmd, cwd)
246+
local function run_build(name, cmd, cwd)
248247
local result = vim.system(cmd, { cwd = cwd }):wait()
249248
if result.code ~= 0 then
250249
local stderr = result.stderr or ''
@@ -255,6 +254,8 @@ local run_build = function(name, cmd, cwd)
255254
end
256255
end
257256

257+
-- This autocommand runs after a plugin is installed or updated and runs the appropriate build command for that plugin if necessary.
258+
-- See `:help vim.pack-events`
258259
vim.api.nvim_create_autocmd('PackChanged', {
259260
callback = function(ev)
260261
local name = ev.data.spec.name
@@ -279,8 +280,11 @@ vim.api.nvim_create_autocmd('PackChanged', {
279280
end,
280281
})
281282

283+
local gh = function(repo) return 'https://github.com/' .. repo end
284+
282285
---@type (string|vim.pack.Spec)[]
283286
local plugins = {
287+
-- You can specify plugins using just a git URL. It will use the default branch (usually `main` or `master`)
284288
gh 'NMAC427/guess-indent.nvim',
285289
gh 'lewis6991/gitsigns.nvim',
286290
gh 'folke/which-key.nvim',
@@ -293,11 +297,14 @@ local plugins = {
293297
gh 'WhoIsSethDaniel/mason-tool-installer.nvim',
294298
gh 'j-hui/fidget.nvim',
295299
gh 'stevearc/conform.nvim',
300+
-- You can also specify plugin using a version range for its git tag.
301+
-- See `:help vim.version.range()` for more info
296302
{ src = gh 'saghen/blink.cmp', version = vim.version.range '1.*' },
297303
{ src = gh 'L3MON4D3/LuaSnip', version = vim.version.range '2.*' },
298304
gh 'folke/tokyonight.nvim',
299305
gh 'folke/todo-comments.nvim',
300306
gh 'nvim-mini/mini.nvim',
307+
-- It is also possible to specify a branch or a specific commit to checkout
301308
{ src = gh 'nvim-treesitter/nvim-treesitter', version = 'main' },
302309
}
303310

@@ -306,8 +313,14 @@ if vim.fn.executable 'make' == 1 then table.insert(plugins, gh 'nvim-telescope/t
306313
-- Useful for getting pretty icons, but requires a Nerd Font.
307314
if vim.g.have_nerd_font then table.insert(plugins, gh 'nvim-tree/nvim-web-devicons') end
308315

316+
-- NOTE: Here is where the plugins are actually installed.
309317
vim.pack.add(plugins)
310318

319+
-- [[ Configure plugins ]]
320+
-- For most plugins you need to call their `.setup()` to start them
321+
--
322+
-- For example, here is the simplest possible setup for `guess-indent.nvim`,
323+
-- which will automatically detect and set your indentation settings based on the current file.
311324
require('guess-indent').setup {}
312325

313326
-- Here is a more advanced example where we pass configuration
@@ -338,24 +351,16 @@ require('which-key').setup {
338351
{ 'gr', group = 'LSP Actions', mode = { 'n' } },
339352
},
340353
}
341-
-- Fuzzy Finder (files, lsp, etc)
342-
--
343-
-- By default, Telescope is included and acts as your picker for everything.
344-
345-
-- # TODO: Rework this docstring
346-
--
347-
-- If you would like to switch to a different picker (like snacks, or fzf-lua)
348-
-- you can disable the Telescope plugin by setting enabled to false and enable
349-
-- your replacement picker by requiring it explicitly (e.g. 'custom.plugins.snacks')
350354

351-
-- Note: If you customize your config for yourself,
352-
-- it’s best to remove the Telescope plugin config entirely
353-
-- instead of just disabling it here, to keep your config clean.
355+
-- [[ Fuzzy Finder (files, lsp, etc) ]]
354356
--
355357
-- Telescope is a fuzzy finder that comes with a lot of different things that
356358
-- it can fuzzy find! It's more than just a "file finder", it can search
357359
-- many different aspects of Neovim, your workspace, LSP, and more!
358360
--
361+
-- There are lots of other alternative pickers (like snacks.picker, or fzf-lua)
362+
-- so feel free to experiment and see what you like!
363+
--
359364
-- The easiest way to use Telescope, is to start by doing something like:
360365
-- :Telescope help_tags
361366
--
@@ -371,7 +376,6 @@ require('which-key').setup {
371376
-- Telescope picker. This is really useful to discover what Telescope can
372377
-- do as well as how to actually do it!
373378

374-
-- [[ Configure Telescope ]]
375379
-- See `:help telescope` and `:help telescope.setup()`
376380
require('telescope').setup {
377381
-- You can put your default mappings / updates / etc. in here
@@ -466,15 +470,7 @@ vim.keymap.set(
466470
-- Shortcut for searching your Neovim configuration files
467471
vim.keymap.set('n', '<leader>sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' })
468472

469-
-- LSP Plugins
470-
471-
-- Automatically install LSPs and related tools to stdpath for Neovim
472-
-- Mason must be loaded before its dependents so we need to set it up here.
473-
require('mason').setup {}
474-
475-
-- Useful status updates for LSP.
476-
require('fidget').setup {}
477-
473+
-- [[ LSP Configuration ]]
478474
-- Brief aside: **What is LSP?**
479475
--
480476
-- LSP is an initialism you've probably heard, but might not understand what it is.
@@ -500,6 +496,9 @@ require('fidget').setup {}
500496
-- If you're wondering about lsp vs treesitter, you can check out the wonderfully
501497
-- and elegantly composed help section, `:help lsp-vs-treesitter`
502498

499+
-- Useful status updates for LSP.
500+
require('fidget').setup {}
501+
503502
-- This function gets run when an LSP attaches to a particular buffer.
504503
-- That is to say, every time a new file is opened that is associated with
505504
-- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this
@@ -621,6 +620,9 @@ local servers = {
621620
},
622621
}
623622

623+
-- Automatically install LSPs and related tools to stdpath for Neovim
624+
require('mason').setup {}
625+
624626
-- Ensure the servers and tools above are installed
625627
--
626628
-- To check the current status of installed tools and/or manually install
@@ -640,7 +642,7 @@ for name, server in pairs(servers) do
640642
vim.lsp.enable(name)
641643
end
642644

643-
-- Autoformat
645+
-- [[ Formatting ]]
644646
require('conform').setup {
645647
notify_on_error = false,
646648
format_on_save = function(bufnr)
@@ -671,17 +673,19 @@ require('conform').setup {
671673

672674
vim.keymap.set({ 'n', 'v' }, '<leader>f', function() require('conform').format { async = true } end, { desc = '[F]ormat buffer' })
673675

676+
-- [[ Autocompletion Configuration ]]
677+
674678
-- Snippet Engine
675-
--
679+
require('luasnip').setup {}
680+
676681
-- `friendly-snippets` contains a variety of premade snippets.
677682
-- See the README about individual language/framework/plugin snippets:
678683
-- https://github.com/rafamadriz/friendly-snippets
679684
--
680685
-- vim.pack.add { gh 'rafamadriz/friendly-snippets' }
681686
-- require('luasnip.loaders.from_vscode').lazy_load()
682-
require('luasnip').setup {}
683687

684-
-- Autocompletion
688+
-- The autocomplete engine
685689
require('blink.cmp').setup {
686690
keymap = {
687691
-- 'default' (recommended) for mappings similar to built-in completions
@@ -742,9 +746,10 @@ require('blink.cmp').setup {
742746
signature = { enabled = true },
743747
}
744748

749+
-- [[ Colorscheme ]]
745750
-- You can easily change to a different colorscheme.
746751
-- Change the name of the colorscheme plugin below, and then
747-
-- change the command in the config to whatever the name of that colorscheme is.
752+
-- change the command under that to load whatever the name of that colorscheme is.
748753
--
749754
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
750755
---@diagnostic disable-next-line: missing-fields
@@ -802,9 +807,11 @@ statusline.section_location = function() return '%2l:%-2v' end
802807
-- ... and there is more!
803808
-- Check out: https://github.com/nvim-mini/mini.nvim
804809

805-
-- Highlight, edit, and navigate code
810+
-- [[ Configure Treesitter ]]
811+
-- Used ighlight, edit, and navigate code
812+
--
813+
-- See `:help nvim-treesitter-intro`
806814

807-
-- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro`
808815
-- ensure basic parser are installed
809816
local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }
810817
require('nvim-treesitter').install(parsers)
@@ -873,9 +880,6 @@ vim.api.nvim_create_autocmd('FileType', {
873880
--
874881
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
875882
-- require 'custom.plugins'
876-
--
877-
-- For additional information with loading, sourcing and examples see `:help vim.pack`
878-
-- and `:help vim.pack-examples`
879883

880884
-- The line beneath this is called `modeline`. See `:help modeline`
881885
-- vim: ts=2 sts=2 sw=2 et

0 commit comments

Comments
 (0)