diff --git a/README.md b/README.md
index a427def2..f445b65e 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,7 @@ 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 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
- Language Setup:
@@ -99,7 +100,7 @@ That's it! Lazy will install all the plugins you have. Use `:Lazy` to view
current plugin status. Hit `q` to close the window.
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.
@@ -182,7 +183,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,17 +193,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
-echo "deb https://deb.debian.org/debian unstable main" | sudo tee -a /etc/apt/sources.list
-sudo apt update
-sudo apt install -t unstable neovim
+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
+
+# make it available in /usr/local/bin, distro installs to /usr/bin
+sudo ln -sf /opt/nvim-linux64/bin/nvim /usr/local/bin/
```
Fedora Install Steps
diff --git a/init.lua b/init.lua
index 7e4aa46e..93510938 100644
--- a/init.lua
+++ b/init.lua
@@ -294,7 +294,12 @@ require('lazy').setup({
['s'] = { name = '[S]earch', _ = 'which_key_ignore' },
['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
['t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
+ ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' },
}
+ -- visual mode
+ require('which-key').register({
+ ['h'] = { 'Git [H]unk' },
+ }, { mode = 'v' })
end,
},
@@ -414,7 +419,7 @@ require('lazy').setup({
'neovim/nvim-lspconfig',
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
- 'williamboman/mason.nvim',
+ { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants
'williamboman/mason-lspconfig.nvim',
'WhoIsSethDaniel/mason-tool-installer.nvim',
@@ -516,13 +521,16 @@ require('lazy').setup({
-- 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
+ 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,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = event.buf,
+ group = highlight_augroup,
callback = vim.lsp.buf.clear_references,
})
end
@@ -533,12 +541,20 @@ require('lazy').setup({
-- This may be unwanted, since they displace some of your code
if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
map('th', function()
- vim.lsp.inlay_hint.enable(0, not vim.lsp.inlay_hint.is_enabled())
+ vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
end, '[T]oggle Inlay [H]ints')
end
end,
})
+ vim.api.nvim_create_autocmd('LspDetach', {
+ group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
+ callback = function(event)
+ vim.lsp.buf.clear_references()
+ vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event.buf }
+ 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.
@@ -722,6 +738,12 @@ require('lazy').setup({
-- This will expand snippets if the LSP sent a snippet.
[''] = cmp.mapping.confirm { select = true },
+ -- If you prefer more traditional completion keymaps,
+ -- you can uncomment the following lines
+ --[''] = cmp.mapping.confirm { select = true },
+ --[''] = cmp.mapping.select_next_item(),
+ --[''] = cmp.mapping.select_prev_item(),
+
-- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display
-- completions whenever it has completion options available.
@@ -885,6 +907,7 @@ require('lazy').setup({
-- require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
+ -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- This is the easiest way to modularize your config.
diff --git a/lua/kickstart/plugins/gitsigns.lua b/lua/kickstart/plugins/gitsigns.lua
new file mode 100644
index 00000000..4bcc70f4
--- /dev/null
+++ b/lua/kickstart/plugins/gitsigns.lua
@@ -0,0 +1,61 @@
+-- Adds git related signs to the gutter, as well as utilities for managing changes
+-- NOTE: gitsigns is already included in init.lua but contains only the base
+-- config. This will add also the recommended keymaps.
+
+return {
+ {
+ 'lewis6991/gitsigns.nvim',
+ opts = {
+ on_attach = function(bufnr)
+ local gitsigns = require 'gitsigns'
+
+ local function map(mode, l, r, opts)
+ opts = opts or {}
+ opts.buffer = bufnr
+ vim.keymap.set(mode, l, r, opts)
+ end
+
+ -- Navigation
+ map('n', ']c', function()
+ if vim.wo.diff then
+ vim.cmd.normal { ']c', bang = true }
+ else
+ gitsigns.nav_hunk 'next'
+ end
+ end, { desc = 'Jump to next git [c]hange' })
+
+ map('n', '[c', function()
+ if vim.wo.diff then
+ vim.cmd.normal { '[c', bang = true }
+ else
+ gitsigns.nav_hunk 'prev'
+ end
+ end, { desc = 'Jump to previous git [c]hange' })
+
+ -- Actions
+ -- visual mode
+ map('v', 'hs', function()
+ gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
+ end, { desc = 'stage git hunk' })
+ map('v', 'hr', function()
+ gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
+ end, { desc = 'reset git hunk' })
+ -- normal mode
+ 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', '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' })
+ map('n', 'hd', gitsigns.diffthis, { desc = 'git [d]iff against index' })
+ map('n', 'hD', function()
+ gitsigns.diffthis '@'
+ 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' })
+ end,
+ },
+ },
+}