- Shell script formatting: shellharden made 2nd choice and NOT 2nd formatter
- Keymaps organized: more accessible, more consistent

TODO
- Ideavimrc fix backspace issue
- Make the keymaps in sync with NVim
This commit is contained in:
Pratik Tripathy
2024-03-08 20:40:35 +05:30
parent 72076d0ad9
commit 617a620e70
11 changed files with 102 additions and 117 deletions

View File

@@ -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")

View File

@@ -34,11 +34,11 @@ return {
})
vim.keymap.set("n", "<F5>", dap.continue, { desc = "Debug: Start/Continue" })
vim.keymap.set("n", "<F1>", dap.step_into, { desc = "Debug: Step Into" })
vim.keymap.set("n", "<F2>", dap.step_over, { desc = "Debug: Step Over" })
vim.keymap.set("n", "<F3>", dap.step_out, { desc = "Debug: Step Out" })
vim.keymap.set("n", "<leader>b", dap.toggle_breakpoint, { desc = "Debug: Toggle Breakpoint" })
vim.keymap.set("n", "<leader>B", function()
vim.keymap.set("n", "<F11>", dap.step_into, { desc = "Debug: Step Into" })
vim.keymap.set("n", "<S-F11>", dap.step_over, { desc = "Debug: Step Over" })
vim.keymap.set("n", "<F12>", dap.step_out, { desc = "Debug: Step Out" })
vim.keymap.set("n", "<F9>", dap.toggle_breakpoint, { desc = "Debug: Toggle Breakpoint" })
vim.keymap.set("n", "<S-F9>", function()
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
end, { desc = "Debug: Set Breakpoint" })

View File

@@ -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" },
},

View File

@@ -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 "<Ignore>"
end, { expr = true, desc = "Jump to previous git hunk" })
-- Staging
-- Actions
-- visual mode
map("v", "<leader>ghr", function()
gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, { desc = "reset git hunk" })
-- normal mode
map("n", "<leader>ghp", gs.preview_hunk, { desc = "preview git hunk" })
map("n", "<leader>gp", gs.preview_hunk, { desc = "preview git hunk" })
map("n", "<leader>gsh", gs.stage_hunk, { desc = "Git: Stage Hunk" })
map("n", "<leader>gsu", gs.undo_stage_hunk, { desc = "Git: Undo Stage Hunk" })
map("n", "<leader>gsb", gs.stage_buffer, { desc = "Git: Stage Current File" })
map("n", "<leader>gr", gs.reset_hunk, { desc = "Git: reset hunk" })
map("n", "<leader>ghr", gs.reset_hunk, { desc = "git reset hunk" })
map("n", "<leader>ghb", function()
gs.blame_line({ full = false })
end, { desc = "git blame line" })
map("n", "<leader>ghD", gs.diffthis, { desc = "git diff against index" })
map("n", "<leader>ghd", function()
-- visual mode
map("v", "<leader>gsH", function()
gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, { desc = "Git: Visual Stage Hunk" })
map("v", "<leader>gsR", function()
gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, { desc = "Git: Visual Reset Hunk" })
-- normal mode
map("n", "<leader>gp", gs.preview_hunk, { desc = "Git: Preview hunk" })
map("n", "<leader>gD", gs.diffthis, { desc = "Git: diff against index" })
map("n", "<leader>gd", function()
gs.diffthis("~")
end, { desc = "git diff against last commit" })
end, { desc = "Git: diff against last commit" })
-- Toggles
map("n", "<leader>gtb", gs.toggle_current_line_blame, { desc = "toggle git blame line" })
map("n", "<leader>gtd", gs.toggle_deleted, { desc = "toggle git show deleted" })
map("n", "<leader>gtb", gs.toggle_current_line_blame, { desc = "Git: toggle blame line" })
map("n", "<leader>gtd", gs.toggle_deleted, { desc = "Git: toggle show deleted" })
-- Text object
map({ "o", "x" }, "gih", ":<C-U>Gitsigns select_hunk<CR>", { desc = "select git hunk" })
map({ "o", "x" }, "gih", ":<C-U>Gitsigns select_hunk<CR>", { desc = "Git: Visual select hunk" })
end,
},
},

