From fc8f483fa780ac5cbeaddd2f005c5f07fb1524d8 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:36:28 -0500 Subject: [PATCH 01/14] refactor neovim config --- nvim/init.lua | 41 ++--- nvim/lazy-lock.json | 3 + nvim/lua/.luarc.json | 77 +++++++++ nvim/lua/clipboard-macos.lua | 1 - nvim/lua/clipboard-unix.lua | 14 -- nvim/lua/clipboard-wsl.lua | 12 -- nvim/lua/juancwu/config/clipboard.lua | 31 ++++ nvim/lua/juancwu/config/init.lua | 150 ++++++++++++++++++ nvim/lua/{ => juancwu/config}/keymaps.lua | 3 - nvim/lua/{ => juancwu/config}/options.lua | 13 +- nvim/lua/juancwu/init.lua | 8 + nvim/lua/{ => juancwu}/plugins/autopairs.lua | 0 nvim/lua/{ => juancwu}/plugins/autotag.lua | 0 nvim/lua/{ => juancwu}/plugins/closetag.lua | 0 nvim/lua/juancwu/plugins/colorscheme.lua | 15 ++ nvim/lua/{ => juancwu}/plugins/comment.lua | 0 nvim/lua/{ => juancwu}/plugins/floaterm.lua | 0 nvim/lua/{ => juancwu}/plugins/fzf.lua | 0 nvim/lua/{ => juancwu}/plugins/git.lua | 0 nvim/lua/{ => juancwu}/plugins/gitsigns.lua | 0 nvim/lua/{ => juancwu}/plugins/harpoon.lua | 0 .../plugins/indent-blankline.lua | 0 nvim/lua/{ => juancwu}/plugins/lsp-zero.lua | 9 ++ nvim/lua/{ => juancwu}/plugins/lualine.lua | 0 .../plugins/markdown-preview.lua | 0 nvim/lua/{ => juancwu}/plugins/neo-tree.lua | 0 nvim/lua/{ => juancwu}/plugins/null-ls.lua | 0 .../lua/{ => juancwu}/plugins/nvim-dap-ui.lua | 0 .../plugins/nvim-dap-vscode-js.lua | 0 nvim/lua/{ => juancwu}/plugins/nvim-dap.lua | 0 .../{ => juancwu}/plugins/telescope-dap.lua | 0 .../plugins/telescope-file-browser.lua | 0 .../plugins/telescope-fzf-native.lua | 0 nvim/lua/{ => juancwu}/plugins/telescope.lua | 0 .../{ => juancwu}/plugins/todo-comments.lua | 0 nvim/lua/{ => juancwu}/plugins/treesitter.lua | 0 nvim/lua/{ => juancwu}/plugins/undotree.lua | 0 nvim/lua/{ => juancwu}/plugins/which-key.lua | 0 nvim/lua/juancwu/utils/init.lua | 10 ++ nvim/lua/juancwu/utils/os.lua | 24 +++ nvim/lua/plugins/colorscheme.lua | 20 --- nvim/lua/plugins/neodev.lua | 10 -- nvim/lua/plugins/rose-pine.lua | 7 - 43 files changed, 346 insertions(+), 102 deletions(-) create mode 100644 nvim/lua/.luarc.json delete mode 100644 nvim/lua/clipboard-macos.lua delete mode 100644 nvim/lua/clipboard-unix.lua delete mode 100644 nvim/lua/clipboard-wsl.lua create mode 100644 nvim/lua/juancwu/config/clipboard.lua create mode 100644 nvim/lua/juancwu/config/init.lua rename nvim/lua/{ => juancwu/config}/keymaps.lua (98%) rename nvim/lua/{ => juancwu/config}/options.lua (89%) create mode 100644 nvim/lua/juancwu/init.lua rename nvim/lua/{ => juancwu}/plugins/autopairs.lua (100%) rename nvim/lua/{ => juancwu}/plugins/autotag.lua (100%) rename nvim/lua/{ => juancwu}/plugins/closetag.lua (100%) create mode 100644 nvim/lua/juancwu/plugins/colorscheme.lua rename nvim/lua/{ => juancwu}/plugins/comment.lua (100%) rename nvim/lua/{ => juancwu}/plugins/floaterm.lua (100%) rename nvim/lua/{ => juancwu}/plugins/fzf.lua (100%) rename nvim/lua/{ => juancwu}/plugins/git.lua (100%) rename nvim/lua/{ => juancwu}/plugins/gitsigns.lua (100%) rename nvim/lua/{ => juancwu}/plugins/harpoon.lua (100%) rename nvim/lua/{ => juancwu}/plugins/indent-blankline.lua (100%) rename nvim/lua/{ => juancwu}/plugins/lsp-zero.lua (94%) rename nvim/lua/{ => juancwu}/plugins/lualine.lua (100%) rename nvim/lua/{ => juancwu}/plugins/markdown-preview.lua (100%) rename nvim/lua/{ => juancwu}/plugins/neo-tree.lua (100%) rename nvim/lua/{ => juancwu}/plugins/null-ls.lua (100%) rename nvim/lua/{ => juancwu}/plugins/nvim-dap-ui.lua (100%) rename nvim/lua/{ => juancwu}/plugins/nvim-dap-vscode-js.lua (100%) rename nvim/lua/{ => juancwu}/plugins/nvim-dap.lua (100%) rename nvim/lua/{ => juancwu}/plugins/telescope-dap.lua (100%) rename nvim/lua/{ => juancwu}/plugins/telescope-file-browser.lua (100%) rename nvim/lua/{ => juancwu}/plugins/telescope-fzf-native.lua (100%) rename nvim/lua/{ => juancwu}/plugins/telescope.lua (100%) rename nvim/lua/{ => juancwu}/plugins/todo-comments.lua (100%) rename nvim/lua/{ => juancwu}/plugins/treesitter.lua (100%) rename nvim/lua/{ => juancwu}/plugins/undotree.lua (100%) rename nvim/lua/{ => juancwu}/plugins/which-key.lua (100%) create mode 100644 nvim/lua/juancwu/utils/init.lua create mode 100644 nvim/lua/juancwu/utils/os.lua delete mode 100644 nvim/lua/plugins/colorscheme.lua delete mode 100644 nvim/lua/plugins/neodev.lua delete mode 100644 nvim/lua/plugins/rose-pine.lua diff --git a/nvim/init.lua b/nvim/init.lua index 36dcc15..46b0436 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,35 +1,16 @@ 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, - }) + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) end vim.opt.rtp:prepend(lazypath) -local has = vim.fn.has -local is_mac = has "macunix" -local is_wsl = has "wsl" -local is_unix = has "unix" - --- custom modules: -require("keymaps") -require("options") - -if is_wsl == 1 then - require("clipboard-wsl") -end - -if is_mac == 1 then - require("clipboard-macos") -end - -if is_unix == 1 and is_mac ~= 1 then - require("clipboard-unix") -end - -require("lazy").setup("plugins") +require("juancwu.config").setup({ + colorscheme = "solarized-osaka", +}) diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 2bc58a6..987fe88 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -14,6 +14,7 @@ "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "9453e3d6cd2ca45d96e20f343e8f1b927364b630" }, "mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" }, + "neodev.nvim": { "branch": "main", "commit": "be6bf4f5d2d3b173c9291f074130a3d29e1af78a" }, "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, "nvim-autopairs": { "branch": "master", "commit": "0f04d78619cce9a5af4f355968040f7d675854a1" }, "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, @@ -25,8 +26,10 @@ "nvim-ts-autotag": { "branch": "main", "commit": "8515e48a277a2f4947d91004d9aa92c29fdc5e18" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1277b4a1f451b0f18c0790e1a7f12e1e5fdebfee" }, "nvim-web-devicons": { "branch": "master", "commit": "a1425903ab52a0a0460622519e827f224e5b4fee" }, + "onedark.nvim": { "branch": "master", "commit": "c5476a091b0f1b4e853db91c91ff941f848a1cdd" }, "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "rose-pine": { "branch": "main", "commit": "92762f4fa2144c05db760ea254f4c399a56a7ef5" }, + "solarized-osaka.nvim": { "branch": "main", "commit": "83b7026ac7a4e185d4ecbe99926fd94b5735e2ea" }, "telescope-dap.nvim": { "branch": "master", "commit": "4e2d5efb92062f0b865fe59b200b5ed7793833bf" }, "telescope-file-browser.nvim": { "branch": "master", "commit": "98101b22402cd6d1c7e9a7e0c4718bfc98cb1625" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, diff --git a/nvim/lua/.luarc.json b/nvim/lua/.luarc.json new file mode 100644 index 0000000..156428e --- /dev/null +++ b/nvim/lua/.luarc.json @@ -0,0 +1,77 @@ +{ + "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" + ] +} \ No newline at end of file diff --git a/nvim/lua/clipboard-macos.lua b/nvim/lua/clipboard-macos.lua deleted file mode 100644 index 588f99c..0000000 --- a/nvim/lua/clipboard-macos.lua +++ /dev/null @@ -1 +0,0 @@ -vim.opt.clipboard:append { "unnamedplus" } diff --git a/nvim/lua/clipboard-unix.lua b/nvim/lua/clipboard-unix.lua deleted file mode 100644 index 1f45f42..0000000 --- a/nvim/lua/clipboard-unix.lua +++ /dev/null @@ -1,14 +0,0 @@ --- vim.opt.clipboard:append { "unnamedplus" } - -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, -} diff --git a/nvim/lua/clipboard-wsl.lua b/nvim/lua/clipboard-wsl.lua deleted file mode 100644 index 9c3eb14..0000000 --- a/nvim/lua/clipboard-wsl.lua +++ /dev/null @@ -1,12 +0,0 @@ -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, -} diff --git a/nvim/lua/juancwu/config/clipboard.lua b/nvim/lua/juancwu/config/clipboard.lua new file mode 100644 index 0000000..7d648ac --- /dev/null +++ b/nvim/lua/juancwu/config/clipboard.lua @@ -0,0 +1,31 @@ +local Utils = require("juancwu.utils") + +if Utils.os.is_linux() then + 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, + } +elseif Utils.os.is_mac() then + vim.opt.clipboard:append { "unnamedplus" } +elseif 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, + } +end diff --git a/nvim/lua/juancwu/config/init.lua b/nvim/lua/juancwu/config/init.lua new file mode 100644 index 0000000..eb0d687 --- /dev/null +++ b/nvim/lua/juancwu/config/init.lua @@ -0,0 +1,150 @@ +---@class Config +local M = {} + +---@class ConfigOptions +local defaultOpts = { + ---@type string | fun() + colorscheme = "rose-pine", + -- icons used by other plugins + icons = { + misc = { + dots = "󰇘", + }, + dap = { + Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" }, + Breakpoint = " ", + BreakpointCondition = " ", + BreakpointRejected = { " ", "DiagnosticError" }, + LogPoint = ".>", + }, + diagnostics = { + Error = " ", + Warn = " ", + Hint = " ", + Info = " ", + }, + git = { + added = " ", + modified = " ", + removed = " ", + }, + kinds = { + Array = " ", + Boolean = "󰨙 ", + Class = " ", + Codeium = "󰘦 ", + Color = " ", + Control = " ", + Collapsed = " ", + Constant = "󰏿 ", + Constructor = " ", + Copilot = " ", + Enum = " ", + EnumMember = " ", + Event = " ", + Field = " ", + File = " ", + Folder = " ", + Function = "󰊕 ", + Interface = " ", + Key = " ", + Keyword = " ", + Method = "󰊕 ", + Module = " ", + Namespace = "󰦮 ", + Null = " ", + Number = "󰎠 ", + Object = " ", + Operator = " ", + Package = " ", + Property = " ", + Reference = " ", + Snippet = " ", + String = " ", + Struct = "󰆼 ", + TabNine = "󰏚 ", + Text = " ", + TypeParameter = " ", + Unit = " ", + Value = " ", + Variable = "󰀫 ", + }, + }, + ---@type table? + kind_filter = { + default = { + "Class", + "Constructor", + "Enum", + "Field", + "Function", + "Interface", + "Method", + "Module", + "Namespace", + "Package", + "Property", + "Struct", + "Trait", + }, + markdown = false, + help = false, + -- you can specify a different filter for each filetype + lua = { + "Class", + "Constructor", + "Enum", + "Field", + "Function", + "Interface", + "Method", + "Module", + "Namespace", + -- "Package", -- remove package since luals uses it for control flow structures + "Property", + "Struct", + "Trait", + }, + }, +} + +---@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(options.colorscheme) == "function" then + options.colorscheme() + else + vim.cmd.colorscheme(options.colorscheme) + end + end, function(err) + local msg = "Failed to load colorscheme " .. options.colorscheme .. "\n\n" .. err + print(msg) + vim.cmd.colorscheme("rose-pine") + end) +end + +return M diff --git a/nvim/lua/keymaps.lua b/nvim/lua/juancwu/config/keymaps.lua similarity index 98% rename from nvim/lua/keymaps.lua rename to nvim/lua/juancwu/config/keymaps.lua index b10d52a..1b10676 100644 --- a/nvim/lua/keymaps.lua +++ b/nvim/lua/juancwu/config/keymaps.lua @@ -1,6 +1,3 @@ -vim.g.mapleader = " " -vim.g.maplocalleader = " " - -- easy escape vim.keymap.set("i", "", "", { noremap = true, silent = true }) vim.keymap.set("v", "", "", { noremap = true, silent = true }) diff --git a/nvim/lua/options.lua b/nvim/lua/juancwu/config/options.lua similarity index 89% rename from nvim/lua/options.lua rename to nvim/lua/juancwu/config/options.lua index 553543e..c55445b 100644 --- a/nvim/lua/options.lua +++ b/nvim/lua/juancwu/config/options.lua @@ -1,3 +1,6 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " + vim.scriptencoding = "utf-8" vim.opt.encoding = "utf-8" vim.opt.fileencoding = "utf-8" @@ -47,11 +50,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 = '*', }) diff --git a/nvim/lua/juancwu/init.lua b/nvim/lua/juancwu/init.lua new file mode 100644 index 0000000..69f7b3f --- /dev/null +++ b/nvim/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/lua/plugins/autopairs.lua b/nvim/lua/juancwu/plugins/autopairs.lua similarity index 100% rename from nvim/lua/plugins/autopairs.lua rename to nvim/lua/juancwu/plugins/autopairs.lua diff --git a/nvim/lua/plugins/autotag.lua b/nvim/lua/juancwu/plugins/autotag.lua similarity index 100% rename from nvim/lua/plugins/autotag.lua rename to nvim/lua/juancwu/plugins/autotag.lua diff --git a/nvim/lua/plugins/closetag.lua b/nvim/lua/juancwu/plugins/closetag.lua similarity index 100% rename from nvim/lua/plugins/closetag.lua rename to nvim/lua/juancwu/plugins/closetag.lua diff --git a/nvim/lua/juancwu/plugins/colorscheme.lua b/nvim/lua/juancwu/plugins/colorscheme.lua new file mode 100644 index 0000000..107b99e --- /dev/null +++ b/nvim/lua/juancwu/plugins/colorscheme.lua @@ -0,0 +1,15 @@ +return { + { + "rose-pine/nvim", + name = "rose-pine", + priority = 1000, + }, + { + 'navarasu/onedark.nvim', + priority = 1000, + }, + { + "craftzdog/solarized-osaka.nvim", + priority = 1000, + } +} diff --git a/nvim/lua/plugins/comment.lua b/nvim/lua/juancwu/plugins/comment.lua similarity index 100% rename from nvim/lua/plugins/comment.lua rename to nvim/lua/juancwu/plugins/comment.lua diff --git a/nvim/lua/plugins/floaterm.lua b/nvim/lua/juancwu/plugins/floaterm.lua similarity index 100% rename from nvim/lua/plugins/floaterm.lua rename to nvim/lua/juancwu/plugins/floaterm.lua diff --git a/nvim/lua/plugins/fzf.lua b/nvim/lua/juancwu/plugins/fzf.lua similarity index 100% rename from nvim/lua/plugins/fzf.lua rename to nvim/lua/juancwu/plugins/fzf.lua diff --git a/nvim/lua/plugins/git.lua b/nvim/lua/juancwu/plugins/git.lua similarity index 100% rename from nvim/lua/plugins/git.lua rename to nvim/lua/juancwu/plugins/git.lua diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/juancwu/plugins/gitsigns.lua similarity index 100% rename from nvim/lua/plugins/gitsigns.lua rename to nvim/lua/juancwu/plugins/gitsigns.lua diff --git a/nvim/lua/plugins/harpoon.lua b/nvim/lua/juancwu/plugins/harpoon.lua similarity index 100% rename from nvim/lua/plugins/harpoon.lua rename to nvim/lua/juancwu/plugins/harpoon.lua diff --git a/nvim/lua/plugins/indent-blankline.lua b/nvim/lua/juancwu/plugins/indent-blankline.lua similarity index 100% rename from nvim/lua/plugins/indent-blankline.lua rename to nvim/lua/juancwu/plugins/indent-blankline.lua diff --git a/nvim/lua/plugins/lsp-zero.lua b/nvim/lua/juancwu/plugins/lsp-zero.lua similarity index 94% rename from nvim/lua/plugins/lsp-zero.lua rename to nvim/lua/juancwu/plugins/lsp-zero.lua index f4fddad..a14d41a 100644 --- a/nvim/lua/plugins/lsp-zero.lua +++ b/nvim/lua/juancwu/plugins/lsp-zero.lua @@ -17,8 +17,17 @@ return { { 'hrsh7th/nvim-cmp' }, -- Required { 'hrsh7th/cmp-nvim-lsp' }, -- Required { 'L3MON4D3/LuaSnip' }, -- Required + + -- Neovim Plugin Development Completions + { + 'folke/neodev.nvim', + opts = {}, + }, }, config = function() + -- required to setup neodev before lspconfig + require('neodev').setup({}) + local lspzero = require("lsp-zero") lspzero.preset({}) diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/juancwu/plugins/lualine.lua similarity index 100% rename from nvim/lua/plugins/lualine.lua rename to nvim/lua/juancwu/plugins/lualine.lua diff --git a/nvim/lua/plugins/markdown-preview.lua b/nvim/lua/juancwu/plugins/markdown-preview.lua similarity index 100% rename from nvim/lua/plugins/markdown-preview.lua rename to nvim/lua/juancwu/plugins/markdown-preview.lua diff --git a/nvim/lua/plugins/neo-tree.lua b/nvim/lua/juancwu/plugins/neo-tree.lua similarity index 100% rename from nvim/lua/plugins/neo-tree.lua rename to nvim/lua/juancwu/plugins/neo-tree.lua diff --git a/nvim/lua/plugins/null-ls.lua b/nvim/lua/juancwu/plugins/null-ls.lua similarity index 100% rename from nvim/lua/plugins/null-ls.lua rename to nvim/lua/juancwu/plugins/null-ls.lua diff --git a/nvim/lua/plugins/nvim-dap-ui.lua b/nvim/lua/juancwu/plugins/nvim-dap-ui.lua similarity index 100% rename from nvim/lua/plugins/nvim-dap-ui.lua rename to nvim/lua/juancwu/plugins/nvim-dap-ui.lua diff --git a/nvim/lua/plugins/nvim-dap-vscode-js.lua b/nvim/lua/juancwu/plugins/nvim-dap-vscode-js.lua similarity index 100% rename from nvim/lua/plugins/nvim-dap-vscode-js.lua rename to nvim/lua/juancwu/plugins/nvim-dap-vscode-js.lua diff --git a/nvim/lua/plugins/nvim-dap.lua b/nvim/lua/juancwu/plugins/nvim-dap.lua similarity index 100% rename from nvim/lua/plugins/nvim-dap.lua rename to nvim/lua/juancwu/plugins/nvim-dap.lua diff --git a/nvim/lua/plugins/telescope-dap.lua b/nvim/lua/juancwu/plugins/telescope-dap.lua similarity index 100% rename from nvim/lua/plugins/telescope-dap.lua rename to nvim/lua/juancwu/plugins/telescope-dap.lua diff --git a/nvim/lua/plugins/telescope-file-browser.lua b/nvim/lua/juancwu/plugins/telescope-file-browser.lua similarity index 100% rename from nvim/lua/plugins/telescope-file-browser.lua rename to nvim/lua/juancwu/plugins/telescope-file-browser.lua diff --git a/nvim/lua/plugins/telescope-fzf-native.lua b/nvim/lua/juancwu/plugins/telescope-fzf-native.lua similarity index 100% rename from nvim/lua/plugins/telescope-fzf-native.lua rename to nvim/lua/juancwu/plugins/telescope-fzf-native.lua diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/juancwu/plugins/telescope.lua similarity index 100% rename from nvim/lua/plugins/telescope.lua rename to nvim/lua/juancwu/plugins/telescope.lua diff --git a/nvim/lua/plugins/todo-comments.lua b/nvim/lua/juancwu/plugins/todo-comments.lua similarity index 100% rename from nvim/lua/plugins/todo-comments.lua rename to nvim/lua/juancwu/plugins/todo-comments.lua diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/juancwu/plugins/treesitter.lua similarity index 100% rename from nvim/lua/plugins/treesitter.lua rename to nvim/lua/juancwu/plugins/treesitter.lua diff --git a/nvim/lua/plugins/undotree.lua b/nvim/lua/juancwu/plugins/undotree.lua similarity index 100% rename from nvim/lua/plugins/undotree.lua rename to nvim/lua/juancwu/plugins/undotree.lua diff --git a/nvim/lua/plugins/which-key.lua b/nvim/lua/juancwu/plugins/which-key.lua similarity index 100% rename from nvim/lua/plugins/which-key.lua rename to nvim/lua/juancwu/plugins/which-key.lua diff --git a/nvim/lua/juancwu/utils/init.lua b/nvim/lua/juancwu/utils/init.lua new file mode 100644 index 0000000..7c1034b --- /dev/null +++ b/nvim/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/lua/juancwu/utils/os.lua b/nvim/lua/juancwu/utils/os.lua new file mode 100644 index 0000000..40a7596 --- /dev/null +++ b/nvim/lua/juancwu/utils/os.lua @@ -0,0 +1,24 @@ +---@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 + +return M diff --git a/nvim/lua/plugins/colorscheme.lua b/nvim/lua/plugins/colorscheme.lua deleted file mode 100644 index 84c5d94..0000000 --- a/nvim/lua/plugins/colorscheme.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - { - "rose-pine/nvim", - name = "rose-pine", - priority = 1000, - enabled = true, - config = function() - vim.cmd.colorscheme("rose-pine") - end - }, - { - -- Theme inspired by Atom - 'navarasu/onedark.nvim', - priority = 1000, - enabled = false, - config = function() - vim.cmd.colorscheme 'onedark' - end, - }, -} diff --git a/nvim/lua/plugins/neodev.lua b/nvim/lua/plugins/neodev.lua deleted file mode 100644 index 5883557..0000000 --- a/nvim/lua/plugins/neodev.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - "folke/neodev.nvim", - enabled = false, - opts = { - library = { - plugins = true, - types = true, - } - } -} diff --git a/nvim/lua/plugins/rose-pine.lua b/nvim/lua/plugins/rose-pine.lua deleted file mode 100644 index 80d9f8d..0000000 --- a/nvim/lua/plugins/rose-pine.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - "rose-pine/nvim", - name = "rose-pine", - opts = function() - vim.cmd.colorscheme("rose-pine") - end -} From ad15e29c52e044cc44a32685d850237d7cc28954 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:46:23 -0500 Subject: [PATCH 02/14] set solarized-osaka bg transparent to false --- nvim/lua/juancwu/plugins/colorscheme.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nvim/lua/juancwu/plugins/colorscheme.lua b/nvim/lua/juancwu/plugins/colorscheme.lua index 107b99e..c40b68b 100644 --- a/nvim/lua/juancwu/plugins/colorscheme.lua +++ b/nvim/lua/juancwu/plugins/colorscheme.lua @@ -11,5 +11,8 @@ return { { "craftzdog/solarized-osaka.nvim", priority = 1000, + opts = { + transparent = false, + } } } From 5942823ba53d11d20c59edfbabd60710f8bbad20 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:46:40 -0500 Subject: [PATCH 03/14] tidy up keymaps --- nvim/lua/juancwu/config/keymaps.lua | 33 ++++++++--------------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/nvim/lua/juancwu/config/keymaps.lua b/nvim/lua/juancwu/config/keymaps.lua index 1b10676..957a494 100644 --- a/nvim/lua/juancwu/config/keymaps.lua +++ b/nvim/lua/juancwu/config/keymaps.lua @@ -3,13 +3,8 @@ vim.keymap.set("i", "", "", { noremap = true, silent = true }) vim.keymap.set("v", "", "", { noremap = true, silent = true }) vim.keymap.set("n", "", "", { noremap = true, silent = true }) --- 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", "x", "Ex") +vim.keymap.set("n", "ex", "Ex") -- move highlighted lines vim.keymap.set("v", "J", ":m '>+1gv=gv") @@ -26,10 +21,7 @@ vim.keymap.set("n", "", "zz") vim.keymap.set("n", "n", "nzzzv") vim.keymap.set("n", "N", "Nzzzv") --- do not copy with x, for god sake, WHY copy something that is being deleted?? -vim.keymap.set("n", "x", "\"_x") - --- smile :) +-- gotta learn how to use macros... vim.keymap.set("n", "Q", "") vim.keymap.set("n", "q", "", { noremap = true }) -- keymap below needs a better combo, need this to enable macros @@ -38,17 +30,17 @@ vim.keymap.set("n", "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") + -- no copy, delete line, for god sake... vim.keymap.set("n", "dd", "\"_dd") -vim.keymap.set("n", "dd", "dd") -- cut line, under my control -vim.keymap.set("x", "d", "\"_d") +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") --- yank/put to/from register 'a' -vim.keymap.set("x", "ay", '"ay', { noremap = true }) -vim.keymap.set("x", "ap", '"ap', { noremap = true }) -- increment/decrement a count, helpful for changing indeces vim.keymap.set("n", "+", "") @@ -56,14 +48,9 @@ vim.keymap.set("n", "-", "") -- do not copy when deleting word vim.keymap.set("n", "dw", "\"_dw") -vim.keymap.set("n", "de", "\"_de") -vim.keymap.set("n", "dw", "dw") -vim.keymap.set("n", "de", "de") -vim.keymap.set("n", "db", "vb\"_d") -- delete in backwards -vim.keymap.set("n", "db", "vbd") - -vim.keymap.set("n", "", "ggG") -- select all +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 @@ -92,7 +79,5 @@ vim.keymap.set("t", "", "", { noremap = true }) -- exit inser vim.keymap.set("t", "", "bd!", { noremap = true }) -- terminate terminal session vim.keymap.set("n", "", "termi", { noremap = true }) -- create new terminal session -vim.keymap.set({ 'n', 'v' }, "", "", { silent = true }) - -- lazygit on floaterm vim.keymap.set("n", "g", "FloatermNew lazygit", { noremap = true }) From d8e94c9dd11cfd0dab34753f92f30ca5e980ccd4 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:47:18 -0500 Subject: [PATCH 04/14] tidy up options --- nvim/lua/juancwu/config/options.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/nvim/lua/juancwu/config/options.lua b/nvim/lua/juancwu/config/options.lua index c55445b..275537d 100644 --- a/nvim/lua/juancwu/config/options.lua +++ b/nvim/lua/juancwu/config/options.lua @@ -1,11 +1,7 @@ vim.g.mapleader = " " vim.g.maplocalleader = " " -vim.scriptencoding = "utf-8" -vim.opt.encoding = "utf-8" -vim.opt.fileencoding = "utf-8" - -vim.wo.number = true -- show line number +vim.opt.number = true -- show line number vim.opt.relativenumber = true -- juicy relativity vim.opt.autoindent = true @@ -47,7 +43,7 @@ vim.opt.termguicolors = true -- good shit, just take it vim.opt.undofile = true --- [[ highlight on yank ]] +-- highlight on yank local highligh_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) vim.api.nvim_create_autocmd('TextYankPost', { callback = function() From acf50a8ec6e5ca791e555b12e9f2d207dbb828cc Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:47:42 -0500 Subject: [PATCH 05/14] add menu as completionopts --- nvim/lua/juancwu/config/options.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/lua/juancwu/config/options.lua b/nvim/lua/juancwu/config/options.lua index 275537d..f6c6bd1 100644 --- a/nvim/lua/juancwu/config/options.lua +++ b/nvim/lua/juancwu/config/options.lua @@ -54,7 +54,7 @@ vim.api.nvim_create_autocmd('TextYankPost', { }) -vim.opt.completeopt = 'menuone,noselect' +vim.opt.completeopt = 'menu,menuone,noselect' vim.opt.breakindent = true From d32fe6dd61cba250078325fedc89affeddb45ada Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:50:34 -0500 Subject: [PATCH 06/14] remove bloated default configs --- nvim/lua/juancwu/config/init.lua | 101 ------------------------------- 1 file changed, 101 deletions(-) diff --git a/nvim/lua/juancwu/config/init.lua b/nvim/lua/juancwu/config/init.lua index eb0d687..ccf06d2 100644 --- a/nvim/lua/juancwu/config/init.lua +++ b/nvim/lua/juancwu/config/init.lua @@ -5,107 +5,6 @@ local M = {} local defaultOpts = { ---@type string | fun() colorscheme = "rose-pine", - -- icons used by other plugins - icons = { - misc = { - dots = "󰇘", - }, - dap = { - Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" }, - Breakpoint = " ", - BreakpointCondition = " ", - BreakpointRejected = { " ", "DiagnosticError" }, - LogPoint = ".>", - }, - diagnostics = { - Error = " ", - Warn = " ", - Hint = " ", - Info = " ", - }, - git = { - added = " ", - modified = " ", - removed = " ", - }, - kinds = { - Array = " ", - Boolean = "󰨙 ", - Class = " ", - Codeium = "󰘦 ", - Color = " ", - Control = " ", - Collapsed = " ", - Constant = "󰏿 ", - Constructor = " ", - Copilot = " ", - Enum = " ", - EnumMember = " ", - Event = " ", - Field = " ", - File = " ", - Folder = " ", - Function = "󰊕 ", - Interface = " ", - Key = " ", - Keyword = " ", - Method = "󰊕 ", - Module = " ", - Namespace = "󰦮 ", - Null = " ", - Number = "󰎠 ", - Object = " ", - Operator = " ", - Package = " ", - Property = " ", - Reference = " ", - Snippet = " ", - String = " ", - Struct = "󰆼 ", - TabNine = "󰏚 ", - Text = " ", - TypeParameter = " ", - Unit = " ", - Value = " ", - Variable = "󰀫 ", - }, - }, - ---@type table? - kind_filter = { - default = { - "Class", - "Constructor", - "Enum", - "Field", - "Function", - "Interface", - "Method", - "Module", - "Namespace", - "Package", - "Property", - "Struct", - "Trait", - }, - markdown = false, - help = false, - -- you can specify a different filter for each filetype - lua = { - "Class", - "Constructor", - "Enum", - "Field", - "Function", - "Interface", - "Method", - "Module", - "Namespace", - -- "Package", -- remove package since luals uses it for control flow structures - "Property", - "Struct", - "Trait", - }, - }, } ---@param name "options" | "keymaps" | "clipboard" From 93d64d99af1269c047d9517d0244d06c7ca476f2 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Mon, 18 Dec 2023 23:27:22 -0500 Subject: [PATCH 07/14] add more colorschemes --- nvim/lua/juancwu/plugins/colorscheme.lua | 58 +++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/nvim/lua/juancwu/plugins/colorscheme.lua b/nvim/lua/juancwu/plugins/colorscheme.lua index c40b68b..5966fb0 100644 --- a/nvim/lua/juancwu/plugins/colorscheme.lua +++ b/nvim/lua/juancwu/plugins/colorscheme.lua @@ -1,18 +1,74 @@ 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", + opts = { + integrations = { + aerial = true, + alpha = true, + cmp = true, + dashboard = true, + flash = true, + gitsigns = true, + headlines = true, + illuminate = true, + indent_blankline = { enabled = true }, + leap = true, + lsp_trouble = true, + mason = true, + markdown = true, + mini = true, + native_lsp = { + enabled = true, + underlines = { + errors = { "undercurl" }, + hints = { "undercurl" }, + warnings = { "undercurl" }, + information = { "undercurl" }, + }, + }, + navic = { enabled = true, custom_bg = "lualine" }, + neotest = true, + neotree = true, + noice = true, + notify = true, + semantic_tokens = true, + telescope = true, + treesitter = true, + treesitter_context = true, + which_key = true, + }, + }, + }, } From 5610e9a725f831ba16cf734a1f452be99b975730 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Mon, 18 Dec 2023 23:27:36 -0500 Subject: [PATCH 08/14] use tokyonight colorscheme --- nvim/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/init.lua b/nvim/init.lua index 46b0436..574f757 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -12,5 +12,5 @@ end vim.opt.rtp:prepend(lazypath) require("juancwu.config").setup({ - colorscheme = "solarized-osaka", + colorscheme = "tokyonight", }) From d15112bc7d99bdbfb053534825307dd5ab029a44 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Tue, 19 Dec 2023 00:05:33 -0500 Subject: [PATCH 09/14] make metatable in config init.lua --- nvim/init.lua | 4 +++- nvim/lua/juancwu/config/init.lua | 26 ++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index 574f757..0c38c0e 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -12,5 +12,7 @@ end vim.opt.rtp:prepend(lazypath) require("juancwu.config").setup({ - colorscheme = "tokyonight", + colorscheme = function() + require("tokyonight").load() + end, }) diff --git a/nvim/lua/juancwu/config/init.lua b/nvim/lua/juancwu/config/init.lua index ccf06d2..0e2fef8 100644 --- a/nvim/lua/juancwu/config/init.lua +++ b/nvim/lua/juancwu/config/init.lua @@ -1,4 +1,4 @@ ----@class Config +---@class Config: ConfigOptions local M = {} ---@class ConfigOptions @@ -34,16 +34,30 @@ function M.setup(opts) -- try to load colorscheme xpcall(function() - if type(options.colorscheme) == "function" then - options.colorscheme() + if type(M.colorscheme) == "function" then + M.colorscheme() else - vim.cmd.colorscheme(options.colorscheme) + vim.cmd.colorscheme(M.colorscheme) end end, function(err) - local msg = "Failed to load colorscheme " .. options.colorscheme .. "\n\n" .. err - print(msg) + 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) end +setmetatable(M, { + __index = function(_, k) + if options == nil then + return vim.deepcopy(defaultOpts)[k] + end + + return options[k] + end +}) + return M From 2b88ac6e5d02877401b516b509047401c3e62aef Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Tue, 19 Dec 2023 00:09:46 -0500 Subject: [PATCH 10/14] move lsp config into a folder --- nvim/lua/juancwu/plugins/lsp-zero.lua | 141 ------------------------- nvim/lua/juancwu/plugins/lsp/init.lua | 144 ++++++++++++++++++++++++++ 2 files changed, 144 insertions(+), 141 deletions(-) delete mode 100644 nvim/lua/juancwu/plugins/lsp-zero.lua create mode 100644 nvim/lua/juancwu/plugins/lsp/init.lua diff --git a/nvim/lua/juancwu/plugins/lsp-zero.lua b/nvim/lua/juancwu/plugins/lsp-zero.lua deleted file mode 100644 index a14d41a..0000000 --- a/nvim/lua/juancwu/plugins/lsp-zero.lua +++ /dev/null @@ -1,141 +0,0 @@ -return { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v2.x', - dependencies = { - -- LSP Support - { 'neovim/nvim-lspconfig' }, -- Required - { - -- Optional - 'williamboman/mason.nvim', - build = function() - pcall(vim.cmd, 'MasonUpdate') - end, - }, - { 'williamboman/mason-lspconfig.nvim' }, -- Optional - - -- Autocompletion - { 'hrsh7th/nvim-cmp' }, -- Required - { 'hrsh7th/cmp-nvim-lsp' }, -- Required - { 'L3MON4D3/LuaSnip' }, -- Required - - -- Neovim Plugin Development Completions - { - 'folke/neodev.nvim', - opts = {}, - }, - }, - config = function() - -- required to setup neodev before lspconfig - require('neodev').setup({}) - - local lspzero = require("lsp-zero") - - lspzero.preset({}) - - lspzero.on_attach(function(client, bufnr) - lspzero.default_keymaps({ - buffer = bufnr, - omit = { - 'gr' - }, - }) - - function nmap(key, action, desc) - vim.keymap.set( - "n", - key, - action, - { - desc = "LSP: " .. desc, - } - ) - end - - nmap("[d", "lua vim.diagnostic.goto_prev()", "Goto Prev Diagnostic"); - nmap("]d", "lua vim.diagnostic.goto_next()", "Goto Next Diagnostic") - - local current_dir = vim.fn.expand("%:p:h") - - -- vim.keymap.set('n', 'gr', 'Telescope lsp_references', { buffer = true }) - - -- format with space + f - -- vim.keymap.set("n", "fb", "lua vim.lsp.buf.format()", - -- { desc = "[F]ormat [B]uffer" }) - nmap("fb", "lua vim.lsp.buf.format()", "[F]ormat [B]uffer") - end) - - lspzero.ensure_installed({ - "tsserver", - "eslint", - "tailwindcss", - }) - - lspzero.format_on_save({ - format_ops = { - async = true, - timeout_ms = 10000, - }, - servers = { - ["lua_ls"] = { "lua" }, - ["null-ls"] = { - "javascript", - "typescript", - "javascriptreact", - "typescriptreact", - "html", - "css", - }, - }, - }) - - local status, lspconfig = pcall(require, "lspconfig") - - if status then - lspconfig.tsserver.setup({}) - lspconfig.tailwindcss.setup({ - filetypes = { - 'templ', - 'html', - 'javascript', - 'typescript', - 'javascriptreact', - 'typescriptreact', - }, - init_options = { - userLanguages = { - templ = "html" - } - } - }) - lspconfig.zls.setup({}) - lspconfig.rust_analyzer.setup({}) - lspconfig.gopls.setup({}) - lspconfig.html.setup({}) - vim.filetype.add({ - extension = { - templ = "templ" - }, - }) - lspconfig.templ.setup({ - filetypes = { - "templ", - }, - }) - end - - lspzero.setup() - - local cmp - status, cmp = pcall(require, "cmp") - - if not status then return end - - cmp.setup({ - mapping = { - -- press 'enter' to confirm completion/suggestion - [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping.abort(), - }, - }) - end -} diff --git a/nvim/lua/juancwu/plugins/lsp/init.lua b/nvim/lua/juancwu/plugins/lsp/init.lua new file mode 100644 index 0000000..1ed8ce8 --- /dev/null +++ b/nvim/lua/juancwu/plugins/lsp/init.lua @@ -0,0 +1,144 @@ +return { + -- lspconfig + { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v2.x', + dependencies = { + -- LSP Support + { 'neovim/nvim-lspconfig' }, -- Required + { + -- Optional + 'williamboman/mason.nvim', + build = function() + pcall(vim.cmd, 'MasonUpdate') + end, + }, + { 'williamboman/mason-lspconfig.nvim' }, -- Optional + + -- Autocompletion + { 'hrsh7th/nvim-cmp' }, -- Required + { 'hrsh7th/cmp-nvim-lsp' }, -- Required + { 'L3MON4D3/LuaSnip' }, -- Required + + -- Neovim Plugin Development Completions + { + 'folke/neodev.nvim', + opts = {}, + }, + }, + config = function() + -- required to setup neodev before lspconfig + require('neodev').setup({}) + + local lspzero = require("lsp-zero") + + lspzero.preset({}) + + lspzero.on_attach(function(client, bufnr) + lspzero.default_keymaps({ + buffer = bufnr, + omit = { + 'gr' + }, + }) + + function nmap(key, action, desc) + vim.keymap.set( + "n", + key, + action, + { + desc = "LSP: " .. desc, + } + ) + end + + nmap("[d", "lua vim.diagnostic.goto_prev()", "Goto Prev Diagnostic"); + nmap("]d", "lua vim.diagnostic.goto_next()", "Goto Next Diagnostic") + + local current_dir = vim.fn.expand("%:p:h") + + -- vim.keymap.set('n', 'gr', 'Telescope lsp_references', { buffer = true }) + + -- format with space + f + -- vim.keymap.set("n", "fb", "lua vim.lsp.buf.format()", + -- { desc = "[F]ormat [B]uffer" }) + nmap("fb", "lua vim.lsp.buf.format()", "[F]ormat [B]uffer") + end) + + lspzero.ensure_installed({ + "tsserver", + "eslint", + "tailwindcss", + }) + + lspzero.format_on_save({ + format_ops = { + async = true, + timeout_ms = 10000, + }, + servers = { + ["lua_ls"] = { "lua" }, + ["null-ls"] = { + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + "html", + "css", + }, + }, + }) + + local status, lspconfig = pcall(require, "lspconfig") + + if status then + lspconfig.tsserver.setup({}) + lspconfig.tailwindcss.setup({ + filetypes = { + 'templ', + 'html', + 'javascript', + 'typescript', + 'javascriptreact', + 'typescriptreact', + }, + init_options = { + userLanguages = { + templ = "html" + } + } + }) + lspconfig.zls.setup({}) + lspconfig.rust_analyzer.setup({}) + lspconfig.gopls.setup({}) + lspconfig.html.setup({}) + vim.filetype.add({ + extension = { + templ = "templ" + }, + }) + lspconfig.templ.setup({ + filetypes = { + "templ", + }, + }) + end + + lspzero.setup() + + local cmp + status, cmp = pcall(require, "cmp") + + if not status then return end + + cmp.setup({ + mapping = { + -- press 'enter' to confirm completion/suggestion + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.abort(), + }, + }) + end + } +} From 4b24a1326387c80e7b969aea565f56413e03b1c2 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:33:19 -0500 Subject: [PATCH 11/14] add conform for formatting --- nvim/init.lua | 22 +-- nvim/lazy-lock.json | 2 + nvim/lua/juancwu/plugins/lsp/init.lua | 263 ++++++++++++++------------ 3 files changed, 152 insertions(+), 135 deletions(-) diff --git a/nvim/init.lua b/nvim/init.lua index 0c38c0e..e568265 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,18 +1,18 @@ 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, - }) + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) end vim.opt.rtp:prepend(lazypath) require("juancwu.config").setup({ - colorscheme = function() - require("tokyonight").load() - end, + colorscheme = function() + require("tokyonight").load() + end, }) diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 987fe88..f05c3d2 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -1,6 +1,7 @@ { "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, "LuaSnip": { "branch": "master", "commit": "57c9f5c31b3d712376c704673eac8e948c82e9c1" }, + "catppuccin": { "branch": "main", "commit": "079500a625f3ae5aa6efb758f1a17fe4c7a57e52" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "fzf": { "branch": "master", "commit": "d21d5c9510170d74a7f959309da720b6df72ca01" }, "fzf-lua": { "branch": "main", "commit": "a1a2d0f42eaec400cc6918a8e898fc1f9c4dbc5f" }, @@ -35,6 +36,7 @@ "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope.nvim": { "branch": "master", "commit": "6213322ab56eb27356fdc09a5078e41e3ea7f3bc" }, "todo-comments.nvim": { "branch": "main", "commit": "4a6737a8d70fe1ac55c64dfa47fcb189ca431872" }, + "tokyonight.nvim": { "branch": "main", "commit": "f247ee700b569ed43f39320413a13ba9b0aef0db" }, "undotree": { "branch": "master", "commit": "36ff7abb6b60980338344982ad4cdf03f7961ecd" }, "vim-closetag": { "branch": "master", "commit": "d0a562f8bdb107a50595aefe53b1a690460c3822" }, "vim-floaterm": { "branch": "master", "commit": "3f01a623376957437f9376327637491b74719e38" }, diff --git a/nvim/lua/juancwu/plugins/lsp/init.lua b/nvim/lua/juancwu/plugins/lsp/init.lua index 1ed8ce8..e85bded 100644 --- a/nvim/lua/juancwu/plugins/lsp/init.lua +++ b/nvim/lua/juancwu/plugins/lsp/init.lua @@ -1,144 +1,159 @@ return { - -- lspconfig - { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v2.x', - dependencies = { - -- LSP Support - { 'neovim/nvim-lspconfig' }, -- Required - { - -- Optional - 'williamboman/mason.nvim', - build = function() - pcall(vim.cmd, 'MasonUpdate') - end, - }, - { 'williamboman/mason-lspconfig.nvim' }, -- Optional + -- lspconfig + { + "VonHeikemen/lsp-zero.nvim", + branch = "v2.x", + dependencies = { + -- LSP Support + { "neovim/nvim-lspconfig" }, -- Required + { + -- Optional + "williamboman/mason.nvim", + build = function() + pcall(vim.cmd, "MasonUpdate") + end, + }, + { "williamboman/mason-lspconfig.nvim" }, -- Optional - -- Autocompletion - { 'hrsh7th/nvim-cmp' }, -- Required - { 'hrsh7th/cmp-nvim-lsp' }, -- Required - { 'L3MON4D3/LuaSnip' }, -- Required + -- Autocompletion + { "hrsh7th/nvim-cmp" }, -- Required + { "hrsh7th/cmp-nvim-lsp" }, -- Required + { "L3MON4D3/LuaSnip" }, -- Required - -- Neovim Plugin Development Completions - { - 'folke/neodev.nvim', - opts = {}, - }, - }, - config = function() - -- required to setup neodev before lspconfig - require('neodev').setup({}) + -- Neovim Plugin Development Completions + { + "folke/neodev.nvim", + opts = {}, + }, - local lspzero = require("lsp-zero") + -- formatting + { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + lua = { "stylua" }, + }, + format_on_save = { + timeout_ms = 500, + lsp_fallback = true, + }, + }, + }, + }, + config = function() + -- required to setup neodev before lspconfig + require("neodev").setup({}) - lspzero.preset({}) + local lspzero = require("lsp-zero") - lspzero.on_attach(function(client, bufnr) - lspzero.default_keymaps({ - buffer = bufnr, - omit = { - 'gr' - }, - }) + lspzero.preset({}) - function nmap(key, action, desc) - vim.keymap.set( - "n", - key, - action, - { - desc = "LSP: " .. desc, - } - ) - end + lspzero.on_attach(function(client, bufnr) + lspzero.default_keymaps({ + buffer = bufnr, + omit = { + "gr", + }, + }) - nmap("[d", "lua vim.diagnostic.goto_prev()", "Goto Prev Diagnostic"); - nmap("]d", "lua vim.diagnostic.goto_next()", "Goto Next Diagnostic") + function nmap(key, action, desc) + vim.keymap.set("n", key, action, { + desc = "LSP: " .. desc, + }) + end - local current_dir = vim.fn.expand("%:p:h") + nmap("[d", "lua vim.diagnostic.goto_prev()", "Goto Prev Diagnostic") + nmap("]d", "lua vim.diagnostic.goto_next()", "Goto Next Diagnostic") - -- vim.keymap.set('n', 'gr', 'Telescope lsp_references', { buffer = true }) + local current_dir = vim.fn.expand("%:p:h") - -- format with space + f - -- vim.keymap.set("n", "fb", "lua vim.lsp.buf.format()", - -- { desc = "[F]ormat [B]uffer" }) - nmap("fb", "lua vim.lsp.buf.format()", "[F]ormat [B]uffer") - end) + -- vim.keymap.set('n', 'gr', 'Telescope lsp_references', { buffer = true }) - lspzero.ensure_installed({ - "tsserver", - "eslint", - "tailwindcss", - }) + -- format with space + f + -- vim.keymap.set("n", "fb", "lua vim.lsp.buf.format()", + -- { desc = "[F]ormat [B]uffer" }) + nmap("fb", "lua vim.lsp.buf.format()", "[F]ormat [B]uffer") - lspzero.format_on_save({ - format_ops = { - async = true, - timeout_ms = 10000, - }, - servers = { - ["lua_ls"] = { "lua" }, - ["null-ls"] = { - "javascript", - "typescript", - "javascriptreact", - "typescriptreact", - "html", - "css", - }, - }, - }) + vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) + require("conform").format({ bufnr = bufnr }) + end, { desc = "Format current buffer with LSP" }) + end) - local status, lspconfig = pcall(require, "lspconfig") + lspzero.ensure_installed({ + "tsserver", + "eslint", + "tailwindcss", + }) - if status then - lspconfig.tsserver.setup({}) - lspconfig.tailwindcss.setup({ - filetypes = { - 'templ', - 'html', - 'javascript', - 'typescript', - 'javascriptreact', - 'typescriptreact', - }, - init_options = { - userLanguages = { - templ = "html" - } - } - }) - lspconfig.zls.setup({}) - lspconfig.rust_analyzer.setup({}) - lspconfig.gopls.setup({}) - lspconfig.html.setup({}) - vim.filetype.add({ - extension = { - templ = "templ" - }, - }) - lspconfig.templ.setup({ - filetypes = { - "templ", - }, - }) - end + -- lspzero.format_on_save({ + -- format_ops = { + -- async = true, + -- timeout_ms = 10000, + -- }, + -- servers = { + -- ["lua_ls"] = { "lua" }, + -- ["null-ls"] = { + -- "javascript", + -- "typescript", + -- "javascriptreact", + -- "typescriptreact", + -- "html", + -- "css", + -- }, + -- }, + -- }) - lspzero.setup() + local status, lspconfig = pcall(require, "lspconfig") - local cmp - status, cmp = pcall(require, "cmp") + if status then + lspconfig.tsserver.setup({}) + lspconfig.tailwindcss.setup({ + filetypes = { + "templ", + "html", + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + }, + init_options = { + userLanguages = { + templ = "html", + }, + }, + }) + lspconfig.zls.setup({}) + lspconfig.rust_analyzer.setup({}) + lspconfig.gopls.setup({}) + lspconfig.html.setup({}) + vim.filetype.add({ + extension = { + templ = "templ", + }, + }) + lspconfig.templ.setup({ + filetypes = { + "templ", + }, + }) + end - if not status then return end + lspzero.setup() - cmp.setup({ - mapping = { - -- press 'enter' to confirm completion/suggestion - [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping.abort(), - }, - }) - end - } + local cmp + status, cmp = pcall(require, "cmp") + + if not status then + return + end + + cmp.setup({ + mapping = { + -- press 'enter' to confirm completion/suggestion + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.abort(), + }, + }) + end, + }, } From 8cfd9c319d6c1d520b0826e04a41f07733d4f491 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:35:20 -0500 Subject: [PATCH 12/14] add js/ts to ft to format --- nvim/lua/juancwu/plugins/lsp/init.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nvim/lua/juancwu/plugins/lsp/init.lua b/nvim/lua/juancwu/plugins/lsp/init.lua index e85bded..9d46a22 100644 --- a/nvim/lua/juancwu/plugins/lsp/init.lua +++ b/nvim/lua/juancwu/plugins/lsp/init.lua @@ -32,6 +32,10 @@ return { opts = { formatters_by_ft = { lua = { "stylua" }, + javascript = { "prettierd" }, + typescript = { "prettierd" }, + javascriptreact = { "prettierd" }, + typescriptreact = { "prettierd" }, }, format_on_save = { timeout_ms = 500, From 7325c06a759e9a6d7bb7a41e733c06c242b06dcb Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:41:08 -0500 Subject: [PATCH 13/14] change format keymap to use conform to format --- nvim/lua/juancwu/plugins/lsp/init.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/nvim/lua/juancwu/plugins/lsp/init.lua b/nvim/lua/juancwu/plugins/lsp/init.lua index 9d46a22..172b398 100644 --- a/nvim/lua/juancwu/plugins/lsp/init.lua +++ b/nvim/lua/juancwu/plugins/lsp/init.lua @@ -52,7 +52,7 @@ return { lspzero.preset({}) - lspzero.on_attach(function(client, bufnr) + lspzero.on_attach(function(_, bufnr) lspzero.default_keymaps({ buffer = bufnr, omit = { @@ -60,26 +60,30 @@ return { }, }) - function nmap(key, action, desc) + local function nmap(key, action, desc) vim.keymap.set("n", key, action, { desc = "LSP: " .. desc, }) end + local function format() + require("conform").format({ bufnr = bufnr }) + end + nmap("[d", "lua vim.diagnostic.goto_prev()", "Goto Prev Diagnostic") nmap("]d", "lua vim.diagnostic.goto_next()", "Goto Next Diagnostic") - local current_dir = vim.fn.expand("%:p:h") + -- local current_dir = vim.fn.expand("%:p:h") -- vim.keymap.set('n', 'gr', 'Telescope lsp_references', { buffer = true }) -- format with space + f -- vim.keymap.set("n", "fb", "lua vim.lsp.buf.format()", -- { desc = "[F]ormat [B]uffer" }) - nmap("fb", "lua vim.lsp.buf.format()", "[F]ormat [B]uffer") + nmap("fb", format, "[F]ormat [B]uffer") vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) - require("conform").format({ bufnr = bufnr }) + format() end, { desc = "Format current buffer with LSP" }) end) From 512ab888d135768fb747d79f31580e905ce1a915 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Thu, 28 Dec 2023 14:11:44 -0500 Subject: [PATCH 14/14] add commands to enable/disable format on save --- nvim/lua/juancwu/config/init.lua | 84 +++++++++++++++------------ nvim/lua/juancwu/plugins/lsp/init.lua | 10 ++-- 2 files changed, 53 insertions(+), 41 deletions(-) diff --git a/nvim/lua/juancwu/config/init.lua b/nvim/lua/juancwu/config/init.lua index 0e2fef8..78c5fe5 100644 --- a/nvim/lua/juancwu/config/init.lua +++ b/nvim/lua/juancwu/config/init.lua @@ -3,20 +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 @@ -24,40 +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" }) 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/plugins/lsp/init.lua b/nvim/lua/juancwu/plugins/lsp/init.lua index 172b398..d9bf389 100644 --- a/nvim/lua/juancwu/plugins/lsp/init.lua +++ b/nvim/lua/juancwu/plugins/lsp/init.lua @@ -37,10 +37,12 @@ return { javascriptreact = { "prettierd" }, typescriptreact = { "prettierd" }, }, - format_on_save = { - timeout_ms = 500, - lsp_fallback = true, - }, + format_on_save = function(bufnr) + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + return { timeout_ms = 500, lsp_fallback = true } + end, }, }, },