From f5c36908f3352f4326025b73e3c41ebef66bf760 Mon Sep 17 00:00:00 2001 From: juancwu Date: Sun, 12 Apr 2026 20:00:06 -0400 Subject: [PATCH] (nvim) make copy of v0.11 neovim config --- nvim-0.11/.gitignore | 0 nvim-0.11/after/ftplugin/blade.lua | 1 + nvim-0.11/after/ftplugin/go.lua | 2 + nvim-0.11/after/ftplugin/markdown.lua | 7 + nvim-0.11/init.lua | 18 ++ nvim-0.11/lazy-lock.json | 45 ++++ nvim-0.11/lua/.luarc.json | 80 +++++++ nvim-0.11/lua/juancwu/config/clipboard.lua | 73 ++++++ nvim-0.11/lua/juancwu/config/init.lua | 73 ++++++ nvim-0.11/lua/juancwu/config/keymaps.lua | 67 ++++++ nvim-0.11/lua/juancwu/config/options.lua | 61 +++++ nvim-0.11/lua/juancwu/init.lua | 8 + .../lua/juancwu/plugins/autocomplete.lua | 139 ++++++++++++ nvim-0.11/lua/juancwu/plugins/autopairs.lua | 11 + nvim-0.11/lua/juancwu/plugins/autotag.lua | 31 +++ nvim-0.11/lua/juancwu/plugins/colorscheme.lua | 48 ++++ nvim-0.11/lua/juancwu/plugins/comment.lua | 38 ++++ nvim-0.11/lua/juancwu/plugins/conform.lua | 77 +++++++ nvim-0.11/lua/juancwu/plugins/fugitive.lua | 23 ++ nvim-0.11/lua/juancwu/plugins/gitsigns.lua | 19 ++ nvim-0.11/lua/juancwu/plugins/lazydev.lua | 9 + nvim-0.11/lua/juancwu/plugins/lsp.lua | 214 ++++++++++++++++++ nvim-0.11/lua/juancwu/plugins/lualine.lua | 62 +++++ nvim-0.11/lua/juancwu/plugins/luvit-meta.lua | 4 + .../lua/juancwu/plugins/mini.indentscope.lua | 30 +++ nvim-0.11/lua/juancwu/plugins/neo-tree.lua | 71 ++++++ nvim-0.11/lua/juancwu/plugins/nvim-lint.lua | 84 +++++++ nvim-0.11/lua/juancwu/plugins/oil.lua | 28 +++ .../lua/juancwu/plugins/render-markdown.lua | 9 + nvim-0.11/lua/juancwu/plugins/telescope.lua | 187 +++++++++++++++ .../lua/juancwu/plugins/todo-comments.lua | 5 + nvim-0.11/lua/juancwu/plugins/toggleterm.lua | 51 +++++ nvim-0.11/lua/juancwu/plugins/treesitter.lua | 100 ++++++++ nvim-0.11/lua/juancwu/plugins/undotree.lua | 22 ++ nvim-0.11/lua/juancwu/plugins/which-key.lua | 49 ++++ nvim-0.11/lua/juancwu/utils/init.lua | 10 + nvim-0.11/lua/juancwu/utils/os.lua | 37 +++ nvim-0.11/stylua.toml | 3 + 38 files changed, 1796 insertions(+) create mode 100644 nvim-0.11/.gitignore create mode 100644 nvim-0.11/after/ftplugin/blade.lua create mode 100644 nvim-0.11/after/ftplugin/go.lua create mode 100644 nvim-0.11/after/ftplugin/markdown.lua create mode 100644 nvim-0.11/init.lua create mode 100644 nvim-0.11/lazy-lock.json create mode 100644 nvim-0.11/lua/.luarc.json create mode 100644 nvim-0.11/lua/juancwu/config/clipboard.lua create mode 100644 nvim-0.11/lua/juancwu/config/init.lua create mode 100644 nvim-0.11/lua/juancwu/config/keymaps.lua create mode 100644 nvim-0.11/lua/juancwu/config/options.lua create mode 100644 nvim-0.11/lua/juancwu/init.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/autocomplete.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/autopairs.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/autotag.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/colorscheme.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/comment.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/conform.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/fugitive.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/gitsigns.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/lazydev.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/lsp.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/lualine.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/luvit-meta.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/mini.indentscope.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/neo-tree.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/nvim-lint.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/oil.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/render-markdown.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/telescope.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/todo-comments.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/toggleterm.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/treesitter.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/undotree.lua create mode 100644 nvim-0.11/lua/juancwu/plugins/which-key.lua create mode 100644 nvim-0.11/lua/juancwu/utils/init.lua create mode 100644 nvim-0.11/lua/juancwu/utils/os.lua create mode 100644 nvim-0.11/stylua.toml diff --git a/nvim-0.11/.gitignore b/nvim-0.11/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/nvim-0.11/after/ftplugin/blade.lua b/nvim-0.11/after/ftplugin/blade.lua new file mode 100644 index 0000000..ee233b9 --- /dev/null +++ b/nvim-0.11/after/ftplugin/blade.lua @@ -0,0 +1 @@ +vim.opt_local.commentstring = "{{-- %s --}}" diff --git a/nvim-0.11/after/ftplugin/go.lua b/nvim-0.11/after/ftplugin/go.lua new file mode 100644 index 0000000..c43d5ad --- /dev/null +++ b/nvim-0.11/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-0.11/after/ftplugin/markdown.lua b/nvim-0.11/after/ftplugin/markdown.lua new file mode 100644 index 0000000..373bf14 --- /dev/null +++ b/nvim-0.11/after/ftplugin/markdown.lua @@ -0,0 +1,7 @@ +local map = vim.keymap.set + +map("v", "ln", "ObsidianLinkNew") +map("n", "", "ObsidianNew") +map("n", "of", "ObsidianSearch") +map("n", "ll", "ObsidianLinks") +map("n", "", "ObsidianFollowLink") diff --git a/nvim-0.11/init.lua b/nvim-0.11/init.lua new file mode 100644 index 0000000..217fc6e --- /dev/null +++ b/nvim-0.11/init.lua @@ -0,0 +1,18 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +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) + +require("juancwu.config").setup({}) diff --git a/nvim-0.11/lazy-lock.json b/nvim-0.11/lazy-lock.json new file mode 100644 index 0000000..73cba48 --- /dev/null +++ b/nvim-0.11/lazy-lock.json @@ -0,0 +1,45 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "blink.cmp": { "branch": "main", "commit": "327fff91fe6af358e990be7be1ec8b78037d2138" }, + "catppuccin": { "branch": "main", "commit": "f19cab18ec4dc86d415512c7a572863b2adbcc18" }, + "conform.nvim": { "branch": "master", "commit": "b4aab989db276993ea5dcb78872be494ce546521" }, + "fidget.nvim": { "branch": "main", "commit": "3f5475949679953af6d78654db29b944fa826e6a" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "gitsigns.nvim": { "branch": "main", "commit": "f780609807eca1f783a36a8a31c30a48fbe150c5" }, + "kanagawa.nvim": { "branch": "master", "commit": "debe91547d7fb1eef34ce26a5106f277fbfdd109" }, + "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, + "lazydev.nvim": { "branch": "main", "commit": "258d2a5ef4a3e3d6d9ba9da72c9725c53e9afcbd" }, + "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, + "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.indentscope": { "branch": "main", "commit": "e9fa0714fc753e1e737940577904e553ee340903" }, + "mini.nvim": { "branch": "main", "commit": "256d35c9e24c9cf5f5da568e121e988c6ceb1e3f" }, + "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, + "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, + "nvim-lint": { "branch": "master", "commit": "0864f81c681e15d9bdc1156fe3a17bd07db5a3ed" }, + "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": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "6141a40173c6efa98242dc951ed4b6f892c97027" }, + "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": "9ab9dade85d8c7d411cc89b592028da3d1b7955a" }, + "rose-pine": { "branch": "main", "commit": "72a04c4065345b51b56aed4859ea1d884f734097" }, + "solarized-osaka.nvim": { "branch": "main", "commit": "f796014c14b1910e08d42cc2077fef34f08e0295" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "3610dc7dc91f06aa98b11dca5cc30dfa98626b7e" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, + "toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, + "tokyonight.nvim": { "branch": "main", "commit": "14fd5ff7f84027064724ec3157fe903199e77ded" }, + "undotree": { "branch": "master", "commit": "fe9a9d0645f0f5532360b5e5f5c550d7bb4f1869" }, + "vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }, + "which-key.nvim": { "branch": "main", "commit": "904308e6885bbb7b60714c80ab3daf0c071c1492" } +} diff --git a/nvim-0.11/lua/.luarc.json b/nvim-0.11/lua/.luarc.json new file mode 100644 index 0000000..97a8b9c --- /dev/null +++ b/nvim-0.11/lua/.luarc.json @@ -0,0 +1,80 @@ +{ + "workspace.library": [ + "/home/jc/.local/share/nvim/lazy/neodev.nvim/types/stable", + "/home/jc/Applications/nvim-linux64/share/nvim/runtime/lua", + "/home/jc/.local/share/nvim/lazy/neodev.nvim/lua", + "/home/jc/.local/share/nvim/lazy/telescope.nvim/lua", + "/home/jc/.local/share/nvim/lazy/telescope-fzf-native.nvim/lua", + "/home/jc/.local/share/nvim/lazy/which-key.nvim/lua", + "/home/jc/.local/share/nvim/lazy/gitsigns.nvim/lua", + "/home/jc/.local/share/nvim/lazy/lsp-zero.nvim/lua", + "/home/jc/.local/share/nvim/lazy/nvim-dap-ui/lua", + "/home/jc/.local/share/nvim/lazy/todo-comments.nvim/lua", + "/home/jc/.local/share/nvim/lazy/nvim-lspconfig/lua", + "/home/jc/.local/share/nvim/lazy/lazy.nvim/lua", + "/home/jc/.local/share/nvim/lazy/mason.nvim/lua", + "/home/jc/.local/share/nvim/lazy/fzf-lua/lua", + "/home/jc/.local/share/nvim/lazy/nvim-treesitter-textobjects/lua", + "/home/jc/.local/share/nvim/lazy/mason-lspconfig.nvim/lua", + "/home/jc/.local/share/nvim/lazy/telescope-dap.nvim/lua", + "/home/jc/.local/share/nvim/lazy/nvim-web-devicons/lua", + "/home/jc/.local/share/nvim/lazy/telescope-file-browser.nvim/lua", + "/home/jc/.local/share/nvim/lazy/nvim-cmp/lua", + "/home/jc/.local/share/nvim/lazy/lualine.nvim/lua", + "/home/jc/.local/share/nvim/lazy/nvim-treesitter/lua", + "/home/jc/.local/share/nvim/lazy/nvim-ts-autotag/lua", + "/home/jc/.local/share/nvim/lazy/nvim-ts-context-commentstring/lua", + "/home/jc/.local/share/nvim/lazy/git.nvim/lua", + "/home/jc/.local/share/nvim/lazy/nvim-autopairs/lua", + "/home/jc/.local/share/nvim/lazy/Comment.nvim/lua", + "/home/jc/.local/share/nvim/lazy/rose-pine/lua", + "/home/jc/.local/share/nvim/lazy/indent-blankline.nvim/lua", + "/home/jc/.local/share/nvim/lazy/harpoon/lua", + "/home/jc/.local/share/nvim/lazy/LuaSnip/lua", + "/home/jc/.local/share/nvim/lazy/nvim-dap/lua", + "/home/jc/.local/share/nvim/lazy/cmp-nvim-lsp/lua", + "/home/jc/.local/share/nvim/lazy/plenary.nvim/lua", + "/home/jc/.local/share/nvim/lazy/null-ls.nvim/lua", + "/home/jc/.local/share/nvim/lazy/neodev.nvim/types/stable", + "/home/jc/Applications/nvim-linux64/share/nvim/runtime/lua", + "/home/jc/.local/share/nvim/lazy/neodev.nvim/lua", + "/home/jc/.local/share/nvim/lazy/telescope.nvim/lua", + "/home/jc/.local/share/nvim/lazy/telescope-fzf-native.nvim/lua", + "/home/jc/.local/share/nvim/lazy/which-key.nvim/lua", + "/home/jc/.local/share/nvim/lazy/gitsigns.nvim/lua", + "/home/jc/.local/share/nvim/lazy/lsp-zero.nvim/lua", + "/home/jc/.local/share/nvim/lazy/nvim-dap-ui/lua", + "/home/jc/.local/share/nvim/lazy/todo-comments.nvim/lua", + "/home/jc/.local/share/nvim/lazy/nvim-lspconfig/lua", + "/home/jc/.local/share/nvim/lazy/lazy.nvim/lua", + "/home/jc/.local/share/nvim/lazy/mason.nvim/lua", + "/home/jc/.local/share/nvim/lazy/fzf-lua/lua", + "/home/jc/.local/share/nvim/lazy/nvim-treesitter-textobjects/lua", + "/home/jc/.local/share/nvim/lazy/mason-lspconfig.nvim/lua", + "/home/jc/.local/share/nvim/lazy/telescope-dap.nvim/lua", + "/home/jc/.local/share/nvim/lazy/nvim-web-devicons/lua", + "/home/jc/.local/share/nvim/lazy/telescope-file-browser.nvim/lua", + "/home/jc/.local/share/nvim/lazy/nvim-cmp/lua", + "/home/jc/.local/share/nvim/lazy/lualine.nvim/lua", + "/home/jc/.local/share/nvim/lazy/nvim-treesitter/lua", + "/home/jc/.local/share/nvim/lazy/nvim-ts-autotag/lua", + "/home/jc/.local/share/nvim/lazy/nvim-ts-context-commentstring/lua", + "/home/jc/.local/share/nvim/lazy/git.nvim/lua", + "/home/jc/.local/share/nvim/lazy/nvim-autopairs/lua", + "/home/jc/.local/share/nvim/lazy/Comment.nvim/lua", + "/home/jc/.local/share/nvim/lazy/rose-pine/lua", + "/home/jc/.local/share/nvim/lazy/indent-blankline.nvim/lua", + "/home/jc/.local/share/nvim/lazy/harpoon/lua", + "/home/jc/.local/share/nvim/lazy/LuaSnip/lua", + "/home/jc/.local/share/nvim/lazy/nvim-dap/lua", + "/home/jc/.local/share/nvim/lazy/cmp-nvim-lsp/lua", + "/home/jc/.local/share/nvim/lazy/plenary.nvim/lua", + "/home/jc/.local/share/nvim/lazy/null-ls.nvim/lua", + "/home/jc/ghq/juancwu/dotfiles/nvim/lua", + "/home/jc/ghq/juancwu/dotfiles/nvim/lua", + "${3rd}/luv/library" + ], + "diagnostics.globals": [ + "vim" + ] +} \ No newline at end of file diff --git a/nvim-0.11/lua/juancwu/config/clipboard.lua b/nvim-0.11/lua/juancwu/config/clipboard.lua new file mode 100644 index 0000000..4e11b15 --- /dev/null +++ b/nvim-0.11/lua/juancwu/config/clipboard.lua @@ -0,0 +1,73 @@ +local Utils = require("juancwu.utils") + +if Utils.os.is_linux() then + local wayland_display = os.getenv("WAYLAND_DISPLAY") + local ssh_tty = os.getenv("SSH_TTY") + 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 ssh_tty then + local clip_path = vim.fn.expand("~/.clipboard") + vim.g.clipboard = { + name = "file-clipboard", + copy = { + ["+"] = { "tee", clip_path }, + ["*"] = { "tee", clip_path }, + }, + paste = { + ["+"] = { "cat", clip_path }, + ["*"] = { "cat", clip_path }, + }, + cache_enabled = 1, + } + 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, + } +end diff --git a/nvim-0.11/lua/juancwu/config/init.lua b/nvim-0.11/lua/juancwu/config/init.lua new file mode 100644 index 0000000..7496e7b --- /dev/null +++ b/nvim-0.11/lua/juancwu/config/init.lua @@ -0,0 +1,73 @@ +---@class Config: ConfigOptions +local M = {} + +---@class ConfigOptions +local defaultOpts = { + ---@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) +end + +---@type ConfigOptions +local options + +---@param opts? ConfigOptions +function M.setup(opts) + options = vim.tbl_deep_extend("force", defaultOpts, opts or {}) or {} + + M.load("options") + M.load("keymaps") + M.load("clipboard") + + 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) + + -- 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 + + return options[k] + end, +}) + +return M diff --git a/nvim-0.11/lua/juancwu/config/keymaps.lua b/nvim-0.11/lua/juancwu/config/keymaps.lua new file mode 100644 index 0000000..6a88c45 --- /dev/null +++ b/nvim-0.11/lua/juancwu/config/keymaps.lua @@ -0,0 +1,67 @@ +-- easy escape +vim.keymap.set("i", "", "", { noremap = true, silent = true }) +vim.keymap.set("v", "", "", { noremap = true, silent = true }) +vim.keymap.set("n", "", "", { noremap = true, silent = true }) + +-- open the explorer +vim.keymap.set("n", "ex", "Ex") + +-- move highlighted lines +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +-- make cursor stay in same position when appending line below +vim.keymap.set("n", "J", "mzJ`z") + +-- make cursor stay in the middle while moving down/up the page +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") + +-- make cursor stay in the middle while looking through search results +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + +-- 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') + +-- no copy, delete line, for god sake... +vim.keymap.set("n", "dd", '"_dd') +vim.keymap.set("n", "dx", "dd") -- cut line, under my control +vim.keymap.set("v", "d", '"_d') + +-- copy/paste to/from system clipboard +vim.keymap.set({ "n", "v" }, "y", '"+y') +vim.keymap.set({ "n", "v" }, "p", '"+p') + +-- increment/decrement a count, helpful for changing indeces +vim.keymap.set("n", "+", "") +vim.keymap.set("n", "-", "") + +-- do not copy when deleting word +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 + +-- pane movement +vim.keymap.set("n", "..", "w") -- toggle +vim.keymap.set("n", "sh", "h") +vim.keymap.set("n", "sk", "k") +vim.keymap.set("n", "sl", "l") +vim.keymap.set("n", "sj", "j") + +-- resize pane +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 }) diff --git a/nvim-0.11/lua/juancwu/config/options.lua b/nvim-0.11/lua/juancwu/config/options.lua new file mode 100644 index 0000000..50f61e9 --- /dev/null +++ b/nvim-0.11/lua/juancwu/config/options.lua @@ -0,0 +1,61 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +vim.opt.number = true -- show line number +vim.opt.relativenumber = true -- juicy relativity + +vim.opt.autoindent = true +vim.opt.smartindent = true +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.smarttab = true +vim.opt.breakindent = true + +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.updatetime = 50 + +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__/*", "*/vendor/*" }) + +-- add '*' in block comments +vim.opt.formatoptions:append({ "r" }) + +-- theme +vim.opt.winblend = 0 +vim.opt.wildoptions = "pum" -- show popup for autocomplete +vim.opt.pumblend = 5 +vim.opt.background = "dark" +vim.opt.termguicolors = true -- good shit, just take it + +-- activate persistent undo +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 = "*", +}) + +vim.opt.completeopt = "menu,menuone,noselect" + +vim.opt.breakindent = true + +vim.opt.cursorline = true + +vim.g.have_nerd_font = true diff --git a/nvim-0.11/lua/juancwu/init.lua b/nvim-0.11/lua/juancwu/init.lua new file mode 100644 index 0000000..69f7b3f --- /dev/null +++ b/nvim-0.11/lua/juancwu/init.lua @@ -0,0 +1,8 @@ +local M = {} + +---@param opts? ConfigOptions +function M.setup(opts) + require("juancwu.config").setup(opts) +end + +return M diff --git a/nvim-0.11/lua/juancwu/plugins/autocomplete.lua b/nvim-0.11/lua/juancwu/plugins/autocomplete.lua new file mode 100644 index 0000000..3045f45 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/autocomplete.lua @@ -0,0 +1,139 @@ +-- 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" }, + version = "1.*", + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + -- 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 = "enter" }, + signature = { + enabled = true, + }, + + 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 = true } }, + + -- 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" }, + }, + opts_extend = { "sources.default" }, +} diff --git a/nvim-0.11/lua/juancwu/plugins/autopairs.lua b/nvim-0.11/lua/juancwu/plugins/autopairs.lua new file mode 100644 index 0000000..ada9976 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/autopairs.lua @@ -0,0 +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, +} diff --git a/nvim-0.11/lua/juancwu/plugins/autotag.lua b/nvim-0.11/lua/juancwu/plugins/autotag.lua new file mode 100644 index 0000000..1c40a6a --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/autotag.lua @@ -0,0 +1,31 @@ +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", + "blade", + }, + config = function() + local autotag = require("nvim-ts-autotag") + autotag.setup({ + enable = true, + enable_close_on_slash = false, + }) + end, +} diff --git a/nvim-0.11/lua/juancwu/plugins/colorscheme.lua b/nvim-0.11/lua/juancwu/plugins/colorscheme.lua new file mode 100644 index 0000000..93743e5 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/colorscheme.lua @@ -0,0 +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, + }, + }, + + -- 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-0.11/lua/juancwu/plugins/comment.lua b/nvim-0.11/lua/juancwu/plugins/comment.lua new file mode 100644 index 0000000..7fb3eab --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/comment.lua @@ -0,0 +1,38 @@ +return { + "numToStr/Comment.nvim", + dependencies = { + { + "JoosepAlviste/nvim-ts-context-commentstring", + opts = { + enable_autocmd = false, + }, + }, + }, + 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 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, +} diff --git a/nvim-0.11/lua/juancwu/plugins/conform.lua b/nvim-0.11/lua/juancwu/plugins/conform.lua new file mode 100644 index 0000000..3afd2fb --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/conform.lua @@ -0,0 +1,77 @@ +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" }, + templ = { "templ" }, + php = { "pint" }, + blade = { "blade-formatter" }, +} + +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, + formatters = { + pint = { + command = "vendor/bin/pint", + args = { "$FILENAME" }, + stdin = false, + }, + ["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 = 2500, + 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("FormatEnable", function() + vim.g.disable_autoformat = false + end, { + desc = "Enable autoformat on save", + }) + end, +} diff --git a/nvim-0.11/lua/juancwu/plugins/fugitive.lua b/nvim-0.11/lua/juancwu/plugins/fugitive.lua new file mode 100644 index 0000000..03812b6 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/fugitive.lua @@ -0,0 +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" }, + }, +} diff --git a/nvim-0.11/lua/juancwu/plugins/gitsigns.lua b/nvim-0.11/lua/juancwu/plugins/gitsigns.lua new file mode 100644 index 0000000..f1e8b44 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/gitsigns.lua @@ -0,0 +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 = "~" }, + }, + }, +} diff --git a/nvim-0.11/lua/juancwu/plugins/lazydev.lua b/nvim-0.11/lua/juancwu/plugins/lazydev.lua new file mode 100644 index 0000000..f38b15c --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/lazydev.lua @@ -0,0 +1,9 @@ +return { + "folke/lazydev.nvim", + ft = "lua", + opts = { + library = { + { path = "luvit-meta/library", words = { "vim%.uv" } }, + }, + }, +} diff --git a/nvim-0.11/lua/juancwu/plugins/lsp.lua b/nvim-0.11/lua/juancwu/plugins/lsp.lua new file mode 100644 index 0000000..3c3792a --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/lsp.lua @@ -0,0 +1,214 @@ +return { + -- lspconfig + "neovim/nvim-lspconfig", + dependencies = { + + { "williamboman/mason.nvim", opts = {} }, + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", + + -- status updates for LSP + { "j-hui/fidget.nvim", opts = {} }, + + { "saghen/blink.cmp" }, + }, + 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) + -- This is the helper function to set keymaps locally for this buffer + local map = function(keys, func, desc, mode) + mode = mode or "n" + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) + end + + -- Use built-in LSP for definitions (replaces deprecated Telescope function) + map("gd", vim.lsp.buf.definition, "[G]oto [D]efinition") + + -- Use Telescope for references (auto-closes on selection) + map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") + + -- Use built-in LSP for implementation (replaces deprecated Telescope function) + map("gI", vim.lsp.buf.implementation, "[G]oto [I]mplementation") + + -- Use built-in LSP for type definitions (replaces deprecated Telescope function) + map("D", vim.lsp.buf.type_definition, "Type [D]efinition") + + -- Telescope for document symbols (this is a good use for Telescope) + map("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") + + -- Telescope for workspace symbols (also a good use for Telescope) + map("ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") + + -- Built-in LSP for renaming + map("rn", vim.lsp.buf.rename, "[R]e[n]ame") + + -- Built-in LSP for code actions + map("ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" }) + + -- Built-in LSP for declaration + map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") + + -- Built-in LSP for diagnostics + 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, + }) + + 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, + }) + + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = require("blink.cmp").get_lsp_capabilities(capabilities) + + vim.filetype.add({ + extension = { + templ = "templ", + }, + pattern = { + [".*%.blade%.php"] = "blade", + }, + }) + + local servers = { + ts_ls = {}, + gopls = {}, + zls = {}, + rust_analyzer = {}, + templ = { + filetypes = { "templ" }, + }, + intelephense = {}, + html = { + filetypes = { "html", "twig", "hbs", "blade" }, + }, + emmet_ls = { + filetypes = { + "html", + "typescriptreact", + "javascriptreact", + "css", + "sass", + "scss", + "less", + "blade", + }, + }, + lua_ls = { + settings = { + Lua = { + completion = { + callSnippet = "Replace", + }, + }, + }, + }, + cssls = {}, + css_variables = {}, + tailwindcss = { + filetypes = { + "templ", + "html", + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + "blade", + }, + init_options = { + userLanguages = { + templ = "html", + blade = "html", + }, + }, + }, + } + + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { "stylua", "yamlfmt", "biome", "goimports", "pint", "blade-formatter" }) + -- require("mason-tool-installer").setup({ ensure_installed = ensure_installed }) + + local profiles = { + base = { "yamlfmt" }, + lua = { "lua_ls", "stylua" }, + web = { + "ts_ls", + "tailwindcss", + "biome", + "intelephense", + "templ", + "cssls", + "css_variables", + "html", + "emmet_ls", + "pint", + "blade-formatter", + }, + go = { "gopls", "goimports" }, + rust = { "rust_analyzer" }, + zig = { "zls" }, + all = ensure_installed, + } + + vim.api.nvim_create_user_command("InstallProfile", function(opts) + local profile_name = opts.args + local tools = profiles[profile_name] + + if not tools then + print( + "Profile '" + .. profile_name + .. "' not found. Available: " + .. table.concat(vim.tbl_keys(profiles), ", ") + ) + return + end + + require("mason-tool-installer").setup({ ensure_installed = tools }) + vim.cmd("MasonToolsInstall") + end, { + desc = "Install tools for a specific profile (e.g., web, lua, go)", + nargs = 1, + complete = function() + return vim.tbl_keys(profiles) + 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-0.11/lua/juancwu/plugins/lualine.lua b/nvim-0.11/lua/juancwu/plugins/lualine.lua new file mode 100644 index 0000000..35a5ac2 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/lualine.lua @@ -0,0 +1,62 @@ +return { + "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 = { + left = '', + right = '' + }, + component_separators = { + 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, +} diff --git a/nvim-0.11/lua/juancwu/plugins/luvit-meta.lua b/nvim-0.11/lua/juancwu/plugins/luvit-meta.lua new file mode 100644 index 0000000..c82f23a --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/luvit-meta.lua @@ -0,0 +1,4 @@ +return { + "Bilal2453/luvit-meta", + lazy = true, +} diff --git a/nvim-0.11/lua/juancwu/plugins/mini.indentscope.lua b/nvim-0.11/lua/juancwu/plugins/mini.indentscope.lua new file mode 100644 index 0000000..5117827 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/mini.indentscope.lua @@ -0,0 +1,30 @@ +return { + "echasnovski/mini.indentscope", + version = false, -- wait till new 0.7.0 release to put it back on semver + event = { "BufReadPre", "BufNewFile" }, + opts = { + -- symbol = "▏", + symbol = "│", + options = { try_as_border = true }, + }, + init = function() + vim.api.nvim_create_autocmd("FileType", { + pattern = { + "help", + "alpha", + "dashboard", + "neo-tree", + "Trouble", + "trouble", + "lazy", + "mason", + "notify", + "toggleterm", + "lazyterm", + }, + callback = function() + vim.b.miniindentscope_disable = true + end, + }) + end, +} diff --git a/nvim-0.11/lua/juancwu/plugins/neo-tree.lua b/nvim-0.11/lua/juancwu/plugins/neo-tree.lua new file mode 100644 index 0000000..fddaad3 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/neo-tree.lua @@ -0,0 +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", + }, + }, +} diff --git a/nvim-0.11/lua/juancwu/plugins/nvim-lint.lua b/nvim-0.11/lua/juancwu/plugins/nvim-lint.lua new file mode 100644 index 0000000..56bc7c5 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/nvim-lint.lua @@ -0,0 +1,84 @@ +local linters_by_ft = { + 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 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 +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() + + if linter then + if vim.tbl_contains(available_linters, linter) then + vim.g.current_linter = linter + return linter + end + end + + 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 +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" }) + + 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-0.11/lua/juancwu/plugins/oil.lua b/nvim-0.11/lua/juancwu/plugins/oil.lua new file mode 100644 index 0000000..a9aa269 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/oil.lua @@ -0,0 +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") + + 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-0.11/lua/juancwu/plugins/render-markdown.lua b/nvim-0.11/lua/juancwu/plugins/render-markdown.lua new file mode 100644 index 0000000..5808d3a --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/render-markdown.lua @@ -0,0 +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 = {}, +} diff --git a/nvim-0.11/lua/juancwu/plugins/telescope.lua b/nvim-0.11/lua/juancwu/plugins/telescope.lua new file mode 100644 index 0000000..6f8a90d --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/telescope.lua @@ -0,0 +1,187 @@ +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 +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 + + 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, + }, + }, + }, + }, + }) + + 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/.*", + "%.rustup/.*", + "target/.*", + ".devbox/.*", + ".nix/.*", + "vendor/.*", + "storage/.*", + }, + } + + 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" }) + + -- 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" }) + + 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" }) + + -- 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-0.11/lua/juancwu/plugins/todo-comments.lua b/nvim-0.11/lua/juancwu/plugins/todo-comments.lua new file mode 100644 index 0000000..2ca05d6 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/todo-comments.lua @@ -0,0 +1,5 @@ +return { + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = {}, +} diff --git a/nvim-0.11/lua/juancwu/plugins/toggleterm.lua b/nvim-0.11/lua/juancwu/plugins/toggleterm.lua new file mode 100644 index 0000000..de18893 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/toggleterm.lua @@ -0,0 +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", + }, + }, + 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-0.11/lua/juancwu/plugins/treesitter.lua b/nvim-0.11/lua/juancwu/plugins/treesitter.lua new file mode 100644 index 0000000..fe4a0d8 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/treesitter.lua @@ -0,0 +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") + + 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-0.11/lua/juancwu/plugins/undotree.lua b/nvim-0.11/lua/juancwu/plugins/undotree.lua new file mode 100644 index 0000000..af98b92 --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/undotree.lua @@ -0,0 +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" }) + + 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 }) + + 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, +} diff --git a/nvim-0.11/lua/juancwu/plugins/which-key.lua b/nvim-0.11/lua/juancwu/plugins/which-key.lua new file mode 100644 index 0000000..d9b3f6f --- /dev/null +++ b/nvim-0.11/lua/juancwu/plugins/which-key.lua @@ -0,0 +1,49 @@ +return { + { + "folke/which-key.nvim", + event = "VeryLazy", + config = function() + vim.opt.timeout = true + vim.opt.timeoutlen = 300 + + 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, + }, +} diff --git a/nvim-0.11/lua/juancwu/utils/init.lua b/nvim-0.11/lua/juancwu/utils/init.lua new file mode 100644 index 0000000..84aba78 --- /dev/null +++ b/nvim-0.11/lua/juancwu/utils/init.lua @@ -0,0 +1,10 @@ +---@class Utils +---@field os juancwu.utils.os +local M = setmetatable({}, { + __index = function(t, k) + t[k] = require("juancwu.utils." .. k) + return t[k] + end, +}) + +return M diff --git a/nvim-0.11/lua/juancwu/utils/os.lua b/nvim-0.11/lua/juancwu/utils/os.lua new file mode 100644 index 0000000..3bfe13c --- /dev/null +++ b/nvim-0.11/lua/juancwu/utils/os.lua @@ -0,0 +1,37 @@ +---@class juancwu.utils.os +local M = {} + +---@return boolean +function M.is_linux() + 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 +end + +---@return boolean +function M.is_win() + return vim.loop.os_uname().sysname:find("Windows") ~= nil +end + +---@return boolean +function M.is_wsl() + 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 +end + +return M diff --git a/nvim-0.11/stylua.toml b/nvim-0.11/stylua.toml new file mode 100644 index 0000000..e55efd5 --- /dev/null +++ b/nvim-0.11/stylua.toml @@ -0,0 +1,3 @@ +indent_type = "Spaces" +indent_width = 4 +column_width = 120