{ config, pkgs, lib, ... }:

{
	imports = [
	];

	programs.neovim.plugins = [
		pkgs.vimPlugins.nvim-treesitter.withAllGrammars
	];
	programs.taskwarrior = {
		enable = true;
	};
	services.syncthing  = {
		enable = true;
		guiAddress = "0.0.0.0:8384";
	};
	programs.ranger = {
		enable = true;
		extraConfig = ''

		'';
		extraPackages = [ ];
		mappings = {
			Q = "quitall";
			q = "quit";
		};
		plugins = [
			{
				name = "zoxide";
				src = builtins.fetchGit {
					url = "https://github.com/jchook/ranger-zoxide.git";
					rev = "363df97af34c96ea873c5b13b035413f56b12ead";
				};
			}
			{
				name = "tmux";
				src = builtins.fetchGit {
					url = "https://github.com/joouha/ranger_tmux.git";
					rev = "05ba5ddf2ce5659a90aa0ada70eb1078470d972a";
				};
			}
		];
		settings = {
			column_ratios = "1,3,3";
			confirm_on_delete = "never";
			scroll_offset = 8;
			unicode_ellipsis = true;
		};
	};
	programs.fzf = {
		enable = true;
		tmux.enableShellIntegration = true;
		enableZshIntegration = true;
		colors = {
			fg = "#d0d0d0";
			bg = "#24283b";
			hl = "#5f87af";
			"fg+" = "#d0d0d0";
			"bg+" = "#414868";
			"hl+" = "#5fd7ff";
			info = "#afaf87";
			prompt = "#d7005f";
			pointer = "#af5fff";
			marker = "#87ff00";
			spinner = "#af5fff";
			header = "#87afaf";
		};
	};
	programs.tmux = {
		enable = true;
		baseIndex = 1;
		clock24 = true;
		disableConfirmationPrompt = true;
		keyMode = "vi";
		mouse = true;
		newSession = true;
		plugins = with pkgs; [
			tmuxPlugins.cpu
			{
				plugin = tmuxPlugins.resurrect;
				extraConfig = "set -g @resurrect-strategy-nvim 'session'";
			}
			{
				plugin = tmuxPlugins.continuum;
				extraConfig = ''
			set -g @continuum-restore 'on'
			set -g @continuum-save-interval '60'
				'';
			}
			tmuxPlugins.yank
			tmuxPlugins.vim-tmux-navigator
			tmuxPlugins.vim-tmux-focus-events
			tmuxPlugins.urlview
			{
				plugin = tmuxPlugins.tokyo-night-tmux;
				extraConfig = ''
				set -g @tokyo-night-tmux_window_id_style digital
				set -g @tokyo-night-tmux_pane_id_style hsquare
				set -g @tokyo-night-tmux_zoom_id_style dsquare
				set -g @tokyo-night-tmux_show_netspeed 1
				set -g @tokyo-night-tmux_netspeed_iface "wlp2s0" # Detected via default route
				set -g @tokyo-night-tmux_netspeed_showip 1      # Display IPv4 address (default 0)
				set -g @tokyo-night-tmux_netspeed_refresh 1     # Update interval in seconds (default 1)
				set -g @tokyo-night-tmux_show_path 1
				set -g @tokyo-night-tmux_path_format relative # 'relative' or 'full'
				set -g @tokyo-night-tmux_show_battery_widget 1
				set -g @tokyo-night-tmux_battery_name "BAT0"  # some linux distro have 'BAT0'
				set -g @tokyo-night-tmux_battery_low_threshold 21 # default
				'';
			}
			tmuxPlugins.tmux-fzf
			# {
			#   plugin = tmuxPlugins.tilish;
			#   extraConfig = ''
			#     set -g @tilish-navigator 'on'
			#     set -g @tilish-default 'main-vertical'
			#     set -g @tilish-enforce 'none'
			#     set -g escape-time 0
			#     set -g @tilish-dmenu 'on'
			#   '';
			# }

		]; 
		prefix = "C-a";
		shell = "${pkgs.zsh}/bin/zsh";
		# terminal = "xterm-kitty:RGB";
		tmuxinator.enable = true;
		extraConfig = ''
		set-option -g update-environment "DISPLAY XAUTHORITY WAYLAND_DISPLAY XDG_RUNTIME_DIR HYPRLAND_INSTANCE_SIGNATURE"
		set -g focus-events on
		set -g escape-time 3
		set-option -g status-position top
		set-option -as terminal-features 'foot:RGB'
		set -g default-terminal 'tmux-256color'
		bind-key b choose-tree -Z "run-shell 'tmux swap-pane -s %%'" 
		# bind C-p display-popup -E -w 60% -h 70% 'tmuxsessions.sh'
		bind C-p run-shell 'tmuxsessions.sh'
		bind C-d run-shell 'dotfile-picker.sh'
		bind [ run-shell 'project-picker.sh'
		# bind C-c display-popup -E -w 50% -h 50% 'nvim +":cd ~/org" ~/org/refile.norg'
		# bind C-c display-popup -E -w 50% -h 50% 'nvim +"VimwikiIndex"
		bind C-c display-popup -E -w 60% -h 60% "pytui -n"
		# bind C-w display-popup -E -w 40% -h 60% "pytui -D"

		bind C-o display-popup -E -w 50% -h 50% 'igrep ~/wiki/notes'

		bind j run-shell 'popuptmux'
		bind r source-file ~/.config/tmux/tmux.conf \; display "Reloaded!"
		bind i split-window -v -c '\
#{pane_current_path}' 'emojicherrypick.py --menu fzf\
		'
		bind-key -n F4 run-shell 'ranger'
# bind-key -n C-e split-window -v -c '\
#{pane_current_path}' 'vifm\'
		bind-key -n C-f split-window 'ranger .'
bind F3 send-keys 'igrep .' C-m
		'';
	};
	programs.git = {
		enable = true;
		userName = "th3r00t";
		userEmail = "tty303@proton.me";
		extraConfig = {
			commit.gpgSign = true;
			gpg.format = "ssh";
			gpg.ssh.allowedSignersFile = "~/.ssh/allowed_signers";
			user.signingkey = "~/.ssh/id_ed25519.pub";
		};
	};
	programs.direnv = {
		enable = true;
		enableZshIntegration = true;
		nix-direnv.enable = true;
	};

	programs.eza = {
		enable = true;
		enableBashIntegration = true;
		enableZshIntegration = true;
	};
	programs.starship = {
		enable = true;
		# custom settings
		settings = {
			add_newline = false;
			aws.disabled = true;
			gcloud.disabled = true;
			line_break.disabled = true;
		};
	};
	programs.zsh = {
		enable = true;
		sessionVariables = {
			PATH="$PATH:$HOME/.local/usr/bin";
			PYTHONBREAKPOINT="pudb.set_trace";
		};
		oh-my-zsh = {
			enable = true;
			plugins = [
				"git"
				"colored-man-pages"
				"colorize"
				"command-not-found"
				"compleat"
				"dirhistory"
				"fzf"
				"git-auto-fetch"
				"git-extras"
				"git-prompt"
				"gitignore"
				"gpg-agent"
				"history"
				"jsontools"
				"man"
				"nmap"
				"pip"
				"python"
				"ssh-agent"
				"sudo"
				"tmux"
				"vi-mode"
				"zsh-navigation-tools"
			];
			# theme = "starship";
		};
	};
	programs.bash = {
		enable = true;
		enableCompletion = true;
		bashrcExtra = ''
		export PATH="$PATH:$HOME/.local/usr/bin";
		'';
		shellAliases = {
			urlencode = "python3 -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.stdin.read()))'";
			urldecode = "python3 -c 'import sys, urllib.parse as ul; print(il.unquote_plus(sys.stdin.read()))'";
			ls = "eza";
			cat = "bat";
		};
	};

}