View File

@@ -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" }, {

View File

@@ -10,17 +10,17 @@ local on_attach = function(_, bufnr)
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
end
nmap("<leader>cr", vim.lsp.buf.rename, "[R]e[n]ame")
nmap("<leader>cr", vim.lsp.buf.rename, "[R]ename Symbol")
nmap("<leader>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("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
-- Lesser used LSP functionality
nmap("<leader>cws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
nmap("<leader>cwl", function()
nmap("<leader>cS", require("telescope.builtin").lsp_dynamic_workspace_symbols, "Search Workspace [S]symbols")
nmap("<leader>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
},
},

View File

@@ -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", "<leader>u", vim.cmd.UndotreeToggle)
end,
keys = {
{ "<leader>u", "<cmd>UndotreeToggle<cr>", desc = "Toggle Undotree panel" },
},
},
-- Show buffers like VS Code tabs
@@ -157,6 +157,8 @@ return {
keys = {
{ "<leader>bp", "<Cmd>BufferLineTogglePin<CR>", desc = "Toggle buffer-pin" },
{ "<leader>xo", "<Cmd>BufferLineCloseOthers<CR>", desc = "Delete other buffers" },
{ "[b", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev buffer" },
{ "]b", "<cmd>BufferLineCycleNext<cr>", 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 = {
{ "<leader>nx", "<cmd>NoiceDismiss<CR>", desc = "Dismiss all [N]oice notifications" },
},
},
-- Set lualine as statusline

View File

@@ -79,8 +79,8 @@ return {
vim.keymap.set("n", "<leader>lv", require("telescope.builtin").vim_options, { desc = "[L]ist [V]im Options" })
-- Git things -> [G]it
vim.keymap.set("n", "<leader>gb", require("telescope.builtin").git_branches, { desc = "List [G]it [B]ranches" })
vim.keymap.set("n", "<leader>gc", require("telescope.builtin").git_commits, { desc = "List [G]it [C]omits" })
vim.keymap.set("n", "<leader>glb", require("telescope.builtin").git_branches, { desc = "List [G]it [B]ranches" })
vim.keymap.set("n", "<leader>glc", require("telescope.builtin").git_commits, { desc = "List [G]it [C]omits" })
-- LSP Things -> [C]oding
vim.keymap.set("n", "<leader>cd", require("telescope.builtin").diagnostics, { desc = "[C]ode: List [D]iagnostics" })

View File

@@ -30,11 +30,16 @@ return {
config = function()
-- document existing key chains
require("which-key").register({
["<leader>e"] = { name = "[E]xplorer", _ = "which_key_ignore" },
["<leader>c"] = { name = "[C]ode", _ = "which_key_ignore" },
["<leader>g"] = { name = "[G]it", _ = "which_key_ignore" },
["<leader>s"] = { name = "[S]earch", _ = "which_key_ignore" },
["<leader>t"] = { name = "[T]oggle", _ = "which_key_ignore" },
["<leader>b"] = { name = "[B]buffer Operations", _ = "which_key_ignore" },
["<leader>d"] = { name = "[D]iagnostics", _ = "which_key_ignore" },
["<leader>f"] = { name = "[F]ile Operations", _ = "which_key_ignore" },
["<leader>g"] = { name = "[G]it Operations", _ = "which_key_ignore" },
["<leader>l"] = { name = "[L]ist Things", _ = "which_key_ignore" },
["<leader>n"] = { name = "[N]VIM Operations", _ = "which_key_ignore" },
["<leader>s"] = { name = "[S]earch/Grep Things", _ = "which_key_ignore" },
["<leader>t"] = { name = "Unit [T]est Operations", _ = "which_key_ignore" },
["<leader>x"] = { name = "Delete/Remove Something", _ = "which_key_ignore" },
})
-- register which-key VISUAL mode
-- required for visual <leader>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
-- { "<leader>sr", function() require("persistence").load() end, desc = "[R]estore [S]ession" },
-- { "<leader>sl", function() require("persistence").load({ last = true }) end, desc = "[R]estore [L]ast Session" },
},
},