diff --git a/init.lua b/init.lua index d4b64cea..0d857673 100644 --- a/init.lua +++ b/init.lua @@ -93,7 +93,9 @@ vim.g.maplocalleader = ' ' -- See `:help vim.opt` -- NOTE: You can change these options as you wish! -- For more options, you can see `:help option-list` - +-- autoindent if possible when entering a new line in a block +vim.opt.autowriteall = false +vim.opt.smartindent = true -- Make line numbers default vim.opt.number = true -- You can also add relative line numbers, to help with jumping. @@ -166,6 +168,9 @@ vim.opt.guicursor = { } -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` +-- recenter to middle after page jump +vim.keymap.set('n', '', 'zz') +vim.keymap.set('n', '', 'zz') -- Clear highlights on search when pressing in normal mode -- See `:help hlsearch` @@ -188,6 +193,21 @@ vim.keymap.set('n', '', 'echo "Use l to move!!"') vim.keymap.set('n', '', 'echo "Use k to move!!"') vim.keymap.set('n', '', 'echo "Use j to move!!"') +vim.keymap.set('i', '', 'echo "Use h to move!!"') +vim.keymap.set('i', '', 'echo "Use l to move!!"') +vim.keymap.set('i', '', 'echo "Use k to move!!"') +vim.keymap.set('i', '', 'echo "Use j to move!!"') + +vim.keymap.set('v', '', 'echo "Use h to move!!"') +vim.keymap.set('v', '', 'echo "Use l to move!!"') +vim.keymap.set('v', '', 'echo "Use k to move!!"') +vim.keymap.set('v', '', 'echo "Use j to move!!"') + +vim.keymap.set('c', '', 'echo "Use h to move!!"') +vim.keymap.set('c', '', 'echo "Use l to move!!"') +vim.keymap.set('c', '', 'echo "Use k to move!!"') +vim.keymap.set('c', '', 'echo "Use j to move!!"') + -- Keybinds to make split navigation easier. -- Use CTRL+ to switch between windows -- @@ -268,30 +288,6 @@ require('lazy').setup({ { '', 'TmuxNavigatePrevious' }, }, }, - { - 'stevearc/oil.nvim', - ---@module 'oil' - ---@type oil.SetupOpts - opts = {}, - -- Optional dependencies - dependencies = { { 'echasnovski/mini.icons', opts = {} } }, - -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons - -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. - lazy = false, - config = function() - require('oil').setup { - vim.keymap.set('n', '-', 'Oil', { desc = 'Open parent directory' }), - } - end, - }, - { - 'nvimdev/dashboard-nvim', - event = 'VimEnter', - config = function() - require('dashboard').setup {} - end, - dependencies = { { 'nvim-tree/nvim-web-devicons' } }, - }, -- Alternatively, use `config = function() ... end` for full control over the configuration. -- If you prefer to call `setup` explicitly, use: -- { @@ -496,7 +492,66 @@ require('lazy').setup({ end, { desc = '[S]earch [N]eovim files' }) end, }, + { + 'ThePrimeagen/harpoon', + branch = 'harpoon2', + dependencies = { 'nvim-lua/plenary.nvim', 'nvim-telescope/telescope.nvim' }, + config = function() + local harpoon = require 'harpoon' + harpoon:setup() + vim.keymap.set('n', 'a', function() + harpoon:list():add() + end, { desc = '[A]dd to Harpoon list' }) + vim.keymap.set('n', 'e', function() + harpoon.ui:toggle_quick_menu(harpoon:list()) + end, { desc = 'Toggle Harpoon m[E]nu' }) + vim.keymap.set('n', '1', function() + harpoon:list():select(1) + end, { desc = 'Harpoon 1' }) + vim.keymap.set('n', '2', function() + harpoon:list():select(2) + end, { desc = 'Harpoon 2' }) + vim.keymap.set('n', '3', function() + harpoon:list():select(3) + end, { desc = 'Harpoon 3' }) + vim.keymap.set('n', '4', function() + harpoon:list():select(4) + end, { desc = 'Harpoon 4' }) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set('n', 'p', function() + harpoon:list():prev() + end, { desc = '[P]revious Harpoon' }) + vim.keymap.set('n', 'n', function() + harpoon:list():next() + end, { desc = '[N]ext Harpoon' }) + + -- basic telescope configuration + 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', '', function() + toggle_telescope(harpoon:list()) + end, { desc = 'Open harpoon window' }) + end, + }, -- LSP Plugins { -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins @@ -797,10 +852,14 @@ require('lazy').setup({ formatters_by_ft = { lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- - -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, + -- python = { 'ruff' }, + javascript = { 'prettier' }, + typescript = { 'prettier' }, + javascriptreact = { 'prettier' }, + typescriptreact = { 'prettier' }, + css = { 'prettier' }, + html = { 'prettier' }, + json = { 'prettier' }, }, }, }, @@ -914,45 +973,13 @@ require('lazy').setup({ vim.cmd 'colorscheme kanagawa' end, }, - - -- 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', + { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, 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' - - statusline.setup { use_icons = false } - - -- 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 + require('lualine').setup { + theme = 'base16', + } end, }, { -- Highlight, edit, and navigate code @@ -997,7 +1024,90 @@ require('lazy').setup({ -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects }, + { + 'nvim-treesitter/nvim-treesitter-context', + }, + { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + config = true, + -- use opts = {} for passing setup options + -- this is equivalent to setup({}) function + }, + { + 'folke/snacks.nvim', + priority = 1000, + lazy = false, + }, + { + 'mikavilpas/yazi.nvim', + event = 'VeryLazy', + dependencies = { + 'folke/snacks.nvim', + }, + keys = { + -- 👇 in this section, choose your own keymappings! + { + '-', + mode = { 'n', 'v' }, + 'Yazi', + desc = 'Open yazi at the current file', + }, + { + -- Open in the current working directory + 'cw', + 'Yazi cwd', + desc = "Open the file manager in nvim's working directory", + }, + { + '', + 'Yazi toggle', + desc = 'Resume the last yazi session', + }, + }, + opts = { + -- if you want to open yazi instead of netrw, see below for more info + open_for_directories = false, + keymaps = { + show_help = '', + }, + }, + -- 👇 if you use `open_for_directories=true`, this is recommended + init = function() + -- More details: https://github.com/mikavilpas/yazi.nvim/issues/802 + -- vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + end, + }, + { + 'goolord/alpha-nvim', + config = function() + local alpha = require 'alpha' + local dashboard = require 'alpha.themes.dashboard' + dashboard.section.header.val = { + ' ', + ' ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ', + ' ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ', + ' ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ', + ' ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ', + ' ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ', + ' ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ', + ' ', + } + -- Set menu + dashboard.section.buttons.val = { + dashboard.button('e', ' > New file', ':ene startinsert '), + dashboard.button('f', ' > Find file', ':cd $HOME/dev | Telescope find_files'), + dashboard.button('r', ' > Recent', ':Telescope oldfiles'), + dashboard.button('s', ' > Settings', ':e $MYVIMRC | :cd %:p:h | split . | wincmd k | pwd'), + dashboard.button('q', ' > Quit NVIM', ':qa'), + } + + -- Send config to alpha + alpha.setup(dashboard.opts) + end, + }, -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the -- init.lua. If you want these files, they are in the repository, so you can just download them and -- place them in the correct locations.