added harpoon

This commit is contained in:
Andre Schaf 2024-03-22 15:54:21 +01:00
parent 0874dcd113
commit 938c52c9b4
4 changed files with 135 additions and 70 deletions

51
lua/plugin/harpoon.lua Normal file
View file

@ -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", "<leader>kk", function() toggle_telescope(harpoon:list()) end,
{ desc = "Open harpoon window" })
vim.keymap.set("n", "<leader>a", function() harpoon:list():append() end)
vim.keymap.set("n", "<leader>1", function() harpoon:list():select(1) end)
vim.keymap.set("n", "<leader>2", function() harpoon:list():select(2) end)
vim.keymap.set("n", "<leader>3", function() harpoon:list():select(3) end)
vim.keymap.set("n", "<leader>4", function() harpoon:list():select(4) end)
vim.keymap.set("n", "<leader>5", function() harpoon:list():select(5) end)
vim.keymap.set("n", "<leader>6", function() harpoon:list():select(6) end)
vim.keymap.set("n", "<leader>7", function() harpoon:list():select(7) end)
vim.keymap.set("n", "<leader>8", function() harpoon:list():select(8) end)
vim.keymap.set("n", "<leader>9", function() harpoon:list():select(9) end)
vim.keymap.set("n", "<leader>d1", function() harpoon:list():removeAt(1) end)
vim.keymap.set("n", "<leader>d2", function() harpoon:list():removeAt(2) end)
vim.keymap.set("n", "<leader>d3", function() harpoon:list():removeAt(3) end)
vim.keymap.set("n", "<leader>d4", function() harpoon:list():removeAt(4) end)
vim.keymap.set("n", "<leader>d5", function() harpoon:list():removeAt(5) end)
vim.keymap.set("n", "<leader>d6", function() harpoon:list():removeAt(6) end)
vim.keymap.set("n", "<leader>d7", function() harpoon:list():removeAt(7) end)
vim.keymap.set("n", "<leader>d8", function() harpoon:list():removeAt(8) end)
vim.keymap.set("n", "<leader>d9", function() harpoon:list():removeAt(9) end)
-- Toggle previous & next buffers stored within Harpoon list
vim.keymap.set("n", "<C-h>", function() harpoon:list():prev() end)
vim.keymap.set("n", "<C-l>", function() harpoon:list():next() end)

View file

@ -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

View file

@ -1,5 +1,5 @@
vim.keymap.set("n", "<leader>;;", ":Neotree toggle<CR>")
vim.keymap.set("n", "<leader>kk", ":Neotree reveal<CR>")
vim.keymap.set("n", "<leader>ll", ":Neotree reveal<CR>")
-- jk to escape
vim.keymap.set("i", "jk", "<Esc>")
@ -16,10 +16,12 @@ vim.keymap.set("v", "<M-k>", ":m '<-2<CR>gv=gv")
vim.keymap.set("n", "<C-x>", ":bd<CR>")
-- C-l / C-h to go to nex / previouse buffer
vim.keymap.set("n", "<C-l>", ":bn<CR>")
vim.keymap.set("n", "<C-h>", ":bp<CR>")
vim.keymap.set("n", "<S-L>", ":bn<CR>")
vim.keymap.set("n", "<S-H>", ":bp<CR>")
-- leader-t-space 2 to set expandtab, shiftwidth, softtabstop to 2
vim.keymap.set("n", "<leader>t<Space>2", ":set expandtab shiftwidth=2 softtabstop=2<CR>")
vim.keymap.set("n", "<leader>t<Space>4", ":set expandtab shiftwidth=4 softtabstop=4<CR>")
vim.keymap.set("n", "<leader>t<Space><Tab>", ":set noexpandtab shiftwidth=4 softtabstop=4<CR>")
-- LazyGit
vim.keymap.set("n", "<leader>gg", ":LazyGit<CR>")

View file

@ -1,3 +1,4 @@
vim.opt.shadafile = "NONE"
vim.opt.nu = true
vim.opt.rnu = true