diff --git a/.config/git/.gitconfig b/.config/git/.gitconfig index 3b476dc..6b98b60 100644 --- a/.config/git/.gitconfig +++ b/.config/git/.gitconfig @@ -8,7 +8,7 @@ [core] editor = nvim pager = delta - autocrlf = input + autocrlf = input [interactive] diffFilter = delta --color-only [delta] @@ -19,3 +19,5 @@ smudge = git-lfs smudge -- %f process = git-lfs filter-process required = true +[url "git@github.com:"] + insteadOf = https://github.com/ diff --git a/.config/glow/glow.yaml b/.config/glow/glow.yaml index ce719f3..30de003 100644 --- a/.config/glow/glow.yaml +++ b/.config/glow/glow.yaml @@ -1,3 +1,5 @@ +# ~/.config/glow/glow.yaml +# ln -sf $DOTFILES/glow/glow.yaml ~/.config/glow/glow.yaml # style name or JSON path (default "auto") style: "auto" # mouse support (TUI-mode only) diff --git a/.config/nvim/.neoconf.json b/.config/nvim.lazy.d/.neoconf.json similarity index 100% rename from .config/nvim/.neoconf.json rename to .config/nvim.lazy.d/.neoconf.json diff --git a/.config/nvim/.options/obsidian.all.lua b/.config/nvim.lazy.d/.options/obsidian.all.lua similarity index 100% rename from .config/nvim/.options/obsidian.all.lua rename to .config/nvim.lazy.d/.options/obsidian.all.lua diff --git a/.config/nvim/README.md b/.config/nvim.lazy.d/README.md similarity index 100% rename from .config/nvim/README.md rename to .config/nvim.lazy.d/README.md diff --git a/.config/nvim.lazy.d/init.lua b/.config/nvim.lazy.d/init.lua new file mode 100644 index 0000000..eded2d3 --- /dev/null +++ b/.config/nvim.lazy.d/init.lua @@ -0,0 +1,8 @@ +-- bootstrap lazy.nvim, LazyVim and your plugins +if (vim.g.vscode) then + print("VSCode detected, skipping lazy loading") + require("vscode.code") +else + require("config.lazy") + -- require("config.lazy") +end diff --git a/.config/nvim.lazy.d/lazy-lock.json b/.config/nvim.lazy.d/lazy-lock.json new file mode 100644 index 0000000..43c566e --- /dev/null +++ b/.config/nvim.lazy.d/lazy-lock.json @@ -0,0 +1,8 @@ +{ + "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, + "nvim-cmp": { "branch": "main", "commit": "be7bd4c5f860c79da97af3a26d489af50babfd4b" }, + "nvim-lspconfig": { "branch": "master", "commit": "c646154d6e4db9b2979eeb517d0b817ad00c9c47" }, + "nvim-treesitter": { "branch": "master", "commit": "efb2e9c607cab1e4f7171493b7c6f63bd39073fc" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" } +} diff --git a/.config/nvim.lazy.d/lazyvim.json b/.config/nvim.lazy.d/lazyvim.json new file mode 100644 index 0000000..bac2955 --- /dev/null +++ b/.config/nvim.lazy.d/lazyvim.json @@ -0,0 +1,10 @@ +{ + "extras": [ + "lazyvim.plugins.extras.ai.copilot", + "lazyvim.plugins.extras.ai.copilot-chat" + ], + "news": { + "NEWS.md": "7429" + }, + "version": 7 +} \ No newline at end of file diff --git a/.config/nvim/lua/config/autocmds.lua b/.config/nvim.lazy.d/lua/config/autocmds.lua similarity index 100% rename from .config/nvim/lua/config/autocmds.lua rename to .config/nvim.lazy.d/lua/config/autocmds.lua diff --git a/.config/nvim.lazy.d/lua/config/keymaps.lua b/.config/nvim.lazy.d/lua/config/keymaps.lua new file mode 100644 index 0000000..0105618 --- /dev/null +++ b/.config/nvim.lazy.d/lua/config/keymaps.lua @@ -0,0 +1,146 @@ +-- Keymaps are automatically loaded on the VeryLazy event +-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua +-- Add any additional keymaps here + +vim.g.mapleader = " " + +-- ================= GENERAL KEYBINDS ================= +-- SAVE/QUIT {{{ +vim.keymap.set("n", "Q", "q", { desc = "Q to quit" }) +vim.keymap.set("n", "", "w", { desc = "S to write file" }) +--}}} + +-- NVIM CONFIG SHORTCUTS {{{ +-- stylua: ignore +vim.keymap.set("n", "rc", "e $HOME/.config/nvim/lua/config/options.lua", { desc = "Open nvim options.lua" }) +vim.keymap.set("n", "rp", "e $HOME/.config/nvim/lua/plugins/.", { desc = "lazy plugins dir" }) +--}}} + +-- UNDO +vim.keymap.set({ "n", "v" }, "l", "u", { desc = "Undo" }) + +-- INSERT +vim.keymap.set({ "n", "v" }, "l", "i", { desc = "Insert" }) +vim.keymap.set({ "n", "v" }, "L", "I", { desc = "Insert at line start" }) + +-- YANK TO SYSTEM CLIPBOARD +vim.keymap.set("v", "Y", '"+y', { desc = "Copy to (System) Clipboard" }) + +-- SEARCH {{{ +vim.keymap.set("n", "", "nohlsearch", { desc = "clear search highlight" }) +--}}} + +-- SPACE TO TAB{{{ +vim.keymap.set("n", "tt", "%s/ /\t/g", { desc = "space to tab" }) +vim.keymap.set("v", "tt", "s/ /\t/g", { desc = "space to tab" }) +--}}} + +-- MISC {{{ +vim.keymap.set("n", "o", "za", { desc = "folding" }) +vim.keymap.set("i", "", "A {}iko", { desc = "insert a pair of {} and goto next line" }) +--}}} + +-- ================= CURSOR MOVEMENT ===================== {{{ +-- NEW CURSOR MOVEMENT (ARROW KEY RESIZE WINDOWS) +-- ^ +-- e +-- < h i > +-- n +-- v +-- +vim.keymap.set({ "n", "v", "", "s", "x" }, "e", "k", { desc = "move cursor ⇧" }) +vim.keymap.set({ "n", "v", "", "s", "x" }, "n", "j", { desc = "move cursor ⇩" }) +vim.keymap.set({ "n", "v", "", "s", "x" }, "h", "h", { desc = "move cursor ⇦" }) +vim.keymap.set({ "n", "v", "", "s", "x" }, "i", "l", { desc = "move cursor ⇨" }) + +vim.keymap.set({ "n", "v" }, "E", "5k", { desc = "Move 5up K -> U" }) +vim.keymap.set({ "n", "v" }, "N", "5j", { desc = "Move 5down J -> E" }) + +vim.keymap.set({ "n", "v" }, "H", "0", { desc = "Move start of line" }) +vim.keymap.set({ "n", "v" }, "I", "$", { desc = "Move end of line" }) + +vim.keymap.set("n", "gu", "gk", { desc = "move up gk -> gu" }) +vim.keymap.set("n", "ge", "gj", { desc = "move down gj -> ge" }) + +vim.keymap.set("n", "\v", "v$h", { desc = "???" }) + +-- FASTER IN-LINE NAVIGATION + +-- SET h (SAME AS n, CURSOR LEFT) TO 'END OF WORD' +vim.keymap.set("n", "j", "e", { desc = "Move cursor to end of word" }) +-- CTRL + U OR E WILL MOVE UP/DOWN THE VIEW PORT WITHOUT MOVING THE CURSOR + +vim.keymap.set({ "n", "v" }, "", "5", { desc = "Move viewport ⇧" }) +vim.keymap.set({ "n", "v" }, "", "5", { desc = "Move viewport ⇩" }) + +-- INSERT MODE CURSOR MOVEMENT +vim.keymap.set("i", "", "A") + +-- COMMAND MODE CURSOR MOVEMENT +vim.keymap.set("c", "", "") +vim.keymap.set("c", "", "") +vim.keymap.set("c", "", "") +vim.keymap.set("c", "", "") +vim.keymap.set("c", "", "") +vim.keymap.set("c", "", "") +vim.keymap.set("c", "", "") +vim.keymap.set("c", "", "") +--}}} + +-- ================= SPLIT MANAGMENT ===================== {{{ +vim.keymap.set("n", "E", "set nosplitbelowsplitset splitbelow", { desc = "Split ⇧" }) +vim.keymap.set("n", "N", "set splitbelowsplit", { desc = "Split ⇩" }) +vim.keymap.set("n", "H", "set nosplitrightvsplitset splitright", { desc = "Split ⇦" }) +vim.keymap.set("n", "I", "set splitrightvsplit", { desc = "Split ⇨" }) + +vim.keymap.set({ "n", "t" }, "e", "k", { desc = "Move cursor to split ⇧" }) +vim.keymap.set({ "n", "t" }, "n", "j", { desc = "Move cursor to split ⇩" }) +vim.keymap.set({ "n", "t" }, "h", "h", { desc = "Move cursor to split ⇦" }) +vim.keymap.set({ "n", "t" }, "i", "l", { desc = "Move cursor to split ⇨" }) + +vim.keymap.set({ "n", "t" }, "", "", { desc = "Move cursor to split ⇧" }) +vim.keymap.set({ "n", "t" }, "", "", { desc = "Move cursor to split ⇩" }) +vim.keymap.set({ "n", "t" }, "", "", { desc = "Move cursor to split ⇦" }) +vim.keymap.set({ "n", "t" }, "", "", { desc = "Move cursor to split ⇨" }) + +vim.keymap.set("n", "", "res -5", { desc = "Resize split 0,-5" }) +vim.keymap.set("n", "", "res +5", { desc = "Resize split 0,+5" }) +vim.keymap.set("n", "", "vertical resize +5", { desc = "Resize split +5,0" }) +vim.keymap.set("n", "", "vertical resize -5", { desc = "Resize split -5,0" }) + +vim.keymap.set("n", "H", "tK", { desc = "Make splits [H]orizontal" }) +vim.keymap.set("n", "V", "tH", { desc = "Make splits [V]ertical" }) + +vim.keymap.set("n", "ri", "bK", { desc = "Rotate splits 90" }) +vim.keymap.set("n", "rh", "bH", { desc = "Rotate splits -90" }) + +vim.keymap.set("n", "q", "jq", { desc = "Close Split ⇩ (Below)" }) +--}}} + +-- TAB MANAGEMENT {{{ +vim.keymap.set("n", "", "tabe", { desc = "New [Tab]" }) + +vim.keymap.set("n", "h", "-tabnext", { desc = "Select Tab ⇦" }) +vim.keymap.set("n", "i", "+tabnext", { desc = "Select Tab ⇨" }) + +vim.keymap.set("n", "H", "-tabmove", { desc = "Tab move ⇦" }) +vim.keymap.set("n", "I", "+tabmove", { desc = "Tab move ⇨" }) + +-- NOTE: Doesn't seem to work: +-- vim.keymap.set("n", "c", "tab split", { desc = "New Tab from [C]urrent" }) +-- vim.keymap.set('n', 'dw', '/\(\<\w\+\>\)\_s*\1', {desc='adjacent duplicate words'}) + +--vim.keymap.del("n", "j") +--vim.keymap.del("n", "k") +--vim.keymap.del("n", "l") +-- }}} + +-- =================== TERM BEHAVIORS ==================== +vim.keymap.set("t", "", "", { desc = "escape terminal, allowing excmds" }) +vim.keymap.set("t", "", "", { desc = "close terminal" }) + +--vim: set fdm=marker fdl=0 + +-- buffers +vim.keymap.set("n", "", "bprevious", { desc = "Prev Buffer" }) +vim.keymap.set("n", "", "bnext", { desc = "Next Buffer" }) diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim.lazy.d/lua/config/lazy.lua similarity index 100% rename from .config/nvim/lua/config/lazy.lua rename to .config/nvim.lazy.d/lua/config/lazy.lua diff --git a/.config/nvim.lazy.d/lua/config/options.lua b/.config/nvim.lazy.d/lua/config/options.lua new file mode 100644 index 0000000..415944a --- /dev/null +++ b/.config/nvim.lazy.d/lua/config/options.lua @@ -0,0 +1,3 @@ +-- Options are automatically loaded before lazy.nvim startup +-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua +-- Add any additional options here diff --git a/.config/nvim/lua/plugins/catppuccin.lua b/.config/nvim.lazy.d/lua/plugins/catppuccin.lua similarity index 95% rename from .config/nvim/lua/plugins/catppuccin.lua rename to .config/nvim.lazy.d/lua/plugins/catppuccin.lua index 01f8b27..c6e52c7 100644 --- a/.config/nvim/lua/plugins/catppuccin.lua +++ b/.config/nvim.lazy.d/lua/plugins/catppuccin.lua @@ -1,54 +1,54 @@ -return { - "catppuccin/nvim", - lazy = true, - name = "catppuccin", - opts = { - integrations = { - aerial = true, - alpha = true, - cmp = true, - dashboard = true, - flash = true, - grug_far = 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, - }, - }, - specs = { - { - "akinsho/bufferline.nvim", - optional = true, - opts = function(_, opts) - if (vim.g.colors_name or ""):find("catppuccin") then - opts.highlights = require("catppuccin.groups.integrations.bufferline").get() - end - end, - }, - }, -} +return { + "catppuccin/nvim", + lazy = true, + name = "catppuccin", + opts = { + integrations = { + aerial = true, + alpha = true, + cmp = true, + dashboard = true, + flash = true, + grug_far = 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, + }, + }, + specs = { + { + "akinsho/bufferline.nvim", + optional = true, + opts = function(_, opts) + if (vim.g.colors_name or ""):find("catppuccin") then + opts.highlights = require("catppuccin.groups.integrations.bufferline").get() + end + end, + }, + }, +} diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim.lazy.d/lua/plugins/colorscheme.lua similarity index 95% rename from .config/nvim/lua/plugins/colorscheme.lua rename to .config/nvim.lazy.d/lua/plugins/colorscheme.lua index 233e7e8..ab99258 100644 --- a/.config/nvim/lua/plugins/colorscheme.lua +++ b/.config/nvim.lazy.d/lua/plugins/colorscheme.lua @@ -1,13 +1,13 @@ -return { - -- add gruvbox - { "ellisonleao/gruvbox.nvim" }, - { "catppuccin/nvim", name = "catppuccin", priority = 1000 }, - - -- Configure LazyVim to load gruvbox - { - "LazyVim/LazyVim", - opts = { - colorscheme = "catppuccin", - }, - }, -} +return { + -- add gruvbox + { "ellisonleao/gruvbox.nvim" }, + { "catppuccin/nvim", name = "catppuccin", priority = 1000 }, + + -- Configure LazyVim to load gruvbox + { + "LazyVim/LazyVim", + opts = { + colorscheme = "catppuccin", + }, + }, +} diff --git a/.config/nvim.lazy.d/lua/plugins/dashboard.lua b/.config/nvim.lazy.d/lua/plugins/dashboard.lua new file mode 100644 index 0000000..368524a --- /dev/null +++ b/.config/nvim.lazy.d/lua/plugins/dashboard.lua @@ -0,0 +1,65 @@ +return { + "nvimdev/dashboard-nvim", + lazy = false, -- As https://github.com/nvimdev/dashboard-nvim/pull/450, dashboard-nvim shouldn't be lazy-loaded to properly handle stdin. + opts = function() + local logo = [[ + ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z + ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z + ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z + ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z + ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ + ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + ]] + + -- logo = string.rep("\n", 8) .. logo .. "\n\n" + + local opts = { + theme = "doom", + hide = { + -- this is taken care of by lualine + -- enabling this messes up the actual laststatus setting after loading a file + statusline = false, + }, + config = { + header = vim.split(logo, "\n"), + -- stylua: ignore + center = { + { action = 'lua LazyVim.pick()()', desc = " Find File", icon = " ", key = "f" }, + { action = "ene | startinsert", desc = " New File", icon = " ", key = "n" }, + { action = 'lua LazyVim.pick("oldfiles")()', desc = " Recent Files", icon = " ", key = "r" }, + { action = 'lua LazyVim.pick("live_grep")()', desc = " Find Text", icon = " ", key = "g" }, + { action = 'lua LazyVim.pick.config_files()()', desc = " Config", icon = " ", key = "c" }, + { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, + { action = "LazyExtras", desc = " Lazy Extras", icon = " ", key = "x" }, + { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, + { action = function() vim.api.nvim_input("qa") end, desc = " Quit", icon = " ", key = "q" }, + }, + footer = function() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + return { "⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" } + end, + }, + } + + for _, button in ipairs(opts.config.center) do + button.desc = button.desc .. string.rep(" ", 43 - #button.desc) + button.key_format = " %s" + end + + -- open dashboard after closing lazy + if vim.o.filetype == "lazy" then + vim.api.nvim_create_autocmd("WinClosed", { + pattern = tostring(vim.api.nvim_get_current_win()), + once = true, + callback = function() + vim.schedule(function() + vim.api.nvim_exec_autocmds("UIEnter", { group = "dashboard" }) + end) + end, + }) + end + + return opts + end, +} diff --git a/.config/nvim/lua/plugins/example.lua b/.config/nvim.lazy.d/lua/plugins/example.lua similarity index 96% rename from .config/nvim/lua/plugins/example.lua rename to .config/nvim.lazy.d/lua/plugins/example.lua index 1fd75d4..17f53d6 100644 --- a/.config/nvim/lua/plugins/example.lua +++ b/.config/nvim.lazy.d/lua/plugins/example.lua @@ -1,197 +1,197 @@ --- since this is just an example spec, don't actually load anything here and return an empty spec --- stylua: ignore -if true then return {} end - --- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim --- --- In your plugin files, you can: --- * add extra plugins --- * disable/enabled LazyVim plugins --- * override the configuration of LazyVim plugins -return { - -- add gruvbox - { "ellisonleao/gruvbox.nvim" }, - - -- Configure LazyVim to load gruvbox - { - "LazyVim/LazyVim", - opts = { - colorscheme = "gruvbox", - }, - }, - - -- change trouble config - { - "folke/trouble.nvim", - -- opts will be merged with the parent spec - opts = { use_diagnostic_signs = true }, - }, - - -- disable trouble - { "folke/trouble.nvim", enabled = false }, - - -- override nvim-cmp and add cmp-emoji - { - "hrsh7th/nvim-cmp", - dependencies = { "hrsh7th/cmp-emoji" }, - ---@param opts cmp.ConfigSchema - opts = function(_, opts) - table.insert(opts.sources, { name = "emoji" }) - end, - }, - - -- change some telescope options and a keymap to browse plugin files - { - "nvim-telescope/telescope.nvim", - keys = { - -- add a keymap to browse plugin files - -- stylua: ignore - { - "fp", - function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end, - desc = "Find Plugin File", - }, - }, - -- change some options - opts = { - defaults = { - layout_strategy = "horizontal", - layout_config = { prompt_position = "top" }, - sorting_strategy = "ascending", - winblend = 0, - }, - }, - }, - - -- add pyright to lspconfig - { - "neovim/nvim-lspconfig", - ---@class PluginLspOpts - opts = { - ---@type lspconfig.options - servers = { - -- pyright will be automatically installed with mason and loaded with lspconfig - pyright = {}, - }, - }, - }, - - -- add tsserver and setup with typescript.nvim instead of lspconfig - { - "neovim/nvim-lspconfig", - dependencies = { - "jose-elias-alvarez/typescript.nvim", - init = function() - require("lazyvim.util").lsp.on_attach(function(_, buffer) - -- stylua: ignore - vim.keymap.set( "n", "co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" }) - vim.keymap.set("n", "cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer }) - end) - end, - }, - ---@class PluginLspOpts - opts = { - ---@type lspconfig.options - servers = { - -- tsserver will be automatically installed with mason and loaded with lspconfig - tsserver = {}, - }, - -- you can do any additional lsp server setup here - -- return true if you don't want this server to be setup with lspconfig - ---@type table - setup = { - -- example to setup with typescript.nvim - tsserver = function(_, opts) - require("typescript").setup({ server = opts }) - return true - end, - -- Specify * to use this function as a fallback for any server - -- ["*"] = function(server, opts) end, - }, - }, - }, - - -- for typescript, LazyVim also includes extra specs to properly setup lspconfig, - -- treesitter, mason and typescript.nvim. So instead of the above, you can use: - { import = "lazyvim.plugins.extras.lang.typescript" }, - - -- add more treesitter parsers - { - "nvim-treesitter/nvim-treesitter", - opts = { - ensure_installed = { - "bash", - "html", - "javascript", - "json", - "lua", - "markdown", - "markdown_inline", - "python", - "query", - "regex", - "tsx", - "typescript", - "vim", - "yaml", - }, - }, - }, - - -- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above - -- would overwrite `ensure_installed` with the new value. - -- If you'd rather extend the default config, use the code below instead: - { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - -- add tsx and treesitter - vim.list_extend(opts.ensure_installed, { - "tsx", - "typescript", - }) - end, - }, - - -- the opts function can also be used to change the default opts: - { - "nvim-lualine/lualine.nvim", - event = "VeryLazy", - opts = function(_, opts) - table.insert(opts.sections.lualine_x, { - function() - return "😄" - end, - }) - end, - }, - - -- or you can return new options to override all the defaults - { - "nvim-lualine/lualine.nvim", - event = "VeryLazy", - opts = function() - return { - --[[add your custom lualine config here]] - } - end, - }, - - -- use mini.starter instead of alpha - { import = "lazyvim.plugins.extras.ui.mini-starter" }, - - -- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc - { import = "lazyvim.plugins.extras.lang.json" }, - - -- add any tools you want to have installed below - { - "williamboman/mason.nvim", - opts = { - ensure_installed = { - "stylua", - "shellcheck", - "shfmt", - "flake8", - }, - }, - }, -} +-- since this is just an example spec, don't actually load anything here and return an empty spec +-- stylua: ignore +if true then return {} end + +-- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim +-- +-- In your plugin files, you can: +-- * add extra plugins +-- * disable/enabled LazyVim plugins +-- * override the configuration of LazyVim plugins +return { + -- add gruvbox + { "ellisonleao/gruvbox.nvim" }, + + -- Configure LazyVim to load gruvbox + { + "LazyVim/LazyVim", + opts = { + colorscheme = "gruvbox", + }, + }, + + -- change trouble config + { + "folke/trouble.nvim", + -- opts will be merged with the parent spec + opts = { use_diagnostic_signs = true }, + }, + + -- disable trouble + { "folke/trouble.nvim", enabled = false }, + + -- override nvim-cmp and add cmp-emoji + { + "hrsh7th/nvim-cmp", + dependencies = { "hrsh7th/cmp-emoji" }, + ---@param opts cmp.ConfigSchema + opts = function(_, opts) + table.insert(opts.sources, { name = "emoji" }) + end, + }, + + -- change some telescope options and a keymap to browse plugin files + { + "nvim-telescope/telescope.nvim", + keys = { + -- add a keymap to browse plugin files + -- stylua: ignore + { + "fp", + function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end, + desc = "Find Plugin File", + }, + }, + -- change some options + opts = { + defaults = { + layout_strategy = "horizontal", + layout_config = { prompt_position = "top" }, + sorting_strategy = "ascending", + winblend = 0, + }, + }, + }, + + -- add pyright to lspconfig + { + "neovim/nvim-lspconfig", + ---@class PluginLspOpts + opts = { + ---@type lspconfig.options + servers = { + -- pyright will be automatically installed with mason and loaded with lspconfig + pyright = {}, + }, + }, + }, + + -- add tsserver and setup with typescript.nvim instead of lspconfig + { + "neovim/nvim-lspconfig", + dependencies = { + "jose-elias-alvarez/typescript.nvim", + init = function() + require("lazyvim.util").lsp.on_attach(function(_, buffer) + -- stylua: ignore + vim.keymap.set( "n", "co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" }) + vim.keymap.set("n", "cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer }) + end) + end, + }, + ---@class PluginLspOpts + opts = { + ---@type lspconfig.options + servers = { + -- tsserver will be automatically installed with mason and loaded with lspconfig + tsserver = {}, + }, + -- you can do any additional lsp server setup here + -- return true if you don't want this server to be setup with lspconfig + ---@type table + setup = { + -- example to setup with typescript.nvim + tsserver = function(_, opts) + require("typescript").setup({ server = opts }) + return true + end, + -- Specify * to use this function as a fallback for any server + -- ["*"] = function(server, opts) end, + }, + }, + }, + + -- for typescript, LazyVim also includes extra specs to properly setup lspconfig, + -- treesitter, mason and typescript.nvim. So instead of the above, you can use: + { import = "lazyvim.plugins.extras.lang.typescript" }, + + -- add more treesitter parsers + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "bash", + "html", + "javascript", + "json", + "lua", + "markdown", + "markdown_inline", + "python", + "query", + "regex", + "tsx", + "typescript", + "vim", + "yaml", + }, + }, + }, + + -- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above + -- would overwrite `ensure_installed` with the new value. + -- If you'd rather extend the default config, use the code below instead: + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + -- add tsx and treesitter + vim.list_extend(opts.ensure_installed, { + "tsx", + "typescript", + }) + end, + }, + + -- the opts function can also be used to change the default opts: + { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + opts = function(_, opts) + table.insert(opts.sections.lualine_x, { + function() + return "😄" + end, + }) + end, + }, + + -- or you can return new options to override all the defaults + { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + opts = function() + return { + --[[add your custom lualine config here]] + } + end, + }, + + -- use mini.starter instead of alpha + { import = "lazyvim.plugins.extras.ui.mini-starter" }, + + -- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc + { import = "lazyvim.plugins.extras.lang.json" }, + + -- add any tools you want to have installed below + { + "williamboman/mason.nvim", + opts = { + ensure_installed = { + "stylua", + "shellcheck", + "shfmt", + "flake8", + }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/just.lua b/.config/nvim.lazy.d/lua/plugins/just.lua similarity index 100% rename from .config/nvim/lua/plugins/just.lua rename to .config/nvim.lazy.d/lua/plugins/just.lua diff --git a/.config/nvim.lazy.d/lua/plugins/lualine.lua b/.config/nvim.lazy.d/lua/plugins/lualine.lua new file mode 100644 index 0000000..756fd96 --- /dev/null +++ b/.config/nvim.lazy.d/lua/plugins/lualine.lua @@ -0,0 +1,126 @@ +return { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + init = function() + vim.g.lualine_laststatus = vim.o.laststatus + if vim.fn.argc(-1) > 0 then + -- set an empty statusline till lualine loads + vim.o.statusline = " " + else + -- hide the statusline on the starter page + vim.o.laststatus = 0 + end + end, + opts = function() + -- PERF: we don't need this lualine require madness 🤷 + local lualine_require = require("lualine_require") + lualine_require.require = require + + local icons = LazyVim.config.icons + + vim.o.laststatus = vim.g.lualine_laststatus + + local opts = { + options = { + theme = "auto", + globalstatus = vim.o.laststatus == 3, + disabled_filetypes = { statusline = { "dashboard", "alpha", "ministarter", "snacks_dashboard", "NvimTree_1" } }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch" }, + + lualine_c = { + LazyVim.lualine.root_dir(), + { + "diagnostics", + symbols = { + error = icons.diagnostics.Error, + warn = icons.diagnostics.Warn, + info = icons.diagnostics.Info, + hint = icons.diagnostics.Hint, + }, + }, + { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, + { LazyVim.lualine.pretty_path() }, + }, + lualine_x = { + -- stylua: ignore + { + function() return require("noice").api.status.command.get() end, + cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end, + color = function() return LazyVim.ui.fg("Statement") end, + }, + -- stylua: ignore + { + function() return require("noice").api.status.mode.get() end, + cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end, + color = function() return LazyVim.ui.fg("Constant") end, + }, + -- stylua: ignore + { + function() return " " .. require("dap").status() end, + cond = function() return package.loaded["dap"] and require("dap").status() ~= "" end, + color = function() return LazyVim.ui.fg("Debug") end, + }, + -- stylua: ignore + { + require("lazy.status").updates, + cond = require("lazy.status").has_updates, + color = function() return LazyVim.ui.fg("Special") end, + }, + { + "diff", + symbols = { + added = icons.git.added, + modified = icons.git.modified, + removed = icons.git.removed, + }, + source = function() + local gitsigns = vim.b.gitsigns_status_dict + if gitsigns then + return { + added = gitsigns.added, + modified = gitsigns.changed, + removed = gitsigns.removed, + } + end + end, + }, + }, + lualine_y = { + { "progress", separator = " ", padding = { left = 1, right = 0 } }, + { "location", padding = { left = 0, right = 1 } }, + }, + lualine_z = { + function() + return " " .. os.date("%R") + end, + }, + }, + extensions = { "neo-tree", "lazy" }, + } + + -- do not add trouble symbols if aerial is enabled + -- And allow it to be overriden for some buffer types (see autocmds) + if vim.g.trouble_lualine and LazyVim.has("trouble.nvim") then + local trouble = require("trouble") + local symbols = trouble.statusline({ + mode = "symbols", + groups = {}, + title = false, + filter = { range = true }, + format = "{kind_icon}{symbol.name:Normal}", + hl_group = "lualine_c_normal", + }) + table.insert(opts.sections.lualine_c, { + symbols and symbols.get, + cond = function() + return vim.b.trouble_lualine ~= false and symbols.has() + end, + }) + end + + return opts + end, +} diff --git a/.config/nvim/lua/plugins/neo-tree.lua b/.config/nvim.lazy.d/lua/plugins/neo-tree.lua similarity index 94% rename from .config/nvim/lua/plugins/neo-tree.lua rename to .config/nvim.lazy.d/lua/plugins/neo-tree.lua index f2f0fb5..d9bccdf 100644 --- a/.config/nvim/lua/plugins/neo-tree.lua +++ b/.config/nvim.lazy.d/lua/plugins/neo-tree.lua @@ -1,127 +1,138 @@ -return { - "nvim-neo-tree/neo-tree.nvim", - cmd = "Neotree", - keys = { - { - "fe", - function() - require("neo-tree.command").execute({ toggle = true, dir = LazyVim.root() }) - end, - desc = "Explorer NeoTree (Root Dir)", - }, - { - "fE", - function() - require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() }) - end, - desc = "Explorer NeoTree (cwd)", - }, - { "e", "fe", desc = "Explorer NeoTree (Root Dir)", remap = true }, - { "E", "fE", desc = "Explorer NeoTree (cwd)", remap = true }, - { - "ge", - function() - require("neo-tree.command").execute({ source = "git_status", toggle = true }) - end, - desc = "Git Explorer", - }, - { - "be", - function() - require("neo-tree.command").execute({ source = "buffers", toggle = true }) - end, - desc = "Buffer Explorer", - }, - }, - deactivate = function() - vim.cmd([[Neotree close]]) - end, - init = function() - -- FIX: use `autocmd` for lazy-loading neo-tree instead of directly requiring it, - -- because `cwd` is not set up properly. - vim.api.nvim_create_autocmd("BufEnter", { - group = vim.api.nvim_create_augroup("Neotree_start_directory", { clear = true }), - desc = "Start Neo-tree with directory", - once = true, - callback = function() - if package.loaded["neo-tree"] then - return - else - local stats = vim.uv.fs_stat(vim.fn.argv(0)) - if stats and stats.type == "directory" then - require("neo-tree") - end - end - end, - }) - end, - opts = { - sources = { "filesystem", "buffers", "git_status" }, - open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" }, - filesystem = { - bind_to_cwd = false, - follow_current_file = { enabled = true }, - use_libuv_file_watcher = true, - }, - window = { - mappings = { - -- MARKED - ["i"] = "open", - -- MARKED - ["e"] = "noop", - ["h"] = "close_node", - [""] = "none", - ["Y"] = { - function(state) - local node = state.tree:get_node() - local path = node:get_id() - vim.fn.setreg("+", path, "c") - end, - desc = "Copy Path to Clipboard", - }, - ["O"] = { - function(state) - require("lazy.util").open(state.tree:get_node().path, { system = true }) - end, - desc = "Open with System Application", - }, - ["P"] = { "toggle_preview", config = { use_float = false } }, - }, - }, - default_component_configs = { - indent = { - with_expanders = true, -- if nil and file nesting is enabled, will enable expanders - expander_collapsed = "", - expander_expanded = "", - expander_highlight = "NeoTreeExpander", - }, - git_status = { - symbols = { - unstaged = "󰄱", - staged = "󰱒", - }, - }, - }, - }, - config = function(_, opts) - local function on_move(data) - LazyVim.lsp.on_rename(data.source, data.destination) - end - - local events = require("neo-tree.events") - opts.event_handlers = opts.event_handlers or {} - vim.list_extend(opts.event_handlers, { - { event = events.FILE_MOVED, handler = on_move }, - { event = events.FILE_RENAMED, handler = on_move }, - }) - require("neo-tree").setup(opts) - vim.api.nvim_create_autocmd("TermClose", { - pattern = "*lazygit", - callback = function() - if package.loaded["neo-tree.sources.git_status"] then - require("neo-tree.sources.git_status").refresh() - end - end, - }) - end, -} +return { + "nvim-neo-tree/neo-tree.nvim", + cmd = "Neotree", + keys = { + { + "fe", + function() + require("neo-tree.command").execute({ toggle = true, dir = LazyVim.root() }) + end, + desc = "Explorer NeoTree (Root Dir)", + }, + { + "fE", + function() + require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() }) + end, + desc = "Explorer NeoTree (cwd)", + }, + { "e", "fe", desc = "Explorer NeoTree (Root Dir)", remap = true }, + { "E", "fE", desc = "Explorer NeoTree (cwd)", remap = true }, + { + "ge", + function() + require("neo-tree.command").execute({ source = "git_status", toggle = true }) + end, + desc = "Git Explorer", + }, + { + "be", + function() + require("neo-tree.command").execute({ source = "buffers", toggle = true }) + end, + desc = "Buffer Explorer", + }, + }, + deactivate = function() + vim.cmd([[Neotree close]]) + end, + init = function() + -- FIX: use `autocmd` for lazy-loading neo-tree instead of directly requiring it, + -- because `cwd` is not set up properly. + vim.api.nvim_create_autocmd("BufEnter", { + group = vim.api.nvim_create_augroup("Neotree_start_directory", { clear = true }), + desc = "Start Neo-tree with directory", + once = true, + callback = function() + if package.loaded["neo-tree"] then + return + else + local stats = vim.uv.fs_stat(vim.fn.argv(0)) + if stats and stats.type == "directory" then + require("neo-tree") + end + end + end, + }) + end, + opts = { + sources = { "filesystem", "buffers", "git_status" }, + open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" }, + filesystem = { + hide_dotfiles = false, + hide_hidden = false, + bind_to_cwd = false, + follow_current_file = { enabled = true }, + use_libuv_file_watcher = true, + hide_by_name = { + ".git", + "node_modules", + "requirements.txt", + "desktop.ini", + }, + never_show = { + ".DS_Store", + }, + }, + window = { + mappings = { + -- MARKED + ["i"] = "open", + -- MARKED + ["e"] = "noop", + ["h"] = "close_node", + [""] = "none", + ["Y"] = { + function(state) + local node = state.tree:get_node() + local path = node:get_id() + vim.fn.setreg("+", path, "c") + end, + desc = "Copy Path to Clipboard", + }, + ["O"] = { + function(state) + require("lazy.util").open(state.tree:get_node().path, { system = true }) + end, + desc = "Open with System Application", + }, + ["P"] = { "toggle_preview", config = { use_float = false } }, + }, + }, + default_component_configs = { + indent = { + with_expanders = true, -- if nil and file nesting is enabled, will enable expanders + expander_collapsed = "", + expander_expanded = "", + expander_highlight = "NeoTreeExpander", + }, + git_status = { + symbols = { + unstaged = "󰄱", + staged = "󰱒", + }, + }, + }, + }, + config = function(_, opts) + local function on_move(data) + LazyVim.lsp.on_rename(data.source, data.destination) + end + + local events = require("neo-tree.events") + opts.event_handlers = opts.event_handlers or {} + vim.list_extend(opts.event_handlers, { + { event = events.FILE_MOVED, handler = on_move }, + { event = events.FILE_RENAMED, handler = on_move }, + }) + require("neo-tree").setup(opts) + vim.api.nvim_create_autocmd("TermClose", { + pattern = "*lazygit", + callback = function() + if package.loaded["neo-tree.sources.git_status"] then + require("neo-tree.sources.git_status").refresh() + end + end, + }) + end, +} diff --git a/.config/nvim.lazy.d/lua/plugins/nvim-tree.lua b/.config/nvim.lazy.d/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..40e9b7c --- /dev/null +++ b/.config/nvim.lazy.d/lua/plugins/nvim-tree.lua @@ -0,0 +1,11 @@ +return { + "nvim-tree/nvim-tree.lua", + version = "*", + lazy = false, + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + config = function() + require("nvim-tree").setup({}) + end, +} diff --git a/.config/nvim.lazy.d/lua/plugins/obsidian.lua b/.config/nvim.lazy.d/lua/plugins/obsidian.lua new file mode 100644 index 0000000..492e085 --- /dev/null +++ b/.config/nvim.lazy.d/lua/plugins/obsidian.lua @@ -0,0 +1,22 @@ +return { + "epwalsh/obsidian.nvim", + version = "*", -- recommended, use latest release instead of latest commit + lazy = true, + ft = "markdown", + dependencies = { + -- Required. + "nvim-lua/plenary.nvim", + + -- see below for full list of optional dependencies 👇 + }, + opts = { + workspaces = { + { + name = "Obsidian", + path = "/mnt/c/Users/citoy/Obsidian", + }, + }, + + -- see below for full list of options 👇 + }, +} diff --git a/.config/nvim/lua/plugins/wakatime.lua b/.config/nvim.lazy.d/lua/plugins/wakatime.lua similarity index 96% rename from .config/nvim/lua/plugins/wakatime.lua rename to .config/nvim.lazy.d/lua/plugins/wakatime.lua index 5161b78..e37e7b5 100644 --- a/.config/nvim/lua/plugins/wakatime.lua +++ b/.config/nvim.lazy.d/lua/plugins/wakatime.lua @@ -1,3 +1,3 @@ -return { - { 'wakatime/vim-wakatime', lazy = false }, +return { + { 'wakatime/vim-wakatime', lazy = false }, } \ No newline at end of file diff --git a/.config/nvim.lazy.d/stylua.toml b/.config/nvim.lazy.d/stylua.toml new file mode 100644 index 0000000..964e1aa --- /dev/null +++ b/.config/nvim.lazy.d/stylua.toml @@ -0,0 +1,3 @@ +indent_type = "Spaces" +indent_width = 2 +column_width = 120 \ No newline at end of file diff --git a/.config/nvim/.DS_Store b/.config/nvim/.DS_Store deleted file mode 100644 index 423eb9c..0000000 Binary files a/.config/nvim/.DS_Store and /dev/null differ diff --git a/.config/nvim/.editorconfig b/.config/nvim/.editorconfig new file mode 100644 index 0000000..f9b0405 --- /dev/null +++ b/.config/nvim/.editorconfig @@ -0,0 +1,12 @@ +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.lua] +indent_type = "Spaces" +indent_width = 2 +column_width = 120 diff --git a/.config/nvim/.gitignore b/.config/nvim/.gitignore new file mode 100644 index 0000000..2fcefc7 --- /dev/null +++ b/.config/nvim/.gitignore @@ -0,0 +1 @@ +lazy-lock.json \ No newline at end of file diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index eded2d3..cdb5629 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,8 +1,28 @@ --- bootstrap lazy.nvim, LazyVim and your plugins -if (vim.g.vscode) then - print("VSCode detected, skipping lazy loading") - require("vscode.code") -else - require("config.lazy") - -- require("config.lazy") -end +--[[ +-*- coding: utf-8 -*- +@Filename init.lua +@Author js0ny +@Date 2024-11-27 +@Description neovim 配置文件 +]] +-- 针对特定文件类型设置快捷键 +vim.api.nvim_create_autocmd("FileType", { + pattern = "markdown", -- 指定文件类型 + callback = function() + vim.api.nvim_buf_set_keymap(0, "v", "`", "c`\"`", { noremap = true, silent = true, desc = "Wrap selection with backticks" }) + end, +}) + +-- 加载配置 +require("config.options") +-- 加载键位映射 +require("config.keymaps") + +-- 加载插件 +require("config.plugins") + +-- 加载主题 +require("config.colorscheme") + + +-- vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) diff --git a/.config/nvim/lua/.DS_Store b/.config/nvim/lua/.DS_Store deleted file mode 100644 index 2bcd0e8..0000000 Binary files a/.config/nvim/lua/.DS_Store and /dev/null differ diff --git a/.config/nvim/lua/config/colorscheme.lua b/.config/nvim/lua/config/colorscheme.lua new file mode 100644 index 0000000..d57d784 --- /dev/null +++ b/.config/nvim/lua/config/colorscheme.lua @@ -0,0 +1 @@ +vim.cmd.colorscheme("catppuccin") diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index 0105618..dfc1d55 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -1,146 +1,2 @@ --- Keymaps are automatically loaded on the VeryLazy event --- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua --- Add any additional keymaps here - -vim.g.mapleader = " " - --- ================= GENERAL KEYBINDS ================= --- SAVE/QUIT {{{ -vim.keymap.set("n", "Q", "q", { desc = "Q to quit" }) -vim.keymap.set("n", "", "w", { desc = "S to write file" }) ---}}} - --- NVIM CONFIG SHORTCUTS {{{ --- stylua: ignore -vim.keymap.set("n", "rc", "e $HOME/.config/nvim/lua/config/options.lua", { desc = "Open nvim options.lua" }) -vim.keymap.set("n", "rp", "e $HOME/.config/nvim/lua/plugins/.", { desc = "lazy plugins dir" }) ---}}} - --- UNDO -vim.keymap.set({ "n", "v" }, "l", "u", { desc = "Undo" }) - --- INSERT -vim.keymap.set({ "n", "v" }, "l", "i", { desc = "Insert" }) -vim.keymap.set({ "n", "v" }, "L", "I", { desc = "Insert at line start" }) - --- YANK TO SYSTEM CLIPBOARD -vim.keymap.set("v", "Y", '"+y', { desc = "Copy to (System) Clipboard" }) - --- SEARCH {{{ -vim.keymap.set("n", "", "nohlsearch", { desc = "clear search highlight" }) ---}}} - --- SPACE TO TAB{{{ -vim.keymap.set("n", "tt", "%s/ /\t/g", { desc = "space to tab" }) -vim.keymap.set("v", "tt", "s/ /\t/g", { desc = "space to tab" }) ---}}} - --- MISC {{{ -vim.keymap.set("n", "o", "za", { desc = "folding" }) -vim.keymap.set("i", "", "A {}iko", { desc = "insert a pair of {} and goto next line" }) ---}}} - --- ================= CURSOR MOVEMENT ===================== {{{ --- NEW CURSOR MOVEMENT (ARROW KEY RESIZE WINDOWS) --- ^ --- e --- < h i > --- n --- v --- -vim.keymap.set({ "n", "v", "", "s", "x" }, "e", "k", { desc = "move cursor ⇧" }) -vim.keymap.set({ "n", "v", "", "s", "x" }, "n", "j", { desc = "move cursor ⇩" }) -vim.keymap.set({ "n", "v", "", "s", "x" }, "h", "h", { desc = "move cursor ⇦" }) -vim.keymap.set({ "n", "v", "", "s", "x" }, "i", "l", { desc = "move cursor ⇨" }) - -vim.keymap.set({ "n", "v" }, "E", "5k", { desc = "Move 5up K -> U" }) -vim.keymap.set({ "n", "v" }, "N", "5j", { desc = "Move 5down J -> E" }) - -vim.keymap.set({ "n", "v" }, "H", "0", { desc = "Move start of line" }) -vim.keymap.set({ "n", "v" }, "I", "$", { desc = "Move end of line" }) - -vim.keymap.set("n", "gu", "gk", { desc = "move up gk -> gu" }) -vim.keymap.set("n", "ge", "gj", { desc = "move down gj -> ge" }) - -vim.keymap.set("n", "\v", "v$h", { desc = "???" }) - --- FASTER IN-LINE NAVIGATION - --- SET h (SAME AS n, CURSOR LEFT) TO 'END OF WORD' -vim.keymap.set("n", "j", "e", { desc = "Move cursor to end of word" }) --- CTRL + U OR E WILL MOVE UP/DOWN THE VIEW PORT WITHOUT MOVING THE CURSOR - -vim.keymap.set({ "n", "v" }, "", "5", { desc = "Move viewport ⇧" }) -vim.keymap.set({ "n", "v" }, "", "5", { desc = "Move viewport ⇩" }) - --- INSERT MODE CURSOR MOVEMENT -vim.keymap.set("i", "", "A") - --- COMMAND MODE CURSOR MOVEMENT -vim.keymap.set("c", "", "") -vim.keymap.set("c", "", "") -vim.keymap.set("c", "", "") -vim.keymap.set("c", "", "") -vim.keymap.set("c", "", "") -vim.keymap.set("c", "", "") -vim.keymap.set("c", "", "") -vim.keymap.set("c", "", "") ---}}} - --- ================= SPLIT MANAGMENT ===================== {{{ -vim.keymap.set("n", "E", "set nosplitbelowsplitset splitbelow", { desc = "Split ⇧" }) -vim.keymap.set("n", "N", "set splitbelowsplit", { desc = "Split ⇩" }) -vim.keymap.set("n", "H", "set nosplitrightvsplitset splitright", { desc = "Split ⇦" }) -vim.keymap.set("n", "I", "set splitrightvsplit", { desc = "Split ⇨" }) - -vim.keymap.set({ "n", "t" }, "e", "k", { desc = "Move cursor to split ⇧" }) -vim.keymap.set({ "n", "t" }, "n", "j", { desc = "Move cursor to split ⇩" }) -vim.keymap.set({ "n", "t" }, "h", "h", { desc = "Move cursor to split ⇦" }) -vim.keymap.set({ "n", "t" }, "i", "l", { desc = "Move cursor to split ⇨" }) - -vim.keymap.set({ "n", "t" }, "", "", { desc = "Move cursor to split ⇧" }) -vim.keymap.set({ "n", "t" }, "", "", { desc = "Move cursor to split ⇩" }) -vim.keymap.set({ "n", "t" }, "", "", { desc = "Move cursor to split ⇦" }) -vim.keymap.set({ "n", "t" }, "", "", { desc = "Move cursor to split ⇨" }) - -vim.keymap.set("n", "", "res -5", { desc = "Resize split 0,-5" }) -vim.keymap.set("n", "", "res +5", { desc = "Resize split 0,+5" }) -vim.keymap.set("n", "", "vertical resize +5", { desc = "Resize split +5,0" }) -vim.keymap.set("n", "", "vertical resize -5", { desc = "Resize split -5,0" }) - -vim.keymap.set("n", "H", "tK", { desc = "Make splits [H]orizontal" }) -vim.keymap.set("n", "V", "tH", { desc = "Make splits [V]ertical" }) - -vim.keymap.set("n", "ri", "bK", { desc = "Rotate splits 90" }) -vim.keymap.set("n", "rh", "bH", { desc = "Rotate splits -90" }) - -vim.keymap.set("n", "q", "jq", { desc = "Close Split ⇩ (Below)" }) ---}}} - --- TAB MANAGEMENT {{{ -vim.keymap.set("n", "", "tabe", { desc = "New [Tab]" }) - -vim.keymap.set("n", "h", "-tabnext", { desc = "Select Tab ⇦" }) -vim.keymap.set("n", "i", "+tabnext", { desc = "Select Tab ⇨" }) - -vim.keymap.set("n", "H", "-tabmove", { desc = "Tab move ⇦" }) -vim.keymap.set("n", "I", "+tabmove", { desc = "Tab move ⇨" }) - --- NOTE: Doesn't seem to work: --- vim.keymap.set("n", "c", "tab split", { desc = "New Tab from [C]urrent" }) --- vim.keymap.set('n', 'dw', '/\(\<\w\+\>\)\_s*\1', {desc='adjacent duplicate words'}) - ---vim.keymap.del("n", "j") ---vim.keymap.del("n", "k") ---vim.keymap.del("n", "l") --- }}} - --- =================== TERM BEHAVIORS ==================== -vim.keymap.set("t", "", "", { desc = "escape terminal, allowing excmds" }) -vim.keymap.set("t", "", "", { desc = "close terminal" }) - ---vim: set fdm=marker fdl=0 - --- buffers -vim.keymap.set("n", "", "bprevious", { desc = "Prev Buffer" }) -vim.keymap.set("n", "", "bnext", { desc = "Next Buffer" }) +require("keymaps") + diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index 415944a..de77bff 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -1,3 +1,52 @@ --- Options are automatically loaded before lazy.nvim startup --- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua --- Add any additional options here +-- is space +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" +-- Disable netrw +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 +-- Disable Perl +vim.g.loaded_perl_provider = 0 -- Don't load Perl + +vim.g.autoformat = true + +local opt = vim.opt + +-- Clipboard +opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" +-- Line number +opt.number = true +opt.relativenumber = true + +opt.confirm = true + +-- Word wrap +opt.linebreak = true + +-- Indentation +opt.expandtab = true +opt.shiftwidth = 4 +opt.shiftround = true + +-- Case +opt.ignorecase = true +opt.smartcase = true + +opt.cursorline = true +-- Terminal GUI +opt.termguicolors = true + +-- Fold +opt.foldlevel = 99 +opt.foldmethod = "expr" + +-- Statusline +opt.laststatus = 0 + +-- Hide Command Line if empty +opt.cmdheight = 0 + +-- Scroll +opt.scrolloff = 5 +opt.sidescrolloff = 10 + +opt.conceallevel = 2 diff --git a/.config/nvim/lua/config/plugins.lua b/.config/nvim/lua/config/plugins.lua new file mode 100644 index 0000000..c55d697 --- /dev/null +++ b/.config/nvim/lua/config/plugins.lua @@ -0,0 +1 @@ +require("plugins") diff --git a/.config/nvim/lua/config/servers.lua b/.config/nvim/lua/config/servers.lua new file mode 100644 index 0000000..38cc888 --- /dev/null +++ b/.config/nvim/lua/config/servers.lua @@ -0,0 +1,34 @@ +--- Available LSP goes here +--- Check https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md +--- for available server and name +local M = {} +M.servers = { + "arduino_language_server", -- Arduino + "bashls", -- Bash + "clangd", -- C/C++ + -- "cmake", -- CMake + "eslint", -- JavaScript + "gopls", -- Go + "html", -- HTML + "julials", -- Julia + "lua_ls", -- Lua + "omnisharp", -- C# & F# + "powershell_es", -- PowerShell + "pyright", -- Python + "rust_analyzer", -- Rust + "taplo", -- TOML + "vimls", -- vimscript +} + +M.server_config = { + lua_ls = { + capabilities = vim.lsp.protocol.make_client_capabilities(), + settings = { + Lua = { + diagnostics = { globals = { "vim" } }, + }, + }, + }, +} + +return M diff --git a/.config/nvim/lua/keymaps/basic.lua b/.config/nvim/lua/keymaps/basic.lua new file mode 100644 index 0000000..00fa177 --- /dev/null +++ b/.config/nvim/lua/keymaps/basic.lua @@ -0,0 +1,20 @@ +local mode_arrow = { "n", "v", "o", "s", "x" } + +local keymaps_basic = { -- Modification of Original Keymap - Colemak + { mode = mode_arrow, keys = "n", cmd = "j" }, + { mode = mode_arrow, keys = "e", cmd = "k" }, + { mode = mode_arrow, keys = "i", cmd = "l" }, + { keys = "H", cmd = ":bprevious" }, + { keys = "N", cmd = "J" }, + { keys = "E", cmd = "K" }, + { keys = "I", cmd = ":bnext" }, + { keys = "l", cmd = "i" }, + { keys = "L", cmd = "I" }, + { keys = "k", cmd = "n" }, + { keys = "K", cmd = "N" }, + { keys = "j", cmd = "e" }, + { keys = "J", cmd = "E" }, + { keys = "Y", cmd = "y$"}, +} + +return keymaps_basic diff --git a/.config/nvim/lua/keymaps/init.lua b/.config/nvim/lua/keymaps/init.lua new file mode 100644 index 0000000..4849d72 --- /dev/null +++ b/.config/nvim/lua/keymaps/init.lua @@ -0,0 +1,52 @@ +local M = {} +local global_default_opts = { noremap = true, silent = true } +local global_default_mode = { "n" } +-- local mode_arrow = { "n", "v", "o", "s", "x" } + +local function set_keymaps(maps, default_opts, default_mode) + for _, map in ipairs(maps) do + local opts = vim.tbl_extend("force", default_opts, map.opts or {}) + local mode = map.mode or default_mode + vim.keymap.set(mode, map.keys, map.cmd, opts) + end +end + + + +local keymaps_basic = require("keymaps.basic") +local keymaps_nvim_tree_general = require("keymaps.nvim-tree").global +local keymaps_leader = require("keymaps.leaders") + +set_keymaps(keymaps_basic, global_default_opts, global_default_mode) +set_keymaps(keymaps_nvim_tree_general, global_default_opts, global_default_mode) +set_keymaps(keymaps_leader, global_default_opts, global_default_mode) + +M.nvim_tree_keymaps = require("keymaps.nvim-tree").plugin + +--- `map` default for `cmp.mapping` +function M.cmp_nvim_keymaps(map) + return { + { keys = "", cmd = map.select_next_item(), desc = "Select next completion item" }, + { keys = "", cmd = map.select_prev_item(), desc = "Select previous completion item" }, + { keys = "", cmd = map.confirm({ select = true }), desc = "Confirm completion" }, + { keys = "", cmd = map.confirm({ select = true }), desc = "Confirm completion" }, + { keys = "", cmd = map.complete(), desc = "Trigger completion" }, + { keys = "", cmd = map.abort(), desc = "Abort completion" }, + } +end + +local function set_markdown_keymaps(bufnr) + local opts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set("v", "`", "c`\"`", opts) +end + +vim.api.nvim_create_autocmd("FileType", { + pattern = "markdown", + callback = function() + set_markdown_keymaps(0) + end, +}) + +require("keymaps.language") + +return M diff --git a/.config/nvim/lua/keymaps/language.lua b/.config/nvim/lua/keymaps/language.lua new file mode 100644 index 0000000..0f8ad64 --- /dev/null +++ b/.config/nvim/lua/keymaps/language.lua @@ -0,0 +1,28 @@ +local M = {} + + +-- Markdown + +local function set_markdown_keymaps(bufnr) + local markdown_opt = { noremap = true, silent = true, buffer = bufnr } + for _, map in ipairs(M.markdown) do + local opts = vim.tbl_extend("force", markdown_opt, map.opts or {}) + vim.keymap.set(map.mode, map.keys, map.cmd, opts) + end +end + + +M.markdown = { + { mode = "v", keys = "`", cmd = "c`pi`" , desc = "Wrap selection in ` for inline code" }, + { mode = "v", keys = "*", cmd = "c**pi**" , desc = "Wrap selection in ** for bold" }, + { mode = "v", keys = "_", cmd = "c*pi*" , desc = "Wrap selection in * for italic" }, +} + +vim.api.nvim_create_autocmd("FileType", { + pattern = "markdown", + callback = function() + set_markdown_keymaps(0) + end, +}) + +return M diff --git a/.config/nvim/lua/keymaps/leaders.lua b/.config/nvim/lua/keymaps/leaders.lua new file mode 100644 index 0000000..3cfe04a --- /dev/null +++ b/.config/nvim/lua/keymaps/leaders.lua @@ -0,0 +1,79 @@ +local M = {} + +local leader_general = { + { keys = "", cmd = ":Telescope find_files", desc = "Find Files" }, + { keys = "/", cmd = ":Telescope live_grep", desc = "Grep Files" }, +} + +for _,map in ipairs(leader_general) do + map.keys = "" .. map.keys + table.insert(M, map) +end + +local leader_q = { -- leader q: Quit + { keys = "q", cmd = ":q", desc = "Quit" }, + { keys = "Q", cmd = ":qa!", desc = "Force Quit" }, + { keys = "w", cmd = ":wq", desc = "Write and Quit" }, + { keys = "W", cmd = ":wall:qa!", desc = "Write all and Force Quit" }, +} + +local leader_w = { -- leader w: Windows Management + { keys = "h", cmd = "h", desc = "Left Window" }, + { keys = "n", cmd = "j", desc = "Down Window" }, + { keys = "e", cmd = "k", desc = "Up Window" }, + { keys = "i", cmd = "l", desc = "Right Window" }, + { keys = "-", cmd = ":split", desc = "Split to down" }, + { keys = "|", cmd = ":vsplit", desc = "Split to right" }, + { keys = "c", cmd = "c", desc = "Close Window" }, + { keys = "o", cmd = "o", desc = "Close Other Windows" }, + { keys = "r", cmd = "r", desc = "Rotate Windows" }, + { keys = "R", cmd = "R", desc = "Reverse Rotate Windows" }, + { keys = "t", cmd = "T", desc = "Move Window to New Tab" }, + { keys = "H", cmd = ":vertical resize -5", desc = "Decrease Window Height" }, + { keys = "N", cmd = ":resize +5", desc = "Increase Window Height" }, + { keys = "E", cmd = ":vertical resize +5", desc = "Increase Window Width" }, + { keys = "I", cmd = ":resize -5", desc = "Decrease Window Width" }, +} + +local leader_f = { -- leader f: Files/Find + { keys = "f", cmd = ":Telescope fd", desc = "Find Files"}, + { keys = "s", cmd = ":Telescope live_grep", desc = "Grep Files"}, + { keys = "b", cmd = ":Telescope buffers", desc = "List Buffers"}, + { keys = "e", cmd = ":NvimTreeToggle", desc = "Toggle File Explorer" }, +} + +local leader_p = { -- leader p: Project +} + +local leader_b = { -- leader b: Buffer + { keys = "d", cmd = ":bdelete", desc = "Delete Buffer" }, + { keys = "h", cmd = ":bprevious", desc = "Previous Buffer" }, + { keys = "i", cmd = ":bnext", desc = "Next Buffer" }, + { keys = "H", cmd = ":bfirst", desc = "First Buffer" }, + { keys = "I", cmd = ":blast", desc = "Last Buffer" }, + { keys = "0", cmd = ":bfirst", desc = "First Buffer" }, + { keys = "^", cmd = ":bfirst", desc = "First Buffer" }, + { keys = "$", cmd = ":blast", desc = "Last Buffer" }, +} + +for _, map in ipairs(leader_q) do + map.keys = "q" .. map.keys + table.insert(M, map) +end + +for _, map in ipairs(leader_w) do + map.keys = "w" .. map.keys + table.insert(M, map) +end + +for _, map in ipairs(leader_f) do + map.keys = "f" .. map.keys + table.insert(M, map) +end + +for _, map in ipairs(leader_b) do + map.keys = "b" .. map.keys + table.insert(M, map) +end + +return M diff --git a/.config/nvim/lua/keymaps/nvim-tree.lua b/.config/nvim/lua/keymaps/nvim-tree.lua new file mode 100644 index 0000000..2e8f57b --- /dev/null +++ b/.config/nvim/lua/keymaps/nvim-tree.lua @@ -0,0 +1,81 @@ +local M = {} + +M.global = { + { mode = "n", keys = "e", cmd = ":NvimTreeToggle" }, +} + +function M.plugin(api, opts) + -- mode is set to "n" by default, in `./lua/plugins/nvim-tree.lua` + return { + -- Toggle + { keys = "e", cmd = ":NvimTreeToggle", opts = opts("Toggle") }, + -- Arrow 箭头 hnei + { keys = "h", cmd = api.node.navigate.parent_close, opts = opts("Close node") }, + { keys = "i", cmd = api.node.open.edit, opts = opts("Open") }, + { keys = "H", cmd = api.tree.toggle_hidden_filter, opts = opts("Toggle Dotfiles") }, + { keys = "N", cmd = api.node.navigate.sibling.next, opts = opts("Next Sibling") }, + { keys = "E", cmd = api.node.navigate.sibling.prev, opts = opts("Previous Sibling") }, + { keys = "I", cmd = api.tree.toggle_gitignore_filter, opts = opts("Toggle GitIgnored") }, + -- CONTROL KEYS 控制键 + { keys = "", cmd = api.node.navigate.parent_close, opts = opts("Close node") }, + { keys = "", cmd = api.node.open.edit, opts = opts("Open") }, + { keys = "", cmd = api.node.open.preview, opts = opts("Open Preview") }, + -- Alpha 字母键 + { keys = "a", cmd = api.fs.create, opts = opts("Create") }, + { keys = "A", cmd = api.fs.create, opts = opts("Create") }, + { keys = "bd", cmd = api.marks.bulk.delete, opts = opts("Delete Bookmarked") }, + { keys = "bt", cmd = api.marks.bulk.trash, opts = opts("Trash Bookmarked") }, + { keys = "bmv", cmd = api.marks.bulk.move, opts = opts("Move Bookmarked") }, + { keys = "B", cmd = api.tree.toggle_no_buffer_filter, opts = opts("Toggle Filter: No Buffer") }, + { keys = "c", cmd = api.fs.copy.node, opts = opts("Copy") }, + { keys = "C", cmd = api.fs.copy.filename, opts = opts("Copy") }, + { keys = "d", cmd = api.fs.remove, opts = opts("Delete") }, + { keys = "D", cmd = api.fs.trash, opts = opts("Trash") }, + { keys = "]e", cmd = api.node.navigate.diagnostics.next, opts = opts("Next Diagnostic") }, + { keys = "[e", cmd = api.node.navigate.diagnostics.prev, opts = opts("Prev Diagnostic") }, + { keys = "F", cmd = api.live_filter.clear, opts = opts("Live Filter: Clear") }, + { keys = "f", cmd = api.live_filter.start, opts = opts("Live Filter: Start") }, + { keys = "[g", cmd = api.node.navigate.git.prev, opts = opts("Prev Git") }, + { keys = "]g", cmd = api.node.navigate.git.next, opts = opts("Next Git") }, + { keys = "L", cmd = api.node.open.toggle_group_empty, opts = opts("Toggle Group Empty") }, + { keys = "M", cmd = api.tree.toggle_no_bookmark_filter, opts = opts("Toggle Filter: No Bookmark") }, + { keys = "m", cmd = api.marks.toggle, opts = opts("Toggle Bookmark") }, + { keys = "o", cmd = api.node.open.edit, opts = opts("Open") }, + { keys = "O", cmd = api.node.open.no_window_picker, opts = opts("Open: No Window Picker") }, + { keys = "p", cmd = api.fs.paste, opts = opts("Paste") }, + { keys = "P", cmd = api.node.navigate.parent, opts = opts("Parent Directory") }, + { keys = "q", cmd = api.tree.close, opts = opts("Close") }, + { keys = "r", cmd = api.fs.rename, opts = opts("Rename") }, + { keys = "R", cmd = api.tree.reload, opts = opts("Refresh") }, + { keys = "s", cmd = api.node.run.system, opts = opts("Run System") }, + { keys = "S", cmd = api.tree.search_node, opts = opts("Search") }, + { keys = "u", cmd = api.fs.rename_full, opts = opts("Rename: Full Path") }, + { keys = "U", cmd = api.tree.toggle_custom_filter, opts = opts("Toggle Filter: Hidden") }, + { keys = "W", cmd = api.tree.collapse_all, opts = opts("Collapse") }, + { keys = "x", cmd = api.fs.cut, opts = opts("Cut") }, + { keys = "y", cmd = api.fs.copy.relative_path, opts = opts("Copy Relative Path") }, + { keys = "Y", cmd = api.fs.copy.absolute_path, opts = opts("Copy Absolute Path") }, + -- Numeric 数字键 + { keys = "!", cmd = api.node.run.cmd, opts = opts("Run Command") }, + -- Non-Alphanumeric 非字母数字键 + { keys = "?", cmd = api.tree.toggle_help, opts = opts("Help") }, + { keys = ">", cmd = api.node.navigate.sibling.next, opts = opts("Next Sibling") }, + { keys = "<", cmd = api.node.navigate.sibling.prev, opts = opts("Previous Sibling") }, + { keys = ".", cmd = api.node.run.cmd, opts = opts("Run Command") }, + { keys = ";", cmd = api.node.run.cmd, opts = opts("Run Command") }, + { keys = "-", cmd = api.tree.change_root_to_parent, opts = opts("Up") }, + -- MOD KEYS Ctrl+ + { keys = "", cmd = api.tree.change_root_to_node, opts = opts("CD") }, + { keys = "", cmd = api.node.open.replace_tree_buffer, opts = opts("Open: In Place") }, + { keys = "", cmd = api.node.show_info_popup, opts = opts("Info") }, + { keys = "", cmd = api.fs.rename_sub, opts = opts("Rename: Omit Filename") }, + { keys = "", cmd = api.node.open.tab, opts = opts("Open: New Tab") }, + { keys = "", cmd = api.node.open.vertical, opts = opts("Open: Vertical Split") }, + { keys = "", cmd = api.node.open.horizontal, opts = opts("Open: Horizontal Split") }, + -- Mouse 鼠标键 + { keys = "<2-LeftMouse>", cmd = api.node.open.edit, opts = opts("Open") }, + { keys = "<2-RightMouse>", cmd = api.tree.change_root_to_node, opts = opts("CD") }, + } +end + +return M diff --git a/.config/nvim/lua/plugins/appearance.lua b/.config/nvim/lua/plugins/appearance.lua new file mode 100644 index 0000000..f6c58b3 --- /dev/null +++ b/.config/nvim/lua/plugins/appearance.lua @@ -0,0 +1,26 @@ +return { + { "catppuccin/nvim", name = "catppuccin" }, + { "RRethy/vim-illuminate" }, + { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require("plugins.mod.lualine") + end, + }, + { + "gbprod/yanky.nvim", + config = function() + require("yanky").setup({ + highlight = { + on_put = true, + on_yank = true, + timer = 500, + }, + }) + end + }, + { import = "plugins.mod.alpha-nvim" }, + { import = "plugins.mod.winbar-nvim"}, + { import = "plugins.mod.bufferline" }, +} diff --git a/.config/nvim/lua/plugins/completion.lua b/.config/nvim/lua/plugins/completion.lua new file mode 100644 index 0000000..6e77a56 --- /dev/null +++ b/.config/nvim/lua/plugins/completion.lua @@ -0,0 +1,8 @@ +return { + { import = "plugins.mod.nvim-cmp" }, + { + "L3MON4D3/LuaSnip", + dependencies = { "rafamadriz/friendly-snippets" }, + }, + { "rafamadriz/friendly-snippets" }, +} diff --git a/.config/nvim/lua/plugins/dashboard.lua b/.config/nvim/lua/plugins/dashboard.lua deleted file mode 100644 index ab6e2f4..0000000 --- a/.config/nvim/lua/plugins/dashboard.lua +++ /dev/null @@ -1,68 +0,0 @@ -return { - { - "nvimdev/dashboard-nvim", - lazy = false, -- As https://github.com/nvimdev/dashboard-nvim/pull/450, dashboard-nvim shouldn't be lazy-loaded to properly handle stdin. - opts = function() - local logo = [[ - ██╗███████╗ ██████╗ ███╗ ██╗██╗ ██╗ - ██║██╔════╝██╔═████╗████╗ ██║╚██╗ ██╔╝ - ██║███████╗██║██╔██║██╔██╗ ██║ ╚████╔╝ -██ ██║╚════██║████╔╝██║██║╚██╗██║ ╚██╔╝ -╚█████╔╝███████║╚██████╔╝██║ ╚████║ ██║ - ╚════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ - ]] - - logo = string.rep("\n", 8) .. logo .. "\n\n" - - local opts = { - theme = "doom", - hide = { - -- this is taken care of by lualine - -- enabling this messes up the actual laststatus setting after loading a file - statusline = false, - }, - config = { - header = vim.split(logo, "\n"), - -- stylua: ignore - center = { - { action = 'lua LazyVim.pick()()', desc = " Find File", icon = " ", key = "f" }, - { action = 'lua LazyVim.pick("oldfiles")()', desc = " Recent Files", icon = " ", key = "r" }, - { action = 'lua LazyVim.pick("live_grep")()', desc = " Find Text", icon = " ", key = "g" }, - { action = 'lua LazyVim.pick.config_files()()', desc = " Config", icon = " ", key = "c" }, - { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, - { action = "LazyExtras", desc = " Lazy Extras", icon = " ", key = "x" }, - { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, - { action = function() vim.api.nvim_input("qa") end, desc = " Quit", icon = " ", key = "q" }, - }, - footer = function() - local stats = require("lazy").stats() - local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - return { - "⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms", - } - end, - }, - } - - for _, button in ipairs(opts.config.center) do - button.desc = button.desc .. string.rep(" ", 43 - #button.desc) - button.key_format = " %s" - end - - -- open dashboard after closing lazy - if vim.o.filetype == "lazy" then - vim.api.nvim_create_autocmd("WinClosed", { - pattern = tostring(vim.api.nvim_get_current_win()), - once = true, - callback = function() - vim.schedule(function() - vim.api.nvim_exec_autocmds("UIEnter", { group = "dashboard" }) - end) - end, - }) - end - - return opts - end, - }, -} diff --git a/.config/nvim/lua/plugins/fileutils.lua b/.config/nvim/lua/plugins/fileutils.lua new file mode 100644 index 0000000..f2d4577 --- /dev/null +++ b/.config/nvim/lua/plugins/fileutils.lua @@ -0,0 +1,6 @@ +return { + { import = "plugins.mod.auto-session" }, + { import = "plugins.mod.nvim-tree" }, + { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } }, + { import = "plugins.mod.projects" } +} diff --git a/.config/nvim/lua/plugins/init.lua b/.config/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..7fa8521 --- /dev/null +++ b/.config/nvim/lua/plugins/init.lua @@ -0,0 +1,22 @@ +-- Entry point of the plugin manager +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", + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + { import = "plugins.appearance" }, + { import = "plugins.completion" }, + { import = "plugins.fileutils" }, + { import = "plugins.lsp" }, + { import = "plugins.syntax" }, + { import = "plugins.misc" }, +}) diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..2a35089 --- /dev/null +++ b/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,21 @@ + +return { + { import = "plugins.mod.lspconfig" }, + { "williamboman/mason.nvim", config = true }, + { + "williamboman/mason-lspconfig.nvim", + lazy = false, + dependencies = { + { "williamboman/mason.nvim" }, + { "neovim/nvim-lspconfig" }, + }, + config = function() + local mason_lspconfig = require("mason-lspconfig") + local servers = require("config.servers").servers + + mason_lspconfig.setup({ + ensure_installed = servers, + }) + end + }, +} diff --git a/.config/nvim/lua/plugins/misc.lua b/.config/nvim/lua/plugins/misc.lua new file mode 100644 index 0000000..15b2070 --- /dev/null +++ b/.config/nvim/lua/plugins/misc.lua @@ -0,0 +1,26 @@ +return { + { 'wakatime/vim-wakatime', lazy = false }, + { import = "plugins.mod.obsidian-nvim" }, + { + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, + }, + { + "github/copilot.vim", + lazy = false, + } +} diff --git a/.config/nvim/lua/plugins/mod/alpha-nvim.lua b/.config/nvim/lua/plugins/mod/alpha-nvim.lua new file mode 100644 index 0000000..3fe33dc --- /dev/null +++ b/.config/nvim/lua/plugins/mod/alpha-nvim.lua @@ -0,0 +1,52 @@ +-- alpha-nvim.lua +return { + { + 'goolord/alpha-nvim', + dependencies = { + -- 'echasnovski/mini.icons', + -- 'nvim-lua/plenary.nvim' + }, + config = function () + local alpha = require'alpha' + local dashboard = require'alpha.themes.dashboard' + dashboard.section.header.val = { + " ", + "================= =============== =============== ======== ========", + "\\\\ . . . . . . .\\\\ //. . . . . . .\\\\ //. . . . . . .\\\\ \\\\. . .\\\\// . . //", + "||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||", + "|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||", + "||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||", + "|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\\ . . . . ||", + "||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\\_ . .|. .||", + "|| . _|| || || || || ||_ . || || . _|| || || || |\\ `-_/| . ||", + "||_-' || .|/ || || \\|. || `-_|| ||_-' || .|/ || || | \\ / |-_.||", + "|| ||_-' || || `-_|| || || ||_-' || || | \\ / | `||", + "|| `' || || `' || || `' || || | \\ / | ||", + "|| .===' `===. .==='.`===. .===' /==. | \\/ | ||", + "|| .==' \\_|-_ `===. .===' _|_ `===. .===' _-|/ `== \\/ | ||", + "|| .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \\/ | ||", + "|| .==' _-' `-__\\._-' `-_./__-' `' |. /| | ||", + "||.==' _-' `' | /==.||", + "==' _-' j s 0 n y N E O V I M \\/ `==", + "\\ _-' `-_ /", + " `'' ``' ", + } + dashboard.section.buttons.val.leader = "SPC" + dashboard.section.buttons.val = { + -- leader = "SPC", + dashboard.button('p', '󰈞 查找项目', ':Telescope projects'), + dashboard.button('h', ' 历史文件', ':Telescope oldfiles'), + dashboard.button('l', ' 加载会话', ':SessionSearch'), + dashboard.button('c', ' 转到设置', ':Telescope find_files cwd=~/.config/nvim'), + dashboard.button('SPC q', '󱊷 退出', ':qa'), + } + dashboard.section.footer.val = "今日 " .. os.date("%Y-%m-%d %A") .. " " + + dashboard.config.opts.noautocmd = true + + -- vim.cmd[[autocmd User AlphaReady echo 'Alpha ready!']] + + alpha.setup(dashboard.config) + end + }; +} diff --git a/.config/nvim/lua/plugins/mod/auto-session.lua b/.config/nvim/lua/plugins/mod/auto-session.lua new file mode 100644 index 0000000..80ab9f7 --- /dev/null +++ b/.config/nvim/lua/plugins/mod/auto-session.lua @@ -0,0 +1,15 @@ +---@diagnostic disable: undefined-doc-name +return { + { + 'rmagatti/auto-session', + lazy = false, + + ---enables autocomplete for opts + ---@module "auto-session" + ---@type AutoSession.Config + opts = { + suppressed_dirs = { '~/', '~/Projects', '~/Downloads', '/' }, + -- log_level = 'debug', + } + } +} diff --git a/.config/nvim/lua/plugins/mod/bufferline.lua b/.config/nvim/lua/plugins/mod/bufferline.lua new file mode 100644 index 0000000..e389de8 --- /dev/null +++ b/.config/nvim/lua/plugins/mod/bufferline.lua @@ -0,0 +1,17 @@ +return { + "akinsho/bufferline.nvim", + dependencies = "nvim-tree/nvim-web-devicons", -- 图标支持 + config = function() + require("bufferline").setup({ + options = { + numbers = "ordinal", -- 显示 buffer 序号 + close_command = "bdelete! %d", -- 关闭 buffer 的命令 + right_mouse_command = "bdelete! %d", -- 右键关闭 + offsets = { + { filetype = "NvimTree", text = "资源管理器", text_align = "center" }, + }, + separator_style = "thin", + }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/mod/lspconfig.lua b/.config/nvim/lua/plugins/mod/lspconfig.lua new file mode 100644 index 0000000..a190a7c --- /dev/null +++ b/.config/nvim/lua/plugins/mod/lspconfig.lua @@ -0,0 +1,4 @@ +return { + "neovim/nvim-lspconfig", + lazy = false +} diff --git a/.config/nvim/lua/plugins/mod/lualine.lua b/.config/nvim/lua/plugins/mod/lualine.lua new file mode 100644 index 0000000..5cddc86 --- /dev/null +++ b/.config/nvim/lua/plugins/mod/lualine.lua @@ -0,0 +1,240 @@ +-- Author: shadmansaleh +-- Credit: glepnir +local lualine = require('lualine') + +-- Color table for highlights +-- stylua: ignore +local colors = { + bg = '#202328', + fg = '#bbc2cf', + yellow = '#ECBE7B', + cyan = '#008080', + darkblue = '#081633', + green = '#98be65', + orange = '#FF8800', + violet = '#a9a1e1', + magenta = '#c678dd', + blue = '#51afef', + red = '#ec5f67', +} + +local conditions = { + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand('%:t')) ~= 1 + end, + hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end, + check_git_workspace = function() + local filepath = vim.fn.expand('%:p:h') + local gitdir = vim.fn.finddir('.git', filepath .. ';') + return gitdir and #gitdir > 0 and #gitdir < #filepath + end, +} + +-- Config +local config = { + options = { + disabled_filetypes = { + statusline = { "NvimTree", "alpha" } + }, + -- Disable sections and component separators + component_separators = '', + section_separators = '', + theme = { + -- We are going to use lualine_c an lualine_x as left and + -- right section. Both are highlighted by c theme . So we + -- are just setting default looks o statusline + normal = { c = { fg = colors.fg, bg = colors.bg } }, + inactive = { c = { fg = colors.fg, bg = colors.bg } }, + }, + }, + sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + -- These will be filled later + lualine_c = {}, + lualine_x = {}, + }, + inactive_sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + lualine_c = {}, + lualine_x = {}, + }, +} + +-- Inserts a component in lualine_c at left section +local function ins_left(component) + table.insert(config.sections.lualine_c, component) +end + +-- Inserts a component in lualine_x at right section +local function ins_right(component) + table.insert(config.sections.lualine_x, component) +end + +ins_left { + function() + return '▊' + end, + color = { fg = colors.blue }, -- Sets highlighting of component + padding = { left = 0, right = 1 }, -- We don't need space before this +} + +ins_left { + -- mode component + function() + return '' + end, + color = function() + -- auto change color according to neovims mode + local mode_color = { + n = colors.red, + i = colors.green, + v = colors.blue, + [''] = colors.blue, + V = colors.blue, + c = colors.magenta, + no = colors.red, + s = colors.orange, + S = colors.orange, + [''] = colors.orange, + ic = colors.yellow, + R = colors.violet, + Rv = colors.violet, + cv = colors.red, + ce = colors.red, + r = colors.cyan, + rm = colors.cyan, + ['r?'] = colors.cyan, + ['!'] = colors.red, + t = colors.red, + } + return { fg = mode_color[vim.fn.mode()] } + end, + padding = { right = 1 }, +} + +-- ins_left { +-- -- filesize component +-- 'filesize', +-- cond = conditions.buffer_not_empty, +-- } + +-- ins_left { +-- 'filename', +-- cond = conditions.buffer_not_empty, +-- color = { fg = colors.magenta, gui = 'bold' }, +-- } + + +-- ins_left { 'location' } + +ins_right { 'progress', color = { fg = colors.fg, gui = 'bold' } } + +ins_left { + 'diagnostics', + sources = { 'nvim_diagnostic' }, + symbols = { error = ' ', warn = ' ', info = ' ' }, + diagnostics_color = { + error = { fg = colors.red }, + warn = { fg = colors.yellow }, + info = { fg = colors.cyan }, + }, +} + +ins_left { + function() + return vim.bo.filetype + end, + color = { fg = colors.blue, gui = 'bold' }, +} + +ins_left { + function() + return vim.bo.shiftwidth .. " space" + end, +} + + + +ins_left { + -- Lsp server name . + function() + local msg = 'No Active Lsp' + local buf_ft = vim.api.nvim_get_option_value('filetype', { buf = 0 }) + local clients = vim.lsp.get_clients() + if next(clients) == nil then + return msg + end + for _, client in ipairs(clients) do + local filetypes = client.config.filetypes + if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + return client.name + end + end + return msg + end, + icon = ' ', + color = { fg = '#ffffff', gui = 'bold' }, +} + +-- Insert mid section. You can make any number of sections in neovim :) +-- for lualine it's any number greater then 2 +ins_left { + function() + return '%=' + end, +} + +-- Add components to right sections +ins_right { + 'o:encoding', -- option component same as &encoding in viml + fmt = string.upper, -- I'm not sure why it's upper case either ;) + cond = conditions.hide_in_width, + color = { fg = colors.green, gui = 'bold' }, +} + +ins_right { + 'fileformat', + fmt = string.upper, + icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh + color = { fg = colors.green, gui = 'bold' }, +} + +ins_right { + 'branch', + icon = '', + color = { fg = colors.violet, gui = 'bold' }, +} + + +ins_right { + 'diff', + -- Is it me or the symbol for modified us really weird + symbols = { added = ' ', modified = '󰝤 ', removed = ' ' }, + diff_color = { + added = { fg = colors.green }, + modified = { fg = colors.orange }, + removed = { fg = colors.red }, + }, + cond = conditions.hide_in_width, +} + +ins_right { + function() + return '▊' + end, + color = { fg = colors.blue }, + padding = { left = 1 }, +} + +-- Now don't forget to initialize lualine +lualine.setup(config) diff --git a/.config/nvim/lua/plugins/mod/nvim-cmp.lua b/.config/nvim/lua/plugins/mod/nvim-cmp.lua new file mode 100644 index 0000000..100697b --- /dev/null +++ b/.config/nvim/lua/plugins/mod/nvim-cmp.lua @@ -0,0 +1,68 @@ +local function set_keymaps(keymaps_cmp) + local mappings = {} + for _, map in ipairs(keymaps_cmp) do + mappings[map.keys] = map.cmd + end + return mappings +end + +return { + "hrsh7th/nvim-cmp", + lazy = false, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + }, + config = function() + local cmp = require("cmp") + local lspconfig = require("lspconfig") + local capabilities = require("cmp_nvim_lsp").default_capabilities() + local servers_module = require("config.servers") + local servers = servers_module.servers + local servers_config = servers_module.server_config + -- 默认 LSP 配置 + local default_server_config = { + capabilities = capabilities, + } + + local raw_keymaps = require("keymaps").cmp_nvim_keymaps(cmp.mapping) + local mapped = set_keymaps(raw_keymaps) + -- 配置 nvim-cmp + cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert(mapped), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "copilot" }, + }, { + { name = "buffer" }, + { name = "path" }, + }), + }) + + -- 配置 cmdline 模式 + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "cmdline" }, + -- path completion is slow under WSL + -- Since WSL loads Windows Environment Variables + }, + }) + + -- 配置 LSP + for _, server in ipairs(servers) do + local config = vim.tbl_deep_extend("force", default_server_config, servers_config[server] or {}) + lspconfig[server].setup(config) + end + end, +} diff --git a/.config/nvim/lua/plugins/mod/nvim-tree.lua b/.config/nvim/lua/plugins/mod/nvim-tree.lua new file mode 100644 index 0000000..32c312c --- /dev/null +++ b/.config/nvim/lua/plugins/mod/nvim-tree.lua @@ -0,0 +1,37 @@ +local function my_on_attach(bufnr) + -- local keymaps = require("config.keymaps") + local api = require "nvim-tree.api" + local default_mode = { "n" } + local keymaps = require("keymaps") + + local function opts(desc) + return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + + local function set_keymaps(maps) + for _, map in ipairs(maps) do + local mode = map.mode or default_mode + vim.keymap.set(mode, map.keys, map.cmd, map.opts) + end + end + + local raw_keymaps = require("keymaps.nvim-tree").plugin(api, opts) + set_keymaps(raw_keymaps) +end + +return { + "nvim-tree/nvim-tree.lua", + version = "*", + lazy = false, + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + config = function() + require("nvim-tree").setup { + on_attach = my_on_attach, + sync_root_with_cwd = true, + respect_buf_cwd = true, + } + end +} diff --git a/.config/nvim/lua/plugins/mod/nvim-treesitter.lua b/.config/nvim/lua/plugins/mod/nvim-treesitter.lua new file mode 100644 index 0000000..2a627f3 --- /dev/null +++ b/.config/nvim/lua/plugins/mod/nvim-treesitter.lua @@ -0,0 +1,11 @@ +return { + "nvim-treesitter/nvim-treesitter", + run = ":TSUpdate", + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = { "markdown", "markdown_inline" }, + highlight = { enable = true }, + indent = { enable = true }, + }) + end, +} diff --git a/.config/nvim/lua/plugins/mod/obsidian-nvim.lua b/.config/nvim/lua/plugins/mod/obsidian-nvim.lua new file mode 100644 index 0000000..528036e --- /dev/null +++ b/.config/nvim/lua/plugins/mod/obsidian-nvim.lua @@ -0,0 +1,33 @@ +return { + "epwalsh/obsidian.nvim", + version = "*", -- recommended, use latest release instead of latest commit + lazy = true, + ft = "markdown", + -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: + -- event = { + -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. + -- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/*.md" + -- -- refer to `:h file-pattern` for more examples + -- "BufReadPre path/to/my-vault/*.md", + -- "BufNewFile path/to/my-vault/*.md", + -- }, + dependencies = { + -- Required. + "nvim-lua/plenary.nvim", + + -- see below for full list of optional dependencies 👇 + }, + opts = { + workspaces = { + { + name = "personal", + path = "/mnt/c/Users/citoy/Obsidian", + }, + }, + completion = { + nvim_cmp = true, + min_chars = 2 + } + -- see below for full list of options 👇 + }, +} diff --git a/.config/nvim/lua/plugins/mod/projects.lua b/.config/nvim/lua/plugins/mod/projects.lua new file mode 100644 index 0000000..9135b33 --- /dev/null +++ b/.config/nvim/lua/plugins/mod/projects.lua @@ -0,0 +1,15 @@ +return { + "ahmedkhalf/project.nvim", + config = function() + require("project_nvim").setup({ + detection_methods = { "lsp", "pattern" }, + patterns = { ".git", "Makefile", "package.json" }, + sync_root_with_cwd = true, + silent_chdir = true, + scope_chdir = "global", + }) + + require("telescope").load_extension("projects") + end, + dependencies = { "nvim-telescope/telescope.nvim" }, +} diff --git a/.config/nvim/lua/plugins/mod/winbar-nvim.lua b/.config/nvim/lua/plugins/mod/winbar-nvim.lua new file mode 100644 index 0000000..ca27161 --- /dev/null +++ b/.config/nvim/lua/plugins/mod/winbar-nvim.lua @@ -0,0 +1,39 @@ +return { + { + "fgheng/winbar.nvim", + config = function() + require("winbar").setup({ + enabled = true, + show_file_path = true, + show_symbols = true, + colors = { + path = '#9c1d91', + file_name = '', + symbols = '', + }, + icons = { + file_icon_default = '', + seperator = '>', + editor_state = '●', + lock_icon = '', + }, + exclude_filetype = { + 'help', + 'startify', + 'dashboard', + 'packer', + 'neogitstatus', + 'NvimTree', + 'Trouble', + 'alpha', + 'lir', + 'Outline', + 'spectre_panel', + 'toggleterm', + 'qf', + } + }) + end, + }, +} + diff --git a/.config/nvim/lua/plugins/syntax.lua b/.config/nvim/lua/plugins/syntax.lua new file mode 100644 index 0000000..f32cff2 --- /dev/null +++ b/.config/nvim/lua/plugins/syntax.lua @@ -0,0 +1,9 @@ +return { + { import = "plugins.mod.nvim-treesitter", }, + { 'echasnovski/mini.pairs', version = false, + config = function() + require("mini.pairs").setup() + end, + }, +} + diff --git a/.config/nvim/lua/vscode/keymaps.lua b/.config/nvim/lua/vscode/keymaps.lua deleted file mode 100644 index 6ac6d89..0000000 --- a/.config/nvim/lua/vscode/keymaps.lua +++ /dev/null @@ -1,40 +0,0 @@ -local keymap = vim.keymap.set - -vim.g.mapleader = " " - -vim.keymap.set({ "n", "v", "", "s", "x" }, "e", "k", { desc = "move cursor ⇧" }) -vim.keymap.set({ "n", "v", "", "s", "x" }, "n", "j", { desc = "move cursor ⇩" }) -vim.keymap.set({ "n", "v", "", "s", "x" }, "h", "h", { desc = "move cursor ⇦" }) -vim.keymap.set({ "n", "v", "", "s", "x" }, "i", "l", { desc = "move cursor ⇨" }) - -vim.keymap.set({ "n", "v", "", "s", "x" }, "N", "J", { desc = "Insert at the line start" }) -vim.keymap.set({ "n", "v", "", "s", "x" }, "E", "K", { desc = "Insert at the line start" }) -vim.keymap.set({ "n", "v", "", "s", "x" }, "I", "L", { desc = "Insert at the line start" }) - -vim.keymap.set({ "n", "v", "", "s", "x" }, "l", "i", { desc = "Insert mode" }) -vim.keymap.set({ "n", "v", "", "s", "x" }, "L", "I", { desc = "Insert at the line start" }) - -vim.keymap.set({ "n", "v", "", "s", "x" }, "k", "n", { desc = "Insert at the line start" }) -vim.keymap.set({ "n", "v", "", "s", "x" }, "K", "N", { desc = "Insert at the line start" }) - -vim.keymap.set({ "n", "v", "", "s", "x" }, "j", "e", { desc = "Insert at the line start" }) -vim.keymap.set({ "n", "v", "", "s", "x" }, "J", "E", { desc = "Insert at the line start" }) - -vim.opt.clipboard = "unnamedplus" -vim.opt.expandtab = true -vim.opt.tabstop = 5 -vim.opt.shiftwidth = 4 -vim.opt.autoindent = true -vim.opt.smartindent = true -vim.opt.wrap = true -vim.opt.scrolloff = 3 -vim.opt.hlsearch = true -vim.opt.incsearch = true -vim.opt.ignorecase = true -vim.opt.smartcase = true -vim.opt.number = true -vim.opt.relativenumber = true - --- VSCode commands -keymap({ "n", "v" }, "pp", "lua require('vscode').action('workbench.view.extension.project-manager')") -keymap({ "n", "v" }, "pP", "lua require('vscode').action('projectManager.listProjects')") diff --git a/.config/nvim/stylua.toml b/.config/nvim/stylua.toml index 964e1aa..d0295e9 100644 --- a/.config/nvim/stylua.toml +++ b/.config/nvim/stylua.toml @@ -1,3 +1,5 @@ -indent_type = "Spaces" -indent_width = 2 -column_width = 120 \ No newline at end of file +indent_type = "Spaces" +indent_width = 2 +column_width = 120 +[sort_requires] +enabled = true diff --git a/.config/readline/inputrc b/.config/readline/inputrc new file mode 100644 index 0000000..9cffebe --- /dev/null +++ b/.config/readline/inputrc @@ -0,0 +1,19 @@ +# $XDG_CONFIG_HOME/readline/inputrc + +# Colemak Key Remaps +set editing-mode vi +set keymap vi +set show-mode-in-prompt on + +set mark-directories on +set completion-ignore-case on +set show-all-if-ambiguous on +set bell-style none + +$if mode=vi + "n": next-history + "e": previous-history + "l": vi-insertion-mode + "L": vi-insert-beg + "i": forward-char +$endif diff --git a/.config/remote.bashrc b/.config/remote.bashrc new file mode 100644 index 0000000..0811d77 --- /dev/null +++ b/.config/remote.bashrc @@ -0,0 +1,161 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + #alias grep='grep --color=auto' + #alias fgrep='fgrep --color=auto' + #alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases +alias ll='ls -l' +alias la='ls -A' +alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +source ~/.nvm/nvm.sh + + +# Append to original bashrc for minimal setup +# echo $DOTFILES/wsl/.bashrc >> ~/.bashrc +bind 'set show-mode-in-prompt on' +set -o vi + +alias sv="sudo vim" +alias v="vim" + +alias sdocker="sudo docker" +alias scompose="sudo docker compose up -d" +alias sdockerps="sudo docker ps" +alias netl="netstat -tulnp" + +alias apt="sudo apt" +alias apts="apt search" +alias apti="sudo apt install" +aptr() { + sudo apt remove $1 || sudo apt autoremove +} +alias aptu="sudo apt upgrade && sudo apt update" + +alias l="ls -lah" +alias ll="ls -l" +alias la="ls -lA" + +bind 'set vi-ins-mode-string "sh"' +bind 'set vi-cmd-mode-string "vi"' + + + +PS2=" > " +update_ps1() { + local last_status=$? + if [[ $last_status -eq 0 ]]; then + PS1="\[\e[0;33m\]  \[\e[0;35m\][\A] \[\e[0;32m\]\u @ \h \[\e[0;34m\]in \w \[\e[0;32m\]✔\n \$ \[\e[0m\]" + else + PS1="\[\e[0;33m\]  \[\e[0;35m\][\A] \[\e[0;32m\]\u @ \h \[\e[0;34m\]in \w \[\e[0;31m\]✘\n \$ \[\e[0m\]" + fi +} + +PROMPT_COMMAND=update_ps1 diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index e94c541..be831e1 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -49,7 +49,7 @@ bind -r N resize-pane -D 5 bind -r E resize-pane -U 5 bind -r I resize-pane -R 5 bind C-h select-window -t :- -bind C-l select-window -t :+ +bind C-i select-window -t :+ bind ` resize-pane -Z # Status Bar diff --git a/.config/vim/noxdg.vimrc b/.config/vim/noxdg.vimrc new file mode 100644 index 0000000..376cc2a --- /dev/null +++ b/.config/vim/noxdg.vimrc @@ -0,0 +1,106 @@ +" $VIMRUNTIME refers to the versioned system directory where Vim stores its +" system runtime files -- /usr/share/vim/vim. +" +" Vim will load $VIMRUNTIME/defaults.vim if the user does not have a vimrc. +" This happens after /etc/vim/vimrc(.local) are loaded, so it will override +" any settings in these files. +" +" If you don't want that to happen, uncomment the below line to prevent +" defaults.vim from being loaded. +" let g:skip_defaults_vim = 1 +" +" If you would rather _use_ default.vim's settings, but have the system or +" user vimrc override its settings, then uncomment the line below. +" source $VIMRUNTIME/defaults.vim + +" All Debian-specific settings are defined in $VIMRUNTIME/debian.vim and +" sourced by the call to :runtime you can find below. If you wish to change +" any of those settings, you should do it in this file or +" /etc/vim/vimrc.local, since debian.vim will be overwritten everytime an +" upgrade of the vim packages is performed. It is recommended to make changes +" after sourcing debian.vim so your settings take precedence. + +runtime! debian.vim + +" Uncomment the next line to make Vim more Vi-compatible +" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes +" numerous options, so any other options should be set AFTER changing +" 'compatible'. +"set compatible + +" Vim5 and later versions support syntax highlighting. Uncommenting the next +" line enables syntax highlighting by default. +syntax on + +" If using a dark background within the editing area and syntax highlighting +" turn on this option as well +"set background=dark + +" Uncomment the following to have Vim jump to the last position when +" reopening a file +"au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif + +" Uncomment the following to have Vim load indentation rules and plugins +" according to the detected filetype. +"filetype plugin indent on + +" The following are commented out as they cause vim to behave a lot +" differently from regular Vi. They are highly recommended though. +set showcmd " Show (partial) command in status line. +set showmatch " Show matching brackets. +set ignorecase " Do case insensitive matching +set smartcase " Do smart case matching +set incsearch " Incremental search +"set autowrite " Automatically save before commands like :next and :make +" set hidden " Hide buffers when they are abandoned +"set mouse=a " Enable mouse usage (all modes) + +" Source a global configuration file if available +if filereadable("/etc/vim/vimrc.local") + source /etc/vim/vimrc.local +endif + +" This is a minimal setup of vimrc +" ln -sf $DOTFILES/.config/vim/vimrc $XDG_CONFIG_HOME/vim/vimrc + +" Colemak Keys + +" Arrow remap +noremap n j +noremap e k +noremap i l +noremap N J +noremap E K +noremap I L + +" Similar position to i +noremap l i +noremap L I +" ne[k]st +noremap k n +noremap K N +" [j]ump +noremap j e +noremap J E + +" Normal minimal setup + +noremap Y y$ +set expandtab +set tabstop=4 +set shiftwidth=4 +set autoindent +set smartindent +set wrap +set scrolloff=3 +set hlsearch +set incsearch +set ignorecase +set smartcase + +set number +set relativenumber + +set laststatus=2 +set showcmd +set statusline=%<%f\ %h%m%r\ %=\ [%l,%v]\ [%p%%]\ [\ %Y]\ [󱑉\ %{strftime('%H:%M:%S')}] diff --git a/.config/vim/vimrc b/.config/vim/vimrc index 5622443..6402a0a 100644 --- a/.config/vim/vimrc +++ b/.config/vim/vimrc @@ -40,6 +40,11 @@ set smartcase set number set relativenumber +set laststatus=2 +set showcmd +set statusline=%<%f\ %h%m%r\ %=\ [%l,%v]\ [%p%%]\ [\ %Y]\ [󱑉\ %{strftime('%H:%M:%S')}] + + " XDG Directory Specifications " Reference to https://jorenar.com/blog/vim-xdg diff --git a/.gitignore b/.gitignore index ec8687e..0b80c5f 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,5 @@ vscode/ # OS generated files .DS_Store + +.venv/ diff --git a/mac/.zshrc b/mac/.zshrc index afefec8..35da61f 100644 --- a/mac/.zshrc +++ b/mac/.zshrc @@ -12,7 +12,6 @@ export ARCHFLAGS="-arch arm64" ### Navigation ### # Absolute navigation alias doku="cd ~/doku && ls" -alias dotfiles="cd $DOTFILES && ls" alias docs="cd ~/Documents" alias dt="cd ~/Desktop" alias down="cd ~/Downloads" @@ -42,3 +41,8 @@ path=('$HOME/.juliaup/bin' $path) export PATH # <<< juliaup initialize <<< + +# macOS # + +alias xclip="pbcopy" +alias clip="pbcopy" diff --git a/setup/mac_setup.sh b/setup/mac_setup.sh index 4b0640d..62b9976 100644 --- a/setup/mac_setup.sh +++ b/setup/mac_setup.sh @@ -6,12 +6,12 @@ echo "Running the setup script" -# Xcode Command Line Tools +# Xcode Command Line Tools echo "[INFO] Installing Xcode Command Line Tools" echo "[ACTION] Request Human Takeover" xcode-select --install -# System Preferences +# System Preferences # Installation Sources echo "[INFO] Setting Installation Sources" # sudo spctl --master-disable @@ -29,10 +29,10 @@ defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Docu defaults write com.apple.finder _FXSortFoldersFirst -bool true defaults write com.apple.finder FinderSpawnTab -bool true # Don't show External Hard Drives on Desktop -defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool false -defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false -defaults write com.apple.finder ShowMountedServersOnDesktop -bool false -defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool false +defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool false +defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false +defaults write com.apple.finder ShowMountedServersOnDesktop -bool false +defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool false # No DS_Store on Network defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true # Keyboard @@ -45,7 +45,7 @@ echo "[INFO] Setting Dock Preferences" defaults write com.apple.dock persistent-apps -array defaults write com.apple.dock persistent-others -array defaults write com.apple.dock autohide -bool true # Autohide Dock -defaults write com.apple.dock autohide-time-modifier -float 0.5 +defaults write com.apple.dock autohide-time-modifier -float 0.5 defaults write com.apple.dock autohide-delay -float 0 # Immediately Autohide Dock defaults write com.apple.dock show-recents -bool false # Hide Recent Applications killall Dock @@ -118,7 +118,7 @@ brew install --formula lazygit # Shell brew install --formula starship # Shell Prompt brew install --formula tmux -brew install --formula zellij +brew install --formula zellij # System Info brew install --formula fastfetch # 這輩子有了 # Utilities @@ -176,6 +176,7 @@ brew install --cask iina # Security brew install --cask keyguard +brew install --cask protonmail-bridge # Engineering brew install --cask ltspice # `sudo` @@ -205,9 +206,9 @@ brew install --cask betterdisplay brew install --cask karabiner-elements # Keyboard Customization brew install --cask scroll-reverser # Let Trackpad and Mouse Scroll in the Same Direction like Windows # brew install --cask orbstack # VM -# brew install --cask docker +# brew install --cask docker brew install --cask clash-verge-rev -brew install --cask chatbox # LLM API Caller +brew install --cask chatbox # LLM API Caller brew install --cask follow # RSS Reader @@ -220,7 +221,7 @@ mas install 451108668 # QQ curl -fsSL https://raw.githubusercontent.com/rime/plum/master/rime-install | bash # Set default apps (duti) -# The id of the app can be found by running +# The id of the app can be found by running # `osascript -e 'id of app "AppName"'` brew install --formula duti echo "[INFO] Setting Default Apps" @@ -285,4 +286,4 @@ mkdir -p $DOTFILES/powershell_private mkdir -p ~/Documents/Source/Forks mkdir -p ~/Documents/Source/Projects mkdir -p ~/Documents/Source/Scripts -mkdir -p ~/Documents/Source/Tutorials \ No newline at end of file +mkdir -p ~/Documents/Source/Tutorials diff --git a/wsl/.bashrc b/wsl/.bashrc index 12821d6..ce32ed5 100644 --- a/wsl/.bashrc +++ b/wsl/.bashrc @@ -1,18 +1,16 @@ # Append to original bashrc for minimal setup # echo $DOTFILES/wsl/.bashrc >> ~/.bashrc +bind 'set show-mode-in-prompt on' set -o vi -bind '"\en": "\C-j"' -bind '"\ee": "\C-k"' -bind '"\ei": "\C-l"' +bind -m vi-command '"n": next-history' +bind -m vi-command '"e": previous-history' +bind -m vi-command '"l": vi-insertion-mode' +bind -m vi-command '"L": vi-insert-beg' +bind -m vi-command '"i": forward-char' -bind '"\el": "\ei"' -bind '"\eL": "\eI"' +# bind -m vi-insert '"\C-r": reverse-search-history"' +# bind -m vi-insert '"\C-l": clear-screen' -bind '"\ek": "\en"' -bind '"\eK": "\eN"' - -bind '"\ej": "\ee"' -bind '"\eJ": "\eE"' - -bind '"\eY": "\ey$"' \ No newline at end of file +bind -m vi-command '"j": vi-end-word' +bind -m vi-command '"J": vi-end-word' diff --git a/wsl/.zshrc b/wsl/.zshrc index ac09f6f..a34d974 100644 --- a/wsl/.zshrc +++ b/wsl/.zshrc @@ -2,10 +2,13 @@ # ln -s $DOTFILES/wsl/.zshrc $XDG_CONFIG_HOME/zsh/.zshrc ### Variables ### +export IS_WSL=true export DOTFILES="$HOME/.dotfiles" for file in $DOTFILES/zsh/*.zsh; do source $file done +source $DOTFILES/wsl/winterop.zsh +source $ZDOTDIR/.zprivate.zsh export ARCHFLAGS="-arch x86_64" # Absolute navigation @@ -77,4 +80,4 @@ export VCPKG_ROOT=~/vcpkg alias pac="sudo pacman" alias paci="sudo pacman -S" alias pacr="sudo pacman -R" -alias pacu="sudo pacman -Ss" +alias pacu="sudo pacman -Syu" diff --git a/wsl/winterop.zsh b/wsl/winterop.zsh new file mode 100644 index 0000000..50e780a --- /dev/null +++ b/wsl/winterop.zsh @@ -0,0 +1,15 @@ +alias clip="clip.exe" +alias xclip="clip.exe" +alias paste='pwsh.exe -NoProfile -Command "Get-Clipboard"' +alias dark-mode='pwsh.exe -Command "dark-mode" 2>&1 /dev/null' +alias winfetch='pwsh.exe -NoProfile -Command "winfetch"' +alias psw="tasklist.exe" +alias killw="taskkill.exe" +alias shutdownw="shutdown.exe /s /t 0" +alias rebootw="shutdown.exe /r /t 0" +alias ipconfig="ipconfig.exe" +alias netstatw="netstat.exe" +alias diskpart="diskpart.exe" +alias winget="winget.exe" +alias pastew='pwsh.exe -NoProfile -Command "Get-Clipboard"' +alias ollama="ollama.exe" diff --git a/zsh/alias.zsh b/zsh/alias.zsh index 73d5579..9949f23 100644 --- a/zsh/alias.zsh +++ b/zsh/alias.zsh @@ -11,8 +11,8 @@ alias clpp='clang++ -std=c++2b' alias python=python3 # Set the default Python version to Python 3 alias py=python # Alias for Python alias pip=pip3 # Alias for pip -alias bashcfg="nvim ~/.bashrc" -alias zshcfg="nvim ~/.zshrc" +# alias bashcfg="nvim ~/.bashrc" +alias zshcfg="nvim $ZDOTDIR/.zshrc" alias shcfg=zshcfg alias reload="source $ZDOTDIR/.zshrc" alias nvimrc="nvim $XDG_CONFIG_HOME/nvim/" @@ -37,7 +37,7 @@ alias cf=cfiles # Functions # mkcd() { - mkdir -p -- "$0" && cd -P -- "$1" + mkdir -p $1 && cd $1 } cdls(){ cd $1 && ls diff --git a/zsh/config.zsh b/zsh/config.zsh index 3beb84a..4ac50b3 100644 --- a/zsh/config.zsh +++ b/zsh/config.zsh @@ -1,13 +1,24 @@ # ZSH Config # export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH +export PATH=$HOME/.local/share/gem/ruby/3.3.0/bin:$PATH # Ruby Executables HIST_STAMPS="yyyy-mm-dd" +HISTSIZE=10000 +SAVEHIST=10000 + +export NVM_DIR="$HOME/.config/nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + # plugins=(git web-search jsontools z vi-mode zsh-syntax-highlighting zsh-autosuggestions) # Plugins (Manually Managed) # # $ZDOTDIR/plugins -source $ZDOTDIR/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh +# echo "[DEBUG] Loading plugins..." +# echo $ZDOTDIR +# Load zsh-syntax-highlighting before zsh-history-substring-search +# Reference: https://github.com/zsh-users/zsh-history-substring-search?tab=readme-ov-file#usage source $ZDOTDIR/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh +source $ZDOTDIR/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh source $ZDOTDIR/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh # Tools Related Environment Variables # @@ -20,21 +31,21 @@ VISUAL="nvim" # ~/.azure/ -> $XDG_DATA_HOME/azure/ export AZURE_CONFIG_DIR="$XDG_DATA_HOME"/azure +# ~/.cargo/ -> $XDG_DATA_HOME/cargo +export CARGO_HOME="$XDG_DATA_HOME"/cargo # ~/.cgdb/ -> $XDG_CONFIG_HOME/cgdb/ export CGDB_DIR="$XDG_CONFIG_HOME"/cgdb -# ~/.nv -> $XDG_CACHE_HOME/nv (CUDA) -# macOS does not have Cuda; Check if CUDA is installed -if [ "$(uname)" != "Darwin" ] && [ -d "/usr/local/cuda" ]; then - export CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv -fi # ~/.docker -> $XDG_CONFIG_HOME/docker export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker # ~/.dotnet -> $XDG_DATA_HOME/dotnet -export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet +# Not working +# export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet # ~/.gnupg -> $XDG_CONFIG_HOME/gnupg export GNUPGHOME="$XDG_DATA_HOME"/gnupg # ~/go -> $XDG_DATA_HOME/go export GOPATH="$XDG_DATA_HOME"/go +# ~/.inputrc -> $XDG_CONFIG_HOME/readline/inputrc +export INPUTRC="$XDG_CONFIG_HOME"/readline/inputrc # ~/.juliaup/ -> $XDG_DATA_HOME/julia/ export JULIA_DEPOT_PATH="$XDG_DATA_HOME/julia:$JULIA_DEPOT_PATH" # Check if node is installed @@ -50,9 +61,22 @@ if command -v node > /dev/null; then export NPM_CONFIG_CACHE="$XDG_CACHE_HOME"/npm export NPM_CONFIG_TMP="$XDG_RUNTIME_DIR"/npm fi +# ~/.nv -> $XDG_CACHE_HOME/nv (CUDA) +# macOS does not have Cuda; Check if CUDA is installed +if [ "$(uname)" != "Darwin" ] && [ -d "/usr/local/cuda" ]; then + export CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv +fi +# ~/,parallel -> $XDG_CONFIG_HOME/parallel +export PARALLEL_HOME="$XDG_CONFIG_HOME"/parallel # ~/.python_history -> $XDG_DATA_HOME/python/history # Works only with Python 3.13.0a3 and later export PYTHON_HISTORY="$XDG_DATA_HOME"/python/history +# ~/.screenrc -> $XDG_CONFIG_HOME/screen/screenrc +export SCREENRC="$XDG_CONFIG_HOME"/screen/screenrc +# ~/.screen/ -> $XDG_RUNTIME_DIR/screen +export SCREENDIR="${XDG_RUNTIME_DIR}/screen" +# ~/.spacemacs/ -> $XDG_CONFIG_HOME/spacemacs +export SPACEMACSDIR="$XDG_CONFIG_HOME"/spacemacs # ~/.tldrc/ -> $XDG_CACHE_HOME/tldr export TLDR_CACHE_DIR="$XDG_CACHE_HOME"/tldr # ~/.w3m -> $XDG_DATA_HOME/w3m @@ -65,6 +89,10 @@ alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"' # ~/.z -> $XDG_DATA_HOME/z export _Z_DATA="$XDG_DATA_HOME/z" # ~/.zcompdump* -> $XDG_CACHE_HOME/zsh/zcompdump* -compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION" +# compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION" # ~/.zsh_history -> $XDG_STATE_HOME/zsh/history export HISTFILE="$XDG_STATE_HOME"/zsh/history + +# https://unix.stackexchange.com/questions/33994/ +# Use `set -k` to mark leading `#` as a comment character +set -k diff --git a/zsh/keymap.zsh b/zsh/keymap.zsh index 32cceb0..9b2e537 100644 --- a/zsh/keymap.zsh +++ b/zsh/keymap.zsh @@ -3,9 +3,9 @@ bindkey -v # Vi Keybindings # Colemak hnei # bindkey -M vicmd 'h' vi-backward-char # No change -bindkey -M vicmd 'n' down-line-or-history -bindkey -M vicmd 'e' up-line-or-history -bindkey -M vicmd 'i' vi-forward-char +bindkey -M vicmd 'n' down-line-or-history +bindkey -M vicmd 'e' up-line-or-history +bindkey -M vicmd 'i' vi-forward-char # Similar position to [i] in QWERTY bindkey -M vicmd 'l' vi-insert @@ -17,4 +17,7 @@ bindkey -M vicmd 'K' vi-rev-repeat-search bindkey -M vicmd 'j' vi-forward-word-end bindkey -M vicmd 'J' vi-forward-blank-word-end # Use N to Join -bindkey -M vicmd 'N' vi-join \ No newline at end of file +bindkey -M vicmd 'N' vi-join + +# Search History with [r]everse (default emacs keybinding) +bindkey '^R' history-incremental-search-backward diff --git a/zsh/navi.zsh b/zsh/navi.zsh index 27e008f..e74d95c 100644 --- a/zsh/navi.zsh +++ b/zsh/navi.zsh @@ -6,4 +6,6 @@ alias ....="cd ../../.." alias .....="cd ../../../.." alias ......="cd ../../../../.." -eval "$(zoxide init zsh)" \ No newline at end of file +function - { cd - } + +eval "$(zoxide init zsh)" diff --git a/zsh/update.sh b/zsh/update.sh index 6bb0f30..95d24da 100644 --- a/zsh/update.sh +++ b/zsh/update.sh @@ -15,4 +15,5 @@ done if [ which brew > /dev/null ]; then brew update brew upgrade -fi \ No newline at end of file +fi +