From 68b1981f0298f5b92b68acc00f42eda5702c4044 Mon Sep 17 00:00:00 2001 From: Damjan 9000 Date: Wed, 25 Oct 2023 21:46:24 +0200 Subject: [PATCH 01/22] 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 433a51d..f819827 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 02/22] 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 f819827..9652d70 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 03/22] 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 9652d70..e2d9ea8 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 04/22] 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 9652d70..1f8e6f4 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 05/22] 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 a7667dd..a301a94 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 06/22] 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 a301a94..b4b8305 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 07/22] 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 b4b8305..0976a46 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 08/22] 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 0976a46..225ad21 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 09/22] 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 225ad21..748e7f8 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 10/22] 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 748e7f8..385b19a 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 11/22] 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 385b19a..3a98da0 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', From ee9790b381416781063d0de6653b303f10ed89b0 Mon Sep 17 00:00:00 2001 From: Tommy Williams Date: Fri, 24 Nov 2023 09:55:19 -0700 Subject: [PATCH 12/22] option to reduce noisy Lua_LS's missing-fields warnings (#511) --- init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/init.lua b/init.lua index 3a98da0..e7f1eec 100644 --- a/init.lua +++ b/init.lua @@ -522,6 +522,8 @@ local servers = { Lua = { workspace = { checkThirdParty = false }, telemetry = { enable = false }, + -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings + -- diagnostics = { disable = { 'missing-fields' } }, }, }, } From 14cf319dbd63ef4bedf9cf219c3732c568718996 Mon Sep 17 00:00:00 2001 From: matt <55467261+mattwyd@users.noreply.github.com> Date: Wed, 29 Nov 2023 19:34:43 -0500 Subject: [PATCH 13/22] Update README.md (#520) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7f54ce8..1979e9e 100644 --- a/README.md +++ b/README.md @@ -39,19 +39,19 @@ Neovim's configurations are located under the following paths, depending on your Clone kickstart.nvim: -```sh # on Linux and Mac +```sh git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim ``` -``` # 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\ ``` From afafc9ab194be254467b4cc8be049fc33fe27b14 Mon Sep 17 00:00:00 2001 From: Damjan 9000 Date: Thu, 30 Nov 2023 10:04:27 +0100 Subject: [PATCH 14/22] README.md: update install section formatting (#523) --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1979e9e..36c1386 100644 --- a/README.md +++ b/README.md @@ -39,18 +39,17 @@ Neovim's configurations are located under the following paths, depending on your Clone kickstart.nvim: -# on Linux and Mac +- on Linux and Mac ```sh git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim ``` - -# on Windows (cmd) +- on Windows (cmd) ``` git clone https://github.com/nvim-lua/kickstart.nvim.git %userprofile%\AppData\Local\nvim\ ``` -# on Windows (powershell) +- on Windows (powershell) ``` git clone https://github.com/nvim-lua/kickstart.nvim.git $env:USERPROFILE\AppData\Local\nvim\ ``` From 39ae0829acea66175721fcf48695c7df6db040b9 Mon Sep 17 00:00:00 2001 From: Sudo <788991+wadkar@users.noreply.github.com> Date: Fri, 1 Dec 2023 07:30:55 +0900 Subject: [PATCH 15/22] Use alias instead of a wrapper script (#524) It is much easier to stick an alias statement in `~/.{z,ba}shrc` than create a script, invoke another instance of interpreter and then run neovim --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 36c1386..78ac6df 100644 --- a/README.md +++ b/README.md @@ -156,12 +156,11 @@ Each PR, especially those which increase the line count, should have a descripti * 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`: + * 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 an alias: ``` - #!/bin/sh - exec env NVIM_APPNAME=nvim-kickstart nvim "$@" + alias nvim-kickstart='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. + When you run Neovim using `nvim-kickstart` alias 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 3ca08acf0e9023b3f8b602a5db2dd00cebdcbfbc Mon Sep 17 00:00:00 2001 From: Damjan 9000 Date: Sat, 2 Dec 2023 22:27:13 +0100 Subject: [PATCH 16/22] Add a github action on pull request to check lua formatting (#526) GitHub Action used: https://github.com/marketplace/actions/stylua This runs `stylua --check` on a PR and it will show success or failure. The suggested stylua changes can be inspected when clicking on the details. The PR can still be merged even if the check fails. --- .github/workflows/stylua.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/stylua.yml diff --git a/.github/workflows/stylua.yml b/.github/workflows/stylua.yml new file mode 100644 index 0000000..e189fe0 --- /dev/null +++ b/.github/workflows/stylua.yml @@ -0,0 +1,18 @@ +# Check Lua Formatting +name: Check Lua Formatting +on: pull_request + +jobs: + stylua-check: + name: Stylua Check + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Stylua Check + uses: JohnnyMorganz/stylua-action@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: --check . + From 12bd68e8b9bc98242084bce55236d2bf9fe299b1 Mon Sep 17 00:00:00 2001 From: Damjan 9000 Date: Sun, 3 Dec 2023 20:23:39 +0100 Subject: [PATCH 17/22] Run stylua (#525) --- init.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/init.lua b/init.lua index e7f1eec..94f7cf4 100644 --- a/init.lua +++ b/init.lua @@ -324,17 +324,17 @@ local function find_git_root() local current_dir local cwd = vim.fn.getcwd() -- If the buffer is not associated with a file, return nil - if current_file == "" then + if current_file == '' then current_dir = cwd else -- Extract the directory from the current file's path - current_dir = vim.fn.fnamemodify(current_file, ":h") + current_dir = vim.fn.fnamemodify(current_file, ':h') end -- 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] + 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. Searching on current working directory") + print 'Not a git repository. Searching on current working directory' return cwd end return git_root @@ -344,9 +344,9 @@ end 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}, - }) + require('telescope.builtin').live_grep { + search_dirs = { git_root }, + } end end @@ -567,7 +567,7 @@ cmp.setup { end, }, completion = { - completeopt = 'menu,menuone,noinsert' + completeopt = 'menu,menuone,noinsert', }, mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.select_next_item(), From f8c8b08bc15b2bac590b3c397db3b466f7fb1d0b Mon Sep 17 00:00:00 2001 From: Damjan 9000 Date: Mon, 4 Dec 2023 16:35:54 +0100 Subject: [PATCH 18/22] Add gitsigns recommended keymaps (#531) * Import gitsigns README.md recommended keymaps (and apply stylua) the previously added visual mode for ]c [c is kept. * Add gitsigns keymap descriptions --- init.lua | 59 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/init.lua b/init.lua index 94f7cf4..76ddd45 100644 --- a/init.lua +++ b/init.lua @@ -126,11 +126,16 @@ require('lazy').setup({ changedelete = { text = '~' }, }, on_attach = function(bufnr) - vim.keymap.set('n', 'hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' }) - - -- don't override the built-in and fugitive keymaps local gs = package.loaded.gitsigns - vim.keymap.set({ 'n', 'v' }, ']c', function() + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map({ 'n', 'v' }, ']c', function() if vim.wo.diff then return ']c' end @@ -138,8 +143,9 @@ require('lazy').setup({ gs.next_hunk() end) return '' - end, { expr = true, buffer = bufnr, desc = 'Jump to next hunk' }) - vim.keymap.set({ 'n', 'v' }, '[c', function() + end, { expr = true, desc = 'Jump to next hunk' }) + + map({ 'n', 'v' }, '[c', function() if vim.wo.diff then return '[c' end @@ -147,7 +153,37 @@ require('lazy').setup({ gs.prev_hunk() end) return '' - end, { expr = true, buffer = bufnr, desc = 'Jump to previous hunk' }) + end, { expr = true, desc = 'Jump to previous hunk' }) + + -- Actions + -- visual mode + map('v', 'hs', function() + gs.stage_hunk { vim.fn.line '.', vim.fn.line 'v' } + end, { desc = 'stage git hunk' }) + map('v', 'hr', function() + gs.reset_hunk { vim.fn.line '.', vim.fn.line 'v' } + end, { desc = 'reset git hunk' }) + -- normal mode + map('n', 'hs', gs.stage_hunk, { desc = 'git stage hunk' }) + map('n', 'hr', gs.reset_hunk, { desc = 'git reset hunk' }) + map('n', 'hS', gs.stage_buffer, { desc = 'git Stage buffer' }) + map('n', 'hu', gs.undo_stage_hunk, { desc = 'undo stage hunk' }) + map('n', 'hR', gs.reset_buffer, { desc = 'git Reset buffer' }) + map('n', 'hp', gs.preview_hunk, { desc = 'preview git hunk' }) + map('n', 'hb', function() + gs.blame_line { full = false } + end, { desc = 'git blame line' }) + map('n', 'hd', gs.diffthis, { desc = 'git diff against index' }) + map('n', 'hD', function() + gs.diffthis '~' + end, { desc = 'git diff against last commit' }) + + -- Toggles + map('n', 'tb', gs.toggle_current_line_blame, { desc = 'toggle git blame line' }) + map('n', 'td', gs.toggle_deleted, { desc = 'toggle git show deleted' }) + + -- Text object + map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', { desc = 'select git hunk' }) end, }, }, @@ -491,11 +527,18 @@ require('which-key').register { ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, - ['h'] = { name = 'More git', _ = 'which_key_ignore' }, + ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, + ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, } +-- register which-key VISUAL mode +-- required for visual hs (hunk stage) to work +require('which-key').register({ + [''] = { name = 'VISUAL ' }, + ['h'] = { 'Git [H]unk' }, +}, { mode = 'v' }) -- mason-lspconfig requires that these setup functions are called in this order -- before setting up the servers. From 3824342d107850dfe5b179d0a39e0d8fcd54411d Mon Sep 17 00:00:00 2001 From: Damjan 9000 Date: Mon, 4 Dec 2023 16:45:01 +0100 Subject: [PATCH 19/22] Adds two essential telescope keymaps (#528) * Added keymap for select Telescope picker * Added keymap for search in all open files --- init.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/init.lua b/init.lua index 76ddd45..36cc9a5 100644 --- a/init.lua +++ b/init.lua @@ -399,6 +399,14 @@ vim.keymap.set('n', '/', function() }) end, { desc = '[/] Fuzzily search in current buffer' }) +local function telescope_live_grep_open_files() + require('telescope.builtin').live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } +end +vim.keymap.set('n', 's/', telescope_live_grep_open_files, { desc = '[S]earch [/] in Open Files' }) +vim.keymap.set('n', 'ss', require('telescope.builtin').builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) 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' }) From 76c5b1ec57f40d17ac787feb018817a802e24bb6 Mon Sep 17 00:00:00 2001 From: Shashwat Agrawal <72117025+ShashwatAgrawal20@users.noreply.github.com> Date: Fri, 8 Dec 2023 18:44:06 +0530 Subject: [PATCH 20/22] feat(cmp): path completion feature (#536) --- init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/init.lua b/init.lua index 36cc9a5..cf4a379 100644 --- a/init.lua +++ b/init.lua @@ -105,6 +105,7 @@ require('lazy').setup({ -- Adds LSP completion capabilities 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', -- Adds a number of user-friendly snippets 'rafamadriz/friendly-snippets', @@ -652,6 +653,7 @@ cmp.setup { sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, + { name = 'path' }, }, } From e39a8bce9d25b3bd8d50098fadf13575a4a71b4b Mon Sep 17 00:00:00 2001 From: Ari Pollak Date: Thu, 21 Dec 2023 15:35:28 -0500 Subject: [PATCH 21/22] Switch cmp up mapping from C-d to C-b to match regular vim up key (#549) --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index cf4a379..48cf771 100644 --- a/init.lua +++ b/init.lua @@ -624,7 +624,7 @@ cmp.setup { mapping = cmp.mapping.preset.insert { [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete {}, [''] = cmp.mapping.confirm { From 4d0dc8d4b1bd6b94e59f7773158149bb1b0ee5be Mon Sep 17 00:00:00 2001 From: John Pekcan Date: Sat, 23 Dec 2023 20:59:59 -0800 Subject: [PATCH 22/22] fix: restore mason config timing for dap startup (#555) Co-authored-by: John Pekcan --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 48cf771..7e68de6 100644 --- a/init.lua +++ b/init.lua @@ -83,7 +83,7 @@ require('lazy').setup({ 'neovim/nvim-lspconfig', dependencies = { -- Automatically install LSPs to stdpath for neovim - 'williamboman/mason.nvim', + { 'williamboman/mason.nvim', config = true }, 'williamboman/mason-lspconfig.nvim', -- Useful status updates for LSP