diff --git a/.config/git/.gitconfig b/.config/git/.gitconfig index 5c7266c..1fc64b7 100644 --- a/.config/git/.gitconfig +++ b/.config/git/.gitconfig @@ -20,3 +20,5 @@ required = true [safe] directory = %(prefix)///wsl.localhost/Arch/home/js0ny/inf2c/coursework-2-mips-simulator-js0ny +[url "git@github.com:"] + insteadOf = https://github.com/ 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..b47d2a3 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,8 +1,20 @@ --- 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 配置文件 +]] +-- 加载配置 +require("config.options") +-- 加载键位映射 +require("config.keymaps") + +-- 加载插件 +require("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..511ae29 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -1,146 +1,128 @@ --- 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" }) +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 global_default_mode + vim.keymap.set(mode, map.keys, map.cmd, opts) + end +end + + + +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 = "N", cmd = "J" }, + { keys = "E", cmd = "K" }, + { keys = "I", cmd = "L" }, + { 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$"}, +} + +local keymaps_lsp = { +} + +local keymaps_nvim_tree_general = { + { mode = "n", keys = "e", cmd = ":NvimTreeToggle" }, +} + +set_keymaps(keymaps_basic, global_default_opts, global_default_mode) +set_keymaps(keymaps_lsp, global_default_opts, global_default_mode) +set_keymaps(keymaps_nvim_tree_general, global_default_opts, global_default_mode) + +function M.nvim_tree_keymaps(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 + +--- `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.complete(), desc = "Trigger completion" }, + { keys = "", cmd = map.abort(), desc = "Abort completion" }, + } +end + +return M diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index 415944a..9d1e34f 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -1,3 +1,50 @@ --- 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 diff --git a/.config/nvim/lua/config/servers.lua b/.config/nvim/lua/config/servers.lua new file mode 100644 index 0000000..6b0ddb8 --- /dev/null +++ b/.config/nvim/lua/config/servers.lua @@ -0,0 +1,22 @@ +--- Available LSP goes here +--- Check https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md +--- for available server and name +local 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 +} + +return servers diff --git a/.config/nvim/lua/plugins/appearance.lua b/.config/nvim/lua/plugins/appearance.lua new file mode 100644 index 0000000..f50330e --- /dev/null +++ b/.config/nvim/lua/plugins/appearance.lua @@ -0,0 +1,12 @@ +return { + { "catppuccin/nvim", name = "catppuccin" }, + { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + config = function() + require("plugins.mod.lualine") + end, + }, + { import = "plugins.mod.alpha-nvim" }, +} + diff --git a/.config/nvim/lua/plugins/completion.lua b/.config/nvim/lua/plugins/completion.lua new file mode 100644 index 0000000..3fcbf1f --- /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..d279055 --- /dev/null +++ b/.config/nvim/lua/plugins/fileutils.lua @@ -0,0 +1,5 @@ +return { + { import = "plugins.mod.auto-session" }, + { import = "plugins.mod.nvim-tree" }, + { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } }, +} 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..a398bfb --- /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") + + 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..b052619 --- /dev/null +++ b/.config/nvim/lua/plugins/misc.lua @@ -0,0 +1,22 @@ +return { + { 'wakatime/vim-wakatime', lazy = false }, + { 'epwalsh/obsidian.nvim', lazy = true }, + { + "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)", + }, + }, + } +} 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..d09b28e --- /dev/null +++ b/.config/nvim/lua/plugins/mod/alpha-nvim.lua @@ -0,0 +1,59 @@ +-- 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('c', ' 新建文件', ':enew'), + dashboard.button('SPC f f', '󰈞 查找文件', ':Telescope find_files'), + dashboard.button('SPC f h', ' 历史文件', ':Telescope oldfiles'), + dashboard.button('SPC s l', ' 加载会话', ':SessionSearch'), -- 加载会话 + dashboard.button('SPC q', '󱊷 退出', ':qa'), + } + local handle = io.popen('fortune') + --- Handle the case where fortune is not installed + local fortune = "" + if handle then + fortune = handle:read("*a") + handle:close() + end + dashboard.section.footer.val = "今日 " .. os.date("%Y-%m-%d %A") .. " " .. fortune + + 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/lspconfig.lua b/.config/nvim/lua/plugins/mod/lspconfig.lua new file mode 100644 index 0000000..c9779c7 --- /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..29d40b4 --- /dev/null +++ b/.config/nvim/lua/plugins/mod/lualine.lua @@ -0,0 +1,223 @@ +-- 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_left { '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 }, + }, +} + +-- 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, +} + +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 = ' LSP:', + color = { fg = '#ffffff', gui = 'bold' }, +} + +-- 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..f5c7224 --- /dev/null +++ b/.config/nvim/lua/plugins/mod/nvim-cmp.lua @@ -0,0 +1,71 @@ + +--- Available LSP goes here +--- Check https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md +--- for available server and name + + + +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 capabitilies = require("cmp_nvim_lsp").default_capabilities() + local servers = require("config.servers") + + cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + sources = cmp.config.sources( + -- This order defines the priority of sources. + { + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, + { + { name = "buffer" }, + { name = "path" }, + } + ), + }) + local keymaps = require("config.keymaps") + local keymaps_cmp = keymaps.cmp_nvim_keymaps(cmp.mapping) + + local function set_keymaps() + local mappings = {} + for _, map in ipairs(keymaps_cmp) do + mappings[map.keys] = map.cmd + end + return mappings + end + cmp.setup.mapping = cmp.mapping.preset.insert(set_keymaps()) + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "cmdline" }, + -- Use `path` is slow under WSL since WSL loads Windows paths + -- https://github.com/zsh-users/zsh-syntax-highlighting/issues/790 + -- { name = "path" }, + } + }) + + for _, server in ipairs(servers) do + lspconfig[server].setup({ + capabilities = capabitilies, + }) + 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..fbd65f0 --- /dev/null +++ b/.config/nvim/lua/plugins/mod/nvim-tree.lua @@ -0,0 +1,41 @@ +local function my_on_attach(bufnr) + -- local keymaps = require("config.keymaps") + local api = require "nvim-tree.api" + local default_mode = { "n" } + local keymaps = require("config.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 = keymaps.nvim_tree_keymaps(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, + update_focused_file = { + enable = true, + update_cwd = true, + }, + } + end +} diff --git a/.config/nvim/lua/plugins/syntax.lua b/.config/nvim/lua/plugins/syntax.lua new file mode 100644 index 0000000..bfff1e0 --- /dev/null +++ b/.config/nvim/lua/plugins/syntax.lua @@ -0,0 +1,6 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + }, +} 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/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/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/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/zsh/alias.zsh b/zsh/alias.zsh index 73d5579..689ea2f 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/" diff --git a/zsh/config.zsh b/zsh/config.zsh index 4c1e78b..8da7225 100644 --- a/zsh/config.zsh +++ b/zsh/config.zsh @@ -1,6 +1,11 @@ # 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" + +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) # @@ -24,21 +29,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 @@ -54,9 +59,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