diff --git a/init.lua b/init.lua index dde09e1..6b40ca1 100644 --- a/init.lua +++ b/init.lua @@ -65,6 +65,22 @@ vim.opt.inccommand = 'split' -- Show which line your cursor is on vim.opt.cursorline = true +vim.opt.termguicolors = true + +-- session +-- vim.opt.sessionoptions = { +-- 'buffers', +-- 'tabpages', +-- -- 'curdir', +-- -- 'folds', +-- -- 'help', +-- -- 'winsize', +-- -- 'winpos', +-- -- 'terminal', +-- 'globals', +-- 'localoptions', +-- } + -- Minimal number of screen lines to keep above and below the cursor. -- vim.opt.scrolloff = 10 @@ -100,6 +116,10 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- treat underscore and hyphen NOT as word separators +-- vim.opt.iskeyword:remove '-' +-- vim.opt.iskeyword:remove '_' + -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' diff --git a/lazy-lock.json b/lazy-lock.json index 1fff697..61cadaf 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -2,7 +2,10 @@ "LuaSnip": { "branch": "master", "commit": "b84eeb3641b08324287587b426ec974b888390d9" }, "adwaita.nvim": { "branch": "main", "commit": "c9379097755701ab597140bafd097fbaff3dd517" }, "aerial.nvim": { "branch": "master", "commit": "e75a3df2c20b3a98c786f5e61587d74a7a6b61d6" }, + "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, + "auto-session": { "branch": "main", "commit": "afa735f5923a4c0e8f519ffaa18885dc03922571" }, "baleia.nvim": { "branch": "main", "commit": "fb3aff021b2b64ef820d0230d2c22ebfaf71bb6a" }, + "bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, @@ -11,12 +14,12 @@ "copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" }, "copilot.lua": { "branch": "master", "commit": "86537b286f18783f8b67bccd78a4ef4345679625" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, - "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, "fzf-lua": { "branch": "main", "commit": "e9413dc2b6e8ab7f62385c972df1dceba483492d" }, "git-conflict.nvim": { "branch": "main", "commit": "bfd9fe6fba9a161fc199771d85996236a0d0faad" }, "gitsigns.nvim": { "branch": "main", "commit": "58bd9e98d8e3c5a1c98af312e85247ee1afd3ed2" }, "gruber-darker.nvim": { "branch": "main", "commit": "1793c0929ca965430410f7ec578272a4af9226ee" }, + "gruvbox.nvim": { "branch": "main", "commit": "7a1b23e4edf73a39642e77508ee6b9cbb8c60f9e" }, "harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" }, "hybrid.nvim": { "branch": "master", "commit": "8838621a2e299582a0af5b8b96d5515f27b5d058" }, "hydra.nvim": { "branch": "main", "commit": "8578056a2226ed49fc608167edc143a87f75d809" }, @@ -25,14 +28,15 @@ "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, "lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" }, "lsp_signature.nvim": { "branch": "master", "commit": "a38da0a61c172bb59e34befc12efe48359884793" }, + "lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" }, "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, - "markview.nvim": { "branch": "main", "commit": "9e5275f3b7507da51deab9bc985e9154d0b6af28" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "62360f061d45177dda8afc1b0fd1327328540301" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mini-git": { "branch": "main", "commit": "c5daa5556c1798b6ef6595a3011af3ca5f7a2fd8" }, "mini.ai": { "branch": "main", "commit": "a9b992b13d22a8db8df6beac25afa59a10b5584d" }, "mini.bufremove": { "branch": "main", "commit": "1ee294a97e091d3cf967974df622c0d887890dc2" }, + "mini.diff": { "branch": "main", "commit": "d58f9cb13400aedc5b5a0ef70fcdf31871ba2ee6" }, "mini.icons": { "branch": "main", "commit": "fe63fe080e76d80713557e5f0c65bc15b14b152d" }, "mini.indentscope": { "branch": "main", "commit": "1222393d9c5e8d92b913ccab6701a7164b21781c" }, "mini.statusline": { "branch": "main", "commit": "ec7e2c509c7262fef85a28a772f60ebe146297db" }, @@ -55,11 +59,15 @@ "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "a727bd368e70808125b7cf589328cc595faf3d5a" }, "readline.nvim": { "branch": "main", "commit": "5cb27349bc01cdcdb3d3494e5337d8b3834aef1a" }, + "render-markdown.nvim": { "branch": "main", "commit": "420058baa6e33f20c096c93bb1df52bc841d9475" }, + "resession.nvim": { "branch": "master", "commit": "e087ebeef81df25a12fcc4ec067ca73e2bb54c4a" }, + "scope.nvim": { "branch": "main", "commit": "5e3f5ead970317b2f276d38dc031cb4bc5742cd4" }, "sg.nvim": { "branch": "master", "commit": "8bdd4d19da2268072708d5fe18fda9c23e16509d" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" }, + "toggleterm.nvim": { "branch": "main", "commit": "48be57eaba817f038d61bbf64d2c597f578c0827" }, "typewriter": { "branch": "main", "commit": "d1b3aa53d4805120674b26554e027d5f10350419" }, "undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" }, "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, diff --git a/lua/rayandrew/keymaps.lua b/lua/rayandrew/keymaps.lua index 80c84f5..f6a5efe 100644 --- a/lua/rayandrew/keymaps.lua +++ b/lua/rayandrew/keymaps.lua @@ -5,4 +5,73 @@ vim.keymap.set('n', 'ws', 'split', { desc = '[W]indow Horizonta vim.keymap.set('n', 'wv', 'vsplit', { desc = '[W]indow [V]ertical Split' }) -- split vertical vim.keymap.set('n', 'wq', 'q', { desc = '[W]indow [Q]uit' }) -- quit vim.keymap.set('n', 'x', '!chmod +x %', { desc = 'Chmod File E[x]ecutable', silent = true }) -vim.keymap.set('n', 'lz', 'Lazy', { desc = 'Chmod File E[x]ecutable', silent = true }) +vim.keymap.set('n', 'lz', 'Lazy', { desc = '[L]azy', silent = true }) +vim.keymap.set('n', 'lp', 'Lazy profile', { desc = '[L]azy [P]rofile', silent = true }) + +vim.keymap.set('n', 'l', 'tablast', { desc = 'Last Tab' }) +vim.keymap.set('n', 'f', 'tabfirst', { desc = 'First Tab' }) +vim.keymap.set('n', '', 'tabnew', { desc = 'New Tab' }) +vim.keymap.set('n', ']', 'tabnext', { desc = 'Next Tab' }) +vim.keymap.set('n', 'd', 'tabclose', { desc = 'Close Tab' }) +vim.keymap.set('n', '[', 'tabprevious', { desc = 'Previous Tab' }) + +vim.keymap.set('n', 'mx', '!chmod +x %', { desc = 'Chmod File E[x]ecutable', silent = true }) + +-- vim.keymap.set('n', 'gg', function() +-- Util.float_term({ 'lazygit' }, { cwd = Util.get_root(), esc_esc = false, ctrl_hjkl = false }) +-- end, { desc = 'Lazygit (root dir)' }) +vim.keymap.set('n', 'gg', function() + local term = require 'rayandrew.term' + term.lazygit_float() +end, { desc = '[G]it Lazygit', noremap = true, silent = true }) +vim.keymap.set('n', 'gG', function() + local term = require 'rayandrew.term' + term.lazygit() +end, { desc = '[G]it Lazygit', noremap = true, silent = true }) + +vim.keymap.set('n', 'tn', ':$tabnew', { noremap = true, silent = true, desc = '[T]ab [N]ew' }) +vim.keymap.set('n', 'tq', ':tabclose', { noremap = true, silent = true, desc = '[T]ab [Q]uit' }) +vim.keymap.set('n', 'tc', ':tabonly', { noremap = true, silent = true, desc = '[T]ab [C]lose All' }) +vim.keymap.set('n', 'tl', ':tabn', { noremap = true, silent = true, desc = '[T]ab Prev' }) +vim.keymap.set('n', 'th', ':tabp', { noremap = true, silent = true, desc = '[T]ab Next' }) +-- move current tab to previous position +vim.keymap.set('n', 'tmh', ':-tabmove', { noremap = true, silent = true, desc = '[T]ab Move Left' }) +-- move current tab to next position +vim.keymap.set('n', 'tml', ':+tabmove', { noremap = true, silent = true, desc = '[T]ab Move Right' }) + +-- Toggle Term + +-- local trim_spaces = true +-- vim.keymap.set('v', 'tl', function() +-- require('toggleterm').send_lines_to_terminal('single_line', trim_spaces, { args = vim.v.count }) +-- end, { desc = 'Send Selection to Terminal' }) +-- vim.g.send_toggleterm_motion = function(motion_type) +-- require('toggleterm').send_lines_to_terminal(motion_type, false, { args = vim.v.count }) +-- end +-- local send_motion_d = function(p) +-- return function() +-- vim.go.operatorfunc = 'v:lua.send_toggleterm_motion' +-- return p +-- end +-- end +-- vim.keymap.set('n', 'tp', send_motion_d 'g@', { desc = 'Send Motion to Terminal', expr = true }) +-- vim.keymap.set('n', 'tt', send_motion_d 'g@_', { desc = 'Send Motion to Terminal Twice', expr = true }) +-- vim.keymap.set('n', 'tf', send_motion_d "ggg@G''", { desc = 'Send Motion to Terminal Full File', expr = true }) + +-- Double the command to send line to terminal +-- vim.keymap.set('n', 'tt', function() +-- -- set_opfunc(function(motion_type) +-- -- require('toggleterm').send_lines_to_terminal(motion_type, false, { args = vim.v.count }) +-- -- end) +-- vim.go.operatorfunc = 'v:lua.send_toggleterm_motion' +-- vim.api.nvim_feedkeys('g@_', 'n', false) +-- end, { desc = 'Send Motion to Terminal Twice', expr = true }) + +-- Send whole file +-- vim.keymap.set('n', 'tf', function() +-- -- set_opfunc(function(motion_type) +-- -- require('toggleterm').send_lines_to_terminal(motion_type, false, { args = vim.v.count }) +-- -- end) +-- vim.go.operatorfunc = 'v:lua.send_toggleterm_motion' +-- vim.api.nvim_feedkeys("ggg@G''", 'n', false) +-- end, { desc = 'Send Whole File to Terminal', expr = true }) diff --git a/lua/rayandrew/plugins/alpha.lua b/lua/rayandrew/plugins/alpha.lua new file mode 100644 index 0000000..70151b5 --- /dev/null +++ b/lua/rayandrew/plugins/alpha.lua @@ -0,0 +1,14 @@ +return { + { + 'goolord/alpha-nvim', + lazy = false, + priority = 100, + dependencies = { + 'nvim-tree/nvim-web-devicons', + 'nvim-lua/plenary.nvim', + }, + config = function() + require('alpha').setup(require('alpha.themes.theta').config) + end, + }, +} diff --git a/lua/rayandrew/plugins/auto-session.lua b/lua/rayandrew/plugins/auto-session.lua new file mode 100644 index 0000000..f9bd595 --- /dev/null +++ b/lua/rayandrew/plugins/auto-session.lua @@ -0,0 +1,35 @@ +return { + { + 'rmagatti/auto-session', + cond = false, + lazy = false, + dependencies = { + 'nvim-telescope/telescope.nvim', + }, + opts = { + auto_session_enabled = true, + auto_session_root_dir = vim.fn.stdpath 'data' .. '/sessions/', + auto_save_enabled = true, + auto_restore_enabled = true, + auto_session_suppress_dirs = nil, + auto_session_allowed_dirs = nil, + auto_session_create_enabled = true, + auto_session_enable_last_session = false, + auto_session_use_git_branch = false, + auto_restore_lazy_delay_enabled = true, + log_level = 'error', + cwd_change_handling = { + restore_upcoming_session = false, + post_cwd_changed_hook = function() + require('bufferline.ui').refresh() + --require("lualine").refresh() -- refresh lualine so the new session name is displayed in the status bar + end, + }, + }, + config = true, + -- config = function(_, opts) + -- require('auto-session').setup { + -- } + -- end, + }, +} diff --git a/lua/rayandrew/plugins/autocomplete.lua b/lua/rayandrew/plugins/autocomplete.lua index b970082..c9f97ab 100644 --- a/lua/rayandrew/plugins/autocomplete.lua +++ b/lua/rayandrew/plugins/autocomplete.lua @@ -115,6 +115,7 @@ return { -- } -- end, -- }, + { 'onsails/lspkind.nvim', config = true }, }, config = function() -- See `:help cmp` @@ -123,6 +124,17 @@ return { luasnip.config.setup {} cmp.setup { + formatting = { + format = require('lspkind').cmp_format { + mode = 'symbol_text', + maxwidth = 50, + ellipsis_char = '...', + show_labelDetails = true, + before = function(entry, vim_item) + return vim_item + end, + }, + }, snippet = { expand = function(args) luasnip.lsp_expand(args.body) diff --git a/lua/rayandrew/plugins/bufferline.lua b/lua/rayandrew/plugins/bufferline.lua new file mode 100644 index 0000000..5a6d259 --- /dev/null +++ b/lua/rayandrew/plugins/bufferline.lua @@ -0,0 +1,53 @@ +return { + { + 'akinsho/bufferline.nvim', + cond = false, + -- event = 'VimEnter', + config = true, + lazy = false, + opts = { + options = { + view = 'multiwindow', + numbers = function(opts) + local harpoon = require 'harpoon.mark' + local buf_name = vim.api.nvim_buf_get_name(opts.id) + local harpoon_mark = harpoon.get_index_of(buf_name) + return harpoon_mark + end, + modified_icon = '●', + max_prefix_length = 5, + tab_size = 18, + diagnostics = 'nvim_lsp', + separator_style = { '|', '' }, + offsets = { + { + filetype = 'NvimTree', + text = 'File Explorer', + text_align = 'center', + }, + }, + sort_by = function(buffer_a, buffer_b) + local function get_local_mark(id) + local harpoon = require 'harpoon.mark' + local buf_name = vim.api.nvim_buf_get_name(id) + local harpoon_mark = harpoon.get_index_of(buf_name) + if harpoon_mark == nil then + return 999999 + end + return harpoon_mark + end + return get_local_mark(buffer_a.id) < get_local_mark(buffer_b.id) + end, + }, + }, + keys = { + { '', 'BufferLineCyclePrev', desc = 'Prev buffer' }, + { '', 'BufferLineCycleNext', desc = 'Next buffer' }, + { '[b', 'BufferLineCyclePrev', desc = 'Prev buffer' }, + { ']b', 'BufferLineCycleNext', desc = 'Next buffer' }, + }, + -- config = function() + -- + -- end, + }, +} diff --git a/lua/rayandrew/plugins/colorscheme.lua b/lua/rayandrew/plugins/colorscheme.lua index 8e1270b..020e262 100644 --- a/lua/rayandrew/plugins/colorscheme.lua +++ b/lua/rayandrew/plugins/colorscheme.lua @@ -8,8 +8,8 @@ return { }, config = function(_, opts) require('gruber-darker').setup(opts) - vim.cmd.colorscheme 'gruber-darker' - vim.cmd.hi 'Comment gui=none' + -- vim.cmd.colorscheme 'gruber-darker' + -- vim.cmd.hi 'Comment gui=none' end, }, @@ -19,19 +19,19 @@ return { -- priority = 1000, -- configure and set on startup config = function() - vim.g.adwaita_darker = true -- for darker version - vim.g.adwaita_disable_cursorline = true -- to disable cursorline - vim.g.adwaita_transparent = true -- makes the background transparent + -- vim.g.adwaita_darker = true -- for darker version + -- vim.g.adwaita_disable_cursorline = true -- to disable cursorline + -- vim.g.adwaita_transparent = true -- makes the background transparent -- vim.cmd.colorscheme 'adwaita' end, }, { 'HoNamDuong/hybrid.nvim', - lazy = false, - priority = 1000, + lazy = true, + -- priority = 1000, config = function() - vim.cmd.colorscheme 'hybrid' + -- vim.cmd.colorscheme 'hybrid' end, }, @@ -43,4 +43,39 @@ return { -- vim.cmd.colorscheme 'kanagawa-dragon' end, }, + + { + 'ellisonleao/gruvbox.nvim', + lazy = false, + priority = 1000, + opts = { + terminal_colors = true, -- add neovim terminal colors + undercurl = true, + underline = true, + bold = true, + italic = { + strings = true, + emphasis = true, + comments = true, + operators = false, + folds = true, + }, + strikethrough = true, + invert_selection = false, + invert_signs = false, + invert_tabline = false, + invert_intend_guides = false, + inverse = true, -- invert background for search, diffs, statuslines and errors + contrast = '', -- can be "hard", "soft" or empty string + palette_overrides = {}, + overrides = {}, + dim_inactive = false, + transparent_mode = false, + }, + config = function(_, opts) + vim.o.background = 'dark' + vim.cmd.colorscheme 'gruvbox' + require('gruvbox').setup(opts) + end, + }, } diff --git a/lua/rayandrew/plugins/conform.lua b/lua/rayandrew/plugins/conform.lua index a389c3e..7414839 100644 --- a/lua/rayandrew/plugins/conform.lua +++ b/lua/rayandrew/plugins/conform.lua @@ -25,7 +25,7 @@ return { -- languages here or re-enable it for the disabled ones. local disable_filetypes = { c = true, cpp = true } return { - timeout_ms = 5000, + timeout_ms = 7500, lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], } end, diff --git a/lua/rayandrew/plugins/fzf.lua b/lua/rayandrew/plugins/fzf.lua index 7e0ee6f..46961a6 100644 --- a/lua/rayandrew/plugins/fzf.lua +++ b/lua/rayandrew/plugins/fzf.lua @@ -21,7 +21,7 @@ return { } vim.keymap.set('n', 'sf', fzf.files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'sk', fzf.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'ss', fzf.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'ss', fzf.builtin, { desc = '[S]earch [S]elect' }) vim.keymap.set('n', 'sg', fzf.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', fzf.diagnostics_document, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', fzf.resume, { desc = '[S]earch [R]esume' }) diff --git a/lua/rayandrew/plugins/indent_line.lua b/lua/rayandrew/plugins/indent_line.lua index ed7f269..08ec33c 100644 --- a/lua/rayandrew/plugins/indent_line.lua +++ b/lua/rayandrew/plugins/indent_line.lua @@ -1,6 +1,7 @@ return { { -- Add indentation guides even on blank lines 'lukas-reineke/indent-blankline.nvim', + event = 'BufRead', -- Enable `lukas-reineke/indent-blankline.nvim` -- See `:help ibl` main = 'ibl', diff --git a/lua/rayandrew/plugins/lsp.lua b/lua/rayandrew/plugins/lsp.lua index 09643a6..7c5d1bf 100644 --- a/lua/rayandrew/plugins/lsp.lua +++ b/lua/rayandrew/plugins/lsp.lua @@ -10,7 +10,7 @@ return { -- Useful status updates for LSP. -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', opts = {} }, + -- { 'j-hui/fidget.nvim', opts = {} }, -- Allows extra capabilities provided by nvim-cmp 'hrsh7th/cmp-nvim-lsp', @@ -100,7 +100,7 @@ return { map('gI', require('fzf-lua').lsp_implementations, '[G]oto [I]mplementation') map('D', require('fzf-lua').lsp_typedefs, 'Type [D]efinition') map('ds', require('fzf-lua').lsp_document_symbols, '[D]ocument [S]ymbols') - map('ws', require('fzf-lua').lsp_live_workspace_symbols, '[W]orkspace [S]ymbols') + map('ps', require('fzf-lua').lsp_live_workspace_symbols, '[W]orkspace [S]ymbols') -- Rename the variable under your cursor. -- Most Language Servers support renaming across files, etc. @@ -148,7 +148,7 @@ return { -- -- This may be unwanted, since they displace some of your code if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then - map('th', function() + map('tlh', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') end diff --git a/lua/rayandrew/plugins/markdown.lua b/lua/rayandrew/plugins/markdown.lua index e889579..7ca3b3b 100644 --- a/lua/rayandrew/plugins/markdown.lua +++ b/lua/rayandrew/plugins/markdown.lua @@ -1,11 +1,31 @@ return { + -- { + -- 'OXY2DEV/markview.nvim', + -- lazy = true, + -- ft = 'markdown', + -- dependencies = { + -- 'nvim-treesitter/nvim-treesitter', + -- 'nvim-tree/nvim-web-devicons', + -- }, + -- opts = { + -- modes = { 'n', 'no', 'i', 'c' }, + -- hybrid_modes = { 'i' }, + -- callbacks = { + -- on_enable = function(_, win) + -- vim.wo[win].conceallevel = 2 + -- vim.wo[win].concealcursor = '' + -- end, + -- }, + -- }, + -- }, { - 'OXY2DEV/markview.nvim', + 'MeanderingProgrammer/render-markdown.nvim', lazy = true, ft = 'markdown', - dependencies = { - 'nvim-treesitter/nvim-treesitter', - 'nvim-tree/nvim-web-devicons', + opts = { + enabled = true, }, + dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use the mini.nvim suite + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons }, } diff --git a/lua/rayandrew/plugins/mini.lua b/lua/rayandrew/plugins/mini.lua index 56e0357..8dc6d0d 100644 --- a/lua/rayandrew/plugins/mini.lua +++ b/lua/rayandrew/plugins/mini.lua @@ -62,20 +62,25 @@ return { { 'echasnovski/mini-git', main = 'mini.git', + cmd = { 'Git' }, version = false, config = true, keys = { - { 'gs', 'lua MiniGit.show_at_cursor()', mode = 'n' }, - { 'gs', 'lua MiniGit.show_at_cursor()', mode = 'x' }, + { 'gc', 'Git commit', desc = '[G]it [C]ommit' }, + { 'gC', 'Git commit --amend', desc = '[G]it [C]ommit (Amend)' }, + { 'gl', 'Git log --oneline', desc = '[G]it [L]og' }, + { 'gl', 'Git log --oneline --follow -- %', desc = '[G]it [L]og Buffer' }, + { 'gs', 'lua MiniGit.show_at_cursor()', mode = 'n', desc = '[G]it [S]how' }, + { 'gs', 'lua MiniGit.show_at_cursor()', mode = 'x', desc = '[G]it [S]how' }, + { 'ga', 'Git add -- %', desc = '[G]it [A]dd' }, + }, + }, + { + 'echasnovski/mini.diff', + version = false, + config = true, + keys = { + { 'go', 'lua MiniDiff.toggle_overlay()' }, }, }, - -- { - -- 'echasnovski/mini.comment', - -- version = false, - -- config = true, - -- keys = { - -- 'gc', - -- 'gcc', - -- }, - -- }, } diff --git a/lua/rayandrew/plugins/neogit.lua b/lua/rayandrew/plugins/neogit.lua index fae6e8d..8ee95a4 100644 --- a/lua/rayandrew/plugins/neogit.lua +++ b/lua/rayandrew/plugins/neogit.lua @@ -13,9 +13,9 @@ return { lazy = true, keys = { { - 'gg', - ':Neogit', - desc = 'Neo[g]it', + 'gt', + ':Neogit', + desc = 'Neo[g]i[t]', }, }, }, diff --git a/lua/rayandrew/plugins/numb.lua b/lua/rayandrew/plugins/numb.lua index d72f31c..4c43d59 100644 --- a/lua/rayandrew/plugins/numb.lua +++ b/lua/rayandrew/plugins/numb.lua @@ -1,7 +1,7 @@ return { { 'nacro90/numb.nvim', - event = 'VimEnter', + event = 'BufRead', config = true, }, } diff --git a/lua/rayandrew/plugins/fold.lua b/lua/rayandrew/plugins/nvim-ufo.lua similarity index 98% rename from lua/rayandrew/plugins/fold.lua rename to lua/rayandrew/plugins/nvim-ufo.lua index 431398d..438f22c 100644 --- a/lua/rayandrew/plugins/fold.lua +++ b/lua/rayandrew/plugins/nvim-ufo.lua @@ -1,6 +1,7 @@ return { { 'kevinhwang91/nvim-ufo', + event = 'BufRead', dependencies = { { 'kevinhwang91/promise-async' }, }, diff --git a/lua/rayandrew/plugins/oil.lua b/lua/rayandrew/plugins/oil.lua index 355ded5..658c9ea 100644 --- a/lua/rayandrew/plugins/oil.lua +++ b/lua/rayandrew/plugins/oil.lua @@ -4,6 +4,7 @@ return { dependencies = { { 'echasnovski/mini.icons', opts = {} } }, cmd = { 'Oil' }, opts = { + columns = {}, default_file_explorer = true, restore_win_options = true, use_default_keymaps = false, @@ -46,7 +47,7 @@ return { 'permissions', 'size', 'mtime', - 'icon', + -- 'icon', } else oil.set_columns {} diff --git a/lua/rayandrew/plugins/rainbow-delimiters.lua b/lua/rayandrew/plugins/rainbow-delimiters.lua index 98b5973..4a53342 100644 --- a/lua/rayandrew/plugins/rainbow-delimiters.lua +++ b/lua/rayandrew/plugins/rainbow-delimiters.lua @@ -1,7 +1,7 @@ return { { 'HiPhish/rainbow-delimiters.nvim', - event = 'VimEnter', + event = 'BufRead', config = function() local rainbow_delimiters = require 'rainbow-delimiters' diff --git a/lua/rayandrew/plugins/resession.lua b/lua/rayandrew/plugins/resession.lua new file mode 100644 index 0000000..2abfc9e --- /dev/null +++ b/lua/rayandrew/plugins/resession.lua @@ -0,0 +1,62 @@ +return { + { + 'stevearc/resession.nvim', + lazy = false, + cond = false, + keys = { + { 'ps', ":lua require('resession').save()", desc = '[S]ave [S]ession' }, + { 'pl', ":lua require('resession').load()", desc = '[L]oad [S]ession' }, + { 'pd', ":lua require('resession').delete()", desc = '[D]elete [S]ession' }, + }, + opts = { + tab_buf_filter = function(tabpage, bufnr) + local dir = vim.fn.getcwd(-1, vim.api.nvim_tabpage_get_number(tabpage)) + -- ensure dir has trailing / + dir = dir:sub(-1) ~= '/' and dir .. '/' or dir + return vim.startswith(vim.api.nvim_buf_get_name(bufnr), dir) + end, + -- override default filter + buf_filter = function(bufnr) + local buftype = vim.bo[bufnr].buftype + if buftype == 'help' then + return true + end + if buftype ~= '' and buftype ~= 'acwrite' then + return false + end + if vim.api.nvim_buf_get_name(bufnr) == '' then + return false + end + + -- this is required, since the default filter skips nobuflisted buffers + return true + end, + extensions = { scope = {} }, + }, + config = function(_, opts) + local resession = require 'resession' + resession.setup(opts) + vim.api.nvim_create_autocmd('VimEnter', { + callback = function() + -- Only load the session if nvim was started with no args + if vim.fn.argc(-1) == 0 then + -- Save these to a different directory, so our manual sessions don't get polluted + resession.load(vim.fn.getcwd(), { dir = 'dirsession', silence_errors = true }) + end + end, + nested = true, + }) + vim.api.nvim_create_autocmd('VimLeavePre', { + callback = function() + resession.save(vim.fn.getcwd(), { dir = 'dirsession', notify = false }) + end, + }) + vim.api.nvim_create_autocmd('VimLeavePre', { + callback = function() + -- Always save a special session named "last" + resession.save 'last' + end, + }) + end, + }, +} diff --git a/lua/rayandrew/plugins/scope.lua b/lua/rayandrew/plugins/scope.lua new file mode 100644 index 0000000..ac3bf81 --- /dev/null +++ b/lua/rayandrew/plugins/scope.lua @@ -0,0 +1,8 @@ +return { + { + 'tiagovla/scope.nvim', + cond = false, + config = true, + -- event = 'VimEnter', + }, +} diff --git a/lua/rayandrew/plugins/tmux.lua b/lua/rayandrew/plugins/tmux.lua index e76dbc4..aa42489 100644 --- a/lua/rayandrew/plugins/tmux.lua +++ b/lua/rayandrew/plugins/tmux.lua @@ -7,7 +7,16 @@ return { 'TmuxNavigateUp', 'TmuxNavigateRight', }, - keys = { '', '', '', '' }, + keys = { + '', + '', + '', + '', + -- { 'wh', 'TmuxNavigateLeft', desc = 'Navigate to the left' }, + -- { 'wj', 'TmuxNavigateDown', desc = 'Navigate down' }, + -- { 'wk', 'TmuxNavigateUp', desc = 'Navigate up' }, + -- { 'wl', 'TmuxNavigateRight', desc = 'Navigate to the right' }, + }, config = function() vim.g.tmux_navigator_no_wrap = 1 end, diff --git a/lua/rayandrew/plugins/toggleterm.lua b/lua/rayandrew/plugins/toggleterm.lua new file mode 100644 index 0000000..f2b40ad --- /dev/null +++ b/lua/rayandrew/plugins/toggleterm.lua @@ -0,0 +1,21 @@ +return { + { + 'akinsho/toggleterm.nvim', + version = '*', + opts = { + size = function(term) + if term.direction == 'horizontal' then + return 15 + elseif term.direction == 'vertical' then + return vim.o.columns * 0.5 + end + end, + on_open = function(_) + vim.cmd 'startinsert!' + -- vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', '', { noremap = true, silent = true, nowait = true }) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', '', { noremap = true, silent = true, nowait = true }) + end, + }, + config = true, + }, +} diff --git a/lua/rayandrew/plugins/treesitter.lua b/lua/rayandrew/plugins/treesitter.lua index d411b7d..5121657 100644 --- a/lua/rayandrew/plugins/treesitter.lua +++ b/lua/rayandrew/plugins/treesitter.lua @@ -1,6 +1,7 @@ return { { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', + event = 'BufRead', build = ':TSUpdate', opts = { ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, diff --git a/lua/rayandrew/term.lua b/lua/rayandrew/term.lua new file mode 100644 index 0000000..7bed402 --- /dev/null +++ b/lua/rayandrew/term.lua @@ -0,0 +1,43 @@ +local M = {} + +local create_lazygit = function(direction) + local Terminal = require('toggleterm.terminal').Terminal + local utils = require 'rayandrew.utils' + + local lazygit = Terminal:new { + cmd = 'lazygit', + hidden = true, + direction = direction, + dir = utils.get_project_root(), + float_opts = { + border = 'double', + }, + + on_open = function(term) + vim.cmd 'startinsert!' + vim.api.nvim_buf_set_keymap(term.bufnr, 'n', 'q', 'close', { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', '', { noremap = true, silent = true, nowait = true }) + vim.api.nvim_buf_set_keymap(term.bufnr, 't', '', '', { noremap = true, silent = true, nowait = true }) + + -- vim.keymap.set('t', '', '', { buffer = buf, nowait = true }) + end, + -- function to run on closing the terminal + on_close = function(_) + vim.cmd 'startinsert!' + end, + } + return lazygit +end + +function M.lazygit() + local lazygit = create_lazygit 'vertical' + lazygit:toggle() +end + +function M.lazygit_float() + local lazygit = create_lazygit 'float' + lazygit:toggle() + -- require('rayandrew.utils').float_term({ 'lazygit' }, { esc_esc = false, ctrl_hjkl = false }) +end + +return M diff --git a/lua/rayandrew/utils.lua b/lua/rayandrew/utils.lua index 2856d23..8b87fc1 100644 --- a/lua/rayandrew/utils.lua +++ b/lua/rayandrew/utils.lua @@ -8,4 +8,52 @@ M.is_argonne_servers = function() return _is_argonne_servers end +local terminals = {} + +function M.float_term(cmd, opts) + opts = vim.tbl_deep_extend('force', { + ft = 'lazyterm', + size = { width = 0.9, height = 0.9 }, + }, opts or {}, { persistent = true }) + ---@cast opts LazyCmdOptions|{interactive?:boolean, esc_esc?:false} + + local termkey = vim.inspect { + cmd = cmd or 'shell', + cwd = opts.cwd, + env = opts.env, + count = vim.v.count1, + } + + if terminals[termkey] and terminals[termkey]:buf_valid() then + terminals[termkey]:toggle() + else + terminals[termkey] = require('lazy.util').float_term(cmd, opts) + local buf = terminals[termkey].buf + vim.b[buf].lazyterm_cmd = cmd + if opts.esc_esc == false then + vim.keymap.set('t', '', '', { buffer = buf, nowait = true }) + end + if opts.ctrl_hjkl == false then + vim.keymap.set('t', '', '', { buffer = buf, nowait = true }) + vim.keymap.set('t', '', '', { buffer = buf, nowait = true }) + vim.keymap.set('t', '', '', { buffer = buf, nowait = true }) + vim.keymap.set('t', '', '', { buffer = buf, nowait = true }) + end + + vim.api.nvim_create_autocmd('BufEnter', { + buffer = buf, + callback = function() + vim.cmd.startinsert() + end, + }) + end + + return terminals[termkey] +end + +function M.get_project_root() + local lsp = require 'lspconfig' + return lsp.util.root_pattern('.git', 'pyproject.toml', '.envrc')() +end + return M