From 938c52c9b4b71b992ad2ed194f5074d41c5ba7e8 Mon Sep 17 00:00:00 2001 From: Andre Schaf Date: Fri, 22 Mar 2024 15:54:21 +0100 Subject: [PATCH] added harpoon --- lua/plugin/harpoon.lua | 51 +++++++++++++++ lua/plugins.lua | 145 ++++++++++++++++++++++------------------- lua/remap.lua | 8 ++- lua/set.lua | 1 + 4 files changed, 135 insertions(+), 70 deletions(-) create mode 100644 lua/plugin/harpoon.lua diff --git a/lua/plugin/harpoon.lua b/lua/plugin/harpoon.lua new file mode 100644 index 0000000..c478225 --- /dev/null +++ b/lua/plugin/harpoon.lua @@ -0,0 +1,51 @@ +local harpoon = require("harpoon") + +harpoon:setup({}) + +local conf = require("telescope.config").values +local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require("telescope.pickers").new({}, { + prompt_title = "Harpoon", + finder = require("telescope.finders").new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }):find() +end + +vim.keymap.set("n", "kk", function() toggle_telescope(harpoon:list()) end, + { desc = "Open harpoon window" }) + +vim.keymap.set("n", "a", function() harpoon:list():append() end) + +vim.keymap.set("n", "1", function() harpoon:list():select(1) end) +vim.keymap.set("n", "2", function() harpoon:list():select(2) end) +vim.keymap.set("n", "3", function() harpoon:list():select(3) end) +vim.keymap.set("n", "4", function() harpoon:list():select(4) end) +vim.keymap.set("n", "5", function() harpoon:list():select(5) end) +vim.keymap.set("n", "6", function() harpoon:list():select(6) end) +vim.keymap.set("n", "7", function() harpoon:list():select(7) end) +vim.keymap.set("n", "8", function() harpoon:list():select(8) end) +vim.keymap.set("n", "9", function() harpoon:list():select(9) end) + +vim.keymap.set("n", "d1", function() harpoon:list():removeAt(1) end) +vim.keymap.set("n", "d2", function() harpoon:list():removeAt(2) end) +vim.keymap.set("n", "d3", function() harpoon:list():removeAt(3) end) +vim.keymap.set("n", "d4", function() harpoon:list():removeAt(4) end) +vim.keymap.set("n", "d5", function() harpoon:list():removeAt(5) end) +vim.keymap.set("n", "d6", function() harpoon:list():removeAt(6) end) +vim.keymap.set("n", "d7", function() harpoon:list():removeAt(7) end) +vim.keymap.set("n", "d8", function() harpoon:list():removeAt(8) end) +vim.keymap.set("n", "d9", function() harpoon:list():removeAt(9) end) + + + +-- Toggle previous & next buffers stored within Harpoon list +vim.keymap.set("n", "", function() harpoon:list():prev() end) +vim.keymap.set("n", "", function() harpoon:list():next() end) diff --git a/lua/plugins.lua b/lua/plugins.lua index fce0ffb..8bd1445 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,85 +1,96 @@ local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) end vim.opt.rtp:prepend(lazypath) require("lazy").setup({ - { - 'nvim-telescope/telescope.nvim', - tag = '0.1.2', - dependencies = { 'nvim-lua/plenary.nvim' } - }, - -- themes - { 'gruvbox-community/gruvbox' }, - -- gitsigns - { 'lewis6991/gitsigns.nvim' }, - -- tpope commentary - { 'tpope/vim-commentary' }, + { + 'nvim-telescope/telescope.nvim', + tag = '0.1.2', + dependencies = { 'nvim-lua/plenary.nvim' } + }, + -- themes + { 'gruvbox-community/gruvbox' }, + -- gitsigns + { 'lewis6991/gitsigns.nvim' }, + -- tpope commentary + { 'tpope/vim-commentary' }, - { - "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" - }, - { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v2.x', - dependencies = { - -- LSP Support - { 'neovim/nvim-lspconfig' }, -- Required - { -- Optional - 'williamboman/mason.nvim', - build = function() - pcall(vim.cmd, 'MasonUpdate') - end, - }, - { 'williamboman/mason-lspconfig.nvim' }, -- Optional - -- formatter - { - 'stevearc/conform.nvim', - opts = {}, - }, - -- Autocompletion - { 'hrsh7th/nvim-cmp' }, -- Required - { 'hrsh7th/cmp-nvim-lsp' }, -- Required - { 'L3MON4D3/LuaSnip' }, -- Required - { 'nvim-cmp' }, - -- { 'github/copilot.vim' }, - { 'mhinz/vim-startify' }, - } - }, - { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + { + "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, - lazy = true, - }, - { - "kdheepak/lazygit.nvim", - -- optional for floating window border decoration - dependencies = { - "nvim-lua/plenary.nvim", + { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v2.x', + dependencies = { + -- LSP Support + { 'neovim/nvim-lspconfig' }, -- Required + { -- Optional + 'williamboman/mason.nvim', + build = function() + pcall(vim.cmd, 'MasonUpdate') + end, + }, + { 'williamboman/mason-lspconfig.nvim' }, -- Optional + -- formatter + { + 'stevearc/conform.nvim', + opts = {}, + }, + -- Autocompletion + { 'hrsh7th/nvim-cmp' }, -- Required + { 'hrsh7th/cmp-nvim-lsp' }, -- Required + { 'L3MON4D3/LuaSnip' }, -- Required + { 'nvim-cmp' }, + -- { 'rcarriga/nvim-dap-ui', dependencies = { 'mfussenegger/nvim-dap' } }, + } }, - }, + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + lazy = true, + }, + { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim" } + }, + { + "kdheepak/lazygit.nvim", + -- optional for floating window border decoration + dependencies = { + "nvim-lua/plenary.nvim", + }, + }, + { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + ft = { "markdown" }, + build = function() vim.fn["mkdp#util#install"]() end, + }, + { 'github/copilot.vim' }, + { 'mhinz/vim-startify' }, }, opts) local files = vim.split(vim.fn.globpath(vim.fn.stdpath('config') .. '/lua/plugin', '*.lua', true), '\n') for _, f in ipairs(files) do - local name = vim.fn.fnamemodify(f, ':t:r') - require('plugin.' .. name) + local name = vim.fn.fnamemodify(f, ':t:r') + require('plugin.' .. name) end diff --git a/lua/remap.lua b/lua/remap.lua index f3aa2dc..f514566 100644 --- a/lua/remap.lua +++ b/lua/remap.lua @@ -1,5 +1,5 @@ vim.keymap.set("n", ";;", ":Neotree toggle") -vim.keymap.set("n", "kk", ":Neotree reveal") +vim.keymap.set("n", "ll", ":Neotree reveal") -- jk to escape vim.keymap.set("i", "jk", "") @@ -16,10 +16,12 @@ vim.keymap.set("v", "", ":m '<-2gv=gv") vim.keymap.set("n", "", ":bd") -- C-l / C-h to go to nex / previouse buffer -vim.keymap.set("n", "", ":bn") -vim.keymap.set("n", "", ":bp") +vim.keymap.set("n", "", ":bn") +vim.keymap.set("n", "", ":bp") -- leader-t-space 2 to set expandtab, shiftwidth, softtabstop to 2 vim.keymap.set("n", "t2", ":set expandtab shiftwidth=2 softtabstop=2") vim.keymap.set("n", "t4", ":set expandtab shiftwidth=4 softtabstop=4") vim.keymap.set("n", "t", ":set noexpandtab shiftwidth=4 softtabstop=4") +-- LazyGit +vim.keymap.set("n", "gg", ":LazyGit") diff --git a/lua/set.lua b/lua/set.lua index 3bd9f18..2da4ab7 100644 --- a/lua/set.lua +++ b/lua/set.lua @@ -1,3 +1,4 @@ +vim.opt.shadafile = "NONE" vim.opt.nu = true vim.opt.rnu = true