diff --git a/nvim/init.lua b/nvim/init.lua index 36dcc15..e568265 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,35 +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) -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 = function() + require("tokyonight").load() + end, +}) diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 2bc58a6..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" }, @@ -14,6 +15,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,13 +27,16 @@ "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" }, "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/.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..78c5fe5 --- /dev/null +++ b/nvim/lua/juancwu/config/init.lua @@ -0,0 +1,73 @@ +---@class Config: ConfigOptions +local M = {} + +---@class ConfigOptions +local defaultOpts = { + ---@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) +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/lua/keymaps.lua b/nvim/lua/juancwu/config/keymaps.lua similarity index 75% rename from nvim/lua/keymaps.lua rename to nvim/lua/juancwu/config/keymaps.lua index b10d52a..957a494 100644 --- a/nvim/lua/keymaps.lua +++ b/nvim/lua/juancwu/config/keymaps.lua @@ -1,18 +1,10 @@ -vim.g.mapleader = " " -vim.g.maplocalleader = " " - --- 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 }) - -- 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") @@ -29,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 @@ -41,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", "+", "") @@ -59,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 @@ -95,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 }) diff --git a/nvim/lua/options.lua b/nvim/lua/juancwu/config/options.lua similarity index 79% rename from nvim/lua/options.lua rename to nvim/lua/juancwu/config/options.lua index 553543e..f6c6bd1 100644 --- a/nvim/lua/options.lua +++ b/nvim/lua/juancwu/config/options.lua @@ -1,8 +1,7 @@ -vim.scriptencoding = "utf-8" -vim.opt.encoding = "utf-8" -vim.opt.fileencoding = "utf-8" +vim.g.mapleader = " " +vim.g.maplocalleader = " " -vim.wo.number = true -- show line number +vim.opt.number = true -- show line number vim.opt.relativenumber = true -- juicy relativity vim.opt.autoindent = true @@ -44,18 +43,18 @@ 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() - vim.highlight.on_yank() - end, - group = highligh_group, - pattern = '*', + callback = function() + vim.highlight.on_yank() + end, + group = highligh_group, + pattern = '*', }) -vim.opt.completeopt = 'menuone,noselect' +vim.opt.completeopt = 'menu,menuone,noselect' vim.opt.breakindent = true 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..5966fb0 --- /dev/null +++ b/nvim/lua/juancwu/plugins/colorscheme.lua @@ -0,0 +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, + }, + }, + }, +} 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/juancwu/plugins/lsp/init.lua b/nvim/lua/juancwu/plugins/lsp/init.lua new file mode 100644 index 0000000..d9bf389 --- /dev/null +++ b/nvim/lua/juancwu/plugins/lsp/init.lua @@ -0,0 +1,169 @@ +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 = {}, + }, + + -- formatting + { + "stevearc/conform.nvim", + opts = { + formatters_by_ft = { + lua = { "stylua" }, + javascript = { "prettierd" }, + typescript = { "prettierd" }, + javascriptreact = { "prettierd" }, + typescriptreact = { "prettierd" }, + }, + 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, + }, + }, + }, + config = function() + -- required to setup neodev before lspconfig + require("neodev").setup({}) + + local lspzero = require("lsp-zero") + + lspzero.preset({}) + + lspzero.on_attach(function(_, bufnr) + lspzero.default_keymaps({ + buffer = bufnr, + omit = { + "gr", + }, + }) + + 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") + + -- 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", format, "[F]ormat [B]uffer") + + vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) + format() + end, { desc = "Format current buffer with LSP" }) + 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/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/lsp-zero.lua b/nvim/lua/plugins/lsp-zero.lua deleted file mode 100644 index f4fddad..0000000 --- a/nvim/lua/plugins/lsp-zero.lua +++ /dev/null @@ -1,132 +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 - }, - config = function() - 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/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 -}