diff --git a/init.lua b/init.lua index 7f91fa4..65f0922 100644 --- a/init.lua +++ b/init.lua @@ -22,11 +22,14 @@ require 'opt.options' -- Configuration of plugins require 'plugin.telescope' +require 'plugin.yanky' require 'plugin.fzf_lsp' require 'plugin.autoclose' require 'plugin.lsp_config' require 'plugin.treesitter' require 'plugin.dracula' require 'plugin.cmp' +require 'plugin.auto_session' +require 'plugin.gitsigns' vim.cmd('colorscheme dracula-soft') diff --git a/lazy-lock.json b/lazy-lock.json index 98ebd0c..28621d3 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -2,22 +2,21 @@ "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, "LuaSnip": { "branch": "master", "commit": "a7a4b4682c4b3e2ba82b82a4e6e5f5a0e79dec32" }, "LuaSnip-snippets.nvim": { "branch": "main", "commit": "d7e40e4cce622eab2316607dbcd8d6039bcb9fe0" }, - "autoclose.nvim": { "branch": "main", "commit": "dc42806540dcf448ecb2bad6b67204410cfbe629" }, - "base16-nvim": { "branch": "master", "commit": "b3e9ec6a82c05b562cd71f40fe8964438a9ba64a" }, + "auto-session": { "branch": "main", "commit": "af2219b9fa99c1d7ac409bd9eac094c459d3f52d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "dracula.nvim": { "branch": "main", "commit": "8d8bddb8814c3e7e62d80dda65a9876f97eb699c" }, "friendly-snippets": { "branch": "main", "commit": "ea068f1becd91bcd4591fceb6420d4335e2e14d3" }, "fzf": { "branch": "master", "commit": "c30e486b648c1540a660802a5015aeca208274fa" }, "fzf-lsp.nvim": { "branch": "main", "commit": "16905056051759b15a388709a3fa65ff098eb243" }, - "haskell-tools.nvim": { "branch": "master", "commit": "217cb7958ebbebf360f7c43efd5129e66d748042" }, + "gitsigns.nvim": { "branch": "main", "commit": "75dc649106827183547d3bedd4602442340d2f7f" }, "indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" }, "lazy.nvim": { "branch": "main", "commit": "af6afefbb46ab29a8a1db69536b04290a9403876" }, "lazygit.nvim": { "branch": "main", "commit": "0ada6c6e7e138df92f5009b6952f4ac41248305a" }, "leap.nvim": { "branch": "main", "commit": "25753d8a16b69fbbce5d392702c21dbc79d86bd1" }, "lsp-zero.nvim": { "branch": "v3.x", "commit": "2b5e9a39b3bf60bfb0cc7c35d5f2e879d4cd72ea" }, - "neoconf.nvim": { "branch": "main", "commit": "9a419c4fa772c4c61839a8f7fdd8e863679a8c94" }, "neodev.nvim": { "branch": "main", "commit": "6a533ed9d3435dcaa456380d833ea04da37ea2ed" }, + "nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" }, "nvim-cmp": { "branch": "main", "commit": "97dc716fc914c46577a4f254035ebef1aa72558a" }, "nvim-dap": { "branch": "master", "commit": "c1695e500c7d552a0a19953a9aefcc89178fb1af" }, "nvim-lspconfig": { "branch": "master", "commit": "6e5c78ebc9936ca74add66bda22c566f951b6ee5" }, @@ -25,9 +24,10 @@ "plenary.nvim": { "branch": "master", "commit": "f7adfc4b3f4f91aab6caebf42b3682945fbc35be" }, "ripgrep": { "branch": "master", "commit": "3ad0e83471588d8802d5747d0cc9accec76f7ccf" }, "rnvimr": { "branch": "main", "commit": "3c41af742a61caf74a9f83fb82b9ed03ef13b880" }, - "sniprun": { "branch": "master", "commit": "97daa506e2faa3939e0491642103635f9d22cd04" }, + "snap": { "branch": "main", "commit": "c0bcae835facb945c25073d233c15dbfeb7adc5e" }, "substitute.nvim": { "branch": "main", "commit": "17ffaeb5a1dc2dbef39cf0865d8a4b6000836714" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, "telescope.nvim": { "branch": "master", "commit": "6312868392331c9c0f22725041f1ec2bef57c751" }, - "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, + "yanky.nvim": { "branch": "main", "commit": "79338563e85a868e59cda02c51b54d90a5514a12" } } \ No newline at end of file diff --git a/lua/keybindings/keymap.lua b/lua/keybindings/keymap.lua index 9cb7d6f..48963f6 100644 --- a/lua/keybindings/keymap.lua +++ b/lua/keybindings/keymap.lua @@ -1,3 +1,7 @@ +-- Yanky + + +-- Leap vim.keymap.set('n', 'z', '(leap)') vim.keymap.set('n', 'Z', '(leap-from-window)') vim.keymap.set({ 'x', 'o' }, 'z', '(leap-forward)') @@ -42,15 +46,26 @@ vim.api.nvim_create_autocmd('TextYankPost', { desc = 'Hightlight selection on yank', pattern = '*', callback = function() - vim.highlight.on_yank { higroup = 'IncSearch', timeout = 200 } + vim.highlight.on_yank { higroup = 'IncSearch', timeout = 50 } end, }) - -- Telescope bindings local builtin = require('telescope.builtin') vim.keymap.set('n', 'f', builtin.find_files, {}) vim.keymap.set('n', 'o', builtin.live_grep, {}) vim.keymap.set('n', 'b', builtin.buffers, {}) +vim.keymap.set('n', 'p', builtin.commands, {}) +vim.keymap.set('n', 'y', ':Telescope yank_history', {}) +vim.keymap.set('n', 'gc', builtin.git_commits, {}) +vim.keymap.set('n', 'gs', builtin.git_status, {}) +vim.keymap.set('n', 'gf', builtin.git_files, {}) +vim.keymap.set('n', '7', builtin.current_buffer_fuzzy_find, {}) + + +-- Bindings for save and quit +vim.api.nvim_set_keymap('n', 'w', ':w', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'q', ':q', {}) + -- Bindings for save and quit diff --git a/lua/plugin/auto_session.lua b/lua/plugin/auto_session.lua new file mode 100644 index 0000000..a378662 --- /dev/null +++ b/lua/plugin/auto_session.lua @@ -0,0 +1,4 @@ +require("auto-session").setup { + log_level = "error", + auto_session_suppress_dirs = { "~/", "~/Projects", "~/Downloads", "/"}, +} diff --git a/lua/plugin/autoclose.lua b/lua/plugin/autoclose.lua deleted file mode 100644 index 82ca4be..0000000 --- a/lua/plugin/autoclose.lua +++ /dev/null @@ -1,7 +0,0 @@ -require("autoclose").setup({ - keys = { - ["$"] = { escape = true, close = true, pair = "$$", disabled_filetypes = { "haskell", "bash", "php" } }, - ["'"] = { escape = true, close = true, pair = "''", disabled_filetypes = { "markdown" } }, - ["`"] = { escape = true, close = true, pair = "``", disabled_filetypes = { "markdown" } }, - }, -}) diff --git a/lua/plugin/cmp.lua b/lua/plugin/cmp.lua index ab84d34..2500e47 100644 --- a/lua/plugin/cmp.lua +++ b/lua/plugin/cmp.lua @@ -32,3 +32,10 @@ cmp.setup({ end, }, }) + +-- If you want insert `(` after select function or method item +local cmp_autopairs = require('nvim-autopairs.completion.cmp') +cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done() +) diff --git a/lua/plugin/gitsigns.lua b/lua/plugin/gitsigns.lua new file mode 100644 index 0000000..c4ee9b8 --- /dev/null +++ b/lua/plugin/gitsigns.lua @@ -0,0 +1,45 @@ +require('gitsigns').setup{ + 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) + + map('n', '[c', function() + if vim.wo.diff then + vim.cmd.normal({'[c', bang = true}) + else + gitsigns.nav_hunk('prev') + end + end) + + -- Actions + map('n', 'hs', gitsigns.stage_hunk) + map('n', 'hr', gitsigns.reset_hunk) + map('v', 'hs', function() gitsigns.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end) + map('v', 'hr', function() gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end) + map('n', 'hS', gitsigns.stage_buffer) + map('n', 'hu', gitsigns.undo_stage_hunk) + map('n', 'hR', gitsigns.reset_buffer) + map('n', 'hp', gitsigns.preview_hunk) + map('n', 'hb', function() gitsigns.blame_line{full=true} end) + map('n', 'tb', gitsigns.toggle_current_line_blame) + map('n', 'hd', gitsigns.diffthis) + map('n', 'hD', function() gitsigns.diffthis('~') end) + map('n', 'td', gitsigns.toggle_deleted) + + map({'o', 'x'}, 'ih', ':Gitsigns select_hunk') + end +} diff --git a/lua/plugin/snap.lua b/lua/plugin/snap.lua new file mode 100644 index 0000000..af35c87 --- /dev/null +++ b/lua/plugin/snap.lua @@ -0,0 +1,7 @@ +local snap = require'snap' +snap.maps { + {"f", snap.config.file {producer = "ripgrep.file"}}, + {"b", snap.config.file {producer = "vim.buffer"}}, + -- {"fo", snap.config.file {producer = "vim.oldfile"}}, + {"g", snap.config.vimgrep {}}, +} diff --git a/lua/plugin/telescope.lua b/lua/plugin/telescope.lua index 0cdab16..71c130f 100644 --- a/lua/plugin/telescope.lua +++ b/lua/plugin/telescope.lua @@ -1,4 +1,5 @@ local telescope = require('telescope') +telescope.load_extension("yank_history") telescope.setup { @@ -13,7 +14,8 @@ telescope.setup { }, pickers = { find_files = { - hidden = true + hidden = true, + theme = "dropdown" } } } diff --git a/lua/plugin/yanky.lua b/lua/plugin/yanky.lua new file mode 100644 index 0000000..9af4d48 --- /dev/null +++ b/lua/plugin/yanky.lua @@ -0,0 +1,13 @@ +require("yanky").setup({ + ring = { + history_length = 100, + storage = "shada", + sync_with_numbered_registers = true, + cancel_event = "update", + ignore_registers = { "_" }, + update_register_on_cycle = false, + }, + system_clipboard = { + sync_with_ring = true, + }, +}) diff --git a/lua/plugins.lua b/lua/plugins.lua index 28efd63..fe4812a 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,6 +1,22 @@ return { { - 'm4xshen/autoclose.nvim', + "gbprod/yanky.nvim", + }, + { + 'lewis6991/gitsigns.nvim' + }, + { + 'windwp/nvim-autopairs', + event = "InsertEnter", + config = true + -- use opts = {} for passing setup options + -- this is equalent to setup({}) function + }, + { + 'rmagatti/auto-session', + }, + { + "camspiers/snap", }, { "Mofiqul/dracula.nvim" @@ -35,10 +51,6 @@ return { { 'hrsh7th/nvim-cmp' }, - { - "folke/neoconf.nvim", - cmd = "Neoconf" - }, { "lukas-reineke/indent-blankline.nvim", main = "ibl", @@ -52,14 +64,16 @@ return { 'nvim-telescope/telescope-fzf-native.nvim', build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }, - { "junegunn/fzf" }, + { + "junegunn/fzf" + }, { "L3MON4D3/LuaSnip", version = "v2.*", dependencies = { "rafamadriz/friendly-snippets", - "molleweide/LuaSnip-snippets.nvim", - "saadparwaiz1/cmp_luasnip" + "molleweide/LuaSnip-snippets.nvim", + "saadparwaiz1/cmp_luasnip" }, build = "make install_jsregexp" }, @@ -91,7 +105,7 @@ return { "nvim-lua/plenary.nvim", }, keys = { - { "gg", "LazyGit", desc = "LazyGit" } + { "gg", "LazyGit", desc = "LazyGit" } } }, {