From 3bc84872ecfded61b67e193555e52ca2ec1f9197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Fri, 15 Nov 2024 20:27:03 +0100 Subject: [PATCH] powerups --- after/plugin/telescope.lua | 33 +++++++++ lazy-lock.json | 10 ++- lua/zak/plugins.lua | 145 +++++++++++++++++++++++++++++++++++++ lua/zak/remap.lua | 28 +++++-- lua/zak/set.lua | 35 +++++++++ 5 files changed, 244 insertions(+), 7 deletions(-) diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index ba3769f..b64b6d6 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -7,3 +7,36 @@ vim.keymap.set('n', '', builtin.buffers, {}) vim.keymap.set('n', 'ps', function() builtin.grep_string({ search = vim.fn.input("Grep > ") }) end) +vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) +vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) +vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) +vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) +vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) +vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) +vim.keymap.set('n', '/', builtin.buffers, { desc = '[ ] Find existing buffers' }) + +-- Slightly advanced example of overriding default behavior and theme +vim.keymap.set('n', '', function() +-- You can pass additional configuration to Telescope to change the theme, layout, etc. +builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, +}) +end, { desc = '[/] Fuzzily search in current buffer' }) + +-- It's also possible to pass additional configuration options. +-- See `:help telescope.builtin.live_grep()` for information about particular keys +vim.keymap.set('n', 's/', function() +builtin.live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', +} +end, { desc = '[S]earch [/] in Open Files' }) + +-- Shortcut for searching your Neovim configuration files +vim.keymap.set('n', 'sn', function() +builtin.find_files { cwd = vim.fn.stdpath 'config' } +end, { desc = '[S]earch [N]eovim files' }) diff --git a/lazy-lock.json b/lazy-lock.json index 819deae..4fefa53 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,17 +1,22 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "LuaSnip": { "branch": "master", "commit": "2737edc9e674e537dc0a97e3405658d57d2d31ed" }, + "avante.nvim": { "branch": "main", "commit": "7bab283616b3bddc92c669e554114fad850844f1" }, "catppuccin": { "branch": "main", "commit": "637d99e638bc6f1efedac582f6ccab08badac0c6" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "copilot.lua": { "branch": "master", "commit": "f8d8d872bb319f640d5177dad5fbf01f7a16d7d0" }, + "dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" }, "harpoon": { "branch": "master", "commit": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3" }, + "img-clip.nvim": { "branch": "main", "commit": "28a32d811d69042f4fa5c3d5fa35571df2bc1623" }, "lazy.nvim": { "branch": "main", "commit": "b1134ab82ee4279e31f7ddf7e34b2a99eb9b7bc9" }, "lsp-zero.nvim": { "branch": "v3.x", "commit": "ab2a3413646fedd77aa0eab4214a6473e62f6a64" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.nvim": { "branch": "main", "commit": "7b4d5d48b6b5a75009d63f8f3e4ef4819b7e8139" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, @@ -20,8 +25,11 @@ "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "render-markdown.nvim": { "branch": "main", "commit": "82184c4a3c3580a7a859b2cb7e58f16c10fd29ef" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, "telescope.nvim": { "branch": "master", "commit": "d829aa64059001ee7b2c8c8aa9c4e6df0b17d893" }, + "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, "undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" }, - "vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" } + "vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" }, + "which-key.nvim": { "branch": "main", "commit": "68e37e12913a66b60073906f5d3f14dee0de19f2" } } diff --git a/lua/zak/plugins.lua b/lua/zak/plugins.lua index e267cae..eaf09fc 100644 --- a/lua/zak/plugins.lua +++ b/lua/zak/plugins.lua @@ -13,6 +13,98 @@ end vim.opt.rtp:prepend(lazypath) return require('lazy').setup({ + -- Highlight todo, notes, etc in comments + { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, + + { -- Collection of various small independent plugins/modules + 'echasnovski/mini.nvim', + config = function() + -- Better Around/Inside textobjects + -- + -- Examples: + -- - va) - [V]isually select [A]round [)]paren + -- - yinq - [Y]ank [I]nside [N]ext [Q]uote + -- - ci' - [C]hange [I]nside [']quote + require('mini.ai').setup { n_lines = 500 } + + -- Add/delete/replace surroundings (brackets, quotes, etc.) + -- + -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren + -- - sd' - [S]urround [D]elete [']quotes + -- - sr)' - [S]urround [R]eplace [)] ['] + require('mini.surround').setup() + + -- Simple and easy statusline. + -- You could remove this setup call if you don't like it, + -- and try some other statusline plugin + local statusline = require 'mini.statusline' + -- set use_icons to true if you have a Nerd Font + statusline.setup { use_icons = vim.g.have_nerd_font } + + -- You can configure sections in the statusline by overriding their + -- default behavior. For example, here we set the section for + -- cursor location to LINE:COLUMN + ---@diagnostic disable-next-line: duplicate-set-field + statusline.section_location = function() + return '%2l:%-2v' + end + + -- ... and there is more! + -- Check out: https://github.com/echasnovski/mini.nvim + end, + }, { -- Useful plugin to show you pending keybinds. + 'folke/which-key.nvim', + event = 'VimEnter', -- Sets the loading event to 'VimEnter' + opts = { + icons = { + -- set icon mappings to true if you have a Nerd Font + mappings = vim.g.have_nerd_font, + -- If you are using a Nerd Font: set icons.keys to an empty table which will use the + -- default whick-key.nvim defined Nerd Font icons, otherwise define a string table + keys = vim.g.have_nerd_font and {} or { + Up = ' ', + Down = ' ', + Left = ' ', + Right = ' ', + C = ' ', + M = ' ', + D = ' ', + S = ' ', + CR = ' ', + Esc = ' ', + ScrollWheelDown = ' ', + ScrollWheelUp = ' ', + NL = ' ', + BS = ' ', + Space = ' ', + Tab = ' ', + F1 = '', + F2 = '', + F3 = '', + F4 = '', + F5 = '', + F6 = '', + F7 = '', + F8 = '', + F9 = '', + F10 = '', + F11 = '', + F12 = '', + }, + }, + + -- Document existing key chains + spec = { + { 'c', group = '[C]ode', mode = { 'n', 'x' } }, + { 'd', group = '[D]ocument' }, + { 'r', group = '[R]ename' }, + { 's', group = '[S]earch' }, + { 'w', group = '[W]orkspace' }, + { 't', group = '[T]oggle' }, + { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + }, + }, + }, { 'nvim-lualine/lualine.nvim', dependencies = { 'nvim-tree/nvim-web-devicons' } @@ -78,4 +170,57 @@ return require('lazy').setup({ 'L3MON4D3/LuaSnip', } }, + { + "yetone/avante.nvim", + event = "VeryLazy", + lazy = false, + version = false, -- set this if you want to always pull the latest change + opts = { + -- add any opts here + }, + -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` + -- build = "make", + build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false", -- for windows + dependencies = { + "nvim-treesitter/nvim-treesitter", + "stevearc/dressing.nvim", + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + --- The below dependencies are optional, + "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons + "zbirenbaum/copilot.lua", -- for providers='copilot' + { + -- support for image pasting + "HakonHarnes/img-clip.nvim", + event = "VeryLazy", + opts = { + -- recommended settings + default = { + embed_image_as_base64 = false, + prompt_for_file_name = false, + drag_and_drop = { + insert_mode = true, + }, + -- required for Windows users + use_absolute_path = true, + }, + }, + }, + { + -- Make sure to set this up properly if you have lazy=true + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { "markdown", "Avante" }, + }, + ft = { "markdown", "Avante" }, + }, + }, + config = function() + require("avante").setup({ + windows = { + position = "left" + }, + }) + end, + } }) diff --git a/lua/zak/remap.lua b/lua/zak/remap.lua index 302e381..cba9c3e 100644 --- a/lua/zak/remap.lua +++ b/lua/zak/remap.lua @@ -59,13 +59,29 @@ function toggleTerminal() if vim.api.nvim_get_current_buf() == term_buf then -- ToggleZen() vim.cmd("close") - vim.cmd("wincmd w") + vim.cmd("wincmd w") else - -- Otherwise, open the terminal buffer in a split at the bottom - vim.cmd("wincmd w") - vim.cmd("belowright split | resize " .. math.floor(vim.o.lines * 0.99)) - vim.api.nvim_set_current_buf(term_buf) - vim.cmd("startinsert") + -- Check if terminal buffer is visible in any window + local term_win = nil + for _, win in ipairs(vim.api.nvim_list_wins()) do + if vim.api.nvim_win_get_buf(win) == term_buf then + term_win = win + break + end + end + + if term_win then + -- Terminal is visible, focus and close it + vim.api.nvim_set_current_win(term_win) + vim.cmd("close") + vim.cmd("wincmd w") + else + -- Otherwise, open the terminal buffer in a split at the bottom + vim.cmd("wincmd w") + vim.cmd("belowright split | resize " .. math.floor(vim.o.lines * 0.99)) + vim.api.nvim_set_current_buf(term_buf) + vim.cmd("startinsert") + end -- ToggleZen() end else diff --git a/lua/zak/set.lua b/lua/zak/set.lua index cc5987b..b3cbcc7 100644 --- a/lua/zak/set.lua +++ b/lua/zak/set.lua @@ -18,6 +18,9 @@ vim.opt.undodir = "C:/Users/zakla/.undodir" vim.opt.undofile = true -- vim.opt.shellcmdflag = "" -- vim.opt.clipboard = 'unnamedplus' +vim.schedule(function() + vim.opt.clipboard = 'unnamedplus' +end) vim.opt.hlsearch = false vim.opt.incsearch = true @@ -27,6 +30,38 @@ vim.opt.signcolumn = "yes" vim.opt.isfname:append("@-@") vim.opt.updatetime = 50 vim.opt.colorcolumn = "120" +-- views can only be fully collapsed with the global statusline +-- vim.opt.laststatus = 3 +-- Make line numbers default +vim.opt.number = true +vim.opt.mouse = 'a' + +-- Don't show the mode, since it's already in the status line +vim.opt.showmode = false + +-- Sync clipboard between OS and Neovim. +-- Schedule the setting after `UiEnter` because it can increase startup-time. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.schedule(function() + vim.opt.clipboard = 'unnamedplus' +end) + +vim.opt.breakindent = true +vim.opt.splitright = true +vim.opt.splitbelow = true +vim.opt.list = true +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } +vim.opt.inccommand = 'split' +vim.opt.cursorline = true + +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) vim.cmd [[ augroup TerminalStuff