diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 2ad4d31d..86598b8d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -9,6 +9,13 @@ assignees: '' +## Before Reporting an Issue +- I have read the kickstart.nvim README.md. +- I have read the appropriate plugin's documentation. +- I have searched that this issue has not been reported before. + +- [ ] **By checking this, I confirm that the above steps are completed. I understand leaving this unchecked will result in this report being closed immediately.** + ## Describe the bug @@ -18,8 +25,8 @@ assignees: '' ## Desktop -- OS: -- Terminal: +- OS: +- Terminal: ## Neovim Version diff --git a/README.md b/README.md index dd51f209..8ace8b9b 100644 --- a/README.md +++ b/README.md @@ -24,20 +24,22 @@ If you are experiencing issues, please make sure you have the latest versions. External Requirements: - Basic utils: `git`, `make`, `unzip`, C Compiler (`gcc`) - [ripgrep](https://github.com/BurntSushi/ripgrep#installation) +- Clipboard tool (xclip/xsel/win32yank or other depending on the platform) - A [Nerd Font](https://www.nerdfonts.com/): optional, provides various icons - if you have it set `vim.g.have_nerd_font` in `init.lua` to true +- Emoji fonts (Ubuntu only, and only if you want emoji!) `sudo apt install fonts-noto-color-emoji` - Language Setup: - - If want to write Typescript, you need `npm` - - If want to write Golang, you will need `go` + - If you want to write Typescript, you need `npm` + - If you want to write Golang, you will need `go` - etc. -> **NOTE** +> [!NOTE] > See [Install Recipes](#Install-Recipes) for additional Windows and Linux specific notes > and quick install snippets ### Install Kickstart -> **NOTE** +> [!NOTE] > [Backup](#FAQ) your previous configuration (if any exists) Neovim's configurations are located under the following paths, depending on your OS: @@ -45,8 +47,8 @@ Neovim's configurations are located under the following paths, depending on your | OS | PATH | | :- | :--- | | Linux, MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | -| Windows (cmd)| `%userprofile%\AppData\Local\nvim\` | -| Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` | +| Windows (cmd)| `%localappdata%\nvim\` | +| Windows (powershell)| `$env:LOCALAPPDATA\nvim\` | #### Recommended Step @@ -54,12 +56,17 @@ Neovim's configurations are located under the following paths, depending on your so that you have your own copy that you can modify, then install by cloning the fork to your machine using one of the commands below, depending on your OS. -> **NOTE** -> Your fork's url will be something like this: +> [!NOTE] +> Your fork's URL will be something like this: > `https://github.com//kickstart.nvim.git` +You likely want to remove `lazy-lock.json` from your fork's `.gitignore` file +too - it's ignored in the kickstart repo to make maintenance easier, but it's +[recommended to track it in version control](https://lazy.folke.io/usage/lockfile). + #### Clone kickstart.nvim -> **NOTE** + +> [!NOTE] > If following the recommended step above (i.e., forking the repo), replace > `nvim-lua` with `` in the commands below @@ -76,13 +83,13 @@ git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HO If you're using `cmd.exe`: ``` -git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ +git clone https://github.com/nvim-lua/kickstart.nvim.git "%localappdata%\nvim" ``` If you're using `powershell.exe` ``` -git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ +git clone https://github.com/nvim-lua/kickstart.nvim.git "${env:LOCALAPPDATA}\nvim" ``` @@ -96,12 +103,17 @@ nvim ``` That's it! Lazy will install all the plugins you have. Use `:Lazy` to view -current plugin status. Hit `q` to close the window. +the current plugin status. Hit `q` to close the window. + +#### Read The Friendly Documentation Read through the `init.lua` file in your configuration folder for more -information about extending and exploring Neovim. That includes also +information about extending and exploring Neovim. That also includes examples of adding popularly requested plugins. +> [!NOTE] +> For more information about a particular plugin check its repository's documentation. + ### Getting Started @@ -109,9 +121,9 @@ examples of adding popularly requested plugins. ### FAQ -* What should I do if I already have a pre-existing neovim configuration? +* What should I do if I already have a pre-existing Neovim configuration? * You should back it up and then delete all associated files. - * This includes your existing init.lua and the neovim files in `~/.local` + * This includes your existing init.lua and the Neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/` * Can I keep my existing configuration in parallel to kickstart? * Yes! You can use [NVIM_APPNAME](https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME)`=nvim-NAME` @@ -125,12 +137,12 @@ examples of adding popularly requested plugins. `~/.local/share/nvim-kickstart`. You can apply this approach to any Neovim distribution that you would like to try out. * What if I want to "uninstall" this configuration: - * See [lazy.nvim uninstall](https://github.com/folke/lazy.nvim#-uninstalling) information + * See [lazy.nvim uninstall](https://lazy.folke.io/usage#-uninstalling) information * Why is the kickstart `init.lua` a single file? Wouldn't it make sense to split it into multiple files? * The main purpose of kickstart is to serve as a teaching tool and a reference configuration that someone can easily use to `git clone` as a basis for their own. As you progress in learning Neovim and Lua, you might consider splitting `init.lua` - into smaller parts. A fork of kickstart that does this while maintaining the + into smaller parts. A fork of kickstart that does this while maintaining the same functionality is available here: * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) * Discussions on this topic can be found here: @@ -169,7 +181,7 @@ run in cmd as **admin**: winget install --accept-source-agreements chocolatey.chocolatey ``` -2. install all requirements using choco, exit previous cmd and +2. install all requirements using choco, exit the previous cmd and open a new one so that choco path is set, and run in cmd as **admin**: ``` choco install -y neovim git ripgrep wget fd unzip gzip mingw make @@ -182,7 +194,7 @@ wsl --install wsl sudo add-apt-repository ppa:neovim-ppa/unstable -y sudo apt update -sudo apt install make gcc ripgrep unzip neovim +sudo apt install make gcc ripgrep unzip git xclip neovim ``` @@ -192,24 +204,24 @@ sudo apt install make gcc ripgrep unzip neovim ``` sudo add-apt-repository ppa:neovim-ppa/unstable -y sudo apt update -sudo apt install make gcc ripgrep unzip git neovim +sudo apt install make gcc ripgrep unzip git xclip neovim ```
Debian Install Steps ``` sudo apt update -sudo apt install make gcc ripgrep unzip git curl +sudo apt install make gcc ripgrep unzip git xclip curl # Now we install nvim -curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz -sudo rm -rf /opt/nvim-linux64 -sudo mkdir -p /opt/nvim-linux64 -sudo chmod a+rX /opt/nvim-linux64 -sudo tar -C /opt -xzf nvim-linux64.tar.gz +curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz +sudo rm -rf /opt/nvim-linux-x86_64 +sudo mkdir -p /opt/nvim-linux-x86_64 +sudo chmod a+rX /opt/nvim-linux-x86_64 +sudo tar -C /opt -xzf nvim-linux-x86_64.tar.gz # make it available in /usr/local/bin, distro installs to /usr/bin -sudo ln -sf /opt/nvim-linux64/bin/nvim /usr/local/bin/ +sudo ln -sf /opt/nvim-linux-x86_64/bin/nvim /usr/local/bin/ ```
Fedora Install Steps diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 558a0e44..b281c815 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -1,12 +1,13 @@ -- [[ Basic Keymaps ]] --- See `:help vim.keymap.set()` +-- NOTE: See `:help vim.keymap.set()` -- vim.keymap.set( required, required, required, not required) + -- Set highlight on search, but clear on pressing in normal mode vim.keymap.set('n', '', 'nohlsearch', { desc = 'Remove higlight after search is done' }) -- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' }) +vim.keymap.set('n', '[d', function() vim.diagnostic.goto({ direction = 'prev', float = false }) end, { desc = 'Go to previous [D]iagnostic message' }) +vim.keymap.set('n', ']d', function() vim.diagnostic.goto({ direction = 'next', float = false }) end, { desc = 'Go to next [D]iagnostic message' }) vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' }) vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) @@ -21,21 +22,20 @@ vim.keymap.set('n', 'pv', vim.cmd.Ex, { desc = 'Open netrw' }) -- open n vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) -- Keybinds to make split navigation easier. --- Use CTRL+ to switch between windows +-- NOTE: Use CTRL+ to switch between windows -- See `:help wincmd` for a list of all window commands vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) --- TODO add more comments, do some improvements on those. -- copy pasting -vim.keymap.set('n', 'Y', 'y$', { desc = 'Yank till the end of the line' }) -- yanks till the end of the line, like C for change or D for delete +vim.keymap.set('n', 'Y', 'y$', { desc = 'Yank till the end of the line' }) vim.keymap.set('n', 'J', 'mzJ`z', { desc = 'Marks the point (mz), joins the lines (J) and gets back to the marked place (`z)' }) vim.keymap.set({ 'n', 'v' }, 'y', '"+y', { desc = 'Prefix y with leader to send to system clipboard' }) -vim.keymap.set({ 'n', 'v' }, 'Y', '"+Y', { desc = 'Prefix y with leader to send to system clipboard' }) -vim.keymap.set('x', 'p', '"+p', { desc = 'Deletes to void registry to avoid changing registry content' }) -vim.keymap.set('x', 'P', '"_dP', { desc = 'Deletes to void registry to avoid changing registry content' }) +vim.keymap.set({ 'n', 'v' }, 'Y', '"+Y', { desc = 'Prefix Y with leader to send to system clipboard' }) +vim.keymap.set('x', 'p', '"+p', { desc = 'Paste from clipboard over the selection, without chaging the clipboard registry("+).' }) +vim.keymap.set('x', 'P', '"_dP', { desc = 'Deletes to void registry("_) to avoid changing registry("0) content, and then pastes from clipboard' }) -- Search remaps vim.keymap.set('n', 'n', 'nzzzv', { desc = 'n = next search, zz = center cursor on screen, zv = open fold if exist' }) @@ -66,20 +66,23 @@ vim.keymap.set('n', '', '', { desc = 'Close window with ctrl+c' } vim.keymap.set({ 'i', 'v', 'n', 's' }, '', 'w', { desc = 'Save file' }) -- Function and remap to toggle relative numbers. -vim.keymap.set('n', 'nr', function() - vim.opt.nu = false - vim.opt.relativenumber = false -end, { desc = 'Disable number and relative number' }) -vim.keymap.set('n', 'rn', function() - vim.opt.nu = true - vim.opt.relativenumber = true -end, { desc = 'Enable number and relative number' }) +vim.keymap.set('n', 'nr', function() vim.opt.nu = false vim.opt.relativenumber = false end, { desc = 'Disable number and relative number' }) +vim.keymap.set('n', 'rn', function() vim.opt.nu = true vim.opt.relativenumber = true end, { desc = 'Enable number and relative number' }) -- Clean up vim.keymap.set('n', 'dw', ':%s/\\s\\+$//e', { desc = 'Clean trailing whitespace in the document' }) vim.keymap.set('n', 'dn', ':%s/\\n\\+\\%$//e', { desc = 'Clean trailing newlines in the document' }) vim.keymap.set('n', 'ds', ':%s/\\^\\[\\+\\%$//e', { desc = 'Clean trailing escape sequences in the document' }) +-- Code runner keymaps +vim.keymap.set('n', 'rr', ':RunCode', { noremap = true, silent = false }) +vim.keymap.set('n', 'rf', ':RunFile', { noremap = true, silent = false }) +vim.keymap.set('n', 'rft', ':RunFile tab', { noremap = true, silent = false }) +vim.keymap.set('n', 'rp', ':RunProject', { noremap = true, silent = false }) +vim.keymap.set('n', 'rc', ':RunClose', { noremap = true, silent = false }) +vim.keymap.set('n', 'crf', ':CRFiletype', { noremap = true, silent = false }) +vim.keymap.set('n', 'crp', ':CRProjects', { noremap = true, silent = false }) + -- Testing remaps and functions -- better indenting diff --git a/lua/lazy-config.lua b/lua/lazy-config.lua index 932cdbca..6d5d7ec5 100644 --- a/lua/lazy-config.lua +++ b/lua/lazy-config.lua @@ -14,49 +14,20 @@ require('lazy').setup({ 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically 'numToStr/Comment.nvim', -- "gc" to comment visual regions/lines 'github/copilot.vim', -- Copilot - - -- One liners - -- Highlight todo, notes, etc in comments - { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, - -- { 'CRAG666/code_runner.nvim', config = true }, -- Execute code within nvim. - - -- Plugins with custom values - require 'plugins_config/which-key', -- Show created key bindings - require 'plugins_config/gitsigns', -- Manage git signs, blame - require 'plugins_config/vim-fugitive', -- Manage git in nvim - require 'plugins_config/telescope', -- Manage searches nicely - require 'plugins_config/worktree', -- Manage worktrees from nvim - require 'plugins_config/lsp', -- Multilanguage lsp config - require 'plugins_config/conform', -- Autoformat files using lsp on save - require 'plugins_config/autocomplete', -- Autocompletion - require 'plugins_config/colortheme', -- Color theme for the editor - require 'plugins_config/mini', -- Collections of useful mini plugins, like around/surround - require 'plugins_config/tree-sitter', -- manage lint, indentation and some othe language related tasks - require 'plugins_config/harpoon', -- Improve workflow for multiple files - require 'plugins_config/code_runner', -- Code runner - -- require 'plugins_config/copilot', -- copilot config - - -- Broken configs/Testing config - -- keeping comments for annotation -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following -- keys can be used to configure plugin behavior/loading/etc. - -- - -- Use `opts = {}` to force a plugin to be loaded. - -- - -- This is equivalent to: - -- require('Comment').setup({}) - - -- "gc" to comment visual regions/lines - -- { 'numToStr/Comment.nvim', opts = {} }, -- optional notation - - -- Here is a more advanced example where we pass configuration - -- options to `gitsigns.nvim`. This is equivalent to the following Lua: - -- require('gitsigns').setup({ ... }) - -- - -- See `:help gitsigns` to understand what the configuration keys do - + -- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded. + -- Alternatively, use `config = function() ... end` for full control over the configuration. + -- If you prefer to call `setup` explicitly, use: + -- { + -- 'lewis6991/gitsigns.nvim', + -- config = function() + -- require('gitsigns').setup({ + -- -- Your gitsigns configuration here + -- }) + -- end, -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- -- This is often very useful to both group configuration, as well as handle @@ -89,6 +60,46 @@ require('lazy').setup({ -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` -- { import = 'custom.plugins' }, + -- } + + -- One liners + -- Highlight todo, notes, etc in comments + { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, + + -- Plugins with custom values + require 'plugins_config/which-key', -- Show created key bindings + require 'plugins_config/gitsigns', -- Manage git signs, blame + require 'plugins_config/vim-fugitive', -- Manage git in nvim + require 'plugins_config/telescope', -- Manage searches nicely + require 'plugins_config/worktree', -- Manage worktrees from nvim + require 'plugins_config/lsp', -- Multilanguage lsp config + require 'plugins_config/conform', -- Autoformat files using lsp on save + require 'plugins_config/autocomplete', -- Autocompletion + require 'plugins_config/colortheme', -- Color theme for the editor + require 'plugins_config/mini', -- Collections of useful mini plugins, like around/surround + require 'plugins_config/tree-sitter', -- manage lint, indentation and some othe language related tasks + require 'plugins_config/harpoon', -- Improve workflow for multiple files + require 'plugins_config/code_runner', -- Code runner + + -- Broken configs/Testing config + + -- NOTE: Plugins can also be added by using a table, + -- with the first argument being the link and the following + -- keys can be used to configure plugin behavior/loading/etc. + -- + -- Use `opts = {}` to force a plugin to be loaded. + -- + -- This is equivalent to: + -- require('Comment').setup({}) + + -- "gc" to comment visual regions/lines + -- { 'numToStr/Comment.nvim', opts = {} }, -- optional notation + + -- Here is a more advanced example where we pass configuration + -- options to `gitsigns.nvim`. This is equivalent to the following Lua: + -- require('gitsigns').setup({ ... }) + -- + -- See `:help gitsigns` to understand what the configuration keys do }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/lazy-install.lua b/lua/lazy-install.lua index 0e208332..b7bf7a83 100644 --- a/lua/lazy-install.lua +++ b/lua/lazy-install.lua @@ -1,8 +1,11 @@ -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' -if not vim.loop.fs_stat(lazypath) then +if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = 'https://github.com/folke/lazy.nvim.git' - vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } + local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } + if vim.v.shell_error ~= 0 then + error('Error cloning lazy.nvim:\n' .. out) + end end ---@diagnostic disable-next-line: undefined-field vim.opt.rtp:prepend(lazypath) diff --git a/lua/options.lua b/lua/options.lua index a9fae643..fd4d3c89 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -13,6 +13,14 @@ vim.opt.mouse = 'a' -- Don't show the mode, since it's already in the status line vim.opt.showmode = false +-- Sync clipboard between OS and Neovim. +-- Schedule the setting after `UiEnter` because it can increase startup-time. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.schedule(function() + vim.opt.clipboard = 'unnamedplus' +end) + -- Set indent -- vim.opt.tabstop = 4 -- vim.opt.softtabstop = 4 @@ -61,7 +69,12 @@ vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } -- Show which line your cursor is on vim.opt.cursorline = true --- + +-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), +-- instead raise a dialog asking if you wish to save the current file(s) +-- See `:help 'confirm'` +vim.opt.confirm = true + -- set netrw config vim.g.netrw_banner = 0 -- Remove banner at the top vim.g.netrw_liststyle = 3 -- Default directory view. Cycle with i diff --git a/lua/plugins_config/colortheme.lua b/lua/plugins_config/colortheme.lua index 17051bcc..1b2f55c6 100644 --- a/lua/plugins_config/colortheme.lua +++ b/lua/plugins_config/colortheme.lua @@ -1,34 +1,20 @@ return { -- 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. - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', - priority = 1000, -- Make sure to load this before all the other start plugins. - init = function() - -- Load the colorscheme here. - -- Like many other themes, this one has different styles, and you could load - -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. + 'folke/tokyonight.nvim', + priority = 1000, -- Make sure to load this before all the other start plugins. + config = function() + ---@diagnostic disable-next-line: missing-fields + require('tokyonight').setup { + styles = { + comments = { italic = false }, -- Disable italics in comments + }, + } - -- You can configure highlights by doing something like: - vim.cmd.hi 'Comment gui=none' - end, -} --- return { -- 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. --- -- --- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. --- 'ellisonleao/gruvbox.nvim', --- priority = 1000, -- Make sure to load this before all the other start plugins. --- init = function() --- -- Load the colorscheme here. --- -- Like many other themes, this one has different styles, and you could load --- -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. --- vim.cmd.colorscheme 'gruvbox' --- --- -- You can configure highlights by doing something like: --- vim.cmd.hi 'Comment gui=none' --- end, --- } + -- Load the colorscheme here. + -- Like many other themes, this one has different styles, and you could load + -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. + vim.cmd.colorscheme 'tokyonight-night' + end, + }, -- diff --git a/lua/plugins_config/conform.lua b/lua/plugins_config/conform.lua index 56f0cd23..50a9c88b 100644 --- a/lua/plugins_config/conform.lua +++ b/lua/plugins_config/conform.lua @@ -1,11 +1,13 @@ return { -- Autoformat 'stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, lazy = false, keys = { { 'f', function() - require('conform').format { async = true, lsp_fallback = true } + require('conform').format { async = true, lsp_format = 'fallback' } end, mode = '', desc = '[F]ormat buffer', @@ -18,10 +20,14 @@ return { -- Autoformat -- have a well standardized coding style. You can add additional -- languages here or re-enable it for the disabled ones. local disable_filetypes = { c = true, cpp = true } - return { - timeout_ms = 500, - lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], - } + if disable_filetypes[vim.bo[bufnr].filetype] then + return nil + else + return { + timeout_ms = 500, + lsp_format = 'fallback', + } + end end, formatters_by_ft = { lua = { 'stylua' }, @@ -32,9 +38,9 @@ return { -- Autoformat rust = { 'rustfmt' }, toml = { 'taplo' }, jinja2 = { 'djlint' }, + javascript = { { 'prettierd', 'prettier' } }, -- You can use a sub-list to tell conform to run *until* a formatter -- is found. - -- javascript = { { "prettierd", "prettier" } }, }, }, } diff --git a/lua/plugins_config/disabled/autopairs.lua b/lua/plugins_config/disabled/autopairs.lua index 87a7e5ff..386d392e 100644 --- a/lua/plugins_config/disabled/autopairs.lua +++ b/lua/plugins_config/disabled/autopairs.lua @@ -4,13 +4,5 @@ return { 'windwp/nvim-autopairs', event = 'InsertEnter', - -- Optional dependency - dependencies = { 'hrsh7th/nvim-cmp' }, - config = function() - require('nvim-autopairs').setup {} - -- If you want to automatically add `(` after selecting a function or method - local cmp_autopairs = require 'nvim-autopairs.completion.cmp' - local cmp = require 'cmp' - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) - end, + opts = {}, } diff --git a/lua/plugins_config/disabled/debug.lua b/lua/plugins_config/disabled/debug.lua index 7be4abdb..753cb0ce 100644 --- a/lua/plugins_config/disabled/debug.lua +++ b/lua/plugins_config/disabled/debug.lua @@ -24,6 +24,59 @@ return { -- Add your own debuggers here 'leoluz/nvim-dap-go', }, + keys = { + -- Basic debugging keymaps, feel free to change to your liking! + { + '', + function() + require('dap').continue() + end, + desc = 'Debug: Start/Continue', + }, + { + '', + function() + require('dap').step_into() + end, + desc = 'Debug: Step Into', + }, + { + '', + function() + require('dap').step_over() + end, + desc = 'Debug: Step Over', + }, + { + '', + function() + require('dap').step_out() + end, + desc = 'Debug: Step Out', + }, + { + 'b', + function() + require('dap').toggle_breakpoint() + end, + desc = 'Debug: Toggle Breakpoint', + }, + { + 'B', + function() + require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, + desc = 'Debug: Set Breakpoint', + }, + -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. + { + '', + function() + require('dapui').toggle() + end, + desc = 'Debug: See last session result.', + }, + }, config = function() local dap = require 'dap' local dapui = require 'dapui' @@ -31,7 +84,7 @@ return { require('mason-nvim-dap').setup { -- Makes a best effort to setup the various debuggers with -- reasonable debug configurations - automatic_setup = true, + automatic_installation = true, -- You can provide additional configuration to the handlers, -- see mason-nvim-dap README for more information @@ -45,16 +98,6 @@ return { }, } - -- Basic debugging keymaps, feel free to change to your liking! - vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) - vim.keymap.set('n', '', dap.step_into, { desc = 'Debug: Step Into' }) - vim.keymap.set('n', '', dap.step_over, { desc = 'Debug: Step Over' }) - vim.keymap.set('n', '', dap.step_out, { desc = 'Debug: Step Out' }) - vim.keymap.set('n', 'b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' }) - vim.keymap.set('n', 'B', function() - dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') - end, { desc = 'Debug: Set Breakpoint' }) - -- Dap UI setup -- For more information, see |:help nvim-dap-ui| dapui.setup { @@ -77,14 +120,29 @@ return { }, } - -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. - vim.keymap.set('n', '', dapui.toggle, { desc = 'Debug: See last session result.' }) + -- Change breakpoint icons + -- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' }) + -- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' }) + -- local breakpoint_icons = vim.g.have_nerd_font + -- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' } + -- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' } + -- for type, icon in pairs(breakpoint_icons) do + -- local tp = 'Dap' .. type + -- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak' + -- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl }) + -- end dap.listeners.after.event_initialized['dapui_config'] = dapui.open dap.listeners.before.event_terminated['dapui_config'] = dapui.close dap.listeners.before.event_exited['dapui_config'] = dapui.close -- Install golang specific config - require('dap-go').setup() + require('dap-go').setup { + delve = { + -- On Windows delve must be run attached or it crashes. + -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring + detached = vim.fn.has 'win32' == 0, + }, + } end, } diff --git a/lua/plugins_config/disabled/lint.lua b/lua/plugins_config/disabled/lint.lua index 7f0dc42f..907c6bf3 100644 --- a/lua/plugins_config/disabled/lint.lua +++ b/lua/plugins_config/disabled/lint.lua @@ -47,7 +47,12 @@ return { vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { group = lint_augroup, callback = function() - require('lint').try_lint() + -- Only run the linter in buffers that you can modify in order to + -- avoid superfluous noise, notably within the handy LSP pop-ups that + -- describe the hovered symbol using Markdown. + if vim.opt_local.modifiable:get() then + lint.try_lint() + end end, }) end, diff --git a/lua/plugins_config/disabled/neo-tree.lua b/lua/plugins_config/disabled/neo-tree.lua index c793b885..bd442269 100644 --- a/lua/plugins_config/disabled/neo-tree.lua +++ b/lua/plugins_config/disabled/neo-tree.lua @@ -11,7 +11,7 @@ return { }, cmd = 'Neotree', keys = { - { '\\', ':Neotree reveal', { desc = 'NeoTree reveal' } }, + { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, }, opts = { filesystem = { diff --git a/lua/plugins_config/gitsigns.lua b/lua/plugins_config/gitsigns.lua index c3c446b9..bbd91a0f 100644 --- a/lua/plugins_config/gitsigns.lua +++ b/lua/plugins_config/gitsigns.lua @@ -46,7 +46,7 @@ return { map('n', 'hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' }) map('n', 'hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' }) map('n', 'hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' }) - map('n', 'hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' }) + map('n', 'hu', gitsigns.stage_hunk, { desc = 'git [u]ndo stage hunk' }) map('n', 'hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' }) map('n', 'hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' }) map('n', 'hb', gitsigns.blame_line, { desc = 'git [b]lame line' }) @@ -56,7 +56,7 @@ return { end, { desc = 'git [D]iff against last commit' }) -- Toggles map('n', 'tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' }) - map('n', 'tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' }) + map('n', 'tD', gitsigns.preview_hunk_inline, { desc = '[T]oggle git show [D]eleted' }) end, }, } diff --git a/lua/plugins_config/health.lua b/lua/plugins_config/health.lua index 04df77b3..b59d0864 100644 --- a/lua/plugins_config/health.lua +++ b/lua/plugins_config/health.lua @@ -6,13 +6,13 @@ --]] local check_version = function() - local verstr = string.format('%s.%s.%s', vim.version().major, vim.version().minor, vim.version().patch) - if not vim.version.cmp then + local verstr = tostring(vim.version()) + if not vim.version.ge then vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) return end - if vim.version.cmp(vim.version(), { 0, 9, 4 }) >= 0 then + if vim.version.ge(vim.version(), '0.10-dev') then vim.health.ok(string.format("Neovim version is: '%s'", verstr)) else vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) diff --git a/lua/plugins_config/lsp.lua b/lua/plugins_config/lsp.lua index b3a21482..7a5567f9 100644 --- a/lua/plugins_config/lsp.lua +++ b/lua/plugins_config/lsp.lua @@ -1,4 +1,15 @@ return { + -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = '${3rd}/luv/library', words = { 'vim%.uv' } }, + }, + }, + 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs and related tools to stdpath for Neovim @@ -10,9 +21,8 @@ return { -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` { 'j-hui/fidget.nvim', opts = {} }, - -- `neodev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - { 'folke/neodev.nvim', opts = {} }, + -- Allows extra capabilities provided by blink.cmp + 'saghen/blink.cmp', }, config = function() -- Brief aside: **What is LSP?** @@ -52,42 +62,40 @@ return { -- -- In this case, we create a function that lets us more easily define mappings specific -- for LSP related items. It sets the mode, buffer and description for us each time. - local map = function(keys, func, desc) - vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) + local map = function(keys, func, desc, mode) + mode = mode or 'n' + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) end + -- Most Language Servers support renaming across files, etc. + map('grn', vim.lsp.buf.rename, '[R]e[n]ame') + + -- Execute a code action, usually your cursor needs to be on top of an error + -- or a suggestion from your LSP for this to activate. + map('gra', vim.lsp.buf.code_action, '[G]oto Code [A]ction', { 'n', 'x' }) + + -- Find references for the word under your cursor. + map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') -- Jump to the definition of the word under your cursor. -- This is where a variable was first declared, or where a function is defined, etc. -- To jump back, press . - map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + map('grd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') - -- Find references for the word under your cursor. - map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. - map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. - map('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header. + map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') -- Fuzzy find all the symbols in your current document. -- Symbols are things like variables, functions, types, etc. - map('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + map('gO', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') -- Fuzzy find all the symbols in your current workspace. -- Similar to document symbols, except searches over your entire project. - map('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') - - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. - map('rn', vim.lsp.buf.rename, '[R]e[n]ame') - - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') -- Opens a popup that displays documentation about the word under your cursor -- See `:help K` for why this keymap. @@ -101,38 +109,89 @@ return { -- word under your cursor when your cursor rests there for a little while. -- See `:help CursorHold` for information about when this is executed -- + + -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) + ---@param client vim.lsp.Client + ---@param method vim.lsp.protocol.Method + ---@param bufnr? integer some lsp support methods only in specific files + ---@return boolean + local function client_supports_method(client, method, bufnr) + if vim.fn.has 'nvim-0.11' == 1 then + return client:supports_method(method, bufnr) + else + return client.supports_method(method, { bufnr = bufnr }) + end + end -- When you move your cursor, the highlights will be cleared (the second autocommand). local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.server_capabilities.documentHighlightProvider then - Autocmd({ 'CursorHold', 'CursorHoldI' }, { + if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then + local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) + vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { buffer = event.buf, + group = highlight_augroup, callback = vim.lsp.buf.document_highlight, }) - Autocmd({ 'CursorMoved', 'CursorMovedI' }, { + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { buffer = event.buf, + group = highlight_augroup, callback = vim.lsp.buf.clear_references, }) + + vim.api.nvim_create_autocmd('LspDetach', { + group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } + end, + }) end - -- The following autocommand is used to enable inlay hints in your + -- The following code creates a keymap to toggle inlay hints in your -- code, if the language server you are using supports them -- -- This may be unwanted, since they displace some of your code - if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then + if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then map('th', function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) - end, '[T]oggle Inlay [H]intsk ') + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) + end, '[T]oggle Inlay [H]ints') end end, }) + -- Diagnostic Config + -- See :help vim.diagnostic.Opts + vim.diagnostic.config { + severity_sort = true, + float = { border = 'rounded', source = 'if_many' }, + underline = { severity = vim.diagnostic.severity.ERROR }, + signs = vim.g.have_nerd_font and { + text = { + [vim.diagnostic.severity.ERROR] = '󰅚 ', + [vim.diagnostic.severity.WARN] = '󰀪 ', + [vim.diagnostic.severity.INFO] = '󰋽 ', + [vim.diagnostic.severity.HINT] = '󰌶 ', + }, + } or {}, + virtual_text = { + source = 'if_many', + spacing = 2, + format = function(diagnostic) + local diagnostic_message = { + [vim.diagnostic.severity.ERROR] = diagnostic.message, + [vim.diagnostic.severity.WARN] = diagnostic.message, + [vim.diagnostic.severity.INFO] = diagnostic.message, + [vim.diagnostic.severity.HINT] = diagnostic.message, + } + return diagnostic_message[diagnostic.severity] + end, + }, + } -- LSP servers and clients are able to communicate to each other what features they support. -- By default, Neovim doesn't support everything that is in the LSP specification. - -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. - -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers. + local capabilities = require('blink.cmp').get_lsp_capabilities() -- Enable the following language servers -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. @@ -145,17 +204,14 @@ return { -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, + gopls = {}, + pyright = {}, + rust_analyzer = {}, + ts_ls = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs - -- -- Some languages (like typescript) have entire language plugins that can be useful: -- https://github.com/pmizio/typescript-tools.nvim - -- - -- But for many setups, the LSP (`tsserver`) will work just fine - -- tsserver = {}, - -- + -- But for many setups, the LSP (`ts_ls`) will work just fine lua_ls = { -- cmd = {...}, @@ -203,3 +259,101 @@ return { } end, } +{ -- Autocompletion + 'saghen/blink.cmp', + event = 'VimEnter', + version = '1.*', + dependencies = { + -- Snippet Engine + { + 'L3MON4D3/LuaSnip', + version = '2.*', + build = (function() + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then + return + end + return 'make install_jsregexp' + end)(), + dependencies = { + -- `friendly-snippets` contains a variety of premade snippets. + -- See the README about individual language/framework/plugin snippets: + -- https://github.com/rafamadriz/friendly-snippets + -- { + -- 'rafamadriz/friendly-snippets', + -- config = function() + -- require('luasnip.loaders.from_vscode').lazy_load() + -- end, + -- }, + }, + opts = {}, + }, + 'folke/lazydev.nvim', + }, + --- @module 'blink.cmp' + --- @type blink.cmp.Config + opts = { + keymap = { + -- 'default' (recommended) for mappings similar to built-in completions + -- to accept ([y]es) the completion. + -- This will auto-import if your LSP supports it. + -- This will expand snippets if the LSP sent a snippet. + -- 'super-tab' for tab to accept + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- For an understanding of why the 'default' preset is recommended, + -- you will need to read `:help ins-completion` + -- + -- No, but seriously. Please read `:help ins-completion`, it is really good! + -- + -- All presets have the following mappings: + -- /: move to right/left of your snippet expansion + -- : Open menu or open docs if already open + -- / or /: Select next/previous item + -- : Hide menu + -- : Toggle signature help + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + preset = 'default', + + -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: + -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps + }, + + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = 'mono', + }, + + completion = { + -- By default, you may press `` to show the documentation. + -- Optionally, set `auto_show = true` to show the documentation after a delay. + documentation = { auto_show = false, auto_show_delay_ms = 500 }, + }, + + sources = { + default = { 'lsp', 'path', 'snippets', 'lazydev' }, + providers = { + lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, + }, + }, + + snippets = { preset = 'luasnip' }, + + -- Blink.cmp includes an optional, recommended rust fuzzy matcher, + -- which automatically downloads a prebuilt binary when enabled. + -- + -- 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 + fuzzy = { implementation = 'lua' }, + + -- Shows a signature help window while you type arguments for a function + signature = { enabled = true }, + }, + }, diff --git a/lua/plugins_config/tree-sitter.lua b/lua/plugins_config/tree-sitter.lua index 3d84a152..a98b583f 100644 --- a/lua/plugins_config/tree-sitter.lua +++ b/lua/plugins_config/tree-sitter.lua @@ -1,8 +1,10 @@ return { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', + main = 'nvim-treesitter.configs', -- Sets main module to use for opts + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'lua', 'rust', 'toml', 'bash', 'dockerfile', 'go', 'http', 'json', 'make', 'markdown', 'python', 'regex', 'yaml' }, + ensure_installed = { 'lua', 'rust', 'toml', 'bash', 'dockerfile', 'go', 'http', 'json', 'make', 'markdown', 'python', 'regex', 'yaml', 'vim', 'vimdoc', 'diff', 'typescript', 'javascript' }, -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = false, diff --git a/lua/plugins_config/which-key.lua b/lua/plugins_config/which-key.lua index cce7e5ed..f9ceac8e 100644 --- a/lua/plugins_config/which-key.lua +++ b/lua/plugins_config/which-key.lua @@ -1,29 +1,68 @@ return { -- Useful plugin to show you pending keybinds. 'folke/which-key.nvim', event = 'VimEnter', -- Sets the loading event to 'VimEnter' - config = function() -- This is the function that runs, AFTER loading - require('which-key').setup() + opts = { + -- delay between pressing a key and opening which-key (milliseconds) + -- this setting is independent of vim.opt.timeoutlen + delay = 0, + icons = { + -- set icon mappings to true if you have a Nerd Font + mappings = vim.g.have_nerd_font, + -- If you are using a Nerd Font: set icons.keys to an empty table which will use the + -- default which-key.nvim defined Nerd Font icons, otherwise define a string table + keys = vim.g.have_nerd_font and {} or { + Up = ' ', + Down = ' ', + Left = ' ', + Right = ' ', + C = ' ', + M = ' ', + D = ' ', + S = ' ', + CR = ' ', + Esc = ' ', + ScrollWheelDown = ' ', + ScrollWheelUp = ' ', + NL = ' ', + BS = ' ', + Space = ' ', + Tab = ' ', + F1 = '', + F2 = '', + F3 = '', + F4 = '', + F5 = '', + F6 = '', + F7 = '', + F8 = '', + F9 = '', + F10 = '', + F11 = '', + F12 = '', + }, + }, -- Document existing key chains - require('which-key').add { + spec = { + { 's', group = '[S]earch' }, + { 't', group = '[T]oggle' }, { 'c', group = '[C]ode' }, { 'c_', hidden = true }, { 'd', group = '[D]ocument' }, { 'd_', hidden = true }, { 'h', group = 'Git [H]unk' }, { 'h_', hidden = true }, - { 'r', group = '[R]ename' }, + { 'r', group = '[R]un code' }, { 'r_', hidden = true }, + { 'R', group = '[R]e[n]ame' }, + { 'R_', hidden = true }, { 's', group = '[S]earch' }, { 's_', hidden = true }, { 't', group = '[T]oggle' }, { 't_', hidden = true }, { 'w', group = '[W]orkspace' }, { 'w_', hidden = true }, - } - -- visual mode - require('which-key').add { - { 'h', desc = 'Git [H]unk', mode = 'v' }, - } - end, + { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + }, + }, }