From 6dd62b4cc8b2142135632483bfb55501645d55b8 Mon Sep 17 00:00:00 2001 From: Mohammad Reza Karimi Date: Wed, 21 Jan 2026 19:06:11 -0500 Subject: big updates --- plugin/10_options.lua | 4 +- plugin/11_keymaps.lua | 46 ++++++++++++++++------ plugin/12_autocommands.lua | 6 --- plugin/plugins/gitsigns.lua | 1 + plugin/plugins/mini.lua | 94 ++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 130 insertions(+), 21 deletions(-) create mode 100644 plugin/plugins/gitsigns.lua (limited to 'plugin') diff --git a/plugin/10_options.lua b/plugin/10_options.lua index ce3b235..f56dc6c 100644 --- a/plugin/10_options.lua +++ b/plugin/10_options.lua @@ -48,6 +48,4 @@ vim.g.tex_no_error = 1 vim.g.tex_comment_nospell = 1 vim.opt.tags:append({ "tags;~", ".tags;~" }) -vim.o.laststatus = 1 -vim.o.statusline = "%<%f %h%w%m%r %=%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}%{% &busy > 0 ? '◐ ' : '' %}%{% luaeval('(package.loaded[''vim.diagnostic''] and #vim.diagnostic.count() ~= 0 and vim.diagnostic.status() .. '' '') or '''' ') %}%{% v:lua.require'mo.statusline'.lsp_status() %}%{% &ruler ? ( &rulerformat == '' ? '%-14.(%l,%c%V%) %P' : &rulerformat ) : '' %}" - +vim.o.laststatus = 2 diff --git a/plugin/11_keymaps.lua b/plugin/11_keymaps.lua index 9dcd4f4..9758fb3 100644 --- a/plugin/11_keymaps.lua +++ b/plugin/11_keymaps.lua @@ -1,3 +1,6 @@ +-- vim: foldmethod=marker + +-- stylua: ignore start local map = function(mode, lhs, rhs, desc) vim.keymap.set(mode, lhs, rhs, { desc = desc }) end local nmap = function(lhs, rhs, desc) map("n", lhs, rhs, desc) end local mapleader = function(mode, suffix, rhs, desc) map(mode, "" .. suffix, rhs, desc) end @@ -21,38 +24,59 @@ vim.keymap.set({ "n", "x" }, "k", [[v:count == 0 ? 'gk' : 'k']], { expr = true, nmap("gK", "K", "use the keywordprg instead of hover") -map('t', '', [[]], "go to normal mode from terminal mode") -map('t', '', '', "map to literal ESC in terminal mode") +map("t", "", [[]], "go to normal mode from terminal mode") +map("t", "", "", "map to literal ESC in terminal mode") + +-- stylua: ignore end --- lua exec +-- lua exec {{{ nmapleader("x", function() - local line = "lua " .. vim.api.nvim_get_current_line() - vim.api.nvim_command(line) - vim.api.nvim_input("") + local line = "lua " .. vim.api.nvim_get_current_line() + vim.api.nvim_command(line) + vim.api.nvim_input("") end, "execute lua line and go to next line") + mapleader("x", "x", ":lua") nmap("x", "luafile %") +-- }}} --- lsp and format +-- lsp and format {{{ nmapleader("e", "lua vim.diagnostic.open_float()") nmap("gd", "lua vim.lsp.buf.definition()") nmap("", "lua require'conform'.format{async=true}") +-- }}} --- fzf +-- fzf {{{ +-- stylua: ignore start nmap("", "FzfLua files", "fzf: find files") nmap("", "FzfLua resume", "fzf: resume") nmap("", "FzfLua buffers", "fzf: buffers") nmap("", "FzfLua oldfiles", "fzf: oldfiles") -nmapleader("fg", "FzfLua live_grep_native", "fzf: grep") -nmapleader("fc", 'FzfLua files prompt="Nvim Config>\\ " cwd=~/.config/nvim', "fzf: search config") -nmapleader("fp", 'lua FzfLua.files({cwd=vim.fn.stdpath("data").."/site/pack/core/opt/"})', "fzf: search plugins") +nmapleader("fg", "FzfLua live_grep", "fzf: grep") +nmapleader("fc", "FzfLua files cwd=~/.config/nvim", "fzf: search config") +nmapleader("fp", "FzfLua files cwd=~/.local/share/nvim/site/pack/core/opt", "fzf: search plugins") nmapleader("fh", "FzfLua helptags", "fzf: help tags") nmapleader("fk", "FzfLua keymaps", "fzf: keymaps") +-- stylua: ignore end +-- }}} + +-- fzf misc {{{ map("n", "z=", "FzfLua spell_suggest", "fzf: suggest spelling") +vim.keymap.set("i", "", function() + vim.cmd([[packadd fzf-lua]]) + require("fzf-lua").complete_file({ + cmd = "rg --files", + winopts = { preview = { hidden = true } }, + }) +end, { silent = true, desc = "fzf: complete file" }) +-- }}} + -- git nmapleader("gs", "Git", "git status") -- qf +-- stylua: ignore start nmapleader("q", function() require("quicker").toggle() end, "Toggle quickfix list") +-- stylua: ignore end diff --git a/plugin/12_autocommands.lua b/plugin/12_autocommands.lua index 829ed97..73bce84 100644 --- a/plugin/12_autocommands.lua +++ b/plugin/12_autocommands.lua @@ -27,12 +27,6 @@ au("LspAttach", { desc = "add sign column when LSP is attached and redraw status", }) -au("LspDetach", { - group = group, - command = "redrawstatus", - desc = "redraw status when LSP is dettached", -}) - au("FileType", { group = group, pattern = "fugitive,git,help,man,qf,query,scratch", diff --git a/plugin/plugins/gitsigns.lua b/plugin/plugins/gitsigns.lua new file mode 100644 index 0000000..d16d238 --- /dev/null +++ b/plugin/plugins/gitsigns.lua @@ -0,0 +1 @@ +require("gitsigns").setup() diff --git a/plugin/plugins/mini.lua b/plugin/plugins/mini.lua index 24027e0..92f86c6 100644 --- a/plugin/plugins/mini.lua +++ b/plugin/plugins/mini.lua @@ -32,6 +32,98 @@ vim.schedule(function() }) end) +vim.schedule(function() require("mini.icons").setup() end) + +local section_filename = function() + local st = "%{% &busy > 0 ? '◐ ' : '' %}" + -- In terminal always use plain name + if vim.bo.buftype == "terminal" then + return st .. "%t" + elseif _G.MiniStatusline.is_truncated(140) then + -- File name with 'truncate', 'modified', 'readonly' flags + -- Use relative path if truncated + return st .. "%f%m%r" + else + -- Use fullpath if not truncated + return st .. "%F%m%r" + end +end + +local section_git = function() + if _G.MiniStatusline.is_truncated(40) then return "" end + local summary = vim.b.gitsigns_head + if summary == nil then return "" end + return " " .. (summary == "" and "-" or summary) +end + +local section_diff = function() + if _G.MiniStatusline.is_truncated(75) then return "" end + local summary = vim.b.gitsigns_status + if summary == nil then return "" end + return (summary == "" and "-" or summary) +end + +local my_diag_status = function(hl_end) + local diag = vim.diagnostic + local counts = diag.count(0) + local signs = { "E", "W", "I", "H" } + local hl_map = { + [diag.severity.ERROR] = "DiagSLError", + [diag.severity.WARN] = "DiagSLWarn", + [diag.severity.INFO] = "DiagSLInfo", + [diag.severity.HINT] = "DiagSLHint", + } + local result_str = vim.iter(pairs(counts)) + :map( + function(severity, count) + return ("%%#%s#%s:%s"):format( + hl_map[severity], + signs[severity], + count + ) + end + ) + :join(" ") + if result_str:len() > 0 then + result_str = result_str .. "%##%#" .. hl_end .. "#" + end + return result_str +end + +local section_diagnostics = function() + if _G.MiniStatusline.is_truncated(75) then return "" end + if package.loaded["vim.diagnostic"] and #vim.diagnostic.count() ~= 0 then + return my_diag_status("SLDev") + end + return "" +end + vim.schedule(function() - require("mini.icons").setup() + local statusline = require("mini.statusline") + statusline.setup({ + content = { + active = function() + local git = section_git() + local diff = section_diff() + local diagnostics = section_diagnostics() + + local lsp = statusline.section_lsp({ trunc_width = 75 }) + local filename = section_filename() + local fileinfo = vim.bo.filetype + local location = "%-6.(%l,%c%V%) %P" + -- "%{% &ruler ? ( &rulerformat == '' ? '' : &rulerformat ) : '' %}" + + return statusline.combine_groups({ + { hl = "SLFilename", strings = { filename } }, + "%=", -- End left alignment + { hl = "SLDev", strings = { git, diff, diagnostics, lsp } }, + "%<", -- Mark general truncate point + { hl = "SLFileInfo", strings = { fileinfo } }, + { hl = "SLLocation", strings = { location } }, + }) + end, + inactive = nil, + }, + use_icons = true, + }) end) -- cgit v1.2.3-71-gdd5e