From e260bc889e92ecc2fa720ac6a4f94fe5b66e61fc Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Sat, 21 Oct 2023 22:13:28 +0800 Subject: [PATCH 01/15] add nvchad --- .gitmodules | 3 +++ general/NvChad | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 general/NvChad diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..66ce6d2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "general/NvChad"] + path = general/NvChad + url = https://github.com/NvChad/NvChad.git diff --git a/general/NvChad b/general/NvChad new file mode 160000 index 0000000..c56f124 --- /dev/null +++ b/general/NvChad @@ -0,0 +1 @@ +Subproject commit c56f1242dfc9c1fbba71fc3a22448d5d563703e0 From d7d344b53054fcda0bb55119c1c13724931c2cf6 Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Mon, 23 Oct 2023 01:47:26 +0800 Subject: [PATCH 02/15] migarate to nvchad --- general/custom/chadrc.lua | 20 ++ general/custom/configs/lspconfig.lua | 17 ++ general/custom/configs/null-ls.lua | 28 +++ general/custom/configs/overrides.lua | 92 ++++++++ general/custom/highlights.lua | 19 ++ .../init.lua} | 0 general/custom/mappings.lua | 115 ++++++++++ general/custom/plugins.lua | 64 ++++++ general/nvim/after/plugin/aerial.rc.lua | 4 - general/nvim/after/plugin/autopairs.rc.lua | 7 - general/nvim/after/plugin/bufferline.rc.lua | 33 --- general/nvim/after/plugin/cmp.rc.lua | 38 ---- general/nvim/after/plugin/colorizer.rc.lua | 6 - general/nvim/after/plugin/colorscheme.lua | 3 - general/nvim/after/plugin/dap.rc.lua | 43 ---- general/nvim/after/plugin/git.rc.lua | 11 - general/nvim/after/plugin/gitsigns.rc.lua | 62 ------ general/nvim/after/plugin/lsp-colors.rc.lua | 9 - general/nvim/after/plugin/lspkind.rc.lua | 47 ----- general/nvim/after/plugin/lualine.rc.lua | 43 ---- general/nvim/after/plugin/mason.rc.lua | 12 -- general/nvim/after/plugin/neotest.rc.lua | 39 ---- general/nvim/after/plugin/nvim-comment.rc.lua | 11 - general/nvim/after/plugin/nvim-tree.rc.lua | 80 ------- general/nvim/after/plugin/telescope.rc.lua | 19 -- general/nvim/after/plugin/toggleterm.rc.lua | 45 ---- general/nvim/after/plugin/treesitter.rc.lua | 24 --- general/nvim/after/plugin/web-devicons.rc.lua | 12 -- general/nvim/init.lua | 17 -- general/nvim/lua/user/base.lua | 46 ---- general/nvim/lua/user/highlights.lua | 6 - general/nvim/lua/user/lsp/handlers.lua | 93 --------- general/nvim/lua/user/lsp/init.lua | 8 - general/nvim/lua/user/lsp/mason.lua | 49 ----- general/nvim/lua/user/lsp/null-ls.lua | 21 -- general/nvim/lua/user/lsp/settings/jsonls.lua | 197 ------------------ .../nvim/lua/user/lsp/settings/pyright.lua | 9 - general/nvim/lua/user/macos.lua | 1 - general/nvim/lua/user/maps.lua | 49 ----- general/nvim/lua/user/plugins.lua | 85 -------- general/nvim/lua/user/windows.lua | 1 - general/nvim/plugin/.gitignore | 1 - 42 files changed, 355 insertions(+), 1131 deletions(-) create mode 100644 general/custom/chadrc.lua create mode 100644 general/custom/configs/lspconfig.lua create mode 100644 general/custom/configs/null-ls.lua create mode 100644 general/custom/configs/overrides.lua create mode 100644 general/custom/highlights.lua rename general/{nvim/after/plugin/markdown-preview.rc.lua => custom/init.lua} (100%) create mode 100644 general/custom/mappings.lua create mode 100644 general/custom/plugins.lua delete mode 100644 general/nvim/after/plugin/aerial.rc.lua delete mode 100644 general/nvim/after/plugin/autopairs.rc.lua delete mode 100644 general/nvim/after/plugin/bufferline.rc.lua delete mode 100644 general/nvim/after/plugin/cmp.rc.lua delete mode 100644 general/nvim/after/plugin/colorizer.rc.lua delete mode 100644 general/nvim/after/plugin/colorscheme.lua delete mode 100644 general/nvim/after/plugin/dap.rc.lua delete mode 100644 general/nvim/after/plugin/git.rc.lua delete mode 100644 general/nvim/after/plugin/gitsigns.rc.lua delete mode 100644 general/nvim/after/plugin/lsp-colors.rc.lua delete mode 100644 general/nvim/after/plugin/lspkind.rc.lua delete mode 100644 general/nvim/after/plugin/lualine.rc.lua delete mode 100644 general/nvim/after/plugin/mason.rc.lua delete mode 100644 general/nvim/after/plugin/neotest.rc.lua delete mode 100644 general/nvim/after/plugin/nvim-comment.rc.lua delete mode 100644 general/nvim/after/plugin/nvim-tree.rc.lua delete mode 100644 general/nvim/after/plugin/telescope.rc.lua delete mode 100644 general/nvim/after/plugin/toggleterm.rc.lua delete mode 100644 general/nvim/after/plugin/treesitter.rc.lua delete mode 100644 general/nvim/after/plugin/web-devicons.rc.lua delete mode 100644 general/nvim/init.lua delete mode 100644 general/nvim/lua/user/base.lua delete mode 100644 general/nvim/lua/user/highlights.lua delete mode 100644 general/nvim/lua/user/lsp/handlers.lua delete mode 100644 general/nvim/lua/user/lsp/init.lua delete mode 100644 general/nvim/lua/user/lsp/mason.lua delete mode 100644 general/nvim/lua/user/lsp/null-ls.lua delete mode 100644 general/nvim/lua/user/lsp/settings/jsonls.lua delete mode 100644 general/nvim/lua/user/lsp/settings/pyright.lua delete mode 100644 general/nvim/lua/user/macos.lua delete mode 100644 general/nvim/lua/user/maps.lua delete mode 100644 general/nvim/lua/user/plugins.lua delete mode 100644 general/nvim/lua/user/windows.lua delete mode 100644 general/nvim/plugin/.gitignore diff --git a/general/custom/chadrc.lua b/general/custom/chadrc.lua new file mode 100644 index 0000000..b84c12b --- /dev/null +++ b/general/custom/chadrc.lua @@ -0,0 +1,20 @@ +---@type ChadrcConfig +local M = {} + +-- Path to overriding theme and highlights files +local highlights = require("custom.highlights") + +M.ui = { + theme = "onedark", + theme_toggle = { "onedark", "one_light" }, + + hl_override = highlights.override, + hl_add = highlights.add, +} + +M.plugins = "custom.plugins" + +-- check core.mappings for table structure +M.mappings = require("custom.mappings") + +return M diff --git a/general/custom/configs/lspconfig.lua b/general/custom/configs/lspconfig.lua new file mode 100644 index 0000000..3d6cabd --- /dev/null +++ b/general/custom/configs/lspconfig.lua @@ -0,0 +1,17 @@ +local on_attach = require("plugins.configs.lspconfig").on_attach +local capabilities = require("plugins.configs.lspconfig").capabilities + +local lspconfig = require("lspconfig") + +-- if you just want default config for the servers then put them in a table +local servers = { "html", "cssls", "tsserver", "clangd", "pyright" } + +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup({ + on_attach = on_attach, + capabilities = capabilities, + }) +end + +-- +-- lspconfig.pyright.setup { blabla} diff --git a/general/custom/configs/null-ls.lua b/general/custom/configs/null-ls.lua new file mode 100644 index 0000000..9c93b59 --- /dev/null +++ b/general/custom/configs/null-ls.lua @@ -0,0 +1,28 @@ +local null_ls = require("null-ls") + +local b = null_ls.builtins + +local sources = { + + -- webdev stuff + b.formatting.deno_fmt, -- choosed deno for ts/js files cuz its very fast! + b.formatting.prettier.with({ filetypes = { "html", "markdown", "css" } }), -- so prettier works only on these filetypes + + -- Lua + b.formatting.stylua, + + -- cpp + b.formatting.clang_format, + + -- python + b.formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }), + b.formatting.black.with({ extra_args = { "--fast" } }), + b.formatting.stylua, + b.formatting.isort, + b.formatting.autoflake.with({ extra_args = { "--remove-all-unused-imports", "--remove-unused-variables" } }), +} + +null_ls.setup({ + debug = false, + sources = sources, +}) diff --git a/general/custom/configs/overrides.lua b/general/custom/configs/overrides.lua new file mode 100644 index 0000000..ab87a42 --- /dev/null +++ b/general/custom/configs/overrides.lua @@ -0,0 +1,92 @@ +local M = {} + +M.treesitter = { + ensure_installed = { + "lua", + "c", + "cpp", + "markdown", + "markdown_inline", + "fish", + "python", + }, + indent = { + enable = true, + disable = {}, + }, +} + +M.mason = { + ensure_installed = { + -- lua stuff + "lua-language-server", + "stylua", + + -- web dev stuff + "css-lsp", + "html-lsp", + "typescript-language-server", + "deno", + "prettier", + + -- c/cpp stuff + "clangd", + "clang-format", + + -- python stuff + "pyright", + "black", + "isort", + "mypy", + + -- markdown stuff + "marksman", + "markdownlint", + "mdformat", + }, +} + +local function nvimtree_attach(bufnr) + local api = require("nvim-tree.api") + + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + api.config.mappings.default_on_attach(bufnr) + + vim.keymap.set("n", "l", api.node.open.edit, opts("Open")) + vim.keymap.set("n", "v", api.node.open.vertical, opts("Open: Vertical Split")) + vim.keymap.set("n", "h", api.node.open.horizontal, opts("Open: Horizontal Split")) +end + +-- git support in nvimtree +M.nvimtree = { + git = { + enable = true, + }, + + on_attach = nvimtree_attach, + + renderer = { + highlight_git = true, + icons = { + show = { + git = true, + }, + }, + }, +} + +M.cmp = { + mapping = { + [""] = require("cmp").mapping.complete(), + [""] = require("cmp").mapping.close(), + [""] = require("cmp").mapping.confirm({ + behavior = require("cmp").ConfirmBehavior.Replace, + select = true, + }), + }, +} + +return M diff --git a/general/custom/highlights.lua b/general/custom/highlights.lua new file mode 100644 index 0000000..8105f26 --- /dev/null +++ b/general/custom/highlights.lua @@ -0,0 +1,19 @@ +-- To find any highlight groups: " Telescope highlights" +-- Each highlight group can take a table with variables fg, bg, bold, italic, etc +-- base30 variable names can also be used as colors + +local M = {} + +---@type Base46HLGroupsList +M.override = { + Comment = { + italic = true, + }, +} + +---@type HLTable +M.add = { + NvimTreeOpenedFolderName = { fg = "green", bold = true }, +} + +return M diff --git a/general/nvim/after/plugin/markdown-preview.rc.lua b/general/custom/init.lua similarity index 100% rename from general/nvim/after/plugin/markdown-preview.rc.lua rename to general/custom/init.lua diff --git a/general/custom/mappings.lua b/general/custom/mappings.lua new file mode 100644 index 0000000..29887ec --- /dev/null +++ b/general/custom/mappings.lua @@ -0,0 +1,115 @@ +---@type MappingsTable +local M = {} + +M.general = { + n = { + [";"] = { + ":", + "enter command mode", + opts = { nowait = true }, + }, + [""] = { "ggG", "Select All" }, + -- Window + [""] = { "<" }, + [""] = { ">", "" }, + [""] = { "+", "" }, + [""] = { "-", "" }, + [""] = { "w", "" }, + + -- Telescope + [""] = { ":Telescope find_files", "Find file" }, + [""] = { ":Telescope live_grep", "Fuzzy find" }, + + ["q"] = { "q", "Quit" }, + ["o"] = { "AerialToggle", "Outline" }, + ["e"] = { "NvimTreeToggle", "Explorer" }, + ["f"] = { "Telescope current_buffer_fuzzy_find", "Find" }, + + [""] = { + function() + require("nvterm.terminal").toggle("horizontal") + end, + "Toggle horizontal term", + }, + }, + v = { + [">"] = { ">gv", "indent" }, + }, + t = { + [""] = { + function() + require("nvterm.terminal").toggle("horizontal") + end, + "Toggle horizontal term", + }, + [""] = { + "", + }, + }, +} + +M.copilot = { + i = { + [""] = { + function() + vim.fn.feedkeys(vim.fn["copilot#Accept"](), "") + end, + "Copilot Accept", + { replace_keycodes = true, nowait = true, silent = true, expr = true, noremap = true }, + }, + }, +} + +M.lsp = { + n = { + ["lf"] = { "lua vim.lsp.buf.format()", "Format" }, + ["lr"] = { "lua vim.lsp.buf.rename()", "Rename" }, + ["ld"] = { "lua vim.lsp.diagnostic.show_line_diagnostics()", "Line diagnostics" }, + ["lp"] = { "lua vim.lsp.diagnostic.goto_prev()", "Previous diagnostic" }, + ["ln"] = { "lua vim.lsp.diagnostic.goto_next()", "Next diagnostic" }, + }, +} + +M.gitsigns = { + n = { + ["]c"] = { + function() + if vim.wo.diff then + return "[c" + end + vim.schedule(function() + require("gitsigns").prev_hunk() + end) + return "" + end, + "Next hunk", + { expr = true }, + }, + ["[c"] = { + function() + if vim.wo.diff then + return "]c" + end + vim.schedule(function() + require("gitsigns").next_hunk() + end) + return "" + end, + "Previous hunk", + { expr = true }, + }, + ["gs"] = { "lua require'gitsigns'.stage_hunk()", "Stage hunk" }, + ["gr"] = { "lua require'gitsigns'.reset_hunk()", "Reset hunk" }, + ["gS"] = { "lua require'gitsigns'.stage_buffer()", "Stage buffer" }, + ["gu"] = { "lua require'gitsigns'.undo_stage_hunk()", "Undo stage hunk" }, + ["gR"] = { "lua require'gitsigns'.reset_buffer()", "Reset buffer" }, + ["gp"] = { "lua require'gitsigns'.preview_hunk()", "Preview hunk" }, + ["gb"] = { "lua require'gitsigns'.blame_line()", "Blame line" }, + ["gt"] = { "lua require'gitsigns'.toggle_current_line_blame()", "Toggle current line blame" }, + ["gd"] = { "lua require'gitsigns'.diffthis()", "Diff this" }, + ["gD"] = { "lua require'gitsigns'.diffthis()", "Diff this (vertical split)" }, + }, +} + +-- more keybinds! +return M diff --git a/general/custom/plugins.lua b/general/custom/plugins.lua new file mode 100644 index 0000000..ead05df --- /dev/null +++ b/general/custom/plugins.lua @@ -0,0 +1,64 @@ +local overrides = require("custom.configs.overrides") + +---@type NvPluginSpec[] +local plugins = { -- Override plugin definition options + { + "neovim/nvim-lspconfig", + dependencies = { -- format & linting + { + "jose-elias-alvarez/null-ls.nvim", + config = function() + require("custom.configs.null-ls") + end, + }, + }, + config = function() + require("plugins.configs.lspconfig") + require("custom.configs.lspconfig") + end, -- Override to setup mason-lspconfig + }, -- override plugin configs + { + "williamboman/mason.nvim", + opts = overrides.mason, + }, + { + "nvim-treesitter/nvim-treesitter", + opts = overrides.treesitter, + }, + { + "nvim-tree/nvim-tree.lua", + opts = overrides.nvimtree, + }, -- Install a plugin + { + "hrsh7th/nvim-cmp", + opts = overrides.cmp, + }, + { + "max397574/better-escape.nvim", + event = "InsertEnter", + config = function() + require("better_escape").setup() + end, + }, + { + "iamcco/markdown-preview.nvim", + run = function() + vim.fn["mkdp#util#install"]() + end, + }, + { + "github/copilot.vim", + lazy = false, + config = function() + vim.g.copilot_no_tab_map = true; + vim.g.copilot_assume_mapped = true; + -- vim.g.copilot_tab_fallback = ""; + end + }, + { + "Pocco81/auto-save.nvim", + lazy = false, + }, +} + +return plugins diff --git a/general/nvim/after/plugin/aerial.rc.lua b/general/nvim/after/plugin/aerial.rc.lua deleted file mode 100644 index 7688b2c..0000000 --- a/general/nvim/after/plugin/aerial.rc.lua +++ /dev/null @@ -1,4 +0,0 @@ -local status, aerial = pcall(require, "aerial") -if (not status) then return end - -aerial.setup() \ No newline at end of file diff --git a/general/nvim/after/plugin/autopairs.rc.lua b/general/nvim/after/plugin/autopairs.rc.lua deleted file mode 100644 index 44d8dbb..0000000 --- a/general/nvim/after/plugin/autopairs.rc.lua +++ /dev/null @@ -1,7 +0,0 @@ -local status, autopairs = pcall(require, "nvim-autopairs") -if (not status) then return end - -autopairs.setup({ - disable_filetype = { "TelescopePrompt" , "vim" }, -}) - diff --git a/general/nvim/after/plugin/bufferline.rc.lua b/general/nvim/after/plugin/bufferline.rc.lua deleted file mode 100644 index 5b070c5..0000000 --- a/general/nvim/after/plugin/bufferline.rc.lua +++ /dev/null @@ -1,33 +0,0 @@ -local status, bufferline = pcall(require, "bufferline") -if (not status) then return end - -bufferline.setup({ - options = { - mode = "tabs", - separator_style = 'slant', - always_show_bufferline = false, - show_buffer_close_icons = false, - show_close_icon = false, - color_icons = true - }, - highlights = { - separator = { - fg = '#073642', - bg = '#002b36', - }, - separator_selected = { - fg = '#073642', - }, - background = { - fg = '#657b83', - bg = '#002b36' - }, - buffer_selected = { - fg = '#fdf6e3', - bold = true, - }, - fill = { - bg = '#073642' - } - }, -}) diff --git a/general/nvim/after/plugin/cmp.rc.lua b/general/nvim/after/plugin/cmp.rc.lua deleted file mode 100644 index 43e7b02..0000000 --- a/general/nvim/after/plugin/cmp.rc.lua +++ /dev/null @@ -1,38 +0,0 @@ -local status, cmp = pcall(require, "cmp") -if (not status) then return end -local lspkind = require 'lspkind' - -cmp.setup({ - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true - }), - }), - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'buffer' }, - { name = 'path' }, - }), - formatting = { - format = lspkind.cmp_format({ with_text = false, maxwidth = 50 }) - } -}) - -vim.cmd [[ - set completeopt=menuone,noinsert,noselect - highlight! default link CmpItemKind CmpItemMenuDefault -]] - --- " Use and to navigate through popup menu --- inoremap pumvisible() ? "\" : "\" --- inoremap pumvisible() ? "\" : "\" diff --git a/general/nvim/after/plugin/colorizer.rc.lua b/general/nvim/after/plugin/colorizer.rc.lua deleted file mode 100644 index 14d25e2..0000000 --- a/general/nvim/after/plugin/colorizer.rc.lua +++ /dev/null @@ -1,6 +0,0 @@ -local status, colorizer = pcall(require, "colorizer") -if (not status) then return end - -colorizer.setup({ - '*'; -}) diff --git a/general/nvim/after/plugin/colorscheme.lua b/general/nvim/after/plugin/colorscheme.lua deleted file mode 100644 index d45ec36..0000000 --- a/general/nvim/after/plugin/colorscheme.lua +++ /dev/null @@ -1,3 +0,0 @@ --- silent! colorscheme hybrid - -vim.cmd('silent! colorscheme hybrid') diff --git a/general/nvim/after/plugin/dap.rc.lua b/general/nvim/after/plugin/dap.rc.lua deleted file mode 100644 index e8844f8..0000000 --- a/general/nvim/after/plugin/dap.rc.lua +++ /dev/null @@ -1,43 +0,0 @@ -local status, dap = pcall(require, "dap") -if (not status) then return end - --- load .vscode/launch.json -require("dap.ext.vscode").load_launchjs() - -local status, dapui = pcall(require, "dapui") -if (not status) then return end - -dapui.setup() - -if (not status) then return end -dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open() -end --- dap.listeners.before.event_terminated["dapui_config"] = function() --- dapui.close() --- end --- dap.listeners.before.event_exited["dapui_config"] = function() --- dapui.close() --- end - -local status, dappython = pcall(require, "dap-python") -if (not status) then return end -dappython.setup('python') -dappython.test_runner = 'pytest' - --- add keymaps -vim.api.nvim_set_keymap('n', '', "lua require'dap'.continue()", {noremap = true, silent = true}) -vim.api.nvim_set_keymap('n', '', "lua require'dap'.step_over()", {noremap = true, silent = true}) -vim.api.nvim_set_keymap('n', '', "lua require'dap'.step_into()", {noremap = true, silent = true}) -vim.api.nvim_set_keymap('n', '', "lua require'dap'.step_out()", {noremap = true, silent = true}) -vim.api.nvim_set_keymap('n', 'b', "lua require'dap'.toggle_breakpoint()", {noremap = true, silent = true}) -vim.api.nvim_set_keymap('n', 'B', "lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))", {noremap = true, silent = true}) -vim.api.nvim_set_keymap('n', 'dp', "lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))", {noremap = true, silent = true}) -vim.api.nvim_set_keymap('n', 'dr', "lua require'dap'.repl.open()", {noremap = true, silent = true}) -vim.api.nvim_set_keymap('n', 'dl', "lua require'dap'.run_last()", {noremap = true, silent = true}) -vim.api.nvim_set_keymap('n', 'dn', "lua require('dap-python').test_method()", {noremap = true, silent = true}) -vim.api.nvim_set_keymap('n', 'df', "lua require('dap-python').test_class()", {noremap = true, silent = true}) -vim.api.nvim_set_keymap('v', 'ds', "lua require('dap-python').debug_selection()", {noremap = true, silent = true}) - --- key map dapui.close -vim.api.nvim_set_keymap('n', 'dc', "lua require'dapui'.close()", {noremap = true, silent = true}) diff --git a/general/nvim/after/plugin/git.rc.lua b/general/nvim/after/plugin/git.rc.lua deleted file mode 100644 index 963f7f9..0000000 --- a/general/nvim/after/plugin/git.rc.lua +++ /dev/null @@ -1,11 +0,0 @@ -local status, git = pcall(require, "git") -if (not status) then return end - -git.setup({ - keymaps = { - -- Open blame window - blame = "gb", - -- Open file/folder in git repository - browse = "go", - } -}) diff --git a/general/nvim/after/plugin/gitsigns.rc.lua b/general/nvim/after/plugin/gitsigns.rc.lua deleted file mode 100644 index cd23272..0000000 --- a/general/nvim/after/plugin/gitsigns.rc.lua +++ /dev/null @@ -1,62 +0,0 @@ -local status, gitsigns = pcall(require, "gitsigns") -if (not status) then return end - -local status, wk = pcall(require, "which-key") -if (not status) then return end - -gitsigns.setup { - on_attach = function(bufnr) - local gs = package.loaded.gitsigns - -- Navigation - vim.keymap.set('n', ']c', function() - if vim.wo.diff then return '[c' end - vim.schedule(function() gs.prev_hunk() end) - return '' - end, { expr = true, buffer = bufnr }) - - vim.keymap.set('n', '[c', function() - if vim.wo.diff then return ']c' end - vim.schedule(function() gs.next_hunk() end) - return '' - end, { expr = true, buffer = bufnr }) - - -- Text object - vim.keymap.set({ 'o', 'x' }, 'ih', function() - if vim.wo.diff then return 'ih' end - return 'lua require"gitsigns".select_hunk()' - end, { expr = true, buffer = bufnr }) - - wk.register({ - h = { - name = "+hunk", - s = { gs.stage_hunk, "Stage hunk" }, - r = { gs.reset_hunk, "Reset hunk" }, - S = { gs.stage_buffer, "Stage buffer" }, - u = { gs.undo_stage_hunk, "Undo stage hunk" }, - R = { gs.reset_buffer, "Reset buffer" }, - p = { gs.preview_hunk, "Preview hunk" }, - b = { gs.blame_line, "Blame line" }, - t = { gs.toggle_current_line_blame, "Toggle current line blame" }, - d = { gs.diffthis, "Diff this" }, - D = { gs.diffthis, "Diff this (vertical split)" }, - }, - }, { prefix = "", mode = "n", buffer = bufnr }) - - wk.register({ - t = { - name = "+toggle", - b = { gs.toggle_current_line_blame, "Toggle current line blame" }, - d = { gs.toggle_deleted, "Toggle deleted" }, - }, - }, { prefix = "", mode = "n", buffer = bufnr }) - - -- visual mode mappings - wk.register({ - h = { - name = "+hunk", - s = { function() gs.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end, "Stage hunk" }, - r = { function() gs.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end, "Reset hunk" }, - }, - }, { prefix = "", mode = "v", buffer = bufnr }) - end -} diff --git a/general/nvim/after/plugin/lsp-colors.rc.lua b/general/nvim/after/plugin/lsp-colors.rc.lua deleted file mode 100644 index 1398123..0000000 --- a/general/nvim/after/plugin/lsp-colors.rc.lua +++ /dev/null @@ -1,9 +0,0 @@ -local status, colors = pcall(require, "lsp-colors") -if (not status) then return end - -colors.setup { - Error = "#db4b4b", - Warning = "#e0af68", - Information = "#0db9d7", - Hint = "#10B981" -} diff --git a/general/nvim/after/plugin/lspkind.rc.lua b/general/nvim/after/plugin/lspkind.rc.lua deleted file mode 100644 index 72ca5c2..0000000 --- a/general/nvim/after/plugin/lspkind.rc.lua +++ /dev/null @@ -1,47 +0,0 @@ -local status, lspkind = pcall(require, "lspkind") -if (not status) then return end - -lspkind.init({ - -- enables text annotations - -- - -- default: true - mode = 'symbol', - - -- default symbol map - -- can be either 'default' (requires nerd-fonts font) or - -- 'codicons' for codicon preset (requires vscode-codicons font) - -- - -- default: 'default' - preset = 'codicons', - - -- override preset symbols - -- - -- default: {} - symbol_map = { - Text = "", - Method = "", - Function = "", - Constructor = "", - Field = "ﰠ", - Variable = "", - Class = "ﴯ", - Interface = "", - Module = "", - Property = "ﰠ", - Unit = "塞", - Value = "", - Enum = "", - Keyword = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "פּ", - Event = "", - Operator = "", - TypeParameter = "" - }, -}) diff --git a/general/nvim/after/plugin/lualine.rc.lua b/general/nvim/after/plugin/lualine.rc.lua deleted file mode 100644 index 89ec5c5..0000000 --- a/general/nvim/after/plugin/lualine.rc.lua +++ /dev/null @@ -1,43 +0,0 @@ -local status, lualine = pcall(require, "lualine") -if (not status) then return end - -lualine.setup { - options = { - icons_enabled = true, - theme = 'solarized_dark', - section_separators = { left = '', right = '' }, - component_separators = { left = '', right = '' }, - disabled_filetypes = {} - }, - sections = { - lualine_a = { 'mode' }, - lualine_b = { 'branch' }, - lualine_c = { { - 'filename', - file_status = true, -- displays file status (readonly status, modified status) - path = 0 -- 0 = just filename, 1 = relative path, 2 = absolute path - } }, - lualine_x = { - { 'diagnostics', sources = { "nvim_diagnostic" }, symbols = { error = ' ', warn = ' ', info = ' ', - hint = ' ' } }, - 'encoding', - 'filetype' - }, - lualine_y = { 'progress' }, - lualine_z = { 'location' } - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { { - 'filename', - file_status = true, -- displays file status (readonly status, modified status) - path = 1 -- 0 = just filename, 1 = relative path, 2 = absolute path - } }, - lualine_x = { 'location' }, - lualine_y = {}, - lualine_z = {} - }, - tabline = {}, - extensions = { 'fugitive' } -} diff --git a/general/nvim/after/plugin/mason.rc.lua b/general/nvim/after/plugin/mason.rc.lua deleted file mode 100644 index 03c4a58..0000000 --- a/general/nvim/after/plugin/mason.rc.lua +++ /dev/null @@ -1,12 +0,0 @@ -local status, mason = pcall(require, "mason") -if (not status) then return end -local status2, lspconfig = pcall(require, "mason-lspconfig") -if (not status2) then return end - -mason.setup({ - -}) - -lspconfig.setup { - automatic_installation = true -} diff --git a/general/nvim/after/plugin/neotest.rc.lua b/general/nvim/after/plugin/neotest.rc.lua deleted file mode 100644 index e1aad1b..0000000 --- a/general/nvim/after/plugin/neotest.rc.lua +++ /dev/null @@ -1,39 +0,0 @@ -local status, neotest = pcall(require, "neotest") -if (not status) then return end - -local status, neotest_python = pcall(require, "neotest-python") -if (not status) then return end - --- if windows use .venv/Scripts/python.exe --- else use .venv/bin/python --- local python = vim.fn.has("win32") == 1 and ".venv\\Scripts\\python.exe" or ".venv/bin/python" - -require("neotest").setup({ - adapters = { - require("neotest-python")({ - -- Extra arguments for nvim-dap configuration - -- See https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for values - dap = { justMyCode = false }, - -- Command line arguments for runner - -- Can also be a function to return dynamic values - args = {"--log-level", "DEBUG"}, - -- Runner to use. Will use pytest if available by default. - -- Can be a function to return dynamic value. - runner = "pytest", - -- Custom python path for the runner. - -- Can be a string or a list of strings. - -- Can also be a function to return dynamic value. - -- If not provided, the path will be inferred by checking for - -- virtual envs in the local directory and for Pipenev/Poetry configs - python = "python", - -- Returns if a given file path is a test file. - -- NB: This function is called a lot so don't perform any heavy tasks within it. - is_test_file = function(file_path) - -- if start with test_ - return file_path:match("test_.*%.py$") ~= nil - end, - }) - } - }) - - vim.api.nvim_set_keymap("n", "tn", "lua require('neotest').run.run(vim.fn.expand('%'))", { noremap = true, silent = true }) \ No newline at end of file diff --git a/general/nvim/after/plugin/nvim-comment.rc.lua b/general/nvim/after/plugin/nvim-comment.rc.lua deleted file mode 100644 index eb1e530..0000000 --- a/general/nvim/after/plugin/nvim-comment.rc.lua +++ /dev/null @@ -1,11 +0,0 @@ -local status_ok, nvim_comment = pcall(require, "nvim_comment") -if (not status_ok) then return end - -nvim_comment.setup({ - marker_padding = true, - comment_empty = false, - create_mappings = false, - line_mapping = "gcc", - operator_mapping = "gc", - hook = nil, -}) diff --git a/general/nvim/after/plugin/nvim-tree.rc.lua b/general/nvim/after/plugin/nvim-tree.rc.lua deleted file mode 100644 index 244c52f..0000000 --- a/general/nvim/after/plugin/nvim-tree.rc.lua +++ /dev/null @@ -1,80 +0,0 @@ -local status_ok, nvim_tree = pcall(require, "nvim-tree") -if not status_ok then - return -end - -local function my_on_attach(bufnr) - local api = require('nvim-tree.api') - - local function opts(desc) - return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } - end - - api.config.mappings.default_on_attach(bufnr) - - vim.keymap.set('n', 'l', api.node.open.edit, opts("Open")) - vim.keymap.set('n', 'v', api.node.open.vertical, opts("Open: Vertical Split")) - vim.keymap.set('n', 'h', api.node.open.horizontal, opts('Open: Horizontal Split')) -end - -nvim_tree.setup { - update_focused_file = { - enable = true, - update_cwd = false, - }, - on_attach = my_on_attach, - renderer = { - root_folder_modifier = ":t", - icons = { - glyphs = { - default = "", - symlink = "", - folder = { - arrow_open = "", - arrow_closed = "", - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - symlink_open = "", - }, - git = { - unstaged = "", - staged = "S", - unmerged = "", - renamed = "➜", - untracked = "U", - deleted = "", - ignored = "◌", - }, - }, - }, - }, - diagnostics = { - enable = false, - show_on_dirs = false, - icons = { - hint = "", - info = "", - warning = "", - error = "", - }, - }, - view = { - width = 30, - side = "left", - }, - filters = { - dotfiles = true, - exclude = { ".vscode", ".git*", ".env", ".dockerignore" }, - custom = { - "__pycache__", - }, - }, - git = { - enable = true, - ignore = false, - timeout = 500, - }, -} diff --git a/general/nvim/after/plugin/telescope.rc.lua b/general/nvim/after/plugin/telescope.rc.lua deleted file mode 100644 index 78c797c..0000000 --- a/general/nvim/after/plugin/telescope.rc.lua +++ /dev/null @@ -1,19 +0,0 @@ -local status, telescope = pcall(require, "telescope") -if (not status) then return end -local actions = require('telescope.actions') -local builtin = require("telescope.builtin") - -local function telescope_buffer_dir() - return vim.fn.expand('%:p:h') -end - -telescope.setup { - defaults = { - mappings = { - n = { - ["q"] = actions.close - }, - }, - }, - extensions = {}, -} diff --git a/general/nvim/after/plugin/toggleterm.rc.lua b/general/nvim/after/plugin/toggleterm.rc.lua deleted file mode 100644 index 78db0e7..0000000 --- a/general/nvim/after/plugin/toggleterm.rc.lua +++ /dev/null @@ -1,45 +0,0 @@ -local status_ok, toggleterm = pcall(require, "toggleterm") -if not status_ok then - return -end - -if vim.fn.has('win32') == 1 or vim.fn.has('win64') == 1 then - shell = 'pwsh' -else - shell = 'fish' -end - -toggleterm.setup({ - size = 20, - open_mapping = [[]], - hide_numbers = true, - shade_filetypes = {}, - shade_terminals = true, - shading_factor = 2, - start_in_insert = true, - insert_mappings = true, - persist_size = true, - direction = "horizontal", - close_on_exit = true, - shell = shell, - float_opts = { - border = "curved", - winblend = 0, - highlights = { - border = "Normal", - background = "Normal", - }, - }, -}) - -function _G.set_terminal_keymaps() - local opts = {noremap = true} - vim.api.nvim_buf_set_keymap(0, 't', '', [[]], opts) - vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[]], opts) - vim.api.nvim_buf_set_keymap(0, 't', '', [[h]], opts) - vim.api.nvim_buf_set_keymap(0, 't', '', [[j]], opts) - vim.api.nvim_buf_set_keymap(0, 't', '', [[k]], opts) - vim.api.nvim_buf_set_keymap(0, 't', '', [[l]], opts) -end - -vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') diff --git a/general/nvim/after/plugin/treesitter.rc.lua b/general/nvim/after/plugin/treesitter.rc.lua deleted file mode 100644 index 117c953..0000000 --- a/general/nvim/after/plugin/treesitter.rc.lua +++ /dev/null @@ -1,24 +0,0 @@ -local status, ts = pcall(require, "nvim-treesitter.configs") -if (not status) then return end - -require("nvim-treesitter.install").compilers = { vim.fn.getenv "CC", "cc", "gcc", "clang", "cl", "zig" } - -ts.setup { - highlight = { - enable = true, - disable = {}, - }, - indent = { - enable = true, - disable = {}, - }, - ensure_installed = { - "fish", - "lua", - "python", - "cpp", - }, - autotag = { - enable = true, - }, -} diff --git a/general/nvim/after/plugin/web-devicons.rc.lua b/general/nvim/after/plugin/web-devicons.rc.lua deleted file mode 100644 index b8396bc..0000000 --- a/general/nvim/after/plugin/web-devicons.rc.lua +++ /dev/null @@ -1,12 +0,0 @@ -local status, icons = pcall(require, "nvim-web-devicons") -if (not status) then return end - -icons.setup { - -- your personnal icons can go here (to override) - -- DevIcon will be appended to `name` - override = { - }, - -- globally enable default icons (default to false) - -- will get overriden by `get_icons` option - default = true -} diff --git a/general/nvim/init.lua b/general/nvim/init.lua deleted file mode 100644 index f0b8ead..0000000 --- a/general/nvim/init.lua +++ /dev/null @@ -1,17 +0,0 @@ -require('user.base') -require('user.highlights') -require('user.maps') -require('user.plugins') -require('user.lsp') - -local has = vim.fn.has -local is_mac = has "macunix" -local is_win = has "win32" - -if is_mac then - require('user.macos') -end -if is_win then - require('user.windows') -end - diff --git a/general/nvim/lua/user/base.lua b/general/nvim/lua/user/base.lua deleted file mode 100644 index 5578fef..0000000 --- a/general/nvim/lua/user/base.lua +++ /dev/null @@ -1,46 +0,0 @@ -vim.cmd("autocmd!") - -vim.scriptencoding = 'utf-8' -vim.opt.encoding = 'utf-8' -vim.opt.fileencoding = 'utf-8' - -vim.wo.number = true -vim.opt.swapfile = false - -vim.opt.title = true -vim.opt.autoindent = true -vim.opt.smartindent = true -vim.opt.hlsearch = true -vim.opt.backup = false -vim.opt.showcmd = true -vim.opt.cmdheight = 1 -vim.opt.laststatus = 2 -vim.opt.expandtab = true -vim.opt.scrolloff = 10 -vim.opt.backupskip = { '/tmp/*', '/private/tmp/*' } -vim.opt.inccommand = 'split' -vim.opt.ignorecase = true -- Case insensitive searching UNLESS /C or capital in search -vim.opt.smarttab = true -vim.opt.breakindent = true -vim.opt.shiftwidth = 2 -vim.opt.tabstop = 2 -vim.opt.wrap = false -- No Wrap lines -vim.opt.backspace = { 'start', 'eol', 'indent' } -vim.opt.path:append { '**' } -- Finding files - Search down into subfolders -vim.opt.wildignore:append { '*/node_modules/*' } - --- Undercurl -vim.cmd([[let &t_Cs = "\e[4:3m"]]) -vim.cmd([[let &t_Ce = "\e[4:0m"]]) - --- Turn off paste mode when leaving insert -vim.api.nvim_create_autocmd("InsertLeave", { - pattern = '*', - command = "set nopaste" -}) - --- Add asterisks in block comments -vim.opt.formatoptions:append { 'r' } - --- Share clipboard with system -vim.opt.clipboard = 'unnamedplus' diff --git a/general/nvim/lua/user/highlights.lua b/general/nvim/lua/user/highlights.lua deleted file mode 100644 index 8e97e5a..0000000 --- a/general/nvim/lua/user/highlights.lua +++ /dev/null @@ -1,6 +0,0 @@ -vim.opt.cursorline = true -vim.opt.termguicolors = true -vim.opt.winblend = 0 -vim.opt.wildoptions = 'pum' -vim.opt.pumblend = 5 -vim.opt.background = 'dark' diff --git a/general/nvim/lua/user/lsp/handlers.lua b/general/nvim/lua/user/lsp/handlers.lua deleted file mode 100644 index 04fee81..0000000 --- a/general/nvim/lua/user/lsp/handlers.lua +++ /dev/null @@ -1,93 +0,0 @@ -local M = {} - -local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") -if not status_cmp_ok then - return -end - -M.capabilities = vim.lsp.protocol.make_client_capabilities() -M.capabilities.textDocument.completion.completionItem.snippetSupport = true -M.capabilities = cmp_nvim_lsp.default_capabilities(M.capabilities) - -M.setup = function() - local signs = { - - { name = "DiagnosticSignError", text = "" }, - { name = "DiagnosticSignWarn", text = "" }, - { name = "DiagnosticSignHint", text = "" }, - { name = "DiagnosticSignInfo", text = "" }, - } - - for _, sign in ipairs(signs) do - vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) - end - - local config = { - virtual_text = false, -- disable virtual text - signs = { - active = signs, -- show signs - }, - update_in_insert = true, - underline = true, - severity_sort = true, - float = { - focusable = true, - style = "minimal", - border = "rounded", - source = "always", - header = "", - prefix = "", - }, - } - - vim.diagnostic.config(config) - - vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - border = "rounded", - }) - - vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - border = "rounded", - }) -end - -local function lsp_keymaps(bufnr) - local opts = { noremap = true, silent = true } - local keymap = vim.api.nvim_buf_set_keymap - keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) - keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) - keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) - keymap(bufnr, "n", "gI", "lua vim.lsp.buf.implementation()", opts) - keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) - keymap(bufnr, "n", "gl", "lua vim.diagnostic.open_float()", opts) - keymap(bufnr, "n", "lf", "lua vim.lsp.buf.format()", opts) - keymap(bufnr, "n", "li", "LspInfo", opts) - keymap(bufnr, "n", "lI", "LspInstallInfo", opts) - keymap(bufnr, "n", "lR", "LspRestart", opts) - keymap(bufnr, "n", "la", "lua vim.lsp.buf.code_action()", opts) - keymap(bufnr, "n", "lj", "lua vim.diagnostic.goto_next({buffer=0})", opts) - keymap(bufnr, "n", "lk", "lua vim.diagnostic.goto_prev({buffer=0})", opts) - keymap(bufnr, "n", "ld", "lua vim.diagnostic.open_float(0, {scope='line'})", opts) - keymap(bufnr, "n", "lr", "lua vim.lsp.buf.rename()", opts) - keymap(bufnr, "n", "ls", "lua vim.lsp.buf.signature_help()", opts) - keymap(bufnr, "n", "lq", "lua vim.diagnostic.setloclist()", opts) -end - -M.on_attach = function(client, bufnr) - if client.name == "tsserver" then - client.server_capabilities.documentFormattingProvider = false - end - - if client.name == "sumneko_lua" then - client.server_capabilities.documentFormattingProvider = false - end - - lsp_keymaps(bufnr) - local status_ok, illuminate = pcall(require, "illuminate") - if not status_ok then - return - end - illuminate.on_attach(client) -end - -return M diff --git a/general/nvim/lua/user/lsp/init.lua b/general/nvim/lua/user/lsp/init.lua deleted file mode 100644 index c8eef0f..0000000 --- a/general/nvim/lua/user/lsp/init.lua +++ /dev/null @@ -1,8 +0,0 @@ -local status_ok, _ = pcall(require, "lspconfig") -if not status_ok then - return -end - -require "user.lsp.mason" -require("user.lsp.handlers").setup() -require "user.lsp.null-ls" diff --git a/general/nvim/lua/user/lsp/mason.lua b/general/nvim/lua/user/lsp/mason.lua deleted file mode 100644 index 5e619f5..0000000 --- a/general/nvim/lua/user/lsp/mason.lua +++ /dev/null @@ -1,49 +0,0 @@ -local servers = { - "lua_ls", - "pyright", - "bashls", - "jsonls", - "yamlls", -} - -local settings = { - ui = { - border = "none", - icons = { - package_installed = "◍", - package_pending = "◍", - package_uninstalled = "◍", - }, - }, - log_level = vim.log.levels.INFO, - max_concurrent_installers = 4, -} - -require("mason").setup(settings) -require("mason-lspconfig").setup({ - ensure_installed = servers, - automatic_installation = true, -}) - -local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig") -if not lspconfig_status_ok then - return -end - -local opts = {} - -for _, server in pairs(servers) do - opts = { - on_attach = require("user.lsp.handlers").on_attach, - capabilities = require("user.lsp.handlers").capabilities, - } - - server = vim.split(server, "@")[1] - - local require_ok, conf_opts = pcall(require, "user.lsp.settings." .. server) - if require_ok then - opts = vim.tbl_deep_extend("force", conf_opts, opts) - end - - lspconfig[server].setup(opts) -end diff --git a/general/nvim/lua/user/lsp/null-ls.lua b/general/nvim/lua/user/lsp/null-ls.lua deleted file mode 100644 index 43ad8be..0000000 --- a/general/nvim/lua/user/lsp/null-ls.lua +++ /dev/null @@ -1,21 +0,0 @@ -local null_ls_status_ok, null_ls = pcall(require, "null-ls") -if not null_ls_status_ok then - return -end - --- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting -local formatting = null_ls.builtins.formatting --- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics -local diagnostics = null_ls.builtins.diagnostics - -null_ls.setup({ - debug = false, - sources = { - formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }), - formatting.black.with({ extra_args = { "--fast" } }), - formatting.stylua, - formatting.isort, - formatting.autoflake.with({ extra_args = { "--remove-all-unused-imports", "--remove-unused-variables" } }), - -- formatting.pyflyby, - }, -}) diff --git a/general/nvim/lua/user/lsp/settings/jsonls.lua b/general/nvim/lua/user/lsp/settings/jsonls.lua deleted file mode 100644 index e202e1e..0000000 --- a/general/nvim/lua/user/lsp/settings/jsonls.lua +++ /dev/null @@ -1,197 +0,0 @@ -local default_schemas = nil -local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls") -if status_ok then - default_schemas = jsonls_settings.get_default_schemas() -end - -local schemas = { - { - description = "TypeScript compiler configuration file", - fileMatch = { - "tsconfig.json", - "tsconfig.*.json", - }, - url = "https://json.schemastore.org/tsconfig.json", - }, - { - description = "Lerna config", - fileMatch = { "lerna.json" }, - url = "https://json.schemastore.org/lerna.json", - }, - { - description = "Babel configuration", - fileMatch = { - ".babelrc.json", - ".babelrc", - "babel.config.json", - }, - url = "https://json.schemastore.org/babelrc.json", - }, - { - description = "ESLint config", - fileMatch = { - ".eslintrc.json", - ".eslintrc", - }, - url = "https://json.schemastore.org/eslintrc.json", - }, - { - description = "Bucklescript config", - fileMatch = { "bsconfig.json" }, - url = "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/8.2.0/docs/docson/build-schema.json", - }, - { - description = "Prettier config", - fileMatch = { - ".prettierrc", - ".prettierrc.json", - "prettier.config.json", - }, - url = "https://json.schemastore.org/prettierrc", - }, - { - description = "Vercel Now config", - fileMatch = { "now.json" }, - url = "https://json.schemastore.org/now", - }, - { - description = "Stylelint config", - fileMatch = { - ".stylelintrc", - ".stylelintrc.json", - "stylelint.config.json", - }, - url = "https://json.schemastore.org/stylelintrc", - }, - { - description = "A JSON schema for the ASP.NET LaunchSettings.json files", - fileMatch = { "launchsettings.json" }, - url = "https://json.schemastore.org/launchsettings.json", - }, - { - description = "Schema for CMake Presets", - fileMatch = { - "CMakePresets.json", - "CMakeUserPresets.json", - }, - url = "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json", - }, - { - description = "Configuration file as an alternative for configuring your repository in the settings page.", - fileMatch = { - ".codeclimate.json", - }, - url = "https://json.schemastore.org/codeclimate.json", - }, - { - description = "LLVM compilation database", - fileMatch = { - "compile_commands.json", - }, - url = "https://json.schemastore.org/compile-commands.json", - }, - { - description = "Config file for Command Task Runner", - fileMatch = { - "commands.json", - }, - url = "https://json.schemastore.org/commands.json", - }, - { - description = "AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment.", - fileMatch = { - "*.cf.json", - "cloudformation.json", - }, - url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/cloudformation.schema.json", - }, - { - description = "The AWS Serverless Application Model (AWS SAM, previously known as Project Flourish) extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.", - fileMatch = { - "serverless.template", - "*.sam.json", - "sam.json", - }, - url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/sam.schema.json", - }, - { - description = "Json schema for properties json file for a GitHub Workflow template", - fileMatch = { - ".github/workflow-templates/**.properties.json", - }, - url = "https://json.schemastore.org/github-workflow-template-properties.json", - }, - { - description = "golangci-lint configuration file", - fileMatch = { - ".golangci.toml", - ".golangci.json", - }, - url = "https://json.schemastore.org/golangci-lint.json", - }, - { - description = "JSON schema for the JSON Feed format", - fileMatch = { - "feed.json", - }, - url = "https://json.schemastore.org/feed.json", - versions = { - ["1"] = "https://json.schemastore.org/feed-1.json", - ["1.1"] = "https://json.schemastore.org/feed.json", - }, - }, - { - description = "Packer template JSON configuration", - fileMatch = { - "packer.json", - }, - url = "https://json.schemastore.org/packer.json", - }, - { - description = "NPM configuration file", - fileMatch = { - "package.json", - }, - url = "https://json.schemastore.org/package.json", - }, - { - description = "JSON schema for Visual Studio component configuration files", - fileMatch = { - "*.vsconfig", - }, - url = "https://json.schemastore.org/vsconfig.json", - }, - { - description = "Resume json", - fileMatch = { "resume.json" }, - url = "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json", - }, -} - -local function extend(tab1, tab2) - for _, value in ipairs(tab2 or {}) do - table.insert(tab1, value) - end - return tab1 -end - -local extended_schemas = extend(schemas, default_schemas) - -local opts = { - settings = { - json = { - schemas = extended_schemas, - }, - }, - setup = { - commands = { - Format = { - function() - vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) - end, - }, - }, - }, -} - -return opts diff --git a/general/nvim/lua/user/lsp/settings/pyright.lua b/general/nvim/lua/user/lsp/settings/pyright.lua deleted file mode 100644 index c2a518d..0000000 --- a/general/nvim/lua/user/lsp/settings/pyright.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - settings = { - python = { - analysis = { - typeCheckingMode = "off", - }, - }, - }, -} diff --git a/general/nvim/lua/user/macos.lua b/general/nvim/lua/user/macos.lua deleted file mode 100644 index 153bcbd..0000000 --- a/general/nvim/lua/user/macos.lua +++ /dev/null @@ -1 +0,0 @@ -vim.opt.clipboard:append { 'unnamedplus' } diff --git a/general/nvim/lua/user/maps.lua b/general/nvim/lua/user/maps.lua deleted file mode 100644 index 8d940b6..0000000 --- a/general/nvim/lua/user/maps.lua +++ /dev/null @@ -1,49 +0,0 @@ -vim.g.mapleader = " " -vim.g.maplocalleader = " " -local keymap = vim.keymap - --- Select all -keymap.set('n', '', 'ggG') --- Window Resize -keymap.set('n', '', '<') -keymap.set('n', '', '>') -keymap.set('n', '=', '+') -keymap.set('n', '-', '-') - --- Telescope -keymap.set('n', '', ':Telescope find_files') -keymap.set('n', '', ':Telescope live_grep') - --- nvim-comment -keymap.set('n', '/', ':CommentToggle') -keymap.set('v', '/', ':\'<,\'>CommentToggle') - -keymap.set('n', '', 'w') - -local leaderkeymap = { - s = { - name = '+split', - s = { "split", "Split" }, - v = { "vsplit", "VSplit" }, - }, - e = { "NvimTreeToggle", "Explorer" }, - f = { "Telescope current_buffer_fuzzy_find", "Find" }, - q = { "q", "Quit" }, - o = { "AerialToggle", "Outline" }, - -- set 1-9 as go to windows 0-9 - ["1"] = { "1wincmd w", "Go to window 1" }, - ["2"] = { "2wincmd w", "Go to window 2" }, - ["3"] = { "3wincmd w", "Go to window 3" }, - ["4"] = { "4wincmd w", "Go to window 4" }, - ["5"] = { "5wincmd w", "Go to window 5" }, - ["6"] = { "6wincmd w", "Go to window 6" }, - ["7"] = { "7wincmd w", "Go to window 7" }, - ["8"] = { "8wincmd w", "Go to window 8" }, - ["9"] = { "9wincmd w", "Go to window 9" }, - ["0"] = { "10wincmd w", "Go to window 10" }, -} - -local status, wk = pcall(require, "which-key") -if status then - wk.register(leaderkeymap, { prefix = "" }) -end diff --git a/general/nvim/lua/user/plugins.lua b/general/nvim/lua/user/plugins.lua deleted file mode 100644 index b83a25d..0000000 --- a/general/nvim/lua/user/plugins.lua +++ /dev/null @@ -1,85 +0,0 @@ -local status, packer = pcall(require, "packer") -if (not status) then - print("Packer is not installed") - return -end - -vim.cmd [[packadd packer.nvim]] - -packer.startup(function(use) - use 'wbthomason/packer.nvim' - use "rafi/awesome-vim-colorschemes" - use 'nvim-lualine/lualine.nvim' -- Statusline - use 'nvim-lua/plenary.nvim' -- Common utilities - use 'onsails/lspkind-nvim' -- vscode-like pictograms - use 'hrsh7th/cmp-buffer' -- nvim-cmp source for buffer words - use 'hrsh7th/cmp-nvim-lsp' -- nvim-cmp source for neovim's built-in LSP - use 'hrsh7th/cmp-path' -- nvim-cmp source for file paths - use 'hrsh7th/nvim-cmp' -- Completion - use 'neovim/nvim-lspconfig' -- LSP - use 'jose-elias-alvarez/null-ls.nvim' -- Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua - use 'williamboman/mason.nvim' - use 'williamboman/mason-lspconfig.nvim' - - use 'glepnir/lspsaga.nvim' -- LSP UIs - use 'L3MON4D3/LuaSnip' - use { - 'nvim-treesitter/nvim-treesitter', - run = function() require('nvim-treesitter.install').update({ with_sync = true }) end, - } - use 'kyazdani42/nvim-web-devicons' -- File icons - use 'nvim-telescope/telescope.nvim' - use 'nvim-telescope/telescope-file-browser.nvim' - use 'windwp/nvim-autopairs' - use 'norcalli/nvim-colorizer.lua' - use({ - "iamcco/markdown-preview.nvim", - run = function() vim.fn["mkdp#util#install"]() end, - }) - use 'github/copilot.vim' - use 'akinsho/nvim-bufferline.lua' - use 'lewis6991/gitsigns.nvim' - use 'dinhhuy258/git.nvim' -- For git blame & browse - use 'Pocco81/auto-save.nvim' - use { - 'glepnir/dashboard-nvim', - event = 'VimEnter', - config = function() - require('dashboard').setup {} - end, - requires = { 'nvim-tree/nvim-web-devicons' } - } - use { - 'nvim-tree/nvim-tree.lua', - requires = { - 'nvim-tree/nvim-web-devicons', -- optional, for file icons - }, - } - use 'ggandor/lightspeed.nvim' - use "terrortylor/nvim-comment" - -- Lua - use { - "folke/which-key.nvim", - config = function() - require("which-key").setup { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - } - end - } - use 'akinsho/toggleterm.nvim' - use 'stevearc/aerial.nvim' - use { "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } } - use "mfussenegger/nvim-dap-python" - - use { - "nvim-neotest/neotest", - requires = { - "nvim-lua/plenary.nvim", - "nvim-treesitter/nvim-treesitter", - "antoinemadec/FixCursorHold.nvim" - } - } - use 'nvim-neotest/neotest-python' -end) diff --git a/general/nvim/lua/user/windows.lua b/general/nvim/lua/user/windows.lua deleted file mode 100644 index 922fe72..0000000 --- a/general/nvim/lua/user/windows.lua +++ /dev/null @@ -1 +0,0 @@ -vim.opt.clipboard:prepend { 'unnamed', 'unnamedplus' } diff --git a/general/nvim/plugin/.gitignore b/general/nvim/plugin/.gitignore deleted file mode 100644 index d547881..0000000 --- a/general/nvim/plugin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -packer_compiled.lua From 525f821f6105faf8e52172304f7c5ac476e4a75e Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Mon, 23 Oct 2023 09:35:00 +0800 Subject: [PATCH 03/15] enable dash --- general/custom/chadrc.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/general/custom/chadrc.lua b/general/custom/chadrc.lua index b84c12b..6ed1f72 100644 --- a/general/custom/chadrc.lua +++ b/general/custom/chadrc.lua @@ -10,6 +10,10 @@ M.ui = { hl_override = highlights.override, hl_add = highlights.add, + + nvdash = { + load_on_startup = true, + } } M.plugins = "custom.plugins" From 6b1da554e1c33977d38127703d4c427928431910 Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Mon, 23 Oct 2023 10:40:56 +0800 Subject: [PATCH 04/15] add markdown preview --- general/custom/chadrc.lua | 4 ++-- general/custom/mappings.lua | 7 +++++++ general/custom/plugins.lua | 19 ++++++++++++------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/general/custom/chadrc.lua b/general/custom/chadrc.lua index 6ed1f72..c95def0 100644 --- a/general/custom/chadrc.lua +++ b/general/custom/chadrc.lua @@ -5,8 +5,8 @@ local M = {} local highlights = require("custom.highlights") M.ui = { - theme = "onedark", - theme_toggle = { "onedark", "one_light" }, + theme = "vscode_dark", + theme_toggle = { "blossom_light", "vscode_dark" }, hl_override = highlights.override, hl_add = highlights.add, diff --git a/general/custom/mappings.lua b/general/custom/mappings.lua index 29887ec..b1c3683 100644 --- a/general/custom/mappings.lua +++ b/general/custom/mappings.lua @@ -111,5 +111,12 @@ M.gitsigns = { }, } +M.peek = { + n = { + ["mo"] = { "lua require('peek').open()", "Markdown Preview" }, + ["mc"] = { "lua require('peek').close()", "Markdown Close" }, + }, +} + -- more keybinds! return M diff --git a/general/custom/plugins.lua b/general/custom/plugins.lua index ead05df..5b9a2ce 100644 --- a/general/custom/plugins.lua +++ b/general/custom/plugins.lua @@ -42,18 +42,23 @@ local plugins = { -- Override plugin definition options }, { "iamcco/markdown-preview.nvim", - run = function() - vim.fn["mkdp#util#install"]() + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = "cd app && npm install", + init = function() + vim.g.mkdp_filetypes = { "markdown" } + vim.g.mkdp_echo_preview_url = 1 + vim.g.mkdp_open_to_the_world = 1 end, + ft = { "markdown" }, }, { "github/copilot.vim", lazy = false, - config = function() - vim.g.copilot_no_tab_map = true; - vim.g.copilot_assume_mapped = true; - -- vim.g.copilot_tab_fallback = ""; - end + config = function() + vim.g.copilot_no_tab_map = true + vim.g.copilot_assume_mapped = true + -- vim.g.copilot_tab_fallback = ""; + end, }, { "Pocco81/auto-save.nvim", From 0e794c7eb73ae52a4c36fc0fd2948b253c42afd0 Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Mon, 23 Oct 2023 10:42:52 +0800 Subject: [PATCH 05/15] remap toggle terminal --- general/custom/mappings.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/general/custom/mappings.lua b/general/custom/mappings.lua index b1c3683..877ef43 100644 --- a/general/custom/mappings.lua +++ b/general/custom/mappings.lua @@ -25,7 +25,7 @@ M.general = { ["e"] = { "NvimTreeToggle", "Explorer" }, ["f"] = { "Telescope current_buffer_fuzzy_find", "Find" }, - [""] = { + [""] = { function() require("nvterm.terminal").toggle("horizontal") end, @@ -36,7 +36,7 @@ M.general = { [">"] = { ">gv", "indent" }, }, t = { - [""] = { + [""] = { function() require("nvterm.terminal").toggle("horizontal") end, From 805dad89e3a7ed25321f0a5850e4472fbde16a52 Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Mon, 23 Oct 2023 10:56:07 +0800 Subject: [PATCH 06/15] remove packer --- homecli/install.py | 9 +-------- scripts/install.ps1 | 10 ++-------- scripts/install.sh | 6 +++--- scripts/install_macos.sh | 11 ++--------- 4 files changed, 8 insertions(+), 28 deletions(-) diff --git a/homecli/install.py b/homecli/install.py index 64be928..923c241 100644 --- a/homecli/install.py +++ b/homecli/install.py @@ -74,17 +74,10 @@ def install_neovim(overwrite=True): os.chmod(bin_file, 0o755) logging.info("Installing neovim done.") - # install packer - subprocess.run( - os.path.join(CACHE_DIR, "miniconda", "bin", "git") - + " clone --depth 1 https://github.com/wbthomason/packer.nvim " - "~/.local/share/nvim/site/pack/packer/start/packer.nvim", - shell=True, - ) # install plugins subprocess.run( os.path.join(BIN_DIR, "nvim") - + " --appimage-extract-and-run --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'", + + ' --appimage-extract-and-run --headless "+Lazy! sync" +qa', shell=True, ) diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 5bbcd05..d44a7ea 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -15,7 +15,8 @@ New-Item -ItemType SymbolicLink -Path $gitConfig -Value $rootDir\general\gitconf # Create symbolic links to the neovim config file $nvimDir = Join-Path $env:USERPROFILE "AppData\Local\nvim" -New-Item -ItemType SymbolicLink -Path $nvimDir -Value $rootDir\general\nvim -Force +New-Item -ItemType SymbolicLink -Path $nvimDir -Value $rootDir\general\NvChad -Force +New-Item -ItemType SymbolicLink -Path $nvimDir\lua\custom -Value $rootDir\general\custom -Force # install scoop Set-ExecutionPolicy RemoteSigned -Scope CurrentUser # Optional: Needed to run a remote script the first time @@ -42,13 +43,6 @@ scoop install extras/tssh $ProgressPreference = "SilentlyContinue" Install-Module -Name PSFzf -# Install packer -git clone https://github.com/wbthomason/packer.nvim "$env:LOCALAPPDATA\nvim-data\site\pack\packer\start\packer.nvim" -nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync' -nvim --headless -c 'TSUpdateSync' -c 'q' -nvim --headless -c 'MasonInstall bash-language-server black isort json-lsp lua-language-server yaml-language-server' -c 'q' -nvim --headless -c 'LspInstall lua_ls pyright bashls jsonls yamlls' -c 'q' - # Install Visual Studio Build Tools winget install -e --id Microsoft.VisualStudio.2019.BuildTools winget install -e --id Microsoft.VisualStudioCode diff --git a/scripts/install.sh b/scripts/install.sh index 1d09020..0138331 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -23,7 +23,7 @@ elif [ "$MODE" = "unpack" ]; then elif [ "$MODE" = "online-install" ]; then DIR="$INSTALL_DIR/HOME/general" mkdir -p $INSTALL_DIR - git clone https://github.com/BrightXiaoHan/HOME $INSTALL_DIR/HOME + git clone -recurse-submodules https://github.com/BrightXiaoHan/HOME $INSTALL_DIR/HOME cd $INSTALL_DIR/HOME elif [ "$MODE" = "relink" ]; then DIR="$INSTALL_DIR/HOME/general" @@ -52,8 +52,8 @@ fi # link nvim dir if .config/nvim not exist if [ ! -d ~/.config/nvim ]; then - ln -s $DIR/nvim/ ~/.config/ - + ln -s $DIR/custom/ $DIR/NvChad/lua/custom + ln -s $DIR/NvChad/ ~/.config/nvim else echo "nvim config already exist. Please backup or remove it." exit 1 diff --git a/scripts/install_macos.sh b/scripts/install_macos.sh index 3d0b2a9..fef8166 100755 --- a/scripts/install_macos.sh +++ b/scripts/install_macos.sh @@ -28,8 +28,8 @@ fi # link nvim dir if .config/nvim not exist if [ ! -d ~/.config/nvim ]; then - ln -s $DIR/nvim/ ~/.config/ - + ln -s $DIR/custom/ $DIR/NvChad/lua/custom + ln -s $DIR/NvChad/ ~/.config/nvim else echo "nvim config already exist. Please backup or remove it." exit 1 @@ -83,10 +83,3 @@ brew install --quiet --cask \ # install font brew tap homebrew/cask-fonts brew install --quiet --cask font-jetbrains-mono - -git clone --depth 1 https://github.com/wbthomason/packer.nvim\ - ~/.local/share/nvim/site/pack/packer/start/packer.nvim -nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync' -nvim --headless -c 'TSUpdateSync' -c 'q' -nvim --headless -c 'MasonInstall bash-language-server black isort json-lsp lua-language-server yaml-language-server' -c 'q' -nvim --headless -c 'LspInstall lua_ls pyright bashls jsonls yamlls' -c 'q' From d7e6c1ae2002f5597591d175a962319f13402bae Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Mon, 23 Oct 2023 13:50:16 +0800 Subject: [PATCH 07/15] fix markdown_preview --- general/custom/mappings.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/general/custom/mappings.lua b/general/custom/mappings.lua index 877ef43..04ffa02 100644 --- a/general/custom/mappings.lua +++ b/general/custom/mappings.lua @@ -111,10 +111,10 @@ M.gitsigns = { }, } -M.peek = { +M.markdown_preview = { n = { - ["mo"] = { "lua require('peek').open()", "Markdown Preview" }, - ["mc"] = { "lua require('peek').close()", "Markdown Close" }, + ["mo"] = { "MarkdownPreview", "Markdown Preview" }, + ["mc"] = { "MarkdownPreviewStop", "Markdown Close" }, }, } From 2ea89cd93c078bc7a31804cdbaff8e844fae1d75 Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Tue, 24 Oct 2023 10:50:40 +0800 Subject: [PATCH 08/15] fix diagnostic --- general/custom/mappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/general/custom/mappings.lua b/general/custom/mappings.lua index 04ffa02..ba35db3 100644 --- a/general/custom/mappings.lua +++ b/general/custom/mappings.lua @@ -64,7 +64,7 @@ M.lsp = { n = { ["lf"] = { "lua vim.lsp.buf.format()", "Format" }, ["lr"] = { "lua vim.lsp.buf.rename()", "Rename" }, - ["ld"] = { "lua vim.lsp.diagnostic.show_line_diagnostics()", "Line diagnostics" }, + ["ld"] = { "lua vim.diagnostic.open_float(0, {scope='line'})", "Line diagnostics" }, ["lp"] = { "lua vim.lsp.diagnostic.goto_prev()", "Previous diagnostic" }, ["ln"] = { "lua vim.lsp.diagnostic.goto_next()", "Next diagnostic" }, }, From 86a7ee3b6e0e15bfd41da682a1e323772e06b23c Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Tue, 24 Oct 2023 11:16:11 +0800 Subject: [PATCH 09/15] update nvterm config --- general/custom/configs/overrides.lua | 32 +++++++++++++++++++++------- general/custom/plugins.lua | 4 ++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/general/custom/configs/overrides.lua b/general/custom/configs/overrides.lua index ab87a42..08a845e 100644 --- a/general/custom/configs/overrides.lua +++ b/general/custom/configs/overrides.lua @@ -79,14 +79,30 @@ M.nvimtree = { } M.cmp = { - mapping = { - [""] = require("cmp").mapping.complete(), - [""] = require("cmp").mapping.close(), - [""] = require("cmp").mapping.confirm({ - behavior = require("cmp").ConfirmBehavior.Replace, - select = true, - }), - }, + mapping = { + [""] = require("cmp").mapping.complete(), + [""] = require("cmp").mapping.close(), + [""] = require("cmp").mapping.confirm({ + behavior = require("cmp").ConfirmBehavior.Replace, + select = true, + }), + }, +} + +-- if win32 then use powershell else fish +if vim.fn.has("win32") == 1 then + SHELL = "powershell.exe" +else + SHELL = "fish" +end + +M.nvterm = { + terminals = { + shell = SHELL, + type_opts = { + horizontal = { location = "rightbelow", split_ratio = 0.5, size = 50 }, + }, + }, } return M diff --git a/general/custom/plugins.lua b/general/custom/plugins.lua index 5b9a2ce..06154c5 100644 --- a/general/custom/plugins.lua +++ b/general/custom/plugins.lua @@ -33,6 +33,10 @@ local plugins = { -- Override plugin definition options "hrsh7th/nvim-cmp", opts = overrides.cmp, }, + { + "Nvchad/nvterm", + opts = overrides.nvterm, + }, { "max397574/better-escape.nvim", event = "InsertEnter", From 820532a2285c8bc7067d4562186df68990de0eee Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Tue, 24 Oct 2023 12:04:51 +0800 Subject: [PATCH 10/15] fix copilot config --- general/custom/configs/overrides.lua | 22 +++++++++++++++++----- general/custom/plugins.lua | 21 ++++++++------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/general/custom/configs/overrides.lua b/general/custom/configs/overrides.lua index 08a845e..4bfadb6 100644 --- a/general/custom/configs/overrides.lua +++ b/general/custom/configs/overrides.lua @@ -80,12 +80,24 @@ M.nvimtree = { M.cmp = { mapping = { - [""] = require("cmp").mapping.complete(), + [""] = require("cmp").mapping.select_prev_item(), + [""] = require("cmp").mapping.select_next_item(), [""] = require("cmp").mapping.close(), - [""] = require("cmp").mapping.confirm({ - behavior = require("cmp").ConfirmBehavior.Replace, - select = true, - }), + [""] = require("cmp").config.disable, + [""] = require("cmp").config.disable, + -- manual completion + ["1"] = require("cmp").mapping.complete(), + }, + sources = { + { name = "nvim_lsp" }, + { name = "buffer" }, + { name = "path" }, + { name = "nvim_lua" }, + { name = "treesitter" }, + }, + -- disable auto-complete + completion = { + autocomplete = false, }, } diff --git a/general/custom/plugins.lua b/general/custom/plugins.lua index 06154c5..b8322e0 100644 --- a/general/custom/plugins.lua +++ b/general/custom/plugins.lua @@ -33,10 +33,10 @@ local plugins = { -- Override plugin definition options "hrsh7th/nvim-cmp", opts = overrides.cmp, }, - { - "Nvchad/nvterm", - opts = overrides.nvterm, - }, + { + "Nvchad/nvterm", + opts = overrides.nvterm, + }, { "max397574/better-escape.nvim", event = "InsertEnter", @@ -47,22 +47,17 @@ local plugins = { -- Override plugin definition options { "iamcco/markdown-preview.nvim", cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, - build = "cd app && npm install", + build = "cd app && npm install", init = function() vim.g.mkdp_filetypes = { "markdown" } - vim.g.mkdp_echo_preview_url = 1 - vim.g.mkdp_open_to_the_world = 1 + vim.g.mkdp_echo_preview_url = 1 + vim.g.mkdp_open_to_the_world = 1 end, ft = { "markdown" }, }, { "github/copilot.vim", - lazy = false, - config = function() - vim.g.copilot_no_tab_map = true - vim.g.copilot_assume_mapped = true - -- vim.g.copilot_tab_fallback = ""; - end, + lazy = false, }, { "Pocco81/auto-save.nvim", From 96ddb28520851cf9a116cf3a1b69c084ba5a738b Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Tue, 24 Oct 2023 14:22:12 +0800 Subject: [PATCH 11/15] format sh and md files --- README.md | 10 +- general/custom/configs/lspconfig.lua | 2 +- general/custom/configs/null-ls.lua | 24 ++++- general/custom/configs/overrides.lua | 21 ++-- homecli/install.py | 38 ++----- scripts/ccp/ccp.sh | 10 +- scripts/ccp/vscode.sh | 18 ++-- scripts/ccp/vscode_remote.sh | 18 ++-- scripts/install.sh | 152 +++++++++++++-------------- scripts/install_macos.sh | 54 +++++----- scripts/pack.sh | 4 +- scripts/uninstall.sh | 26 ++--- 12 files changed, 186 insertions(+), 191 deletions(-) diff --git a/README.md b/README.md index 6540658..daded4d 100644 --- a/README.md +++ b/README.md @@ -7,15 +7,17 @@ My Personal Home Directory. ### linux install + ```bash HOMECLI_INSTALL_DIR=$HOME/.homecli /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/BrightXiaoHan/HOME/main/scripts/install.sh)" ``` + update + ```bash HOMECLI_INSTALL_DIR=$HOME/.homecli /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/BrightXiaoHan/HOME/main/scripts/update.sh)" ``` - uninstall ```bash @@ -30,19 +32,21 @@ HOMECLI_INSTALL_DIR=$HOME/.homecli /bin/bash -c "$(curl -fsSL https://raw.github unpack -* Download prepacked `home-cli.tar` file and `install.sh` -* Run `install.sh` +- Download prepacked `home-cli.tar` file and `install.sh` +- Run `install.sh` ```bash HOMECLI_INSTALL_DIR=$HOME/.homecli bash install.sh unpack homecli.tar.gz ``` uninstall but don't delete installation cache, you can relink it if needed. + ```bash HOMECLI_INSTALL_DIR=$HOME/.homecli bash scripts/uninstall.sh false ``` relink + ```bash HOMECLI_INSTALL_DIR=$HOME/.homecli bash scripts/install.sh relink ``` diff --git a/general/custom/configs/lspconfig.lua b/general/custom/configs/lspconfig.lua index 3d6cabd..7544560 100644 --- a/general/custom/configs/lspconfig.lua +++ b/general/custom/configs/lspconfig.lua @@ -4,7 +4,7 @@ local capabilities = require("plugins.configs.lspconfig").capabilities local lspconfig = require("lspconfig") -- if you just want default config for the servers then put them in a table -local servers = { "html", "cssls", "tsserver", "clangd", "pyright" } +local servers = { "html", "cssls", "tsserver", "clangd", "pyright", "lua_ls", "bashls"} for _, lsp in ipairs(servers) do lspconfig[lsp].setup({ diff --git a/general/custom/configs/null-ls.lua b/general/custom/configs/null-ls.lua index 9c93b59..0dfb59d 100644 --- a/general/custom/configs/null-ls.lua +++ b/general/custom/configs/null-ls.lua @@ -6,7 +6,26 @@ local sources = { -- webdev stuff b.formatting.deno_fmt, -- choosed deno for ts/js files cuz its very fast! - b.formatting.prettier.with({ filetypes = { "html", "markdown", "css" } }), -- so prettier works only on these filetypes + b.formatting.prettier.with({ + filetypes = { + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "vue", + "css", + "scss", + "less", + "html", + "json", + "jsonc", + "yaml", + "markdown", + "markdown.mdx", + "graphql", + "handlebars", + }, + }), -- so prettier works only on these filetypes -- Lua b.formatting.stylua, @@ -20,6 +39,9 @@ local sources = { b.formatting.stylua, b.formatting.isort, b.formatting.autoflake.with({ extra_args = { "--remove-all-unused-imports", "--remove-unused-variables" } }), + + -- bash sh + b.formatting.shfmt.with({ filetypes = { "sh" } }), -- sh } null_ls.setup({ diff --git a/general/custom/configs/overrides.lua b/general/custom/configs/overrides.lua index 4bfadb6..ce75a5d 100644 --- a/general/custom/configs/overrides.lua +++ b/general/custom/configs/overrides.lua @@ -5,10 +5,9 @@ M.treesitter = { "lua", "c", "cpp", - "markdown", - "markdown_inline", "fish", "python", + "bash", }, indent = { enable = true, @@ -38,11 +37,6 @@ M.mason = { "black", "isort", "mypy", - - -- markdown stuff - "marksman", - "markdownlint", - "mdformat", }, } @@ -84,21 +78,18 @@ M.cmp = { [""] = require("cmp").mapping.select_next_item(), [""] = require("cmp").mapping.close(), [""] = require("cmp").config.disable, - [""] = require("cmp").config.disable, - -- manual completion - ["1"] = require("cmp").mapping.complete(), }, sources = { - { name = "nvim_lsp" }, - { name = "buffer" }, { name = "path" }, + { name = "nvim_lsp", max_item_count = 3 }, + { name = "buffer" }, { name = "nvim_lua" }, { name = "treesitter" }, }, -- disable auto-complete - completion = { - autocomplete = false, - }, + -- completion = { + -- autocomplete = false, + -- }, } -- if win32 then use powershell else fish diff --git a/homecli/install.py b/homecli/install.py index 923c241..b522d2a 100644 --- a/homecli/install.py +++ b/homecli/install.py @@ -88,36 +88,9 @@ def install_neovim(overwrite=True): ) # mason - mason_list = [ - "bash-language-server", - "black", - "isort", - "json-lsp", - "lua-language-server", - "yaml-language-server", - ] subprocess.run( os.path.join(BIN_DIR, "nvim") - + " --appimage-extract-and-run --headless -c 'MasonInstall " - + " ".join(mason_list) - + "'" - + " -c 'q'", - shell=True, - ) - - # LspInstall - lsp_list = [ - "lua_ls", - "pyright", - "bashls", - "jsonls", - "yamlls", - ] - subprocess.run( - os.path.join(BIN_DIR, "nvim") - + " --appimage-extract-and-run --headless -c 'LspInstall " - + " ".join(lsp_list) - + "'" + + " --appimage-extract-and-run --headless -c 'MasonInstallAll'" + " -c 'q'", shell=True, ) @@ -231,11 +204,16 @@ def install_conda(): check=True, env=env, ) - + env = os.environ.copy() env["PIPX_HOME"] = os.path.join(CACHE_DIR, "pipx") env["PIPX_BIN_DIR"] = os.path.join(CACHE_DIR, "bin") - for package in ["rich-cli", "git+https://github.com/BrightXiaoHan/ssr-command-client.git@socks2http", "mycli", "mdformat"]: + for package in [ + "rich-cli", + "git+https://github.com/BrightXiaoHan/ssr-command-client.git@socks2http", + "mycli", + "mdformat", + ]: subprocess.run( [ os.path.join(CACHE_DIR, "miniconda", "bin", "pipx"), diff --git a/scripts/ccp/ccp.sh b/scripts/ccp/ccp.sh index 438cda7..4425d72 100644 --- a/scripts/ccp/ccp.sh +++ b/scripts/ccp/ccp.sh @@ -3,16 +3,16 @@ set -e if [ -n "$XDG_CONFIG_HOME" ]; then - CONFIG_DIR="$XDG_CONFIG_HOME" + CONFIG_DIR="$XDG_CONFIG_HOME" else - CONFIG_DIR="$HOME/.config" + CONFIG_DIR="$HOME/.config" fi COPILOT_DIR="$CONFIG_DIR/github-copilot" if [ ! -d "$COPILOT_DIR" ]; then - mkdir -p "$COPILOT_DIR" + mkdir -p "$COPILOT_DIR" fi -echo '{"github.com":{"user":"cocopilot","oauth_token":"ghu_ThisIsARealFreeCopilotKeyByCoCopilot","dev_override":{"copilot_token_url":"https://api.cocopilot.org/copilot_internal/v2/token"}}}' > "$COPILOT_DIR/hosts.json" +echo '{"github.com":{"user":"cocopilot","oauth_token":"ghu_ThisIsARealFreeCopilotKeyByCoCopilot","dev_override":{"copilot_token_url":"https://api.cocopilot.org/copilot_internal/v2/token"}}}' >"$COPILOT_DIR/hosts.json" -echo 'done. please restart your ide.' \ No newline at end of file +echo 'done. please restart your ide.' diff --git a/scripts/ccp/vscode.sh b/scripts/ccp/vscode.sh index cea67b2..7838c33 100644 --- a/scripts/ccp/vscode.sh +++ b/scripts/ccp/vscode.sh @@ -4,26 +4,26 @@ set -e EXTENSIONS_DIR="$HOME/.vscode/extensions" if [ ! -d "$EXTENSIONS_DIR" ]; then - echo "ERROR: VSCode extensions directory not found!" - exit 1 + echo "ERROR: VSCode extensions directory not found!" + exit 1 fi COPILOT_DIR=$(ls -lt "$EXTENSIONS_DIR" | grep '^d' | awk '{print $9}' | grep -E '^github\.copilot-[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1) if [ -z "$COPILOT_DIR" ]; then - echo "ERROR: Copilot extension not found!" - exit 1 + echo "ERROR: Copilot extension not found!" + exit 1 fi COPILOT_DIR="$EXTENSIONS_DIR/$COPILOT_DIR" EXTENSION_FILE="$COPILOT_DIR/dist/extension.js" if [ ! -f "$EXTENSION_FILE" ]; then - echo "ERROR: Copilot extension entry file not found!" - exit 1 + echo "ERROR: Copilot extension entry file not found!" + exit 1 fi TMP_FILE="$COPILOT_DIR/dist/extension.js.tmp" -echo 'process.env.CODESPACES="true";process.env.GITHUB_TOKEN="ghu_ThisIsARealFreeCopilotKeyByCoCopilot";process.env.GITHUB_SERVER_URL="https://github.com";process.env.GITHUB_API_URL="https://api.cocopilot.org";' > "$TMP_FILE" -cat "$EXTENSION_FILE" >> "$TMP_FILE" +echo 'process.env.CODESPACES="true";process.env.GITHUB_TOKEN="ghu_ThisIsARealFreeCopilotKeyByCoCopilot";process.env.GITHUB_SERVER_URL="https://github.com";process.env.GITHUB_API_URL="https://api.cocopilot.org";' >"$TMP_FILE" +cat "$EXTENSION_FILE" >>"$TMP_FILE" mv "$TMP_FILE" "$EXTENSION_FILE" -echo 'done. please restart your vscode.' \ No newline at end of file +echo 'done. please restart your vscode.' diff --git a/scripts/ccp/vscode_remote.sh b/scripts/ccp/vscode_remote.sh index 91cfb3c..673a27c 100644 --- a/scripts/ccp/vscode_remote.sh +++ b/scripts/ccp/vscode_remote.sh @@ -4,26 +4,26 @@ set -e EXTENSIONS_DIR="$HOME/.vscode-server/extensions" if [ ! -d "$EXTENSIONS_DIR" ]; then - echo "ERROR: VSCode extensions directory not found!" - exit 1 + echo "ERROR: VSCode extensions directory not found!" + exit 1 fi COPILOT_DIR=$(ls -lt "$EXTENSIONS_DIR" | grep '^d' | awk '{print $9}' | grep -E '^github\.copilot-[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1) if [ -z "$COPILOT_DIR" ]; then - echo "ERROR: Copilot extension not found!" - exit 1 + echo "ERROR: Copilot extension not found!" + exit 1 fi COPILOT_DIR="$EXTENSIONS_DIR/$COPILOT_DIR" EXTENSION_FILE="$COPILOT_DIR/dist/extension.js" if [ ! -f "$EXTENSION_FILE" ]; then - echo "ERROR: Copilot extension entry file not found!" - exit 1 + echo "ERROR: Copilot extension entry file not found!" + exit 1 fi TMP_FILE="$COPILOT_DIR/dist/extension.js.tmp" -echo 'process.env.CODESPACES="true";process.env.GITHUB_TOKEN="ghu_ThisIsARealFreeCopilotKeyByCoCopilot";process.env.GITHUB_SERVER_URL="https://github.com";process.env.GITHUB_API_URL="https://api.cocopilot.org";' > "$TMP_FILE" -cat "$EXTENSION_FILE" >> "$TMP_FILE" +echo 'process.env.CODESPACES="true";process.env.GITHUB_TOKEN="ghu_ThisIsARealFreeCopilotKeyByCoCopilot";process.env.GITHUB_SERVER_URL="https://github.com";process.env.GITHUB_API_URL="https://api.cocopilot.org";' >"$TMP_FILE" +cat "$EXTENSION_FILE" >>"$TMP_FILE" mv "$TMP_FILE" "$EXTENSION_FILE" -echo 'done. please restart your vscode.' \ No newline at end of file +echo 'done. please restart your vscode.' diff --git a/scripts/install.sh b/scripts/install.sh index 0138331..54cf746 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -3,34 +3,34 @@ MODE=${1:-online-install} INSTALL_DIR=${HOMECLI_INSTALL_DIR:-$HOME/.homecli} if [ "$MODE" = "local-install" ]; then - CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - DIR="$INSTALL_DIR/HOME/general" - mkdir -p $INSTALL_DIR/HOME - cp -r $CWD/.. $INSTALL_DIR/HOME - cd $INSTALL_DIR/HOME + CWD="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" + DIR="$INSTALL_DIR/HOME/general" + mkdir -p $INSTALL_DIR/HOME + cp -r $CWD/.. $INSTALL_DIR/HOME + cd $INSTALL_DIR/HOME elif [ "$MODE" = "unpack" ]; then - TARFILE="$2" - if [ -z "$TARFILE" ]; then - echo "Usage: install.sh unpack " - exit 1 - fi - mkdir -p $INSTALL_DIR - tar -xvf "$TARFILE" -C "$INSTALL_DIR" - mkdir -p $INSTALL_DIR/miniconda - tar -xvf $INSTALL_DIR/miniconda.tar.gz -C $INSTALL_DIR/miniconda - DIR="$INSTALL_DIR/HOME/general" + TARFILE="$2" + if [ -z "$TARFILE" ]; then + echo "Usage: install.sh unpack " + exit 1 + fi + mkdir -p $INSTALL_DIR + tar -xvf "$TARFILE" -C "$INSTALL_DIR" + mkdir -p $INSTALL_DIR/miniconda + tar -xvf $INSTALL_DIR/miniconda.tar.gz -C $INSTALL_DIR/miniconda + DIR="$INSTALL_DIR/HOME/general" elif [ "$MODE" = "online-install" ]; then - DIR="$INSTALL_DIR/HOME/general" - mkdir -p $INSTALL_DIR - git clone -recurse-submodules https://github.com/BrightXiaoHan/HOME $INSTALL_DIR/HOME - cd $INSTALL_DIR/HOME + DIR="$INSTALL_DIR/HOME/general" + mkdir -p $INSTALL_DIR + git clone -recurse-submodules https://github.com/BrightXiaoHan/HOME $INSTALL_DIR/HOME + cd $INSTALL_DIR/HOME elif [ "$MODE" = "relink" ]; then - DIR="$INSTALL_DIR/HOME/general" + DIR="$INSTALL_DIR/HOME/general" else - echo "Usage: install.sh [tarfile]" - echo "mode: local-install, online-install, unpack or relink (local-install is default)" - exit 1 + echo "Usage: install.sh [tarfile]" + echo "mode: local-install, online-install, unpack or relink (local-install is default)" + exit 1 fi # get current dir @@ -38,103 +38,103 @@ mkdir -p ~/.config # test if python3 is installed if ! [ -x "$(command -v python3)" ]; then - echo 'Error: python3 is not installed.' >&2 - exit 1 + echo 'Error: python3 is not installed.' >&2 + exit 1 fi # link alacritty dir if .config/alacritty not exist if [ ! -d ~/.config/alacritty ]; then - ln -s $DIR/alacritty/ ~/.config/ + ln -s $DIR/alacritty/ ~/.config/ else - echo "alacritty config already exist. Please backup or remove it." - exit 1 + echo "alacritty config already exist. Please backup or remove it." + exit 1 fi # link nvim dir if .config/nvim not exist if [ ! -d ~/.config/nvim ]; then - ln -s $DIR/custom/ $DIR/NvChad/lua/custom - ln -s $DIR/NvChad/ ~/.config/nvim + ln -s $DIR/custom/ $DIR/NvChad/lua/custom + ln -s $DIR/NvChad/ ~/.config/nvim else - echo "nvim config already exist. Please backup or remove it." - exit 1 + echo "nvim config already exist. Please backup or remove it." + exit 1 fi # link tmux dir if .config/tmux not exist if [ ! -d ~/.config/tmux ]; then - ln -s $DIR/tmux/ ~/.config/ + ln -s $DIR/tmux/ ~/.config/ else - echo "tmux config already exist. Please backup or remove it." - exit 1 + echo "tmux config already exist. Please backup or remove it." + exit 1 fi # link fish dir if .config/fish not exist if [ ! -d ~/.config/fish ]; then - ln -s $DIR/fish/ ~/.config/ + ln -s $DIR/fish/ ~/.config/ else - echo "fish config already exist. Please backup or remove it." - exit 1 + echo "fish config already exist. Please backup or remove it." + exit 1 fi if [ ! -d ~/.ssh ]; then - mkdir ~/.ssh + mkdir ~/.ssh fi ln -s $DIR/ssh/config ~/.ssh/config ln -s $DIR/ssh/id_rsa.pub ~/.ssh/id_rsa.pub # add authorized_keys into .ssh/authorized_keys if [ ! -f ~/.ssh/authorized_keys ]; then - touch ~/.ssh/authorized_keys + touch ~/.ssh/authorized_keys fi # if id_rsa.pub not in authorized_keys, add it if ! grep -q "$(cat ~/.ssh/id_rsa.pub)" ~/.ssh/authorized_keys; then - cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys + cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys fi ln -s $DIR/gitconfig ~/.gitconfig ln -s $DIR/mambarc ~/.mambarc if [ "$MODE" = "local-install" ] || [ "$MODE" = "online-install" ]; then - PYTHONPATH="./:$PYTHONPATH" \ - PATH="$INSTALL_DIR/miniconda/bin:$INSTALL_DIR/nodejs/bin:$PATH" \ - python3 homecli/install.py - curl https://pyenv.run | PYENV_ROOT="$INSTALL_DIR/pyenv" bash - mv $HOME/.local/share/nvim $INSTALL_DIR/nvim - ln -s $INSTALL_DIR/nvim $HOME/.local/share/nvim + PYTHONPATH="./:$PYTHONPATH" \ + PATH="$INSTALL_DIR/miniconda/bin:$INSTALL_DIR/nodejs/bin:$PATH" \ + python3 homecli/install.py + curl https://pyenv.run | PYENV_ROOT="$INSTALL_DIR/pyenv" bash + mv $HOME/.local/share/nvim $INSTALL_DIR/nvim + ln -s $INSTALL_DIR/nvim $HOME/.local/share/nvim elif [ "$MODE" = "unpack" ]; then - mkdir -p ~/.local/share && ln -s $INSTALL_DIR/nvim/ ~/.local/share/nvim - source $INSTALL_DIR/miniconda/bin/activate - CRYPTOGRAPHY_OPENSSL_NO_LEGACY=1 conda unpack - - # Re-link broken symlinks - for file in $(find $HOME -type l ! -exec test -e {} \; -print); do - old=$(readlink $file) - # Re-link to the new location with $HOME prefix - # e.g.> /root/.homecli/xxx -> /home/hanbing/.homecli/xxx - - if [[ $old == *".local/share/nvim"* ]]; then - prefix=$(echo $old | sed 's/\.local\/share\/nvim.*//') - # replace prefix with $HOME - new=$(echo $old | sed "s|^$prefix|$HOME/|") - rm $file - ln -s $new $file - fi - - if [[ $old == *"miniconda/bin/"* ]]; then - prefix=$(echo $old | sed 's/\/miniconda\/bin.*//') - # replace prefix with $HOME - new=$(echo $old | sed "s|^$prefix|$INSTALL_DIR/|") - rm $file - ln -s $new $file - fi - done + mkdir -p ~/.local/share && ln -s $INSTALL_DIR/nvim/ ~/.local/share/nvim + source $INSTALL_DIR/miniconda/bin/activate + CRYPTOGRAPHY_OPENSSL_NO_LEGACY=1 conda unpack + + # Re-link broken symlinks + for file in $(find $HOME -type l ! -exec test -e {} \; -print); do + old=$(readlink $file) + # Re-link to the new location with $HOME prefix + # e.g.> /root/.homecli/xxx -> /home/hanbing/.homecli/xxx + + if [[ $old == *".local/share/nvim"* ]]; then + prefix=$(echo $old | sed 's/\.local\/share\/nvim.*//') + # replace prefix with $HOME + new=$(echo $old | sed "s|^$prefix|$HOME/|") + rm $file + ln -s $new $file + fi + + if [[ $old == *"miniconda/bin/"* ]]; then + prefix=$(echo $old | sed 's/\/miniconda\/bin.*//') + # replace prefix with $HOME + new=$(echo $old | sed "s|^$prefix|$INSTALL_DIR/|") + rm $file + ln -s $new $file + fi + done elif [ "$MODE" = "relink" ]; then - ln -s $INSTALL_DIR/nvim/ ~/.local/share/nvim + ln -s $INSTALL_DIR/nvim/ ~/.local/share/nvim fi # add fish path to .bashrc if ! grep -q 'alias fish.*' ~/.bashrc; then - echo "alias fish='$INSTALL_DIR/miniconda/bin/fish'" >> ~/.bashrc + echo "alias fish='$INSTALL_DIR/miniconda/bin/fish'" >>~/.bashrc fi # add HOMECLI_INSTALL_DIR to config-local.fish -echo "set -gx HOMECLI_INSTALL_DIR $INSTALL_DIR" > ~/.config/fish/config-local.fish +echo "set -gx HOMECLI_INSTALL_DIR $INSTALL_DIR" >~/.config/fish/config-local.fish diff --git a/scripts/install_macos.sh b/scripts/install_macos.sh index fef8166..17cbed7 100755 --- a/scripts/install_macos.sh +++ b/scripts/install_macos.sh @@ -6,7 +6,7 @@ brew install --quiet mas mas install 497799835 xcode-select --install -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" DIR="$DIR/../general" # get current dir @@ -14,71 +14,71 @@ mkdir -p ~/.config # test if python3 is installed if ! [ -x "$(command -v python3)" ]; then - echo 'Error: python3 is not installed.' >&2 - exit 1 + echo 'Error: python3 is not installed.' >&2 + exit 1 fi # link alacritty dir if .config/alacritty not exist if [ ! -d ~/.config/alacritty ]; then - ln -s $DIR/alacritty/ ~/.config/ + ln -s $DIR/alacritty/ ~/.config/ else - echo "alacritty config already exist. Please backup or remove it." - exit 1 + echo "alacritty config already exist. Please backup or remove it." + exit 1 fi # link nvim dir if .config/nvim not exist if [ ! -d ~/.config/nvim ]; then - ln -s $DIR/custom/ $DIR/NvChad/lua/custom - ln -s $DIR/NvChad/ ~/.config/nvim + ln -s $DIR/custom/ $DIR/NvChad/lua/custom + ln -s $DIR/NvChad/ ~/.config/nvim else - echo "nvim config already exist. Please backup or remove it." - exit 1 + echo "nvim config already exist. Please backup or remove it." + exit 1 fi # link tmux dir if .config/tmux not exist if [ ! -d ~/.config/tmux ]; then - ln -s $DIR/tmux/ ~/.config/ + ln -s $DIR/tmux/ ~/.config/ else - echo "tmux config already exist. Please backup or remove it." - exit 1 + echo "tmux config already exist. Please backup or remove it." + exit 1 fi # link fish dir if .config/fish not exist if [ ! -d ~/.config/fish ]; then - ln -s $DIR/fish/ ~/.config/ + ln -s $DIR/fish/ ~/.config/ else - echo "fish config already exist. Please backup or remove it." - exit 1 + echo "fish config already exist. Please backup or remove it." + exit 1 fi if [ ! -d ~/.ssh ]; then - mkdir ~/.ssh + mkdir ~/.ssh fi ln -s $DIR/ssh/config ~/.ssh/config # add authorized_keys into .ssh/authorized_keys if [ ! -f ~/.ssh/authorized_keys ]; then - touch ~/.ssh/authorized_keys + touch ~/.ssh/authorized_keys fi # if id_rsa.pub not in authorized_keys, add it if ! grep -q "$(cat ~/.ssh/id_rsa.pub)" ~/.ssh/authorized_keys; then - cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys + cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys fi ln -s $DIR/gitconfig ~/.gitconfig ln -s $DIR/mambarc ~/.mambarc brew install --quiet \ - git-lfs tmux fish neovim ripgrep fzf pyenv node aliyunpan trzsz-ssh \ - cmake poetry pipx starship zoxide openssh rich-cli \ - openssl readline sqlite3 xz zlib # pyenv + git-lfs tmux fish neovim ripgrep fzf pyenv node aliyunpan trzsz-ssh \ + cmake poetry pipx starship zoxide openssh rich-cli \ + openssl readline sqlite3 xz zlib # pyenv brew install --quiet --cask \ - iterm2 wechat wpsoffice-cn postman sogouinput \ - dingtalk todesk microsoft-edge adrive \ - appcleaner downie typora visual-studio-code \ - parallels tencent-meeting telegram microsoft-remote-desktop \ - clashx obs bing-wallpaper qqmusic douyin keycastr bruno + iterm2 wechat wpsoffice-cn postman sogouinput \ + dingtalk todesk microsoft-edge adrive \ + appcleaner downie typora visual-studio-code \ + parallels tencent-meeting telegram microsoft-remote-desktop \ + clashx obs bing-wallpaper qqmusic douyin keycastr bruno # install font brew tap homebrew/cask-fonts diff --git a/scripts/pack.sh b/scripts/pack.sh index 5bae14f..57c8254 100755 --- a/scripts/pack.sh +++ b/scripts/pack.sh @@ -10,6 +10,6 @@ echo $CURDIR OUTFILE=${1:-homecli.tar.gz} cd $DIR tar -cvf $CURDIR/$OUTFILE \ - HOME bin miniconda.tar.gz pyenv pipx nvim + HOME bin miniconda.tar.gz pyenv pipx nvim rm miniconda.tar.gz -cd - \ No newline at end of file +cd - diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index 26febcb..49a6702 100755 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -3,27 +3,27 @@ REMOVE_CACHE=${1:-true} # remove config files rm -rf ~/.config/alacritty \ - ~/.config/nvim \ - ~/.config/tmux \ - ~/.config/fish \ - ~/.gitconfig \ - ~/.ssh/config \ - ~/.ssh/id_rsa.pub \ - ~/.mambarc + ~/.config/nvim \ + ~/.config/tmux \ + ~/.config/fish \ + ~/.gitconfig \ + ~/.ssh/config \ + ~/.ssh/id_rsa.pub \ + ~/.mambarc # remove nvim plugins rm -rf ~/.local/share/nvim # remove cache if [ "$REMOVE_CACHE" = "true" ]; then - rm -rf $INSTALL_DIR + rm -rf $INSTALL_DIR elif [ "$REMOVE_CACHE" = "false" ]; then - echo "remove cache skipped" + echo "remove cache skipped" else - echo "invalid argument: $REMOVE_CACHE (should be true or false)" - echo "usage: $0 [true|false]" - exit 1 + echo "invalid argument: $REMOVE_CACHE (should be true or false)" + echo "usage: $0 [true|false]" + exit 1 fi # remove export PATH=$INSTALL_DIR/bin:$PATH' from .bashrc -sed -i '/export PATH=.*homecli\/miniconda\/bin:$PATH/d' ~/.bashrc \ No newline at end of file +sed -i '/export PATH=.*homecli\/miniconda\/bin:$PATH/d' ~/.bashrc From 847c02e483362b18ff73995f7b243282fff340a8 Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Tue, 24 Oct 2023 14:44:52 +0800 Subject: [PATCH 12/15] treesitter lazy=false --- general/custom/plugins.lua | 3 ++- homecli/install.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/general/custom/plugins.lua b/general/custom/plugins.lua index b8322e0..d550cda 100644 --- a/general/custom/plugins.lua +++ b/general/custom/plugins.lua @@ -24,6 +24,7 @@ local plugins = { -- Override plugin definition options { "nvim-treesitter/nvim-treesitter", opts = overrides.treesitter, + lazy = false, }, { "nvim-tree/nvim-tree.lua", @@ -57,7 +58,7 @@ local plugins = { -- Override plugin definition options }, { "github/copilot.vim", - lazy = false, + lazy = false, }, { "Pocco81/auto-save.nvim", diff --git a/homecli/install.py b/homecli/install.py index b522d2a..f01205b 100644 --- a/homecli/install.py +++ b/homecli/install.py @@ -83,7 +83,7 @@ def install_neovim(overwrite=True): subprocess.run( os.path.join(BIN_DIR, "nvim") - + " --appimage-extract-and-run --headless -c 'TSUpdateSync' -c 'q'", + + " --appimage-extract-and-run --headless -c 'TSInstallSync' -c 'q'", shell=True, ) From 2d2a267d2121b3e686ef23ac5d8ddb92f53c222b Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Tue, 24 Oct 2023 16:06:21 +0800 Subject: [PATCH 13/15] set scrolloff=8 --- general/custom/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/general/custom/init.lua b/general/custom/init.lua index 1d20b18..82be81d 100644 --- a/general/custom/init.lua +++ b/general/custom/init.lua @@ -1,3 +1,5 @@ +vim.opt.scrolloff = 8 + vim.g.mkdp_echo_preview_url = 1 vim.g.mkdp_open_to_the_world = 1 vim.g.mkdp_port = 33333 From f1a6d4c172fea0b2e0ff37f679916f6558160e1b Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Tue, 24 Oct 2023 22:55:34 +0800 Subject: [PATCH 14/15] add aerial --- general/custom/plugins.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/general/custom/plugins.lua b/general/custom/plugins.lua index d550cda..a604b36 100644 --- a/general/custom/plugins.lua +++ b/general/custom/plugins.lua @@ -64,6 +64,24 @@ local plugins = { -- Override plugin definition options "Pocco81/auto-save.nvim", lazy = false, }, + { + "stevearc/aerial.nvim", + opts = {}, + -- Optional dependencies + dependencies = { + "nvim-treesitter/nvim-treesitter", + "nvim-tree/nvim-web-devicons", + }, + lazy = false, + config = function() + require("aerial").setup({ + layout = { + max_width = { 40, 0.2 }, + min_width = 25, + }, + }) + end, + }, } return plugins From f53f6b4bbf263b0c16f2c2a007c0e4986b619d36 Mon Sep 17 00:00:00 2001 From: BrightXiaoHan Date: Tue, 24 Oct 2023 23:03:47 +0800 Subject: [PATCH 15/15] upgrade NvChad --- general/NvChad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/general/NvChad b/general/NvChad index c56f124..fd10af1 160000 --- a/general/NvChad +++ b/general/NvChad @@ -1 +1 @@ -Subproject commit c56f1242dfc9c1fbba71fc3a22448d5d563703e0 +Subproject commit fd10af115e0507b3976d78123eda9748fe0e2d29