diff --git a/init.lua b/init.lua index 8d1f19a..80a1488 100644 --- a/init.lua +++ b/init.lua @@ -94,7 +94,7 @@ vim.g.maplocalleader = ' ' vim.g.have_nerd_font = false -- [[ Setting options ]] --- See `:help vim.o` +-- See `:help vim.o` -- NOTE: You can change these options as you wish! -- For more options, you can see `:help option-list` @@ -172,7 +172,7 @@ vim.o.confirm = true vim.keymap.set('n', '', 'nohlsearch') -- Diagnostic Config & Keymaps --- See :help vim.diagnostic.Opts +-- See `:help vim.diagnostic.Opts` vim.diagnostic.config { update_in_insert = false, severity_sort = true, @@ -272,8 +272,9 @@ require('lazy').setup({ -- Here is a more advanced example where we pass configuration -- options to `gitsigns.nvim`. -- - -- See `:help gitsigns` to understand what the configuration keys do - { -- Adds git related signs to the gutter, as well as utilities for managing changes + -- See `:help gitsigns` to understand what each configuration keys does. + -- Adds git related signs to the gutter, as well as utilities for managing changes + { 'lewis6991/gitsigns.nvim', ---@module 'gitsigns' ---@type Gitsigns.Config @@ -302,15 +303,16 @@ require('lazy').setup({ -- -- Then, because we use the `opts` key (recommended), the configuration runs -- after the plugin has been loaded as `require(MODULE).setup(opts)`. - - { -- Useful plugin to show you pending keybinds. + -- + -- Useful plugin to show you pending keybinds. + { 'folke/which-key.nvim', event = 'VimEnter', ---@module 'which-key' ---@type wk.Opts ---@diagnostic disable-next-line: missing-fields opts = { - -- delay between pressing a key and opening which-key (milliseconds) + -- Delay between pressing a key and opening which-key (milliseconds) delay = 0, icons = { mappings = vim.g.have_nerd_font }, @@ -330,8 +332,9 @@ require('lazy').setup({ -- you do for a plugin at the top level, you can do for a dependency. -- -- Use the `dependencies` key to specify the dependencies of a particular plugin - - { -- Fuzzy Finder (files, lsp, etc) + -- + -- Fuzzy Finder (files, lsp, etc) + { 'nvim-telescope/telescope.nvim', -- By default, Telescope is included and acts as your picker for everything. @@ -346,7 +349,8 @@ require('lazy').setup({ event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim', - { -- If encountering errors, see telescope-fzf-native README for installation instructions + -- If encountering errors, see telescope-fzf-native README for installation instructions + { 'nvim-telescope/telescope-fzf-native.nvim', -- `build` is used to run some command when the plugin is installed/updated. @@ -417,8 +421,8 @@ require('lazy').setup({ vim.keymap.set('n', 'sc', builtin.commands, { desc = '[S]earch [C]ommands' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - -- This runs on LSP attach per buffer (see main LSP attach function in 'neovim/nvim-lspconfig' config for more info, - -- it is better explained there). This allows easily switching between pickers if you prefer using something else! + -- Add Telescope-based LSP pickers when an LSP attaches to a buffer. + -- If you later switch picker plugins, this is where to update these mappings. vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('telescope-lsp-attach', { clear = true }), callback = function(event) @@ -669,7 +673,8 @@ require('lazy').setup({ end, }, - { -- Autoformat + -- Autoformat + { 'stevearc/conform.nvim', event = { 'BufWritePre' }, cmd = { 'ConformInfo' }, @@ -712,7 +717,8 @@ require('lazy').setup({ }, }, - { -- Autocompletion + -- Autocompletion + { 'saghen/blink.cmp', event = 'VimEnter', version = '1.*', @@ -766,7 +772,7 @@ require('lazy').setup({ -- : Hide menu -- : Toggle signature help -- - -- See :h blink-cmp-config-keymap for defining your own keymap + -- See `:help blink-cmp-config-keymap` for defining your own keymap preset = 'default', -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: @@ -797,7 +803,7 @@ require('lazy').setup({ -- By default, we use the Lua implementation instead, but you may enable -- the rust implementation via `'prefer_rust_with_warning'` -- - -- See :h blink-cmp-config-fuzzy for more information + -- See `:help blink-cmp-config-fuzzy` for more information fuzzy = { implementation = 'lua' }, -- Shows a signature help window while you type arguments for a function @@ -805,7 +811,8 @@ require('lazy').setup({ }, }, - { -- You can easily change to a different colorscheme. + { + -- You can easily change to a different colorscheme. -- Change the name of the colorscheme plugin below, and then -- change the command in the config to whatever the name of that colorscheme is. -- @@ -838,7 +845,8 @@ require('lazy').setup({ opts = { signs = false }, }, - { -- Collection of various small independent plugins/modules + -- Collection of various small independent plugins/modules + { 'nvim-mini/mini.nvim', config = function() -- Better Around/Inside textobjects @@ -867,7 +875,7 @@ require('lazy').setup({ -- You could remove this setup call if you don't like it, -- and try some other statusline plugin local statusline = require 'mini.statusline' - -- set use_icons to true if you have a Nerd Font + -- Set `use_icons` to true if you have a Nerd Font statusline.setup { use_icons = vim.g.have_nerd_font } -- You can configure sections in the statusline by overriding their @@ -881,35 +889,36 @@ require('lazy').setup({ end, }, - { -- Highlight, edit, and navigate code + -- Used to highlight, edit, and navigate code + { 'nvim-treesitter/nvim-treesitter', lazy = false, build = ':TSUpdate', branch = 'main', -- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro` config = function() - -- ensure basic parser are installed + -- Ensure basic parsers are installed local parsers = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' } require('nvim-treesitter').install(parsers) ---@param buf integer ---@param language string local function treesitter_try_attach(buf, language) - -- check if parser exists and load it + -- Check if a parser exists and load it if not vim.treesitter.language.add(language) then return end - -- enables syntax highlighting and other treesitter features + -- Enable syntax highlighting and other treesitter features vim.treesitter.start(buf, language) - -- enables treesitter based folds - -- for more info on folds see `:help folds` + -- Enable treesitter based folds + -- For more info on folds see `:help folds` -- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' -- vim.wo.foldmethod = 'expr' - -- check if treesitter indentation is available for this language, and if so enable it + -- Check if treesitter indentation is available for this language, and if so enable it -- in case there is no indent query, the indentexpr will fallback to the vim's built in one local has_indent_query = vim.treesitter.query.get(language, 'indents') ~= nil - -- enables treesitter based indentation + -- Enable treesitter based indentation if has_indent_query then vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" end end @@ -924,13 +933,13 @@ require('lazy').setup({ local installed_parsers = require('nvim-treesitter').get_installed 'parsers' if vim.tbl_contains(installed_parsers, language) then - -- enable the parser if it is installed + -- Enable the parser if it is already installed treesitter_try_attach(buf, language) elseif vim.tbl_contains(available_parsers, language) then - -- if a parser is available in `nvim-treesitter` auto install it, and enable it after the installation is done + -- If a parser is available in `nvim-treesitter`, auto-install it and enable it after the installation is done require('nvim-treesitter').install(language):await(function() treesitter_try_attach(buf, language) end) else - -- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter` + -- Try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter` treesitter_try_attach(buf, language) end end,