Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241local sync = require 'sync'
-- Returns Lazy plugin updates status if checker.enabled is truelocal function lazy_updates_status() local ok, lazy_config = pcall(require, 'lazy.core.config') if not ok or not lazy_config or not lazy_config.options or not lazy_config.options.checker or not lazy_config.options.checker.enabled then return '' end local ok_status, lazy_status = pcall(require, 'lazy.status') if not ok_status or not lazy_status.updates then return '' end return lazy_status.updates() or ''end
-- Returns nvim config git status if sync module and function existlocal function sync_git_status() local ok, sync_mod = pcall(require, 'sync') if not ok or not sync_mod or type(sync_mod.get_nvim_config_git_status) ~= 'function' then return '' end return sync_mod.get_nvim_config_git_status() or ''end
-- Chezmoi statusbar indicatorlocal chezmoi_cache = {}local chezmoi_dir = vim.env.HOME .. '/.local/share/chezmoi'
local function chezmoi_file() if vim.fn.executable 'chezmoi' == 0 then return '' end
local bufnr = vim.api.nvim_get_current_buf() if chezmoi_cache[bufnr] ~= nil then return chezmoi_cache[bufnr] end
local filepath = vim.api.nvim_buf_get_name(bufnr) local result = ''
if filepath ~= '' and vim.bo.buftype == '' and vim.startswith(filepath, chezmoi_dir .. '/') then result = 'CHEZMOI' end
chezmoi_cache[bufnr] = result return resultend
vim.api.nvim_create_autocmd('BufDelete', { group = vim.api.nvim_create_augroup('chezmoi_statusline', { clear = true }), callback = function(ev) chezmoi_cache[ev.buf] = nil end,})
--- Returns filetype icon, name and sizelocal function my_fileinfo() local filetype = vim.bo.filetype local filetype_label = filetype ~= '' and filetype or 'text' -- Get filetype icon from nvim-web-devicons local devicons_ok, devicons = pcall(require, 'nvim-web-devicons') local ft_icon = '' if devicons_ok and filetype ~= '' then local ok_icon, icon = pcall(devicons.get_icon_by_filetype, filetype, { default = true }) if ok_icon and icon then ft_icon = icon .. ' ' end end
-- Get Treesitter language icon (fallback to none if parser missing) if ft_icon == '' then local ts_ok, parsers = pcall(require, 'nvim-treesitter.parsers') if ts_ok then local ok_lang, lang = pcall(parsers.get_buf_lang, 0) lang = (ok_lang and lang) or '' if lang ~= '' and devicons_ok then local ok_icon, icon = pcall(devicons.get_icon_by_filetype, lang, { default = true }) if ok_icon and icon then ft_icon = icon .. ' ' end end end end
local size = vim.fn.getfsize(vim.fn.expand '%') local sizeOut = '' if size < 0 then sizeOut = '' elseif size < 1024 then sizeOut = size .. 'B' elseif size < 1024 * 1024 then sizeOut = string.format('%.1fK', size / 1024) else sizeOut = string.format('%.1fM', size / (1024 * 1024)) end
return string.format('%s%s %s', ft_icon, filetype_label, sizeOut)end
--- @type LazySpec | LazySpec[]return { -- Collection of various small independent plugins/modules 'echasnovski/mini.nvim', config = function() -- Initialize and update nvim git status using sync module sync.refresh_nvim_config_git_status()
-- Align stuff require('mini.align').setup()
-- Better Around/Inside textobjects -- -- Examples: -- - va) - [V]isually select [A]round [)]paren -- - yinq - [Y]ank [I]nside [N]ext [Q]uote -- - ci' - [C]hange [I]nside [']quote require('mini.ai').setup { n_lines = 500 }
-- if 'timeoutlen' is low enough to cause occasional usage of |s| keymap -- (that deletes character under cursor), disable it with the following call: vim.keymap.set({ 'n', 'x' }, 's', '<Nop>')
-- Add/delete/replace surroundings (brackets, quotes, etc.) -- -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren -- - sd' - [S]urround [D]elete [']quotes -- - sr)' - [S]urround [R]eplace [)] ['] require('mini.surround').setup { -- Add custom surroundings to be used on top of builtin ones. For more -- information with examples, see `:h MiniSurround.config`. custom_surroundings = nil,
-- Duration (in ms) of highlight when calling `MiniSurround.highlight()` highlight_duration = 500,
-- Module mappings. Use `''` (empty string) to disable one. mappings = { add = 'sa', -- Add surrounding in Normal and Visual modes delete = 'sd', -- Delete surrounding find = 'sf', -- Find surrounding (to the right) find_left = 'sF', -- Find surrounding (to the left) highlight = 'sh', -- Highlight surrounding replace = 'sr', -- Replace surrounding update_n_lines = 'sn', -- Update `n_lines`
suffix_last = 'l', -- Suffix to search with "prev" method suffix_next = 'n', -- Suffix to search with "next" method },
-- Number of lines within which surrounding is searched n_lines = 100,
-- Whether to respect selection type: -- - Place surroundings on separate lines in linewise mode. -- - Place surroundings on each line in blockwise mode. respect_selection_type = false,
-- How to search for surrounding (first inside current line, then inside -- neighborhood). One of 'cover', 'cover_or_next', 'cover_or_prev', -- 'cover_or_nearest', 'next', 'prev', 'nearest'. For more details, -- see `:h MiniSurround.config`. search_method = 'cover',
-- Whether to disable showing non-error feedback -- This also affects (purely informational) helper messages shown after -- idle time if user input is required. silent = false, }
-- Setup autopairs -- Works for ( [ { < " ' -- require('mini.pairs').setup { -- -- mappings = { -- ['<'] = { action = 'open', pair = '<>', neigh_pattern = '[^\\].' }, -- ['>'] = { action = 'close', pair = '<>', neigh_pattern = '[^\\].' }, -- }, -- }
-- Simple and easy statusline. -- You could remove this setup call if you don't like it, -- and try some other statusline plugin local statusline = require 'mini.statusline' -- set use_icons to true if you have a Nerd Font statusline.setup { content = { active = function() local mode, mode_hl = MiniStatusline.section_mode { trunc_width = 120 } local git = MiniStatusline.section_git { trunc_width = 40 } local diff = MiniStatusline.section_diff { trunc_width = 75 } local diagnostics = MiniStatusline.section_diagnostics { trunc_width = 75 } local lsp = MiniStatusline.section_lsp { trunc_width = 75 } local filename = MiniStatusline.section_filename { trunc_width = 140 } -- local fileinfo = MiniStatusline.section_fileinfo { trunc_width = 120 } local location = MiniStatusline.section_location { trunc_width = 75 } local search = MiniStatusline.section_searchcount { trunc_width = 75 } local git_status = sync_git_status() local chezmoi_status = chezmoi_file()
local ok, noice = pcall(require, 'noice') ---@diagnostic disable-next-line: undefined-field, deprecated if ok and noice.api.statusline.mode.has() then ---@diagnostic disable-next-line: deprecated, undefined-field local cmd = noice.api.statusline.mode.get() -- Remove messages like "-- INSERT --", "-- VISUAL --", etc. cmd = cmd:gsub('%s*%-%- .* %-%-', ''):gsub('^%s+', ''):gsub('%s+$', '') -- Only append if it's non-empty (so @recording etc. shows up) if cmd ~= '' then mode = mode .. ' ' .. cmd end end
return MiniStatusline.combine_groups { { hl = mode_hl, strings = { mode } }, { hl = 'MiniStatuslineDevinfo', strings = { git, diff, diagnostics, lsp } }, '%<', -- Mark general truncate point { hl = 'MiniStatuslineFilename', strings = { filename } }, '%=', -- End left alignment { hl = 'MiniStatuslineInactive', strings = { git_status } }, { hl = mode_hl, strings = { chezmoi_status } }, { hl = 'MiniStatuslineFileinfo', strings = { lazy_updates_status(), my_fileinfo() } }, { hl = mode_hl, strings = { search, location } }, } end, }, use_icons = true, }
-- You can configure sections in the statusline by overriding their -- default behavior. For example, here we set the section for -- cursor location to LINE:COLUMN ---@diagnostic disable-next-line: duplicate-set-field statusline.section_location = function() return '%2l:%-2v' end
-- ... and there is more! -- Check out: https://github.com/echasnovski/mini.nvim end,}