From dc94f3b0a84d11f1248c35be6ed1dfd6fa1ea1a2 Mon Sep 17 00:00:00 2001 From: Pratik Tripathy Date: Mon, 30 Dec 2024 23:23:17 +0530 Subject: [PATCH] chore(nvim): - Spell check autocommand moved to filetype-based-keymaps.lua - Remove quickfix traversal keybindings - Lualine organized better: Git, debug on left; key, file type, location on right --- common/.config/nvim/lua/config/autocmd.lua | 12 +--- .../lua/config/filetype-based-keymaps.lua | 10 +++ common/.config/nvim/lua/config/keymaps.lua | 5 +- common/.config/nvim/lua/plugins/ui.lua | 70 ++++++++++--------- 4 files changed, 49 insertions(+), 48 deletions(-) diff --git a/common/.config/nvim/lua/config/autocmd.lua b/common/.config/nvim/lua/config/autocmd.lua index 712b4fa..59c9e65 100644 --- a/common/.config/nvim/lua/config/autocmd.lua +++ b/common/.config/nvim/lua/config/autocmd.lua @@ -1,5 +1,5 @@ +-- Auto reload existing session if not vim.g.vscode then - -- Auto reload existing session vim.api.nvim_create_autocmd("VimEnter", { group = vim.api.nvim_create_augroup("restore_session", { clear = true }), callback = function() @@ -12,13 +12,3 @@ if not vim.g.vscode then nested = true, }) end - --- Enable spell check on markdown and text files -vim.api.nvim_create_autocmd("FileType", { - group = vim.api.nvim_create_augroup("spell_check_text_files", { clear = true }), - pattern = { "markdown", "gitcommit", "text" }, - callback = function() - vim.opt.spell = true - end, - nested = true, -}) diff --git a/common/.config/nvim/lua/config/filetype-based-keymaps.lua b/common/.config/nvim/lua/config/filetype-based-keymaps.lua index abdddd1..c377eec 100644 --- a/common/.config/nvim/lua/config/filetype-based-keymaps.lua +++ b/common/.config/nvim/lua/config/filetype-based-keymaps.lua @@ -25,3 +25,13 @@ vim.api.nvim_create_autocmd("FileType", { end, nested = true, }) + +-- Enable spell check on markdown and text files +vim.api.nvim_create_autocmd("FileType", { + group = vim.api.nvim_create_augroup("spell_check_text_files", { clear = true }), + pattern = { "markdown", "gitcommit", "text" }, + callback = function() + vim.opt.spell = true + end, + nested = true, +}) diff --git a/common/.config/nvim/lua/config/keymaps.lua b/common/.config/nvim/lua/config/keymaps.lua index e0570da..99f9be9 100644 --- a/common/.config/nvim/lua/config/keymaps.lua +++ b/common/.config/nvim/lua/config/keymaps.lua @@ -60,9 +60,8 @@ vim.keymap.set({ "n", "v" }, "xb", function() end, { desc = "Save and close current buffer" }) -- Traverse quickfix --- TODO: Friendly message when no quickfix -vim.keymap.set("n", "[q", vim.cmd.cprev, { desc = "Previous quickfix" }) -vim.keymap.set("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" }) +-- vim.keymap.set("n", "[q", vim.cmd.cprev, { desc = "Previous quickfix" }) +-- vim.keymap.set("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" }) -- Clear searches vim.keymap.set({ "i", "n" }, "", "noh", { desc = "Escape and clear hlsearch" }) diff --git a/common/.config/nvim/lua/plugins/ui.lua b/common/.config/nvim/lua/plugins/ui.lua index c091def..1a736cc 100644 --- a/common/.config/nvim/lua/plugins/ui.lua +++ b/common/.config/nvim/lua/plugins/ui.lua @@ -282,8 +282,27 @@ return { extensions = { "neo-tree", "lazy" }, sections = { lualine_a = { "mode" }, - lualine_b = { "branch" }, - + lualine_b = { + "branch", + { + "diff", + symbols = { + added = config.icons.git.added, + modified = config.icons.git.modified, + removed = config.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_c = { { "diagnostics", @@ -294,11 +313,14 @@ return { hint = config.icons.diagnostics.Hint, }, }, - { "filetype", padding = { left = 1, right = 1 } }, { - "filename", - file_status = true, - path = 1, + function() + return " " .. require("dap").status() + end, + cond = function() + return package.loaded["dap"] and require("dap").status() ~= "" + end, + color = config.fg("Debug"), }, }, @@ -321,36 +343,16 @@ return { end, color = config.fg("Constant"), }, - { - function() - return " " .. require("dap").status() - end, - cond = function() - return package.loaded["dap"] and require("dap").status() ~= "" - end, - color = config.fg("Debug"), - }, - { - "diff", - symbols = { - added = config.icons.git.added, - modified = config.icons.git.modified, - removed = config.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 = {}, + lualine_y = { + { + "filename", + file_status = true, + path = 1, + }, + { "filetype", padding = { left = 1, right = 1 } }, + }, lualine_z = { { "progress", separator = " ", padding = { left = 1, right = 0 } }, { "location", padding = { left = 0, right = 1 } },