diff --git a/common/.config/ideavim/ideavimrc b/common/.config/ideavim/ideavimrc index b905358..a87d661 100644 --- a/common/.config/ideavim/ideavimrc +++ b/common/.config/ideavim/ideavimrc @@ -4,6 +4,25 @@ " Enable IdeaVim plugins https://jb.gg/ideavim-plugins "source ~/.vimrc +" FIX: "u" appears randomly when deleting words and other times +" TODO: Keep the mappings same across Neovim & Idea +" Keymap structure: +" b+: [B]buffer Operations +" c+: [C]oding Stuff +" d+: [D]iagnostics +" f+: [F]ile Operations +" g+: [G]it Operations +" l+: [L]ist Things +" n+: [N]eoVim Stuff +" s+: Grep/[S]earch Things +" t+: [T]est runner stuff +" x+: close/dismiss something +" e: explorer +" j: EasyMotion jump +" p: Paste from system clipboard +" y: Copy selected stuff to system clipboard +" u: Open undo-tree side-panel +" v: Open document symbol explorer """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" source ~/.vim/configs.vim @@ -19,11 +38,7 @@ set tabstop=4 set shiftwidth=4 " Searches -set hlsearch " highlight search occurrences -set ignorecase " ignore case in search patterns -set smartcase " no ignore case when pattern is uppercase -set incsearch " show search results while typing -set wrapscan " searches wrap around the end of the file +set hlsearch ignorecase smartcase incsearch wrapscan " Common settings set gdefault " substitute all occurrences in line diff --git a/common/.config/nvim/init.lua b/common/.config/nvim/init.lua index 0f7cda9..91265df 100644 --- a/common/.config/nvim/init.lua +++ b/common/.config/nvim/init.lua @@ -7,20 +7,25 @@ -- Check past messages -> :messages -- TIP: Keymap structure: --- b: buffer --- g: git/github --- c: Coding Stuff +-- b+: [B]buffer Operations +-- c+: [C]oding Stuff +-- d+: [D]iagnostics +-- f+: [F]ile Operations +-- g+: [G]it Operations +-- l+: [L]ist Things +-- n+: [N]eoVim Stuff +-- s+: Grep/[S]earch Things +-- t+: [T]est runner stuff +-- x+: close/dismiss something -- e: explorer --- l: list & find something --- s: Grep/Search over something --- x: close/dismiss something --- l: List some stuff --- d: [D]iagnostics --- t: Test runner stuff +-- j: EasyMotion jump +-- p: Paste from system clipboard +-- y: Copy selected stuff to system clipboard +-- u: Open undo-tree side-panel +-- v: Open document symbol explorer -- TODO: -- Reduce noice timeout --- WhichKey add hints -- Load keymaps & options require("config") diff --git a/common/.config/nvim/lua/plugins/coding-debug.lua b/common/.config/nvim/lua/plugins/coding-debug.lua index 54d671a..ab4bf81 100644 --- a/common/.config/nvim/lua/plugins/coding-debug.lua +++ b/common/.config/nvim/lua/plugins/coding-debug.lua @@ -34,11 +34,11 @@ return { }) vim.keymap.set("n", "", dap.continue, { desc = "Debug: Start/Continue" }) - vim.keymap.set("n", "", dap.step_into, { desc = "Debug: Step Into" }) - vim.keymap.set("n", "", dap.step_over, { desc = "Debug: Step Over" }) - vim.keymap.set("n", "", dap.step_out, { desc = "Debug: Step Out" }) - vim.keymap.set("n", "b", dap.toggle_breakpoint, { desc = "Debug: Toggle Breakpoint" }) - vim.keymap.set("n", "B", function() + vim.keymap.set("n", "", dap.step_into, { desc = "Debug: Step Into" }) + vim.keymap.set("n", "", dap.step_over, { desc = "Debug: Step Over" }) + vim.keymap.set("n", "", dap.step_out, { desc = "Debug: Step Out" }) + vim.keymap.set("n", "", dap.toggle_breakpoint, { desc = "Debug: Toggle Breakpoint" }) + vim.keymap.set("n", "", function() dap.set_breakpoint(vim.fn.input("Breakpoint condition: ")) end, { desc = "Debug: Set Breakpoint" }) diff --git a/common/.config/nvim/lua/plugins/coding-formatting.lua b/common/.config/nvim/lua/plugins/coding-formatting.lua index 28c2c5f..15b060b 100644 --- a/common/.config/nvim/lua/plugins/coding-formatting.lua +++ b/common/.config/nvim/lua/plugins/coding-formatting.lua @@ -21,9 +21,9 @@ return { graphql = { { "prettierd", "prettier" } }, lua = { "stylua" }, python = { "black" }, - sh = { "shfmt", "shellharden" }, - bash = { "shfmt", "shellharden" }, - zsh = { "shfmt", "shellharden" }, + sh = { { "shfmt", "shellharden" } }, + bash = { { "shfmt", "shellharden" } }, + zsh = { { "shfmt", "shellharden" } }, ["*"] = { "codespell" }, ["_"] = { "trim_whitespace" }, }, diff --git a/common/.config/nvim/lua/plugins/coding-git.lua b/common/.config/nvim/lua/plugins/coding-git.lua index 43a120b..7fe8768 100644 --- a/common/.config/nvim/lua/plugins/coding-git.lua +++ b/common/.config/nvim/lua/plugins/coding-git.lua @@ -11,11 +11,12 @@ return { signs = { add = { text = "+" }, change = { text = "~" }, - delete = { text = "_" }, - topdelete = { text = "‾" }, + delete = { text = "—" }, + topdelete = { text = "—" }, changedelete = { text = "~" }, - untracked = { text = "▎" }, + untracked = { text = "┆" }, }, + attach_to_untracker = true, on_attach = function(bufnr) local gs = package.loaded.gitsigns @@ -46,30 +47,34 @@ return { return "" end, { expr = true, desc = "Jump to previous git hunk" }) + -- Staging -- Actions - -- visual mode - map("v", "ghr", function() - gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) - end, { desc = "reset git hunk" }) - -- normal mode - map("n", "ghp", gs.preview_hunk, { desc = "preview git hunk" }) - map("n", "gp", gs.preview_hunk, { desc = "preview git hunk" }) + map("n", "gsh", gs.stage_hunk, { desc = "Git: Stage Hunk" }) + map("n", "gsu", gs.undo_stage_hunk, { desc = "Git: Undo Stage Hunk" }) + map("n", "gsb", gs.stage_buffer, { desc = "Git: Stage Current File" }) + map("n", "gr", gs.reset_hunk, { desc = "Git: reset hunk" }) - map("n", "ghr", gs.reset_hunk, { desc = "git reset hunk" }) - map("n", "ghb", function() - gs.blame_line({ full = false }) - end, { desc = "git blame line" }) - map("n", "ghD", gs.diffthis, { desc = "git diff against index" }) - map("n", "ghd", function() + -- visual mode + map("v", "gsH", function() + gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, { desc = "Git: Visual Stage Hunk" }) + map("v", "gsR", function() + gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, { desc = "Git: Visual Reset Hunk" }) + + -- normal mode + map("n", "gp", gs.preview_hunk, { desc = "Git: Preview hunk" }) + map("n", "gD", gs.diffthis, { desc = "Git: diff against index" }) + map("n", "gd", function() gs.diffthis("~") - end, { desc = "git diff against last commit" }) + end, { desc = "Git: diff against last commit" }) -- Toggles - map("n", "gtb", gs.toggle_current_line_blame, { desc = "toggle git blame line" }) - map("n", "gtd", gs.toggle_deleted, { desc = "toggle git show deleted" }) + map("n", "gtb", gs.toggle_current_line_blame, { desc = "Git: toggle blame line" }) + map("n", "gtd", gs.toggle_deleted, { desc = "Git: toggle show deleted" }) -- Text object - map({ "o", "x" }, "gih", ":Gitsigns select_hunk", { desc = "select git hunk" }) + map({ "o", "x" }, "gih", ":Gitsigns select_hunk", { desc = "Git: Visual select hunk" }) end, }, }, diff --git a/common/.config/nvim/lua/plugins/coding-lint.lua b/common/.config/nvim/lua/plugins/coding-lint.lua index 7e68e99..fffadc2 100644 --- a/common/.config/nvim/lua/plugins/coding-lint.lua +++ b/common/.config/nvim/lua/plugins/coding-lint.lua @@ -8,46 +8,10 @@ return { -- Linters are only required for dynamically typed languages lint.linters_by_ft = { - -- javascript = { "eslint_d" }, - -- typescript = { "eslint_d" }, - -- javascriptreact = { "eslint_d" }, - -- typescriptreact = { "eslint_d" }, - svelte = { "eslint_d" }, python = { "pylint" }, ["*"] = { "codespell" }, } - -- Uncomment and use the below section in `package.json` to enable eslint_d - -- "eslintConfig": { - -- "root": true, - -- "extends": [ - -- "eslint:recommended", - -- "plugin:@typescript-eslint/recommended" - -- ], - -- "parser": "@typescript-eslint/parser", - -- "parserOptions": { - -- "project": [ - -- "./tsconfig.json" - -- ] - -- }, - -- "plugins": [ - -- "@typescript-eslint" - -- ], - -- "rules": { - -- "@typescript-eslint/strict-boolean-expressions": [ - -- 2, - -- { - -- "allowString": false, - -- "allowNumber": false - -- } - -- ] - -- }, - -- "ignorePatterns": [ - -- "src/**/*.test.ts", - -- "src/frontend/generated/*" - -- ] - -- } - local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { diff --git a/common/.config/nvim/lua/plugins/coding-lsp.lua b/common/.config/nvim/lua/plugins/coding-lsp.lua index c315e94..a79af96 100644 --- a/common/.config/nvim/lua/plugins/coding-lsp.lua +++ b/common/.config/nvim/lua/plugins/coding-lsp.lua @@ -10,17 +10,17 @@ local on_attach = function(_, bufnr) vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc }) end - nmap("cr", vim.lsp.buf.rename, "[R]e[n]ame") + nmap("cr", vim.lsp.buf.rename, "[R]ename Symbol") nmap("ca", vim.lsp.buf.code_action, "[C]ode [A]ction") -- See `:help K` for why this keymap nmap("K", vim.lsp.buf.hover, "Hover Documentation") -- nmap("", vim.lsp.buf.signature_help, "Signature Documentation") -- Lesser used LSP functionality - nmap("cws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") - nmap("cwl", function() + nmap("cS", require("telescope.builtin").lsp_dynamic_workspace_symbols, "Search Workspace [S]symbols") + nmap("clf", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, "[W]orkspace [L]ist Folders") + end, "Workspace [L]ist [F]olders") -- Create a command `:Format` local to the LSP buffer vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) @@ -34,11 +34,11 @@ return { "neovim/nvim-lspconfig", dependencies = { -- Automatically install LSPs to stdpath for neovim - { "williamboman/mason.nvim", config = true }, + { "williamboman/mason.nvim", config = true }, { "williamboman/mason-lspconfig.nvim" }, -- Useful status updates for LSP - { "j-hui/fidget.nvim", opts = {} }, + { "j-hui/fidget.nvim", opts = {} }, { "folke/neodev.nvim" }, }, @@ -84,7 +84,7 @@ return { cssls = {}, dockerls = {}, docker_compose_language_service = {}, - html = { filetypes = { 'html', 'twig', 'hbs' } }, + html = { filetypes = { "html", "twig", "hbs" } }, jsonls = {}, pyright = {}, rust_analyzer = {}, @@ -99,7 +99,7 @@ return { includeInlayPropertyDeclarationTypeHints = true, includeInlayFunctionLikeReturnTypeHints = true, includeInlayEnumMemberValueHints = true, - } + }, }, javascript = { inlayHints = { @@ -111,8 +111,8 @@ return { includeInlayPropertyDeclarationTypeHints = true, includeInlayFunctionLikeReturnTypeHints = true, includeInlayEnumMemberValueHints = true, - } - } + }, + }, }, } @@ -141,14 +141,14 @@ return { "j-hui/fidget.nvim", opts = { progress = { - poll_rate = 1, -- How and when to poll for progress messages - suppress_on_insert = true, -- Suppress new messages while in insert mode - ignore_done_already = true, -- Ignore new tasks that are already complete + poll_rate = 1, -- How and when to poll for progress messages + suppress_on_insert = true, -- Suppress new messages while in insert mode + ignore_done_already = true, -- Ignore new tasks that are already complete ignore_empty_message = true, -- Ignore new tasks that don't contain a message - ignore = {}, -- List of LSP servers to ignore + ignore = {}, -- List of LSP servers to ignore display = { - render_limit = 1, -- How many LSP messages to show at once + render_limit = 1, -- How many LSP messages to show at once skip_history = true, -- Whether progress notifications should be omitted from history }, }, diff --git a/common/.config/nvim/lua/plugins/editor.lua b/common/.config/nvim/lua/plugins/editor.lua index 3e3993d..2655b44 100644 --- a/common/.config/nvim/lua/plugins/editor.lua +++ b/common/.config/nvim/lua/plugins/editor.lua @@ -56,7 +56,7 @@ return { mappings = { ["s"] = "open_split", -- horizontal split ["v"] = "open_vsplit", -- vertical split - ["Y"] = function(state) + ["Y"] = function(state) -- Copy file's path to + register local node = state.tree:get_node() local path = node:get_id() vim.fn.setreg("+", path, "c") @@ -142,9 +142,9 @@ return { -- Display undotree { "mbbill/undotree", - config = function() - vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) - end, + keys = { + { "u", "UndotreeToggle", desc = "Toggle Undotree panel" }, + }, }, -- Show buffers like VS Code tabs @@ -157,6 +157,8 @@ return { keys = { { "bp", "BufferLineTogglePin", desc = "Toggle buffer-pin" }, { "xo", "BufferLineCloseOthers", desc = "Delete other buffers" }, + { "[b", "BufferLineCyclePrev", desc = "Prev buffer" }, + { "]b", "BufferLineCycleNext", desc = "Next buffer" }, }, opts = { options = { @@ -176,9 +178,6 @@ return { text_align = "left", }, }, - numbers = function(opts) - return string.format("%s", opts.raise(opts.id)) - end, }, }, config = function(_, opts) @@ -306,9 +305,6 @@ return { inc_rename = true, }, }, - keys = { - { "nx", "NoiceDismiss", desc = "Dismiss all [N]oice notifications" }, - }, }, -- Set lualine as statusline diff --git a/common/.config/nvim/lua/plugins/telescope.lua b/common/.config/nvim/lua/plugins/telescope.lua index b25e856..d3b1913 100644 --- a/common/.config/nvim/lua/plugins/telescope.lua +++ b/common/.config/nvim/lua/plugins/telescope.lua @@ -79,8 +79,8 @@ return { vim.keymap.set("n", "lv", require("telescope.builtin").vim_options, { desc = "[L]ist [V]im Options" }) -- Git things -> [G]it - vim.keymap.set("n", "gb", require("telescope.builtin").git_branches, { desc = "List [G]it [B]ranches" }) - vim.keymap.set("n", "gc", require("telescope.builtin").git_commits, { desc = "List [G]it [C]omits" }) + vim.keymap.set("n", "glb", require("telescope.builtin").git_branches, { desc = "List [G]it [B]ranches" }) + vim.keymap.set("n", "glc", require("telescope.builtin").git_commits, { desc = "List [G]it [C]omits" }) -- LSP Things -> [C]oding vim.keymap.set("n", "cd", require("telescope.builtin").diagnostics, { desc = "[C]ode: List [D]iagnostics" }) diff --git a/common/.config/nvim/lua/plugins/utility-plugs.lua b/common/.config/nvim/lua/plugins/utility-plugs.lua index 3a30806..dd96df3 100644 --- a/common/.config/nvim/lua/plugins/utility-plugs.lua +++ b/common/.config/nvim/lua/plugins/utility-plugs.lua @@ -30,11 +30,16 @@ return { config = function() -- document existing key chains require("which-key").register({ - ["e"] = { name = "[E]xplorer", _ = "which_key_ignore" }, ["c"] = { name = "[C]ode", _ = "which_key_ignore" }, - ["g"] = { name = "[G]it", _ = "which_key_ignore" }, - ["s"] = { name = "[S]earch", _ = "which_key_ignore" }, - ["t"] = { name = "[T]oggle", _ = "which_key_ignore" }, + ["b"] = { name = "[B]buffer Operations", _ = "which_key_ignore" }, + ["d"] = { name = "[D]iagnostics", _ = "which_key_ignore" }, + ["f"] = { name = "[F]ile Operations", _ = "which_key_ignore" }, + ["g"] = { name = "[G]it Operations", _ = "which_key_ignore" }, + ["l"] = { name = "[L]ist Things", _ = "which_key_ignore" }, + ["n"] = { name = "[N]VIM Operations", _ = "which_key_ignore" }, + ["s"] = { name = "[S]earch/Grep Things", _ = "which_key_ignore" }, + ["t"] = { name = "Unit [T]est Operations", _ = "which_key_ignore" }, + ["x"] = { name = "Delete/Remove Something", _ = "which_key_ignore" }, }) -- register which-key VISUAL mode -- required for visual hs (hunk stage) to work @@ -46,19 +51,13 @@ return { }, -- Session management. Saves your session in the background + -- TIP: autocmd to autoload sessions at: ../config/autocmd.lua { "folke/persistence.nvim", event = "BufReadPre", opts = { -- Session files stored at: ~/.config/nvim/sessions/ dir = vim.fn.expand(vim.fn.stdpath("config") .. "/sessions/"), - options = vim.opt.sessionoptions:get(), - -- NOTE: autocmd to autoload sessions at: ../config/autocmd.lua - }, - keys = { - -- Since we are auto-restoring sessions, keymaps aren't required - -- { "sr", function() require("persistence").load() end, desc = "[R]estore [S]ession" }, - -- { "sl", function() require("persistence").load({ last = true }) end, desc = "[R]estore [L]ast Session" }, }, }, diff --git a/common/.profile b/common/.profile index 759ee99..75d53db 100644 --- a/common/.profile +++ b/common/.profile @@ -27,6 +27,7 @@ ################################################################################## eval "$(ssh-agent -s)" >/dev/null +# shellcheck disable=SC3045 ulimit -n 10240 [ ! -f "$XDG_CONFIG_HOME/templates/.gitignore" ] || export GITIGNORE_TEMPLATE="$XDG_CONFIG_HOME/templates/.gitignore"