From 578c6b3208ba6a1b09287bb4677abab0bae9a837 Mon Sep 17 00:00:00 2001 From: afonso Date: Sun, 16 Mar 2025 01:09:34 +0000 Subject: [PATCH 1/5] [fish] big change --- .../conf.d/{myfunctions.fish => aliases.fish} | 0 .config/fish/conf.d/fishbang.fish | 6 -- .config/fish/config.fish | 10 +- .config/fish/fish_variables | 15 ++- .config/fish/functions/__fzf_complete.fish | 92 +++++++++++++++++++ 5 files changed, 107 insertions(+), 16 deletions(-) rename .config/fish/conf.d/{myfunctions.fish => aliases.fish} (100%) create mode 100644 .config/fish/functions/__fzf_complete.fish diff --git a/.config/fish/conf.d/myfunctions.fish b/.config/fish/conf.d/aliases.fish similarity index 100% rename from .config/fish/conf.d/myfunctions.fish rename to .config/fish/conf.d/aliases.fish diff --git a/.config/fish/conf.d/fishbang.fish b/.config/fish/conf.d/fishbang.fish index a6c6ed2..08b2c0b 100644 --- a/.config/fish/conf.d/fishbang.fish +++ b/.config/fish/conf.d/fishbang.fish @@ -1,5 +1,3 @@ -# Credits to https://github.com/BrewingWeasel/fishbang - function last_history_item echo $history[1] end @@ -57,7 +55,3 @@ abbr -a !^ --position anywhere --function first_history_arg # !^ returns the fir abbr -a !\$ --position anywhere --function last_history_arg # !$ returns the last argument of the last command abbr -a !\* --position anywhere --function history_args # !* returns all arguments of the last command abbr -a bang_nth_arg --position anywhere --regex '!:([0-9]*)' --function nth_history_arg # !$ returns the last argument of the last command - -bind -M insert enter expand-abbr execute -bind -M default enter expand-abbr execute -bind enter expand-abbr execute diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 9c0a4f5..85c7e6b 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -5,9 +5,7 @@ end set -g fish_greeting fish_vi_key_bindings -bind -M insert \t complete-and-search -bind -M insert --key btab complete - +bind -M insert \t "__fzf_complete" # XDG directories set -x XDG_CONFIG_HOME "$HOME/.config" @@ -35,6 +33,7 @@ end # Common paths fish_add_path /usr/sbin fish_add_path /sbin +fish_add_path $HOME/opt/*/bin fish_add_path $HOME/.local/share/nvim/mason/bin fish_add_path $HOME/.local/bin fish_add_path $HOME/go/bin @@ -46,7 +45,6 @@ if test (uname) = "Darwin" eval (/opt/homebrew/bin/brew shellenv) end +# Set up fzf +set -U FZF_DEFAULT_OPTS "--bind 'bs:backward-delete-char/eof'" fzf --fish | source - -# Added by LM Studio CLI (lms) -set -gx PATH $PATH /Users/afonso/.lmstudio/bin diff --git a/.config/fish/fish_variables b/.config/fish/fish_variables index c8c2a8e..edd7afa 100644 --- a/.config/fish/fish_variables +++ b/.config/fish/fish_variables @@ -1,8 +1,14 @@ # This file contains fish universal variable definitions. # VERSION: 3.0 -SETUVAR FZF_CTRL_R_OPTS:\x2d\x2dreverse -SETUVAR FZF_TMUX_OPTS:\x2dp -SETUVAR __fish_initialized:3400 +SETUVAR FZF_COMPLETE:2 +SETUVAR FZF_DEFAULT_OPTS:\x2d\x2dbind\x20\x27bs\x3abackward\x2ddelete\x2dchar/eof\x27 +SETUVAR __fish_initialized:3800 +SETUVAR _fisher_brewingweasel_2F_fishbang_files:\x7e/\x2econfig/fish/conf\x2ed/fishbang\x2efish +SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish +SETUVAR _fisher_plugins:jorgebucaran/fisher\x1ebrewingweasel/fishbang +SETUVAR _fisher_upgraded_to_4_4:\x1d +SETUVAR fifc_keybinding:\x09 +SETUVAR fifc_open_keybinding:ctrl\x2do SETUVAR fish_color_autosuggestion:brblack SETUVAR fish_color_cancel:\x2dr SETUVAR fish_color_command:blue @@ -25,10 +31,11 @@ SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrbl SETUVAR fish_color_status:red SETUVAR fish_color_user:brgreen SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_complete_path:vertical\x1e/opt/homebrew/Cellar/fish/3\x2e7\x2e1/share/fish/completions\x1e/opt/homebrew/Cellar/fish/4\x2e0\x2e1/share/fish/completions SETUVAR fish_key_bindings:fish_vi_key_bindings SETUVAR fish_pager_color_completion:normal SETUVAR fish_pager_color_description:yellow\x1e\x2di SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan SETUVAR fish_pager_color_selected_background:\x2dr -SETUVAR fish_user_paths:/Users/afonso/\x2eghcup/bin\x1e/Users/afonso/\x2ecargo/bin\x1e/Users/afonso/go/bin\x1e/Users/afonso/\x2elocal/bin\x1e/Users/afonso/\x2elocal/share/nvim/mason/bin\x1e/sbin\x1e/usr/sbin\x1e/Users/afonso/\x2egem/bin\x1e/opt/homebrew/opt/texlive/bin\x1e/opt/homebrew/bin +SETUVAR fish_user_paths:/Users/afonso/opt/fish/bin\x1e/Users/afonso/opt/neovim/bin\x1e/Users/afonso/\x2eghcup/bin\x1e/Users/afonso/\x2ecargo/bin\x1e/Users/afonso/go/bin\x1e/Users/afonso/\x2elocal/bin\x1e/Users/afonso/\x2elocal/share/nvim/mason/bin\x1e/sbin\x1e/usr/sbin\x1e/Users/afonso/\x2egem/bin\x1e/opt/homebrew/opt/texlive/bin\x1e/opt/homebrew/bin diff --git a/.config/fish/functions/__fzf_complete.fish b/.config/fish/functions/__fzf_complete.fish new file mode 100644 index 0000000..bc9a675 --- /dev/null +++ b/.config/fish/functions/__fzf_complete.fish @@ -0,0 +1,92 @@ +function __fzf_complete -d 'fzf completion and print selection back to commandline' + # As of 2.6, fish's "complete" function does not understand + # subcommands. Instead, we use the same hack as __fish_complete_subcommand and + # extract the subcommand manually. + set -l cmd (commandline -co) (commandline -ct) + + switch $cmd[1] + case env sudo + for i in (seq 2 (count $cmd)) + switch $cmd[$i] + case '-*' + case '*=*' + case '*' + set cmd $cmd[$i..-1] + break + end + end + end + + set -l cmd_lastw $cmd[-1] + set cmd (string join -- ' ' $cmd) + + set -l initial_query '' + test -n "$cmd_lastw"; and set initial_query --query="$cmd_lastw" + + set -l complist (complete -C$cmd) + set -l result + + # do nothing if there is nothing to select from + test -z "$complist"; and return + + set -l compwc (echo $complist | wc -w) + if test $compwc -eq 1 + # if there is only one option dont open fzf + set result "$complist" + else + + set -l query + string join -- \n $complist \ + | eval fzf --height=90% (string escape --no-quoted -- $initial_query) --print-query (__fzf_complete_opts) \ + | cut -f1 \ + | while read -l r + # first line is the user entered query + if test -z "$query" + set query $r + # rest of lines are selected candidates + else + set result $result $r + end + end + + # exit if user canceled + if test -z "$query" ;and test -z "$result" + commandline -f repaint + return + end + + # if user accepted but no candidate matches, use the input as result + if test -z "$result" + set result $query + end + end + + set prefix (string sub -s 1 -l 1 -- (commandline -t)) + for i in (seq (count $result)) + set -l r $result[$i] + switch $prefix + case "'" + commandline -t -- (string escape -- $r) + case '"' + if string match '*"*' -- $r >/dev/null + commandline -t -- (string escape -- $r) + else + commandline -t -- '"'$r'"' + end + case '~' + commandline -t -- (string sub -s 2 (string escape -n -- $r)) + case '*' + commandline -t -- $r + end + [ $i -lt (count $result) ]; and commandline -i ' ' + end + + commandline -f repaint +end + +function __fzf_complete_opts + if set -q FZF_DEFAULT_OPTS + echo $FZF_DEFAULT_OPTS + end + echo --cycle --reverse --inline-info --no-multi --bind tab:down,btab:up +end From d949a30dc8d553876aaff586b4bfe70a85520985 Mon Sep 17 00:00:00 2001 From: afonso Date: Sun, 16 Mar 2025 01:12:43 +0000 Subject: [PATCH 2/5] [nvim] a lot of changes --- .config/nvim/.gitignore | 2 +- .config/nvim/init.lua | 1 - .config/nvim/lua/core/package_manager.lua | 33 +++++---- .config/nvim/lua/core/variables.lua | 1 - .config/nvim/lua/plugins/cmp.lua | 16 +++-- .config/nvim/lua/plugins/lsp.lua | 48 ++++++++++++- .config/nvim/lua/plugins/misc.lua | 13 +++- .config/nvim/lua/plugins/picker.lua | 2 +- .config/nvim/lua/plugins/statusline.lua | 24 +++++++ .config/nvim/lua/plugins/treesitter.lua | 9 +++ .config/nvim/lua/plugins/ui.lua | 19 ++--- .config/nvim/lua/winbar.lua | 87 ----------------------- 12 files changed, 135 insertions(+), 120 deletions(-) create mode 100644 .config/nvim/lua/plugins/statusline.lua delete mode 100644 .config/nvim/lua/winbar.lua diff --git a/.config/nvim/.gitignore b/.config/nvim/.gitignore index 648bf93..cb39c01 100644 --- a/.config/nvim/.gitignore +++ b/.config/nvim/.gitignore @@ -1,2 +1,2 @@ -plugin lazy-lock.json +lua/dev diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index fc41d55..d66f680 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -2,5 +2,4 @@ require("core.variables") require("core.keymaps") require("core.autocmds") require('core.package_manager') -require('winbar') require('core.theme') diff --git a/.config/nvim/lua/core/package_manager.lua b/.config/nvim/lua/core/package_manager.lua index 0a78990..8d72c6f 100644 --- a/.config/nvim/lua/core/package_manager.lua +++ b/.config/nvim/lua/core/package_manager.lua @@ -1,18 +1,27 @@ +-- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" - -if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end end - vim.opt.rtp:prepend(lazypath) --Call lazy config here local lazy = require("lazy") -lazy.setup("plugins") +lazy.setup({ + spec = { + { import = "plugins" } + }, + dev = { + path = vim.fn.stdpath("config") .. "/lua/dev" + } +}) diff --git a/.config/nvim/lua/core/variables.lua b/.config/nvim/lua/core/variables.lua index f815f1d..e9c628e 100644 --- a/.config/nvim/lua/core/variables.lua +++ b/.config/nvim/lua/core/variables.lua @@ -47,4 +47,3 @@ vim.opt.signcolumn = "yes" vim.opt.autoread = true -- disable swapfile vim.opt.swapfile = false -vim.opt.laststatus = 3 diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua index f2574bb..a1913fd 100644 --- a/.config/nvim/lua/plugins/cmp.lua +++ b/.config/nvim/lua/plugins/cmp.lua @@ -25,18 +25,26 @@ return { sources = { default = { 'lsp', 'path', 'snippets', 'buffer' }, providers = { - lazydev = { name = "LazyDev", module = "lazydev.integrations.blink", fallbacks = { "lsp" } }, + lazydev = { + name = "LazyDev", + module = "lazydev.integrations.blink", + fallbacks = { "lsp" } + }, }, }, signature = { enabled = true, window = { - max_width = 160, - max_height = 30, - scrollbar = true, show_documentation = false, } }, + cmdline = { + completion = { + menu = { + auto_show = true + } + } + }, completion = { accept = { auto_brackets = { diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 59cf01e..1ff5fdd 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -117,10 +117,19 @@ return { capabilities = capabilities, filetypes = { 'haskell', 'lhaskell', 'cabal' }, }) - lspconfig["clangd"].setup({ + -- lspconfig["clangd"].setup({ + -- capabilities = capabilities, + -- }) + lspconfig["texlab"].setup({ capabilities = capabilities, }) - lspconfig["texlab"].setup({ + lspconfig["bashls"].setup({ + capabilities = capabilities, + }) + lspconfig["zls"].setup({ + capabilities = capabilities, + }) + lspconfig["pyright"].setup({ capabilities = capabilities, }) end, @@ -165,11 +174,35 @@ return { rust = { "rustfmt" }, go = { "gofmt" }, json = { "jq" }, - bash = { "shfmt" } + bash = { "shfmt", "beautysh" }, + zsh = { "beautysh" } } }) end, }, + { + 'mfussenegger/nvim-lint', + config = function() + local lint = require("lint") + + lint.linters_by_ft = { + go = { "golangcilint" }, + } + + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + + vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + + vim.keymap.set("n", "li", function() + lint.try_lint() + end, { desc = "Trigger linting for current file" }) + end, + }, { "lervag/vimtex", @@ -180,6 +213,15 @@ return { else vim.g.vimtex_view_method = 'zathura' end + vim.g.vimtex_quickfix_ignore_filters = { + "warning", + "Warning" + } + vim.g.vimtex_quickfix_open_on_warning = 0 + vim.g.vimtex_quickfix_ignore_filters = { + 'Overfull', + 'Underfull', + } vim.g.vimtex_compiler_method = 'latexmk' vim.g.vimtex_compiler_latexmk = { out_dir = 'build', diff --git a/.config/nvim/lua/plugins/misc.lua b/.config/nvim/lua/plugins/misc.lua index bb2c338..4d2182c 100644 --- a/.config/nvim/lua/plugins/misc.lua +++ b/.config/nvim/lua/plugins/misc.lua @@ -25,6 +25,7 @@ return { statuscolumn = { enabled = true }, dashboard = { enabled = true }, input = { enabled = true }, + image = { enabled = true }, lazygit = { vim.keymap.set('n', 'lg', function() Snacks.lazygit.open() @@ -46,5 +47,15 @@ return { end }, "tpope/vim-fugitive", - "pimalaya/himalaya-vim" + { + "afonsofrancof/worktrees.nvim", + dev = true, + opts = { + mappings = { + create = "wtc", + delete = "wtd", + switch = "wts", + } + } + } } diff --git a/.config/nvim/lua/plugins/picker.lua b/.config/nvim/lua/plugins/picker.lua index 4bae661..24479bf 100644 --- a/.config/nvim/lua/plugins/picker.lua +++ b/.config/nvim/lua/plugins/picker.lua @@ -9,7 +9,7 @@ return { fzflua.setup({ defaults = { winopts = { - border = "single", + border = "rounded", width = 0.6, height = 0.5, }, diff --git a/.config/nvim/lua/plugins/statusline.lua b/.config/nvim/lua/plugins/statusline.lua new file mode 100644 index 0000000..0b3d5e7 --- /dev/null +++ b/.config/nvim/lua/plugins/statusline.lua @@ -0,0 +1,24 @@ +return { + { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + opts = { + sections = { + lualine_a = { 'mode' }, + lualine_b = { 'branch', 'diff', 'diagnostics' }, + lualine_c = { { 'filename', path = 1 } }, + lualine_x = { 'filetype' }, + lualine_y = { 'progress' }, + lualine_z = { 'location' } + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { 'filename' }, + lualine_x = { 'location' }, + lualine_y = {}, + lualine_z = {} + }, + } + } +} diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index e74bd8c..6001626 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -19,6 +19,15 @@ return { disable = { "latex" }, use_languagetree = true, }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, indent = { enable = true, }, diff --git a/.config/nvim/lua/plugins/ui.lua b/.config/nvim/lua/plugins/ui.lua index e6a41ba..e8c82e5 100644 --- a/.config/nvim/lua/plugins/ui.lua +++ b/.config/nvim/lua/plugins/ui.lua @@ -1,14 +1,14 @@ return { - { - "vimpostor/vim-tpipeline", - config = function() - vim.g.tpipeline_restore = 0 - vim.g.tpipeline_autoembed = 0 - vim.o.laststatus = 0 - vim.g.tpipeline_statusline = '%=%l:%c' - end - }, + -- { + -- "vimpostor/vim-tpipeline", + -- config = function() + -- vim.g.tpipeline_restore = 0 + -- vim.g.tpipeline_autoembed = 0 + -- vim.o.laststatus = 0 + -- vim.g.tpipeline_statusline = '%=%l:%c' + -- end + -- }, { "folke/noice.nvim", event = "VeryLazy", @@ -36,6 +36,7 @@ return { }, { 'kevinhwang91/nvim-ufo', + event = "VeryLazy", dependencies = 'kevinhwang91/promise-async', config = function() vim.o.foldcolumn = '0' diff --git a/.config/nvim/lua/winbar.lua b/.config/nvim/lua/winbar.lua deleted file mode 100644 index 436ea0d..0000000 --- a/.config/nvim/lua/winbar.lua +++ /dev/null @@ -1,87 +0,0 @@ -local folder_icon = "󰉋" - -local M = {} - ---- Window bar that shows the current file path (in a fancy way). ----@return string -function M.render() - -- Get the path and expand variables. - local path = vim.fs.normalize(vim.fn.expand '%:p' --[[@as string]]) - - -- Replace slashes by arrows. - local separator = ' %#WinbarSeparator# ' - - local prefix, prefix_path = '', '' - - -- If the window gets too narrow, shorten the path and drop the prefix. - if vim.api.nvim_win_get_width(0) < math.floor(vim.o.columns / 3) then - path = vim.fn.pathshorten(path) - else - -- For some special folders, add a prefix instead of the full path (making - -- sure to pick the longest prefix). - ---@type table - local special_dirs = { - DOTFILES = "$HOME/.config", - HOME = vim.env.HOME, - PROJECTS = "$HOME/projects", - ["University"] = "$HOME/projects/University", - ["Personal"] = "$HOME/projects/Personal", - } - for dir_name, dir_path in pairs(special_dirs) do - if vim.startswith(path, vim.fs.normalize(dir_path)) and #dir_path > #prefix_path then - prefix, prefix_path = dir_name, dir_path - end - end - if prefix ~= '' then - path = path:gsub('^' .. prefix_path, '') - prefix = string.format('%%#WinBarSpecial#%s %s%s', folder_icon, prefix, separator) - end - end - - -- Remove leading slash. - path = path:gsub('^/', '') - - -- Get the background color of the Normal highlight group - local normal_bg_color = vim.api.nvim_get_hl_by_name('Normal', true).background - -- Get the foreground color of the Normal highlight group - local normal_fg_color = vim.api.nvim_get_hl_by_name('Normal', true).foreground - - -- Convert the RGB color to a hex string - local bg_hex_color = normal_bg_color and string.format('#%06x', normal_bg_color) or 'transparent' - -- Convert the RGB color to a hex string - local fg_hex_color = string.format('#%06x', normal_fg_color) - - -- Define the Winbar highlight group with the same background color - vim.api.nvim_command('highlight Winbar guibg=' .. bg_hex_color) - -- Define the Winbar highlight group with the same foreground color - vim.api.nvim_command('highlight Winbar guifg=' .. fg_hex_color) - - return table.concat { - ' ', - prefix, - table.concat( - vim.iter(vim.split(path, '/')) - :map(function(segment) - return string.format('%%#Winbar#%s', segment) - end):totable(), - separator - ), - } -end - -vim.api.nvim_create_autocmd('BufWinEnter', { - group = vim.api.nvim_create_augroup('mariasolos/winbar', { clear = true }), - desc = 'Attach winbar', - callback = function(args) - if - not vim.api.nvim_win_get_config(0).zindex -- Not a floating window - and vim.bo[args.buf].buftype == '' -- Normal buffer - and vim.api.nvim_buf_get_name(args.buf) ~= '' -- Has a file name - and not vim.wo[0].diff -- Not in diff mode - then - vim.wo.winbar = "%{%v:lua.require'winbar'.render()%}" - end - end, -}) - -return M From 9f1a61fd1740068a8379cbe4a2e3e9396b5d39a3 Mon Sep 17 00:00:00 2001 From: afonso Date: Sun, 16 Mar 2025 01:13:24 +0000 Subject: [PATCH 3/5] [tmux] make the config a single file for simplicity --- .config/tmux/tmux.conf | 90 ++++++++++++++++++++++++++++--- .config/tmux/tmux_binds.conf | 34 ------------ .config/tmux/tmux_copy_mode.conf | 10 ---- .config/tmux/tmux_general.conf | 19 ------- .config/tmux/tmux_init.conf | 6 --- .config/tmux/tmux_plugins.conf | 15 ------ .config/tmux/tmux_status_bar.conf | 35 ------------ 7 files changed, 84 insertions(+), 125 deletions(-) delete mode 100644 .config/tmux/tmux_binds.conf delete mode 100644 .config/tmux/tmux_copy_mode.conf delete mode 100644 .config/tmux/tmux_general.conf delete mode 100644 .config/tmux/tmux_init.conf delete mode 100644 .config/tmux/tmux_plugins.conf delete mode 100644 .config/tmux/tmux_status_bar.conf diff --git a/.config/tmux/tmux.conf b/.config/tmux/tmux.conf index ab7ea46..8792039 100644 --- a/.config/tmux/tmux.conf +++ b/.config/tmux/tmux.conf @@ -1,9 +1,87 @@ # tmux.conf -source-file ~/.config/tmux/tmux_general.conf -source-file ~/.config/tmux/tmux_binds.conf -source-file ~/.config/tmux/tmux_copy_mode.conf -source-file ~/.config/tmux/tmux_plugins.conf -source-file ~/.config/tmux/tmux_init.conf -source-file ~/.config/tmux/tmux_status_bar.conf +# General +set -g default-terminal "tmux-256color" +set -gq allow-passthrough on +set -g visual-activity off +set -sa terminal-features ",*:RGB" +set -sg escape-time 0 +set -g mouse on +set -g base-index 1 +set -g pane-base-index 1 +set -g detach-on-destroy off +set -g history-limit 250000 +set -g set-clipboard on +set -g renumber-windows on +setw -g mode-keys vi +# Status +set -g status-right "" +set -g status-left-length 20 +set -g status-position top +set -g status-justify left +set -g status-style 'bg=#181926 fg=#cad3f5' +set -g status-left '[#S] ' +set -g status-style ' #[bg=#{status-bg},fg=#{@unfocused-fg}]' +set -g window-status-format ' #I:#W ' +set -g window-status-current-format '#[bg=#{@focused-bg},fg=#{@focused-fg}] #I:#W ' + +# Theme +set -g status-bg "#1d2021" +set -g @unfocused-fg "#ebdbb2" +set -g @focused-bg "#ebdbb2" +set -g @focused-fg "#1d2021" + +# Plugins +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' +set -g @plugin 'niqodea/tmux-matryoshka' +set -g @plugin 'laktak/extrakto' + +# Plugin settings +set -g @resurrect-strategy-nvim 'session' +set -g @resurrect-capture-pane-contents 'on' +set -g @continuum-save-interval '5' +set -g @open-lazygit 'g' + +# Binds +bind-key 'x' kill-pane +bind-key 'h' previous-window +bind-key 'j' switch-client -p +bind-key 'k' switch-client -n +bind-key 'l' next-window +bind-key 'n' new-window -c '#{pane_current_path}' +bind-key 'N' new-window +bind-key 'c' kill-window + +# Decide whether we're in a Vim process +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" + +unbind y +bind-key 'y' if-shell "$is_vim" 'send-keys F5' 'select-pane -L' +unbind u +bind-key 'u' if-shell "$is_vim" 'send-keys F6' 'select-pane -D' +unbind i +bind-key 'i' if-shell "$is_vim" 'send-keys F7' 'select-pane -U' +unbind o +bind-key 'o' if-shell "$is_vim" 'send-keys F8' 'select-pane -R' + +unbind s +bind-key 's' display-popup -E -w 60% -h 40% "~/.local/bin/tms" +unbind t +bind-key 't' display-popup -E -w 60% -h 40% "~/.local/bin/change-theme.sh" +unbind g +bind-key 'g' display-popup -d '#{pane_current_path}' -E -w 100% -h 100% "lazygit" + +# Copy mode +bind -T copy-mode-vi v send -X begin-selection +bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy" +bind P paste-buffer +# Copy mode mouse +unbind-key -T copy-mode-vi MouseDragEnd1Pane +bind-key -T copy-mode-vi MouseDown1Pane select-pane\; send-keys -X clear-selection + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +set-environment -g PATH "/opt/homebrew/bin:/bin:/usr/bin" +run '~/.config/tmux/plugins/tpm/tpm' diff --git a/.config/tmux/tmux_binds.conf b/.config/tmux/tmux_binds.conf deleted file mode 100644 index ef3c724..0000000 --- a/.config/tmux/tmux_binds.conf +++ /dev/null @@ -1,34 +0,0 @@ -# tmux_binds.conf - -# Binds -bind-key 'x' kill-pane -bind-key 'h' previous-window -bind-key 'j' switch-client -p -bind-key 'k' switch-client -n -bind-key 'l' next-window -bind-key 'n' new-window -c '#{pane_current_path}' -bind-key 'N' new-window -bind-key 'c' kill-window - -# Decide whether we're in a Vim process -is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ - | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" - -unbind y -bind-key 'y' if-shell "$is_vim" 'send-keys F5' 'select-pane -L' -unbind u -bind-key 'u' if-shell "$is_vim" 'send-keys F6' 'select-pane -D' -unbind i -bind-key 'i' if-shell "$is_vim" 'send-keys F7' 'select-pane -U' -unbind o -bind-key 'o' if-shell "$is_vim" 'send-keys F8' 'select-pane -R' - -# Tmus sessionizer -unbind s -bind-key 's' display-popup -E -w 60% -h 40% "~/.local/bin/tms" - -unbind t -bind-key 't' display-popup -E -w 60% -h 40% "~/.local/bin/change-theme.sh" - -unbind g -bind-key 'g' display-popup -d '#{pane_current_path}' -E -w 100% -h 100% "lazygit" diff --git a/.config/tmux/tmux_copy_mode.conf b/.config/tmux/tmux_copy_mode.conf deleted file mode 100644 index 33656a5..0000000 --- a/.config/tmux/tmux_copy_mode.conf +++ /dev/null @@ -1,10 +0,0 @@ -# tmux_copy_mode.conf - -# Copy mode -bind -T copy-mode-vi v send -X begin-selection -bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy" -bind P paste-buffer - -# Copy mode mouse -unbind-key -T copy-mode-vi MouseDragEnd1Pane -bind-key -T copy-mode-vi MouseDown1Pane select-pane\; send-keys -X clear-selection diff --git a/.config/tmux/tmux_general.conf b/.config/tmux/tmux_general.conf deleted file mode 100644 index d40021f..0000000 --- a/.config/tmux/tmux_general.conf +++ /dev/null @@ -1,19 +0,0 @@ -# tmux_general.conf - -set -g default-terminal "tmux-256color" -set -gq allow-passthrough on -set -g visual-activity off -set -sa terminal-features ",*:RGB" -set -sg escape-time 0 -set -g mouse on -set -g base-index 1 -set -g pane-base-index 1 -set -g detach-on-destroy off -set -g history-limit 250000 -set -g set-clipboard on -set -g status-position top -set -g renumber-windows on -setw -g mode-keys vi -set -g status-style 'bg=#181926 fg=#cad3f5' -set -g status-right "" -set -g status-left-length 20 diff --git a/.config/tmux/tmux_init.conf b/.config/tmux/tmux_init.conf deleted file mode 100644 index 11faff1..0000000 --- a/.config/tmux/tmux_init.conf +++ /dev/null @@ -1,6 +0,0 @@ -# tmux_init.conf - -# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) -set-environment -g PATH "/opt/homebrew/bin:/bin:/usr/bin" -run '~/.config/tmux/plugins/tpm/tpm' - diff --git a/.config/tmux/tmux_plugins.conf b/.config/tmux/tmux_plugins.conf deleted file mode 100644 index b46202c..0000000 --- a/.config/tmux/tmux_plugins.conf +++ /dev/null @@ -1,15 +0,0 @@ -# tmux_plugins.conf - -# List of plugins -set -g @plugin 'tmux-plugins/tpm' -set -g @plugin 'tmux-plugins/tmux-sensible' -set -g @plugin 'niqodea/tmux-matryoshka' -set -g @plugin 'laktak/extrakto' -set -g @plugin 'Morantron/tmux-fingers' - -# Plugin settings -set -g @resurrect-strategy-nvim 'session' -set -g @resurrect-capture-pane-contents 'on' -set -g @continuum-save-interval '5' -set -g @open-lazygit 'g' - diff --git a/.config/tmux/tmux_status_bar.conf b/.config/tmux/tmux_status_bar.conf deleted file mode 100644 index a00bea7..0000000 --- a/.config/tmux/tmux_status_bar.conf +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash - -# Hardcoded values -set -g status-bg "#272e33" -set -g @unfocused-fg "#3c4841" -set -g @focused-bg "#3c4841" -set -g @focused-fg "#d3c6aa" - -# Set status bar position -set -g status-position top - -# Set status bar justification -set -g status-justify left - -# Set right side of the status bar -set -g status-right '#(cat #{socket_path}-\#{session_id}-vimbridge-R)' - -set -g status-left '[#S] ' - -# Set status bar style -set -g status-style ' #[bg=#{status-bg},fg=#{@unfocused-fg}]' - -# Set window status format -set -g window-status-format ' #I:#W ' - -# Set window status format for the current window -set -g window-status-current-format '#[bg=#{@focused-bg},fg=#{@focused-fg}] #I:#W ' - - -# AUTO RENAME WINDOW -#set-option -g status-interval 5 - -#set-option -g automatic-rename on - -#set-option -g automatic-rename-format "#{?#{==:#{pane_current_command},zsh},#{b:pane_current_path},#{pane_current_command}}" From 97f9e9a0a5d548b476c7f5eced5fca1a1e7fffb5 Mon Sep 17 00:00:00 2001 From: afonso Date: Sun, 16 Mar 2025 01:14:42 +0000 Subject: [PATCH 4/5] [zsh] added functions to manage path --- .config/zsh/.zshenv | 59 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/.config/zsh/.zshenv b/.config/zsh/.zshenv index 050b921..70c01e0 100644 --- a/.config/zsh/.zshenv +++ b/.config/zsh/.zshenv @@ -1,3 +1,35 @@ +function remove_from_path() { + local a + local p + local s + local r + eval "p=\$$1" + a=( ${(s/:/)p} ) + if [[ ${a[(i)${2}]} -gt ${#a} ]] && return + for s in $a; do + if [[ ! $s == $2 ]]; then + [[ -z "$r" ]] && r=$s || r="$r:$s" + fi + done + eval $1="$r" +} + +function prepend_path() { + [[ ! -d "$2" ]] && return + local p + remove_from_path "$1" "$2" + eval "p=\$$1" + eval export $1="$2:$p" +} + +function append_path() { + [[ ! -d "$2" ]] && return + local p + remove_from_path "$1" "$2" + eval "p=\$$1" + eval export $1="$p:$2" +} + export EDITOR=nvim export VISUAL=nvim export READER=mupdf @@ -15,19 +47,22 @@ export GOBIN="$GOPATH/bin" if [[ $(uname) == "Darwin" ]]; then export JAVA_HOME=$(/usr/libexec/java_home) export GEM_HOME=$HOME/.gem - export PATH="/opt/homebrew/bin:$PATH" - export PATH="/opt/homebrew/opt/texlive/bin:$PATH" - export PATH=$PATH:$GEM_HOME/bin + prepend_path PATH "/opt/homebrew/bin" + prepend_path PATH "/opt/homebrew/opt/texlive/bin" + append_path PATH $GEM_HOME/bin fi - #BOTH -export PATH="/usr/sbin:/sbin:$PATH" -export PATH="$HOME/.local/share/nvim/mason/bin:$PATH" -export PATH="$HOME/.local/bin:$PATH" -export PATH="$HOME/go/bin:$PATH" -export PATH="$HOME/.cargo/bin:$PATH" -export PATH="$HOME/.ghcup/bin:$PATH" -export PATH="$HOME/.cabal/bin:$PATH" +append_path PATH "/usr/sbin:/sbin" +append_path PATH "$HOME/.local/share/nvim/mason/bin" +append_path PATH "$HOME/.local/bin" +append_path PATH "$HOME/go/bin" +append_path PATH "$HOME/.ghcup/bin" +append_path PATH "$HOME/.cabal/bin" +append_path PATH "$HOME/.cargo/bin" +for bindir in ~/opt/*/bin(N); do + if [[ -d "$bindir" ]]; then + prepend_path PATH "$bindir" + fi +done -. "$HOME/.cargo/env" From cca94480edef81b5492783db220aaae49911b38b Mon Sep 17 00:00:00 2001 From: afonso Date: Sun, 16 Mar 2025 01:14:58 +0000 Subject: [PATCH 5/5] [scripts] update change-theme.sh --- .local/bin/change-theme.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.local/bin/change-theme.sh b/.local/bin/change-theme.sh index ef91b80..95af692 100755 --- a/.local/bin/change-theme.sh +++ b/.local/bin/change-theme.sh @@ -154,6 +154,7 @@ themes[everforest-hard-dark]=\ nvim_color_scheme=everforest additional_nvim_commands="\ vim.g.everforest_better_performance=1 +vim.g.everforest_transparent_background=2 vim.g.everforest_background=\"hard\" vim.opt.background=\"dark\""' @@ -166,6 +167,7 @@ themes[everforest-medium-dark]=\ nvim_color_scheme=everforest additional_nvim_commands="\ vim.g.everforest_better_performance=1 +vim.g.everforest_transparent_background=2 vim.g.everforest_background=\"medium\" vim.opt.background=\"dark\""' @@ -179,6 +181,7 @@ themes[everforest-soft-dark]=\ additional_nvim_commands="\ vim.g.everforest_better_performance=1 vim.g.everforest_background=\"soft\" +vim.g.everforest_transparent_background=2 vim.opt.background=\"dark\""' # Function to reload Neovim @@ -197,10 +200,10 @@ change_theme() { [[ -n "$alacritty_theme_name" ]] && sed -i '' -e "s|import = \[\"~/.config/alacritty/themes/.*\"\]|import = [\"~/.config/alacritty/themes/${alacritty_theme_name}.toml\"]|g" ~/.config/alacritty/alacritty.toml [[ -n "$ghostty_theme_name" ]] && sed -i '' -E "s/theme =.*$/theme = $ghostty_theme_name/" ~/.config/ghostty/config [[ -n "$kitty_theme" ]] && kitten themes --reload-in=all "$kitty_theme" - sed -i '' -E "s/set -g status-bg .*$/set -g status-bg \"$background_color\"/" ~/.config/tmux/tmux_status_bar.conf - sed -i '' -E "s/set -g @unfocused-fg .*$/set -g @unfocused-fg \"$tmux_bar_unfocused_fg\"/" ~/.config/tmux/tmux_status_bar.conf - sed -i '' -E "s/set -g @focused-bg .*$/set -g @focused-bg \"$tmux_bar_focused_bg\"/" ~/.config/tmux/tmux_status_bar.conf - sed -i '' -E "s/set -g @focused-fg .*$/set -g @focused-fg \"$tmux_bar_focused_fg\"/" ~/.config/tmux/tmux_status_bar.conf + sed -i '' -E "s/set -g status-bg .*$/set -g status-bg \"$background_color\"/" ~/.config/tmux/tmux.conf + sed -i '' -E "s/set -g @unfocused-fg .*$/set -g @unfocused-fg \"$tmux_bar_unfocused_fg\"/" ~/.config/tmux/tmux.conf + sed -i '' -E "s/set -g @focused-bg .*$/set -g @focused-bg \"$tmux_bar_focused_bg\"/" ~/.config/tmux/tmux.conf + sed -i '' -E "s/set -g @focused-fg .*$/set -g @focused-fg \"$tmux_bar_focused_fg\"/" ~/.config/tmux/tmux.conf tmux source-file ~/.config/tmux/tmux.conf reload_neovim "$nvim_color_scheme" "$additional_nvim_commands" }