From 720c6a3dbb52d0bdf557ac61caaab3f2398d4765 Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Mon, 11 Mar 2024 23:19:59 +0100 Subject: [PATCH] Up --- home/homepage/default.nix | 3 ++ home/hyprland/default.nix | 4 +- home/misc/default.nix | 27 ++++-------- home/misc/scripts.nix | 87 +++++++++++++++++++++++++++++++++++++++ home/misc/sshconfig.nix | 14 +++++++ home/nvim/cmp.nix | 6 +-- home/nvim/default.nix | 41 ++++++++---------- home/nvim/lsp.nix | 29 ++++++------- home/nvim/options.nix | 19 +++++++-- 9 files changed, 164 insertions(+), 66 deletions(-) create mode 100644 home/homepage/default.nix create mode 100644 home/misc/scripts.nix create mode 100644 home/misc/sshconfig.nix diff --git a/home/homepage/default.nix b/home/homepage/default.nix new file mode 100644 index 0000000..0db3279 --- /dev/null +++ b/home/homepage/default.nix @@ -0,0 +1,3 @@ +{ + +} diff --git a/home/hyprland/default.nix b/home/hyprland/default.nix index 971b594..9773436 100644 --- a/home/hyprland/default.nix +++ b/home/hyprland/default.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: { +{ pkgs, config, ... }: { home.packages = with pkgs; [ xdg-desktop-portal-hyprland @@ -26,7 +26,7 @@ settings = { "$mod" = "SUPER"; - "$menu" = "~/scripts/menu.sh"; + "$menu" = "menu"; "$powermenu" = "${pkgs.wlogout}/bin/wlogout"; exec-once = [ diff --git a/home/misc/default.nix b/home/misc/default.nix index 69d3e3b..997d775 100644 --- a/home/misc/default.nix +++ b/home/misc/default.nix @@ -1,24 +1,11 @@ { - # TODO: - # choose output sound - # choose wallpaper - # import wireguard config - # powermenu - # menu - # custom colors on all config files - # vim format on save + imports = [ ./scripts.nix ./sshconfig.nix ]; + + # TODO: + # custom colors on all config files + # auto update + # auto remove old + # script to edit, rebuild, push - home.file = { - ".ssh/config" = { - text = '' - Host github.com - User git - Hostname github.com - PreferredAuthentications publickey - IdentityFile ~/.ssh/github - ''; - executable = false; - }; - }; } diff --git a/home/misc/scripts.nix b/home/misc/scripts.nix new file mode 100644 index 0000000..c9f266b --- /dev/null +++ b/home/misc/scripts.nix @@ -0,0 +1,87 @@ +{ pkgs, config, ... }: + +let + homedir = config.home.homeDirectory; + + wallpaper = pkgs.writeShellScriptBin "wallpaper" '' + WALLPAPER_FOLDER="${homedir}/Nextcloud/wallpaper" + + cd $WALLPAPER_FOLDER + + choosed_wallpaper=$(fd . | + fzf \ + --preview='kitty icat --clear --transfer-mode=memory --stdin=no --place=''${FZF_PREVIEW_COLUMNS}x''${FZF_PREVIEW_LINES}@0x0 {}' \ + --preview-window=bottom,border-top \ + --margin=1 \ + --layout=reverse \ + --border --border-label "Wallpaper" \ + --info="hidden" \ + --header="" \ + --prompt='/ ' \ + --color="dark,fg+:white,bg+:-1,fg:white,bg:-1"\ + --color='prompt:grey,pointer:magenta,fg+:regular') || exit 1 + + swww img $choosed_wallpaper + ''; + + menu = pkgs.writeShellScriptBin "menu" '' + if pgrep wofi; then + pkill wofi + else + wofi --show drun + fi + ''; + + wireguard-import = pkgs.writeShellScriptBin "wireguard-import" '' + nmcli connection import type wireguard file "$0" + ''; + + choose-output = pkgs.writeShellScriptBin "choose-output" '' + function parse_sinks(){ + output=$(wpctl status) + sinks=($(echo "$output" | sed 's/ │ //' | awk '/Sinks:/ {flag=1; next} /^$/ {flag=0} flag' | sed 's/ /-/g')) + + for sink in "''${sinks[@]}"; do + + id="" + default=false + sink=$(echo "$sink" | sed 's/-/ /g') + sink_name=$(echo "$sink" | sed 's/\[vol:.*$//') + + if [[ $sink_name == "*"* ]]; then + sink_name=$(echo "$sink_name" | sed 's/*//') + default=true + fi + + id=$(echo "$sink_name" | cut -d'.' -f1) + sink_name=$(echo "$sink_name" | sed 's/^[ ]*//;s/[ ]*$//' ) + sink_name=$(echo "$sink_name" | cut -d'.' -f2 ) + + if [[ $default == true ]];then + printf "*%s (%d)" "$sink_name" "$id" + else + printf " %s (%d)" "$sink_name" "$id" + fi + printf "\n" + done + } + + + choosed_sink=$(echo "$(parse_sinks)" | fzf \ + --margin=1 \ + --layout=reverse \ + --border --border-label "Wallpaper" \ + --info="hidden" \ + --header="" \ + --prompt='/ ' \ + --color="dark,fg+:white,bg+:-1,fg:white,bg:-1"\ + --color='prompt:grey,pointer:magenta,fg+:regular') || exit 1 + + choosed_sink_id=$(echo "$choosed_sink" | sed 's/.*(\(.*\))/\1/') + + wpctl set-default $choosed_sink_id + ''; + +in { + home.packages = with pkgs; [ wallpaper menu wireguard-import choose-output ]; +} diff --git a/home/misc/sshconfig.nix b/home/misc/sshconfig.nix new file mode 100644 index 0000000..34e6eb3 --- /dev/null +++ b/home/misc/sshconfig.nix @@ -0,0 +1,14 @@ +{ + home.file = { + ".ssh/config" = { + text = '' + Host github.com + User git + Hostname github.com + PreferredAuthentications publickey + IdentityFile ~/.ssh/github + ''; + executable = false; + }; + }; +} diff --git a/home/nvim/cmp.nix b/home/nvim/cmp.nix index da40ac9..55b2da7 100644 --- a/home/nvim/cmp.nix +++ b/home/nvim/cmp.nix @@ -79,8 +79,8 @@ window = { completion = { winhighlight = - "FloatBorder:CmpBorder,Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel"; - scrollbar = false; + "FloatBorder:CmpBorder,Normal:CmpPmenu,Search:PmenuSel"; + scrollbar = true; sidePadding = 0; border = [ "╭" "─" "╮" "│" "╯" "─" "╰" "│" ]; }; @@ -88,7 +88,7 @@ documentation = { border = [ "╭" "─" "╮" "│" "╯" "─" "╰" "│" ]; winhighlight = - "FloatBorder:CmpBorder,Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel"; + "FloatBorder:CmpBorder,Normal:CmpPmenu,Search:PmenuSel"; }; }; diff --git a/home/nvim/default.nix b/home/nvim/default.nix index 05532b5..e060d0e 100644 --- a/home/nvim/default.nix +++ b/home/nvim/default.nix @@ -20,32 +20,27 @@ programs.nixvim = { -enable = true; + enable = true; - colorschemes.catppuccin.enable = true; + colorschemes.catppuccin.enable = true; - keymaps = [ - # Global Mappings - # Default mode is "" which means normal-visual-op - { - # Toggle NvimTree - key = "e"; - action = "Neotree toggle"; - } - { - # Format file - key = "fm"; - action = "lua vim.lsp.buf.format()"; - } + keymaps = [ + { + key = "e"; + action = "Neotree toggle"; + } + { + key = "fm"; + action = "lua vim.lsp.buf.format()"; + } - # Terminal Mappings - { - # Escape terminal mode using ESC - mode = "t"; - key = ""; - action = ""; - } - ]; + # Terminal Mappings + { + mode = "t"; + key = ""; + action = ""; + } + ]; }; } diff --git a/home/nvim/lsp.nix b/home/nvim/lsp.nix index 335c8f6..ba62a7c 100644 --- a/home/nvim/lsp.nix +++ b/home/nvim/lsp.nix @@ -2,20 +2,21 @@ programs.nixvim.plugins = { lsp-format.enable = true; lsp = { - enable = true; - servers = { - bashls.enable = true; - clangd.enable = true; - gopls.enable = true; - nixd.enable = true; + enable = true; + servers = { + bashls.enable = true; + clangd.enable = true; + gopls.enable = true; + nixd.enable = true; + tailwindcss.enable = true; + }; + keymaps.lspBuf = { + "gd" = "definition"; + "gD" = "references"; + "gt" = "type_definition"; + "gi" = "implementation"; + "K" = "hover"; + }; }; - keymaps.lspBuf = { - "gd" = "definition"; - "gD" = "references"; - "gt" = "type_definition"; - "gi" = "implementation"; - "K" = "hover"; - }; - }; }; } diff --git a/home/nvim/options.nix b/home/nvim/options.nix index 0daa0d3..19cba86 100644 --- a/home/nvim/options.nix +++ b/home/nvim/options.nix @@ -2,24 +2,35 @@ programs.nixvim.globals.mapleader = " "; programs.nixvim.options = { - updatetime = 100; # Faster completion + updatetime = 50; # Faster completion number = true; relativenumber = true; autoindent = true; - clipboard = "unnamedplus"; + clipboard = "unnamed,unnamedplus"; + expandtab = true; + tabstop = 2; + softtabstop = 2; shiftwidth = 2; smartindent = true; - tabstop = 2; + breakindent = true; ignorecase = true; incsearch = true; + hlsearch = true; smartcase = true; wildmode = "list:longest"; + completeopt = [ "menuone" "noselect" ]; + signcolumn = "yes"; + cursorline = true; + scrolloff = 8; + mouse = "a"; + + wrap = false; swapfile = false; - undofile = true; # Build-in persistent undo + undofile = true; }; }