diff --git a/init.lua b/init.lua index af4312bc..de1cc296 100644 --- a/init.lua +++ b/init.lua @@ -458,7 +458,7 @@ 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', '', function() builtin.buffers() end, { desc = '[ ] Find existing buffers' }) -- Slightly advanced example of overriding default behavior and theme vim.keymap.set('n', '/', function() @@ -899,28 +899,52 @@ require('lazy').setup({ }, }, - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- change the command in the config to whatever the name of that colorscheme is. - -- - -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', - priority = 1000, -- Make sure to load this before all the other start plugins. + -- Load catppuccin theme at startup + { + 'catppuccin/nvim', + name = 'catppuccin', + priority = 1000, -- Make sure to load this before all the other start plugins config = function() - ---@diagnostic disable-next-line: missing-fields - require('tokyonight').setup { + -- Configure the theme + require('catppuccin').setup { + flavour = 'mocha', -- latte, frappe, macchiato, mocha + background = { + light = 'latte', + dark = 'mocha', + }, + transparent_background = false, styles = { - comments = { italic = false }, -- Disable italics in comments + comments = { 'italic' }, + conditionals = { 'italic' }, + }, + integrations = { + cmp = true, + gitsigns = true, + nvimtree = true, + telescope = true, + treesitter = true, }, } - -- Load the colorscheme here. - -- Like many other themes, this one has different styles, and you could load - -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + -- Load the colorscheme + vim.cmd.colorscheme 'catppuccin' end, }, + -- Original tokyonight theme (commented out) + -- { -- You can easily change to a different colorscheme. + -- 'folke/tokyonight.nvim', + -- priority = 1000, + -- config = function() + -- require('tokyonight').setup { + -- styles = { + -- comments = { italic = false }, + -- }, + -- } + -- vim.cmd.colorscheme 'tokyonight-night' + -- end, + -- }, + -- Highlight todo, notes, etc in comments { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, diff --git a/lua/custom/plugins/comment.lua b/lua/custom/plugins/comment.lua new file mode 100644 index 00000000..0da4ad24 --- /dev/null +++ b/lua/custom/plugins/comment.lua @@ -0,0 +1,50 @@ +-- Comment.nvim - Smart and powerful commenting plugin +-- https://github.com/numToStr/Comment.nvim + +return { + "numToStr/Comment.nvim", + event = "VeryLazy", + config = function() + require('Comment').setup({ + -- Add a space between comment and the line + padding = true, + -- Whether cursor should stay at its position + sticky = true, + -- LHS of toggle mappings in NORMAL mode + toggler = { + -- Line-comment toggle keymap + line = 'gcc', + -- Block-comment toggle keymap + block = 'gbc', + }, + -- LHS of operator-pending mappings in NORMAL and VISUAL mode + opleader = { + -- Line-comment keymap + line = 'gc', + -- Block-comment keymap + block = 'gb', + }, + -- LHS of extra mappings + extra = { + -- Add comment on the line above + above = 'gcO', + -- Add comment on the line below + below = 'gco', + -- Add comment at the end of line + eol = 'gcA', + }, + -- Enable keybindings + mappings = { + -- Operator-pending mapping + basic = true, + -- Extra mapping + extra = true, + }, + -- Pre-hook, called before commenting the line + -- Can be used with treesitter for better tsx/jsx commenting + pre_hook = nil, + -- Post-hook, called after commenting is done + post_hook = nil, + }) + end, +} diff --git a/lua/custom/plugins/copilot-chat.lua b/lua/custom/plugins/copilot-chat.lua index 24e6f5fb..ffe78f4a 100644 --- a/lua/custom/plugins/copilot-chat.lua +++ b/lua/custom/plugins/copilot-chat.lua @@ -174,8 +174,10 @@ return { -- Toggle inline chat for quick questions about the current line vim.keymap.set("n", "cl", function() - select.line() - chat.toggle() + -- Use chat.ask with a line selector instead of separate select.line() call + chat.ask("What does this line of code do?", { + selection = select.line, -- Pass the function reference, not the function call + }) end, { desc = "Chat About Current Line" }) -- Open Copilot Chat with a custom prompt diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index e52a9f58..718fea53 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -12,4 +12,8 @@ return { { import = "custom.plugins.harpoon" }, { import = "custom.plugins.lazygit" }, { import = "custom.plugins.toggleterm" }, + { import = "custom.plugins.comment" }, + { import = "custom.plugins.leetcode" }, + -- { import = "custom.plugins.telescope_fix" }, + { import = "custom.plugins.catppuccin" }, } diff --git a/lua/custom/plugins/lazygit.lua b/lua/custom/plugins/lazygit.lua index 1458f6dd..27183bdd 100644 --- a/lua/custom/plugins/lazygit.lua +++ b/lua/custom/plugins/lazygit.lua @@ -25,12 +25,12 @@ return { -- Plugin configuration config = function() -- Configure floating window border - require("lazygit").setup({ - floating_window_winblend = 0, -- transparency of floating window - floating_window_scaling_factor = 0.9, -- scaling factor for floating window - floating_window_border_chars = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' }, -- customize floating window border chars - lazygit_floating_window_use_plenary = true, -- use plenary.nvim to manage floating window if available - }) + -- require("lazygit").setup({ + -- -- floating_window_winblend = 0, -- transparency of floating window + -- floating_window_scaling_factor = 0.9, -- scaling factor for floating window + -- floating_window_border_chars = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' }, -- customize floating window border chars + -- lazygit_floating_window_use_plenary = true, -- use plenary.nvim to manage floating window if available + -- }) end, } } diff --git a/lua/custom/plugins/leetcode.lua b/lua/custom/plugins/leetcode.lua new file mode 100644 index 00000000..ed7eef6b --- /dev/null +++ b/lua/custom/plugins/leetcode.lua @@ -0,0 +1,93 @@ +-- filepath: /home/kali/.config/nvim/lua/custom/plugins/leetcode.lua +-- LeetCode.nvim - Solve LeetCode problems within Neovim +-- https://github.com/kawre/leetcode.nvim + +return { + "kawre/leetcode.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + "nvim-tree/nvim-web-devicons", -- optional but recommended + "nvim-treesitter/nvim-treesitter" -- make sure treesitter is a direct dependency + }, + build = function() + -- Make sure the HTML parser is installed for treesitter + require("nvim-treesitter.install").ensure_installed("html") + end, + config = function() + require("leetcode").setup({ + -- Default language for solving problems + lang = "python3", -- you can change this to your preferred language + + -- Storage directories + storage = { + home = vim.fn.stdpath("data") .. "/leetcode", + cache = vim.fn.stdpath("cache") .. "/leetcode", + }, + + -- Console settings + console = { + open_on_runcode = true, + dir = "row", -- "row" or "col" for horizontal or vertical split + size = { + width = "90%", + height = "75%", + }, + result = { + size = "60%", + }, + testcase = { + virt_text = true, + size = "40%", + }, + }, + + -- Description panel settings + description = { + position = "left", -- "left" or "right" + width = "40%", + show_stats = true, -- show problem stats in description panel + }, + + -- You can choose either telescope or fzf-lua + picker = { + provider = "telescope", -- set to "fzf-lua" if you prefer that + }, + + -- Default keybindings - these won't conflict with your existing mappings + -- as they only activate within LeetCode buffers + keys = { + toggle = { "q" }, + confirm = { "" }, + + reset_testcases = "r", + use_testcase = "U", + focus_testcases = "H", + focus_result = "L", + }, + + -- Code injection settings - adds useful imports automatically + injector = { + ["cpp"] = { + before = { "#include ", "using namespace std;" }, + }, + ["java"] = { + before = "import java.util.*;", + }, + ["python3"] = { + before = true, -- use default imports + }, + }, + + -- Enable logging + logging = true, + + -- Non-standalone mode (false means it won't interfere with your normal workflow) + plugins = { + non_standalone = false, + }, + }) + end, + cmd = "Leet", -- lazy-load on command +} diff --git a/lua/custom/plugins/leetcode_guide.md b/lua/custom/plugins/leetcode_guide.md new file mode 100644 index 00000000..76cae7d3 --- /dev/null +++ b/lua/custom/plugins/leetcode_guide.md @@ -0,0 +1,66 @@ +# LeetCode.nvim Guide: Solve LeetCode Problems in Neovim + +LeetCode.nvim is a powerful plugin that integrates LeetCode directly into your Neovim editor, allowing you to browse, solve, and submit LeetCode problems without leaving your favorite editor. + +## Getting Started + +1. Open the LeetCode interface with command: + + ``` + :Leet + ``` + +2. You'll need to log in to your LeetCode account the first time you run it. + +## Basic Commands + +- `:Leet` - Opens the main LeetCode menu +- `:Leet daily` - Open today's daily challenge +- `:Leet random` - Get a random problem +- `:Leet list` - Browse all problems +- `:Leet tabs` - Switch between open problems +- `:Leet submit` - Submit current solution +- `:Leet run` - Run current solution with test cases +- `:Leet reset` - Reset the code to default template +- `:Leet lang` - Change programming language for current problem +- `:Leet cookie update` - Update your LeetCode cookie + +## Filter Problems + +When using `:Leet list` or `:Leet random`, you can filter problems: + +- By difficulty: `difficulty=easy/medium/hard` +- By status: `status=ac/notac/todo` +- By tags: `tags=array,string,dp` + +Example: + +``` +:Leet list difficulty=medium status=notac +:Leet random status=todo difficulty=hard +``` + +## Keybindings Within LeetCode UI + +These keys only work within the LeetCode interface and won't conflict with your existing keymaps: + +- `q` - Toggle/close panels +- `` (Enter) - Confirm selection +- `r` - Reset test cases +- `U` - Use a custom test case +- `H` - Focus on test cases panel +- `L` - Focus on results panel + +## Tips for Use + +1. **Switch Languages**: Use `:Leet lang` to change your programming language for the current problem. + +2. **Multiple Problems**: You can have multiple LeetCode problems open in different tabs. + +3. **Code Auto-Injection**: Useful imports and boilerplate code are automatically added for common languages. + +4. **Description Format**: Problem descriptions are formatted for better readability, including proper markdown rendering. + +5. **Efficient Workflow**: LeetCode.nvim caches your progress, making it faster to get back to your problems. + +Enjoy solving LeetCode problems without leaving your favorite editor! diff --git a/lua/custom/plugins/telescope_fix.lua.back b/lua/custom/plugins/telescope_fix.lua.back new file mode 100644 index 00000000..418650f9 --- /dev/null +++ b/lua/custom/plugins/telescope_fix.lua.back @@ -0,0 +1,34 @@ +-- Fix for Telescope error with nil paths +-- return { +-- "nvim-telescope/telescope.nvim", +-- -- This will only modify the existing telescope configuration +-- config = function() +-- local telescope = require('telescope') + +-- -- Only apply our patch if telescope is loaded +-- local utils = require('telescope.utils') +-- local original_path_expand = utils.path_expand + +-- -- Override path_expand with a safer version that handles nil paths +-- utils.path_expand = function(path) +-- if path == nil then +-- -- Return the current working directory if path is nil +-- return vim.fn.getcwd() or vim.fn.expand('%:p:h') or '.' +-- end +-- return original_path_expand(path) +-- end + +-- -- Any additional telescope settings can be set here +-- telescope.setup({ +-- defaults = { +-- path_display = { "truncate" }, +-- mappings = { +-- i = { +-- [""] = false, +-- [""] = false, +-- }, +-- }, +-- }, +-- }) +-- end, +-- }