From af22c7ff3202af65b11eabb1b696297807e3f57f Mon Sep 17 00:00:00 2001 From: Dino Danic Date: Wed, 26 Mar 2025 15:26:42 +0100 Subject: [PATCH] config --- init.lua | 12 +++++-- lua/custom/keymaps.lua | 1 - lua/custom/macros.lua | 2 ++ lua/custom/{settings.lua => options.lua} | 24 ++++++++++++- lua/custom/plugins/avante.lua | 2 +- lua/custom/plugins/harpoon.lua | 45 ++++++++++++++++++++++++ lua/custom/plugins/init.lua | 3 +- 7 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 lua/custom/macros.lua rename lua/custom/{settings.lua => options.lua} (74%) create mode 100644 lua/custom/plugins/harpoon.lua diff --git a/init.lua b/init.lua index a1ea8ed6..59883dc6 100644 --- a/init.lua +++ b/init.lua @@ -27,9 +27,10 @@ vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal vim.g.have_nerd_font = true -require 'custom.settings' +require 'custom.options' require 'custom.keymaps' require 'custom.basic-autocommands' +require 'custom.macros' -- [[ Install `lazy.nvim` plugin manager ]] local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' @@ -112,6 +113,7 @@ require('lazy').setup({ { 's', group = '[S]earch' }, { 'w', group = '[W]save' }, { 't', group = '[T]oggle' }, + { 'o', group = 'Harp[O]on' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, }, }, @@ -154,6 +156,11 @@ require('lazy').setup({ [''] = 'to_fuzzy_refine', [''] = 'move_selection_next', [''] = 'move_selection_previous', + [''] = 'delete_buffer', + }, + n = { + ['d'] = require('telescope.actions').delete_buffer, + ['q'] = require('telescope.actions').close, }, }, }, @@ -202,7 +209,8 @@ require('lazy').setup({ 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' }) + -- vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + vim.keymap.set('n', '', 'Telescope buffers sort_mru=true sort_lastused=true theme=ivy', { desc = '[ ] Find existing buffers' }) -- It's also possible to pass additional configuration options. -- See `:help telescope.builtin.live_grep()` for information about particular keys diff --git a/lua/custom/keymaps.lua b/lua/custom/keymaps.lua index 97998ef6..e03535ac 100644 --- a/lua/custom/keymaps.lua +++ b/lua/custom/keymaps.lua @@ -1,4 +1,3 @@ --- [[ Basic Keymaps ]] vim.keymap.set('n', '', 'nohlsearch') vim.keymap.set('n', 'h', 'nohlsearch') vim.keymap.set('i', 'jj', '') diff --git a/lua/custom/macros.lua b/lua/custom/macros.lua new file mode 100644 index 00000000..53d23e44 --- /dev/null +++ b/lua/custom/macros.lua @@ -0,0 +1,2 @@ +-- console.log("cursor: , cursor) +vim.fn.setreg('l', 'yiwoconsole.log("jjpa:" , jjpa);jj') diff --git a/lua/custom/settings.lua b/lua/custom/options.lua similarity index 74% rename from lua/custom/settings.lua rename to lua/custom/options.lua index ea605fe1..199cd846 100644 --- a/lua/custom/settings.lua +++ b/lua/custom/options.lua @@ -37,7 +37,7 @@ vim.opt.smartcase = true vim.opt.signcolumn = 'yes' -- Decrease update time -vim.opt.updatetime = 250 +vim.opt.updatetime = 50 -- Decrease mapped sequence wait time vim.opt.timeoutlen = 300 @@ -65,3 +65,25 @@ vim.opt.scrolloff = 10 -- instead raise a dialog asking if you wish to save the current file(s) -- See `:help 'confirm'` vim.opt.confirm = true + +vim.opt.relativenumber = true + +-- set to 0 becouse of empty line +vim.opt.cmdheight = 0 + +-- set cmd height when entering command mode +vim.api.nvim_command 'autocmd CmdlineEnter * set cmdheight=1' +vim.api.nvim_command 'autocmd CmdlineLeave * set cmdheight=0' +vim.api.nvim_command 'autocmd RecordingEnter * set cmdheight=1' +vim.api.nvim_command 'autocmd RecordingLeave * set cmdheight=0' + +-- auto resize screen +-- Create an autocommand group for auto resizing +vim.api.nvim_create_augroup('autoequalize', { clear = true }) + +vim.api.nvim_create_autocmd({ 'VimEnter', 'VimResized' }, { + callback = function() + vim.cmd 'wincmd =' + end, + group = 'autoequalize', +}) diff --git a/lua/custom/plugins/avante.lua b/lua/custom/plugins/avante.lua index fd21d9aa..1eb59b04 100644 --- a/lua/custom/plugins/avante.lua +++ b/lua/custom/plugins/avante.lua @@ -8,7 +8,7 @@ return { provider = 'openai', openai = { endpoint = 'https://api.openai.com/v1', - model = 'gpt-4o-mini', -- your desired model (or use gpt-4o, etc.) + model = 'gpt-4o', -- your desired model (or use gpt-4o, etc.) timeout = 30000, -- Timeout in milliseconds, increase this for reasoning models temperature = 0, max_completion_tokens = 8192, -- Increase this to include reasoning tokens (for reasoning models) diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000..1c8761f3 --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,45 @@ +return { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'nvim-lua/plenary.nvim' }, + config = function() + local harpoon = require 'harpoon' + + -- REQUIRED + harpoon:setup() + -- REQUIRED + + vim.keymap.set('n', 'oa', function() + harpoon:list():add() + end, { desc = 'Add File' }) + + vim.keymap.set('n', 'oi', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end, { desc = 'Open L[I]st' }) + + vim.keymap.set('n', '1', function() + harpoon:list():select(1) + end, { desc = 'Select [1]' }) + + vim.keymap.set('n', '2', function() + harpoon:list():select(2) + end, { desc = 'Select [2]' }) + + vim.keymap.set('n', '3', function() + harpoon:list():select(3) + end, { desc = 'Select [3]' }) + + vim.keymap.set('n', '4', function() + harpoon:list():select(4) + end, { desc = 'Select [4]' }) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set('n', 'oj', function() + harpoon:list():prev() + end, { desc = 'Previus File' }) + + vim.keymap.set('n', 'ok', function() + harpoon:list():next() + end, { desc = 'Next File' }) + end, +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 9ad0efa2..4aef103b 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -14,6 +14,7 @@ return { }, -------------------------------------UTILS------------------------------------- require 'custom.plugins.avante', + -- i use this so i can comment in TS components etc 'JoosepAlviste/nvim-ts-context-commentstring', { 'numToStr/Comment.nvim', @@ -59,7 +60,7 @@ return { 'y', mode = { 'n', 'v' }, 'Yazi', - desc = 'Open yazi at the current file', + desc = 'Open [Y]azi at the current file', }, }, opts = {