From 9844c832ba3e503dd791ae39d2bcb884599592f7 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Fri, 5 Sep 2025 09:39:31 -0400 Subject: [PATCH 1/7] (nvim) format all lua files --- nvim/lua/juancwu/config/clipboard.lua | 106 +++--- nvim/lua/juancwu/config/init.lua | 100 +++--- nvim/lua/juancwu/config/options.lua | 14 +- nvim/lua/juancwu/init.lua | 2 +- nvim/lua/juancwu/plugins/autocomplete.lua | 170 ++++----- nvim/lua/juancwu/plugins/autopairs.lua | 18 +- nvim/lua/juancwu/plugins/autotag.lua | 56 +-- nvim/lua/juancwu/plugins/colorscheme.lua | 80 ++--- nvim/lua/juancwu/plugins/comment.lua | 57 ++- nvim/lua/juancwu/plugins/conform.lua | 107 +++--- nvim/lua/juancwu/plugins/fugitive.lua | 44 +-- nvim/lua/juancwu/plugins/gitsigns.lua | 32 +- nvim/lua/juancwu/plugins/godoc.lua | 36 +- nvim/lua/juancwu/plugins/harpoon.lua | 36 +- nvim/lua/juancwu/plugins/indent-blankline.lua | 18 +- nvim/lua/juancwu/plugins/lazydev.lua | 12 +- nvim/lua/juancwu/plugins/lsp.lua | 262 +++++++------- nvim/lua/juancwu/plugins/lualine.lua | 100 +++--- nvim/lua/juancwu/plugins/luvit-meta.lua | 4 +- nvim/lua/juancwu/plugins/neo-tree.lua | 136 ++++---- nvim/lua/juancwu/plugins/nvim-lint.lua | 126 +++---- nvim/lua/juancwu/plugins/oil.lua | 50 +-- nvim/lua/juancwu/plugins/render-markdown.lua | 14 +- nvim/lua/juancwu/plugins/telescope.lua | 330 +++++++++--------- nvim/lua/juancwu/plugins/todo-comments.lua | 6 +- nvim/lua/juancwu/plugins/toggleterm.lua | 92 ++--- nvim/lua/juancwu/plugins/treesitter.lua | 194 +++++----- nvim/lua/juancwu/plugins/undotree.lua | 30 +- nvim/lua/juancwu/plugins/which-key.lua | 90 ++--- nvim/lua/juancwu/utils/colors.lua | 32 +- nvim/lua/juancwu/utils/init.lua | 8 +- nvim/lua/juancwu/utils/os.lua | 24 +- 32 files changed, 1200 insertions(+), 1186 deletions(-) diff --git a/nvim/lua/juancwu/config/clipboard.lua b/nvim/lua/juancwu/config/clipboard.lua index c0bb3ae..8aade05 100644 --- a/nvim/lua/juancwu/config/clipboard.lua +++ b/nvim/lua/juancwu/config/clipboard.lua @@ -1,58 +1,58 @@ local Utils = require("juancwu.utils") if Utils.os.is_linux() then - local wayland_display = os.getenv("WAYLAND_DISPLAY") - if Utils.os.is_wsl() then - vim.g.clipboard = { - name = "win32yank", - copy = { - ["+"] = "win32yank.exe -i --crlf", - ["*"] = "win32yank.exe -i --crlf", - }, - paste = { - ["+"] = "win32yank.exe -o --lf", - ["*"] = "win32yank.exe -o --lf", - }, - cache_enabled = 0, - } - elseif wayland_display then - vim.g.clipboard = { - name = "wl-clipboard", - copy = { - ["+"] = "wl-copy", - ["*"] = "wl-copy", - }, - paste = { - ["+"] = "wl-paste", - ["*"] = "wl-paste", - }, - cache_enabled = 1, - } - else - vim.g.clipboard = { - name = "xclip", - copy = { - ["+"] = "xclip -sel clip -i -quiet", - ["*"] = "xclip -sel primary -i -quiet", - }, - paste = { - ["+"] = "xclip -sel clip -o -quiet", - ["*"] = "xclip -sel primary -o -quiet", - }, - cache_enabled = 1, - } - end + local wayland_display = os.getenv("WAYLAND_DISPLAY") + if Utils.os.is_wsl() then + vim.g.clipboard = { + name = "win32yank", + copy = { + ["+"] = "win32yank.exe -i --crlf", + ["*"] = "win32yank.exe -i --crlf", + }, + paste = { + ["+"] = "win32yank.exe -o --lf", + ["*"] = "win32yank.exe -o --lf", + }, + cache_enabled = 0, + } + elseif wayland_display then + vim.g.clipboard = { + name = "wl-clipboard", + copy = { + ["+"] = "wl-copy", + ["*"] = "wl-copy", + }, + paste = { + ["+"] = "wl-paste", + ["*"] = "wl-paste", + }, + cache_enabled = 1, + } + else + vim.g.clipboard = { + name = "xclip", + copy = { + ["+"] = "xclip -sel clip -i -quiet", + ["*"] = "xclip -sel primary -i -quiet", + }, + paste = { + ["+"] = "xclip -sel clip -o -quiet", + ["*"] = "xclip -sel primary -o -quiet", + }, + cache_enabled = 1, + } + end elseif Utils.os.is_mac() then - vim.g.clipboard = { - name = "mac-clipboard", - copy = { - ["+"] = "pbcopy", - ["*"] = "pbcopy", - }, - paste = { - ["+"] = "pbpaste", - ["*"] = "pbpaste", - }, - cache_enabled = 1, - } + vim.g.clipboard = { + name = "mac-clipboard", + copy = { + ["+"] = "pbcopy", + ["*"] = "pbcopy", + }, + paste = { + ["+"] = "pbpaste", + ["*"] = "pbpaste", + }, + cache_enabled = 1, + } end diff --git a/nvim/lua/juancwu/config/init.lua b/nvim/lua/juancwu/config/init.lua index 203664d..b2525b0 100644 --- a/nvim/lua/juancwu/config/init.lua +++ b/nvim/lua/juancwu/config/init.lua @@ -3,22 +3,22 @@ local M = {} ---@class ConfigOptions local defaultOpts = { - ---@type string | fun() - colorscheme = "rose-pine", + ---@type string | fun() + colorscheme = "rose-pine", } vim.g.disable_autoformat = false ---@param name "options" | "keymaps" | "clipboard" function M.load(name) - local mod = "juancwu.config." .. name - local error_handler = function(err) - local msg = "Failed loading " .. mod .. "\n\n" .. err - print(msg) - end - xpcall(function() - require(mod) - end, error_handler) + local mod = "juancwu.config." .. name + local error_handler = function(err) + local msg = "Failed loading " .. mod .. "\n\n" .. err + print(msg) + end + xpcall(function() + require(mod) + end, error_handler) end ---@type ConfigOptions @@ -26,55 +26,55 @@ local options ---@param opts? ConfigOptions function M.setup(opts) - options = vim.tbl_deep_extend("force", defaultOpts, opts or {}) or {} + options = vim.tbl_deep_extend("force", defaultOpts, opts or {}) or {} - M.load("options") - M.load("keymaps") - M.load("clipboard") + M.load("options") + M.load("keymaps") + M.load("clipboard") - require("lazy").setup("juancwu.plugins") + require("lazy").setup("juancwu.plugins") - -- try to load colorscheme - xpcall(function() - if type(M.colorscheme) == "function" then - M.colorscheme() - else - vim.cmd.colorscheme(M.colorscheme) - end - end, function(err) - if type(M.colorscheme) == "string" then - local msg = "Failed to load colorscheme " .. M.colorscheme .. "\n\n" .. err - print(msg) - else - print("Failed to load colorscheme\n\n" .. err) - end - vim.cmd.colorscheme("rose-pine") - end) + -- try to load colorscheme + xpcall(function() + if type(M.colorscheme) == "function" then + M.colorscheme() + else + vim.cmd.colorscheme(M.colorscheme) + end + end, function(err) + if type(M.colorscheme) == "string" then + local msg = "Failed to load colorscheme " .. M.colorscheme .. "\n\n" .. err + print(msg) + else + print("Failed to load colorscheme\n\n" .. err) + end + vim.cmd.colorscheme("rose-pine") + end) - -- create command to disable autoformat - vim.api.nvim_create_user_command("FormatDisable", function(args) - vim.g.disable_autoformat = true - end, { desc = "Disable Autoformat" }) - vim.api.nvim_create_user_command("FormatEnable", function(args) - vim.g.disable_autoformat = false - end, { desc = "Enable Autoformat" }) + -- create command to disable autoformat + vim.api.nvim_create_user_command("FormatDisable", function(args) + vim.g.disable_autoformat = true + end, { desc = "Disable Autoformat" }) + vim.api.nvim_create_user_command("FormatEnable", function(args) + vim.g.disable_autoformat = false + end, { desc = "Enable Autoformat" }) - -- create command to toggle colorscheme - vim.api.nvim_create_user_command( - "ToggleColors", - require("juancwu.utils.colors").toggle_colors, - { desc = "Toggle colorscheme" } - ) + -- create command to toggle colorscheme + vim.api.nvim_create_user_command( + "ToggleColors", + require("juancwu.utils.colors").toggle_colors, + { desc = "Toggle colorscheme" } + ) end setmetatable(M, { - __index = function(_, k) - if options == nil then - return vim.deepcopy(defaultOpts)[k] - end + __index = function(_, k) + if options == nil then + return vim.deepcopy(defaultOpts)[k] + end - return options[k] - end, + return options[k] + end, }) return M diff --git a/nvim/lua/juancwu/config/options.lua b/nvim/lua/juancwu/config/options.lua index 4bf2b6d..ae77103 100644 --- a/nvim/lua/juancwu/config/options.lua +++ b/nvim/lua/juancwu/config/options.lua @@ -1,7 +1,7 @@ vim.g.mapleader = " " vim.g.maplocalleader = " " -vim.opt.number = true -- show line number +vim.opt.number = true -- show line number vim.opt.relativenumber = true -- juicy relativity vim.opt.autoindent = true @@ -18,7 +18,7 @@ vim.opt.wrap = false -- bad, stay away from me! vim.opt.hlsearch = false vim.opt.incsearch = true -- highlight search pattern as you type -vim.opt.scrolloff = 12 -- give me some personal space +vim.opt.scrolloff = 12 -- give me some personal space vim.opt.updatetime = 50 @@ -45,11 +45,11 @@ vim.opt.undofile = true -- highlight on yank local highligh_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }) vim.api.nvim_create_autocmd("TextYankPost", { - callback = function() - vim.highlight.on_yank() - end, - group = highligh_group, - pattern = "*", + callback = function() + vim.highlight.on_yank() + end, + group = highligh_group, + pattern = "*", }) vim.opt.completeopt = "menu,menuone,noselect" diff --git a/nvim/lua/juancwu/init.lua b/nvim/lua/juancwu/init.lua index 69f7b3f..83343d5 100644 --- a/nvim/lua/juancwu/init.lua +++ b/nvim/lua/juancwu/init.lua @@ -2,7 +2,7 @@ local M = {} ---@param opts? ConfigOptions function M.setup(opts) - require("juancwu.config").setup(opts) + require("juancwu.config").setup(opts) end return M diff --git a/nvim/lua/juancwu/plugins/autocomplete.lua b/nvim/lua/juancwu/plugins/autocomplete.lua index e416535..281fda7 100644 --- a/nvim/lua/juancwu/plugins/autocomplete.lua +++ b/nvim/lua/juancwu/plugins/autocomplete.lua @@ -1,93 +1,93 @@ return { -- Autocompletion - "hrsh7th/nvim-cmp", - event = "InsertEnter", - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - { - "L3MON4D3/LuaSnip", - build = (function() - -- Build Step is needed for regex support in snippets. - -- This step is not supported in many windows environments. - -- Remove the below condition to re-enable on windows. - if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then - return - end - return "make install_jsregexp" - end)(), - dependencies = { - { - "rafamadriz/friendly-snippets", - config = function() - require("luasnip.loaders.from_vscode").lazy_load() - end, - }, - }, - }, - "saadparwaiz1/cmp_luasnip", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-path", - }, - config = function() - -- See `:help cmp` - local cmp = require("cmp") - local luasnip = require("luasnip") - luasnip.config.setup({}) + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + { + "L3MON4D3/LuaSnip", + build = (function() + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. + if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then + return + end + return "make install_jsregexp" + end)(), + dependencies = { + { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, + }, + }, + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + }, + config = function() + -- See `:help cmp` + local cmp = require("cmp") + local luasnip = require("luasnip") + luasnip.config.setup({}) - cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { completeopt = "menu,menuone,noinsert" }, + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { completeopt = "menu,menuone,noinsert" }, - -- For an understanding of why these mappings were - -- chosen, you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! - mapping = cmp.mapping.preset.insert({ - -- Select the [n]ext item - [""] = cmp.mapping.select_next_item(), - -- Select the [p]revious item - [""] = cmp.mapping.select_prev_item(), + -- For an understanding of why these mappings were + -- chosen, you will need to read `:help ins-completion` + -- + -- No, but seriously. Please read `:help ins-completion`, it is really good! + mapping = cmp.mapping.preset.insert({ + -- Select the [n]ext item + [""] = cmp.mapping.select_next_item(), + -- Select the [p]revious item + [""] = cmp.mapping.select_prev_item(), - -- Scroll the documentation window [b]ack / [f]orward - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), + -- Scroll the documentation window [b]ack / [f]orward + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), - -- 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 }), + -- 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 }), - -- Manually trigger a completion from nvim-cmp. - -- Generally you don't need this, because nvim-cmp will display - -- completions whenever it has completion options available. - [""] = cmp.mapping.complete({}), + -- Manually trigger a completion from nvim-cmp. + -- Generally you don't need this, because nvim-cmp will display + -- completions whenever it has completion options available. + [""] = cmp.mapping.complete({}), - -- will move you to the right of each of the expansion locations. - -- is similar, except moving you backwards. - [""] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { "i", "s" }), - [""] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { "i", "s" }), - }), - sources = { - { - name = "lazydev", - -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it - group_index = 0, - }, - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "path" }, - }, - }) - end, + -- will move you to the right of each of the expansion locations. + -- is similar, except moving you backwards. + [""] = cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end, { "i", "s" }), + [""] = cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { "i", "s" }), + }), + sources = { + { + name = "lazydev", + -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it + group_index = 0, + }, + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + }, + }) + end, } diff --git a/nvim/lua/juancwu/plugins/autopairs.lua b/nvim/lua/juancwu/plugins/autopairs.lua index 44c4230..9a43685 100644 --- a/nvim/lua/juancwu/plugins/autopairs.lua +++ b/nvim/lua/juancwu/plugins/autopairs.lua @@ -1,11 +1,11 @@ return { - "windwp/nvim-autopairs", - event = "InsertEnter", - dependencies = { "hrsh7th/nvim-cmp" }, - config = function() - require("nvim-autopairs").setup({}) - local cmp_autopairs = require("nvim-autopairs.completion.cmp") - local cmp = require("cmp") - cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) - end, + "windwp/nvim-autopairs", + event = "InsertEnter", + dependencies = { "hrsh7th/nvim-cmp" }, + config = function() + require("nvim-autopairs").setup({}) + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + local cmp = require("cmp") + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end, } diff --git a/nvim/lua/juancwu/plugins/autotag.lua b/nvim/lua/juancwu/plugins/autotag.lua index 92e4961..60b15ae 100644 --- a/nvim/lua/juancwu/plugins/autotag.lua +++ b/nvim/lua/juancwu/plugins/autotag.lua @@ -1,30 +1,30 @@ return { - "windwp/nvim-ts-autotag", - dependencies = { "nvim-treesitter/nvim-treesitter", build = ':TSUpdate' }, - ft = { - 'html', - 'javascript', - 'typescript', - 'javascriptreact', - 'typescriptreact', - 'svelte', - 'vue', - 'tsx', - 'jsx', - 'xml', - 'php', - 'markdown', - 'astro', - 'glimmer', - 'handlebars', - 'hbs', - 'templ', - }, - config = function() - local autotag = require('nvim-ts-autotag') - autotag.setup({ - enable = true, - enable_close_on_slash = false, - }) - end + "windwp/nvim-ts-autotag", + dependencies = { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, + ft = { + "html", + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + "svelte", + "vue", + "tsx", + "jsx", + "xml", + "php", + "markdown", + "astro", + "glimmer", + "handlebars", + "hbs", + "templ", + }, + config = function() + local autotag = require("nvim-ts-autotag") + autotag.setup({ + enable = true, + enable_close_on_slash = false, + }) + end, } diff --git a/nvim/lua/juancwu/plugins/colorscheme.lua b/nvim/lua/juancwu/plugins/colorscheme.lua index 6fb328d..754d371 100644 --- a/nvim/lua/juancwu/plugins/colorscheme.lua +++ b/nvim/lua/juancwu/plugins/colorscheme.lua @@ -1,47 +1,47 @@ return { - -- rose-pine - { - "rose-pine/nvim", - name = "rose-pine", - priority = 1000, - }, + -- rose-pine + { + "rose-pine/nvim", + name = "rose-pine", + priority = 1000, + }, - -- onedark - { - "navarasu/onedark.nvim", - priority = 1000, - }, + -- onedark + { + "navarasu/onedark.nvim", + priority = 1000, + }, - -- solarized-osaka - { - "craftzdog/solarized-osaka.nvim", - priority = 1000, - opts = { - transparent = false, - }, - }, + -- solarized-osaka + { + "craftzdog/solarized-osaka.nvim", + priority = 1000, + opts = { + transparent = false, + }, + }, - -- tokyonight - { - "folke/tokyonight.nvim", - lazy = true, - opts = { style = "moon" }, - }, + -- tokyonight + { + "folke/tokyonight.nvim", + lazy = true, + opts = { style = "moon" }, + }, - -- catppuccin - { - "catppuccin/nvim", - lazy = true, - name = "catppuccin", - priority = 1000, - opts = { - flavour = "mocha", - }, - }, + -- catppuccin + { + "catppuccin/nvim", + lazy = true, + name = "catppuccin", + priority = 1000, + opts = { + flavour = "mocha", + }, + }, - -- great kanagawa - { - "rebelot/kanagawa.nvim", - opts = {}, - }, + -- great kanagawa + { + "rebelot/kanagawa.nvim", + opts = {}, + }, } diff --git a/nvim/lua/juancwu/plugins/comment.lua b/nvim/lua/juancwu/plugins/comment.lua index 89425bd..cf08df1 100644 --- a/nvim/lua/juancwu/plugins/comment.lua +++ b/nvim/lua/juancwu/plugins/comment.lua @@ -1,34 +1,33 @@ return { - "numToStr/Comment.nvim", - dependencies = { - "JoosepAlviste/nvim-ts-context-commentstring", - }, - config = function() - local comment = require('Comment') - comment.setup({ - pre_hook = function(ctx) - -- only for tsx/jsx filetypes - if vim.bo.filetype == "typescriptreact" or vim.bo.filetype == "javascriptreact" then - local U = require('Comment.utils') + "numToStr/Comment.nvim", + dependencies = { + "JoosepAlviste/nvim-ts-context-commentstring", + }, + config = function() + local comment = require("Comment") + comment.setup({ + pre_hook = function(ctx) + -- only for tsx/jsx filetypes + if vim.bo.filetype == "typescriptreact" or vim.bo.filetype == "javascriptreact" then + local U = require("Comment.utils") - -- determine wheter to use linwise or blockwise commentstring - local type = ctx.ctype == U.ctype.linewise and '__default' or '__multiline' + -- determine wheter to use linwise or blockwise commentstring + local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline" + -- determine the location where to calcualte commentstring from + local location = nil + if ctx.ctype == U.ctype.blockwise then + location = require("ts_context_commentstring.utils").get_cursor_location() + elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + location = require("ts_context_commentstring.utils").get_visual_start_location() + end - -- determine the location where to calcualte commentstring from - local location = nil - if ctx.ctype == U.ctype.blockwise then - location = require('ts_context_commentstring.utils').get_cursor_location() - elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then - location = require('ts_context_commentstring.utils').get_visual_start_location() - end - - return require('ts_context_commentstring.internal').calculate_commentstring({ - key = type, - location = location, - }) - end - end, - }) - end + return require("ts_context_commentstring.internal").calculate_commentstring({ + key = type, + location = location, + }) + end + end, + }) + end, } diff --git a/nvim/lua/juancwu/plugins/conform.lua b/nvim/lua/juancwu/plugins/conform.lua index a98e0e8..c082d55 100644 --- a/nvim/lua/juancwu/plugins/conform.lua +++ b/nvim/lua/juancwu/plugins/conform.lua @@ -1,61 +1,60 @@ local formatters_by_ft = { - lua = { "stylua" }, - javascript = { "biome" }, - typescript = { "biome" }, - javascriptreact = { "biome" }, - typescriptreact = { "biome" }, - css = { "biome" }, - markdown = { "biome" }, - jsonc = { "biome" }, - json = { "biome" }, - go = { "gofmt", "goimports" }, - python = { "autopep8" }, - yaml = { "yamlfmt" }, - yml = { "yamlfmt" }, - zig = { "zigfmt" }, - rust = { "rustfmt" }, + lua = { "stylua" }, + javascript = { "biome" }, + typescript = { "biome" }, + javascriptreact = { "biome" }, + typescriptreact = { "biome" }, + css = { "biome" }, + markdown = { "biome" }, + jsonc = { "biome" }, + json = { "biome" }, + go = { "gofmt", "goimports" }, + python = { "autopep8" }, + yaml = { "yamlfmt" }, + yml = { "yamlfmt" }, + zig = { "zigfmt" }, + rust = { "rustfmt" }, } return { - "stevearc/conform.nvim", - event = { "BufWritePre", "BufEnter" }, - cmd = { "ConformInfo" }, - keys = { - { - "ff", - function() - require("conform").format({ async = true, lsp_format = "fallback" }) - end, - mode = "", - desc = "[F]ormat buffer", - }, - }, - config = function() - require("conform").setup({ - notify_on_error = false, - formatters_by_ft = formatters_by_ft, - format_on_save = function(bufnr) - if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then - return - end - return { - timeout_ms = 500, - lsp_format = "fallback", - } - end, - }) + "stevearc/conform.nvim", + event = { "BufWritePre", "BufEnter" }, + cmd = { "ConformInfo" }, + keys = { + { + "ff", + function() + require("conform").format({ async = true, lsp_format = "fallback" }) + end, + mode = "", + desc = "[F]ormat buffer", + }, + }, + config = function() + require("conform").setup({ + notify_on_error = false, + formatters_by_ft = formatters_by_ft, + format_on_save = function(bufnr) + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + return { + timeout_ms = 500, + lsp_format = "fallback", + } + end, + }) - vim.api.nvim_create_user_command("FormatDisable", function() - vim.g.disable_autoformat = true - end, { - desc = "Disable autoformat on save", - }) + vim.api.nvim_create_user_command("FormatDisable", function() + vim.g.disable_autoformat = true + end, { + desc = "Disable autoformat on save", + }) - vim.api.nvim_create_user_command("FormatEnable", function() - vim.g.disable_autoformat = false - end, { - desc = "Enable autoformat on save", - }) - end, + vim.api.nvim_create_user_command("FormatEnable", function() + vim.g.disable_autoformat = false + end, { + desc = "Enable autoformat on save", + }) + end, } - diff --git a/nvim/lua/juancwu/plugins/fugitive.lua b/nvim/lua/juancwu/plugins/fugitive.lua index bb976df..9142e2a 100644 --- a/nvim/lua/juancwu/plugins/fugitive.lua +++ b/nvim/lua/juancwu/plugins/fugitive.lua @@ -1,23 +1,23 @@ return { - "tpope/vim-fugitive", - cmd = { - "Git", - "G", - "Gdiffsplit", - "Gread", - "Gwrite", - "Ggrep", - "GMove", - "GDelete", - "GBrowse", - "GRemove", - "GRename", - "Glgrep", - "Gedit" - }, - keys = { - { "gs", "Git", desc = "Git status" }, - { "gbl", "Git blame", desc = "Open [G]it [Bl]ame" }, - { "gd", "Gdiffsplit", desc = "Open [G]it [D]iff" }, - }, -} \ No newline at end of file + "tpope/vim-fugitive", + cmd = { + "Git", + "G", + "Gdiffsplit", + "Gread", + "Gwrite", + "Ggrep", + "GMove", + "GDelete", + "GBrowse", + "GRemove", + "GRename", + "Glgrep", + "Gedit", + }, + keys = { + { "gs", "Git", desc = "Git status" }, + { "gbl", "Git blame", desc = "Open [G]it [Bl]ame" }, + { "gd", "Gdiffsplit", desc = "Open [G]it [D]iff" }, + }, +} diff --git a/nvim/lua/juancwu/plugins/gitsigns.lua b/nvim/lua/juancwu/plugins/gitsigns.lua index d93e667..412175a 100644 --- a/nvim/lua/juancwu/plugins/gitsigns.lua +++ b/nvim/lua/juancwu/plugins/gitsigns.lua @@ -1,19 +1,19 @@ return { - "lewis6991/gitsigns.nvim", - opts = { - current_line_blame = true, - current_line_blame_opts = { - virt_text = true, - virt_text_pos = 'eol', - delay = 1000, - ignore_whitespace = false - }, - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '-' }, - changedelete = { text = '~' }, - }, + "lewis6991/gitsigns.nvim", + opts = { + current_line_blame = true, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", + delay = 1000, + ignore_whitespace = false, }, + signs = { + add = { text = "+" }, + change = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "-" }, + changedelete = { text = "~" }, + }, + }, } diff --git a/nvim/lua/juancwu/plugins/godoc.lua b/nvim/lua/juancwu/plugins/godoc.lua index 6179c1e..43ec765 100644 --- a/nvim/lua/juancwu/plugins/godoc.lua +++ b/nvim/lua/juancwu/plugins/godoc.lua @@ -1,20 +1,20 @@ return { - "fredrikaverpil/godoc.nvim", - version = "*", - dependencies = { - { "nvim-telescope/telescope.nvim" }, - { - "nvim-treesitter/nvim-treesitter", - opts = { - ensure_installed = { "go" }, - }, - }, - }, - build = "go install github.com/lotusirous/gostdsym/stdsym@latest", -- optional - cmd = { "GoDoc" }, -- optional - opts = { - picker = { - type = "telescope", - }, - }, + "fredrikaverpil/godoc.nvim", + version = "*", + dependencies = { + { "nvim-telescope/telescope.nvim" }, + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { "go" }, + }, + }, + }, + build = "go install github.com/lotusirous/gostdsym/stdsym@latest", -- optional + cmd = { "GoDoc" }, -- optional + opts = { + picker = { + type = "telescope", + }, + }, } diff --git a/nvim/lua/juancwu/plugins/harpoon.lua b/nvim/lua/juancwu/plugins/harpoon.lua index 0169db7..6885ea2 100644 --- a/nvim/lua/juancwu/plugins/harpoon.lua +++ b/nvim/lua/juancwu/plugins/harpoon.lua @@ -1,18 +1,26 @@ return { - "ThePrimeagen/harpoon", - dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - local mark = require("harpoon.mark") - local ui = require("harpoon.ui") + "ThePrimeagen/harpoon", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local mark = require("harpoon.mark") + local ui = require("harpoon.ui") - vim.keymap.set("n", "a", mark.add_file) - vim.keymap.set("n", "", ui.toggle_quick_menu) + vim.keymap.set("n", "a", mark.add_file) + vim.keymap.set("n", "", ui.toggle_quick_menu) - vim.keymap.set("n", "q", function() ui.nav_file(1) end) - vim.keymap.set("n", "w", function() ui.nav_file(2) end) - vim.keymap.set("n", "e", function() ui.nav_file(3) end) - vim.keymap.set("n", "r", function() ui.nav_file(4) end) - vim.keymap.set("n", ",", ui.nav_prev) - vim.keymap.set("n", ".", ui.nav_next) - end + vim.keymap.set("n", "q", function() + ui.nav_file(1) + end) + vim.keymap.set("n", "w", function() + ui.nav_file(2) + end) + vim.keymap.set("n", "e", function() + ui.nav_file(3) + end) + vim.keymap.set("n", "r", function() + ui.nav_file(4) + end) + vim.keymap.set("n", ",", ui.nav_prev) + vim.keymap.set("n", ".", ui.nav_next) + end, } diff --git a/nvim/lua/juancwu/plugins/indent-blankline.lua b/nvim/lua/juancwu/plugins/indent-blankline.lua index 793ee26..4e373e9 100644 --- a/nvim/lua/juancwu/plugins/indent-blankline.lua +++ b/nvim/lua/juancwu/plugins/indent-blankline.lua @@ -1,12 +1,12 @@ return { - "lukas-reineke/indent-blankline.nvim", - opts = { - indent = { - smart_indent_cap = true, - }, - scope = { - show_end = true, - }, + "lukas-reineke/indent-blankline.nvim", + opts = { + indent = { + smart_indent_cap = true, }, - main = "ibl" + scope = { + show_end = true, + }, + }, + main = "ibl", } diff --git a/nvim/lua/juancwu/plugins/lazydev.lua b/nvim/lua/juancwu/plugins/lazydev.lua index 35963b3..193d759 100644 --- a/nvim/lua/juancwu/plugins/lazydev.lua +++ b/nvim/lua/juancwu/plugins/lazydev.lua @@ -1,9 +1,9 @@ return { - 'folke/lazydev.nvim', - ft = 'lua', - opts = { - library = { - { path = 'luvit-meta/library', words = { 'vim%.uv' } }, - }, + "folke/lazydev.nvim", + ft = "lua", + opts = { + library = { + { path = "luvit-meta/library", words = { "vim%.uv" } }, }, + }, } diff --git a/nvim/lua/juancwu/plugins/lsp.lua b/nvim/lua/juancwu/plugins/lsp.lua index c12134c..01fca90 100644 --- a/nvim/lua/juancwu/plugins/lsp.lua +++ b/nvim/lua/juancwu/plugins/lsp.lua @@ -1,154 +1,154 @@ return { - -- lspconfig - "neovim/nvim-lspconfig", - dependencies = { + -- lspconfig + "neovim/nvim-lspconfig", + dependencies = { - { "williamboman/mason.nvim", opts = {} }, - "williamboman/mason-lspconfig.nvim", - "WhoIsSethDaniel/mason-tool-installer.nvim", + { "williamboman/mason.nvim", opts = {} }, + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", - -- status updates for LSP - { "j-hui/fidget.nvim", opts = {} }, + -- status updates for LSP + { "j-hui/fidget.nvim", opts = {} }, - { "hrsh7th/cmp-nvim-lsp" }, -- Required - }, - config = function() - -- stole this from kickstart, great config - vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), - callback = function(event) - local map = function(keys, func, desc, mode) - mode = mode or "n" - vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) - end + { "hrsh7th/cmp-nvim-lsp" }, -- Required + }, + config = function() + -- stole this from kickstart, great config + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), + callback = function(event) + local map = function(keys, func, desc, mode) + mode = mode or "n" + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) + end - -- Jump to the definition of the word under your cursor. - -- This is where a variable was first declared, or where a function is defined, etc. - -- To jump back, press . - map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") + -- Jump to the definition of the word under your cursor. + -- This is where a variable was first declared, or where a function is defined, etc. + -- To jump back, press . + map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") - -- Find references for the word under your cursor. - map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") + -- Find references for the word under your cursor. + map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. - map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. - map("D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition") + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + map("D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition") - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - map("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + map("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") - -- Fuzzy find all the symbols in your current workspace. - -- Similar to document symbols, except searches over your entire project. - map("ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + map("ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. - map("rn", vim.lsp.buf.rename, "[R]e[n]ame") + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + map("rn", vim.lsp.buf.rename, "[R]e[n]ame") - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - map("ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" }) + -- Execute a code action, usually your cursor needs to be on top of an error + -- or a suggestion from your LSP for this to activate. + map("ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" }) - -- 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") + -- 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") - map("[d", vim.diagnostic.goto_prev, "Go to previous diagnostic") - map("]d", vim.diagnostic.goto_next, "Go to next diagnostic") + map("[d", vim.diagnostic.goto_prev, "Go to previous diagnostic") + map("]d", vim.diagnostic.goto_next, "Go to next diagnostic") - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then - local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false }) - vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then + local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false }) + vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) - vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) + vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) - vim.api.nvim_create_autocmd("LspDetach", { - group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf }) - end, - }) - end - end, - }) + vim.api.nvim_create_autocmd("LspDetach", { + group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf }) + end, + }) + end + end, + }) - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) - vim.filetype.add({ - extension = { - templ = "templ", - }, - }) + vim.filetype.add({ + extension = { + templ = "templ", + }, + }) - local servers = { - ts_ls = {}, - gopls = {}, - zls = {}, - rust_analyzer = {}, - templ = { - filetypes = { "templ" }, - }, - intelephense = {}, - lua_ls = { - settings = { - Lua = { - completion = { - callSnippet = "Replace", - }, - }, - }, - }, - tailwindcss = { - filetypes = { - "templ", - "html", - "javascript", - "typescript", - "javascriptreact", - "typescriptreact", - }, - init_options = { - userLanguages = { - templ = "html", - }, - }, - }, - } + local servers = { + ts_ls = {}, + gopls = {}, + zls = {}, + rust_analyzer = {}, + templ = { + filetypes = { "templ" }, + }, + intelephense = {}, + lua_ls = { + settings = { + Lua = { + completion = { + callSnippet = "Replace", + }, + }, + }, + }, + tailwindcss = { + filetypes = { + "templ", + "html", + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + }, + init_options = { + userLanguages = { + templ = "html", + }, + }, + }, + } - local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { "stylua", "yamlfmt", "autopep8", "biome", "goimports" }) - require("mason-tool-installer").setup({ ensure_installed = ensure_installed }) + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { "stylua", "yamlfmt", "autopep8", "biome", "goimports" }) + require("mason-tool-installer").setup({ ensure_installed = ensure_installed }) - require("mason-lspconfig").setup({ - handlers = { - function(server_name) - local server = servers[server_name] or {} - server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) - require("lspconfig")[server_name].setup(server) - end, - }, - }) - end, + require("mason-lspconfig").setup({ + handlers = { + function(server_name) + local server = servers[server_name] or {} + server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) + require("lspconfig")[server_name].setup(server) + end, + }, + }) + end, } diff --git a/nvim/lua/juancwu/plugins/lualine.lua b/nvim/lua/juancwu/plugins/lualine.lua index e496763..63ecac4 100644 --- a/nvim/lua/juancwu/plugins/lualine.lua +++ b/nvim/lua/juancwu/plugins/lualine.lua @@ -1,13 +1,13 @@ return { - "nvim-lualine/lualine.nvim", - dependencies = { "nvim-tree/nvim-web-devicons", lazy = true }, - config = function() - local lualine = require('lualine') + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons", lazy = true }, + config = function() + local lualine = require("lualine") - lualine.setup { - options = { - icons_enabled = false, - --[[ section_separators = { + lualine.setup({ + options = { + icons_enabled = false, + --[[ section_separators = { left = '', right = '' }, @@ -15,44 +15,48 @@ return { left = '', right = '' }, ]] - section_separators = '', - component_separators = '|', - disabled_filetypes = {} - }, - sections = { - lualine_a = { }, - lualine_b = { }, - lualine_c = { { - 'filename', - file_status = true, -- display file status - path = 1 -- no file path - } }, - lualine_x = { - { - 'diagnostics', - sources = { 'nvim_diagnostic' }, - symbols = { error = ' ', warn = ' ', info = ' ', hint = '' } - }, - 'enconding', - 'filetype' - }, - lualine_y = { 'progress' }, - lualine_z = { 'location' } - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { { - 'filename', - file_status = true, - path = 1 - } }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - extensions = { 'fugitive' } - } - end + section_separators = "", + component_separators = "|", + disabled_filetypes = {}, + }, + sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { + { + "filename", + file_status = true, -- display file status + path = 1, -- no file path + }, + }, + lualine_x = { + { + "diagnostics", + sources = { "nvim_diagnostic" }, + symbols = { error = " ", warn = " ", info = " ", hint = "" }, + }, + "enconding", + "filetype", + }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { + { + "filename", + file_status = true, + path = 1, + }, + }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + extensions = { "fugitive" }, + }) + end, } diff --git a/nvim/lua/juancwu/plugins/luvit-meta.lua b/nvim/lua/juancwu/plugins/luvit-meta.lua index 3abf672..7fcb36c 100644 --- a/nvim/lua/juancwu/plugins/luvit-meta.lua +++ b/nvim/lua/juancwu/plugins/luvit-meta.lua @@ -1,4 +1,4 @@ return { - 'Bilal2453/luvit-meta', - lazy = true, + "Bilal2453/luvit-meta", + lazy = true, } diff --git a/nvim/lua/juancwu/plugins/neo-tree.lua b/nvim/lua/juancwu/plugins/neo-tree.lua index fbf88f7..88f27c3 100644 --- a/nvim/lua/juancwu/plugins/neo-tree.lua +++ b/nvim/lua/juancwu/plugins/neo-tree.lua @@ -1,71 +1,71 @@ return { - "nvim-neo-tree/neo-tree.nvim", - enabled = false, - branch = "v2.x", - cmd = { "Neotree" }, - keys = { - { "fs", "NeoTreeFloatToggle", desc = "Toggle [F]ile [S]ystem Floating Menu" }, - { "", "NeoTreeFocusToggle", desc = "Open Side File System" } + "nvim-neo-tree/neo-tree.nvim", + enabled = false, + branch = "v2.x", + cmd = { "Neotree" }, + keys = { + { "fs", "NeoTreeFloatToggle", desc = "Toggle [F]ile [S]ystem Floating Menu" }, + { "", "NeoTreeFocusToggle", desc = "Open Side File System" }, + }, + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + opts = { + use_default_mappings = true, + mappings = { + [""] = { + "toggle_node", + nowait = true, -- disable `nowait` if you have existing combos starting with this char that you want to use + }, + ["<2-LeftMouse>"] = "open", + [""] = "open", + [""] = "cancel", -- close preview or floating neo-tree window + ["P"] = { "toggle_preview", config = { use_float = true } }, + ["l"] = "focus_preview", + ["O"] = "open_split", + ["o"] = "open_vsplit", + ["S"] = "none", + ["s"] = "none", + -- ["S"] = "split_with_window_picker", + -- ["s"] = "vsplit_with_window_picker", + ["t"] = "open_tabnew", + -- [""] = "open_drop", + -- ["t"] = "open_tab_drop", + ["w"] = "open_with_window_picker", + --["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing + ["C"] = "close_node", + -- ['C'] = 'close_all_subnodes', + ["z"] = "close_all_nodes", + --["Z"] = "expand_all_nodes", + ["a"] = { + "add", + -- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details + -- some commands may take optional config options, see `:h neo-tree-mappings` for details + config = { + show_path = "none", -- "none", "relative", "absolute" + }, + }, + ["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion. + ["d"] = "delete", + ["r"] = "rename", + ["y"] = "copy_to_clipboard", + ["x"] = "cut_to_clipboard", + ["p"] = "paste_from_clipboard", + ["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add": + -- ["c"] = { + -- "copy", + -- config = { + -- show_path = "none" -- "none", "relative", "absolute" + -- } + --} + ["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add". + ["q"] = "close_window", + ["R"] = "refresh", + ["?"] = "show_help", + ["<"] = "prev_source", + [">"] = "next_source", }, - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - }, - opts = { - use_default_mappings = true, - mappings = { - [""] = { - "toggle_node", - nowait = true, -- disable `nowait` if you have existing combos starting with this char that you want to use - }, - ["<2-LeftMouse>"] = "open", - [""] = "open", - [""] = "cancel", -- close preview or floating neo-tree window - ["P"] = { "toggle_preview", config = { use_float = true } }, - ["l"] = "focus_preview", - ["O"] = "open_split", - ["o"] = "open_vsplit", - ["S"] = "none", - ["s"] = "none", - -- ["S"] = "split_with_window_picker", - -- ["s"] = "vsplit_with_window_picker", - ["t"] = "open_tabnew", - -- [""] = "open_drop", - -- ["t"] = "open_tab_drop", - ["w"] = "open_with_window_picker", - --["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing - ["C"] = "close_node", - -- ['C'] = 'close_all_subnodes', - ["z"] = "close_all_nodes", - --["Z"] = "expand_all_nodes", - ["a"] = { - "add", - -- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details - -- some commands may take optional config options, see `:h neo-tree-mappings` for details - config = { - show_path = "none" -- "none", "relative", "absolute" - } - }, - ["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion. - ["d"] = "delete", - ["r"] = "rename", - ["y"] = "copy_to_clipboard", - ["x"] = "cut_to_clipboard", - ["p"] = "paste_from_clipboard", - ["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add": - -- ["c"] = { - -- "copy", - -- config = { - -- show_path = "none" -- "none", "relative", "absolute" - -- } - --} - ["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add". - ["q"] = "close_window", - ["R"] = "refresh", - ["?"] = "show_help", - ["<"] = "prev_source", - [">"] = "next_source", - } - } + }, } diff --git a/nvim/lua/juancwu/plugins/nvim-lint.lua b/nvim/lua/juancwu/plugins/nvim-lint.lua index c9388de..c4a23fe 100644 --- a/nvim/lua/juancwu/plugins/nvim-lint.lua +++ b/nvim/lua/juancwu/plugins/nvim-lint.lua @@ -1,84 +1,84 @@ local linters_by_ft = { - javascript = { "biomejs", "eslint" }, - typescript = { "biomejs", "eslint" }, - javascriptreact = { "biomejs", "eslint" }, - typescriptreact = { "biomejs", "eslint" }, - jsonc = { "biomejs" }, - json = { "biomejs" }, - css = { "biomejs" }, + javascript = { "biomejs", "eslint" }, + typescript = { "biomejs", "eslint" }, + javascriptreact = { "biomejs", "eslint" }, + typescriptreact = { "biomejs", "eslint" }, + jsonc = { "biomejs" }, + json = { "biomejs" }, + css = { "biomejs" }, } -- Function to find the first config file by walking up the directory tree local function find_first_config() - local current_dir = vim.fn.expand("%:p:h") - local home_dir = vim.fn.expand("$HOME") + local current_dir = vim.fn.expand("%:p:h") + local home_dir = vim.fn.expand("$HOME") - local config_files = { - biomejs = { "biome.json" }, - eslint = { ".eslintrc", ".eslintrc.js", ".eslintrc.json", ".eslintrc.yml" }, - } + local config_files = { + biomejs = { "biome.json" }, + eslint = { ".eslintrc", ".eslintrc.js", ".eslintrc.json", ".eslintrc.yml" }, + } - while current_dir ~= home_dir and current_dir ~= "/" do - for linter, patterns in pairs(config_files) do - for _, pattern in ipairs(patterns) do - local config_file = current_dir .. "/" .. pattern - if vim.fn.filereadable(config_file) == 1 then - return linter - end - end - end - current_dir = vim.fn.fnamemodify(current_dir, ":h") - end - return nil + while current_dir ~= home_dir and current_dir ~= "/" do + for linter, patterns in pairs(config_files) do + for _, pattern in ipairs(patterns) do + local config_file = current_dir .. "/" .. pattern + if vim.fn.filereadable(config_file) == 1 then + return linter + end + end + end + current_dir = vim.fn.fnamemodify(current_dir, ":h") + end + return nil end -- Function to determine the linter based on config files and file type local function get_linter() - local filetype = vim.bo.filetype - local available_linters = linters_by_ft[filetype] or {} - local linter = find_first_config() + local filetype = vim.bo.filetype + local available_linters = linters_by_ft[filetype] or {} + local linter = find_first_config() - if linter then - if vim.tbl_contains(available_linters, linter) then - vim.g.current_linter = linter - return linter - end - end + if linter then + if vim.tbl_contains(available_linters, linter) then + vim.g.current_linter = linter + return linter + end + end - return nil + return nil end local function lint() - local nvimlint = require("lint") - local linter = get_linter() - if linter ~= nil then - nvimlint.try_lint(linter) - else - print("No linter found for filetype: " .. vim.bo.filetype) - end + local nvimlint = require("lint") + local linter = get_linter() + if linter ~= nil then + nvimlint.try_lint(linter) + else + print("No linter found for filetype: " .. vim.bo.filetype) + end end return { - "mfussenegger/nvim-lint", - keys = { - { - "lf", - function() - lint() - end, - mode = "n", - desc = "[L]int [F]ile", - }, - }, - config = function() - vim.api.nvim_create_user_command("Lint", function() - lint() - end, { desc = "Lint file" }) + "mfussenegger/nvim-lint", + keys = { + { + "lf", + function() + lint() + end, + mode = "n", + desc = "[L]int [F]ile", + }, + }, + config = function() + vim.api.nvim_create_user_command("Lint", function() + lint() + end, { desc = "Lint file" }) - vim.api.nvim_create_user_command("LintInfo", function() - print("Current linter: " .. (vim.g.current_linter or "none")) - end, { - desc = "Show current linter being used", - }) - end, + vim.api.nvim_create_user_command("LintInfo", function() + print("Current linter: " .. (vim.g.current_linter or "none")) + end, { + desc = "Show current linter being used", + }) + end, } diff --git a/nvim/lua/juancwu/plugins/oil.lua b/nvim/lua/juancwu/plugins/oil.lua index fd9a9e2..1252aeb 100644 --- a/nvim/lua/juancwu/plugins/oil.lua +++ b/nvim/lua/juancwu/plugins/oil.lua @@ -1,28 +1,28 @@ return { - "stevearc/oil.nvim", - ---@module 'oil' - ---@type oil.SetupOpts - -- Optional dependencies - dependencies = { { "echasnovski/mini.icons", opts = {} } }, - -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. - lazy = false, - config = function() - local oil = require("oil") + "stevearc/oil.nvim", + ---@module 'oil' + ---@type oil.SetupOpts + -- Optional dependencies + dependencies = { { "echasnovski/mini.icons", opts = {} } }, + -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. + lazy = false, + config = function() + local oil = require("oil") - oil.setup({ - view_options = { - show_hidden = true, - }, - }) - end, - keys = { - { - "oo", - function() - require("oil").open() - end, - mode = "n", - desc = "[O]pen [O]il", - }, - }, + oil.setup({ + view_options = { + show_hidden = true, + }, + }) + end, + keys = { + { + "oo", + function() + require("oil").open() + end, + mode = "n", + desc = "[O]pen [O]il", + }, + }, } diff --git a/nvim/lua/juancwu/plugins/render-markdown.lua b/nvim/lua/juancwu/plugins/render-markdown.lua index 4bbd31e..533b6a4 100644 --- a/nvim/lua/juancwu/plugins/render-markdown.lua +++ b/nvim/lua/juancwu/plugins/render-markdown.lua @@ -1,9 +1,9 @@ return { - "MeanderingProgrammer/render-markdown.nvim", - dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite - -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins - -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons - ---@module 'render-markdown' - ---@type render.md.UserConfig - opts = {}, + "MeanderingProgrammer/render-markdown.nvim", + dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons + ---@module 'render-markdown' + ---@type render.md.UserConfig + opts = {}, } diff --git a/nvim/lua/juancwu/plugins/telescope.lua b/nvim/lua/juancwu/plugins/telescope.lua index a95bd0f..2df54e7 100644 --- a/nvim/lua/juancwu/plugins/telescope.lua +++ b/nvim/lua/juancwu/plugins/telescope.lua @@ -1,181 +1,181 @@ local function get_fd_command() - if vim.fn.executable("fd") == 1 then - return "fd" - elseif vim.fn.executable("fdfind") == 1 then - return "fdfind" - end - return nil + if vim.fn.executable("fd") == 1 then + return "fd" + elseif vim.fn.executable("fdfind") == 1 then + return "fdfind" + end + return nil end return { - "nvim-telescope/telescope.nvim", - version = "0.1.8", - dependencies = { - "nvim-lua/plenary.nvim", - { - "nvim-telescope/telescope-fzf-native.nvim", - build = "make", - enabled = true, - cond = function() - return vim.fn.executable("make") == 1 - end, - }, - { - "nvim-telescope/telescope-file-browser.nvim", - dependencies = { - "nvim-telescope/telescope.nvim", - "nvim-lua/plenary.nvim", - }, - enabled = true, - }, - { "nvim-telescope/telescope-ui-select.nvim" }, - { "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font }, - }, - config = function() - local telescope = require("telescope") - local actions = require("telescope.actions") - local builtin = require("telescope.builtin") - local fb_actions = require("telescope").extensions.file_browser.actions + "nvim-telescope/telescope.nvim", + version = "0.1.8", + dependencies = { + "nvim-lua/plenary.nvim", + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + enabled = true, + cond = function() + return vim.fn.executable("make") == 1 + end, + }, + { + "nvim-telescope/telescope-file-browser.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + "nvim-lua/plenary.nvim", + }, + enabled = true, + }, + { "nvim-telescope/telescope-ui-select.nvim" }, + { "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font }, + }, + config = function() + local telescope = require("telescope") + local actions = require("telescope.actions") + local builtin = require("telescope.builtin") + local fb_actions = require("telescope").extensions.file_browser.actions - local function telescope_buffer_dir() - return vim.fn.expand("%:p:h") - end + local function telescope_buffer_dir() + return vim.fn.expand("%:p:h") + end - telescope.setup({ - defaults = { - mappings = { - n = { - ["q"] = actions.close, - }, - }, - }, - extensions = { - ["ui-select"] = { - require("telescope.themes").get_dropdown(), - }, - file_browser = { - theme = "dropdown", - hijack_netrw = false, - hidden = true, - mappings = { - ["i"] = { - [""] = function() - vim.cmd("normal vbd") - end, - [""] = function(bufnr) - actions.move_selection_next(bufnr) - end, - [""] = function(bufnr) - actions.move_selection_previous(bufnr) - end, - [""] = function(bufnr) - actions.select_vertical(bufnr) - end, - }, - ["n"] = { - ["a"] = fb_actions.create, - ["h"] = fb_actions.goto_parent_dir, - ["/"] = function() - vim.cmd("startinsert") - end, - ["d"] = fb_actions.remove, - ["e"] = fb_actions.change_cwd, - [""] = function(bufnr) - actions.select_vertical(bufnr) - end, - [""] = function(bufnr) - actions.toggle_all(bufnr) - end, - [""] = function(bufnr) - actions.move_selection_next(bufnr) - end, - [""] = function(bufnr) - actions.move_selection_previous(bufnr) - end, - }, - }, - }, - }, - }) + telescope.setup({ + defaults = { + mappings = { + n = { + ["q"] = actions.close, + }, + }, + }, + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown(), + }, + file_browser = { + theme = "dropdown", + hijack_netrw = false, + hidden = true, + mappings = { + ["i"] = { + [""] = function() + vim.cmd("normal vbd") + end, + [""] = function(bufnr) + actions.move_selection_next(bufnr) + end, + [""] = function(bufnr) + actions.move_selection_previous(bufnr) + end, + [""] = function(bufnr) + actions.select_vertical(bufnr) + end, + }, + ["n"] = { + ["a"] = fb_actions.create, + ["h"] = fb_actions.goto_parent_dir, + ["/"] = function() + vim.cmd("startinsert") + end, + ["d"] = fb_actions.remove, + ["e"] = fb_actions.change_cwd, + [""] = function(bufnr) + actions.select_vertical(bufnr) + end, + [""] = function(bufnr) + actions.toggle_all(bufnr) + end, + [""] = function(bufnr) + actions.move_selection_next(bufnr) + end, + [""] = function(bufnr) + actions.move_selection_previous(bufnr) + end, + }, + }, + }, + }, + }) - pcall(telescope.load_extension, "file_browser") - pcall(telescope.load_extension, "fzf") - pcall(telescope.load_extension, "ui-select") + pcall(telescope.load_extension, "file_browser") + pcall(telescope.load_extension, "fzf") + pcall(telescope.load_extension, "ui-select") - -- Builtin pickers - vim.keymap.set("n", "sf", function() - local fd_cmd = get_fd_command() - local config = { - hidden = true, - file_ignore_patterns = { - "node%_modules/.*", - "%.git/.*", - }, - } + -- Builtin pickers + vim.keymap.set("n", "sf", function() + local fd_cmd = get_fd_command() + local config = { + hidden = true, + file_ignore_patterns = { + "node%_modules/.*", + "%.git/.*", + }, + } - if fd_cmd then - config.find_command = { - fd_cmd, - "--type", - "f", - "--color", - "never", - "--hidden", - "--no-ignore", - } - end + if fd_cmd then + config.find_command = { + fd_cmd, + "--type", + "f", + "--color", + "never", + "--hidden", + "--no-ignore", + } + end - builtin.find_files(config) - end, { desc = "[S]earch [F]iles" }) - vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[S]earch [H]elp Tags" }) - vim.keymap.set("n", "sb", builtin.buffers, { desc = "[S]earch [B]uffers" }) - vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch current [W]ord" }) - vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) - vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) - vim.keymap.set("n", "gr", builtin.lsp_references, { desc = "[G]o to [R]eferences", noremap = true }) - vim.keymap.set("n", "gd", builtin.lsp_definitions, { desc = "[G]o to [D]efinitions" }) - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "[G]o to [D]eclaration" }) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "[R]e[N]ame" }) + builtin.find_files(config) + end, { desc = "[S]earch [F]iles" }) + vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[S]earch [H]elp Tags" }) + vim.keymap.set("n", "sb", builtin.buffers, { desc = "[S]earch [B]uffers" }) + vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch current [W]ord" }) + vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) + vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) + vim.keymap.set("n", "gr", builtin.lsp_references, { desc = "[G]o to [R]eferences", noremap = true }) + vim.keymap.set("n", "gd", builtin.lsp_definitions, { desc = "[G]o to [D]efinitions" }) + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "[G]o to [D]eclaration" }) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "[R]e[N]ame" }) - -- Git pickers - vim.keymap.set("n", "gf", builtin.git_files, { desc = "Search [G]it [F]iles" }) - vim.keymap.set("n", "gs", builtin.git_status, { desc = "List [G]it [S]tatus" }) - vim.keymap.set("n", "gh", builtin.git_stash, { desc = "List [G]it [S]tash" }) - vim.keymap.set("n", "gbb", builtin.git_branches, { desc = "List [G]it [B]ranches" }) - vim.keymap.set("n", "gc", builtin.git_bcommits, { desc = "List Buffer [G]it [C]ommits" }) + -- Git pickers + vim.keymap.set("n", "gf", builtin.git_files, { desc = "Search [G]it [F]iles" }) + vim.keymap.set("n", "gs", builtin.git_status, { desc = "List [G]it [S]tatus" }) + vim.keymap.set("n", "gh", builtin.git_stash, { desc = "List [G]it [S]tash" }) + vim.keymap.set("n", "gbb", builtin.git_branches, { desc = "List [G]it [B]ranches" }) + vim.keymap.set("n", "gc", builtin.git_bcommits, { desc = "List Buffer [G]it [C]ommits" }) - -- File Browser Ext - vim.keymap.set("n", "fs", function() - telescope.extensions.file_browser.file_browser({ - path = "%:p:h", - cwd = telescope_buffer_dir(), - respect_gitignore = false, - hidden = true, - grouped = true, - previewer = false, - initial_mode = "normal", - layout_config = { height = 40 }, - }) - end, { desc = "Open [F]ile [S]ystem Menu" }) + -- File Browser Ext + vim.keymap.set("n", "fs", function() + telescope.extensions.file_browser.file_browser({ + path = "%:p:h", + cwd = telescope_buffer_dir(), + respect_gitignore = false, + hidden = true, + grouped = true, + previewer = false, + initial_mode = "normal", + layout_config = { height = 40 }, + }) + end, { desc = "Open [F]ile [S]ystem Menu" }) - vim.keymap.set("n", "/", function() - builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ - winblend = 10, - previewer = false, - })) - end, { desc = "[/] Fuzzily serach in current buffer" }) + vim.keymap.set("n", "/", function() + builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ + winblend = 10, + previewer = false, + })) + end, { desc = "[/] Fuzzily serach in current buffer" }) - -- live grep in open files only - vim.keymap.set("n", "s/", function() - builtin.live_grep({ - grep_open_files = true, - prompt_title = "Live Grep in Open Files", - }) - end, { desc = "[S]search [/] in Open Files" }) + -- live grep in open files only + vim.keymap.set("n", "s/", function() + builtin.live_grep({ + grep_open_files = true, + prompt_title = "Live Grep in Open Files", + }) + end, { desc = "[S]search [/] in Open Files" }) - -- shortcut for searching neovim config files - vim.keymap.set("n", "sn", function() - builtin.find_files({ cwd = vim.fn.stdpath("config") }) - end, { desc = "[S]earch [N]eovim files" }) - end, + -- shortcut for searching neovim config files + vim.keymap.set("n", "sn", function() + builtin.find_files({ cwd = vim.fn.stdpath("config") }) + end, { desc = "[S]earch [N]eovim files" }) + end, } diff --git a/nvim/lua/juancwu/plugins/todo-comments.lua b/nvim/lua/juancwu/plugins/todo-comments.lua index 2ca05d6..c88cb75 100644 --- a/nvim/lua/juancwu/plugins/todo-comments.lua +++ b/nvim/lua/juancwu/plugins/todo-comments.lua @@ -1,5 +1,5 @@ return { - "folke/todo-comments.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - opts = {}, + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = {}, } diff --git a/nvim/lua/juancwu/plugins/toggleterm.lua b/nvim/lua/juancwu/plugins/toggleterm.lua index 8d81164..e163b22 100644 --- a/nvim/lua/juancwu/plugins/toggleterm.lua +++ b/nvim/lua/juancwu/plugins/toggleterm.lua @@ -1,47 +1,51 @@ return { - "akinsho/toggleterm.nvim", - version = "*", - keys = { - { "lg", function() - local Terminal = require('toggleterm.terminal').Terminal - local lazygit = Terminal:new({ - cmd = "lazygit", - direction = "float", - float_opts = { - border = "double", - }, - on_open = function(term) - vim.cmd("startinsert!") - end, - on_close = function(term) - vim.cmd("startinsert!") - end, - }) - lazygit:toggle() - end, desc = "Open lazygit in a floating window" }, + "akinsho/toggleterm.nvim", + version = "*", + keys = { + { + "lg", + function() + local Terminal = require("toggleterm.terminal").Terminal + local lazygit = Terminal:new({ + cmd = "lazygit", + direction = "float", + float_opts = { + border = "double", + }, + on_open = function(term) + vim.cmd("startinsert!") + end, + on_close = function(term) + vim.cmd("startinsert!") + end, + }) + lazygit:toggle() + end, + desc = "Open lazygit in a floating window", }, - opts = { - size = 20, - open_mapping = [[]], - hide_numbers = true, - shade_filetypes = {}, - shade_terminals = true, - shading_factor = 2, - start_in_insert = true, - insert_mappings = true, - terminal_mappings = true, - persist_size = true, - persist_mode = true, - direction = "float", - close_on_exit = true, - shell = vim.o.shell, - float_opts = { - border = "curved", - winblend = 0, - highlights = { - border = "Normal", - background = "Normal", - }, - }, + }, + opts = { + size = 20, + open_mapping = [[]], + hide_numbers = true, + shade_filetypes = {}, + shade_terminals = true, + shading_factor = 2, + start_in_insert = true, + insert_mappings = true, + terminal_mappings = true, + persist_size = true, + persist_mode = true, + direction = "float", + close_on_exit = true, + shell = vim.o.shell, + float_opts = { + border = "curved", + winblend = 0, + highlights = { + border = "Normal", + background = "Normal", + }, }, -} \ No newline at end of file + }, +} diff --git a/nvim/lua/juancwu/plugins/treesitter.lua b/nvim/lua/juancwu/plugins/treesitter.lua index e23d915..516c653 100644 --- a/nvim/lua/juancwu/plugins/treesitter.lua +++ b/nvim/lua/juancwu/plugins/treesitter.lua @@ -1,100 +1,100 @@ return { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - event = { - "BufReadPost", - "BufNewFile", - }, - branch = "master", - dependencies = { - "nvim-treesitter/nvim-treesitter-textobjects", - }, - config = function() - local treesitter = require("nvim-treesitter.configs") + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = { + "BufReadPost", + "BufNewFile", + }, + branch = "master", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, + config = function() + local treesitter = require("nvim-treesitter.configs") - treesitter.setup({ - -- A list of parser names, or "all" - ensure_installed = { - "vimdoc", - "javascript", - "typescript", - "c", - "lua", - "rust", - "go", - "gosum", - "gomod", - "php", - "blade", - }, - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - -- Automatically install missing parsers when entering buffer - auto_install = true, - indent = { - enable = true, - }, - highlight = { - enable = true, - additional_vim_regex_highlighting = true, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "c", - node_incremental = "", - scope_incremental = "", - node_decremental = "", - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["aa"] = "@parameter.outer", - ["ia"] = "@parameter.inner", - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - ["]m"] = "@function.outer", - ["]]"] = "@class.outer", - }, - goto_next_end = { - ["]M"] = "@function.outer", - ["]["] = "@class.outer", - }, - goto_previous_start = { - ["[m"] = "@function.outer", - ["[["] = "@class.outer", - }, - goto_previous_end = { - ["[M"] = "@function.outer", - ["[]"] = "@class.outer", - }, - }, - swap = { - enable = true, - swap_next = { - ["]"] = "@parameter.inner", - }, - swap_previous = { - ["["] = "@parameter.inner", - }, - }, - }, - autotag = { - enable = false, - enable_close_on_slash = false, - }, - }) - end, + treesitter.setup({ + -- A list of parser names, or "all" + ensure_installed = { + "vimdoc", + "javascript", + "typescript", + "c", + "lua", + "rust", + "go", + "gosum", + "gomod", + "php", + "blade", + }, + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + -- Automatically install missing parsers when entering buffer + auto_install = true, + indent = { + enable = true, + }, + highlight = { + enable = true, + additional_vim_regex_highlighting = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "c", + node_incremental = "", + scope_incremental = "", + node_decremental = "", + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["aa"] = "@parameter.outer", + ["ia"] = "@parameter.inner", + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]m"] = "@function.outer", + ["]]"] = "@class.outer", + }, + goto_next_end = { + ["]M"] = "@function.outer", + ["]["] = "@class.outer", + }, + goto_previous_start = { + ["[m"] = "@function.outer", + ["[["] = "@class.outer", + }, + goto_previous_end = { + ["[M"] = "@function.outer", + ["[]"] = "@class.outer", + }, + }, + swap = { + enable = true, + swap_next = { + ["]"] = "@parameter.inner", + }, + swap_previous = { + ["["] = "@parameter.inner", + }, + }, + }, + autotag = { + enable = false, + enable_close_on_slash = false, + }, + }) + end, } diff --git a/nvim/lua/juancwu/plugins/undotree.lua b/nvim/lua/juancwu/plugins/undotree.lua index fe1b251..31a2fe6 100644 --- a/nvim/lua/juancwu/plugins/undotree.lua +++ b/nvim/lua/juancwu/plugins/undotree.lua @@ -1,22 +1,22 @@ return { - "mbbill/undotree", - keys = { - { "u", "UndotreeToggle", desc = "Toggle Undotree" }, - }, - config = function() - local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" }) + "mbbill/undotree", + keys = { + { "u", "UndotreeToggle", desc = "Toggle Undotree" }, + }, + config = function() + local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" }) - if has_persistent_undo then - local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" }) + if has_persistent_undo then + local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" }) - local is_directory = vim.api.nvim_call_function("isdirectory", { target_path }) + local is_directory = vim.api.nvim_call_function("isdirectory", { target_path }) - if not is_directory then - vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 }) - end + if not is_directory then + vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 }) + end - vim.opt.undodir = target_path - vim.opt.undofile = true - end + vim.opt.undodir = target_path + vim.opt.undofile = true end + end, } diff --git a/nvim/lua/juancwu/plugins/which-key.lua b/nvim/lua/juancwu/plugins/which-key.lua index eaee4da..ed7fb7a 100644 --- a/nvim/lua/juancwu/plugins/which-key.lua +++ b/nvim/lua/juancwu/plugins/which-key.lua @@ -1,49 +1,49 @@ return { - { - "folke/which-key.nvim", - event = "VeryLazy", - config = function() - vim.opt.timeout = true - vim.opt.timeoutlen = 300 + { + "folke/which-key.nvim", + event = "VeryLazy", + config = function() + vim.opt.timeout = true + vim.opt.timeoutlen = 300 - local wk = require("which-key") + local wk = require("which-key") - wk.setup({ - delay = 0, - icons = { - mappings = vim.g.have_nerd_font, - keys = vim.g.have_nerd_font and {} or { - Up = ' ', - Down = ' ', - Left = ' ', - Right = ' ', - C = ' ', - M = ' ', - D = ' ', - S = ' ', - CR = ' ', - Esc = ' ', - ScrollWheelDown = ' ', - ScrollWheelUp = ' ', - NL = ' ', - BS = ' ', - Space = ' ', - Tab = ' ', - F1 = '', - F2 = '', - F3 = '', - F4 = '', - F5 = '', - F6 = '', - F7 = '', - F8 = '', - F9 = '', - F10 = '', - F11 = '', - F12 = '', - } - } - }) - end, - } + wk.setup({ + delay = 0, + icons = { + mappings = vim.g.have_nerd_font, + keys = vim.g.have_nerd_font and {} or { + Up = " ", + Down = " ", + Left = " ", + Right = " ", + C = " ", + M = " ", + D = " ", + S = " ", + CR = " ", + Esc = " ", + ScrollWheelDown = " ", + ScrollWheelUp = " ", + NL = " ", + BS = " ", + Space = " ", + Tab = " ", + F1 = "", + F2 = "", + F3 = "", + F4 = "", + F5 = "", + F6 = "", + F7 = "", + F8 = "", + F9 = "", + F10 = "", + F11 = "", + F12 = "", + }, + }, + }) + end, + }, } diff --git a/nvim/lua/juancwu/utils/colors.lua b/nvim/lua/juancwu/utils/colors.lua index b4cbe91..de0d5d4 100644 --- a/nvim/lua/juancwu/utils/colors.lua +++ b/nvim/lua/juancwu/utils/colors.lua @@ -5,33 +5,33 @@ local dark = "catppuccin-mocha" ---@return boolean function M.is_daytime() - return false + return false end ---@return boolean function M.legacy_is_daytime() - return false + return false end ---@return string function M.get_timebased_colorscheme() - if M.is_daytime() then - vim.g.is_light_colors = true - return light - else - vim.g.is_light_colors = false - return dark - end + if M.is_daytime() then + vim.g.is_light_colors = true + return light + else + vim.g.is_light_colors = false + return dark + end end function M.toggle_colors() - if vim.g.is_light_colors then - vim.g.is_light_colors = false - vim.cmd.colorscheme(dark) - else - vim.g.is_light_colors = true - vim.cmd.colorscheme(light) - end + if vim.g.is_light_colors then + vim.g.is_light_colors = false + vim.cmd.colorscheme(dark) + else + vim.g.is_light_colors = true + vim.cmd.colorscheme(light) + end end return M diff --git a/nvim/lua/juancwu/utils/init.lua b/nvim/lua/juancwu/utils/init.lua index 8b5d893..d89c668 100644 --- a/nvim/lua/juancwu/utils/init.lua +++ b/nvim/lua/juancwu/utils/init.lua @@ -2,10 +2,10 @@ ---@field os juancwu.utils.os ---@field colors juancwu.utils.colors local M = setmetatable({}, { - __index = function(t, k) - t[k] = require("juancwu.utils." .. k) - return t[k] - end, + __index = function(t, k) + t[k] = require("juancwu.utils." .. k) + return t[k] + end, }) return M diff --git a/nvim/lua/juancwu/utils/os.lua b/nvim/lua/juancwu/utils/os.lua index f1cbbc9..48306d5 100644 --- a/nvim/lua/juancwu/utils/os.lua +++ b/nvim/lua/juancwu/utils/os.lua @@ -3,35 +3,35 @@ local M = {} ---@return boolean function M.is_linux() - return vim.loop.os_uname().sysname:find("Linux") ~= nil + return vim.loop.os_uname().sysname:find("Linux") ~= nil end ---@return boolean function M.is_mac() - return vim.loop.os_uname().sysname:find("Darwin") ~= nil + return vim.loop.os_uname().sysname:find("Darwin") ~= nil end ---@return boolean function M.is_win() - return vim.loop.os_uname().sysname:find("Windows") ~= nil + return vim.loop.os_uname().sysname:find("Windows") ~= nil end ---@return boolean function M.is_wsl() - return vim.fn.has("wsl") == 1 + return vim.fn.has("wsl") == 1 end ---@param cmd string ---@return boolean function M.cmd_exists(cmd) - local handle = io.popen("command -v " .. cmd) - if handle ~= nil then - local result = handle:read("*a") - handle:close() - return #result > 0 - else - return false - end + local handle = io.popen("command -v " .. cmd) + if handle ~= nil then + local result = handle:read("*a") + handle:close() + return #result > 0 + else + return false + end end return M From 3b376950c85bfa20dfffa76c1d7a0f3ba4713177 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Fri, 5 Sep 2025 14:33:13 -0400 Subject: [PATCH 2/7] (nvim) update in progress --- nvim/after/ftplugin/go.lua | 2 + nvim/init.lua | 27 +- nvim/lazy-lock.json | 6 +- nvim/lua/juancwu/config/clipboard.lua | 106 +++--- nvim/lua/juancwu/config/init.lua | 95 +++--- nvim/lua/juancwu/config/keymaps.lua | 27 +- nvim/lua/juancwu/config/options.lua | 12 +- nvim/lua/juancwu/init.lua | 2 +- nvim/lua/juancwu/plugins/autocomplete.lua | 235 ++++++++----- nvim/lua/juancwu/plugins/autopairs.lua | 18 +- nvim/lua/juancwu/plugins/autotag.lua | 56 +-- nvim/lua/juancwu/plugins/colorscheme.lua | 83 ++--- nvim/lua/juancwu/plugins/comment.lua | 56 +-- nvim/lua/juancwu/plugins/conform.lua | 104 +++--- nvim/lua/juancwu/plugins/fugitive.lua | 42 +-- nvim/lua/juancwu/plugins/gitsigns.lua | 32 +- nvim/lua/juancwu/plugins/godoc.lua | 20 -- nvim/lua/juancwu/plugins/harpoon.lua | 26 -- nvim/lua/juancwu/plugins/indent-blankline.lua | 18 +- nvim/lua/juancwu/plugins/lazydev.lua | 12 +- nvim/lua/juancwu/plugins/lsp.lua | 260 +++++++------- nvim/lua/juancwu/plugins/lualine.lua | 104 +++--- nvim/lua/juancwu/plugins/luvit-meta.lua | 4 +- nvim/lua/juancwu/plugins/neo-tree.lua | 136 ++++---- nvim/lua/juancwu/plugins/nvim-lint.lua | 118 +++---- nvim/lua/juancwu/plugins/oil.lua | 48 +-- nvim/lua/juancwu/plugins/render-markdown.lua | 14 +- nvim/lua/juancwu/plugins/telescope.lua | 322 +++++++++--------- nvim/lua/juancwu/plugins/todo-comments.lua | 6 +- nvim/lua/juancwu/plugins/toggleterm.lua | 94 ++--- nvim/lua/juancwu/plugins/treesitter.lua | 194 +++++------ nvim/lua/juancwu/plugins/undotree.lua | 32 +- nvim/lua/juancwu/plugins/which-key.lua | 90 ++--- nvim/lua/juancwu/utils/colors.lua | 37 -- nvim/lua/juancwu/utils/init.lua | 9 +- nvim/lua/juancwu/utils/os.lua | 24 +- nvim/stylua.toml | 4 +- 37 files changed, 1214 insertions(+), 1261 deletions(-) create mode 100644 nvim/after/ftplugin/go.lua delete mode 100644 nvim/lua/juancwu/plugins/godoc.lua delete mode 100644 nvim/lua/juancwu/plugins/harpoon.lua delete mode 100644 nvim/lua/juancwu/utils/colors.lua diff --git a/nvim/after/ftplugin/go.lua b/nvim/after/ftplugin/go.lua new file mode 100644 index 0000000..c43d5ad --- /dev/null +++ b/nvim/after/ftplugin/go.lua @@ -0,0 +1,2 @@ +-- quick way to handle errors in Go +vim.keymap.set("n", "ee", "oif err != nil {}Oreturn err") diff --git a/nvim/init.lua b/nvim/init.lua index 7743d72..217fc6e 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,17 +1,18 @@ +-- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end end vim.opt.rtp:prepend(lazypath) -local Utils = require("juancwu.utils") -require("juancwu.config").setup({ - colorscheme = Utils.colors.get_timebased_colorscheme(), -}) +require("juancwu.config").setup({}) diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index df60f50..6568486 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -1,16 +1,12 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "LuaSnip": { "branch": "master", "commit": "21f74f7ba8c49f95f9d7c8293b147c2901dd2d3a" }, + "blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" }, "catppuccin": { "branch": "main", "commit": "30fa4d122d9b22ad8b2e0ab1b533c8c26c4dde86" }, "cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" }, - "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "conform.nvim": { "branch": "master", "commit": "b4aab989db276993ea5dcb78872be494ce546521" }, "fidget.nvim": { "branch": "main", "commit": "4d5858bd4c471c895060e1b9f3575f1551184dc5" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" }, - "godoc.nvim": { "branch": "main", "commit": "356f79853dbb3b3e200064367603751895153c29" }, - "harpoon": { "branch": "master", "commit": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "kanagawa.nvim": { "branch": "master", "commit": "debe91547d7fb1eef34ce26a5106f277fbfdd109" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, diff --git a/nvim/lua/juancwu/config/clipboard.lua b/nvim/lua/juancwu/config/clipboard.lua index 8aade05..8285a1e 100644 --- a/nvim/lua/juancwu/config/clipboard.lua +++ b/nvim/lua/juancwu/config/clipboard.lua @@ -1,58 +1,58 @@ local Utils = require("juancwu.utils") if Utils.os.is_linux() then - local wayland_display = os.getenv("WAYLAND_DISPLAY") - if Utils.os.is_wsl() then - vim.g.clipboard = { - name = "win32yank", - copy = { - ["+"] = "win32yank.exe -i --crlf", - ["*"] = "win32yank.exe -i --crlf", - }, - paste = { - ["+"] = "win32yank.exe -o --lf", - ["*"] = "win32yank.exe -o --lf", - }, - cache_enabled = 0, - } - elseif wayland_display then - vim.g.clipboard = { - name = "wl-clipboard", - copy = { - ["+"] = "wl-copy", - ["*"] = "wl-copy", - }, - paste = { - ["+"] = "wl-paste", - ["*"] = "wl-paste", - }, - cache_enabled = 1, - } - else - vim.g.clipboard = { - name = "xclip", - copy = { - ["+"] = "xclip -sel clip -i -quiet", - ["*"] = "xclip -sel primary -i -quiet", - }, - paste = { - ["+"] = "xclip -sel clip -o -quiet", - ["*"] = "xclip -sel primary -o -quiet", - }, - cache_enabled = 1, - } - end + local wayland_display = os.getenv("WAYLAND_DISPLAY") + if Utils.os.is_wsl() then + vim.g.clipboard = { + name = "win32yank", + copy = { + ["+"] = "win32yank.exe -i --crlf", + ["*"] = "win32yank.exe -i --crlf", + }, + paste = { + ["+"] = "win32yank.exe -o --lf", + ["*"] = "win32yank.exe -o --lf", + }, + cache_enabled = 0, + } + elseif wayland_display then + vim.g.clipboard = { + name = "wl-clipboard", + copy = { + ["+"] = "wl-copy", + ["*"] = "wl-copy", + }, + paste = { + ["+"] = "wl-paste", + ["*"] = "wl-paste", + }, + cache_enabled = 1, + } + else + vim.g.clipboard = { + name = "xclip", + copy = { + ["+"] = "xclip -sel clip -i -quiet", + ["*"] = "xclip -sel primary -i -quiet", + }, + paste = { + ["+"] = "xclip -sel clip -o -quiet", + ["*"] = "xclip -sel primary -o -quiet", + }, + cache_enabled = 1, + } + end elseif Utils.os.is_mac() then - vim.g.clipboard = { - name = "mac-clipboard", - copy = { - ["+"] = "pbcopy", - ["*"] = "pbcopy", - }, - paste = { - ["+"] = "pbpaste", - ["*"] = "pbpaste", - }, - cache_enabled = 1, - } + vim.g.clipboard = { + name = "mac-clipboard", + copy = { + ["+"] = "pbcopy", + ["*"] = "pbcopy", + }, + paste = { + ["+"] = "pbpaste", + ["*"] = "pbpaste", + }, + cache_enabled = 1, + } end diff --git a/nvim/lua/juancwu/config/init.lua b/nvim/lua/juancwu/config/init.lua index b2525b0..7496e7b 100644 --- a/nvim/lua/juancwu/config/init.lua +++ b/nvim/lua/juancwu/config/init.lua @@ -3,22 +3,22 @@ local M = {} ---@class ConfigOptions local defaultOpts = { - ---@type string | fun() - colorscheme = "rose-pine", + ---@type string | fun() + colorscheme = "catppuccin", } vim.g.disable_autoformat = false ---@param name "options" | "keymaps" | "clipboard" function M.load(name) - local mod = "juancwu.config." .. name - local error_handler = function(err) - local msg = "Failed loading " .. mod .. "\n\n" .. err - print(msg) - end - xpcall(function() - require(mod) - end, error_handler) + local mod = "juancwu.config." .. name + local error_handler = function(err) + local msg = "Failed loading " .. mod .. "\n\n" .. err + print(msg) + end + xpcall(function() + require(mod) + end, error_handler) end ---@type ConfigOptions @@ -26,55 +26,48 @@ local options ---@param opts? ConfigOptions function M.setup(opts) - options = vim.tbl_deep_extend("force", defaultOpts, opts or {}) or {} + options = vim.tbl_deep_extend("force", defaultOpts, opts or {}) or {} - M.load("options") - M.load("keymaps") - M.load("clipboard") + M.load("options") + M.load("keymaps") + M.load("clipboard") - require("lazy").setup("juancwu.plugins") + require("lazy").setup("juancwu.plugins") - -- try to load colorscheme - xpcall(function() - if type(M.colorscheme) == "function" then - M.colorscheme() - else - vim.cmd.colorscheme(M.colorscheme) - end - end, function(err) - if type(M.colorscheme) == "string" then - local msg = "Failed to load colorscheme " .. M.colorscheme .. "\n\n" .. err - print(msg) - else - print("Failed to load colorscheme\n\n" .. err) - end - vim.cmd.colorscheme("rose-pine") - end) + -- try to load colorscheme + xpcall(function() + if type(M.colorscheme) == "function" then + M.colorscheme() + else + vim.cmd.colorscheme(M.colorscheme) + end + end, function(err) + if type(M.colorscheme) == "string" then + local msg = "Failed to load colorscheme " .. M.colorscheme .. "\n\n" .. err + print(msg) + else + print("Failed to load colorscheme\n\n" .. err) + end + vim.cmd.colorscheme("rose-pine") + end) - -- create command to disable autoformat - vim.api.nvim_create_user_command("FormatDisable", function(args) - vim.g.disable_autoformat = true - end, { desc = "Disable Autoformat" }) - vim.api.nvim_create_user_command("FormatEnable", function(args) - vim.g.disable_autoformat = false - end, { desc = "Enable Autoformat" }) - - -- create command to toggle colorscheme - vim.api.nvim_create_user_command( - "ToggleColors", - require("juancwu.utils.colors").toggle_colors, - { desc = "Toggle colorscheme" } - ) + -- create command to disable autoformat + vim.api.nvim_create_user_command("FormatDisable", function(args) + vim.g.disable_autoformat = true + end, { desc = "Disable Autoformat" }) + vim.api.nvim_create_user_command("FormatEnable", function(args) + vim.g.disable_autoformat = false + end, { desc = "Enable Autoformat" }) end setmetatable(M, { - __index = function(_, k) - if options == nil then - return vim.deepcopy(defaultOpts)[k] - end + __index = function(_, k) + if options == nil then + return vim.deepcopy(defaultOpts)[k] + end - return options[k] - end, + return options[k] + end, }) return M diff --git a/nvim/lua/juancwu/config/keymaps.lua b/nvim/lua/juancwu/config/keymaps.lua index 79e461d..a3502a9 100644 --- a/nvim/lua/juancwu/config/keymaps.lua +++ b/nvim/lua/juancwu/config/keymaps.lua @@ -21,19 +21,16 @@ vim.keymap.set("n", "", "zz") vim.keymap.set("n", "n", "nzzzv") vim.keymap.set("n", "N", "Nzzzv") --- keymap below needs a better combo, need this to enable macros --- vim.keymap.set("n", "q", "q", { noremap = true }) - -- select and replace vim.keymap.set("n", "ss", [[:%s/\<\>//gI]]) -- do not copy with x, for god sake, WHY copy something that is being deleted?? -vim.keymap.set("n", "x", '"_x') +vim.keymap.set("n", "x", '"xx') -- no copy, delete line, for god sake... -vim.keymap.set("n", "dd", '"_dd') +vim.keymap.set("n", "dd", '"ddd') vim.keymap.set("n", "dx", "dd") -- cut line, under my control -vim.keymap.set("v", "d", '"_d') +vim.keymap.set("v", "d", '"dd') -- copy/paste to/from system clipboard vim.keymap.set({ "n", "v" }, "y", '"+y') @@ -48,6 +45,7 @@ vim.keymap.set("n", "dw", '"_dw') vim.keymap.set("n", "db", 'vb"_d') -- delete in backwards vim.keymap.set("n", "", "ggG") -- select all + -- split pane vim.keymap.set("n", "ss", ":splitw", { silent = true }) -- horizontal vim.keymap.set("n", "sv", ":vsplitw", { silent = true }) -- vertical @@ -60,19 +58,10 @@ vim.keymap.set("n", "sl", "l") vim.keymap.set("n", "sj", "j") -- resize pane -vim.keymap.set("n", "", "<") -vim.keymap.set("n", "", ">") -vim.keymap.set("n", "", "+") -vim.keymap.set("n", "", "-") - --- my arrow keys babyyyy -vim.keymap.set("i", "", "", { noremap = true }) -vim.keymap.set("i", "", "", { noremap = true }) -vim.keymap.set("i", "", "", { noremap = true }) -vim.keymap.set("i", "", "", { noremap = true }) +vim.keymap.set("n", "", "5>") +vim.keymap.set("n", "", "5<") +vim.keymap.set("n", "", "5+") +vim.keymap.set("n", "", "5-") -- lazygit on floaterm vim.keymap.set("n", "g", "FloatermNew lazygit", { noremap = true }) - --- quick way to handle errors in Go -vim.keymap.set("n", "ee", "oif err != nil {}Oreturn err") diff --git a/nvim/lua/juancwu/config/options.lua b/nvim/lua/juancwu/config/options.lua index ae77103..50f61e9 100644 --- a/nvim/lua/juancwu/config/options.lua +++ b/nvim/lua/juancwu/config/options.lua @@ -27,7 +27,7 @@ vim.opt.ignorecase = true -- case-insensitive search vim.opt.backspace = { "start", "eol", "indent" } -- don't want to look into these... -vim.opt.wildignore:append({ "*/node_modules/*", "*/__pycache__/*" }) +vim.opt.wildignore:append({ "*/node_modules/*", "*/__pycache__/*", "*/vendor/*" }) -- add '*' in block comments vim.opt.formatoptions:append({ "r" }) @@ -45,11 +45,11 @@ vim.opt.undofile = true -- highlight on yank local highligh_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }) vim.api.nvim_create_autocmd("TextYankPost", { - callback = function() - vim.highlight.on_yank() - end, - group = highligh_group, - pattern = "*", + callback = function() + vim.highlight.on_yank() + end, + group = highligh_group, + pattern = "*", }) vim.opt.completeopt = "menu,menuone,noselect" diff --git a/nvim/lua/juancwu/init.lua b/nvim/lua/juancwu/init.lua index 83343d5..69f7b3f 100644 --- a/nvim/lua/juancwu/init.lua +++ b/nvim/lua/juancwu/init.lua @@ -2,7 +2,7 @@ local M = {} ---@param opts? ConfigOptions function M.setup(opts) - require("juancwu.config").setup(opts) + require("juancwu.config").setup(opts) end return M diff --git a/nvim/lua/juancwu/plugins/autocomplete.lua b/nvim/lua/juancwu/plugins/autocomplete.lua index 281fda7..27981ca 100644 --- a/nvim/lua/juancwu/plugins/autocomplete.lua +++ b/nvim/lua/juancwu/plugins/autocomplete.lua @@ -1,93 +1,148 @@ -return { -- Autocompletion - "hrsh7th/nvim-cmp", - event = "InsertEnter", - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - { - "L3MON4D3/LuaSnip", - build = (function() - -- Build Step is needed for regex support in snippets. - -- This step is not supported in many windows environments. - -- Remove the below condition to re-enable on windows. - if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then - return - end - return "make install_jsregexp" - end)(), - dependencies = { - { - "rafamadriz/friendly-snippets", - config = function() - require("luasnip.loaders.from_vscode").lazy_load() - end, +-- return { -- Autocompletion +-- "hrsh7th/nvim-cmp", +-- event = "InsertEnter", +-- dependencies = { +-- -- Snippet Engine & its associated nvim-cmp source +-- { +-- "L3MON4D3/LuaSnip", +-- build = (function() +-- -- Build Step is needed for regex support in snippets. +-- -- This step is not supported in many windows environments. +-- -- Remove the below condition to re-enable on windows. +-- if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then +-- return +-- end +-- return "make install_jsregexp" +-- end)(), +-- dependencies = { +-- { +-- "rafamadriz/friendly-snippets", +-- config = function() +-- require("luasnip.loaders.from_vscode").lazy_load() +-- end, +-- }, +-- }, +-- }, +-- "saadparwaiz1/cmp_luasnip", +-- "hrsh7th/cmp-nvim-lsp", +-- "hrsh7th/cmp-path", +-- }, +-- config = function() +-- -- See `:help cmp` +-- local cmp = require("cmp") +-- local luasnip = require("luasnip") +-- luasnip.config.setup({}) +-- +-- cmp.setup({ +-- snippet = { +-- expand = function(args) +-- luasnip.lsp_expand(args.body) +-- end, +-- }, +-- completion = { completeopt = "menu,menuone,noinsert" }, +-- +-- -- For an understanding of why these mappings were +-- -- chosen, you will need to read `:help ins-completion` +-- -- +-- -- No, but seriously. Please read `:help ins-completion`, it is really good! +-- mapping = cmp.mapping.preset.insert({ +-- -- Select the [n]ext item +-- [""] = cmp.mapping.select_next_item(), +-- -- Select the [p]revious item +-- [""] = cmp.mapping.select_prev_item(), +-- +-- -- Scroll the documentation window [b]ack / [f]orward +-- [""] = cmp.mapping.scroll_docs(-4), +-- [""] = cmp.mapping.scroll_docs(4), +-- +-- -- 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 }), +-- +-- -- Manually trigger a completion from nvim-cmp. +-- -- Generally you don't need this, because nvim-cmp will display +-- -- completions whenever it has completion options available. +-- [""] = cmp.mapping.complete({}), +-- +-- -- will move you to the right of each of the expansion locations. +-- -- is similar, except moving you backwards. +-- [""] = cmp.mapping(function() +-- if luasnip.expand_or_locally_jumpable() then +-- luasnip.expand_or_jump() +-- end +-- end, { "i", "s" }), +-- [""] = cmp.mapping(function() +-- if luasnip.locally_jumpable(-1) then +-- luasnip.jump(-1) +-- end +-- end, { "i", "s" }), +-- }), +-- sources = { +-- { +-- name = "lazydev", +-- -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it +-- group_index = 0, +-- }, +-- { name = "nvim_lsp" }, +-- { name = "luasnip" }, +-- { name = "path" }, +-- }, +-- }) +-- end, +-- } +-- + +return { + "saghen/blink.cmp", + -- optional: provides snippets for the snippet source + dependencies = { "rafamadriz/friendly-snippets" }, + + -- use a release tag to download pre-built binaries + version = "1.*", + -- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust + -- build = 'cargo build --release', + -- If you use nix, you can build from source using latest nightly rust with: + -- build = 'nix run .#build-plugin', + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) + -- 'super-tab' for mappings similar to vscode (tab to accept) + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- All presets have the following mappings: + -- C-space: Open menu or open docs if already open + -- C-n/C-p or Up/Down: Select next/previous item + -- C-e: Hide menu + -- C-k: Toggle signature help (if signature.enabled = true) + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + keymap = { preset = "default" }, + + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = "mono", }, - }, + + -- (Default) Only show the documentation popup when manually triggered + completion = { documentation = { auto_show = false } }, + + -- Default list of enabled providers defined so that you can extend it + -- elsewhere in your config, without redefining it, due to `opts_extend` + sources = { + default = { "lsp", "path", "snippets", "buffer" }, + }, + + -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance + -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, + -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` + -- + -- See the fuzzy documentation for more information + fuzzy = { implementation = "prefer_rust_with_warning" }, }, - "saadparwaiz1/cmp_luasnip", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-path", - }, - config = function() - -- See `:help cmp` - local cmp = require("cmp") - local luasnip = require("luasnip") - luasnip.config.setup({}) - - cmp.setup({ - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - completion = { completeopt = "menu,menuone,noinsert" }, - - -- For an understanding of why these mappings were - -- chosen, you will need to read `:help ins-completion` - -- - -- No, but seriously. Please read `:help ins-completion`, it is really good! - mapping = cmp.mapping.preset.insert({ - -- Select the [n]ext item - [""] = cmp.mapping.select_next_item(), - -- Select the [p]revious item - [""] = cmp.mapping.select_prev_item(), - - -- Scroll the documentation window [b]ack / [f]orward - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - - -- 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 }), - - -- Manually trigger a completion from nvim-cmp. - -- Generally you don't need this, because nvim-cmp will display - -- completions whenever it has completion options available. - [""] = cmp.mapping.complete({}), - - -- will move you to the right of each of the expansion locations. - -- is similar, except moving you backwards. - [""] = cmp.mapping(function() - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - end - end, { "i", "s" }), - [""] = cmp.mapping(function() - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - end - end, { "i", "s" }), - }), - sources = { - { - name = "lazydev", - -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it - group_index = 0, - }, - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "path" }, - }, - }) - end, + opts_extend = { "sources.default" }, } diff --git a/nvim/lua/juancwu/plugins/autopairs.lua b/nvim/lua/juancwu/plugins/autopairs.lua index 9a43685..ada9976 100644 --- a/nvim/lua/juancwu/plugins/autopairs.lua +++ b/nvim/lua/juancwu/plugins/autopairs.lua @@ -1,11 +1,11 @@ return { - "windwp/nvim-autopairs", - event = "InsertEnter", - dependencies = { "hrsh7th/nvim-cmp" }, - config = function() - require("nvim-autopairs").setup({}) - local cmp_autopairs = require("nvim-autopairs.completion.cmp") - local cmp = require("cmp") - cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) - end, + "windwp/nvim-autopairs", + event = "InsertEnter", + dependencies = { "hrsh7th/nvim-cmp" }, + config = function() + require("nvim-autopairs").setup({}) + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + local cmp = require("cmp") + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end, } diff --git a/nvim/lua/juancwu/plugins/autotag.lua b/nvim/lua/juancwu/plugins/autotag.lua index 60b15ae..fad4051 100644 --- a/nvim/lua/juancwu/plugins/autotag.lua +++ b/nvim/lua/juancwu/plugins/autotag.lua @@ -1,30 +1,30 @@ return { - "windwp/nvim-ts-autotag", - dependencies = { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, - ft = { - "html", - "javascript", - "typescript", - "javascriptreact", - "typescriptreact", - "svelte", - "vue", - "tsx", - "jsx", - "xml", - "php", - "markdown", - "astro", - "glimmer", - "handlebars", - "hbs", - "templ", - }, - config = function() - local autotag = require("nvim-ts-autotag") - autotag.setup({ - enable = true, - enable_close_on_slash = false, - }) - end, + "windwp/nvim-ts-autotag", + dependencies = { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, + ft = { + "html", + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + "svelte", + "vue", + "tsx", + "jsx", + "xml", + "php", + "markdown", + "astro", + "glimmer", + "handlebars", + "hbs", + "templ", + }, + config = function() + local autotag = require("nvim-ts-autotag") + autotag.setup({ + enable = true, + enable_close_on_slash = false, + }) + end, } diff --git a/nvim/lua/juancwu/plugins/colorscheme.lua b/nvim/lua/juancwu/plugins/colorscheme.lua index 754d371..93743e5 100644 --- a/nvim/lua/juancwu/plugins/colorscheme.lua +++ b/nvim/lua/juancwu/plugins/colorscheme.lua @@ -1,47 +1,48 @@ return { - -- rose-pine - { - "rose-pine/nvim", - name = "rose-pine", - priority = 1000, - }, - - -- onedark - { - "navarasu/onedark.nvim", - priority = 1000, - }, - - -- solarized-osaka - { - "craftzdog/solarized-osaka.nvim", - priority = 1000, - opts = { - transparent = false, + -- rose-pine + { + "rose-pine/nvim", + name = "rose-pine", + priority = 1000, }, - }, - -- tokyonight - { - "folke/tokyonight.nvim", - lazy = true, - opts = { style = "moon" }, - }, - - -- catppuccin - { - "catppuccin/nvim", - lazy = true, - name = "catppuccin", - priority = 1000, - opts = { - flavour = "mocha", + -- onedark + { + "navarasu/onedark.nvim", + priority = 1000, }, - }, - -- great kanagawa - { - "rebelot/kanagawa.nvim", - opts = {}, - }, + -- solarized-osaka + { + "craftzdog/solarized-osaka.nvim", + priority = 1000, + opts = { + transparent = false, + }, + }, + + -- tokyonight + { + "folke/tokyonight.nvim", + lazy = true, + opts = { style = "moon" }, + }, + + -- catppuccin + { + "catppuccin/nvim", + lazy = true, + name = "catppuccin", + priority = 1000, + opts = { + flavour = "mocha", + integrations = { blink_cmp = true }, + }, + }, + + -- great kanagawa + { + "rebelot/kanagawa.nvim", + opts = {}, + }, } diff --git a/nvim/lua/juancwu/plugins/comment.lua b/nvim/lua/juancwu/plugins/comment.lua index cf08df1..8e0efe5 100644 --- a/nvim/lua/juancwu/plugins/comment.lua +++ b/nvim/lua/juancwu/plugins/comment.lua @@ -1,33 +1,33 @@ return { - "numToStr/Comment.nvim", - dependencies = { - "JoosepAlviste/nvim-ts-context-commentstring", - }, - config = function() - local comment = require("Comment") - comment.setup({ - pre_hook = function(ctx) - -- only for tsx/jsx filetypes - if vim.bo.filetype == "typescriptreact" or vim.bo.filetype == "javascriptreact" then - local U = require("Comment.utils") + "numToStr/Comment.nvim", + dependencies = { + "JoosepAlviste/nvim-ts-context-commentstring", + }, + config = function() + local comment = require("Comment") + comment.setup({ + pre_hook = function(ctx) + -- only for tsx/jsx filetypes + if vim.bo.filetype == "typescriptreact" or vim.bo.filetype == "javascriptreact" then + local U = require("Comment.utils") - -- determine wheter to use linwise or blockwise commentstring - local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline" + -- determine wheter to use linwise or blockwise commentstring + local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline" - -- determine the location where to calcualte commentstring from - local location = nil - if ctx.ctype == U.ctype.blockwise then - location = require("ts_context_commentstring.utils").get_cursor_location() - elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then - location = require("ts_context_commentstring.utils").get_visual_start_location() - end + -- determine the location where to calcualte commentstring from + local location = nil + if ctx.ctype == U.ctype.blockwise then + location = require("ts_context_commentstring.utils").get_cursor_location() + elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + location = require("ts_context_commentstring.utils").get_visual_start_location() + end - return require("ts_context_commentstring.internal").calculate_commentstring({ - key = type, - location = location, - }) - end - end, - }) - end, + return require("ts_context_commentstring.internal").calculate_commentstring({ + key = type, + location = location, + }) + end + end, + }) + end, } diff --git a/nvim/lua/juancwu/plugins/conform.lua b/nvim/lua/juancwu/plugins/conform.lua index c082d55..7354f85 100644 --- a/nvim/lua/juancwu/plugins/conform.lua +++ b/nvim/lua/juancwu/plugins/conform.lua @@ -1,60 +1,60 @@ local formatters_by_ft = { - lua = { "stylua" }, - javascript = { "biome" }, - typescript = { "biome" }, - javascriptreact = { "biome" }, - typescriptreact = { "biome" }, - css = { "biome" }, - markdown = { "biome" }, - jsonc = { "biome" }, - json = { "biome" }, - go = { "gofmt", "goimports" }, - python = { "autopep8" }, - yaml = { "yamlfmt" }, - yml = { "yamlfmt" }, - zig = { "zigfmt" }, - rust = { "rustfmt" }, + lua = { "stylua" }, + javascript = { "biome" }, + typescript = { "biome" }, + javascriptreact = { "biome" }, + typescriptreact = { "biome" }, + css = { "biome" }, + markdown = { "biome" }, + jsonc = { "biome" }, + json = { "biome" }, + go = { "gofmt", "goimports" }, + python = { "autopep8" }, + yaml = { "yamlfmt" }, + yml = { "yamlfmt" }, + zig = { "zigfmt" }, + rust = { "rustfmt" }, } return { - "stevearc/conform.nvim", - event = { "BufWritePre", "BufEnter" }, - cmd = { "ConformInfo" }, - keys = { - { - "ff", - function() - require("conform").format({ async = true, lsp_format = "fallback" }) - end, - mode = "", - desc = "[F]ormat buffer", + "stevearc/conform.nvim", + event = { "BufWritePre", "BufEnter" }, + cmd = { "ConformInfo" }, + keys = { + { + "ff", + function() + require("conform").format({ async = true, lsp_format = "fallback" }) + end, + mode = "", + desc = "[F]ormat buffer", + }, }, - }, - config = function() - require("conform").setup({ - notify_on_error = false, - formatters_by_ft = formatters_by_ft, - format_on_save = function(bufnr) - if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then - return - end - return { - timeout_ms = 500, - lsp_format = "fallback", - } - end, - }) + config = function() + require("conform").setup({ + notify_on_error = false, + formatters_by_ft = formatters_by_ft, + format_on_save = function(bufnr) + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + return { + timeout_ms = 500, + lsp_format = "fallback", + } + end, + }) - vim.api.nvim_create_user_command("FormatDisable", function() - vim.g.disable_autoformat = true - end, { - desc = "Disable autoformat on save", - }) + vim.api.nvim_create_user_command("FormatDisable", function() + vim.g.disable_autoformat = true + end, { + desc = "Disable autoformat on save", + }) - vim.api.nvim_create_user_command("FormatEnable", function() - vim.g.disable_autoformat = false - end, { - desc = "Enable autoformat on save", - }) - end, + vim.api.nvim_create_user_command("FormatEnable", function() + vim.g.disable_autoformat = false + end, { + desc = "Enable autoformat on save", + }) + end, } diff --git a/nvim/lua/juancwu/plugins/fugitive.lua b/nvim/lua/juancwu/plugins/fugitive.lua index 9142e2a..03812b6 100644 --- a/nvim/lua/juancwu/plugins/fugitive.lua +++ b/nvim/lua/juancwu/plugins/fugitive.lua @@ -1,23 +1,23 @@ return { - "tpope/vim-fugitive", - cmd = { - "Git", - "G", - "Gdiffsplit", - "Gread", - "Gwrite", - "Ggrep", - "GMove", - "GDelete", - "GBrowse", - "GRemove", - "GRename", - "Glgrep", - "Gedit", - }, - keys = { - { "gs", "Git", desc = "Git status" }, - { "gbl", "Git blame", desc = "Open [G]it [Bl]ame" }, - { "gd", "Gdiffsplit", desc = "Open [G]it [D]iff" }, - }, + "tpope/vim-fugitive", + cmd = { + "Git", + "G", + "Gdiffsplit", + "Gread", + "Gwrite", + "Ggrep", + "GMove", + "GDelete", + "GBrowse", + "GRemove", + "GRename", + "Glgrep", + "Gedit", + }, + keys = { + { "gs", "Git", desc = "Git status" }, + { "gbl", "Git blame", desc = "Open [G]it [Bl]ame" }, + { "gd", "Gdiffsplit", desc = "Open [G]it [D]iff" }, + }, } diff --git a/nvim/lua/juancwu/plugins/gitsigns.lua b/nvim/lua/juancwu/plugins/gitsigns.lua index 412175a..f1e8b44 100644 --- a/nvim/lua/juancwu/plugins/gitsigns.lua +++ b/nvim/lua/juancwu/plugins/gitsigns.lua @@ -1,19 +1,19 @@ return { - "lewis6991/gitsigns.nvim", - opts = { - current_line_blame = true, - current_line_blame_opts = { - virt_text = true, - virt_text_pos = "eol", - delay = 1000, - ignore_whitespace = false, + "lewis6991/gitsigns.nvim", + opts = { + current_line_blame = true, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", + delay = 1000, + ignore_whitespace = false, + }, + signs = { + add = { text = "+" }, + change = { text = "~" }, + delete = { text = "_" }, + topdelete = { text = "-" }, + changedelete = { text = "~" }, + }, }, - signs = { - add = { text = "+" }, - change = { text = "~" }, - delete = { text = "_" }, - topdelete = { text = "-" }, - changedelete = { text = "~" }, - }, - }, } diff --git a/nvim/lua/juancwu/plugins/godoc.lua b/nvim/lua/juancwu/plugins/godoc.lua deleted file mode 100644 index 43ec765..0000000 --- a/nvim/lua/juancwu/plugins/godoc.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - "fredrikaverpil/godoc.nvim", - version = "*", - dependencies = { - { "nvim-telescope/telescope.nvim" }, - { - "nvim-treesitter/nvim-treesitter", - opts = { - ensure_installed = { "go" }, - }, - }, - }, - build = "go install github.com/lotusirous/gostdsym/stdsym@latest", -- optional - cmd = { "GoDoc" }, -- optional - opts = { - picker = { - type = "telescope", - }, - }, -} diff --git a/nvim/lua/juancwu/plugins/harpoon.lua b/nvim/lua/juancwu/plugins/harpoon.lua deleted file mode 100644 index 6885ea2..0000000 --- a/nvim/lua/juancwu/plugins/harpoon.lua +++ /dev/null @@ -1,26 +0,0 @@ -return { - "ThePrimeagen/harpoon", - dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - local mark = require("harpoon.mark") - local ui = require("harpoon.ui") - - vim.keymap.set("n", "a", mark.add_file) - vim.keymap.set("n", "", ui.toggle_quick_menu) - - vim.keymap.set("n", "q", function() - ui.nav_file(1) - end) - vim.keymap.set("n", "w", function() - ui.nav_file(2) - end) - vim.keymap.set("n", "e", function() - ui.nav_file(3) - end) - vim.keymap.set("n", "r", function() - ui.nav_file(4) - end) - vim.keymap.set("n", ",", ui.nav_prev) - vim.keymap.set("n", ".", ui.nav_next) - end, -} diff --git a/nvim/lua/juancwu/plugins/indent-blankline.lua b/nvim/lua/juancwu/plugins/indent-blankline.lua index 4e373e9..61651ec 100644 --- a/nvim/lua/juancwu/plugins/indent-blankline.lua +++ b/nvim/lua/juancwu/plugins/indent-blankline.lua @@ -1,12 +1,12 @@ return { - "lukas-reineke/indent-blankline.nvim", - opts = { - indent = { - smart_indent_cap = true, + "lukas-reineke/indent-blankline.nvim", + opts = { + indent = { + smart_indent_cap = true, + }, + scope = { + show_end = true, + }, }, - scope = { - show_end = true, - }, - }, - main = "ibl", + main = "ibl", } diff --git a/nvim/lua/juancwu/plugins/lazydev.lua b/nvim/lua/juancwu/plugins/lazydev.lua index 193d759..f38b15c 100644 --- a/nvim/lua/juancwu/plugins/lazydev.lua +++ b/nvim/lua/juancwu/plugins/lazydev.lua @@ -1,9 +1,9 @@ return { - "folke/lazydev.nvim", - ft = "lua", - opts = { - library = { - { path = "luvit-meta/library", words = { "vim%.uv" } }, + "folke/lazydev.nvim", + ft = "lua", + opts = { + library = { + { path = "luvit-meta/library", words = { "vim%.uv" } }, + }, }, - }, } diff --git a/nvim/lua/juancwu/plugins/lsp.lua b/nvim/lua/juancwu/plugins/lsp.lua index 01fca90..e51e9da 100644 --- a/nvim/lua/juancwu/plugins/lsp.lua +++ b/nvim/lua/juancwu/plugins/lsp.lua @@ -1,154 +1,154 @@ return { - -- lspconfig - "neovim/nvim-lspconfig", - dependencies = { + -- lspconfig + "neovim/nvim-lspconfig", + dependencies = { - { "williamboman/mason.nvim", opts = {} }, - "williamboman/mason-lspconfig.nvim", - "WhoIsSethDaniel/mason-tool-installer.nvim", + { "williamboman/mason.nvim", opts = {} }, + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", - -- status updates for LSP - { "j-hui/fidget.nvim", opts = {} }, + -- status updates for LSP + { "j-hui/fidget.nvim", opts = {} }, - { "hrsh7th/cmp-nvim-lsp" }, -- Required - }, - config = function() - -- stole this from kickstart, great config - vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), - callback = function(event) - local map = function(keys, func, desc, mode) - mode = mode or "n" - vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) - end + { "hrsh7th/cmp-nvim-lsp" }, -- Required + }, + config = function() + -- stole this from kickstart, great config + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), + callback = function(event) + local map = function(keys, func, desc, mode) + mode = mode or "n" + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) + end - -- Jump to the definition of the word under your cursor. - -- This is where a variable was first declared, or where a function is defined, etc. - -- To jump back, press . - map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") + -- Jump to the definition of the word under your cursor. + -- This is where a variable was first declared, or where a function is defined, etc. + -- To jump back, press . + map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") - -- Find references for the word under your cursor. - map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") + -- Find references for the word under your cursor. + map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") - -- Jump to the implementation of the word under your cursor. - -- Useful when your language has ways of declaring types without an actual implementation. - map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") - -- Jump to the type of the word under your cursor. - -- Useful when you're not sure what type a variable is and you want to see - -- the definition of its *type*, not where it was *defined*. - map("D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition") + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + map("D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition") - -- Fuzzy find all the symbols in your current document. - -- Symbols are things like variables, functions, types, etc. - map("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + map("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") - -- Fuzzy find all the symbols in your current workspace. - -- Similar to document symbols, except searches over your entire project. - map("ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + map("ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") - -- Rename the variable under your cursor. - -- Most Language Servers support renaming across files, etc. - map("rn", vim.lsp.buf.rename, "[R]e[n]ame") + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + map("rn", vim.lsp.buf.rename, "[R]e[n]ame") - -- Execute a code action, usually your cursor needs to be on top of an error - -- or a suggestion from your LSP for this to activate. - map("ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" }) + -- Execute a code action, usually your cursor needs to be on top of an error + -- or a suggestion from your LSP for this to activate. + map("ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" }) - -- 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") + -- 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") - map("[d", vim.diagnostic.goto_prev, "Go to previous diagnostic") - map("]d", vim.diagnostic.goto_next, "Go to next diagnostic") + map("[d", vim.diagnostic.goto_prev, "Go to previous diagnostic") + map("]d", vim.diagnostic.goto_next, "Go to next diagnostic") - -- The following two autocommands are used to highlight references of the - -- word under your cursor when your cursor rests there for a little while. - -- See `:help CursorHold` for information about when this is executed - -- - -- When you move your cursor, the highlights will be cleared (the second autocommand). - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then - local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false }) - vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then + local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false }) + vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) - vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) + vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) - vim.api.nvim_create_autocmd("LspDetach", { - group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf }) + vim.api.nvim_create_autocmd("LspDetach", { + group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf }) + end, + }) + end end, - }) - end - end, - }) + }) - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) - vim.filetype.add({ - extension = { - templ = "templ", - }, - }) - - local servers = { - ts_ls = {}, - gopls = {}, - zls = {}, - rust_analyzer = {}, - templ = { - filetypes = { "templ" }, - }, - intelephense = {}, - lua_ls = { - settings = { - Lua = { - completion = { - callSnippet = "Replace", + vim.filetype.add({ + extension = { + templ = "templ", }, - }, - }, - }, - tailwindcss = { - filetypes = { - "templ", - "html", - "javascript", - "typescript", - "javascriptreact", - "typescriptreact", - }, - init_options = { - userLanguages = { - templ = "html", - }, - }, - }, - } + }) - local ensure_installed = vim.tbl_keys(servers or {}) - vim.list_extend(ensure_installed, { "stylua", "yamlfmt", "autopep8", "biome", "goimports" }) - require("mason-tool-installer").setup({ ensure_installed = ensure_installed }) + local servers = { + ts_ls = {}, + gopls = {}, + zls = {}, + rust_analyzer = {}, + templ = { + filetypes = { "templ" }, + }, + intelephense = {}, + lua_ls = { + settings = { + Lua = { + completion = { + callSnippet = "Replace", + }, + }, + }, + }, + tailwindcss = { + filetypes = { + "templ", + "html", + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + }, + init_options = { + userLanguages = { + templ = "html", + }, + }, + }, + } - require("mason-lspconfig").setup({ - handlers = { - function(server_name) - local server = servers[server_name] or {} - server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) - require("lspconfig")[server_name].setup(server) - end, - }, - }) - end, + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { "stylua", "yamlfmt", "autopep8", "biome", "goimports" }) + require("mason-tool-installer").setup({ ensure_installed = ensure_installed }) + + require("mason-lspconfig").setup({ + handlers = { + function(server_name) + local server = servers[server_name] or {} + server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) + require("lspconfig")[server_name].setup(server) + end, + }, + }) + end, } diff --git a/nvim/lua/juancwu/plugins/lualine.lua b/nvim/lua/juancwu/plugins/lualine.lua index 63ecac4..35a5ac2 100644 --- a/nvim/lua/juancwu/plugins/lualine.lua +++ b/nvim/lua/juancwu/plugins/lualine.lua @@ -1,13 +1,13 @@ return { - "nvim-lualine/lualine.nvim", - dependencies = { "nvim-tree/nvim-web-devicons", lazy = true }, - config = function() - local lualine = require("lualine") + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons", lazy = true }, + config = function() + local lualine = require("lualine") - lualine.setup({ - options = { - icons_enabled = false, - --[[ section_separators = { + lualine.setup({ + options = { + icons_enabled = false, + --[[ section_separators = { left = '', right = '' }, @@ -15,48 +15,48 @@ return { left = '', right = '' }, ]] - section_separators = "", - component_separators = "|", - disabled_filetypes = {}, - }, - sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { - { - "filename", - file_status = true, -- display file status - path = 1, -- no file path - }, - }, - lualine_x = { - { - "diagnostics", - sources = { "nvim_diagnostic" }, - symbols = { error = " ", warn = " ", info = " ", hint = "" }, - }, - "enconding", - "filetype", - }, - lualine_y = { "progress" }, - lualine_z = { "location" }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { - { - "filename", - file_status = true, - path = 1, - }, - }, - lualine_x = { "location" }, - lualine_y = {}, - lualine_z = {}, - }, - tabline = {}, - extensions = { "fugitive" }, - }) - end, + section_separators = "", + component_separators = "|", + disabled_filetypes = {}, + }, + sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { + { + "filename", + file_status = true, -- display file status + path = 1, -- no file path + }, + }, + lualine_x = { + { + "diagnostics", + sources = { "nvim_diagnostic" }, + symbols = { error = " ", warn = " ", info = " ", hint = "" }, + }, + "enconding", + "filetype", + }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { + { + "filename", + file_status = true, + path = 1, + }, + }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + extensions = { "fugitive" }, + }) + end, } diff --git a/nvim/lua/juancwu/plugins/luvit-meta.lua b/nvim/lua/juancwu/plugins/luvit-meta.lua index 7fcb36c..c82f23a 100644 --- a/nvim/lua/juancwu/plugins/luvit-meta.lua +++ b/nvim/lua/juancwu/plugins/luvit-meta.lua @@ -1,4 +1,4 @@ return { - "Bilal2453/luvit-meta", - lazy = true, + "Bilal2453/luvit-meta", + lazy = true, } diff --git a/nvim/lua/juancwu/plugins/neo-tree.lua b/nvim/lua/juancwu/plugins/neo-tree.lua index 88f27c3..fddaad3 100644 --- a/nvim/lua/juancwu/plugins/neo-tree.lua +++ b/nvim/lua/juancwu/plugins/neo-tree.lua @@ -1,71 +1,71 @@ return { - "nvim-neo-tree/neo-tree.nvim", - enabled = false, - branch = "v2.x", - cmd = { "Neotree" }, - keys = { - { "fs", "NeoTreeFloatToggle", desc = "Toggle [F]ile [S]ystem Floating Menu" }, - { "", "NeoTreeFocusToggle", desc = "Open Side File System" }, - }, - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - }, - opts = { - use_default_mappings = true, - mappings = { - [""] = { - "toggle_node", - nowait = true, -- disable `nowait` if you have existing combos starting with this char that you want to use - }, - ["<2-LeftMouse>"] = "open", - [""] = "open", - [""] = "cancel", -- close preview or floating neo-tree window - ["P"] = { "toggle_preview", config = { use_float = true } }, - ["l"] = "focus_preview", - ["O"] = "open_split", - ["o"] = "open_vsplit", - ["S"] = "none", - ["s"] = "none", - -- ["S"] = "split_with_window_picker", - -- ["s"] = "vsplit_with_window_picker", - ["t"] = "open_tabnew", - -- [""] = "open_drop", - -- ["t"] = "open_tab_drop", - ["w"] = "open_with_window_picker", - --["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing - ["C"] = "close_node", - -- ['C'] = 'close_all_subnodes', - ["z"] = "close_all_nodes", - --["Z"] = "expand_all_nodes", - ["a"] = { - "add", - -- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details - -- some commands may take optional config options, see `:h neo-tree-mappings` for details - config = { - show_path = "none", -- "none", "relative", "absolute" - }, - }, - ["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion. - ["d"] = "delete", - ["r"] = "rename", - ["y"] = "copy_to_clipboard", - ["x"] = "cut_to_clipboard", - ["p"] = "paste_from_clipboard", - ["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add": - -- ["c"] = { - -- "copy", - -- config = { - -- show_path = "none" -- "none", "relative", "absolute" - -- } - --} - ["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add". - ["q"] = "close_window", - ["R"] = "refresh", - ["?"] = "show_help", - ["<"] = "prev_source", - [">"] = "next_source", + "nvim-neo-tree/neo-tree.nvim", + enabled = false, + branch = "v2.x", + cmd = { "Neotree" }, + keys = { + { "fs", "NeoTreeFloatToggle", desc = "Toggle [F]ile [S]ystem Floating Menu" }, + { "", "NeoTreeFocusToggle", desc = "Open Side File System" }, + }, + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + opts = { + use_default_mappings = true, + mappings = { + [""] = { + "toggle_node", + nowait = true, -- disable `nowait` if you have existing combos starting with this char that you want to use + }, + ["<2-LeftMouse>"] = "open", + [""] = "open", + [""] = "cancel", -- close preview or floating neo-tree window + ["P"] = { "toggle_preview", config = { use_float = true } }, + ["l"] = "focus_preview", + ["O"] = "open_split", + ["o"] = "open_vsplit", + ["S"] = "none", + ["s"] = "none", + -- ["S"] = "split_with_window_picker", + -- ["s"] = "vsplit_with_window_picker", + ["t"] = "open_tabnew", + -- [""] = "open_drop", + -- ["t"] = "open_tab_drop", + ["w"] = "open_with_window_picker", + --["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing + ["C"] = "close_node", + -- ['C'] = 'close_all_subnodes', + ["z"] = "close_all_nodes", + --["Z"] = "expand_all_nodes", + ["a"] = { + "add", + -- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details + -- some commands may take optional config options, see `:h neo-tree-mappings` for details + config = { + show_path = "none", -- "none", "relative", "absolute" + }, + }, + ["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion. + ["d"] = "delete", + ["r"] = "rename", + ["y"] = "copy_to_clipboard", + ["x"] = "cut_to_clipboard", + ["p"] = "paste_from_clipboard", + ["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add": + -- ["c"] = { + -- "copy", + -- config = { + -- show_path = "none" -- "none", "relative", "absolute" + -- } + --} + ["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add". + ["q"] = "close_window", + ["R"] = "refresh", + ["?"] = "show_help", + ["<"] = "prev_source", + [">"] = "next_source", + }, }, - }, } diff --git a/nvim/lua/juancwu/plugins/nvim-lint.lua b/nvim/lua/juancwu/plugins/nvim-lint.lua index c4a23fe..56bc7c5 100644 --- a/nvim/lua/juancwu/plugins/nvim-lint.lua +++ b/nvim/lua/juancwu/plugins/nvim-lint.lua @@ -1,84 +1,84 @@ local linters_by_ft = { - javascript = { "biomejs", "eslint" }, - typescript = { "biomejs", "eslint" }, - javascriptreact = { "biomejs", "eslint" }, - typescriptreact = { "biomejs", "eslint" }, - jsonc = { "biomejs" }, - json = { "biomejs" }, - css = { "biomejs" }, + javascript = { "biomejs", "eslint" }, + typescript = { "biomejs", "eslint" }, + javascriptreact = { "biomejs", "eslint" }, + typescriptreact = { "biomejs", "eslint" }, + jsonc = { "biomejs" }, + json = { "biomejs" }, + css = { "biomejs" }, } -- Function to find the first config file by walking up the directory tree local function find_first_config() - local current_dir = vim.fn.expand("%:p:h") - local home_dir = vim.fn.expand("$HOME") + local current_dir = vim.fn.expand("%:p:h") + local home_dir = vim.fn.expand("$HOME") - local config_files = { - biomejs = { "biome.json" }, - eslint = { ".eslintrc", ".eslintrc.js", ".eslintrc.json", ".eslintrc.yml" }, - } + local config_files = { + biomejs = { "biome.json" }, + eslint = { ".eslintrc", ".eslintrc.js", ".eslintrc.json", ".eslintrc.yml" }, + } - while current_dir ~= home_dir and current_dir ~= "/" do - for linter, patterns in pairs(config_files) do - for _, pattern in ipairs(patterns) do - local config_file = current_dir .. "/" .. pattern - if vim.fn.filereadable(config_file) == 1 then - return linter + while current_dir ~= home_dir and current_dir ~= "/" do + for linter, patterns in pairs(config_files) do + for _, pattern in ipairs(patterns) do + local config_file = current_dir .. "/" .. pattern + if vim.fn.filereadable(config_file) == 1 then + return linter + end + end end - end + current_dir = vim.fn.fnamemodify(current_dir, ":h") end - current_dir = vim.fn.fnamemodify(current_dir, ":h") - end - return nil + return nil end -- Function to determine the linter based on config files and file type local function get_linter() - local filetype = vim.bo.filetype - local available_linters = linters_by_ft[filetype] or {} - local linter = find_first_config() + local filetype = vim.bo.filetype + local available_linters = linters_by_ft[filetype] or {} + local linter = find_first_config() - if linter then - if vim.tbl_contains(available_linters, linter) then - vim.g.current_linter = linter - return linter + if linter then + if vim.tbl_contains(available_linters, linter) then + vim.g.current_linter = linter + return linter + end end - end - return nil + return nil end local function lint() - local nvimlint = require("lint") - local linter = get_linter() - if linter ~= nil then - nvimlint.try_lint(linter) - else - print("No linter found for filetype: " .. vim.bo.filetype) - end + local nvimlint = require("lint") + local linter = get_linter() + if linter ~= nil then + nvimlint.try_lint(linter) + else + print("No linter found for filetype: " .. vim.bo.filetype) + end end return { - "mfussenegger/nvim-lint", - keys = { - { - "lf", - function() - lint() - end, - mode = "n", - desc = "[L]int [F]ile", + "mfussenegger/nvim-lint", + keys = { + { + "lf", + function() + lint() + end, + mode = "n", + desc = "[L]int [F]ile", + }, }, - }, - config = function() - vim.api.nvim_create_user_command("Lint", function() - lint() - end, { desc = "Lint file" }) + config = function() + vim.api.nvim_create_user_command("Lint", function() + lint() + end, { desc = "Lint file" }) - vim.api.nvim_create_user_command("LintInfo", function() - print("Current linter: " .. (vim.g.current_linter or "none")) - end, { - desc = "Show current linter being used", - }) - end, + vim.api.nvim_create_user_command("LintInfo", function() + print("Current linter: " .. (vim.g.current_linter or "none")) + end, { + desc = "Show current linter being used", + }) + end, } diff --git a/nvim/lua/juancwu/plugins/oil.lua b/nvim/lua/juancwu/plugins/oil.lua index 1252aeb..a9aa269 100644 --- a/nvim/lua/juancwu/plugins/oil.lua +++ b/nvim/lua/juancwu/plugins/oil.lua @@ -1,28 +1,28 @@ return { - "stevearc/oil.nvim", - ---@module 'oil' - ---@type oil.SetupOpts - -- Optional dependencies - dependencies = { { "echasnovski/mini.icons", opts = {} } }, - -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. - lazy = false, - config = function() - local oil = require("oil") + "stevearc/oil.nvim", + ---@module 'oil' + ---@type oil.SetupOpts + -- Optional dependencies + dependencies = { { "echasnovski/mini.icons", opts = {} } }, + -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. + lazy = false, + config = function() + local oil = require("oil") - oil.setup({ - view_options = { - show_hidden = true, - }, - }) - end, - keys = { - { - "oo", - function() - require("oil").open() - end, - mode = "n", - desc = "[O]pen [O]il", + oil.setup({ + view_options = { + show_hidden = true, + }, + }) + end, + keys = { + { + "oo", + function() + require("oil").open() + end, + mode = "n", + desc = "[O]pen [O]il", + }, }, - }, } diff --git a/nvim/lua/juancwu/plugins/render-markdown.lua b/nvim/lua/juancwu/plugins/render-markdown.lua index 533b6a4..5808d3a 100644 --- a/nvim/lua/juancwu/plugins/render-markdown.lua +++ b/nvim/lua/juancwu/plugins/render-markdown.lua @@ -1,9 +1,9 @@ return { - "MeanderingProgrammer/render-markdown.nvim", - dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite - -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins - -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons - ---@module 'render-markdown' - ---@type render.md.UserConfig - opts = {}, + "MeanderingProgrammer/render-markdown.nvim", + dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons + ---@module 'render-markdown' + ---@type render.md.UserConfig + opts = {}, } diff --git a/nvim/lua/juancwu/plugins/telescope.lua b/nvim/lua/juancwu/plugins/telescope.lua index 2df54e7..8fcda7c 100644 --- a/nvim/lua/juancwu/plugins/telescope.lua +++ b/nvim/lua/juancwu/plugins/telescope.lua @@ -1,181 +1,181 @@ local function get_fd_command() - if vim.fn.executable("fd") == 1 then - return "fd" - elseif vim.fn.executable("fdfind") == 1 then - return "fdfind" - end - return nil + if vim.fn.executable("fd") == 1 then + return "fd" + elseif vim.fn.executable("fdfind") == 1 then + return "fdfind" + end + return nil end return { - "nvim-telescope/telescope.nvim", - version = "0.1.8", - dependencies = { - "nvim-lua/plenary.nvim", - { - "nvim-telescope/telescope-fzf-native.nvim", - build = "make", - enabled = true, - cond = function() - return vim.fn.executable("make") == 1 - end, - }, - { - "nvim-telescope/telescope-file-browser.nvim", - dependencies = { - "nvim-telescope/telescope.nvim", + "nvim-telescope/telescope.nvim", + version = "0.1.8", + dependencies = { "nvim-lua/plenary.nvim", - }, - enabled = true, + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + enabled = true, + cond = function() + return vim.fn.executable("make") == 1 + end, + }, + { + "nvim-telescope/telescope-file-browser.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + "nvim-lua/plenary.nvim", + }, + enabled = true, + }, + { "nvim-telescope/telescope-ui-select.nvim" }, + { "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font }, }, - { "nvim-telescope/telescope-ui-select.nvim" }, - { "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font }, - }, - config = function() - local telescope = require("telescope") - local actions = require("telescope.actions") - local builtin = require("telescope.builtin") - local fb_actions = require("telescope").extensions.file_browser.actions + config = function() + local telescope = require("telescope") + local actions = require("telescope.actions") + local builtin = require("telescope.builtin") + local fb_actions = require("telescope").extensions.file_browser.actions - local function telescope_buffer_dir() - return vim.fn.expand("%:p:h") - end + local function telescope_buffer_dir() + return vim.fn.expand("%:p:h") + end - telescope.setup({ - defaults = { - mappings = { - n = { - ["q"] = actions.close, - }, - }, - }, - extensions = { - ["ui-select"] = { - require("telescope.themes").get_dropdown(), - }, - file_browser = { - theme = "dropdown", - hijack_netrw = false, - hidden = true, - mappings = { - ["i"] = { - [""] = function() - vim.cmd("normal vbd") - end, - [""] = function(bufnr) - actions.move_selection_next(bufnr) - end, - [""] = function(bufnr) - actions.move_selection_previous(bufnr) - end, - [""] = function(bufnr) - actions.select_vertical(bufnr) - end, + telescope.setup({ + defaults = { + mappings = { + n = { + ["q"] = actions.close, + }, + }, }, - ["n"] = { - ["a"] = fb_actions.create, - ["h"] = fb_actions.goto_parent_dir, - ["/"] = function() - vim.cmd("startinsert") - end, - ["d"] = fb_actions.remove, - ["e"] = fb_actions.change_cwd, - [""] = function(bufnr) - actions.select_vertical(bufnr) - end, - [""] = function(bufnr) - actions.toggle_all(bufnr) - end, - [""] = function(bufnr) - actions.move_selection_next(bufnr) - end, - [""] = function(bufnr) - actions.move_selection_previous(bufnr) - end, + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown(), + }, + file_browser = { + theme = "dropdown", + hijack_netrw = false, + hidden = true, + mappings = { + ["i"] = { + [""] = function() + vim.cmd("normal vbd") + end, + [""] = function(bufnr) + actions.move_selection_next(bufnr) + end, + [""] = function(bufnr) + actions.move_selection_previous(bufnr) + end, + [""] = function(bufnr) + actions.select_vertical(bufnr) + end, + }, + ["n"] = { + ["a"] = fb_actions.create, + ["h"] = fb_actions.goto_parent_dir, + ["/"] = function() + vim.cmd("startinsert") + end, + ["d"] = fb_actions.remove, + ["e"] = fb_actions.change_cwd, + [""] = function(bufnr) + actions.select_vertical(bufnr) + end, + [""] = function(bufnr) + actions.toggle_all(bufnr) + end, + [""] = function(bufnr) + actions.move_selection_next(bufnr) + end, + [""] = function(bufnr) + actions.move_selection_previous(bufnr) + end, + }, + }, + }, }, - }, - }, - }, - }) + }) - pcall(telescope.load_extension, "file_browser") - pcall(telescope.load_extension, "fzf") - pcall(telescope.load_extension, "ui-select") + pcall(telescope.load_extension, "file_browser") + pcall(telescope.load_extension, "fzf") + pcall(telescope.load_extension, "ui-select") - -- Builtin pickers - vim.keymap.set("n", "sf", function() - local fd_cmd = get_fd_command() - local config = { - hidden = true, - file_ignore_patterns = { - "node%_modules/.*", - "%.git/.*", - }, - } + -- Builtin pickers + vim.keymap.set("n", "sf", function() + local fd_cmd = get_fd_command() + local config = { + hidden = true, + file_ignore_patterns = { + "node%_modules/.*", + "%.git/.*", + }, + } - if fd_cmd then - config.find_command = { - fd_cmd, - "--type", - "f", - "--color", - "never", - "--hidden", - "--no-ignore", - } - end + if fd_cmd then + config.find_command = { + fd_cmd, + "--type", + "f", + "--color", + "never", + "--hidden", + "--no-ignore", + } + end - builtin.find_files(config) - end, { desc = "[S]earch [F]iles" }) - vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[S]earch [H]elp Tags" }) - vim.keymap.set("n", "sb", builtin.buffers, { desc = "[S]earch [B]uffers" }) - vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch current [W]ord" }) - vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) - vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) - vim.keymap.set("n", "gr", builtin.lsp_references, { desc = "[G]o to [R]eferences", noremap = true }) - vim.keymap.set("n", "gd", builtin.lsp_definitions, { desc = "[G]o to [D]efinitions" }) - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "[G]o to [D]eclaration" }) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "[R]e[N]ame" }) + builtin.find_files(config) + end, { desc = "[S]earch [F]iles" }) + vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[S]earch [H]elp Tags" }) + vim.keymap.set("n", "sb", builtin.buffers, { desc = "[S]earch [B]uffers" }) + vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch current [W]ord" }) + vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) + vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) + vim.keymap.set("n", "gr", builtin.lsp_references, { desc = "[G]o to [R]eferences", noremap = true }) + vim.keymap.set("n", "gd", builtin.lsp_definitions, { desc = "[G]o to [D]efinitions" }) + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "[G]o to [D]eclaration" }) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "[R]e[N]ame" }) - -- Git pickers - vim.keymap.set("n", "gf", builtin.git_files, { desc = "Search [G]it [F]iles" }) - vim.keymap.set("n", "gs", builtin.git_status, { desc = "List [G]it [S]tatus" }) - vim.keymap.set("n", "gh", builtin.git_stash, { desc = "List [G]it [S]tash" }) - vim.keymap.set("n", "gbb", builtin.git_branches, { desc = "List [G]it [B]ranches" }) - vim.keymap.set("n", "gc", builtin.git_bcommits, { desc = "List Buffer [G]it [C]ommits" }) + -- Git pickers + vim.keymap.set("n", "gf", builtin.git_files, { desc = "Search [G]it [F]iles" }) + vim.keymap.set("n", "gs", builtin.git_status, { desc = "List [G]it [S]tatus" }) + vim.keymap.set("n", "gh", builtin.git_stash, { desc = "List [G]it [S]tash" }) + vim.keymap.set("n", "gbb", builtin.git_branches, { desc = "List [G]it [B]ranches" }) + vim.keymap.set("n", "gc", builtin.git_bcommits, { desc = "List Buffer [G]it [C]ommits" }) - -- File Browser Ext - vim.keymap.set("n", "fs", function() - telescope.extensions.file_browser.file_browser({ - path = "%:p:h", - cwd = telescope_buffer_dir(), - respect_gitignore = false, - hidden = true, - grouped = true, - previewer = false, - initial_mode = "normal", - layout_config = { height = 40 }, - }) - end, { desc = "Open [F]ile [S]ystem Menu" }) + -- File Browser Ext + vim.keymap.set("n", "fs", function() + telescope.extensions.file_browser.file_browser({ + path = "%:p:h", + cwd = telescope_buffer_dir(), + respect_gitignore = false, + hidden = true, + grouped = true, + previewer = false, + initial_mode = "normal", + layout_config = { height = 40 }, + }) + end, { desc = "Open [F]ile [S]ystem Menu" }) - vim.keymap.set("n", "/", function() - builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ - winblend = 10, - previewer = false, - })) - end, { desc = "[/] Fuzzily serach in current buffer" }) + vim.keymap.set("n", "/", function() + builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ + winblend = 10, + previewer = false, + })) + end, { desc = "[/] Fuzzily serach in current buffer" }) - -- live grep in open files only - vim.keymap.set("n", "s/", function() - builtin.live_grep({ - grep_open_files = true, - prompt_title = "Live Grep in Open Files", - }) - end, { desc = "[S]search [/] in Open Files" }) + -- live grep in open files only + vim.keymap.set("n", "s/", function() + builtin.live_grep({ + grep_open_files = true, + prompt_title = "Live Grep in Open Files", + }) + end, { desc = "[S]search [/] in Open Files" }) - -- shortcut for searching neovim config files - vim.keymap.set("n", "sn", function() - builtin.find_files({ cwd = vim.fn.stdpath("config") }) - end, { desc = "[S]earch [N]eovim files" }) - end, + -- shortcut for searching neovim config files + vim.keymap.set("n", "sn", function() + builtin.find_files({ cwd = vim.fn.stdpath("config") }) + end, { desc = "[S]earch [N]eovim files" }) + end, } diff --git a/nvim/lua/juancwu/plugins/todo-comments.lua b/nvim/lua/juancwu/plugins/todo-comments.lua index c88cb75..2ca05d6 100644 --- a/nvim/lua/juancwu/plugins/todo-comments.lua +++ b/nvim/lua/juancwu/plugins/todo-comments.lua @@ -1,5 +1,5 @@ return { - "folke/todo-comments.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - opts = {}, + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = {}, } diff --git a/nvim/lua/juancwu/plugins/toggleterm.lua b/nvim/lua/juancwu/plugins/toggleterm.lua index e163b22..de18893 100644 --- a/nvim/lua/juancwu/plugins/toggleterm.lua +++ b/nvim/lua/juancwu/plugins/toggleterm.lua @@ -1,51 +1,51 @@ return { - "akinsho/toggleterm.nvim", - version = "*", - keys = { - { - "lg", - function() - local Terminal = require("toggleterm.terminal").Terminal - local lazygit = Terminal:new({ - cmd = "lazygit", - direction = "float", - float_opts = { - border = "double", - }, - on_open = function(term) - vim.cmd("startinsert!") - end, - on_close = function(term) - vim.cmd("startinsert!") - end, - }) - lazygit:toggle() - end, - desc = "Open lazygit in a floating window", + "akinsho/toggleterm.nvim", + version = "*", + keys = { + { + "lg", + function() + local Terminal = require("toggleterm.terminal").Terminal + local lazygit = Terminal:new({ + cmd = "lazygit", + direction = "float", + float_opts = { + border = "double", + }, + on_open = function(term) + vim.cmd("startinsert!") + end, + on_close = function(term) + vim.cmd("startinsert!") + end, + }) + lazygit:toggle() + end, + desc = "Open lazygit in a floating window", + }, }, - }, - opts = { - size = 20, - open_mapping = [[]], - hide_numbers = true, - shade_filetypes = {}, - shade_terminals = true, - shading_factor = 2, - start_in_insert = true, - insert_mappings = true, - terminal_mappings = true, - persist_size = true, - persist_mode = true, - direction = "float", - close_on_exit = true, - shell = vim.o.shell, - float_opts = { - border = "curved", - winblend = 0, - highlights = { - border = "Normal", - background = "Normal", - }, + opts = { + size = 20, + open_mapping = [[]], + hide_numbers = true, + shade_filetypes = {}, + shade_terminals = true, + shading_factor = 2, + start_in_insert = true, + insert_mappings = true, + terminal_mappings = true, + persist_size = true, + persist_mode = true, + direction = "float", + close_on_exit = true, + shell = vim.o.shell, + float_opts = { + border = "curved", + winblend = 0, + highlights = { + border = "Normal", + background = "Normal", + }, + }, }, - }, } diff --git a/nvim/lua/juancwu/plugins/treesitter.lua b/nvim/lua/juancwu/plugins/treesitter.lua index 516c653..fe4a0d8 100644 --- a/nvim/lua/juancwu/plugins/treesitter.lua +++ b/nvim/lua/juancwu/plugins/treesitter.lua @@ -1,100 +1,100 @@ return { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - event = { - "BufReadPost", - "BufNewFile", - }, - branch = "master", - dependencies = { - "nvim-treesitter/nvim-treesitter-textobjects", - }, - config = function() - local treesitter = require("nvim-treesitter.configs") + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = { + "BufReadPost", + "BufNewFile", + }, + branch = "master", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, + config = function() + local treesitter = require("nvim-treesitter.configs") - treesitter.setup({ - -- A list of parser names, or "all" - ensure_installed = { - "vimdoc", - "javascript", - "typescript", - "c", - "lua", - "rust", - "go", - "gosum", - "gomod", - "php", - "blade", - }, - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, - -- Automatically install missing parsers when entering buffer - auto_install = true, - indent = { - enable = true, - }, - highlight = { - enable = true, - additional_vim_regex_highlighting = true, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "c", - node_incremental = "", - scope_incremental = "", - node_decremental = "", - }, - }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["aa"] = "@parameter.outer", - ["ia"] = "@parameter.inner", - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - }, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - ["]m"] = "@function.outer", - ["]]"] = "@class.outer", - }, - goto_next_end = { - ["]M"] = "@function.outer", - ["]["] = "@class.outer", - }, - goto_previous_start = { - ["[m"] = "@function.outer", - ["[["] = "@class.outer", - }, - goto_previous_end = { - ["[M"] = "@function.outer", - ["[]"] = "@class.outer", - }, - }, - swap = { - enable = true, - swap_next = { - ["]"] = "@parameter.inner", - }, - swap_previous = { - ["["] = "@parameter.inner", - }, - }, - }, - autotag = { - enable = false, - enable_close_on_slash = false, - }, - }) - end, + treesitter.setup({ + -- A list of parser names, or "all" + ensure_installed = { + "vimdoc", + "javascript", + "typescript", + "c", + "lua", + "rust", + "go", + "gosum", + "gomod", + "php", + "blade", + }, + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + -- Automatically install missing parsers when entering buffer + auto_install = true, + indent = { + enable = true, + }, + highlight = { + enable = true, + additional_vim_regex_highlighting = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "c", + node_incremental = "", + scope_incremental = "", + node_decremental = "", + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["aa"] = "@parameter.outer", + ["ia"] = "@parameter.inner", + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + ["]m"] = "@function.outer", + ["]]"] = "@class.outer", + }, + goto_next_end = { + ["]M"] = "@function.outer", + ["]["] = "@class.outer", + }, + goto_previous_start = { + ["[m"] = "@function.outer", + ["[["] = "@class.outer", + }, + goto_previous_end = { + ["[M"] = "@function.outer", + ["[]"] = "@class.outer", + }, + }, + swap = { + enable = true, + swap_next = { + ["]"] = "@parameter.inner", + }, + swap_previous = { + ["["] = "@parameter.inner", + }, + }, + }, + autotag = { + enable = false, + enable_close_on_slash = false, + }, + }) + end, } diff --git a/nvim/lua/juancwu/plugins/undotree.lua b/nvim/lua/juancwu/plugins/undotree.lua index 31a2fe6..af98b92 100644 --- a/nvim/lua/juancwu/plugins/undotree.lua +++ b/nvim/lua/juancwu/plugins/undotree.lua @@ -1,22 +1,22 @@ return { - "mbbill/undotree", - keys = { - { "u", "UndotreeToggle", desc = "Toggle Undotree" }, - }, - config = function() - local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" }) + "mbbill/undotree", + keys = { + { "u", "UndotreeToggle", desc = "Toggle Undotree" }, + }, + config = function() + local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" }) - if has_persistent_undo then - local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" }) + if has_persistent_undo then + local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" }) - local is_directory = vim.api.nvim_call_function("isdirectory", { target_path }) + local is_directory = vim.api.nvim_call_function("isdirectory", { target_path }) - if not is_directory then - vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 }) - end + if not is_directory then + vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 }) + end - vim.opt.undodir = target_path - vim.opt.undofile = true - end - end, + vim.opt.undodir = target_path + vim.opt.undofile = true + end + end, } diff --git a/nvim/lua/juancwu/plugins/which-key.lua b/nvim/lua/juancwu/plugins/which-key.lua index ed7fb7a..d9b3f6f 100644 --- a/nvim/lua/juancwu/plugins/which-key.lua +++ b/nvim/lua/juancwu/plugins/which-key.lua @@ -1,49 +1,49 @@ return { - { - "folke/which-key.nvim", - event = "VeryLazy", - config = function() - vim.opt.timeout = true - vim.opt.timeoutlen = 300 + { + "folke/which-key.nvim", + event = "VeryLazy", + config = function() + vim.opt.timeout = true + vim.opt.timeoutlen = 300 - local wk = require("which-key") + local wk = require("which-key") - wk.setup({ - delay = 0, - icons = { - mappings = vim.g.have_nerd_font, - keys = vim.g.have_nerd_font and {} or { - Up = " ", - Down = " ", - Left = " ", - Right = " ", - C = " ", - M = " ", - D = " ", - S = " ", - CR = " ", - Esc = " ", - ScrollWheelDown = " ", - ScrollWheelUp = " ", - NL = " ", - BS = " ", - Space = " ", - Tab = " ", - F1 = "", - F2 = "", - F3 = "", - F4 = "", - F5 = "", - F6 = "", - F7 = "", - F8 = "", - F9 = "", - F10 = "", - F11 = "", - F12 = "", - }, - }, - }) - end, - }, + wk.setup({ + delay = 0, + icons = { + mappings = vim.g.have_nerd_font, + keys = vim.g.have_nerd_font and {} or { + Up = " ", + Down = " ", + Left = " ", + Right = " ", + C = " ", + M = " ", + D = " ", + S = " ", + CR = " ", + Esc = " ", + ScrollWheelDown = " ", + ScrollWheelUp = " ", + NL = " ", + BS = " ", + Space = " ", + Tab = " ", + F1 = "", + F2 = "", + F3 = "", + F4 = "", + F5 = "", + F6 = "", + F7 = "", + F8 = "", + F9 = "", + F10 = "", + F11 = "", + F12 = "", + }, + }, + }) + end, + }, } diff --git a/nvim/lua/juancwu/utils/colors.lua b/nvim/lua/juancwu/utils/colors.lua deleted file mode 100644 index de0d5d4..0000000 --- a/nvim/lua/juancwu/utils/colors.lua +++ /dev/null @@ -1,37 +0,0 @@ ----@class juancwu.utils.colors -local M = {} -local light = "catppuccin-latte" -local dark = "catppuccin-mocha" - ----@return boolean -function M.is_daytime() - return false -end - ----@return boolean -function M.legacy_is_daytime() - return false -end - ----@return string -function M.get_timebased_colorscheme() - if M.is_daytime() then - vim.g.is_light_colors = true - return light - else - vim.g.is_light_colors = false - return dark - end -end - -function M.toggle_colors() - if vim.g.is_light_colors then - vim.g.is_light_colors = false - vim.cmd.colorscheme(dark) - else - vim.g.is_light_colors = true - vim.cmd.colorscheme(light) - end -end - -return M diff --git a/nvim/lua/juancwu/utils/init.lua b/nvim/lua/juancwu/utils/init.lua index d89c668..84aba78 100644 --- a/nvim/lua/juancwu/utils/init.lua +++ b/nvim/lua/juancwu/utils/init.lua @@ -1,11 +1,10 @@ ---@class Utils ---@field os juancwu.utils.os ----@field colors juancwu.utils.colors local M = setmetatable({}, { - __index = function(t, k) - t[k] = require("juancwu.utils." .. k) - return t[k] - end, + __index = function(t, k) + t[k] = require("juancwu.utils." .. k) + return t[k] + end, }) return M diff --git a/nvim/lua/juancwu/utils/os.lua b/nvim/lua/juancwu/utils/os.lua index 48306d5..3bfe13c 100644 --- a/nvim/lua/juancwu/utils/os.lua +++ b/nvim/lua/juancwu/utils/os.lua @@ -3,35 +3,35 @@ local M = {} ---@return boolean function M.is_linux() - return vim.loop.os_uname().sysname:find("Linux") ~= nil + return vim.loop.os_uname().sysname:find("Linux") ~= nil end ---@return boolean function M.is_mac() - return vim.loop.os_uname().sysname:find("Darwin") ~= nil + return vim.loop.os_uname().sysname:find("Darwin") ~= nil end ---@return boolean function M.is_win() - return vim.loop.os_uname().sysname:find("Windows") ~= nil + return vim.loop.os_uname().sysname:find("Windows") ~= nil end ---@return boolean function M.is_wsl() - return vim.fn.has("wsl") == 1 + return vim.fn.has("wsl") == 1 end ---@param cmd string ---@return boolean function M.cmd_exists(cmd) - local handle = io.popen("command -v " .. cmd) - if handle ~= nil then - local result = handle:read("*a") - handle:close() - return #result > 0 - else - return false - end + local handle = io.popen("command -v " .. cmd) + if handle ~= nil then + local result = handle:read("*a") + handle:close() + return #result > 0 + else + return false + end end return M diff --git a/nvim/stylua.toml b/nvim/stylua.toml index 5d6c50d..e55efd5 100644 --- a/nvim/stylua.toml +++ b/nvim/stylua.toml @@ -1,3 +1,3 @@ indent_type = "Spaces" -indent_width = 2 -column_width = 120 \ No newline at end of file +indent_width = 4 +column_width = 120 From ae2d33f63d6515089b4e764c1b763dc4ab49d388 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Fri, 5 Sep 2025 14:59:41 -0400 Subject: [PATCH 3/7] (nvim) updating auto complete --- nvim/lua/juancwu/plugins/autocomplete.lua | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/nvim/lua/juancwu/plugins/autocomplete.lua b/nvim/lua/juancwu/plugins/autocomplete.lua index 27981ca..0512557 100644 --- a/nvim/lua/juancwu/plugins/autocomplete.lua +++ b/nvim/lua/juancwu/plugins/autocomplete.lua @@ -97,30 +97,21 @@ return { "saghen/blink.cmp", -- optional: provides snippets for the snippet source dependencies = { "rafamadriz/friendly-snippets" }, - - -- use a release tag to download pre-built binaries version = "1.*", - -- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust - -- build = 'cargo build --release', - -- If you use nix, you can build from source using latest nightly rust with: - -- build = 'nix run .#build-plugin', ---@module 'blink.cmp' ---@type blink.cmp.Config opts = { - -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) - -- 'super-tab' for mappings similar to vscode (tab to accept) - -- 'enter' for enter to accept - -- 'none' for no mappings - -- - -- All presets have the following mappings: -- C-space: Open menu or open docs if already open -- C-n/C-p or Up/Down: Select next/previous item -- C-e: Hide menu -- C-k: Toggle signature help (if signature.enabled = true) -- -- See :h blink-cmp-config-keymap for defining your own keymap - keymap = { preset = "default" }, + keymap = { preset = "enter" }, + signature = { + enabled = true, + }, appearance = { -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' From 6c4fbccef87aba5e89bb56143a9bead49f0eeb02 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Mon, 22 Sep 2025 09:05:19 -0400 Subject: [PATCH 4/7] (nvim) do not copy on x,d --- nvim/lua/juancwu/config/keymaps.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nvim/lua/juancwu/config/keymaps.lua b/nvim/lua/juancwu/config/keymaps.lua index a3502a9..6a88c45 100644 --- a/nvim/lua/juancwu/config/keymaps.lua +++ b/nvim/lua/juancwu/config/keymaps.lua @@ -25,12 +25,12 @@ vim.keymap.set("n", "N", "Nzzzv") vim.keymap.set("n", "ss", [[:%s/\<\>//gI]]) -- do not copy with x, for god sake, WHY copy something that is being deleted?? -vim.keymap.set("n", "x", '"xx') +vim.keymap.set("n", "x", '"_x') -- no copy, delete line, for god sake... -vim.keymap.set("n", "dd", '"ddd') +vim.keymap.set("n", "dd", '"_dd') vim.keymap.set("n", "dx", "dd") -- cut line, under my control -vim.keymap.set("v", "d", '"dd') +vim.keymap.set("v", "d", '"_d') -- copy/paste to/from system clipboard vim.keymap.set({ "n", "v" }, "y", '"+y') From 2f564de51d4a566b34e3d153e734c71b8ea06bf4 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Mon, 22 Sep 2025 09:05:42 -0400 Subject: [PATCH 5/7] (nvim) enable templ formatter and biome for php --- nvim/lua/juancwu/plugins/conform.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nvim/lua/juancwu/plugins/conform.lua b/nvim/lua/juancwu/plugins/conform.lua index 7354f85..48ce9e3 100644 --- a/nvim/lua/juancwu/plugins/conform.lua +++ b/nvim/lua/juancwu/plugins/conform.lua @@ -14,6 +14,8 @@ local formatters_by_ft = { yml = { "yamlfmt" }, zig = { "zigfmt" }, rust = { "rustfmt" }, + templ = { "templ" }, + php = { "biome" }, } return { From 9a823fa2b4b4106012797af9497248b76ef1f9d4 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Mon, 27 Oct 2025 09:49:11 -0400 Subject: [PATCH 6/7] (nvim) add blade template file formatter --- nvim/lazy-lock.json | 30 +++++++++++++++------------- nvim/lua/juancwu/plugins/conform.lua | 12 ++++++++++- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 6568486..85d4194 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -1,36 +1,38 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "blink.cmp": { "branch": "main", "commit": "bae4bae0eedd1fa55f34b685862e94a222d5c6f8" }, - "catppuccin": { "branch": "main", "commit": "30fa4d122d9b22ad8b2e0ab1b533c8c26c4dde86" }, + "LuaSnip": { "branch": "master", "commit": "b3104910bb5ebf40492aadffae18f2528fa757d9" }, + "catppuccin": { "branch": "main", "commit": "f19cab18ec4dc86d415512c7a572863b2adbcc18" }, "cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" }, + "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "conform.nvim": { "branch": "master", "commit": "b4aab989db276993ea5dcb78872be494ce546521" }, - "fidget.nvim": { "branch": "main", "commit": "4d5858bd4c471c895060e1b9f3575f1551184dc5" }, + "fidget.nvim": { "branch": "main", "commit": "3f5475949679953af6d78654db29b944fa826e6a" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "6e3c66548035e50db7bd8e360a29aec6620c3641" }, + "gitsigns.nvim": { "branch": "main", "commit": "f780609807eca1f783a36a8a31c30a48fbe150c5" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "kanagawa.nvim": { "branch": "master", "commit": "debe91547d7fb1eef34ce26a5106f277fbfdd109" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, + "lazydev.nvim": { "branch": "main", "commit": "258d2a5ef4a3e3d6d9ba9da72c9725c53e9afcbd" }, "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, - "luvit-meta": { "branch": "main", "commit": "1df30b60b1b4aecfebc785aa98943db6c6989716" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "5e085efe67fccb13372d54331d849219662a7e93" }, + "luvit-meta": { "branch": "main", "commit": "0ea4ff636c5bb559ffa78108561d0976f4de9682" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "a1067cf84b4ff81b66d2bf4d01f4cbdb5de40bd0" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "517ef5994ef9d6b738322664d5fdd948f0fdeb46" }, "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, "mini.icons": { "branch": "main", "commit": "f9a177c11daa7829389b7b6eaaec8b8a5c47052d" }, - "mini.nvim": { "branch": "main", "commit": "e7538b549361c9ac8416a07b0223ce03c508bfe7" }, + "mini.nvim": { "branch": "main", "commit": "256d35c9e24c9cf5f5da568e121e988c6ceb1e3f" }, "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, - "nvim-lint": { "branch": "master", "commit": "f126af5345c7472e9a0cdbe1d1a29209be72c4c4" }, - "nvim-lspconfig": { "branch": "master", "commit": "3e89e4973d784e1c966517e528b3a30395403fa7" }, + "nvim-lint": { "branch": "master", "commit": "335a6044be16d7701001059cba9baa36fbeef422" }, + "nvim-lspconfig": { "branch": "master", "commit": "b3cce1419ca67871ae782b3e529652f8a016f0de" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "71385f191ec06ffc60e80e6b0c9a9d5daed4824c" }, - "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, + "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-web-devicons": { "branch": "master", "commit": "6e51ca170563330e063720449c21f43e27ca0bc1" }, "oil.nvim": { "branch": "master", "commit": "07f80ad645895af849a597d1cac897059d89b686" }, "onedark.nvim": { "branch": "master", "commit": "de495fabe171d48aed5525f002d14414efcecbb2" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, - "render-markdown.nvim": { "branch": "main", "commit": "e76eb2e4262f0f0a1a7bd7a454dd7d44f1299afd" }, + "render-markdown.nvim": { "branch": "main", "commit": "9ab9dade85d8c7d411cc89b592028da3d1b7955a" }, "rose-pine": { "branch": "main", "commit": "72a04c4065345b51b56aed4859ea1d884f734097" }, "solarized-osaka.nvim": { "branch": "main", "commit": "f796014c14b1910e08d42cc2077fef34f08e0295" }, "telescope-file-browser.nvim": { "branch": "master", "commit": "3610dc7dc91f06aa98b11dca5cc30dfa98626b7e" }, @@ -39,8 +41,8 @@ "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, - "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, + "tokyonight.nvim": { "branch": "main", "commit": "14fd5ff7f84027064724ec3157fe903199e77ded" }, "undotree": { "branch": "master", "commit": "fe9a9d0645f0f5532360b5e5f5c550d7bb4f1869" }, "vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }, - "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } + "which-key.nvim": { "branch": "main", "commit": "904308e6885bbb7b60714c80ab3daf0c071c1492" } } diff --git a/nvim/lua/juancwu/plugins/conform.lua b/nvim/lua/juancwu/plugins/conform.lua index 48ce9e3..4d398eb 100644 --- a/nvim/lua/juancwu/plugins/conform.lua +++ b/nvim/lua/juancwu/plugins/conform.lua @@ -16,6 +16,7 @@ local formatters_by_ft = { rust = { "rustfmt" }, templ = { "templ" }, php = { "biome" }, + blade = { "blade-formatter" }, } return { @@ -36,12 +37,21 @@ return { require("conform").setup({ notify_on_error = false, formatters_by_ft = formatters_by_ft, + formatters = { + ["blade-formatter"] = { + command = "blade-formatter", + args = { + "--write", + "--stdin", + }, + }, + }, format_on_save = function(bufnr) if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then return end return { - timeout_ms = 500, + timeout_ms = 2500, lsp_format = "fallback", } end, From d1c08ddf5fc1e9d974e7c9f3448ed9ee6604e2e0 Mon Sep 17 00:00:00 2001 From: juancwu <46619361+juancwu@users.noreply.github.com> Date: Mon, 27 Oct 2025 09:49:26 -0400 Subject: [PATCH 7/7] add alias for nvim --- zsh/.zshrc | 1 + 1 file changed, 1 insertion(+) diff --git a/zsh/.zshrc b/zsh/.zshrc index fdb6107..69e99dc 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -6,6 +6,7 @@ alias ll="lsd -alF" alias la="lsd -A" alias l="lsd -CF" alias lg="lazygit" +alias vim="nvim" # Nice line headers for logs ERROR=$'\033[39;41mERROR:\033[0m'