From 05bc6a185ff1272f6b1faf3b50490e44c11875e3 Mon Sep 17 00:00:00 2001 From: danny Date: Sun, 21 Sep 2025 16:26:21 +0800 Subject: [PATCH] feat: nvf mini surround --- home/user/nvf/default.nix | 211 ++-------------------- home/user/nvf/plugins/lualine/default.nix | 176 ++++++++++++++++++ 2 files changed, 196 insertions(+), 191 deletions(-) create mode 100644 home/user/nvf/plugins/lualine/default.nix diff --git a/home/user/nvf/default.nix b/home/user/nvf/default.nix index 7cba547..e866b3e 100644 --- a/home/user/nvf/default.nix +++ b/home/user/nvf/default.nix @@ -25,6 +25,7 @@ in { imports = [ ./plugins/snacks-nvim + ./plugins/lualine ]; programs.nvf = { @@ -32,6 +33,8 @@ in settings = { vim = { enableLuaLoader = true; + vimAlias = true; + clipboard = { enable = true; providers = { @@ -285,8 +288,6 @@ in transparent_enabled = true; }; - vimAlias = true; - options = { foldcolumn = "0"; foldlevel = 99; @@ -421,180 +422,6 @@ in indent-blankline.enable = true; }; - statusline = { - lualine = { - enable = true; - activeSection = { - a = lib.mkForce [ - '' - { - "mode", - icons_enabled = true, - separator = { - left = "", - right = "" - }, - } - '' - '' - { - "", - draw_empty = true, - separator = { left = '', right = '' } - } - '' - ]; - b = lib.mkForce [ - '' - { - "filetype", - colored = true, - icon_only = true, - icon = { align = 'left' } - } - '' - '' - { - "filename", - symbols = {modified = ' ', readonly = ' '}, - separator = { left = '', right = ''} - } - '' - '' - { - "", - draw_empty = true, - separator = { left = '', right = '' } - } - '' - ]; - c = lib.mkForce [ - '' - { - "diff", - colored = false, - diff_color = { - -- Same color values as the general color option can be used here. - added = 'DiffAdd', -- Changes the diff's added color - modified = 'DiffChange', -- Changes the diff's modified color - removed = 'DiffDelete', -- Changes the diff's removed color you - }, - symbols = {added = '+', modified = '~', removed = '-'}, -- Changes the diff symbols - separator = {right = ''} - } - '' - ]; - x = lib.mkForce [ - '' - { - -- Lsp server name - function() - local buf_ft = vim.bo.filetype - local excluded_buf_ft = { toggleterm = true, NvimTree = true, ["neo-tree"] = true, TelescopePrompt = true } - - if excluded_buf_ft[buf_ft] then - return "" - end - - local bufnr = vim.api.nvim_get_current_buf() - local clients = vim.lsp.get_clients({ bufnr = bufnr }) - - if vim.tbl_isempty(clients) then - return "No Active LSP" - end - - local active_clients = {} - for _, client in ipairs(clients) do - table.insert(active_clients, client.name) - end - - return table.concat(active_clients, ", ") - end, - icon = ' ', - separator = {left = ''}, - } - '' - '' - { - "diagnostics", - sources = {'nvim_lsp', 'nvim_diagnostic', 'nvim_diagnostic', 'vim_lsp', 'coc'}, - symbols = {error = '󰅙 ', warn = ' ', info = ' ', hint = '󰌵 '}, - colored = true, - update_in_insert = false, - always_visible = false, - diagnostics_color = { - color_error = { fg = 'red' }, - color_warn = { fg = 'yellow' }, - color_info = { fg = 'cyan' }, - }, - } - '' - ]; - y = lib.mkForce [ - '' - { - "", - draw_empty = true, - separator = { left = '', right = '' } - } - '' - '' - { - 'searchcount', - maxcount = 999, - timeout = 120, - separator = {left = ''} - } - '' - '' - { - "branch", - icon = ' •', - separator = {left = ''} - } - '' - ]; - z = lib.mkForce [ - '' - { - "", - draw_empty = true, - separator = { left = '', right = '' } - } - '' - '' - { - "progress", - separator = {left = ''} - } - '' - '' - {"location"} - '' - '' - { - "fileformat", - color = {fg='black'}, - symbols = { - unix = '', -- e843 - dos = '', -- e70f - mac = '', -- e711 - } - } - '' - ]; - }; - componentSeparator = { - left = ""; - right = ""; - }; - sectionSeparator = { - left = ""; - right = ""; - }; - }; - }; - autopairs.nvim-autopairs.enable = true; autocomplete = { @@ -627,21 +454,6 @@ in enable = true; }; - filetree = { - neo-tree = { - enable = false; - setupOpts = { - window = { - position = "right"; - mappings = { - "l" = "open"; - "h" = "close_node"; - }; - }; - }; - }; - }; - tabline = { nvimBufferline = { enable = true; @@ -820,6 +632,23 @@ in }; }; }; + + mini.surround = { + enable = true; + setupOpts = { + mappings = { + add = "gsa"; + delete = "gsd"; + find = "gsf"; + find_left = "gsF"; + highlight = "gsh"; + replace = "gsr"; + suffix_last = ""; + suffix_next = ""; + }; + silent = true; + }; + }; }; }; }; diff --git a/home/user/nvf/plugins/lualine/default.nix b/home/user/nvf/plugins/lualine/default.nix new file mode 100644 index 0000000..5bdb05c --- /dev/null +++ b/home/user/nvf/plugins/lualine/default.nix @@ -0,0 +1,176 @@ +{ pkgs, lib, ... }: +{ + programs.nvf.settings.vim.statusline = { + lualine = { + enable = true; + activeSection = { + a = lib.mkForce [ + '' + { + "mode", + icons_enabled = true, + separator = { + left = "", + right = "" + }, + } + '' + '' + { + "", + draw_empty = true, + separator = { left = '', right = '' } + } + '' + ]; + b = lib.mkForce [ + '' + { + "filetype", + colored = true, + icon_only = true, + icon = { align = 'left' } + } + '' + '' + { + "filename", + symbols = {modified = ' ', readonly = ' '}, + separator = { left = '', right = ''} + } + '' + '' + { + "", + draw_empty = true, + separator = { left = '', right = '' } + } + '' + ]; + c = lib.mkForce [ + '' + { + "diff", + colored = false, + diff_color = { + -- Same color values as the general color option can be used here. + added = 'DiffAdd', -- Changes the diff's added color + modified = 'DiffChange', -- Changes the diff's modified color + removed = 'DiffDelete', -- Changes the diff's removed color you + }, + symbols = {added = '+', modified = '~', removed = '-'}, -- Changes the diff symbols + separator = {right = ''} + } + '' + ]; + x = lib.mkForce [ + '' + { + -- Lsp server name + function() + local buf_ft = vim.bo.filetype + local excluded_buf_ft = { toggleterm = true, NvimTree = true, ["neo-tree"] = true, TelescopePrompt = true } + + if excluded_buf_ft[buf_ft] then + return "" + end + + local bufnr = vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients({ bufnr = bufnr }) + + if vim.tbl_isempty(clients) then + return "No Active LSP" + end + + local active_clients = {} + for _, client in ipairs(clients) do + table.insert(active_clients, client.name) + end + + return table.concat(active_clients, ", ") + end, + icon = ' ', + separator = {left = ''}, + } + '' + '' + { + "diagnostics", + sources = {'nvim_lsp', 'nvim_diagnostic', 'nvim_diagnostic', 'vim_lsp', 'coc'}, + symbols = {error = '󰅙 ', warn = ' ', info = ' ', hint = '󰌵 '}, + colored = true, + update_in_insert = false, + always_visible = false, + diagnostics_color = { + color_error = { fg = 'red' }, + color_warn = { fg = 'yellow' }, + color_info = { fg = 'cyan' }, + }, + } + '' + ]; + y = lib.mkForce [ + '' + { + "", + draw_empty = true, + separator = { left = '', right = '' } + } + '' + '' + { + 'searchcount', + maxcount = 999, + timeout = 120, + separator = {left = ''} + } + '' + '' + { + "branch", + icon = ' •', + separator = {left = ''} + } + '' + ]; + z = lib.mkForce [ + '' + { + "", + draw_empty = true, + separator = { left = '', right = '' } + } + '' + '' + { + "progress", + separator = {left = ''} + } + '' + '' + {"location"} + '' + '' + { + "fileformat", + color = {fg='black'}, + symbols = { + unix = '', -- e843 + dos = '', -- e70f + mac = '', -- e711 + } + } + '' + ]; + }; + componentSeparator = { + left = ""; + right = ""; + }; + sectionSeparator = { + left = ""; + right = ""; + }; + }; + }; +}