From e00fc002a6441fa3741d1f705337efbbd8850744 Mon Sep 17 00:00:00 2001 From: Elvis Claros Castro Date: Mon, 9 Dec 2024 10:44:18 -0300 Subject: Cambios varios. --- lua/config/autocmds.lua | 55 ++++++++-- lua/config/composer.lua | 104 +++++++++++++++++++ lua/config/init.lua | 1 + lua/config/lazy.lua | 6 +- lua/pi/dap/init.lua | 10 +- lua/pi/lsp/servers/phpactor.lua | 6 +- lua/plugins/CodeGPT.lua | 10 -- lua/plugins/aerial.lua | 54 ++++++++++ lua/plugins/close-buffer.lua | 12 +++ lua/plugins/code-annotation.lua | 35 +++++++ lua/plugins/codecompanion.lua | 15 +++ lua/plugins/copilot-chat.lua | 219 +++++++++++++++++++++++++++++++++++++++- lua/plugins/flutter.lua | 2 +- lua/plugins/hurl.lua | 39 +++++++ lua/plugins/icon-picker.lua | 2 +- lua/plugins/lsp.lua | 3 - lua/plugins/navigator.lua | 43 ++++++++ lua/plugins/neotest.lua | 6 ++ lua/plugins/note.lua | 29 ++++++ lua/plugins/nvim-ts-autotag.lua | 7 ++ lua/plugins/rayso.lua | 10 ++ lua/plugins/spectre.lua | 70 ++++++++++++- lua/plugins/undotree.lua | 40 ++++++-- lua/plugins/which-key.lua | 12 ++- lua/plugins/zenmode.lua | 44 ++++++++ 25 files changed, 779 insertions(+), 55 deletions(-) create mode 100644 lua/config/composer.lua delete mode 100644 lua/plugins/CodeGPT.lua create mode 100644 lua/plugins/aerial.lua create mode 100644 lua/plugins/close-buffer.lua create mode 100644 lua/plugins/code-annotation.lua create mode 100644 lua/plugins/codecompanion.lua create mode 100644 lua/plugins/hurl.lua create mode 100644 lua/plugins/navigator.lua create mode 100644 lua/plugins/note.lua create mode 100644 lua/plugins/nvim-ts-autotag.lua create mode 100644 lua/plugins/rayso.lua create mode 100644 lua/plugins/zenmode.lua (limited to 'lua') diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index 86d3e1d..24ff236 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -38,17 +38,6 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, { end, }) -if vim.fn.has "persistent_undo" then - local target_path = vim.fn.expand "~/.cache/undodir" - -- crear el directorio y cualquier directorio padre - -- si la ubicación no existe. - if not vim.fn.isdirectory(target_path) then - vim.fn.mkdir(target_path, "p", 0700) - end - - vim.o.undodir = target_path - vim.o.undofile = true -end -- Función para alternar el ajuste de línea function ToggleWrap() local wrap = vim.wo.wrap @@ -84,3 +73,47 @@ vim.api.nvim_create_autocmd("BufEnter", { end end, }) + +-- Autocmds are automatically loaded on the VeryLazy event +-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua +-- Add any additional autocmds here +-- +local function augroup(name) + return vim.api.nvim_create_augroup("my_lazyvim_" .. name, { clear = true }) +end + +-- Set filetype for .env and .env.* files +vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + group = augroup("env_filetype"), + pattern = { "*.env", ".env.*" }, + callback = function() + vim.opt_local.filetype = "sh" + end, +}) + +-- Set filetype for .hurl files +vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + group = augroup("hurl_filetype"), + pattern = { "*.hurl" }, + callback = function() + vim.opt_local.filetype = "hurl" + end, +}) + +-- Set filetype for .toml files +vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + group = augroup("toml_filetype"), + pattern = { "*.tomg-config*" }, + callback = function() + vim.opt_local.filetype = "toml" + end, +}) + +-- Set filetype for .ejs files +vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { + group = augroup("ejs_filetype"), + pattern = { "*.ejs", "*.ejs.t" }, + callback = function() + vim.opt_local.filetype = "embedded_template" + end, +}) diff --git a/lua/config/composer.lua b/lua/config/composer.lua new file mode 100644 index 0000000..2405416 --- /dev/null +++ b/lua/config/composer.lua @@ -0,0 +1,104 @@ +vim.treesitter.query.set( + "json", + "composer_dependencies", + [[ + (pair + key: (string + (string_content) @key (#match? @key "require|require-dev") + ) + value: (object + (pair + key: (string (string_content) @depen) + ) + ) + ) + ]] +) +local group = vim.api.nvim_create_augroup("composer-info", {}) +vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost" }, { + pattern = "composer.json", + group = group, + callback = function(event) + local parser = vim.treesitter.get_parser(event.buf, "json") + local tree = parser:parse()[1] + if tree == nil then + return + end + local query = vim.treesitter.query.get("json", "composer_dependencies") + if not query then + return + end + + local dependencies = {} + + for id, node in query:iter_captures(tree:root(), event.buf) do + if query.captures[id] == "depen" then + table.insert(dependencies, { + name = vim.treesitter.get_node_text(node, event.buf), + line = node:start(), + }) + end + end + + if #dependencies == 0 then + return + end + + local ns = vim.api.nvim_create_namespace("composer-deps") + vim.api.nvim_buf_clear_namespace(event.buf, ns, 0, -1) + + vim.system( + { "composer", "info", "-f", "json" }, + {}, + vim.schedule_wrap(function(out) + if out.code ~= 0 then + return + end + + local data = vim.json.decode(out.stdout, {}) + if type(data.installed) ~= "table" then + return + end + + for _, dep in ipairs(dependencies) do + local info = vim.iter(data.installed):find(function(inst) + return dep.name == inst.name + end) + if info then + vim.api.nvim_buf_set_extmark(event.buf, ns, dep.line, 0, { + virt_text = { { string.format('<- %s', info.version), "comment" } }, + virt_text_pos = "eol", + }) + end + end + end) + ) + vim.system( + { "composer", "outdated", "-f", "json" }, + {}, + vim.schedule_wrap(function(out) + if out.code ~= 0 then + return + end + + local data = vim.json.decode(out.stdout, {}) + if type(data.installed) ~= "table" then + return + end + + for _, dep in ipairs(dependencies) do + local info = vim.iter(data.installed):find(function(inst) + return dep.name == inst.name + end) + if info then + vim.api.nvim_buf_set_extmark(event.buf, ns, dep.line - 1, 0, { + virt_text = { { string.format('^ %s (new version)', info.latest), "error" } }, + virt_text_pos = "eol", + }) + end + end + end) + ) + end, +}) + diff --git a/lua/config/init.lua b/lua/config/init.lua index 008ebf5..74e9c00 100644 --- a/lua/config/init.lua +++ b/lua/config/init.lua @@ -8,6 +8,7 @@ vim.api.nvim_create_autocmd("User", { require "config.usercmds" require "config.keymaps" require "config.diagnostic" + require "config.composer" end, }) require "config.lazy" diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 70aaec7..34e034f 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -13,7 +13,7 @@ vim.opt.rtp:prepend(lazypath) require("lazy").setup { -- leave nil when passing the spec as the first argument to setup() - spec = { { import = "plugins" } }, + spec = { { "LazyVim/LazyVim", import = "plugins" } }, local_spec = true, -- load project specific .lazy.lua spec files. They will be added at the end of the spec. defaults = { -- Set this to `true` to have all your plugins lazy-loaded by default. @@ -200,7 +200,3 @@ require("lazy").setup { }, } - - - - diff --git a/lua/pi/dap/init.lua b/lua/pi/dap/init.lua index 97084fd..13b6954 100644 --- a/lua/pi/dap/init.lua +++ b/lua/pi/dap/init.lua @@ -10,11 +10,11 @@ for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/pi/dap/configs/*.lua end -- Signs -vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "", linehl = "", numhl = "" }) -vim.fn.sign_define("DapStopped", { text = "▶", texthl = "", linehl = "", numhl = "" }) -vim.fn.sign_define("DapBreakpointRejected", { text = "", texthl = "", linehl = "", numhl = "" }) -vim.fn.sign_define("DapBreakpointCondition", { text = "", texthl = "", linehl = "", numhl = "" }) -vim.fn.sign_define("DapLogPoint", { text = "󰍢", texthl = "", linehl = "", numhl = "" }) +vim.fn.sign_define("DapBreakpoint", { text = " ", texthl = "", linehl = "", numhl = "" }) +vim.fn.sign_define("DapStopped", { text = " ", texthl = "", linehl = "", numhl = "" }) +vim.fn.sign_define("DapBreakpointRejected", { text = " ", texthl = "", linehl = "", numhl = "" }) +vim.fn.sign_define("DapBreakpointCondition", { text = " ", texthl = "", linehl = "", numhl = "" }) +vim.fn.sign_define("DapLogPoint", { text = "󰍢 ", texthl = "", linehl = "", numhl = "" }) -- UI structure dapui.setup { diff --git a/lua/pi/lsp/servers/phpactor.lua b/lua/pi/lsp/servers/phpactor.lua index e5a92ed..6196cdb 100644 --- a/lua/pi/lsp/servers/phpactor.lua +++ b/lua/pi/lsp/servers/phpactor.lua @@ -28,8 +28,8 @@ local function phpactor_attach(_, bufnr) }, position = "50%", size = { - width = "80%", - height = "60%", + width = "60%", + height = "40%", }, } @@ -65,7 +65,7 @@ return function(ops) ["language_server_configuration.auto_config"] = false, ["code_transform.import_globals"] = true, ["language_server_phpstan.enabled"] = true, - ["language_server_phpstan.level"] = 7, + ["language_server_phpstan.level"] = "7", ["language_server_phpstan.bin"] = "phpstan", }, handlers = { diff --git a/lua/plugins/CodeGPT.lua b/lua/plugins/CodeGPT.lua deleted file mode 100644 index ee3579b..0000000 --- a/lua/plugins/CodeGPT.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - "dpayne/CodeGPT.nvim", - dependencies = { - 'nvim-lua/plenary.nvim', - 'MunifTanjim/nui.nvim', - }, - config = function() - require("codegpt.config") - end -} diff --git a/lua/plugins/aerial.lua b/lua/plugins/aerial.lua new file mode 100644 index 0000000..f8bc139 --- /dev/null +++ b/lua/plugins/aerial.lua @@ -0,0 +1,54 @@ +-- Silent keymap option +local opts = { silent = true } + +return { + { + "folke/edgy.nvim", + optional = true, + opts = function(_, opts) + opts.right = opts.right or {} + table.insert(opts.right, "aerial") + table.insert(opts.right, { + title = "hurl.nvim", + ft = "hurl-nvim", + size = { width = 0.5 }, + }) + + end, + }, + { + "stevearc/aerial.nvim", + keys = { + { "ta", "AerialToggle", desc = "AerialToggle" }, + }, + config = function() + local status_ok, aerial = pcall(require, "aerial") + if not status_ok then + return + end + + aerial.setup({ + -- optionally use on_attach to set keymaps when aerial has attached to a buffer + on_attach = function(bufnr) + -- Jump forwards/backwards with '{' and '}' + vim.keymap.set("n", "{", "AerialPrev", { buffer = bufnr }) + vim.keymap.set("n", "}", "AerialNext", { buffer = bufnr }) + + vim.keymap.set("n", "fi", "Telescope aerial", opts) + end, + }) + + local tele_status_ok, telescope = pcall(require, "telescope") + if not tele_status_ok then + return + end + + -- Define a custom command to open aerial with telescope + vim.keymap.set("n", "fi", "Telescope aerial", { + desc = "Telescope Aerial", + }) + + telescope.load_extension("aerial") + end, + }, +} diff --git a/lua/plugins/close-buffer.lua b/lua/plugins/close-buffer.lua new file mode 100644 index 0000000..947f31a --- /dev/null +++ b/lua/plugins/close-buffer.lua @@ -0,0 +1,12 @@ +return { + -- Send buffers into early retirement by automatically closing them after x minutes of inactivity. + { + "chrisgrieser/nvim-early-retirement", + config = true, + event = "VeryLazy", + opts = { + -- if a buffer has been inactive for this many minutes, close it + retirementAgeMins = 30, + }, + }, +} diff --git a/lua/plugins/code-annotation.lua b/lua/plugins/code-annotation.lua new file mode 100644 index 0000000..eae61d0 --- /dev/null +++ b/lua/plugins/code-annotation.lua @@ -0,0 +1,35 @@ +local neogeo_opts = {} + +if not vim.g.vscode then + neogeo_opts = { + enabled = true, + -- Only use luasnip as snippet engine if that is not vscode + snippet_engine = "luasnip", + } +end + +return { + -- JsDoc generator + { + "heavenshell/vim-jsdoc", + ft = "javascript,typescript,typescriptreact,svelte", + cmd = "JsDoc", + keys = { + { "jd", "JsDoc", desc = "JsDoc" }, + }, + -- make sure that you will have lehre install locally on plugin folder, refer https://github.com/heavenshell/vim-jsdoc#manual-installation + build = "make install", + }, + { + -- A better annotation generator. Supports multiple languages and annotation conventions. + -- to jump to next annotation, to jump to previous annotation + "danymat/neogen", + vscode = true, + dependencies = "nvim-treesitter/nvim-treesitter", + opts = neogeo_opts, + cmd = "Neogen", + keys = { + { "ci", "Neogen", desc = "Neogen - Annotation generator" }, + }, + }, +} diff --git a/lua/plugins/codecompanion.lua b/lua/plugins/codecompanion.lua new file mode 100644 index 0000000..a98a7af --- /dev/null +++ b/lua/plugins/codecompanion.lua @@ -0,0 +1,15 @@ +return { + "olimorris/codecompanion.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + "hrsh7th/nvim-cmp", -- Optional: For using slash commands and variables in the chat buffer + "nvim-telescope/telescope.nvim", -- Optional: For using slash commands + { + "MeanderingProgrammer/render-markdown.nvim", + ft = { "markdown", "codecompanion" }, + }, -- Optional: For prettier markdown rendering + { "stevearc/dressing.nvim", opts = {} }, -- Optional: Improves `vim.ui.select` + }, + config = true, +} diff --git a/lua/plugins/copilot-chat.lua b/lua/plugins/copilot-chat.lua index 63ec0b2..0ae500d 100644 --- a/lua/plugins/copilot-chat.lua +++ b/lua/plugins/copilot-chat.lua @@ -1,15 +1,224 @@ +local IS_DEV = false + +local prompts = { + -- Code related prompts + Explain = "Please explain how the following code works.", + Review = "Please review the following code and provide suggestions for improvement.", + Tests = "Please explain how the selected code works, then generate unit tests for it.", + Refactor = "Please refactor the following code to improve its clarity and readability.", + FixCode = "Please fix the following code to make it work as intended.", + FixError = "Please explain the error in the following text and provide a solution.", + BetterNamings = "Please provide better names for the following variables and functions.", + Documentation = "Please provide documentation for the following code.", + SwaggerApiDocs = "Please provide documentation for the following API using Swagger.", + SwaggerJsDocs = "Please write JSDoc for the following API using Swagger.", + -- Text related prompts + Summarize = "Please summarize the following text.", + Spelling = "Please correct any grammar and spelling errors in the following text.", + Wording = "Please improve the grammar and wording of the following text.", + Concise = "Please rewrite the following text to make it more concise.", +} + return { + -- { import = "plugins.extras.copilot-vim" }, -- Or use { import = "lazyvim.plugins.extras.coding.copilot" }, + { + "folke/which-key.nvim", + optional = true, + opts = { + spec = { + { "a", group = "ai" }, + { "gm", group = "+Copilot chat" }, + { "gmh", desc = "Show help" }, + { "gmd", desc = "Show diff" }, + { "gmp", desc = "Show system prompt" }, + { "gms", desc = "Show selection" }, + { "gmy", desc = "Yank diff" }, + }, + }, + }, { + dir = IS_DEV and "~/Projects/research/CopilotChat.nvim" or nil, "CopilotC-Nvim/CopilotChat.nvim", - branch = "canary", + -- version = "v3.3.0", -- Use a specific version to prevent breaking changes dependencies = { + { "nvim-telescope/telescope.nvim" }, -- Use telescope for help actions + { "nvim-lua/plenary.nvim" }, { "zbirenbaum/copilot.lua" }, -- or github/copilot.vim - { "nvim-lua/plenary.nvim" }, -- for curl, log wrapper }, opts = { - debug = true, -- Enable debugging - -- See Configuration section for rest + question_header = "## User ", + answer_header = "## Copilot ", + error_header = "## Error ", + prompts = prompts, + auto_follow_cursor = false, -- Don't follow the cursor after getting response + mappings = { + -- Use tab for completion + complete = { + detail = "Use @ or / for options.", + insert = "", + }, + -- Close the chat + close = { + normal = "q", + insert = "", + }, + -- Reset the chat buffer + reset = { + normal = "", + insert = "", + }, + -- Submit the prompt to Copilot + submit_prompt = { + normal = "", + insert = "", + }, + -- Accept the diff + accept_diff = { + normal = "", + insert = "", + }, + -- Yank the diff in the response to register + yank_diff = { + normal = "gmy", + }, + -- Show the diff + show_diff = { + normal = "gmd", + }, + -- Show the info + show_info = { + normal = "gmi", + }, + -- Show the context + show_context = { + normal = "gmc", + }, + -- Show help + show_help = { + normal = "gmh", + }, + }, + }, + config = function(_, opts) + local chat = require("CopilotChat") + local select = require("CopilotChat.select") + -- Use unnamed register for the selection + opts.selection = select.unnamed + + chat.setup(opts) + + vim.api.nvim_create_user_command("CopilotChatVisual", function(args) + chat.ask(args.args, { selection = select.visual }) + end, { nargs = "*", range = true }) + + -- Inline chat with Copilot + vim.api.nvim_create_user_command("CopilotChatInline", function(args) + chat.ask(args.args, { + selection = select.visual, + window = { + layout = "float", + relative = "cursor", + width = 1, + height = 0.4, + row = 1, + }, + }) + end, { nargs = "*", range = true }) + + -- Restore CopilotChatBuffer + vim.api.nvim_create_user_command("CopilotChatBuffer", function(args) + chat.ask(args.args, { selection = select.buffer }) + end, { nargs = "*", range = true }) + + -- Custom buffer for CopilotChat + vim.api.nvim_create_autocmd("BufEnter", { + pattern = "copilot-*", + callback = function() + vim.opt_local.relativenumber = true + vim.opt_local.number = true + + -- Get current filetype and set it to markdown if the current filetype is copilot-chat + local ft = vim.bo.filetype + if ft == "copilot-chat" then + vim.bo.filetype = "markdown" + end + end, + }) + end, + event = "VeryLazy", + keys = { + -- Show prompts actions with telescope + { + "ap", + function() + local actions = require("CopilotChat.actions") + require("CopilotChat.integrations.telescope").pick(actions.prompt_actions()) + end, + desc = "CopilotChat - Prompt actions", + }, + { + "ap", + ":lua require('CopilotChat.integrations.telescope').pick(require('CopilotChat.actions').prompt_actions({selection = require('CopilotChat.select').visual}))", + mode = "x", + desc = "CopilotChat - Prompt actions", + }, + -- Code related commands + { "ae", "CopilotChatExplain", desc = "CopilotChat - Explain code" }, + { "at", "CopilotChatTests", desc = "CopilotChat - Generate tests" }, + { "ar", "CopilotChatReview", desc = "CopilotChat - Review code" }, + { "aR", "CopilotChatRefactor", desc = "CopilotChat - Refactor code" }, + { "an", "CopilotChatBetterNamings", desc = "CopilotChat - Better Naming" }, + -- Chat with Copilot in visual mode + { + "av", + ":CopilotChatVisual", + mode = "x", + desc = "CopilotChat - Open in vertical split", + }, + { + "ax", + ":CopilotChatInline", + mode = "x", + desc = "CopilotChat - Inline chat", + }, + -- Custom input for CopilotChat + { + "ai", + function() + local input = vim.fn.input("Ask Copilot: ") + if input ~= "" then + vim.cmd("CopilotChat " .. input) + end + end, + desc = "CopilotChat - Ask input", + }, + -- Generate commit message based on the git diff + { + "am", + "CopilotChatCommit", + desc = "CopilotChat - Generate commit message for all changes", + }, + -- Quick chat with Copilot + { + "aq", + function() + local input = vim.fn.input("Quick Chat: ") + if input ~= "" then + vim.cmd("CopilotChatBuffer " .. input) + end + end, + desc = "CopilotChat - Quick chat", + }, + -- Debug + { "ad", "CopilotChatDebugInfo", desc = "CopilotChat - Debug Info" }, + -- Fix the issue with diagnostic + { "af", "CopilotChatFixDiagnostic", desc = "CopilotChat - Fix Diagnostic" }, + -- Clear buffer and chat history + { "al", "CopilotChatReset", desc = "CopilotChat - Clear buffer and chat history" }, + -- Toggle Copilot Chat Vsplit + { "av", "CopilotChatToggle", desc = "CopilotChat - Toggle" }, + -- Copilot Chat Models + { "a?", "CopilotChatModels", desc = "CopilotChat - Select Models" }, }, - -- See Commands section for default commands if you want to lazy load on them }, } diff --git a/lua/plugins/flutter.lua b/lua/plugins/flutter.lua index 91cabad..9d83940 100644 --- a/lua/plugins/flutter.lua +++ b/lua/plugins/flutter.lua @@ -1,7 +1,7 @@ return { 'akinsho/flutter-tools.nvim', - lazy = true, + lazy = false, filetype = 'dart', dependencies = { 'nvim-lua/plenary.nvim', diff --git a/lua/plugins/hurl.lua b/lua/plugins/hurl.lua new file mode 100644 index 0000000..cd949ee --- /dev/null +++ b/lua/plugins/hurl.lua @@ -0,0 +1,39 @@ +local IS_DEV = false + +return { + { + "jellydn/hurl.nvim", + dir = IS_DEV and "~/Projects/research/hurl.nvim" or nil, + ft = "hurl", + dependencies = { "MunifTanjim/nui.nvim", "nvim-treesitter/nvim-treesitter" }, + opts = { + mode = "split", + auto_close = false, + debug = false, + show_notification = false, + formatters = { + json = { "jq" }, + html = { + "prettier", + "--parser", + "html", + }, + }, + }, + keys = { + -- Run API request + { "rA", "HurlRunner", desc = "Hurl - Run All requests" }, + { "ra", "HurlRunnerAt", desc = "Hurl - Run Api request" }, + { "re", "HurlRunnerToEntry", desc = "Hurl -Run Api request to entry" }, + { "th", "HurlToggleMode", desc = "Hurl - Toggle Mode" }, + { "rv", "HurlVerbose", desc = "Hurl - Run Api in verbose mode" }, + -- Run Hurl request in visual mode + { "rh", ":HurlRunner", desc = "Hurl Runner", mode = "v" }, + -- Show last response + { "rh", "HurlShowLastResponse", desc = "Hurl History", mode = "n" }, + -- Manage variable + { "hg", ":HurlSetVariable", desc = "Hurl - Set global variable" }, + { "hG", "HurlManageVariable", desc = "Hurl - Manage global variable" }, + }, + }, +} diff --git a/lua/plugins/icon-picker.lua b/lua/plugins/icon-picker.lua index a466b6a..adb1bb4 100644 --- a/lua/plugins/icon-picker.lua +++ b/lua/plugins/icon-picker.lua @@ -3,7 +3,7 @@ return { keys = { { "i", "IconPickerNormal nerd_font", mode = "n", desc = "IconPicker NerdFont Insert" }, { "y", "IconPickerYank nerd_font", mode = "n", desc = "IconPicker NerdFont Yank" }, - { "", "IconPickerInsert nerd_font", mode = "i", desc = "IconPicker NerdFont Insert mode" }, + { "", "IconPickerInsert nerd_font emoji alt_font nerd_font_v3 symbols ", mode = "i", desc = "IconPicker NerdFont Insert mode" }, }, opts = { disable_legacy_commands = true }, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 0799874..eae804e 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -21,8 +21,5 @@ return { enable = true, auto_install = false, }, - servers = { - phpactor = { enable = true }, - }, }, } diff --git a/lua/plugins/navigator.lua b/lua/plugins/navigator.lua new file mode 100644 index 0000000..53a7735 --- /dev/null +++ b/lua/plugins/navigator.lua @@ -0,0 +1,43 @@ +-- [[ +-- Use or :q! to kill the floating window +-- (or , ) to move +-- or to open location or apply code actions. Note: might be bound in insert mode by other plugins +-- ]] +return { + { + "ray-x/navigator.lua", + event = "LspAttach", + dependencies = { + { "ray-x/guihua.lua", build = "cd lua/fzy && make" }, + { + "neovim/nvim-lspconfig", + }, + }, + opts = { + default_mapping = false, + lsp = { + disable_lsp = "all", + hover = { + enable = false, + }, + }, + }, + -- Refer more usage on https://raw.githubusercontent.com/ray-x/navigator.lua/master/lua/navigator/lspclient/mapping.lua + keys = { + { "gr", ":lua require'navigator.reference'.async_ref()", desc = "Navigator - Async reference" }, + { "gS", ":lua require'navigator.symbols'.document_symbols()", desc = "Navigator - Document symbols" }, + { + "gw", + ":lua require'navigator.workspace'.workspace_symbol_live()", + desc = "Navigator - workspace symbols live", + }, + { "gd", ":lua require'navigator.definition'.definition()", desc = "Navigator - Definition" }, + { + "gp", + ":lua require'navigator.definition'.definition_preview()", + desc = "Navigator - Definition preview", + }, + { "ga", ":lua require'navigator.codeAction'.code_action()", desc = "Navigator - Code Action" }, + }, + }, +} diff --git a/lua/plugins/neotest.lua b/lua/plugins/neotest.lua index 2afc490..c00f12e 100644 --- a/lua/plugins/neotest.lua +++ b/lua/plugins/neotest.lua @@ -10,11 +10,17 @@ return { "nvim-neotest/neotest-plenary", "nvim-neotest/neotest-vim-test", "anuvyklack/hydra.nvim", + "nvim-neotest/neotest-python", }, config = function() local neotest = require "neotest" neotest.setup { adapters = { + ["neotest-python"] = { + -- Here you can specify the settings for the adapter, i.e. + -- runner = "pytest", + -- python = ".venv/bin/python", + }, require "neotest-go", require('rustaceanvim.neotest'), require "neotest-plenary", diff --git a/lua/plugins/note.lua b/lua/plugins/note.lua new file mode 100644 index 0000000..2728bde --- /dev/null +++ b/lua/plugins/note.lua @@ -0,0 +1,29 @@ +return { + { + "jellydn/my-note.nvim", + dependencies = { "MunifTanjim/nui.nvim" }, + keys = { + { + "mn", + "MyNote", + desc = "Open MyNote", + }, + { + "mg", + "MyNote global", + desc = "Open MyNote Global", + }, + }, + opts = { + files = { + -- Using the parent .git folder as the cwd + cwd = function() + local bufPath = vim.api.nvim_buf_get_name(0) + local cwd = require("lspconfig").util.root_pattern(".git")(bufPath) + + return cwd + end, + }, + }, + }, +} diff --git a/lua/plugins/nvim-ts-autotag.lua b/lua/plugins/nvim-ts-autotag.lua new file mode 100644 index 0000000..59473b2 --- /dev/null +++ b/lua/plugins/nvim-ts-autotag.lua @@ -0,0 +1,7 @@ +return { + 'windwp/nvim-ts-autotag', + ft = {'html', 'javascript', 'typescript', 'javascriptreact', 'typescriptreact', 'svelte', 'vue', 'php', 'jsx', 'tsx', 'erb', 'ejs', 'pug', 'liquid', 'hbs', 'twig', 'blade', 'html.handlebars'}, + config = function() + require('nvim-ts-autotag').setup() + end +} diff --git a/lua/plugins/rayso.lua b/lua/plugins/rayso.lua new file mode 100644 index 0000000..8821e47 --- /dev/null +++ b/lua/plugins/rayso.lua @@ -0,0 +1,10 @@ +return { + { + "TobinPalmer/rayso.nvim", + cmd = { "Rayso" }, + keys = { + { "cs", "Rayso", desc = "Screenshot code" }, + }, + config = true, + }, +} diff --git a/lua/plugins/spectre.lua b/lua/plugins/spectre.lua index 7510c7a..e3840af 100644 --- a/lua/plugins/spectre.lua +++ b/lua/plugins/spectre.lua @@ -1,5 +1,69 @@ +--- General configuration for spectre base on current git repo +---@param default_opts table | nil +---@return table +function _G.get_spectre_options(default_opts) + local Path = require("utils.path") + local opts = default_opts or {} + + if Path.is_git_repo() then + opts.cwd = Path.get_git_root() + end + + return opts +end + return { - "nvim-pack/nvim-spectre", - keys = { { "F", ":Spectre", desc = "Spectre Search open" } }, - config = true, + { "MagicDuck/grug-far.nvim", enabled = false }, + { + -- Search and replace with pattern + "nvim-pack/nvim-spectre", + cmd = "Spectre", + opts = { open_cmd = "noswapfile vnew" }, + keys = { + { + "sr", + function() + require("spectre").open() + end, + desc = "Replace in files", + }, + { + "sp", + ":lua require('spectre').open(_G.get_spectre_options())", + desc = "Replace in files (Root dir)", + }, + -- Search current word + { + "sP", + ":lua require('spectre').open_visual(_G.get_spectre_options({ select_word = true }))", + desc = "Replace current word (Root dir)", + }, + -- Open search with select word in visual mode + { + "sr", + ":lua require('spectre').open_visual(_G.get_spectre_options())", + mode = "v", + silent = true, + desc = "Replace current word (Root dir)", + }, + -- Search on current file + { + "sf", + ":lua require('spectre').open_file_search(_G.get_spectre_options({ select_word = true }))", + desc = "Replace in current file", + }, + }, + }, + { + "folke/edgy.nvim", + optional = true, + opts = function(_, opts) + opts.left = opts.left or {} + table.insert(opts.left, { + title = "Spectre", + ft = "spectre_panel", + size = { width = 0.3 }, + }) + end, + }, } diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua index 3f96d83..fd105c5 100644 --- a/lua/plugins/undotree.lua +++ b/lua/plugins/undotree.lua @@ -1,11 +1,37 @@ return { - "mbbill/undotree", - lazy = false, -- needs to be explicitly set, because of the keys property - keys = { - { - "u", - vim.cmd.UndotreeToggle, - desc = "Toggle undotree", + { + "mbbill/undotree", + cmd = "UndotreeToggle", + keys = { + -- [U]ndo [T]ree + { "uT", "UndotreeToggle", desc = "Undo Tree Toggle" }, }, + init = function() + -- Persist undo, refer https://github.com/mbbill/undotree#usage + local undodir = vim.fn.expand("~/.cache/undodir") + + if vim.fn.has("persistent_undo") == 1 then + if vim.fn.isdirectory(undodir) == 0 then + os.execute("mkdir -p " .. undodir) + end + + vim.opt.undodir = undodir + vim.opt.undofile = true + end + + -- set layout style to 2, let g:undotree_WindowLayout = 2 + vim.g.undotree_WindowLayout = 2 + end, + }, + { + "folke/edgy.nvim", + optional = true, + opts = function(_, opts) + opts.left = opts.left or {} + table.insert(opts.left, { + title = "Undo Tree", + ft = "undotree", + }) + end, }, } diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua index b9a47db..2d8d47d 100644 --- a/lua/plugins/which-key.lua +++ b/lua/plugins/which-key.lua @@ -2,7 +2,17 @@ return { "folke/which-key.nvim", event = "VeryLazy", opts = { - preset = "modern" + preset = "modern", + spec = { + { "a", group = "ai" }, + { "gm", group = "+Copilot chat" }, + { "gmh", desc = "Show help" }, + { "gmd", desc = "Show diff" }, + { "gmp", desc = "Show system prompt" }, + { "gms", desc = "Show selection" }, + { "gmy", desc = "Yank diff" }, + }, + }, keys = { { diff --git a/lua/plugins/zenmode.lua b/lua/plugins/zenmode.lua new file mode 100644 index 0000000..a6922c6 --- /dev/null +++ b/lua/plugins/zenmode.lua @@ -0,0 +1,44 @@ +-- Calculate min width of the window should be 70% of the editor width or 90 columns +-- whichever is smaller +local function zen_mode_width() + local width = vim.api.nvim_win_get_width(0) + local min_width = math.max(width * 0.70, 90) + return math.min(width, min_width) +end + +return { + { + "folke/zen-mode.nvim", + cmd = { "ZenMode" }, + opts = { + window = { + width = zen_mode_width(), + }, + plugins = { + options = { + enabled = true, + ruler = false, -- disables the ruler text in the cmd line area + showcmd = false, -- disables the command in the last line of the screen + laststatus = 0, -- turn off the statusline in zen mode + }, + -- NOTE: Those options are disables by default, change to enabled = true to enable + gitsigns = { enabled = false }, -- disables git signs + tmux = { enabled = false }, -- disables the tmux statusline + -- NOTE: Need to add to wezterm config https://github.com/folke/zen-mode.nvim#wezterm + wezterm = { + enabled = false, + font = "+1", -- +1 font size or fixed size, e.g. 21 + }, + }, + }, + config = true, + keys = { + -- add cz to enter zen mode + { + "cz", + "ZenMode", + desc = "Distraction Free Mode", + }, + }, + }, +} -- cgit v1.2.3