From a269e21cbcdfc8b847a36bce246345b2c9dc1e2c Mon Sep 17 00:00:00 2001 From: Aadi Rave Date: Sun, 16 Mar 2025 05:17:51 -0400 Subject: [PATCH] decent config ngl --- init.lua | 44 ++-- lua/custom/plugins/init.lua | 422 ++++++++++++++++++++---------------- 2 files changed, 267 insertions(+), 199 deletions(-) diff --git a/init.lua b/init.lua index 105d9fe7..1582af56 100644 --- a/init.lua +++ b/init.lua @@ -196,19 +196,28 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the right win vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` - --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` -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() +-- markdown keybinds +on_attach = + function(bufnr) + local map = vim.keymap.set + local opts = { buffer = bufnr } + map({ 'n', 'i' }, '', 'MDListItemBelow', opts) + map({ 'n', 'i' }, '', 'MDListItemAbove', opts) + map('n', '', 'MDTaskToggle', opts) + map('x', '', ':MDTaskToggle', opts) end, -}) + -- [[ Basic Autocommands ]] + -- See `:help lua-guide-autocommands` + -- Highlight when yanking (copying) text + -- Try it with `yap` in normal mode + -- See `:help vim.highlight.on_yank()` + 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, + }) -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info @@ -486,6 +495,12 @@ require('lazy').setup({ 'hrsh7th/cmp-nvim-lsp', }, config = function() + -- personal setup for bracket autocompletion + + local cmp_autopairs = require 'nvim-autopairs.completion.cmp' + local cmp = require 'cmp' + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + -- Brief aside: **What is LSP?** -- -- LSP is an initialism you've probably heard, but might not understand what it is. @@ -561,6 +576,9 @@ require('lazy').setup({ -- or a suggestion from your LSP for this to activate. map('ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' }) + -- open explorer + map('E', ':NvimTreeOpen', '[E]xplorer') + -- WARN: This is not Goto Definition, this is Goto Declaration. -- For example, in C this would take you to the header. map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') @@ -841,7 +859,7 @@ require('lazy').setup({ -- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.confirm { select = true }, -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index e6842415..92ef4313 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -3,197 +3,247 @@ -- -- See the kickstart.nvim README for more information return { - 'folke/snacks.nvim', - lazy = false, - priority = 1000, - ---@type snacks.Config - opts = { - bigfile = { enabled = true }, - dashboard = { enabled = true }, - explorer = { enabled = true }, - indent = { enabled = true }, - input = { enabled = true }, - notifier = { - enabled = true, - timeout = 3000, + -- snacks type shit + { + 'folke/snacks.nvim', + lazy = false, + priority = 1000, + ---@type snacks.Config + opts = { + bigfile = { enabled = true }, + dashboard = { enabled = true }, + explorer = { enabled = true }, + indent = { enabled = true }, + input = { enabled = true }, + notifier = { + enabled = true, + timeout = 3000, + }, + picker = { enabled = true }, + quickfile = { enabled = true }, + scope = { enabled = true }, + statuscolumn = { enabled = true }, + words = { enabled = true }, + styles = { + notification = { + -- wo = { wrap = true } -- Wrap notifications + }, + }, }, - picker = { enabled = true }, - quickfile = { enabled = true }, - scope = { enabled = true }, - scroll = { enabled = true }, - statuscolumn = { enabled = true }, - words = { enabled = true }, - styles = { - notification = { - -- wo = { wrap = true } -- Wrap notifications + keys = { + -- git + { + 'gb', + function() + Snacks.picker.git_branches() + end, + desc = 'Git Branches', + }, + { + 'gl', + function() + Snacks.picker.git_log() + end, + desc = 'Git Log', + }, + { + 'gL', + function() + Snacks.picker.git_log_line() + end, + desc = 'Git Log Line', + }, + { + 'gs', + function() + Snacks.picker.git_status() + end, + desc = 'Git Status', + }, + { + 'gS', + function() + Snacks.picker.git_stash() + end, + desc = 'Git Stash', + }, + { + 'gd', + function() + Snacks.picker.git_diff() + end, + desc = 'Git Diff (Hunks)', + }, + { + 'gf', + function() + Snacks.picker.git_log_file() + end, + desc = 'Git Log File', + }, + -- Grep + { + 'sb', + function() + Snacks.picker.lines() + end, + desc = 'Buffer Lines', + }, + { + 'sB', + function() + Snacks.picker.grep_buffers() + end, + desc = 'Grep Open Buffers', + }, + { + 'sg', + function() + Snacks.picker.grep() + end, + desc = 'Grep', + }, + { + 'sw', + function() + Snacks.picker.grep_word() + end, + desc = 'Visual selection or word', + mode = { 'n', 'x' }, + }, + -- Other + { + 'z', + function() + Snacks.zen() + end, + desc = 'Toggle Zen Mode', + }, + { + 'gB', + function() + Snacks.gitbrowse() + end, + desc = 'Git Browse', + mode = { 'n', 'v' }, + }, + { + 'gg', + function() + Snacks.lazygit() + end, + desc = 'Lazygit', + }, + { + ']]', + function() + Snacks.words.jump(vim.v.count1) + end, + desc = 'Next Reference', + mode = { 'n', 't' }, + }, + { + '[[', + function() + Snacks.words.jump(-vim.v.count1) + end, + desc = 'Prev Reference', + mode = { 'n', 't' }, + }, + { + 'N', + desc = 'Neovim News', + function() + Snacks.win { + file = vim.api.nvim_get_runtime_file('doc/news.txt', false)[1], + width = 0.6, + height = 0.6, + wo = { + spell = false, + wrap = false, + signcolumn = 'yes', + statuscolumn = ' ', + conceallevel = 3, + }, + } + end, }, }, + init = function() + vim.api.nvim_create_autocmd('User', { + pattern = 'VeryLazy', + callback = function() + -- Setup some globals for debugging (lazy-loaded) + _G.dd = function(...) + Snacks.debug.inspect(...) + end + _G.bt = function() + Snacks.debug.backtrace() + end + vim.print = _G.dd -- Override print to use snacks for `:=` command + + -- Create some toggle mappings + Snacks.toggle.option('spell', { name = 'Spelling' }):map 'us' + Snacks.toggle.option('wrap', { name = 'Wrap' }):map 'uw' + Snacks.toggle.option('relativenumber', { name = 'Relative Number' }):map 'uL' + Snacks.toggle.diagnostics():map 'ud' + Snacks.toggle.line_number():map 'ul' + Snacks.toggle.option('conceallevel', { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map 'uc' + Snacks.toggle.treesitter():map 'uT' + Snacks.toggle.option('background', { off = 'light', on = 'dark', name = 'Dark Background' }):map 'ub' + Snacks.toggle.inlay_hints():map 'uh' + Snacks.toggle.indent():map 'ug' + Snacks.toggle.dim():map 'uD' + end, + }) + end, }, - keys = { - -- git - { - 'gb', - function() - Snacks.picker.git_branches() - end, - desc = 'Git Branches', - }, - { - 'gl', - function() - Snacks.picker.git_log() - end, - desc = 'Git Log', - }, - { - 'gL', - function() - Snacks.picker.git_log_line() - end, - desc = 'Git Log Line', - }, - { - 'gs', - function() - Snacks.picker.git_status() - end, - desc = 'Git Status', - }, - { - 'gS', - function() - Snacks.picker.git_stash() - end, - desc = 'Git Stash', - }, - { - 'gd', - function() - Snacks.picker.git_diff() - end, - desc = 'Git Diff (Hunks)', - }, - { - 'gf', - function() - Snacks.picker.git_log_file() - end, - desc = 'Git Log File', - }, - -- Grep - { - 'sb', - function() - Snacks.picker.lines() - end, - desc = 'Buffer Lines', - }, - { - 'sB', - function() - Snacks.picker.grep_buffers() - end, - desc = 'Grep Open Buffers', - }, - { - 'sg', - function() - Snacks.picker.grep() - end, - desc = 'Grep', - }, - { - 'sw', - function() - Snacks.picker.grep_word() - end, - desc = 'Visual selection or word', - mode = { 'n', 'x' }, - }, - -- Other - { - 'z', - function() - Snacks.zen() - end, - desc = 'Toggle Zen Mode', - }, - { - 'gB', - function() - Snacks.gitbrowse() - end, - desc = 'Git Browse', - mode = { 'n', 'v' }, - }, - { - 'gg', - function() - Snacks.lazygit() - end, - desc = 'Lazygit', - }, - { - ']]', - function() - Snacks.words.jump(vim.v.count1) - end, - desc = 'Next Reference', - mode = { 'n', 't' }, - }, - { - '[[', - function() - Snacks.words.jump(-vim.v.count1) - end, - desc = 'Prev Reference', - mode = { 'n', 't' }, - }, - { - 'N', - desc = 'Neovim News', - function() - Snacks.win { - file = vim.api.nvim_get_runtime_file('doc/news.txt', false)[1], - width = 0.6, - height = 0.6, - wo = { - spell = false, - wrap = false, - signcolumn = 'yes', - statuscolumn = ' ', - conceallevel = 3, - }, - } - end, + + -- bracket autocomplete + { + 'windwp/nvim-autopairs', + event = 'InsertEnter', + config = true, + }, + + -- typst preview + { + 'chomosuke/typst-preview.nvim', + lazy = false, + version = '1.*', + opts = {}, + }, + + -- mini + { 'echasnovski/mini.nvim', version = '*' }, + + -- file explorer + { + 'nvim-tree/nvim-tree.lua', + version = '*', + lazy = false, + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + config = function() + require('nvim-tree').setup {} + end, + }, + + -- markdown stuff + { + 'tadmccorkle/markdown.nvim', + ft = 'markdown', -- or 'event = "VeryLazy"' + opts = { + -- configuration here or empty for defaults }, }, - init = function() - vim.api.nvim_create_autocmd('User', { - pattern = 'VeryLazy', - callback = function() - -- Setup some globals for debugging (lazy-loaded) - _G.dd = function(...) - Snacks.debug.inspect(...) - end - _G.bt = function() - Snacks.debug.backtrace() - end - vim.print = _G.dd -- Override print to use snacks for `:=` command - -- Create some toggle mappings - Snacks.toggle.option('spell', { name = 'Spelling' }):map 'us' - Snacks.toggle.option('wrap', { name = 'Wrap' }):map 'uw' - Snacks.toggle.option('relativenumber', { name = 'Relative Number' }):map 'uL' - Snacks.toggle.diagnostics():map 'ud' - Snacks.toggle.line_number():map 'ul' - Snacks.toggle.option('conceallevel', { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map 'uc' - Snacks.toggle.treesitter():map 'uT' - Snacks.toggle.option('background', { off = 'light', on = 'dark', name = 'Dark Background' }):map 'ub' - Snacks.toggle.inlay_hints():map 'uh' - Snacks.toggle.indent():map 'ug' - Snacks.toggle.dim():map 'uD' - end, - }) - end, + { + 'MeanderingProgrammer/render-markdown.nvim', + dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.nvim' }, -- if you use the mini.nvim suite + ---@module 'render-markdown' + ---@type render.md.UserConfig + opts = {}, + }, }