From 01ed2525bbff69756cd867673dea4dd9e54dfdee Mon Sep 17 00:00:00 2001 From: Ashraf Michail Date: Tue, 3 Oct 2023 13:22:25 +0000 Subject: [PATCH 01/15] Fix bash errors --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 11f55d05..ee1f390e 100644 --- a/init.lua +++ b/init.lua @@ -333,7 +333,7 @@ vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = vim.defer_fn(function() require('nvim-treesitter.configs').setup { -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' }, + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = false, From c27b05467a80a36a2be757a84384ffba86221094 Mon Sep 17 00:00:00 2001 From: Pedro Santayana Date: Sat, 7 Oct 2023 22:34:24 -0300 Subject: [PATCH 02/15] docs: fix misstype on README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d27756c..433a51de 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Neovim's configurations are located under the following paths, depending on your | OS | PATH | | :- | :--- | | Linux | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | -| MacOS | `$XDG_CONFIG_HOME/nvim`, '~/.config/nvim` | +| MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | | Windows | `%userprofile%\AppData\Local\nvim\` | Clone kickstart.nvim: From db7189f35c33f9b7e95a1602ff4d8dffe5cbf741 Mon Sep 17 00:00:00 2001 From: Alvaro-Kothe Date: Tue, 10 Oct 2023 19:57:49 -0300 Subject: [PATCH 03/15] Fix help for indent-blankline plugin Since version 3 `:help indent_blankline` no longer works. Replace it with `:help ibl`. --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index ee1f390e..fb080807 100644 --- a/init.lua +++ b/init.lua @@ -177,7 +177,7 @@ require('lazy').setup({ -- Add indentation guides even on blank lines 'lukas-reineke/indent-blankline.nvim', -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help indent_blankline.txt` + -- See `:help ibl` main = 'ibl', opts = {}, }, From 5d8921990bf2fab9a1c9dc0d74bf1bbe1b6dc980 Mon Sep 17 00:00:00 2001 From: Theo P Date: Fri, 13 Oct 2023 16:21:10 +0900 Subject: [PATCH 04/15] feat(lsp): use Telescope builtin functions for LSP definition and type definition --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index fb080807..a7667ddc 100644 --- a/init.lua +++ b/init.lua @@ -422,10 +422,10 @@ local on_attach = function(_, bufnr) nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') From 68b1981f0298f5b92b68acc00f42eda5702c4044 Mon Sep 17 00:00:00 2001 From: Damjan 9000 Date: Wed, 25 Oct 2023 21:46:24 +0200 Subject: [PATCH 05/15] Update README Post Installation steps Change the recommendation to just run nvim normally instead of the headless mode for the first run. This will show Lazy UI updating the plugins which would match what the video show and may be easier to understand what is going on thant the silent headless run. --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 433a51de..f8198270 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,15 @@ git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\L ### Post Installation -Run the following command and then **you are ready to go**! +Start Neovim + +```sh +nvim +``` + +The `Lazy` plugin manager will start automatically on the first run and install the configured plugins - as can be seen in the introduction video. After the installation is complete you can press `q` to close the `Lazy` UI and **you are ready to go**! Next time you run nvim `Lazy` will no longer show up. + +If you would prefer to hide this step and run the plugin sync from the command line, you can use: ```sh nvim --headless "+Lazy! sync" +qa From 0dd934ee017cdd52bc91b4e5dd9f4e4e31a5d98b Mon Sep 17 00:00:00 2001 From: Damjan 9000 Date: Sat, 28 Oct 2023 23:33:10 +0200 Subject: [PATCH 06/15] README.md: add a note about NVIM_APPNAME in the FAQ section --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index f8198270..9652d708 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,13 @@ Each PR, especially those which increase the line count, should have a descripti * You should back it up, then delete all files associated with it. * This includes your existing init.lua and the neovim files in `~/.local` which can be deleted with `rm -rf ~/.local/share/nvim/` * You may also want to look at the [migration guide for lazy.nvim](https://github.com/folke/lazy.nvim#-migration-guide) +* 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` to maintain multiple configurations. For example you can install the kickstart configuration in `~/.config/nvim-kickstart` and create a script `~/bin/nvim-kickstart`: + ``` + #!/bin/sh + exec env NVIM_APPNAME=nvim-kickstart nvim "$@" + ``` + When you run Neovim with `nvim-kickstart` it will use the alternative config directory and the matching local directory: `~/.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 * Are there any cool videos about this plugin? From 4d2cf48fb6b620a5b4ae30f6b2a0b3b521cdbce8 Mon Sep 17 00:00:00 2001 From: n-a11s Date: Fri, 3 Nov 2023 13:47:30 +0100 Subject: [PATCH 07/15] Update README.md Added information on where to install if you use Powershell in windows. Since CMD and Powershell work differently. `%userprofile%` only works for the CMD application. `$env:USERPROFILE` works in Powershell. --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9652d708..e2d9ea84 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,8 @@ Neovim's configurations are located under the following paths, depending on your | :- | :--- | | Linux | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | | MacOS | `$XDG_CONFIG_HOME/nvim`, `~/.config/nvim` | -| Windows | `%userprofile%\AppData\Local\nvim\` | +| Windows (cmd)| `%userprofile%\AppData\Local\nvim\` | +| Windows (powershell)| `$env:USERPROFILE\AppData\Local\nvim\` | Clone kickstart.nvim: @@ -45,10 +46,16 @@ git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HO ``` -# on Windows +# on Windows (cmd) git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ ``` +``` +# on Windows (powershell) +git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ +``` + + ### Post Installation Start Neovim From 1ad1ec250907acd6e1c593f9990eb61430aa7c74 Mon Sep 17 00:00:00 2001 From: Damjan 9000 Date: Fri, 3 Nov 2023 19:04:25 +0100 Subject: [PATCH 08/15] README.md: Added a FAQ: why is init.lua a single file --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 9652d708..1f8e6f40 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,16 @@ Each PR, especially those which increase the line count, should have a descripti * Are there any cool videos about this plugin? * Current iteration of kickstart (coming soon) * Here is one about the previous iteration of kickstart: [video introduction to Kickstart.nvim](https://youtu.be/stqUbv-5u2s). Note the install via init.lua no longer works as specified. Please follow the install instructions in this file instead as they're up to date. +* 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 `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 exact + same functionality is available here: + * [kickstart-modular.nvim](https://github.com/dam9000/kickstart-modular.nvim) + * Discussions on this topic can be found here: + * [Restructure the configuration](https://github.com/nvim-lua/kickstart.nvim/issues/218) + * [Reorganize init.lua into a multi-file setup](https://github.com/nvim-lua/kickstart.nvim/pull/473) ### Windows Installation From 0fda9af7c94a2c3687a5123a7cf254613de45a46 Mon Sep 17 00:00:00 2001 From: Sebastian Lara Menares Date: Mon, 6 Nov 2023 11:10:16 -0300 Subject: [PATCH 09/15] add Telescope live_grep on Git root --- init.lua | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index a7667ddc..a301a94e 100644 --- a/init.lua +++ b/init.lua @@ -308,6 +308,40 @@ require('telescope').setup { -- Enable telescope fzf native, if installed pcall(require('telescope').load_extension, 'fzf') +-- Telescope live_grep in git root +-- Function to find the git root directory based on the current buffer's path +local function find_git_root() + -- Use the current buffer's path as the starting point for the git search + local current_file = vim.api.nvim_buf_get_name(0) + -- If the buffer is not associated with a file, return nil + if current_file == "" then + print("Buffer is not associated with a file") + return nil + end + -- Extract the directory from the current file's path + local current_dir = vim.fn.fnamemodify(current_file, ":h") + -- Find the Git root directory from the current file's path + print("git -C " .. vim.fn.escape(current_dir, " ") .. " rev-parse --show-toplevel") + local git_root = vim.fn.systemlist("git -C " .. vim.fn.escape(current_dir, " ") .. " rev-parse --show-toplevel")[1] + if vim.v.shell_error ~= 0 then + print("Not a git repository") + return nil + end + return git_root +end + +-- Custom live_grep function to search in git root +local function live_grep_git_root() + local git_root = find_git_root() + if git_root then + require('telescope.builtin').live_grep({ + search_dirs = {git_root}, + }) + end +end + +vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) + -- See `:help telescope.builtin` vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) @@ -323,7 +357,8 @@ vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', 'sG', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', 'sg', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) From 5ce4f38e1e9b62c7e2477b2e21af08ecac232bc5 Mon Sep 17 00:00:00 2001 From: Sebastian Lara Menares Date: Mon, 6 Nov 2023 15:29:09 -0300 Subject: [PATCH 10/15] change keymap to not disrupt existing users of Search by Grep --- init.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index a301a94e..b4b83051 100644 --- a/init.lua +++ b/init.lua @@ -321,7 +321,6 @@ local function find_git_root() -- Extract the directory from the current file's path local current_dir = vim.fn.fnamemodify(current_file, ":h") -- Find the Git root directory from the current file's path - print("git -C " .. vim.fn.escape(current_dir, " ") .. " rev-parse --show-toplevel") local git_root = vim.fn.systemlist("git -C " .. vim.fn.escape(current_dir, " ") .. " rev-parse --show-toplevel")[1] if vim.v.shell_error ~= 0 then print("Not a git repository") @@ -357,8 +356,8 @@ vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sG', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sg', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) +vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', 'sG', ':LiveGrepGitRoot', { desc = '[S]earch by [G]rep on Git Root' }) vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) From 1d14453024dcb8e2025ba3a14d5c3f1daa384e63 Mon Sep 17 00:00:00 2001 From: Sebastian Lara Menares Date: Mon, 6 Nov 2023 22:29:05 -0300 Subject: [PATCH 11/15] Live Grep from Git root falls back to cwd on special buffers --- init.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index b4b83051..0976a461 100644 --- a/init.lua +++ b/init.lua @@ -313,18 +313,21 @@ pcall(require('telescope').load_extension, 'fzf') local function find_git_root() -- Use the current buffer's path as the starting point for the git search local current_file = vim.api.nvim_buf_get_name(0) + local current_dir + local cwd = vim.fn.getcwd() -- If the buffer is not associated with a file, return nil if current_file == "" then - print("Buffer is not associated with a file") - return nil + current_dir = cwd + else + -- Extract the directory from the current file's path + current_dir = vim.fn.fnamemodify(current_file, ":h") end - -- Extract the directory from the current file's path - local current_dir = vim.fn.fnamemodify(current_file, ":h") + -- Find the Git root directory from the current file's path local git_root = vim.fn.systemlist("git -C " .. vim.fn.escape(current_dir, " ") .. " rev-parse --show-toplevel")[1] if vim.v.shell_error ~= 0 then - print("Not a git repository") - return nil + print("Not a git repository. Searching on current working directory") + return cwd end return git_root end From f23484cf88197ac38574f4fd4965cc2c17263f20 Mon Sep 17 00:00:00 2001 From: Damjan 9000 Date: Tue, 7 Nov 2023 11:18:15 +0100 Subject: [PATCH 12/15] init.lua: move diagnostic keymaps together with other keymaps --- init.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index 0976a461..225ad21a 100644 --- a/init.lua +++ b/init.lua @@ -281,6 +281,12 @@ vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) + -- [[ Highlight on yank ]] -- See `:help vim.highlight.on_yank()` local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) @@ -433,12 +439,6 @@ vim.defer_fn(function() } end, 0) --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) - -- [[ Configure LSP ]] -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_, bufnr) From c8dd8e7e0cd5d3d1d3760eac908513de1be0b37c Mon Sep 17 00:00:00 2001 From: Damjan 9000 Date: Tue, 7 Nov 2023 11:27:14 +0100 Subject: [PATCH 13/15] init.lua: minor edits of section comments for consistency --- init.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 225ad21a..748e7f81 100644 --- a/init.lua +++ b/init.lua @@ -37,13 +37,14 @@ I hope you enjoy your Neovim journey, 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 = ' ' --- Install package manager +-- [[ Install `lazy.nvim` plugin manager ]] -- https://github.com/folke/lazy.nvim -- `:help lazy.nvim.txt` for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' @@ -59,6 +60,7 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) +-- [[ Configure plugins ]] -- NOTE: Here is where you install your plugins. -- You can configure plugins using the `config` key. -- From af4f51b2cd6cfb2511d34adc99900110f4d3916b Mon Sep 17 00:00:00 2001 From: Shashwat Agrawal Date: Sat, 11 Nov 2023 20:31:05 +0530 Subject: [PATCH 14/15] fix(auto-completion): ensure first menu item is selected by default --- init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init.lua b/init.lua index 748e7f81..385b19a0 100644 --- a/init.lua +++ b/init.lua @@ -564,6 +564,9 @@ cmp.setup { luasnip.lsp_expand(args.body) end, }, + completion = { + completeopt = 'menu,menuone,noinsert' + }, mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), From 711e5976dd83f0bdb904e3d884375b79c89f0e2a Mon Sep 17 00:00:00 2001 From: j-hui Date: Mon, 13 Nov 2023 15:46:34 -0500 Subject: [PATCH 15/15] init.lua: remove 'legacy' tag from fidget.nvim --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 385b19a0..3a98da03 100644 --- a/init.lua +++ b/init.lua @@ -88,7 +88,7 @@ require('lazy').setup({ -- Useful status updates for LSP -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, + { 'j-hui/fidget.nvim', opts = {} }, -- Additional lua configuration, makes nvim stuff amazing! 'folke/neodev.nvim',