From 634e8cabace81e15d2333da38ec45bfd8f6f0d55 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 9 Aug 2021 08:19:21 -0400 Subject: [PATCH 01/35] a bit of nix config --- nixos/configuration.nix | 146 ++++++++++++++++++++ nixos/flakes/flake.nix | 31 +++++ nixos/home.nix | 157 ++++++++++++++++++++++ nixos/init.lua | 285 ++++++++++++++++++++++++++++++++++++++++ nixos/justfile | 11 ++ nixos/todo.txt | 3 + 6 files changed, 633 insertions(+) create mode 100644 nixos/configuration.nix create mode 100644 nixos/flakes/flake.nix create mode 100644 nixos/home.nix create mode 100644 nixos/init.lua create mode 100644 nixos/justfile create mode 100644 nixos/todo.txt diff --git a/nixos/configuration.nix b/nixos/configuration.nix new file mode 100644 index 0000000..e368334 --- /dev/null +++ b/nixos/configuration.nix @@ -0,0 +1,146 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + /etc/nixos/hardware-configuration.nix + ]; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # networking.hostName = "nixos"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Set your time zone. + time.timeZone = "America/New_York"; + + # The global useDHCP flag is deprecated, therefore explicitly set to false here. + # Per-interface useDHCP will be mandatory in the future, so this generated config + # replicates the default behaviour. + networking.useDHCP = false; + networking.interfaces.enp0s31f6.useDHCP = true; + networking.interfaces.wlp3s0.useDHCP = true; + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Select internationalisation properties. + # i18n.defaultLocale = "en_US.UTF-8"; + # console = { + # font = "Lat2-Terminus16"; + # keyMap = "us"; + # }; + + # Enable the X11 windowing system. + # services.xserver.enable = true; + services.xserver = { + enable = true; + desktopManager = { + xterm.enable = false; + xfce.enable = true; + }; + displayManager.defaultSession = "xfce"; + + # Disable mouse acceleration + libinput.mouse.accelProfile = "flat"; + }; + + # Configure keymap in X11 + services.xserver.layout = "us"; + services.xserver.xkbOptions = "eurosign:e"; + + # Enable CUPS to print documents. + # services.printing.enable = true; + + # Enable sound. + sound.enable = true; + hardware.pulseaudio.enable = true; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + # Replace sudo with doas + security = { + + # Remove sudo + sudo.enable = false; + + # Add doas + doas = { + enable = true; + + # No password required + wheelNeedsPassword = false; + + # Pass environment variables from user to root + # Also requires removing password here + extraRules = [{ + groups = [ "wheel" ]; + noPass = true; + keepEnv = true; + }]; + }; + }; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.noah = { + + # Not sure what this means tbh + isNormalUser = true; + + # Automatically create a password to start + initialPassword = "changeme"; + + # Enable sudo privileges + extraGroups = [ "wheel" ]; + + # Use the fish shell + shell = pkgs.fish; + }; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + fish + vim + wget + curl + home-manager + just + ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + # services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "21.05"; # Did you read the comment? + +} diff --git a/nixos/flakes/flake.nix b/nixos/flakes/flake.nix new file mode 100644 index 0000000..619f45d --- /dev/null +++ b/nixos/flakes/flake.nix @@ -0,0 +1,31 @@ +{ + description = "System Config"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-21.05"; + home-manager.url = "github:nix-community/home-manager/release-21.05"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { nixpkgs, home-manager, ... }: { + let + system = "x86_64-linux"; + + pkgs = import nixpkgs { + inherit system; + config = { allowUnfree = true; }; + }; + + lib = nixpkgs.lib; + + in { + nixosConfigurations = { + nixos = lib.nixosSystem { + inherit system; + modules = [ + ./configuration.nix + ] + }; + }; + }; +} diff --git a/nixos/home.nix b/nixos/home.nix new file mode 100644 index 0000000..d280df6 --- /dev/null +++ b/nixos/home.nix @@ -0,0 +1,157 @@ +{ pkgs, ... }: + +let + + # Import unstable channel (for Neovim 0.5) + unstable = import { config = { allowUnfree = true; }; }; + +in + +{ + home.packages = with pkgs; [ + firefox + unzip + # alacritty + # unstable.neovim + tmux + rsync + ripgrep + bat + fd + exa + sd + jq + tealdeer + zoxide + unstable._1password-gui + ]; + + programs.alacritty = { + enable = true; + settings = { + window = { + dimensions = { + columns = 110; + lines = 30; + }; + padding = { + x = 20; + y = 20; + }; + }; + scrolling.history = 10000; + font = { + size = 15.0; + }; + key_bindings = [ + { + key = "F"; + mods = "Super"; + action = "ToggleFullscreen"; + } + { + key = "L"; + mods = "Super"; + chars = "\x1F"; + } + ]; + }; + }; + + programs.fish = { + enable = true; + }; + + home.sessionVariables = { + EDITOR = "nvim"; + }; + + programs.starship = { + enable = true; + enableFishIntegration = true; + }; + + programs.fzf = { + enable = true; + enableFishIntegration = true; + }; + + # Other configs + xdg.configFile = { + "starship.toml".source = ../starship/starship.toml.configlink; + #"alacritty/alacritty.yml".source = ../alacritty.configlink/alacritty.yml; + # "nvim/init.lua".source = ../nvim.configlink/init.lua; + }; + + # nixpkgs.overlays = [( + # self: super: { + # neovim = unstable.neovim; + # }) + # ]; + nixpkgs.overlays = [ + (import (builtins.fetchTarball { + url = https://github.com/nix-community/neovim-nightly-overlay/archive/master.tar.gz; + })) + ]; + + programs.neovim = { + enable = true; + package = pkgs.neovim-nightly; + vimAlias = true; + plugins = with pkgs.vimPlugins; [ + fzf-vim + fzfWrapper + vim-eunuch + vim-vinegar + surround + commentary + repeat + gruvbox-nvim + nvim-lspconfig + lsp-colors-nvim + vim-vsnip + vim-vsnip-integ + nvim-compe + tabular + vimwiki + vim-rooter + lualine-nvim + nvim-web-devicons + nvim-treesitter + vim-fish + nginx-vim + vim-terraform + vim-toml + vim-helm + vim-nix + gitsigns-nvim + plenary-nvim + vim-hexokinase + ]; + extraPackages = with pkgs; [ + nodePackages.pyright + rust-analyzer + ]; + extraConfig = '' + lua << EOF + ${builtins.readFile ./init.lua} + EOF + ''; + }; + + # # Neovim config + # home.file = { + # ".config/nvim/init.lua".source = ../nvim.configlink/init.lua; + # }; + + programs.git = { + enable = true; + userName = "Noah Masur"; + userEmail = "7386960+nmasur@users.noreply.github.com"; + extraConfig = { + core = { + editor = "nvim"; + }; + }; + }; +} diff --git a/nixos/init.lua b/nixos/init.lua new file mode 100644 index 0000000..1c2cdad --- /dev/null +++ b/nixos/init.lua @@ -0,0 +1,285 @@ +-- LSP Settings +-- ============ + +require('lspconfig').rust_analyzer.setup{} +require('lspconfig').pyright.setup{ + cmd = { "poetry", "run", "pyright-langserver", "--stdio" } +} +require'compe'.setup({ + enabled = true, + source = { + path = true, + buffer = true, + nvim_lsp = true, + }, +}) +if require('lspconfig/util').has_bins('diagnostic-languageserver') then + require('lspconfig').diagnosticls.setup{ + cmd = { "diagnostic-languageserver", "--stdio" }, + filetypes = { "sh" }, + on_attach = on_attach, + init_options = { + filetypes = { + sh = "shellcheck", + }, + linters = { + shellcheck = { + sourceName = "shellcheck", + command = "shellcheck", + debounce = 100, + args = { "--format=gcc", "-" }, + offsetLine = 0, + offsetColumn = 0, + formatLines = 1, + formatPattern = { + "^[^:]+:(\\d+):(\\d+):\\s+([^:]+):\\s+(.*)$", + { + line = 1, + column = 2, + message = 4, + security = 3 + } + }, + securities = { + error = "error", + warning = "warning", + } + }, + } + } + } +end + +-- Auto-complete +-- ==================== + +-- Auto-complete mapping +local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) +end + +local check_back_space = function() + local col = vim.fn.col('.') - 1 + if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then + return true + else + return false + end +end +-- Use (s-)tab to: +--- move to prev/next item in completion menuone +--- jump to prev/next snippet's placeholder +_G.tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t "" + elseif vim.fn.call("vsnip#available", {1}) == 1 then + return t "(vsnip-expand-or-jump)" + elseif check_back_space() then + return t "" + else + return vim.fn['compe#complete']() + end +end +_G.s_tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t "" + elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then + return t "(vsnip-jump-prev)" + else + return t "" + end +end + +-- Auto-complete keybinds +vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) +vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) +vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) +vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) + +-- Settings +-- ======== + +-- Basic Settings +vim.o.termguicolors = true -- Set to truecolor +vim.cmd[[colorscheme gruvbox]] -- Installed with a plugin +vim.o.hidden = true -- Don't unload buffers when leaving them +vim.wo.number = true -- Show line numbers +vim.wo.relativenumber = true -- Relative numbers instead of absolute +vim.o.list = true -- Reveal whitespace with dashes +vim.o.expandtab = true -- Tabs into spaces +vim.o.shiftwidth = 4 -- Amount to shift with > key +vim.o.softtabstop = 4 -- Amount to shift with key +vim.o.ignorecase = true -- Ignore case when searching +vim.o.smartcase = true -- Check case when using capitals in search +vim.o.infercase = true -- Don't match cases when completing suggestions +vim.o.incsearch = true -- Search while typing +vim.o.visualbell = true -- No sounds +vim.o.scrolljump = 1 -- Number of lines to scroll +vim.o.scrolloff = 3 -- Margin of lines to see while scrolling +vim.o.splitright = true -- Vertical splits on the right side +vim.o.splitbelow = true -- Horizontal splits on the bottom side +vim.o.pastetoggle = "" -- Use F3 to enter raw paste mode +vim.o.clipboard = "unnamedplus" -- Uses system clipboard for yanking +vim.o.updatetime = 300 -- Faster diagnostics +vim.o.mouse = "nv" -- Mouse interaction / scrolling + +-- Neovim features +vim.o.inccommand = "split" -- Live preview search and replace +vim.o.completeopt = "menuone,noselect" -- Required for nvim-compe completion + +-- Remember last position when reopening file +vim.api.nvim_exec([[ + if has("autocmd") + au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif + endif +]], false) + +-- Better backup, swap and undo storage +vim.o.backup = true -- Easier to recover and more secure +vim.bo.swapfile = false -- Instead of swaps, create backups +vim.bo.undofile = true -- Keeps undos after quit + +-- Create backup directories if they don't exist +vim.api.nvim_exec([[ + set backupdir=~/.local/share/nvim/backup + set undodir=~/.local/share/nvim/undo + if !isdirectory(&backupdir) + call mkdir(&backupdir, "p") + endif + if !isdirectory(&undodir) + call mkdir(&undodir, "p") + endif +]], false) + +-- Keep selection when tabbing +vim.api.nvim_set_keymap("v", "<", "", ">gv", {noremap=true}) + +-- Force filetype patterns that Vim doesn't know about +vim.api.nvim_exec([[ + au BufRead,BufNewFile *.Brewfile setfiletype brewfile + au BufRead,BufNewFile tmux.conf* setfiletype tmux + au BufRead,BufNewFile *ignore.*link setfiletype gitignore + au BufRead,BufNewFile gitconfig.*link setfiletype gitconfig + au BufRead,BufNewFile *.toml.*link setfiletype toml + au BufRead,BufNewFile *.muttrc setfiletype muttrc + au BufRead,BufNewFile .env* set ft=text | set syntax=sh +]], false) + +-- LaTeX options +vim.api.nvim_exec([[ + au FileType tex inoremap ;bf \textbf{}i + au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw! +]], false) + +-- Highlight when yanking +vim.api.nvim_exec([[ + au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 } +]], false) + +-- Rust stuff +-- vim.api.nvim_exec([[ +-- au BufWritePost *.rs silent! execute "%! rustfmt" +-- ]], false) + +-- Auto-pairs +vim.g.AutoPairsFlyMode = 0 + +-- Netrw +vim.g.netrw_liststyle = 3 -- Change style to 'tree' view +vim.g.netrw_banner = 0 -- Remove useless banner +vim.g.netrw_winsize = 15 -- Explore window takes % of page +vim.g.netrw_browse_split = 4 -- Open in previous window +vim.g.netrw_altv = 1 -- Always split left + +-- Polyglot +vim.g.terraform_fmt_on_save = 1 -- Formats with terraform plugin +vim.g.rustfmt_autosave = 1 -- Formats with rust plugin + +-- VimWiki +vim.g.vimwiki_list = { + { + ["path"] = "$NOTES_PATH", + ["syntax"] = "markdown", + ["index"] = "home", + ["ext"] = ".md" + } +} +vim.g.vimwiki_key_mappings = { + ["all_maps"] = 1, + ["mouse"] = 1, +} +vim.g.vimwiki_auto_chdir = 1 -- Set local dir to Wiki when open +vim.g.vimwiki_create_link = 0 -- Don't automatically create new links +vim.g.vimwiki_listsyms = " x" -- Set checkbox symbol progression +vim.g.vimwiki_table_mappings = 0 -- VimWiki table keybinds interfere with tab completion +vim.api.nvim_exec([[ + au FileType markdown inoremap ;tt :AddTag + + function! PInsert(item) + let @z=a:item + norm "zpx + endfunction + + command! AddTag call fzf#run({'source': 'rg "#[A-Za-z/]+[ |\$]" -o --no-filename --no-line-number | sort | uniq', 'sink': function('PInsert')}) +]], false) + +-- Status bar +require('lualine').setup({ + options = { theme = 'gruvbox' } +}) + +-- Remap space as leader key +vim.api.nvim_set_keymap("", "", "", {noremap=true, silent=true}) +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- Unset search pattern register +vim.api.nvim_set_keymap("n", "", ":noh", {noremap=true, silent=true}) + +-- Shuffle lines around +vim.api.nvim_set_keymap("n", "", ":m .+1==", {noremap=true}) +vim.api.nvim_set_keymap("n", "", ":m .-2==", {noremap=true}) +vim.api.nvim_set_keymap("i", "", ":m .+1==gi", {noremap=true}) +vim.api.nvim_set_keymap("i", "", ":m .-2==gi", {noremap=true}) +vim.api.nvim_set_keymap("v", "", ":m '>+1gv=gv", {noremap=true}) +vim.api.nvim_set_keymap("v", "", ":m '<-2gv=gv", {noremap=true}) + +-- Fzf (fuzzy finder) +vim.api.nvim_set_keymap("n", "/", ":Rg", {noremap=true}) +vim.api.nvim_set_keymap("n", "ff", ":Files", {noremap=true}) +vim.api.nvim_set_keymap("n", "fr", ":History", {noremap=true}) +vim.api.nvim_set_keymap("n", "b", ":Buffers", {noremap=true}) +vim.api.nvim_set_keymap("n", "s", ":BLines", {noremap=true}) + +-- File commands +vim.api.nvim_set_keymap("n", "q", ":quit", {noremap=true}) +vim.api.nvim_set_keymap("n", "Q", ":quitall", {noremap=true}) +vim.api.nvim_set_keymap("n", "fs", ":write", {noremap=true}) +vim.api.nvim_set_keymap("n", "fe", ":!chmod 755 %", {noremap=true}) +vim.api.nvim_set_keymap("n", "fn", ":!chmod 644 %", {noremap=true}) +vim.api.nvim_set_keymap("n", "fd", ":lcd %:p:h", {silent=true, noremap=true}) +vim.api.nvim_set_keymap("n", "fu", ":lcd ..", {silent=true, noremap=true}) +vim.api.nvim_set_keymap("n", "", ":b#", {silent=true, noremap=true}) +vim.api.nvim_set_keymap("n", "gr", ":!gh repo view -w", {silent=true, noremap=true}) +vim.api.nvim_set_keymap("n", "tt", [[exe 'edit ~/notes/journal/'.strftime("%Y-%m-%d_%a").'.md']], {noremap=true}) + +-- Window commands +vim.api.nvim_set_keymap("n", "wv", ":vsplit", {noremap=true}) +vim.api.nvim_set_keymap("n", "wh", ":split", {noremap=true}) +vim.api.nvim_set_keymap("n", "wm", ":only", {noremap=true}) + +-- Tabularize +vim.api.nvim_set_keymap("", "ta", ":Tabularize /", {noremap=true}) +vim.api.nvim_set_keymap("", "t#", ":Tabularize /#", {noremap=true}) +vim.api.nvim_set_keymap("", "t\"", ":Tabularize /\"", {noremap=true}) + +-- Vimrc +vim.api.nvim_set_keymap("n", "fv", ":edit $MYVIMRC", {noremap=true}) +vim.api.nvim_set_keymap("n", "rr", ":luafile $MYVIMRC", {noremap=true}) + +-- Other +vim.api.nvim_set_keymap("n", "", ":HopWord", {noremap=true}) +vim.api.nvim_set_keymap("t", "", "", {noremap=true}) -- Exit terminal mode +vim.api.nvim_set_keymap("n", "", ":noh", {noremap=true, silent=true}) +vim.api.nvim_set_keymap('n', 'Y', 'y$', { noremap = true}) diff --git a/nixos/justfile b/nixos/justfile new file mode 100644 index 0000000..dda353e --- /dev/null +++ b/nixos/justfile @@ -0,0 +1,11 @@ +# Show these options +default: + @just --list --list-heading $'Update NixOS config:\n' + +# Update the system +system: + nixos-rebuild switch -I nixos-config=./configuration.nix + +# Update the user environment +home: + home-manager switch -f ./home.nix diff --git a/nixos/todo.txt b/nixos/todo.txt new file mode 100644 index 0000000..75e24ea --- /dev/null +++ b/nixos/todo.txt @@ -0,0 +1,3 @@ +libratbag (ratbagd) for input devices + +inspiration: https://github.com/JonathanReeve/dotfiles/blob/minimal/dotfiles/home.nix From b111045ab4689c514b7af9fd302639228da1d7e8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 9 Aug 2021 08:45:46 -0400 Subject: [PATCH 02/35] fish abbreviations --- nixos/home.nix | 113 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 1 deletion(-) diff --git a/nixos/home.nix b/nixos/home.nix index d280df6..df425cf 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -22,7 +22,6 @@ in sd jq tealdeer - zoxide unstable._1password-gui ]; @@ -60,6 +59,112 @@ in programs.fish = { enable = true; + functions = {}; + interactiveShellInit = ""; + loginShellInit = ""; + shellAbbrs = { + + # Directory aliases + l = "ls"; + lh = "ls -lh"; + ll = "ls -alhF"; + lf = "ls -lh | fzf"; + c = "cd"; + # -- - = "cd -"; + mkd = "mkdir -pv"; + + # Tmux + ta = "tmux attach-session"; + tan = "tmux attach-session -t noah"; + tnn = "tmux new-session -s noah"; + + # Git + g = "git"; + gs = "git status"; + gd = "git diff"; + gds = "git diff --staged"; + gdp = "git diff HEAD^"; + ga = "git add"; + gaa = "git add -A"; + gac = "git commit -am"; + gc = "git commit -m"; + gca = "git commit --amend"; + gu = "git pull"; + gp = "git push"; + gpp = "git_set_upstream"; + gl = "git log --graph --decorate --oneline -20"; + gll = "git log --graph --decorate --oneline"; + gco = "git checkout"; + gcom = "git switch master"; + gcob = "git switch -c"; + gb = "git branch"; + gbd = "git branch -d"; + gbD = "git branch -D"; + gr = "git reset"; + grh = "git reset --hard"; + gm = "git merge"; + gcp = "git cherry-pick"; + cdg = "cd (git rev-parse --show-toplevel)"; + + # GitHub + ghr = "gh repo view -w"; + gha = "gh run list | head -1 | awk \'{ print $(NF-2) }\' | xargs gh run view"; + grw = "gh run watch"; + grf = "gh run view --log-failed"; + grl = "gh run view --log"; + + # Vim + v = "vim"; + vl = "vim -c 'normal! `0'"; + vll = "vim -c 'Hist'"; + + # Notes + qn = "quicknote"; + sn = "syncnotes"; + to = "today"; + work = "vim $NOTES_PATH/work.md"; + + # Improved CLI Tools + cat = "bat"; # Swap cat with bat + h = "http -Fh --all"; # Curl site for headers + + # Fun CLI Tools + weather = "curl wttr.in/$WEATHER_CITY"; + moon = "curl wttr.in/Moon"; + + # Cheat Sheets + ssl = "openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr"; + fingerprint = "ssh-keyscan myhost.com | ssh-keygen -lf -"; + publickey = "ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub"; + forloop = "for i in (seq 1 100)"; + + # Docker + dc = "$DOTS/bin/docker_cleanup"; + dr = "docker run --rm -it"; + db = "docker build . -t"; + + # Terraform + te = "terraform"; + + # Kubernetes + k = "kubectl"; + pods = "kubectl get pods -A"; + nodes = "kubectl get nodes"; + deploys = "kubectl get deployments -A"; + dash = "kube-dashboard"; + ks = "k9s"; + + # Python + py = "python"; + po = "poetry"; + pr = "poetry run python"; + + # Rust + ca = "cargo"; + + }; + shellAliases = {}; + shellInit = ""; }; home.sessionVariables = { @@ -76,6 +181,11 @@ in enableFishIntegration = true; }; + programs.zoxide = { + enable = true; + enableFishIntegration = true; + }; + # Other configs xdg.configFile = { "starship.toml".source = ../starship/starship.toml.configlink; @@ -131,6 +241,7 @@ in extraPackages = with pkgs; [ nodePackages.pyright rust-analyzer + terraform-ls ]; extraConfig = '' lua << EOF From 0aade99d4a822845ac9f9e8b2274b9cb56af28d2 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 6 Nov 2021 15:16:53 -0400 Subject: [PATCH 03/35] fonts --- nixos/configuration.nix | 6 ++++++ nixos/home.nix | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index e368334..9b45b21 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -63,6 +63,12 @@ sound.enable = true; hardware.pulseaudio.enable = true; + # Install fonts + fonts.fonts = with pkgs; [ + fira-code + fira-code-symbols + ]; + # Enable touchpad support (enabled default in most desktopManager). # services.xserver.libinput.enable = true; diff --git a/nixos/home.nix b/nixos/home.nix index df425cf..47b5f8b 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -30,7 +30,7 @@ in settings = { window = { dimensions = { - columns = 110; + columns = 85; lines = 30; }; padding = { @@ -169,6 +169,7 @@ in home.sessionVariables = { EDITOR = "nvim"; + fish_greeting = ""; }; programs.starship = { From f1bc34e8fdba15edf40f49daf1054e7cbe304adb Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 24 Nov 2021 03:19:19 +0000 Subject: [PATCH 04/35] updates with ec2 --- nixos/home.nix | 142 ++++----- nixos/init.lua | 777 +++++++++++++++++++++++++++++++++++++------------ nixos/justfile | 4 + 3 files changed, 650 insertions(+), 273 deletions(-) diff --git a/nixos/home.nix b/nixos/home.nix index 47b5f8b..47e1814 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -9,8 +9,10 @@ in { home.packages = with pkgs; [ - firefox + # firefox unzip + neovim + gcc # for tree-sitter # alacritty # unstable.neovim tmux @@ -22,40 +24,40 @@ in sd jq tealdeer - unstable._1password-gui + /* unstable._1password-gui */ ]; - programs.alacritty = { - enable = true; - settings = { - window = { - dimensions = { - columns = 85; - lines = 30; - }; - padding = { - x = 20; - y = 20; - }; - }; - scrolling.history = 10000; - font = { - size = 15.0; - }; - key_bindings = [ - { - key = "F"; - mods = "Super"; - action = "ToggleFullscreen"; - } - { - key = "L"; - mods = "Super"; - chars = "\x1F"; - } - ]; - }; - }; + #programs.alacritty = { + # enable = true; + # settings = { + # window = { + # dimensions = { + # columns = 85; + # lines = 30; + # }; + # padding = { + # x = 20; + # y = 20; + # }; + # }; + # scrolling.history = 10000; + # font = { + # size = 15.0; + # }; + # key_bindings = [ + # { + # key = "F"; + # mods = "Super"; + # action = "ToggleFullscreen"; + # } + # { + # key = "L"; + # mods = "Super"; + # chars = "\x1F"; + # } + # ]; + # }; + #}; programs.fish = { enable = true; @@ -114,9 +116,9 @@ in grl = "gh run view --log"; # Vim - v = "vim"; - vl = "vim -c 'normal! `0'"; - vll = "vim -c 'Hist'"; + v = "nvim"; + vl = "nvim -c 'normal! `0'"; + vll = "nvim -c 'Hist'"; # Notes qn = "quicknote"; @@ -127,6 +129,7 @@ in # Improved CLI Tools cat = "bat"; # Swap cat with bat h = "http -Fh --all"; # Curl site for headers + j = "just"; # Fun CLI Tools weather = "curl wttr.in/$WEATHER_CITY"; @@ -191,7 +194,7 @@ in xdg.configFile = { "starship.toml".source = ../starship/starship.toml.configlink; #"alacritty/alacritty.yml".source = ../alacritty.configlink/alacritty.yml; - # "nvim/init.lua".source = ../nvim.configlink/init.lua; + "nvim/init.lua".source = ./init.lua; }; # nixpkgs.overlays = [( @@ -205,51 +208,26 @@ in })) ]; - programs.neovim = { - enable = true; - package = pkgs.neovim-nightly; - vimAlias = true; - plugins = with pkgs.vimPlugins; [ - fzf-vim - fzfWrapper - vim-eunuch - vim-vinegar - surround - commentary - repeat - gruvbox-nvim - nvim-lspconfig - lsp-colors-nvim - vim-vsnip - vim-vsnip-integ - nvim-compe - tabular - vimwiki - vim-rooter - lualine-nvim - nvim-web-devicons - nvim-treesitter - vim-fish - nginx-vim - vim-terraform - vim-toml - vim-helm - vim-nix - gitsigns-nvim - plenary-nvim - vim-hexokinase - ]; - extraPackages = with pkgs; [ - nodePackages.pyright - rust-analyzer - terraform-ls - ]; - extraConfig = '' - lua << EOF - ${builtins.readFile ./init.lua} - EOF - ''; - }; + #programs.neovim = { + # enable = true; + # # package = pkgs.neovim-nightly; + # vimAlias = true; + # extraPackages = with pkgs; [ + # nodePackages.pyright + # rust-analyzer + # terraform-ls + # ]; + # #extraConfig = builtins.concatStringsSep "\n" [ + # # '' + # # luafile ${builtins.toString ./init.lua} + # # '' + # #]; + # #extraConfig = '' + # # lua << EOF + # # ${builtins.readFile ./init.lua} + # # EOF + # #''; + #}; # # Neovim config # home.file = { diff --git a/nixos/init.lua b/nixos/init.lua index 1c2cdad..f3f4110 100644 --- a/nixos/init.lua +++ b/nixos/init.lua @@ -1,169 +1,450 @@ --- LSP Settings --- ============ +-- Bootstrap the Packer plugin manager +local fn = vim.fn +local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' +if fn.empty(fn.glob(install_path)) > 0 then + packer_bootstrap = fn.system( + { + 'git', 'clone', '--depth', '1', + 'https://github.com/wbthomason/packer.nvim', install_path + } + ) +end -require('lspconfig').rust_analyzer.setup{} -require('lspconfig').pyright.setup{ - cmd = { "poetry", "run", "pyright-langserver", "--stdio" } -} -require'compe'.setup({ - enabled = true, - source = { - path = true, - buffer = true, - nvim_lsp = true, - }, -}) -if require('lspconfig/util').has_bins('diagnostic-languageserver') then - require('lspconfig').diagnosticls.setup{ - cmd = { "diagnostic-languageserver", "--stdio" }, - filetypes = { "sh" }, - on_attach = on_attach, - init_options = { - filetypes = { - sh = "shellcheck", - }, - linters = { - shellcheck = { - sourceName = "shellcheck", - command = "shellcheck", - debounce = 100, - args = { "--format=gcc", "-" }, - offsetLine = 0, - offsetColumn = 0, - formatLines = 1, - formatPattern = { - "^[^:]+:(\\d+):(\\d+):\\s+([^:]+):\\s+(.*)$", - { - line = 1, - column = 2, - message = 4, - security = 3 - } +-- Packer plugin installations +require('packer').startup(function(use) + + -- Maintain plugin manager + use 'wbthomason/packer.nvim' + + -- Startup speed hacks + use { + 'lewis6991/impatient.nvim', + config = function() + require('impatient') + end + } + + -- Important tweaks + use 'tpope/vim-surround' --- Manipulate parentheses + use 'tpope/vim-commentary' --- Use gc or gcc to add comments + + -- Convenience tweaks + use 'tpope/vim-eunuch' --- File manipulation in Vim + use 'tpope/vim-vinegar' --- Fixes netrw file explorer + use 'tpope/vim-fugitive' --- Git commands and syntax + use 'tpope/vim-repeat' --- Actually repeat using . + use 'christoomey/vim-tmux-navigator' --- Hotkeys for tmux panes + + -- Colorscheme + use { + 'morhetz/gruvbox', + config = function() + vim.cmd[[colorscheme gruvbox]] + end + } + + -- Git next to line numbers + use { + 'lewis6991/gitsigns.nvim', + branch = 'main', + requires = {'nvim-lua/plenary.nvim'}, + config = function() + require('gitsigns').setup() + end + } + + -- Status bar + -- use { + -- 'hoob3rt/lualine.nvim', + -- requires = { 'kyazdani42/nvim-web-devicons', opt = true }, + -- config = function() + -- require('lualine').setup({ + -- options = { + -- theme = 'gruvbox', + -- icons_enabled = true + -- } + -- }) + -- end + -- } + + -- Improve speed and filetype detection + use { + 'nathom/filetype.nvim', + config = function() + -- Filetype for .env files + local envfiletype = function() + vim.bo.filetype = 'text' + vim.bo.syntax = 'sh' + end + -- Force filetype patterns that Vim doesn't know about + require('filetype').setup({ + overrides = { + extensions = { + Brewfile = 'brewfile', + muttrc = 'muttrc', + hcl = 'terraform', }, - securities = { - error = "error", - warning = "warning", - } - }, + literal = { + Caskfile = 'brewfile', + [".gitignore"] = 'gitignore', + }, + complex = { + [".*git/config"] = "gitconfig", + ["tmux.conf%..*link"] = "tmux", + ["gitconfig%..*link"] = "gitconfig", + [".*ignore%..*link"] = "gitignore", + [".*%.toml%..*link"] = "toml", + }, + function_extensions = {}, + function_literal = { + [".envrc"] = envfiletype, + [".env"] = envfiletype, + [".env.dev"] = envfiletype, + [".env.prod"] = envfiletype, + [".env.example"] = envfiletype, + }, + } + }) + end + } + + -- Alignment tool + use 'godlygeek/tabular' + + -- Markdown renderer / wiki notes + use 'vimwiki/vimwiki' + + -- Markdown pretty view + use 'ellisonleao/glow.nvim' + + -- Navigation + use { + 'ggandor/lightspeed.nvim', + branch = 'smart-autojump' + } + + -- Snippet engine + use 'L3MON4D3/LuaSnip' + + -- ======================================================================= + -- Language Server + -- ======================================================================= + + -- Language server engine + use { + 'neovim/nvim-lspconfig', + requires = { 'hrsh7th/cmp-nvim-lsp' }, + config = function() + local capabilities = require('cmp_nvim_lsp').update_capabilities( + vim.lsp.protocol.make_client_capabilities() + ) + require('lspconfig').rust_analyzer.setup{ capabilities = capabilities } + require('lspconfig').tflint.setup{ capabilities = capabilities } + require('lspconfig').terraformls.setup{ capabilities = capabilities } + require('lspconfig').pyright.setup{ + cmd = { "poetry", "run", "pyright-langserver", "--stdio" }, + capabilities = capabilities, } + if require('lspconfig/util').has_bins('diagnostic-languageserver') then + require('lspconfig').diagnosticls.setup{ + cmd = { "diagnostic-languageserver", "--stdio" }, + filetypes = { "sh" }, + on_attach = on_attach, + init_options = { + filetypes = { sh = "shellcheck" }, + linters = { + shellcheck = { + sourceName = "shellcheck", + command = "shellcheck", + debounce = 100, + args = { "--format=gcc", "-" }, + offsetLine = 0, + offsetColumn = 0, + formatLines = 1, + formatPattern = { + "^[^:]+:(\\d+):(\\d+):\\s+([^:]+):\\s+(.*)$", + { line = 1, column = 2, message = 4, security = 3 } + }, + securities = { error = "error", warning = "warning", } + }, + } + } + } + end + end + } + + -- Pretty highlights + use 'folke/lsp-colors.nvim' + + use { + 'folke/trouble.nvim', + requires = 'kyazdani42/nvim-web-devicons', + config = function() + require("trouble").setup { } + end + } + + -- ======================================================================= + -- Completion System + -- ======================================================================= + + -- Completion sources + use 'hrsh7th/cmp-nvim-lsp' --- Language server completion plugin + use 'hrsh7th/cmp-buffer' --- Generic text completion + use 'hrsh7th/cmp-path' --- Local file completion + use 'hrsh7th/cmp-cmdline' --- Command line completion + use 'hrsh7th/cmp-nvim-lua' --- Nvim lua api completion + use 'saadparwaiz1/cmp_luasnip' --- Luasnip completion + use 'lukas-reineke/cmp-rg' --- Ripgrep completion + + -- Completion engine + use { + 'hrsh7th/nvim-cmp', + requires = { 'L3MON4D3/LuaSnip', }, + config = function() + local cmp = require('cmp') + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + mapping = { + [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), + [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), + [''] = function(fallback) + cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }) + vim.cmd('stopinsert') --- Abort and leave insert mode + end, + -- [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }), + -- [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 's' }), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + [''] = cmp.mapping(function(fallback) + if require('luasnip').expand_or_jumpable() then + require('luasnip').expand_or_jump() + end + end, {"i", "s"}) + }, + sources = { + { name = 'nvim_lua' }, + { name = 'nvim_lsp' }, + { name = 'path' }, + { name = 'luasnip' }, + { name = 'buffer', keyword_length = 3, max_item_count = 10 }, + { + name = 'rg', keyword_length = 6, max_item_count = 10, + option = { additional_arguments = "--ignore-case" } + }, + }, + experimental = { + native_menu = false, --- Use cmp menu instead of Vim menu + ghost_text = true, --- Show preview auto-completion + }, + }) + + -- Use buffer source for `/` + cmp.setup.cmdline('/', { + sources = { + { name = 'buffer', keyword_length = 5 } + } + }) + + -- Use cmdline & path source for ':' + cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) + }) + end + } + + -- ======================================================================= + -- Syntax + -- ======================================================================= + + -- Syntax engine + use { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate', + config = function() + require('nvim-treesitter.configs').setup { + highlight = { enable = true }, + indent = { enable = true }, + } + end + } + + -- Additional syntax sources + use 'bfontaine/Brewfile.vim' --- Brewfile syntax + use 'chr4/nginx.vim' --- Nginx syntax + use 'hashivim/vim-terraform' --- Terraform formatting + use 'towolf/vim-helm' --- Helm syntax + use 'rodjek/vim-puppet' --- Puppet syntax + use 'blankname/vim-fish' --- Better fish syntax + + -- ======================================================================= + -- Fuzzy Launcher + -- ======================================================================= + + use { + 'nvim-telescope/telescope.nvim', + requires = { 'nvim-lua/plenary.nvim' }, + config = function() + -- Telescope: quit instantly with escape + local actions = require("telescope.actions") + require("telescope").setup({ + defaults = { + mappings = { + i = { + [""] = actions.close, + [""] = "which_key", + }, + }, + }, + pickers = { + find_files = { theme = "ivy" }, + oldfiles = { theme = "ivy" }, + buffers = { theme = "dropdown" }, + }, + extensions = { + fzy_native = {}, + tmux = {}, + zoxide = {}, + -- neoclip = {}, + project = { + base_dirs = { '~/dev/work', }, + }, + }, + }) + end + } + + -- Faster sorting + use 'nvim-telescope/telescope-fzy-native.nvim' + + -- Jump around tmux sessions + use 'camgraff/telescope-tmux.nvim' + + -- Jump directories + use { + 'jvgrootveld/telescope-zoxide', + requires = {'nvim-lua/popup.nvim'}, + } + + -- Jump projects + use { + 'nvim-telescope/telescope-project.nvim', + requires = {'nvim-telescope/telescope.nvim'}, + config = function() + require('telescope').load_extension('project') + end + } + + -- Clipboard history + -- use { + -- "AckslD/nvim-neoclip.lua", + -- branch = 'main', + -- requires = { + -- {'tami5/sqlite.lua', module = 'sqlite'}, + -- {'nvim-telescope/telescope.nvim'}, + -- }, + -- config = function() + -- require('neoclip').setup({ + -- enable_persistant_history = true, + -- default_register = {'+', '"'}, + -- keys = { + -- i = { paste = '' }, + -- }, + -- }) + -- require('telescope').load_extension('neoclip') + -- end + -- } + + -- Project bookmarks + use { + 'ThePrimeagen/harpoon', + requires = { + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope.nvim' } } -end --- Auto-complete --- ==================== + -- TLDR Lookup + use { + 'mrjones2014/tldr.nvim', + requires = {'nvim-telescope/telescope.nvim'} + } --- Auto-complete mapping -local t = function(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) -end + -- ======================================================================= -local check_back_space = function() - local col = vim.fn.col('.') - 1 - if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then - return true - else - return false + -- Install on initial bootstrap + if packer_bootstrap then + require('packer').sync() end -end --- Use (s-)tab to: ---- move to prev/next item in completion menuone ---- jump to prev/next snippet's placeholder -_G.tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t "" - elseif vim.fn.call("vsnip#available", {1}) == 1 then - return t "(vsnip-expand-or-jump)" - elseif check_back_space() then - return t "" - else - return vim.fn['compe#complete']() - end -end -_G.s_tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t "" - elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then - return t "(vsnip-jump-prev)" - else - return t "" - end -end - --- Auto-complete keybinds -vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) +end) +-- =========================================================================== -- Settings --- ======== +-- =========================================================================== --- Basic Settings -vim.o.termguicolors = true -- Set to truecolor -vim.cmd[[colorscheme gruvbox]] -- Installed with a plugin -vim.o.hidden = true -- Don't unload buffers when leaving them -vim.wo.number = true -- Show line numbers -vim.wo.relativenumber = true -- Relative numbers instead of absolute -vim.o.list = true -- Reveal whitespace with dashes -vim.o.expandtab = true -- Tabs into spaces -vim.o.shiftwidth = 4 -- Amount to shift with > key -vim.o.softtabstop = 4 -- Amount to shift with key -vim.o.ignorecase = true -- Ignore case when searching -vim.o.smartcase = true -- Check case when using capitals in search -vim.o.infercase = true -- Don't match cases when completing suggestions -vim.o.incsearch = true -- Search while typing -vim.o.visualbell = true -- No sounds -vim.o.scrolljump = 1 -- Number of lines to scroll -vim.o.scrolloff = 3 -- Margin of lines to see while scrolling -vim.o.splitright = true -- Vertical splits on the right side -vim.o.splitbelow = true -- Horizontal splits on the bottom side -vim.o.pastetoggle = "" -- Use F3 to enter raw paste mode -vim.o.clipboard = "unnamedplus" -- Uses system clipboard for yanking -vim.o.updatetime = 300 -- Faster diagnostics -vim.o.mouse = "nv" -- Mouse interaction / scrolling +vim.o.termguicolors = true --- Set to truecolor +vim.o.hidden = true --- Don't unload buffers when leaving them +vim.wo.number = true --- Show line numbers +vim.wo.relativenumber = true --- Relative numbers instead of absolute +vim.o.list = true --- Reveal whitespace with dashes +vim.o.expandtab = true --- Tabs into spaces +vim.o.shiftwidth = 4 --- Amount to shift with > key +vim.o.softtabstop = 4 --- Amount to shift with key +vim.o.ignorecase = true --- Ignore case when searching +vim.o.smartcase = true --- Check case when using capitals in search +vim.o.infercase = true --- Don't match cases when completing suggestions +vim.o.incsearch = true --- Search while typing +vim.o.visualbell = true --- No sounds +vim.o.scrolljump = 1 --- Number of lines to scroll +vim.o.scrolloff = 3 --- Margin of lines to see while scrolling +vim.o.splitright = true --- Vertical splits on the right side +vim.o.splitbelow = true --- Horizontal splits on the bottom side +vim.o.pastetoggle = "" --- Use F3 to enter raw paste mode +vim.o.clipboard = "unnamedplus" --- Uses system clipboard for yanking +vim.o.updatetime = 300 --- Faster diagnostics +vim.o.mouse = "nv" --- Mouse interaction / scrolling -- Neovim features -vim.o.inccommand = "split" -- Live preview search and replace -vim.o.completeopt = "menuone,noselect" -- Required for nvim-compe completion +vim.o.inccommand = "split" --- Live preview search and replace +vim.o.completeopt = "menu,menuone,noselect" --- Required for nvim-cmp completion +-- Required until 0.6.0: do not source the default filetype.vim +vim.g.did_load_filetypes = 1 -- Remember last position when reopening file vim.api.nvim_exec([[ - if has("autocmd") - au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif - endif + au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif ]], false) -- Better backup, swap and undo storage -vim.o.backup = true -- Easier to recover and more secure -vim.bo.swapfile = false -- Instead of swaps, create backups -vim.bo.undofile = true -- Keeps undos after quit +vim.o.backup = true --- Easier to recover and more secure +vim.bo.swapfile = false --- Instead of swaps, create backups +vim.bo.undofile = true --- Keeps undos after quit -- Create backup directories if they don't exist +-- Should be fixed in 0.6 by https://github.com/neovim/neovim/pull/15433 +vim.o.backupdir = vim.fn.stdpath('cache') .. '/backup' vim.api.nvim_exec([[ - set backupdir=~/.local/share/nvim/backup - set undodir=~/.local/share/nvim/undo if !isdirectory(&backupdir) call mkdir(&backupdir, "p") endif - if !isdirectory(&undodir) - call mkdir(&undodir, "p") - endif -]], false) - --- Keep selection when tabbing -vim.api.nvim_set_keymap("v", "<", "", ">gv", {noremap=true}) - --- Force filetype patterns that Vim doesn't know about -vim.api.nvim_exec([[ - au BufRead,BufNewFile *.Brewfile setfiletype brewfile - au BufRead,BufNewFile tmux.conf* setfiletype tmux - au BufRead,BufNewFile *ignore.*link setfiletype gitignore - au BufRead,BufNewFile gitconfig.*link setfiletype gitconfig - au BufRead,BufNewFile *.toml.*link setfiletype toml - au BufRead,BufNewFile *.muttrc setfiletype muttrc - au BufRead,BufNewFile .env* set ft=text | set syntax=sh ]], false) -- LaTeX options @@ -177,14 +458,6 @@ vim.api.nvim_exec([[ au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 } ]], false) --- Rust stuff --- vim.api.nvim_exec([[ --- au BufWritePost *.rs silent! execute "%! rustfmt" --- ]], false) - --- Auto-pairs -vim.g.AutoPairsFlyMode = 0 - -- Netrw vim.g.netrw_liststyle = 3 -- Change style to 'tree' view vim.g.netrw_banner = 0 -- Remove useless banner @@ -192,7 +465,7 @@ vim.g.netrw_winsize = 15 -- Explore window takes % of page vim.g.netrw_browse_split = 4 -- Open in previous window vim.g.netrw_altv = 1 -- Always split left --- Polyglot +-- Formatting vim.g.terraform_fmt_on_save = 1 -- Formats with terraform plugin vim.g.rustfmt_autosave = 1 -- Formats with rust plugin @@ -224,62 +497,184 @@ vim.api.nvim_exec([[ command! AddTag call fzf#run({'source': 'rg "#[A-Za-z/]+[ |\$]" -o --no-filename --no-line-number | sort | uniq', 'sink': function('PInsert')}) ]], false) --- Status bar -require('lualine').setup({ - options = { theme = 'gruvbox' } -}) +-- =========================================================================== +-- Custom Functions +-- =========================================================================== + +grep_notes = function() + local opts = { + prompt_title = "Search Notes", + cwd = '$NOTES_PATH', + } + require('telescope.builtin').live_grep(opts) +end + +find_notes = function() + local opts = { + prompt_title = "Find Notes", + cwd = '$NOTES_PATH', + } + require('telescope.builtin').find_files(opts) +end + +find_downloads = function() + local opts = { + prompt_title = "Find Downloads", + cwd = '~/Downloads', + } + require('telescope.builtin').file_browser(opts) +end + +choose_project = function() + local opts = require("telescope.themes").get_ivy { + layout_config = { + bottom_pane = { + height = 10, + }, + }, + } + require('telescope').extensions.project.project(opts) +end + +clipboard_history = function() + local opts = require("telescope.themes").get_cursor { + layout_config = { + cursor = { + width = 150, + }, + }, + } + require('telescope').extensions.neoclip.neoclip(opts) +end + +command_history = function() + local opts = require("telescope.themes").get_ivy { + layout_config = { + bottom_pane = { + height = 15, + } + } + } + require('telescope.builtin').command_history(opts) +end + +-- =========================================================================== +-- Key Mapping +-- =========================================================================== + +-- Function to cut down config boilerplate +local key = function(mode, key_sequence, action, params) + params = params or {} + params["noremap"] = true + vim.api.nvim_set_keymap(mode, key_sequence, action, params) +end -- Remap space as leader key -vim.api.nvim_set_keymap("", "", "", {noremap=true, silent=true}) +key("", "", "", {silent=true}) vim.g.mapleader = " " vim.g.maplocalleader = " " --- Unset search pattern register -vim.api.nvim_set_keymap("n", "", ":noh", {noremap=true, silent=true}) +-- Keep selection when changing indentation +key("v", "<", "", ">gv") + +-- Clear search register +key("n", "", ":noh", {silent=true}) -- Shuffle lines around -vim.api.nvim_set_keymap("n", "", ":m .+1==", {noremap=true}) -vim.api.nvim_set_keymap("n", "", ":m .-2==", {noremap=true}) -vim.api.nvim_set_keymap("i", "", ":m .+1==gi", {noremap=true}) -vim.api.nvim_set_keymap("i", "", ":m .-2==gi", {noremap=true}) -vim.api.nvim_set_keymap("v", "", ":m '>+1gv=gv", {noremap=true}) -vim.api.nvim_set_keymap("v", "", ":m '<-2gv=gv", {noremap=true}) +key("n", "", ":m .+1==") +key("n", "", ":m .-2==") +key("i", "", ":m .+1==gi") +key("i", "", ":m .-2==gi") +key("v", "", ":m '>+1gv=gv") +key("v", "", ":m '<-2gv=gv") --- Fzf (fuzzy finder) -vim.api.nvim_set_keymap("n", "/", ":Rg", {noremap=true}) -vim.api.nvim_set_keymap("n", "ff", ":Files", {noremap=true}) -vim.api.nvim_set_keymap("n", "fr", ":History", {noremap=true}) -vim.api.nvim_set_keymap("n", "b", ":Buffers", {noremap=true}) -vim.api.nvim_set_keymap("n", "s", ":BLines", {noremap=true}) +-- Telescope (fuzzy finder) +key("n", "k", ":Telescope keymaps") +key("n", "/", ":Telescope live_grep") +key("n", "ff", ":Telescope find_files") +key("n", "fp", ":Telescope git_files") +key("n", "fN", "lua find_notes()") +key("n", "N", "lua grep_notes()") +key("n", "fD", "lua find_downloads()") +key("n", "fa", ":Telescope file_browser") +key("n", "fw", ":Telescope grep_string") +key("n", "wt", ":Telescope tmux sessions") +key("n", "ww", ":Telescope tmux windows") +key("n", "w/", ":Telescope tmux pane_contents") +key("n", "fz", ":Telescope zoxide list") +key("n", "b", ":Telescope buffers") +key("n", "hh", ":Telescope help_tags") +key("n", "fr", ":Telescope oldfiles") +key("n", "cc", ":Telescope commands") +key("n", "cr", "lua command_history()") +key("n", "y", "lua clipboard_history()") +key("i", "", "lua clipboard_history()") +key("n", "s", ":Telescope current_buffer_fuzzy_find") +key("n", "gc", ":Telescope git_commits") +key("n", "gf", ":Telescope git_bcommits") +key("n", "gb", ":Telescope git_branches") +key("n", "gs", ":Telescope git_status") +key("n", "", "lua choose_project()") + +-- Harpoon +key("n", "m", "lua require('harpoon.mark').add_file()") +key("n", "`", "lua require('harpoon.ui').toggle_quick_menu()") +key("n", "1", "lua require('harpoon.ui').nav_file(1)") +key("n", "2", "lua require('harpoon.ui').nav_file(2)") +key("n", "3", "lua require('harpoon.ui').nav_file(3)") + +-- LSP +key("n", "gd", "lua vim.lsp.buf.definition()", {silent=true}) +key("n", "gi", "lua vim.lsp.buf.implementation()", {silent=true}) +key("n", "gh", "lua vim.lsp.buf.hover()", {silent=true}) +key("n", "]e", "lua vim.lsp.diagnostic.goto_next()", {silent=true}) +key("n", "[e", "lua vim.lsp.diagnostic.goto_prev()", {silent=true}) +key("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", {silent=true}) -- File commands -vim.api.nvim_set_keymap("n", "q", ":quit", {noremap=true}) -vim.api.nvim_set_keymap("n", "Q", ":quitall", {noremap=true}) -vim.api.nvim_set_keymap("n", "fs", ":write", {noremap=true}) -vim.api.nvim_set_keymap("n", "fe", ":!chmod 755 %", {noremap=true}) -vim.api.nvim_set_keymap("n", "fn", ":!chmod 644 %", {noremap=true}) -vim.api.nvim_set_keymap("n", "fd", ":lcd %:p:h", {silent=true, noremap=true}) -vim.api.nvim_set_keymap("n", "fu", ":lcd ..", {silent=true, noremap=true}) -vim.api.nvim_set_keymap("n", "", ":b#", {silent=true, noremap=true}) -vim.api.nvim_set_keymap("n", "gr", ":!gh repo view -w", {silent=true, noremap=true}) -vim.api.nvim_set_keymap("n", "tt", [[exe 'edit ~/notes/journal/'.strftime("%Y-%m-%d_%a").'.md']], {noremap=true}) +key("n", "q", ":quit") +key("n", "Q", ":quitall") +key("n", "fs", ":write") +key("n", "fd", ":lcd %:p:h", {silent=true}) +key("n", "fu", ":lcd ..", {silent=true}) +key("n", "", ":b#", {silent=true}) +key("n", "gr", ":!gh repo view -w", {silent=true}) +key("n", "tt", + [[exe 'edit $NOTES_PATH/journal/'.strftime("%Y-%m-%d_%a").'.md']] +) +key("n", "jj", ":!journal:e") -- Window commands -vim.api.nvim_set_keymap("n", "wv", ":vsplit", {noremap=true}) -vim.api.nvim_set_keymap("n", "wh", ":split", {noremap=true}) -vim.api.nvim_set_keymap("n", "wm", ":only", {noremap=true}) +key("n", "wv", ":vsplit") +key("n", "wh", ":split") +key("n", "wm", ":only") -- Tabularize -vim.api.nvim_set_keymap("", "ta", ":Tabularize /", {noremap=true}) -vim.api.nvim_set_keymap("", "t#", ":Tabularize /#", {noremap=true}) -vim.api.nvim_set_keymap("", "t\"", ":Tabularize /\"", {noremap=true}) +key("", "ta", ":Tabularize /") +key("", "t#", ":Tabularize /#") +key("", "tl", ":Tabularize /---") --- Vimrc -vim.api.nvim_set_keymap("n", "fv", ":edit $MYVIMRC", {noremap=true}) -vim.api.nvim_set_keymap("n", "rr", ":luafile $MYVIMRC", {noremap=true}) +-- Vimrc editing +key("n", "fv", ":edit $MYVIMRC") +key("n", "rr", ":luafile $MYVIMRC") +key("n", "rp", ":luafile $MYVIMRC:PackerInstall:") +key("n", "rc", ":luafile $MYVIMRC:PackerCompile") + +-- Keep cursor in place +key("n", 'n', "nzz") +key("n", 'N', "Nzz") +key("n", 'J', "mzJ`z") --- Mark and jump back to it + +-- Add undo breakpoints +key("i", ',', ",u") +key("i", '.', ".u") +key("i", '!', "!u") +key("i", '?', "?u") -- Other -vim.api.nvim_set_keymap("n", "", ":HopWord", {noremap=true}) -vim.api.nvim_set_keymap("t", "", "", {noremap=true}) -- Exit terminal mode -vim.api.nvim_set_keymap("n", "", ":noh", {noremap=true, silent=true}) -vim.api.nvim_set_keymap('n', 'Y', 'y$', { noremap = true}) +key("t", "", "") --- Exit terminal mode +key("n", "", ":noh", {silent=true}) --- Clear search in VimWiki +key("n", "Y", "y$") --- Copy to end of line +key("v", "", "y:%s/+//gc") --- Substitute selected +key("v", "D", "y'>gp") --- Duplicate selected diff --git a/nixos/justfile b/nixos/justfile index dda353e..90e040b 100644 --- a/nixos/justfile +++ b/nixos/justfile @@ -2,6 +2,10 @@ default: @just --list --list-heading $'Update NixOS config:\n' +channel: + nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixos-unstable + nix-channel --update + # Update the system system: nixos-rebuild switch -I nixos-config=./configuration.nix From fc66f23a49d2e4c5997320e46feb68ce8cf4ac01 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 13 Jan 2022 08:51:13 -0500 Subject: [PATCH 05/35] start with nvme drive --- nixos/configuration.nix | 11 +++++++++++ nixos/home.nix | 9 ++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 9b45b21..cc0c563 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -10,6 +10,8 @@ /etc/nixos/hardware-configuration.nix ]; + nixpkgs.config.allowUnfree = true; + # Use the systemd-boot EFI boot loader. boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; @@ -63,6 +65,15 @@ sound.enable = true; hardware.pulseaudio.enable = true; + #services.xrandr.xrandrHeads = [ + # "HDMI-0" + #]; + services.xserver.displayManager.setupCommands = '' + LEFT='HDMI-0' + RIGHT='DisplayPort-0' + ${pkgs.xorg.xrandr}/bin/xrandr --output $LEFT --output $RIGHT --right-of $LEFT --rotate left + ''; + # Install fonts fonts.fonts = with pkgs; [ fira-code diff --git a/nixos/home.nix b/nixos/home.nix index 47e1814..12cf384 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -8,12 +8,14 @@ let in { + nixpkgs.config.allowUnfree = true; + home.packages = with pkgs; [ - # firefox + firefox unzip neovim gcc # for tree-sitter - # alacritty + alacritty # unstable.neovim tmux rsync @@ -24,7 +26,8 @@ in sd jq tealdeer - /* unstable._1password-gui */ + _1password-gui + discord ]; #programs.alacritty = { From 31fc8e204ff13cd91aba26102ac181ed9e5877ec Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 13 Jan 2022 09:39:48 -0500 Subject: [PATCH 06/35] use unstable nix for everything --- nixos/channels.sh | 4 ++++ nixos/home.nix | 32 ++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 14 deletions(-) create mode 100755 nixos/channels.sh diff --git a/nixos/channels.sh b/nixos/channels.sh new file mode 100755 index 0000000..a53945a --- /dev/null +++ b/nixos/channels.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +doas nix-channel --add https://nixos.org/channels/nixos-unstable +doas nix-channel --add https://nixos.org/channels/nixpkgs-unstable diff --git a/nixos/home.nix b/nixos/home.nix index 12cf384..47db1bd 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -2,8 +2,7 @@ let - # Import unstable channel (for Neovim 0.5) - unstable = import { config = { allowUnfree = true; }; }; + # Nothing in @@ -16,7 +15,6 @@ in neovim gcc # for tree-sitter alacritty - # unstable.neovim tmux rsync ripgrep @@ -28,6 +26,7 @@ in tealdeer _1password-gui discord + gh ]; #programs.alacritty = { @@ -200,17 +199,6 @@ in "nvim/init.lua".source = ./init.lua; }; - # nixpkgs.overlays = [( - # self: super: { - # neovim = unstable.neovim; - # }) - # ]; - nixpkgs.overlays = [ - (import (builtins.fetchTarball { - url = https://github.com/nix-community/neovim-nightly-overlay/archive/master.tar.gz; - })) - ]; - #programs.neovim = { # enable = true; # # package = pkgs.neovim-nightly; @@ -245,6 +233,22 @@ in core = { editor = "nvim"; }; + pager = { + branch = "false"; + }; + #credential = { + # helper = "store"; + #}; + /* credential = { */ + /* "https://github.com/helper" = "!gh auth git-credential"; */ + /* }; */ }; }; + + programs.gh = { + #package = nixos-unstable.gh; + enable = true; + enableGitCredentialHelper = true; + settings.git_protocol = "https"; + }; } From 98e5bc7cbf4565cbe0113b2a18eced5ba9ebdfd9 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 13 Jan 2022 09:45:27 -0500 Subject: [PATCH 07/35] switch to pipewire --- nixos/configuration.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index cc0c563..6d7e471 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -63,7 +63,16 @@ # Enable sound. sound.enable = true; - hardware.pulseaudio.enable = true; + hardware.pulseaudio.enable = false; + services.pipewire = { + enable = true; + + # Sound card drivers + alsa.enable = true; + + # PulseAudio emulation + pulse.enable = true; + }; #services.xrandr.xrandrHeads = [ # "HDMI-0" From 244b36aee31693c97fc8511a7d66ae564627e861 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 13 Jan 2022 18:16:10 -0500 Subject: [PATCH 08/35] remove unnecessary comments --- nixos/home.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/nixos/home.nix b/nixos/home.nix index 47db1bd..61c9c7b 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -236,17 +236,10 @@ in pager = { branch = "false"; }; - #credential = { - # helper = "store"; - #}; - /* credential = { */ - /* "https://github.com/helper" = "!gh auth git-credential"; */ - /* }; */ }; }; programs.gh = { - #package = nixos-unstable.gh; enable = true; enableGitCredentialHelper = true; settings.git_protocol = "https"; From e2288101ad142abbe99d0c78d573dd628d2ce1e8 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 13 Jan 2022 18:23:49 -0500 Subject: [PATCH 09/35] use original nvim --- nixos/home.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/home.nix b/nixos/home.nix index 61c9c7b..b579421 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -196,7 +196,7 @@ in xdg.configFile = { "starship.toml".source = ../starship/starship.toml.configlink; #"alacritty/alacritty.yml".source = ../alacritty.configlink/alacritty.yml; - "nvim/init.lua".source = ./init.lua; + "nvim/init.lua".source = ../nvim.configlink/init.lua; }; #programs.neovim = { From cc06fadcd98e0f93c52b1aac9807575f10c2e7b0 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 13 Jan 2022 18:44:56 -0500 Subject: [PATCH 10/35] alacritty colors --- nixos/home.nix | 93 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 62 insertions(+), 31 deletions(-) diff --git a/nixos/home.nix b/nixos/home.nix index b579421..64d55a9 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -29,37 +29,68 @@ in gh ]; - #programs.alacritty = { - # enable = true; - # settings = { - # window = { - # dimensions = { - # columns = 85; - # lines = 30; - # }; - # padding = { - # x = 20; - # y = 20; - # }; - # }; - # scrolling.history = 10000; - # font = { - # size = 15.0; - # }; - # key_bindings = [ - # { - # key = "F"; - # mods = "Super"; - # action = "ToggleFullscreen"; - # } - # { - # key = "L"; - # mods = "Super"; - # chars = "\x1F"; - # } - # ]; - # }; - #}; + programs.alacritty = { + enable = true; + settings = { + window = { + dimensions = { + columns = 85; + lines = 30; + }; + padding = { + x = 20; + y = 20; + }; + }; + scrolling.history = 10000; + font = { + size = 13.0; + }; + key_bindings = [ + { + key = "F"; + mods = "Super"; + action = "ToggleFullscreen"; + } + { + key = "L"; + mods = "Super"; + chars = "\x1F"; + } + ]; + colors = { + primary = { + background = "0x1d2021"; + foreground = "0xd5c4a1"; + }; + cursor = { + text = "0x1d2021"; + cursor = "0xd5c4a1"; + }; + normal = { + black = "0x1d2021"; + red = "0xfb4934"; + green = "0xb8bb26"; + yellow = "0xfabd2f"; + blue = "0x83a598"; + magenta = "0xd3869b"; + cyan = "0x8ec07c"; + white = "0xd5c4a1"; + }; + bright = { + black = "0x665c54"; + red = "0xfe8019"; + green = "0x3c3836"; + yellow = "0x504945"; + blue = "0xbdae93"; + magenta = "0xebdbb2"; + cyan = "0xd65d0e"; + white = "0xfbf1c7"; + }; + }; + draw_bold_text_with_bright_colors = false; + }; + }; programs.fish = { enable = true; From 0b7221bd6a7789e9cca85e81b0d158c35771d77f Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 13 Jan 2022 18:45:12 -0500 Subject: [PATCH 11/35] temp: disable neoclip --- nvim.configlink/init.lua | 62 ++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/nvim.configlink/init.lua b/nvim.configlink/init.lua index 6c39329..e455095 100644 --- a/nvim.configlink/init.lua +++ b/nvim.configlink/init.lua @@ -338,7 +338,7 @@ require("packer").startup(function(use) fzy_native = {}, tmux = {}, zoxide = {}, - neoclip = {}, + --neoclip = {}, project = { base_dirs = { "~/dev/work" }, }, @@ -369,26 +369,26 @@ require("packer").startup(function(use) }) -- Clipboard history - use({ - "AckslD/nvim-neoclip.lua", - branch = "main", - requires = { - { "tami5/sqlite.lua", module = "sqlite" }, - { "nvim-telescope/telescope.nvim" }, - }, - config = function() - require("neoclip").setup({ - enable_persistant_history = true, - default_register = { "+", '"' }, - keys = { - telescope = { - i = { paste = "" }, - }, - }, - }) - require("telescope").load_extension("neoclip") - end, - }) + -- use({ + -- "AckslD/nvim-neoclip.lua", + -- branch = "main", + -- requires = { + -- { "tami5/sqlite.lua", module = "sqlite" }, + -- { "nvim-telescope/telescope.nvim" }, + -- }, + -- config = function() + -- require("neoclip").setup({ + -- enable_persistant_history = true, + -- default_register = { "+", '"' }, + -- keys = { + -- telescope = { + -- i = { paste = "" }, + -- }, + -- }, + -- }) + -- require("telescope").load_extension("neoclip") + -- end, + -- }) -- Project bookmarks use({ @@ -564,16 +564,16 @@ choose_project = function() require("telescope").extensions.project.project(opts) end -clipboard_history = function() - local opts = require("telescope.themes").get_cursor({ - layout_config = { - cursor = { - width = 150, - }, - }, - }) - require("telescope").extensions.neoclip.neoclip(opts) -end +-- clipboard_history = function() +-- local opts = require("telescope.themes").get_cursor({ +-- layout_config = { +-- cursor = { +-- width = 150, +-- }, +-- }, +-- }) +-- require("telescope").extensions.neoclip.neoclip(opts) +-- end command_history = function() local opts = require("telescope.themes").get_ivy({ From 322eb1310adb85c9d3e2d72f18a1b1bb8ea7f5b0 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 13 Jan 2022 18:45:21 -0500 Subject: [PATCH 12/35] swap caps lock --- nixos/configuration.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 6d7e471..9f31b53 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -56,7 +56,7 @@ # Configure keymap in X11 services.xserver.layout = "us"; - services.xserver.xkbOptions = "eurosign:e"; + services.xserver.xkbOptions = "eurosign:e,caps:swapescape"; # Enable CUPS to print documents. # services.printing.enable = true; From ccf17ec0010a608bda306a33d1378d462ad924e7 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 13 Jan 2022 18:54:26 -0500 Subject: [PATCH 13/35] include fish functions --- nixos/home.nix | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/nixos/home.nix b/nixos/home.nix index 64d55a9..a47c3cf 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -226,36 +226,10 @@ in # Other configs xdg.configFile = { "starship.toml".source = ../starship/starship.toml.configlink; - #"alacritty/alacritty.yml".source = ../alacritty.configlink/alacritty.yml; "nvim/init.lua".source = ../nvim.configlink/init.lua; + "fish/functions".source = ../fish.configlink/functions; }; - #programs.neovim = { - # enable = true; - # # package = pkgs.neovim-nightly; - # vimAlias = true; - # extraPackages = with pkgs; [ - # nodePackages.pyright - # rust-analyzer - # terraform-ls - # ]; - # #extraConfig = builtins.concatStringsSep "\n" [ - # # '' - # # luafile ${builtins.toString ./init.lua} - # # '' - # #]; - # #extraConfig = '' - # # lua << EOF - # # ${builtins.readFile ./init.lua} - # # EOF - # #''; - #}; - - # # Neovim config - # home.file = { - # ".config/nvim/init.lua".source = ../nvim.configlink/init.lua; - # }; - programs.git = { enable = true; userName = "Noah Masur"; From b560659dfebdd20368350b52aafe725f5c5a2fa4 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 13 Jan 2022 19:07:52 -0500 Subject: [PATCH 14/35] fix: fish complete keybind --- nixos/home.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/home.nix b/nixos/home.nix index a47c3cf..c23cb8b 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -55,7 +55,7 @@ in { key = "L"; mods = "Super"; - chars = "\x1F"; + chars = "\\x1F"; } ]; colors = { From 7ad8892d81a9d2ef0cd7e8077761843fe1102abf Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Thu, 13 Jan 2022 19:08:25 -0500 Subject: [PATCH 15/35] try to make left monitor primary --- nixos/configuration.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 9f31b53..97442d3 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -80,7 +80,7 @@ services.xserver.displayManager.setupCommands = '' LEFT='HDMI-0' RIGHT='DisplayPort-0' - ${pkgs.xorg.xrandr}/bin/xrandr --output $LEFT --output $RIGHT --right-of $LEFT --rotate left + ${pkgs.xorg.xrandr}/bin/xrandr --output $LEFT --primary --output $RIGHT --right-of $LEFT --rotate left ''; # Install fonts From 82d5c72a7d52f1e2702db19b059bfda27c524c80 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 15 Jan 2022 10:14:12 -0500 Subject: [PATCH 16/35] mouse accel and channels in justfile --- nixos/channels.sh | 4 ---- nixos/configuration.nix | 15 +++++++++++++-- nixos/justfile | 9 +++++---- 3 files changed, 18 insertions(+), 10 deletions(-) delete mode 100755 nixos/channels.sh diff --git a/nixos/channels.sh b/nixos/channels.sh deleted file mode 100755 index a53945a..0000000 --- a/nixos/channels.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -doas nix-channel --add https://nixos.org/channels/nixos-unstable -doas nix-channel --add https://nixos.org/channels/nixpkgs-unstable diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 97442d3..fc6201e 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -52,6 +52,7 @@ # Disable mouse acceleration libinput.mouse.accelProfile = "flat"; + libinput.mouse.accelSpeed = "3.0"; }; # Configure keymap in X11 @@ -68,12 +69,20 @@ enable = true; # Sound card drivers - alsa.enable = true; + alsa = { + enable = true; + support32Bit = true; + }; # PulseAudio emulation pulse.enable = true; }; + /* systemd.services.pavucontrol = { */ + /* wantedBy = [ "multi-user.target" ]; */ + /* script = "${pkgs.pavucontrol}/bin/pavucontrol"; */ + /* }; */ + #services.xrandr.xrandrHeads = [ # "HDMI-0" #]; @@ -140,6 +149,8 @@ curl home-manager just + /* pavucontrol */ + libratbag ]; # Some programs need SUID wrappers, can be configured further or are @@ -167,6 +178,6 @@ # this value at the release version of the first install of this system. # Before changing this value read the documentation for this option # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). - system.stateVersion = "21.05"; # Did you read the comment? + system.stateVersion = "21.11"; # Did you read the comment? } diff --git a/nixos/justfile b/nixos/justfile index 90e040b..af83d3f 100644 --- a/nixos/justfile +++ b/nixos/justfile @@ -2,13 +2,14 @@ default: @just --list --list-heading $'Update NixOS config:\n' -channel: - nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixos-unstable - nix-channel --update +channels: + doas nix-channel --add https://nixos.org/channels/nixos-unstable + doas nix-channel --add https://nixos.org/channels/nixpkgs-unstable + doas nix-channel --update # Update the system system: - nixos-rebuild switch -I nixos-config=./configuration.nix + doas nixos-rebuild switch -I nixos-config=./configuration.nix # Update the user environment home: From 62f74cdf4adc299992f6f4cf8cc4c4c1ff98631b Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 15 Jan 2022 10:34:56 -0500 Subject: [PATCH 17/35] piper and xrandr fixes --- nixos/configuration.nix | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index fc6201e..a01f185 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -55,6 +55,9 @@ libinput.mouse.accelSpeed = "3.0"; }; + # Mouse config + services.ratbagd.enable = true; + # Configure keymap in X11 services.xserver.layout = "us"; services.xserver.xkbOptions = "eurosign:e,caps:swapescape"; @@ -83,14 +86,20 @@ /* script = "${pkgs.pavucontrol}/bin/pavucontrol"; */ /* }; */ - #services.xrandr.xrandrHeads = [ - # "HDMI-0" - #]; services.xserver.displayManager.setupCommands = '' - LEFT='HDMI-0' - RIGHT='DisplayPort-0' - ${pkgs.xorg.xrandr}/bin/xrandr --output $LEFT --primary --output $RIGHT --right-of $LEFT --rotate left - ''; + ${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 \ + --mode 1920x1200 \ + --pos 1920x0 \ + --rotate left \ + --output HDMI-0 \ + --primary \ + --mode 1920x1080 \ + --pos 0x559 \ + --rotate normal \ + --output DVI-0 --off \ + --output DVI-1 --off \ + ''; + # Install fonts fonts.fonts = with pkgs; [ @@ -149,8 +158,9 @@ curl home-manager just - /* pavucontrol */ libratbag + pavucontrol + piper ]; # Some programs need SUID wrappers, can be configured further or are From 4d5791c213e6ab74cce6fb610113219d7275cadc Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 17 Jan 2022 00:18:49 -0500 Subject: [PATCH 18/35] sound redshift awesomewm steam --- nixos/configuration.nix | 77 ++++-- nixos/home.nix | 37 ++- nixos/rc.lua | 564 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 649 insertions(+), 29 deletions(-) create mode 100644 nixos/rc.lua diff --git a/nixos/configuration.nix b/nixos/configuration.nix index a01f185..7a966fa 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -44,42 +44,51 @@ # services.xserver.enable = true; services.xserver = { enable = true; - desktopManager = { - xterm.enable = false; - xfce.enable = true; + + /* desktopManager = { */ + /* xterm.enable = false; */ + /* xfce.enable = true; */ + /* }; */ + /* displayManager.defaultSession = "xfce"; */ + windowManager = { + awesome = { + enable = true; + }; }; - displayManager.defaultSession = "xfce"; + + # Enable touchpad support (enabled default in most desktopManager). + libinput.enable = true; # Disable mouse acceleration libinput.mouse.accelProfile = "flat"; - libinput.mouse.accelSpeed = "3.0"; + libinput.mouse.accelSpeed = "2.0"; + + # Configure keymap in X11 + layout = "us"; + xkbOptions = "eurosign:e,caps:swapescape"; }; # Mouse config services.ratbagd.enable = true; - # Configure keymap in X11 - services.xserver.layout = "us"; - services.xserver.xkbOptions = "eurosign:e,caps:swapescape"; - # Enable CUPS to print documents. # services.printing.enable = true; # Enable sound. sound.enable = true; - hardware.pulseaudio.enable = false; - services.pipewire = { - enable = true; + hardware.pulseaudio.enable = true; + /* services.pipewire = { */ + /* enable = true; */ - # Sound card drivers - alsa = { - enable = true; - support32Bit = true; - }; + /* # Sound card drivers */ + /* alsa = { */ + /* enable = true; */ + /* support32Bit = true; */ + /* }; */ - # PulseAudio emulation - pulse.enable = true; - }; + /* # PulseAudio emulation */ + /* pulse.enable = true; */ + /* }; */ /* systemd.services.pavucontrol = { */ /* wantedBy = [ "multi-user.target" ]; */ @@ -107,8 +116,12 @@ fira-code-symbols ]; - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; + # Gaming + hardware.opengl = { + enable = true; + driSupport32Bit = true; + }; + hardware.steam-hardware.enable = true; # Replace sudo with doas security = { @@ -158,11 +171,29 @@ curl home-manager just + + # Mouse config libratbag - pavucontrol piper + + # Audio + alsa-utils + + # Pulse Audio control utility + #pavucontrol + + steam ]; + location = { + latitude = 40.0; + longitude = 74.0; + }; + + services.redshift = { + enable = true; + }; + # Some programs need SUID wrappers, can be configured further or are # started in user sessions. # programs.mtr.enable = true; diff --git a/nixos/home.nix b/nixos/home.nix index c23cb8b..6d21a33 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -27,6 +27,9 @@ in _1password-gui discord gh + /* neomutt */ + mpv # Video viewer + sxiv # Image viewer ]; programs.alacritty = { @@ -47,14 +50,14 @@ in size = 13.0; }; key_bindings = [ - { - key = "F"; - mods = "Super"; - action = "ToggleFullscreen"; - } + /* { */ + /* key = "F"; */ + /* mods = "Super"; */ + /* action = "ToggleFullscreen"; */ + /* } */ { key = "L"; - mods = "Super"; + mods = "Control|Shift"; chars = "\\x1F"; } ]; @@ -228,6 +231,7 @@ in "starship.toml".source = ../starship/starship.toml.configlink; "nvim/init.lua".source = ../nvim.configlink/init.lua; "fish/functions".source = ../fish.configlink/functions; + "awesome/rc.lua".source = ./rc.lua; }; programs.git = { @@ -249,4 +253,25 @@ in enableGitCredentialHelper = true; settings.git_protocol = "https"; }; + + # Email + /* programs.himalaya = { */ + /* enable = true; */ + /* settings = { */ + /* name = "Noah Masur"; */ + /* downloads-dir = "~/Downloads"; */ + /* home = { */ + /* default = true; */ + /* email = "censored"; */ + /* imap-host = "censored"; */ + /* imap-port = 993; */ + /* imap-login = "censored"; */ + /* imap-passwd-cmd = "cat ~/.config/himalaya/passwd"; */ + /* smtp-host = "censored"; */ + /* smtp-port = 587; */ + /* smtp-login = "censored"; */ + /* smtp-passwd-cmd = "cat ~/.config/himalaya/passwd"; */ + /* }; */ + /* }; */ + /* }; */ } diff --git a/nixos/rc.lua b/nixos/rc.lua new file mode 100644 index 0000000..aef164c --- /dev/null +++ b/nixos/rc.lua @@ -0,0 +1,564 @@ +-- If LuaRocks is installed, make sure that packages installed through it are +-- found (e.g. lgi). If LuaRocks is not installed, do nothing. +pcall(require, "luarocks.loader") + +-- Standard awesome library +local gears = require("gears") +local awful = require("awful") +require("awful.autofocus") +-- Widget and layout library +local wibox = require("wibox") +-- Theme handling library +local beautiful = require("beautiful") +-- Notification library +local naughty = require("naughty") +local menubar = require("menubar") +local hotkeys_popup = require("awful.hotkeys_popup") +-- Enable hotkeys help widget for VIM and other apps +-- when client with a matching name is opened: +require("awful.hotkeys_popup.keys") + +-- {{{ Error handling +-- Check if awesome encountered an error during startup and fell back to +-- another config (This code will only ever execute for the fallback config) +if awesome.startup_errors then + naughty.notify({ preset = naughty.config.presets.critical, + title = "Oops, there were errors during startup!", + text = awesome.startup_errors }) +end + +-- Handle runtime errors after startup +do + local in_error = false + awesome.connect_signal("debug::error", function (err) + -- Make sure we don't go into an endless error loop + if in_error then return end + in_error = true + + naughty.notify({ preset = naughty.config.presets.critical, + title = "Oops, an error happened!", + text = tostring(err) }) + in_error = false + end) +end +-- }}} + +-- {{{ Variable definitions +-- Themes define colours, icons, font and wallpapers. +beautiful.init(gears.filesystem.get_themes_dir() .. "default/theme.lua") + +-- This is used later as the default terminal and editor to run. +terminal = "alacritty" +editor = os.getenv("EDITOR") or "nano" +editor_cmd = terminal .. " -e " .. editor + +-- Default modkey. +-- Usually, Mod4 is the key with a logo between Control and Alt. +-- If you do not like this or do not have such a key, +-- I suggest you to remap Mod4 to another key using xmodmap or other tools. +-- However, you can use another modifier like Mod1, but it may interact with others. +modkey = "Mod4" + +-- Table of layouts to cover with awful.layout.inc, order matters. +awful.layout.layouts = { + awful.layout.suit.floating, + awful.layout.suit.tile, + awful.layout.suit.tile.left, + awful.layout.suit.tile.bottom, + awful.layout.suit.tile.top, + awful.layout.suit.fair, + awful.layout.suit.fair.horizontal, + awful.layout.suit.spiral, + awful.layout.suit.spiral.dwindle, + awful.layout.suit.max, + awful.layout.suit.max.fullscreen, + awful.layout.suit.magnifier, + awful.layout.suit.corner.nw, + -- awful.layout.suit.corner.ne, + -- awful.layout.suit.corner.sw, + -- awful.layout.suit.corner.se, +} +-- }}} + +-- {{{ Menu +-- Create a launcher widget and a main menu +myawesomemenu = { + { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, + { "manual", terminal .. " -e man awesome" }, + { "edit config", editor_cmd .. " " .. awesome.conffile }, + { "restart", awesome.restart }, + { "quit", function() awesome.quit() end }, +} + +mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, + { "open terminal", terminal } + } + }) + +mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, + menu = mymainmenu }) + +-- Menubar configuration +menubar.utils.terminal = terminal -- Set the terminal for applications that require it +-- }}} + +-- Keyboard map indicator and switcher +mykeyboardlayout = awful.widget.keyboardlayout() + +-- {{{ Wibar +-- Create a textclock widget +mytextclock = wibox.widget.textclock() + +-- Create a wibox for each screen and add it +local taglist_buttons = gears.table.join( + awful.button({ }, 1, function(t) t:view_only() end), + awful.button({ modkey }, 1, function(t) + if client.focus then + client.focus:move_to_tag(t) + end + end), + awful.button({ }, 3, awful.tag.viewtoggle), + awful.button({ modkey }, 3, function(t) + if client.focus then + client.focus:toggle_tag(t) + end + end), + awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), + awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end) + ) + +local tasklist_buttons = gears.table.join( + awful.button({ }, 1, function (c) + if c == client.focus then + c.minimized = true + else + c:emit_signal( + "request::activate", + "tasklist", + {raise = true} + ) + end + end), + awful.button({ }, 3, function() + awful.menu.client_list({ theme = { width = 250 } }) + end), + awful.button({ }, 4, function () + awful.client.focus.byidx(1) + end), + awful.button({ }, 5, function () + awful.client.focus.byidx(-1) + end)) + +local function set_wallpaper(s) + -- Wallpaper + if beautiful.wallpaper then + local wallpaper = beautiful.wallpaper + -- If wallpaper is a function, call it with the screen + if type(wallpaper) == "function" then + wallpaper = wallpaper(s) + end + gears.wallpaper.maximized(wallpaper, s, true) + end +end + +-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution) +screen.connect_signal("property::geometry", set_wallpaper) + +awful.screen.connect_for_each_screen(function(s) + -- Wallpaper + set_wallpaper(s) + + -- Each screen has its own tag table. + awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) + + -- Create a promptbox for each screen + s.mypromptbox = awful.widget.prompt() + -- Create an imagebox widget which will contain an icon indicating which layout we're using. + -- We need one layoutbox per screen. + s.mylayoutbox = awful.widget.layoutbox(s) + s.mylayoutbox:buttons(gears.table.join( + awful.button({ }, 1, function () awful.layout.inc( 1) end), + awful.button({ }, 3, function () awful.layout.inc(-1) end), + awful.button({ }, 4, function () awful.layout.inc( 1) end), + awful.button({ }, 5, function () awful.layout.inc(-1) end))) + -- Create a taglist widget + s.mytaglist = awful.widget.taglist { + screen = s, + filter = awful.widget.taglist.filter.all, + buttons = taglist_buttons + } + + -- Create a tasklist widget + s.mytasklist = awful.widget.tasklist { + screen = s, + filter = awful.widget.tasklist.filter.currenttags, + buttons = tasklist_buttons + } + + -- Create the wibox + s.mywibox = awful.wibar({ position = "top", screen = s }) + + -- Add widgets to the wibox + s.mywibox:setup { + layout = wibox.layout.align.horizontal, + { -- Left widgets + layout = wibox.layout.fixed.horizontal, + mylauncher, + s.mytaglist, + s.mypromptbox, + }, + s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + mykeyboardlayout, + wibox.widget.systray(), + mytextclock, + s.mylayoutbox, + }, + } +end) +-- }}} + +-- {{{ Mouse bindings +root.buttons(gears.table.join( + awful.button({ }, 3, function () mymainmenu:toggle() end), + awful.button({ }, 4, awful.tag.viewnext), + awful.button({ }, 5, awful.tag.viewprev) +)) +-- }}} + +-- {{{ Key bindings +globalkeys = gears.table.join( + awful.key({ modkey, }, "s", hotkeys_popup.show_help, + {description="show help", group="awesome"}), + awful.key({ modkey, }, "Left", awful.tag.viewprev, + {description = "view previous", group = "tag"}), + awful.key({ modkey, }, "Right", awful.tag.viewnext, + {description = "view next", group = "tag"}), + awful.key({ modkey, }, "Escape", awful.tag.history.restore, + {description = "go back", group = "tag"}), + + awful.key({ modkey, }, "j", + function () + awful.client.focus.byidx( 1) + end, + {description = "focus next by index", group = "client"} + ), + awful.key({ modkey, }, "k", + function () + awful.client.focus.byidx(-1) + end, + {description = "focus previous by index", group = "client"} + ), + awful.key({ modkey, }, "w", function () mymainmenu:show() end, + {description = "show main menu", group = "awesome"}), + + -- Layout manipulation + awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end, + {description = "swap with next client by index", group = "client"}), + awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end, + {description = "swap with previous client by index", group = "client"}), + awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end, + {description = "focus the next screen", group = "screen"}), + awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end, + {description = "focus the previous screen", group = "screen"}), + awful.key({ modkey, }, "u", awful.client.urgent.jumpto, + {description = "jump to urgent client", group = "client"}), + awful.key({ modkey, }, "Tab", + function () + awful.client.focus.history.previous() + if client.focus then + client.focus:raise() + end + end, + {description = "go back", group = "client"}), + + -- Standard program + awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end, + {description = "open a terminal", group = "launcher"}), + awful.key({ modkey, "Control" }, "r", awesome.restart, + {description = "reload awesome", group = "awesome"}), + awful.key({ modkey, "Shift" }, "q", awesome.quit, + {description = "quit awesome", group = "awesome"}), + + awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end, + {description = "increase master width factor", group = "layout"}), + awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end, + {description = "decrease master width factor", group = "layout"}), + awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end, + {description = "increase the number of master clients", group = "layout"}), + awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end, + {description = "decrease the number of master clients", group = "layout"}), + awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end, + {description = "increase the number of columns", group = "layout"}), + awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end, + {description = "decrease the number of columns", group = "layout"}), + awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end, + {description = "select next", group = "layout"}), + awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end, + {description = "select previous", group = "layout"}), + + awful.key({ modkey, "Control" }, "n", + function () + local c = awful.client.restore() + -- Focus restored client + if c then + c:emit_signal( + "request::activate", "key.unminimize", {raise = true} + ) + end + end, + {description = "restore minimized", group = "client"}), + + -- Prompt + awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end, + {description = "run prompt", group = "launcher"}), + + awful.key({ modkey }, "x", + function () + awful.prompt.run { + prompt = "Run Lua code: ", + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = awful.util.eval, + history_path = awful.util.get_cache_dir() .. "/history_eval" + } + end, + {description = "lua execute prompt", group = "awesome"}), + -- Menubar + awful.key({ modkey }, "p", function() menubar.show() end, + {description = "show the menubar", group = "launcher"}) +) + +clientkeys = gears.table.join( + awful.key({ modkey, }, "f", + function (c) + c.fullscreen = not c.fullscreen + c:raise() + end, + {description = "toggle fullscreen", group = "client"}), + awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end, + {description = "close", group = "client"}), + awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle , + {description = "toggle floating", group = "client"}), + awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end, + {description = "move to master", group = "client"}), + awful.key({ modkey, }, "o", function (c) c:move_to_screen() end, + {description = "move to screen", group = "client"}), + awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end, + {description = "toggle keep on top", group = "client"}), + awful.key({ modkey, }, "n", + function (c) + -- The client currently has the input focus, so it cannot be + -- minimized, since minimized clients can't have the focus. + c.minimized = true + end , + {description = "minimize", group = "client"}), + awful.key({ modkey, }, "m", + function (c) + c.maximized = not c.maximized + c:raise() + end , + {description = "(un)maximize", group = "client"}), + awful.key({ modkey, "Control" }, "m", + function (c) + c.maximized_vertical = not c.maximized_vertical + c:raise() + end , + {description = "(un)maximize vertically", group = "client"}), + awful.key({ modkey, "Shift" }, "m", + function (c) + c.maximized_horizontal = not c.maximized_horizontal + c:raise() + end , + {description = "(un)maximize horizontally", group = "client"}) +) + +-- Bind all key numbers to tags. +-- Be careful: we use keycodes to make it work on any keyboard layout. +-- This should map on the top row of your keyboard, usually 1 to 9. +for i = 1, 9 do + globalkeys = gears.table.join(globalkeys, + -- View tag only. + awful.key({ modkey }, "#" .. i + 9, + function () + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + tag:view_only() + end + end, + {description = "view tag #"..i, group = "tag"}), + -- Toggle tag display. + awful.key({ modkey, "Control" }, "#" .. i + 9, + function () + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) + end + end, + {description = "toggle tag #" .. i, group = "tag"}), + -- Move client to tag. + awful.key({ modkey, "Shift" }, "#" .. i + 9, + function () + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:move_to_tag(tag) + end + end + end, + {description = "move focused client to tag #"..i, group = "tag"}), + -- Toggle tag on focused client. + awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, + function () + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:toggle_tag(tag) + end + end + end, + {description = "toggle focused client on tag #" .. i, group = "tag"}) + ) +end + +clientbuttons = gears.table.join( + awful.button({ }, 1, function (c) + c:emit_signal("request::activate", "mouse_click", {raise = true}) + end), + awful.button({ modkey }, 1, function (c) + c:emit_signal("request::activate", "mouse_click", {raise = true}) + awful.mouse.client.move(c) + end), + awful.button({ modkey }, 3, function (c) + c:emit_signal("request::activate", "mouse_click", {raise = true}) + awful.mouse.client.resize(c) + end) +) + +-- Set keys +root.keys(globalkeys) +-- }}} + +-- {{{ Rules +-- Rules to apply to new clients (through the "manage" signal). +awful.rules.rules = { + -- All clients will match this rule. + { rule = { }, + properties = { border_width = beautiful.border_width, + border_color = beautiful.border_normal, + focus = awful.client.focus.filter, + raise = true, + keys = clientkeys, + buttons = clientbuttons, + screen = awful.screen.preferred, + placement = awful.placement.no_overlap+awful.placement.no_offscreen + } + }, + + -- Floating clients. + { rule_any = { + instance = { + "DTA", -- Firefox addon DownThemAll. + "copyq", -- Includes session name in class. + "pinentry", + }, + class = { + "Arandr", + "Blueman-manager", + "Gpick", + "Kruler", + "MessageWin", -- kalarm. + "Sxiv", + "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. + "Wpa_gui", + "veromix", + "xtightvncviewer"}, + + -- Note that the name property shown in xprop might be set slightly after creation of the client + -- and the name shown there might not match defined rules here. + name = { + "Event Tester", -- xev. + }, + role = { + "AlarmWindow", -- Thunderbird's calendar. + "ConfigManager", -- Thunderbird's about:config. + "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. + } + }, properties = { floating = true }}, + + -- Add titlebars to normal clients and dialogs + { rule_any = {type = { "normal", "dialog" } + }, properties = { titlebars_enabled = true } + }, + + -- Set Firefox to always map on the tag named "2" on screen 1. + -- { rule = { class = "Firefox" }, + -- properties = { screen = 1, tag = "2" } }, +} +-- }}} + +-- {{{ Signals +-- Signal function to execute when a new client appears. +client.connect_signal("manage", function (c) + -- Set the windows at the slave, + -- i.e. put it at the end of others instead of setting it master. + -- if not awesome.startup then awful.client.setslave(c) end + + if awesome.startup + and not c.size_hints.user_position + and not c.size_hints.program_position then + -- Prevent clients from being unreachable after screen count changes. + awful.placement.no_offscreen(c) + end +end) + +-- Add a titlebar if titlebars_enabled is set to true in the rules. +client.connect_signal("request::titlebars", function(c) + -- buttons for the titlebar + local buttons = gears.table.join( + awful.button({ }, 1, function() + c:emit_signal("request::activate", "titlebar", {raise = true}) + awful.mouse.client.move(c) + end), + awful.button({ }, 3, function() + c:emit_signal("request::activate", "titlebar", {raise = true}) + awful.mouse.client.resize(c) + end) + ) + + awful.titlebar(c) : setup { + { -- Left + awful.titlebar.widget.iconwidget(c), + buttons = buttons, + layout = wibox.layout.fixed.horizontal + }, + { -- Middle + { -- Title + align = "center", + widget = awful.titlebar.widget.titlewidget(c) + }, + buttons = buttons, + layout = wibox.layout.flex.horizontal + }, + { -- Right + awful.titlebar.widget.floatingbutton (c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.stickybutton (c), + awful.titlebar.widget.ontopbutton (c), + awful.titlebar.widget.closebutton (c), + layout = wibox.layout.fixed.horizontal() + }, + layout = wibox.layout.align.horizontal + } +end) + +-- Enable sloppy focus, so that focus follows mouse. +client.connect_signal("mouse::enter", function(c) + c:emit_signal("request::activate", "mouse_enter", {raise = false}) +end) + +client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) +client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) +-- }}} From bbd39ca5e0bd93c34950a4961638308a65dc52ca Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Tue, 18 Jan 2022 21:09:12 -0500 Subject: [PATCH 19/35] fix audio control w pipewire --- nixos/configuration.nix | 35 +++++++++++++---------------------- nixos/rc.lua | 10 +++++++++- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 7a966fa..292b1a4 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -76,24 +76,19 @@ # Enable sound. sound.enable = true; - hardware.pulseaudio.enable = true; - /* services.pipewire = { */ - /* enable = true; */ + hardware.pulseaudio.enable = false; + services.pipewire = { + enable = true; - /* # Sound card drivers */ - /* alsa = { */ - /* enable = true; */ - /* support32Bit = true; */ - /* }; */ + # Sound card drivers + alsa = { + enable = true; + support32Bit = true; + }; - /* # PulseAudio emulation */ - /* pulse.enable = true; */ - /* }; */ - - /* systemd.services.pavucontrol = { */ - /* wantedBy = [ "multi-user.target" ]; */ - /* script = "${pkgs.pavucontrol}/bin/pavucontrol"; */ - /* }; */ + # PulseAudio emulation + pulse.enable = true; + }; services.xserver.displayManager.setupCommands = '' ${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 \ @@ -171,17 +166,13 @@ curl home-manager just + xclip + pamixer # Mouse config libratbag piper - # Audio - alsa-utils - - # Pulse Audio control utility - #pavucontrol - steam ]; diff --git a/nixos/rc.lua b/nixos/rc.lua index aef164c..177ed75 100644 --- a/nixos/rc.lua +++ b/nixos/rc.lua @@ -326,7 +326,15 @@ globalkeys = gears.table.join( {description = "lua execute prompt", group = "awesome"}), -- Menubar awful.key({ modkey }, "p", function() menubar.show() end, - {description = "show the menubar", group = "launcher"}) + {description = "show the menubar", group = "launcher"}), + + -- Volume + awful.key({}, "XF86AudioLowerVolume", function() + awful.spawn "pamixer -d 2" + end), + awful.key({}, "XF86AudioRaiseVolume", function() + awful.spawn "pamixer -i 2" + end) ) clientkeys = gears.table.join( From ec42968d7dd8e5c0d775539fd8a63bcf6dcd5011 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 19 Jan 2022 08:32:59 -0500 Subject: [PATCH 20/35] add back himalaya --- nixos/home.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/home.nix b/nixos/home.nix index 6d21a33..e65488c 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -28,6 +28,7 @@ in discord gh /* neomutt */ + himalaya # Email mpv # Video viewer sxiv # Image viewer ]; From 60414f062ac0d02385e2a1ce36df824e476ab20c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Wed, 19 Jan 2022 08:45:19 -0500 Subject: [PATCH 21/35] remove some awesomewm boilerplate --- nixos/rc.lua | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/nixos/rc.lua b/nixos/rc.lua index 177ed75..b7e8789 100644 --- a/nixos/rc.lua +++ b/nixos/rc.lua @@ -18,38 +18,13 @@ local hotkeys_popup = require("awful.hotkeys_popup") -- when client with a matching name is opened: require("awful.hotkeys_popup.keys") --- {{{ Error handling --- Check if awesome encountered an error during startup and fell back to --- another config (This code will only ever execute for the fallback config) -if awesome.startup_errors then - naughty.notify({ preset = naughty.config.presets.critical, - title = "Oops, there were errors during startup!", - text = awesome.startup_errors }) -end - --- Handle runtime errors after startup -do - local in_error = false - awesome.connect_signal("debug::error", function (err) - -- Make sure we don't go into an endless error loop - if in_error then return end - in_error = true - - naughty.notify({ preset = naughty.config.presets.critical, - title = "Oops, an error happened!", - text = tostring(err) }) - in_error = false - end) -end --- }}} - -- {{{ Variable definitions -- Themes define colours, icons, font and wallpapers. -beautiful.init(gears.filesystem.get_themes_dir() .. "default/theme.lua") +beautiful.init(gears.filesystem.get_themes_dir() .. "zenburn/theme.lua") -- This is used later as the default terminal and editor to run. terminal = "alacritty" -editor = os.getenv("EDITOR") or "nano" +editor = os.getenv("EDITOR") or "vim" editor_cmd = terminal .. " -e " .. editor -- Default modkey. @@ -61,8 +36,8 @@ modkey = "Mod4" -- Table of layouts to cover with awful.layout.inc, order matters. awful.layout.layouts = { - awful.layout.suit.floating, awful.layout.suit.tile, + awful.layout.suit.floating, awful.layout.suit.tile.left, awful.layout.suit.tile.bottom, awful.layout.suit.tile.top, From 010b9bbc3d6488e3db0d8a5d887e93b69855eea2 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Fri, 21 Jan 2022 19:22:11 -0500 Subject: [PATCH 22/35] update mouse speed --- nixos/configuration.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 292b1a4..ccd3e56 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -61,7 +61,7 @@ # Disable mouse acceleration libinput.mouse.accelProfile = "flat"; - libinput.mouse.accelSpeed = "2.0"; + libinput.mouse.accelSpeed = "1.5"; # Configure keymap in X11 layout = "us"; From ecc00acc05d908c8933867b2e4b630e3ea77de82 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Jan 2022 10:46:51 -0500 Subject: [PATCH 23/35] set fonts with italics --- nixos/configuration.nix | 7 +- nixos/home.nix | 8 +- nixos/init.lua | 680 --------------------------------------- nvim.configlink/init.lua | 1 + 4 files changed, 12 insertions(+), 684 deletions(-) delete mode 100644 nixos/init.lua diff --git a/nixos/configuration.nix b/nixos/configuration.nix index ccd3e56..368267d 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -44,6 +44,8 @@ # services.xserver.enable = true; services.xserver = { enable = true; + autoRepeatDelay = 250; + autoRepeatInterval = 40; /* desktopManager = { */ /* xterm.enable = false; */ @@ -107,9 +109,10 @@ # Install fonts fonts.fonts = with pkgs; [ - fira-code - fira-code-symbols + victor-mono + nerdfonts ]; + fonts.fontconfig.defaultFonts.monospace = ["Victor Mono"]; # Gaming hardware.opengl = { diff --git a/nixos/home.nix b/nixos/home.nix index e65488c..e9e6858 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -48,7 +48,10 @@ in }; scrolling.history = 10000; font = { - size = 13.0; + size = 14.0; + normal = { + family = "Victor Mono"; + }; }; key_bindings = [ /* { */ @@ -155,7 +158,8 @@ in # Vim v = "nvim"; vl = "nvim -c 'normal! `0'"; - vll = "nvim -c 'Hist'"; + vll = "nvim -c 'Telescope oldfiles'"; + vimrc = "nvim ~/dev/personal/dotfiles/nvim.configlink/init.lua"; # Notes qn = "quicknote"; diff --git a/nixos/init.lua b/nixos/init.lua deleted file mode 100644 index f3f4110..0000000 --- a/nixos/init.lua +++ /dev/null @@ -1,680 +0,0 @@ --- Bootstrap the Packer plugin manager -local fn = vim.fn -local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' -if fn.empty(fn.glob(install_path)) > 0 then - packer_bootstrap = fn.system( - { - 'git', 'clone', '--depth', '1', - 'https://github.com/wbthomason/packer.nvim', install_path - } - ) -end - --- Packer plugin installations -require('packer').startup(function(use) - - -- Maintain plugin manager - use 'wbthomason/packer.nvim' - - -- Startup speed hacks - use { - 'lewis6991/impatient.nvim', - config = function() - require('impatient') - end - } - - -- Important tweaks - use 'tpope/vim-surround' --- Manipulate parentheses - use 'tpope/vim-commentary' --- Use gc or gcc to add comments - - -- Convenience tweaks - use 'tpope/vim-eunuch' --- File manipulation in Vim - use 'tpope/vim-vinegar' --- Fixes netrw file explorer - use 'tpope/vim-fugitive' --- Git commands and syntax - use 'tpope/vim-repeat' --- Actually repeat using . - use 'christoomey/vim-tmux-navigator' --- Hotkeys for tmux panes - - -- Colorscheme - use { - 'morhetz/gruvbox', - config = function() - vim.cmd[[colorscheme gruvbox]] - end - } - - -- Git next to line numbers - use { - 'lewis6991/gitsigns.nvim', - branch = 'main', - requires = {'nvim-lua/plenary.nvim'}, - config = function() - require('gitsigns').setup() - end - } - - -- Status bar - -- use { - -- 'hoob3rt/lualine.nvim', - -- requires = { 'kyazdani42/nvim-web-devicons', opt = true }, - -- config = function() - -- require('lualine').setup({ - -- options = { - -- theme = 'gruvbox', - -- icons_enabled = true - -- } - -- }) - -- end - -- } - - -- Improve speed and filetype detection - use { - 'nathom/filetype.nvim', - config = function() - -- Filetype for .env files - local envfiletype = function() - vim.bo.filetype = 'text' - vim.bo.syntax = 'sh' - end - -- Force filetype patterns that Vim doesn't know about - require('filetype').setup({ - overrides = { - extensions = { - Brewfile = 'brewfile', - muttrc = 'muttrc', - hcl = 'terraform', - }, - literal = { - Caskfile = 'brewfile', - [".gitignore"] = 'gitignore', - }, - complex = { - [".*git/config"] = "gitconfig", - ["tmux.conf%..*link"] = "tmux", - ["gitconfig%..*link"] = "gitconfig", - [".*ignore%..*link"] = "gitignore", - [".*%.toml%..*link"] = "toml", - }, - function_extensions = {}, - function_literal = { - [".envrc"] = envfiletype, - [".env"] = envfiletype, - [".env.dev"] = envfiletype, - [".env.prod"] = envfiletype, - [".env.example"] = envfiletype, - }, - } - }) - end - } - - -- Alignment tool - use 'godlygeek/tabular' - - -- Markdown renderer / wiki notes - use 'vimwiki/vimwiki' - - -- Markdown pretty view - use 'ellisonleao/glow.nvim' - - -- Navigation - use { - 'ggandor/lightspeed.nvim', - branch = 'smart-autojump' - } - - -- Snippet engine - use 'L3MON4D3/LuaSnip' - - -- ======================================================================= - -- Language Server - -- ======================================================================= - - -- Language server engine - use { - 'neovim/nvim-lspconfig', - requires = { 'hrsh7th/cmp-nvim-lsp' }, - config = function() - local capabilities = require('cmp_nvim_lsp').update_capabilities( - vim.lsp.protocol.make_client_capabilities() - ) - require('lspconfig').rust_analyzer.setup{ capabilities = capabilities } - require('lspconfig').tflint.setup{ capabilities = capabilities } - require('lspconfig').terraformls.setup{ capabilities = capabilities } - require('lspconfig').pyright.setup{ - cmd = { "poetry", "run", "pyright-langserver", "--stdio" }, - capabilities = capabilities, - } - if require('lspconfig/util').has_bins('diagnostic-languageserver') then - require('lspconfig').diagnosticls.setup{ - cmd = { "diagnostic-languageserver", "--stdio" }, - filetypes = { "sh" }, - on_attach = on_attach, - init_options = { - filetypes = { sh = "shellcheck" }, - linters = { - shellcheck = { - sourceName = "shellcheck", - command = "shellcheck", - debounce = 100, - args = { "--format=gcc", "-" }, - offsetLine = 0, - offsetColumn = 0, - formatLines = 1, - formatPattern = { - "^[^:]+:(\\d+):(\\d+):\\s+([^:]+):\\s+(.*)$", - { line = 1, column = 2, message = 4, security = 3 } - }, - securities = { error = "error", warning = "warning", } - }, - } - } - } - end - end - } - - -- Pretty highlights - use 'folke/lsp-colors.nvim' - - use { - 'folke/trouble.nvim', - requires = 'kyazdani42/nvim-web-devicons', - config = function() - require("trouble").setup { } - end - } - - -- ======================================================================= - -- Completion System - -- ======================================================================= - - -- Completion sources - use 'hrsh7th/cmp-nvim-lsp' --- Language server completion plugin - use 'hrsh7th/cmp-buffer' --- Generic text completion - use 'hrsh7th/cmp-path' --- Local file completion - use 'hrsh7th/cmp-cmdline' --- Command line completion - use 'hrsh7th/cmp-nvim-lua' --- Nvim lua api completion - use 'saadparwaiz1/cmp_luasnip' --- Luasnip completion - use 'lukas-reineke/cmp-rg' --- Ripgrep completion - - -- Completion engine - use { - 'hrsh7th/nvim-cmp', - requires = { 'L3MON4D3/LuaSnip', }, - config = function() - local cmp = require('cmp') - cmp.setup({ - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - mapping = { - [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), - [''] = function(fallback) - cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }) - vim.cmd('stopinsert') --- Abort and leave insert mode - end, - -- [''] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }), - -- [''] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 's' }), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - [''] = cmp.mapping(function(fallback) - if require('luasnip').expand_or_jumpable() then - require('luasnip').expand_or_jump() - end - end, {"i", "s"}) - }, - sources = { - { name = 'nvim_lua' }, - { name = 'nvim_lsp' }, - { name = 'path' }, - { name = 'luasnip' }, - { name = 'buffer', keyword_length = 3, max_item_count = 10 }, - { - name = 'rg', keyword_length = 6, max_item_count = 10, - option = { additional_arguments = "--ignore-case" } - }, - }, - experimental = { - native_menu = false, --- Use cmp menu instead of Vim menu - ghost_text = true, --- Show preview auto-completion - }, - }) - - -- Use buffer source for `/` - cmp.setup.cmdline('/', { - sources = { - { name = 'buffer', keyword_length = 5 } - } - }) - - -- Use cmdline & path source for ':' - cmp.setup.cmdline(':', { - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) - }) - end - } - - -- ======================================================================= - -- Syntax - -- ======================================================================= - - -- Syntax engine - use { - 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdate', - config = function() - require('nvim-treesitter.configs').setup { - highlight = { enable = true }, - indent = { enable = true }, - } - end - } - - -- Additional syntax sources - use 'bfontaine/Brewfile.vim' --- Brewfile syntax - use 'chr4/nginx.vim' --- Nginx syntax - use 'hashivim/vim-terraform' --- Terraform formatting - use 'towolf/vim-helm' --- Helm syntax - use 'rodjek/vim-puppet' --- Puppet syntax - use 'blankname/vim-fish' --- Better fish syntax - - -- ======================================================================= - -- Fuzzy Launcher - -- ======================================================================= - - use { - 'nvim-telescope/telescope.nvim', - requires = { 'nvim-lua/plenary.nvim' }, - config = function() - -- Telescope: quit instantly with escape - local actions = require("telescope.actions") - require("telescope").setup({ - defaults = { - mappings = { - i = { - [""] = actions.close, - [""] = "which_key", - }, - }, - }, - pickers = { - find_files = { theme = "ivy" }, - oldfiles = { theme = "ivy" }, - buffers = { theme = "dropdown" }, - }, - extensions = { - fzy_native = {}, - tmux = {}, - zoxide = {}, - -- neoclip = {}, - project = { - base_dirs = { '~/dev/work', }, - }, - }, - }) - end - } - - -- Faster sorting - use 'nvim-telescope/telescope-fzy-native.nvim' - - -- Jump around tmux sessions - use 'camgraff/telescope-tmux.nvim' - - -- Jump directories - use { - 'jvgrootveld/telescope-zoxide', - requires = {'nvim-lua/popup.nvim'}, - } - - -- Jump projects - use { - 'nvim-telescope/telescope-project.nvim', - requires = {'nvim-telescope/telescope.nvim'}, - config = function() - require('telescope').load_extension('project') - end - } - - -- Clipboard history - -- use { - -- "AckslD/nvim-neoclip.lua", - -- branch = 'main', - -- requires = { - -- {'tami5/sqlite.lua', module = 'sqlite'}, - -- {'nvim-telescope/telescope.nvim'}, - -- }, - -- config = function() - -- require('neoclip').setup({ - -- enable_persistant_history = true, - -- default_register = {'+', '"'}, - -- keys = { - -- i = { paste = '' }, - -- }, - -- }) - -- require('telescope').load_extension('neoclip') - -- end - -- } - - -- Project bookmarks - use { - 'ThePrimeagen/harpoon', - requires = { - 'nvim-lua/plenary.nvim', - 'nvim-telescope/telescope.nvim' - } - } - - -- TLDR Lookup - use { - 'mrjones2014/tldr.nvim', - requires = {'nvim-telescope/telescope.nvim'} - } - - -- ======================================================================= - - -- Install on initial bootstrap - if packer_bootstrap then - require('packer').sync() - end -end) - --- =========================================================================== --- Settings --- =========================================================================== - -vim.o.termguicolors = true --- Set to truecolor -vim.o.hidden = true --- Don't unload buffers when leaving them -vim.wo.number = true --- Show line numbers -vim.wo.relativenumber = true --- Relative numbers instead of absolute -vim.o.list = true --- Reveal whitespace with dashes -vim.o.expandtab = true --- Tabs into spaces -vim.o.shiftwidth = 4 --- Amount to shift with > key -vim.o.softtabstop = 4 --- Amount to shift with key -vim.o.ignorecase = true --- Ignore case when searching -vim.o.smartcase = true --- Check case when using capitals in search -vim.o.infercase = true --- Don't match cases when completing suggestions -vim.o.incsearch = true --- Search while typing -vim.o.visualbell = true --- No sounds -vim.o.scrolljump = 1 --- Number of lines to scroll -vim.o.scrolloff = 3 --- Margin of lines to see while scrolling -vim.o.splitright = true --- Vertical splits on the right side -vim.o.splitbelow = true --- Horizontal splits on the bottom side -vim.o.pastetoggle = "" --- Use F3 to enter raw paste mode -vim.o.clipboard = "unnamedplus" --- Uses system clipboard for yanking -vim.o.updatetime = 300 --- Faster diagnostics -vim.o.mouse = "nv" --- Mouse interaction / scrolling - --- Neovim features -vim.o.inccommand = "split" --- Live preview search and replace -vim.o.completeopt = "menu,menuone,noselect" --- Required for nvim-cmp completion --- Required until 0.6.0: do not source the default filetype.vim -vim.g.did_load_filetypes = 1 - --- Remember last position when reopening file -vim.api.nvim_exec([[ - au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif -]], false) - --- Better backup, swap and undo storage -vim.o.backup = true --- Easier to recover and more secure -vim.bo.swapfile = false --- Instead of swaps, create backups -vim.bo.undofile = true --- Keeps undos after quit - --- Create backup directories if they don't exist --- Should be fixed in 0.6 by https://github.com/neovim/neovim/pull/15433 -vim.o.backupdir = vim.fn.stdpath('cache') .. '/backup' -vim.api.nvim_exec([[ - if !isdirectory(&backupdir) - call mkdir(&backupdir, "p") - endif -]], false) - --- LaTeX options -vim.api.nvim_exec([[ - au FileType tex inoremap ;bf \textbf{}i - au BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw! -]], false) - --- Highlight when yanking -vim.api.nvim_exec([[ - au TextYankPost * silent! lua vim.highlight.on_yank { timeout = 250 } -]], false) - --- Netrw -vim.g.netrw_liststyle = 3 -- Change style to 'tree' view -vim.g.netrw_banner = 0 -- Remove useless banner -vim.g.netrw_winsize = 15 -- Explore window takes % of page -vim.g.netrw_browse_split = 4 -- Open in previous window -vim.g.netrw_altv = 1 -- Always split left - --- Formatting -vim.g.terraform_fmt_on_save = 1 -- Formats with terraform plugin -vim.g.rustfmt_autosave = 1 -- Formats with rust plugin - --- VimWiki -vim.g.vimwiki_list = { - { - ["path"] = "$NOTES_PATH", - ["syntax"] = "markdown", - ["index"] = "home", - ["ext"] = ".md" - } -} -vim.g.vimwiki_key_mappings = { - ["all_maps"] = 1, - ["mouse"] = 1, -} -vim.g.vimwiki_auto_chdir = 1 -- Set local dir to Wiki when open -vim.g.vimwiki_create_link = 0 -- Don't automatically create new links -vim.g.vimwiki_listsyms = " x" -- Set checkbox symbol progression -vim.g.vimwiki_table_mappings = 0 -- VimWiki table keybinds interfere with tab completion -vim.api.nvim_exec([[ - au FileType markdown inoremap ;tt :AddTag - - function! PInsert(item) - let @z=a:item - norm "zpx - endfunction - - command! AddTag call fzf#run({'source': 'rg "#[A-Za-z/]+[ |\$]" -o --no-filename --no-line-number | sort | uniq', 'sink': function('PInsert')}) -]], false) - --- =========================================================================== --- Custom Functions --- =========================================================================== - -grep_notes = function() - local opts = { - prompt_title = "Search Notes", - cwd = '$NOTES_PATH', - } - require('telescope.builtin').live_grep(opts) -end - -find_notes = function() - local opts = { - prompt_title = "Find Notes", - cwd = '$NOTES_PATH', - } - require('telescope.builtin').find_files(opts) -end - -find_downloads = function() - local opts = { - prompt_title = "Find Downloads", - cwd = '~/Downloads', - } - require('telescope.builtin').file_browser(opts) -end - -choose_project = function() - local opts = require("telescope.themes").get_ivy { - layout_config = { - bottom_pane = { - height = 10, - }, - }, - } - require('telescope').extensions.project.project(opts) -end - -clipboard_history = function() - local opts = require("telescope.themes").get_cursor { - layout_config = { - cursor = { - width = 150, - }, - }, - } - require('telescope').extensions.neoclip.neoclip(opts) -end - -command_history = function() - local opts = require("telescope.themes").get_ivy { - layout_config = { - bottom_pane = { - height = 15, - } - } - } - require('telescope.builtin').command_history(opts) -end - --- =========================================================================== --- Key Mapping --- =========================================================================== - --- Function to cut down config boilerplate -local key = function(mode, key_sequence, action, params) - params = params or {} - params["noremap"] = true - vim.api.nvim_set_keymap(mode, key_sequence, action, params) -end - --- Remap space as leader key -key("", "", "", {silent=true}) -vim.g.mapleader = " " -vim.g.maplocalleader = " " - --- Keep selection when changing indentation -key("v", "<", "", ">gv") - --- Clear search register -key("n", "", ":noh", {silent=true}) - --- Shuffle lines around -key("n", "", ":m .+1==") -key("n", "", ":m .-2==") -key("i", "", ":m .+1==gi") -key("i", "", ":m .-2==gi") -key("v", "", ":m '>+1gv=gv") -key("v", "", ":m '<-2gv=gv") - --- Telescope (fuzzy finder) -key("n", "k", ":Telescope keymaps") -key("n", "/", ":Telescope live_grep") -key("n", "ff", ":Telescope find_files") -key("n", "fp", ":Telescope git_files") -key("n", "fN", "lua find_notes()") -key("n", "N", "lua grep_notes()") -key("n", "fD", "lua find_downloads()") -key("n", "fa", ":Telescope file_browser") -key("n", "fw", ":Telescope grep_string") -key("n", "wt", ":Telescope tmux sessions") -key("n", "ww", ":Telescope tmux windows") -key("n", "w/", ":Telescope tmux pane_contents") -key("n", "fz", ":Telescope zoxide list") -key("n", "b", ":Telescope buffers") -key("n", "hh", ":Telescope help_tags") -key("n", "fr", ":Telescope oldfiles") -key("n", "cc", ":Telescope commands") -key("n", "cr", "lua command_history()") -key("n", "y", "lua clipboard_history()") -key("i", "", "lua clipboard_history()") -key("n", "s", ":Telescope current_buffer_fuzzy_find") -key("n", "gc", ":Telescope git_commits") -key("n", "gf", ":Telescope git_bcommits") -key("n", "gb", ":Telescope git_branches") -key("n", "gs", ":Telescope git_status") -key("n", "", "lua choose_project()") - --- Harpoon -key("n", "m", "lua require('harpoon.mark').add_file()") -key("n", "`", "lua require('harpoon.ui').toggle_quick_menu()") -key("n", "1", "lua require('harpoon.ui').nav_file(1)") -key("n", "2", "lua require('harpoon.ui').nav_file(2)") -key("n", "3", "lua require('harpoon.ui').nav_file(3)") - --- LSP -key("n", "gd", "lua vim.lsp.buf.definition()", {silent=true}) -key("n", "gi", "lua vim.lsp.buf.implementation()", {silent=true}) -key("n", "gh", "lua vim.lsp.buf.hover()", {silent=true}) -key("n", "]e", "lua vim.lsp.diagnostic.goto_next()", {silent=true}) -key("n", "[e", "lua vim.lsp.diagnostic.goto_prev()", {silent=true}) -key("n", "e", "lua vim.lsp.diagnostic.show_line_diagnostics()", {silent=true}) - --- File commands -key("n", "q", ":quit") -key("n", "Q", ":quitall") -key("n", "fs", ":write") -key("n", "fd", ":lcd %:p:h", {silent=true}) -key("n", "fu", ":lcd ..", {silent=true}) -key("n", "", ":b#", {silent=true}) -key("n", "gr", ":!gh repo view -w", {silent=true}) -key("n", "tt", - [[exe 'edit $NOTES_PATH/journal/'.strftime("%Y-%m-%d_%a").'.md']] -) -key("n", "jj", ":!journal:e") - --- Window commands -key("n", "wv", ":vsplit") -key("n", "wh", ":split") -key("n", "wm", ":only") - --- Tabularize -key("", "ta", ":Tabularize /") -key("", "t#", ":Tabularize /#") -key("", "tl", ":Tabularize /---") - --- Vimrc editing -key("n", "fv", ":edit $MYVIMRC") -key("n", "rr", ":luafile $MYVIMRC") -key("n", "rp", ":luafile $MYVIMRC:PackerInstall:") -key("n", "rc", ":luafile $MYVIMRC:PackerCompile") - --- Keep cursor in place -key("n", 'n', "nzz") -key("n", 'N', "Nzz") -key("n", 'J', "mzJ`z") --- Mark and jump back to it - --- Add undo breakpoints -key("i", ',', ",u") -key("i", '.', ".u") -key("i", '!', "!u") -key("i", '?', "?u") - --- Other -key("t", "", "") --- Exit terminal mode -key("n", "", ":noh", {silent=true}) --- Clear search in VimWiki -key("n", "Y", "y$") --- Copy to end of line -key("v", "", "y:%s/+//gc") --- Substitute selected -key("v", "D", "y'>gp") --- Duplicate selected diff --git a/nvim.configlink/init.lua b/nvim.configlink/init.lua index e455095..dcd09b2 100644 --- a/nvim.configlink/init.lua +++ b/nvim.configlink/init.lua @@ -40,6 +40,7 @@ require("packer").startup(function(use) use({ "morhetz/gruvbox", config = function() + vim.g.gruvbox_italic = 1 vim.cmd([[colorscheme gruvbox]]) end, }) From 121e1e9c372a064453499f1c30986ba4afecebca Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Jan 2022 11:01:52 -0500 Subject: [PATCH 24/35] nixfmt --- nixos/configuration.nix | 37 ++++------- nixos/home.nix | 138 +++++++++++++++++++-------------------- nvim.configlink/init.lua | 4 +- 3 files changed, 81 insertions(+), 98 deletions(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 368267d..74beb5c 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -5,10 +5,9 @@ { config, pkgs, ... }: { - imports = - [ # Include the results of the hardware scan. - /etc/nixos/hardware-configuration.nix - ]; + imports = [ # Include the results of the hardware scan. + /etc/nixos/hardware-configuration.nix + ]; nixpkgs.config.allowUnfree = true; @@ -47,16 +46,12 @@ autoRepeatDelay = 250; autoRepeatInterval = 40; - /* desktopManager = { */ - /* xterm.enable = false; */ - /* xfce.enable = true; */ - /* }; */ - /* displayManager.defaultSession = "xfce"; */ - windowManager = { - awesome = { - enable = true; - }; - }; + # desktopManager = { + # xterm.enable = false; + # xfce.enable = true; + # }; + # displayManager.defaultSession = "xfce"; + windowManager = { awesome = { enable = true; }; }; # Enable touchpad support (enabled default in most desktopManager). libinput.enable = true; @@ -104,15 +99,11 @@ --rotate normal \ --output DVI-0 --off \ --output DVI-1 --off \ - ''; - + ''; # Install fonts - fonts.fonts = with pkgs; [ - victor-mono - nerdfonts - ]; - fonts.fontconfig.defaultFonts.monospace = ["Victor Mono"]; + fonts.fonts = with pkgs; [ victor-mono nerdfonts ]; + fonts.fontconfig.defaultFonts.monospace = [ "Victor Mono" ]; # Gaming hardware.opengl = { @@ -184,9 +175,7 @@ longitude = 74.0; }; - services.redshift = { - enable = true; - }; + services.redshift = { enable = true; }; # Some programs need SUID wrappers, can be configured further or are # started in user sessions. diff --git a/nixos/home.nix b/nixos/home.nix index e9e6858..2e5fdad 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -2,19 +2,26 @@ let - # Nothing + font = "Victor Mono"; -in - -{ +in { nixpkgs.config.allowUnfree = true; home.packages = with pkgs; [ + # Applications firefox - unzip neovim - gcc # for tree-sitter alacritty + _1password-gui + discord + # neomutt + himalaya # Email + mpv # Video viewer + sxiv # Image viewer + + # Utilities + unzip + gcc # for tree-sitter tmux rsync ripgrep @@ -24,13 +31,9 @@ in sd jq tealdeer - _1password-gui - discord gh - /* neomutt */ - himalaya # Email - mpv # Video viewer - sxiv # Image viewer + pass + nixfmt ]; programs.alacritty = { @@ -49,22 +52,13 @@ in scrolling.history = 10000; font = { size = 14.0; - normal = { - family = "Victor Mono"; - }; + normal = { family = "${font}"; }; }; - key_bindings = [ - /* { */ - /* key = "F"; */ - /* mods = "Super"; */ - /* action = "ToggleFullscreen"; */ - /* } */ - { - key = "L"; - mods = "Control|Shift"; - chars = "\\x1F"; - } - ]; + key_bindings = [{ + key = "L"; + mods = "Control|Shift"; + chars = "\\x1F"; + }]; colors = { primary = { background = "0x1d2021"; @@ -75,24 +69,24 @@ in cursor = "0xd5c4a1"; }; normal = { - black = "0x1d2021"; - red = "0xfb4934"; - green = "0xb8bb26"; - yellow = "0xfabd2f"; - blue = "0x83a598"; + black = "0x1d2021"; + red = "0xfb4934"; + green = "0xb8bb26"; + yellow = "0xfabd2f"; + blue = "0x83a598"; magenta = "0xd3869b"; - cyan = "0x8ec07c"; - white = "0xd5c4a1"; + cyan = "0x8ec07c"; + white = "0xd5c4a1"; }; bright = { - black = "0x665c54"; - red = "0xfe8019"; - green = "0x3c3836"; - yellow = "0x504945"; - blue = "0xbdae93"; + black = "0x665c54"; + red = "0xfe8019"; + green = "0x3c3836"; + yellow = "0x504945"; + blue = "0xbdae93"; magenta = "0xebdbb2"; - cyan = "0xd65d0e"; - white = "0xfbf1c7"; + cyan = "0xd65d0e"; + white = "0xfbf1c7"; }; }; draw_bold_text_with_bright_colors = false; @@ -101,7 +95,7 @@ in programs.fish = { enable = true; - functions = {}; + functions = { }; interactiveShellInit = ""; loginShellInit = ""; shellAbbrs = { @@ -150,7 +144,8 @@ in # GitHub ghr = "gh repo view -w"; - gha = "gh run list | head -1 | awk \'{ print $(NF-2) }\' | xargs gh run view"; + gha = + "gh run list | head -1 | awk '{ print $(NF-2) }' | xargs gh run view"; grw = "gh run watch"; grf = "gh run view --log-failed"; grl = "gh run view --log"; @@ -168,7 +163,7 @@ in work = "vim $NOTES_PATH/work.md"; # Improved CLI Tools - cat = "bat"; # Swap cat with bat + cat = "bat"; # Swap cat with bat h = "http -Fh --all"; # Curl site for headers j = "just"; @@ -177,7 +172,8 @@ in moon = "curl wttr.in/Moon"; # Cheat Sheets - ssl = "openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr"; + ssl = + "openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr"; fingerprint = "ssh-keyscan myhost.com | ssh-keygen -lf -"; publickey = "ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub"; forloop = "for i in (seq 1 100)"; @@ -207,13 +203,15 @@ in ca = "cargo"; }; - shellAliases = {}; + shellAliases = { }; shellInit = ""; }; home.sessionVariables = { - EDITOR = "nvim"; fish_greeting = ""; + EDITOR = "nvim"; + NIXOS_CONFIG = builtins.getEnv "PWD"; + DOTS = "${builtins.getEnv "PWD"}/.."; }; programs.starship = { @@ -244,12 +242,8 @@ in userName = "Noah Masur"; userEmail = "7386960+nmasur@users.noreply.github.com"; extraConfig = { - core = { - editor = "nvim"; - }; - pager = { - branch = "false"; - }; + core = { editor = "nvim"; }; + pager = { branch = "false"; }; }; }; @@ -260,23 +254,23 @@ in }; # Email - /* programs.himalaya = { */ - /* enable = true; */ - /* settings = { */ - /* name = "Noah Masur"; */ - /* downloads-dir = "~/Downloads"; */ - /* home = { */ - /* default = true; */ - /* email = "censored"; */ - /* imap-host = "censored"; */ - /* imap-port = 993; */ - /* imap-login = "censored"; */ - /* imap-passwd-cmd = "cat ~/.config/himalaya/passwd"; */ - /* smtp-host = "censored"; */ - /* smtp-port = 587; */ - /* smtp-login = "censored"; */ - /* smtp-passwd-cmd = "cat ~/.config/himalaya/passwd"; */ - /* }; */ - /* }; */ - /* }; */ + # programs.himalaya = { + # enable = true; + # settings = { + # name = "Noah Masur"; + # downloads-dir = "~/Downloads"; + # home = { + # default = true; + # email = "censored"; + # imap-host = "censored"; + # imap-port = 993; + # imap-login = "censored"; + # imap-passwd-cmd = "cat ~/.config/himalaya/passwd"; + # smtp-host = "censored"; + # smtp-port = 587; + # smtp-login = "censored"; + # smtp-passwd-cmd = "cat ~/.config/himalaya/passwd"; + # }; + # }; + # }; } diff --git a/nvim.configlink/init.lua b/nvim.configlink/init.lua index dcd09b2..2414398 100644 --- a/nvim.configlink/init.lua +++ b/nvim.configlink/init.lua @@ -165,7 +165,7 @@ require("packer").startup(function(use) args = { "run", "black", "--quiet", "--fast", "-" }, }), require("null-ls").builtins.formatting.fish_indent, - -- require("null-ls").builtins.formatting.nixfmt, + require("null-ls").builtins.formatting.nixfmt, require("null-ls").builtins.formatting.rustfmt, require("null-ls").builtins.diagnostics.shellcheck, require("null-ls").builtins.formatting.shfmt.with({ @@ -683,7 +683,7 @@ key("", "t#", ":Tabularize /#") key("", "tl", ":Tabularize /---") -- Vimrc editing -key("n", "fv", ":edit $MYVIMRC") +key("n", "fv", ":edit $DOTS/nvim.configlink/init.lua") key("n", "rr", ":luafile $MYVIMRC") key("n", "rp", ":luafile $MYVIMRC:PackerInstall:") key("n", "rc", ":luafile $MYVIMRC:PackerCompile") From 635414aa36e978c31290ef8d332ac5ae150b2774 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Jan 2022 11:06:14 -0500 Subject: [PATCH 25/35] make nvim an alias of vim --- nixos/home.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nixos/home.nix b/nixos/home.nix index 2e5fdad..5c05a12 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -98,6 +98,7 @@ in { functions = { }; interactiveShellInit = ""; loginShellInit = ""; + shellAliases = { vim = "nvim"; }; shellAbbrs = { # Directory aliases @@ -124,7 +125,7 @@ in { gaa = "git add -A"; gac = "git commit -am"; gc = "git commit -m"; - gca = "git commit --amend"; + gca = "git commit --amend --no-edit"; gu = "git pull"; gp = "git push"; gpp = "git_set_upstream"; @@ -151,10 +152,10 @@ in { grl = "gh run view --log"; # Vim - v = "nvim"; - vl = "nvim -c 'normal! `0'"; - vll = "nvim -c 'Telescope oldfiles'"; - vimrc = "nvim ~/dev/personal/dotfiles/nvim.configlink/init.lua"; + v = "vim"; + vl = "vim -c 'normal! `0'"; + vll = "vim -c 'Telescope oldfiles'"; + vimrc = "vim ~/dev/personal/dotfiles/nvim.configlink/init.lua"; # Notes qn = "quicknote"; From 449b452cd1d7db0393e27e0426b78b418026bed1 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Jan 2022 14:01:32 -0500 Subject: [PATCH 26/35] don't install formatters globally --- .gitignore | 1 + nixos/.envrc | 1 + nixos/awesomerc.lua | 564 ++++++++++++++++++++++++++++++++++++++++++++ nixos/home.nix | 17 +- nixos/rc.lua | 547 ------------------------------------------ nixos/shell.nix | 4 + 6 files changed, 583 insertions(+), 551 deletions(-) create mode 100644 nixos/.envrc create mode 100644 nixos/awesomerc.lua delete mode 100644 nixos/rc.lua create mode 100644 nixos/shell.nix diff --git a/.gitignore b/.gitignore index a7b536b..7d161dc 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ fish_variables homebrew/*.lock.json *.bak *.db +**/.direnv/** diff --git a/nixos/.envrc b/nixos/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/nixos/.envrc @@ -0,0 +1 @@ +use nix diff --git a/nixos/awesomerc.lua b/nixos/awesomerc.lua new file mode 100644 index 0000000..3a452e3 --- /dev/null +++ b/nixos/awesomerc.lua @@ -0,0 +1,564 @@ +-- If LuaRocks is installed, make sure that packages installed through it are +-- found (e.g. lgi). If LuaRocks is not installed, do nothing. +pcall(require, "luarocks.loader") + +-- Standard awesome library +local gears = require("gears") +local awful = require("awful") +require("awful.autofocus") +-- Widget and layout library +local wibox = require("wibox") +-- Theme handling library +local beautiful = require("beautiful") +-- Notification library +local naughty = require("naughty") +local menubar = require("menubar") +local hotkeys_popup = require("awful.hotkeys_popup") +-- Enable hotkeys help widget for VIM and other apps +-- when client with a matching name is opened: +require("awful.hotkeys_popup.keys") + +-- {{{ Variable definitions +-- Themes define colours, icons, font and wallpapers. +beautiful.init(gears.filesystem.get_themes_dir() .. "zenburn/theme.lua") + +-- This is used later as the default terminal and editor to run. +terminal = "alacritty" +editor = os.getenv("EDITOR") or "vim" +editor_cmd = terminal .. " -e " .. editor + +-- Default modkey. +-- Usually, Mod4 is the key with a logo between Control and Alt. +-- If you do not like this or do not have such a key, +-- I suggest you to remap Mod4 to another key using xmodmap or other tools. +-- However, you can use another modifier like Mod1, but it may interact with others. +modkey = "Mod4" + +-- Table of layouts to cover with awful.layout.inc, order matters. +awful.layout.layouts = { + awful.layout.suit.tile, + awful.layout.suit.floating, + -- awful.layout.suit.tile.left, + -- awful.layout.suit.tile.bottom, + -- awful.layout.suit.tile.top, + -- awful.layout.suit.fair, + -- awful.layout.suit.fair.horizontal, + -- awful.layout.suit.spiral, + -- awful.layout.suit.spiral.dwindle, + -- awful.layout.suit.max, + -- awful.layout.suit.max.fullscreen, + -- awful.layout.suit.magnifier, + -- awful.layout.suit.corner.nw, + -- awful.layout.suit.corner.ne, + -- awful.layout.suit.corner.sw, + -- awful.layout.suit.corner.se, +} +-- }}} + +-- {{{ Menu +-- Create a launcher widget and a main menu +myawesomemenu = { + { + "hotkeys", + function() + hotkeys_popup.show_help(nil, awful.screen.focused()) + end, + }, + { "manual", terminal .. " -e man awesome" }, + { "edit config", editor_cmd .. " " .. awesome.conffile }, + { "restart", awesome.restart }, + { + "quit", + function() + awesome.quit() + end, + }, +} + +mymainmenu = awful.menu({ + items = { + { "awesome", myawesomemenu, beautiful.awesome_icon }, + { "open terminal", terminal }, + }, +}) + +mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu }) + +-- Menubar configuration +menubar.utils.terminal = terminal -- Set the terminal for applications that require it +-- }}} + +-- Keyboard map indicator and switcher +mykeyboardlayout = awful.widget.keyboardlayout() + +-- {{{ Wibar +-- Create a textclock widget +mytextclock = wibox.widget.textclock() + +-- Create a wibox for each screen and add it +local taglist_buttons = gears.table.join( + awful.button({}, 1, function(t) + t:view_only() + end), + awful.button({ modkey }, 1, function(t) + if client.focus then + client.focus:move_to_tag(t) + end + end), + awful.button({}, 3, awful.tag.viewtoggle), + awful.button({ modkey }, 3, function(t) + if client.focus then + client.focus:toggle_tag(t) + end + end), + awful.button({}, 4, function(t) + awful.tag.viewnext(t.screen) + end), + awful.button({}, 5, function(t) + awful.tag.viewprev(t.screen) + end) +) + +local tasklist_buttons = gears.table.join( + awful.button({}, 1, function(c) + if c == client.focus then + c.minimized = true + else + c:emit_signal("request::activate", "tasklist", { raise = true }) + end + end), + awful.button({}, 3, function() + awful.menu.client_list({ theme = { width = 250 } }) + end), + awful.button({}, 4, function() + awful.client.focus.byidx(1) + end), + awful.button({}, 5, function() + awful.client.focus.byidx(-1) + end) +) + +local function set_wallpaper(s) + -- Wallpaper + if beautiful.wallpaper then + local wallpaper = beautiful.wallpaper + -- If wallpaper is a function, call it with the screen + if type(wallpaper) == "function" then + wallpaper = wallpaper(s) + end + gears.wallpaper.maximized(wallpaper, s, true) + end +end + +-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution) +screen.connect_signal("property::geometry", set_wallpaper) + +awful.screen.connect_for_each_screen(function(s) + -- Wallpaper + set_wallpaper(s) + + -- Each screen has its own tag table. + awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) + + -- Create a promptbox for each screen + s.mypromptbox = awful.widget.prompt() + -- Create an imagebox widget which will contain an icon indicating which layout we're using. + -- We need one layoutbox per screen. + s.mylayoutbox = awful.widget.layoutbox(s) + s.mylayoutbox:buttons(gears.table.join( + awful.button({}, 1, function() + awful.layout.inc(1) + end), + awful.button({}, 3, function() + awful.layout.inc(-1) + end), + awful.button({}, 4, function() + awful.layout.inc(1) + end), + awful.button({}, 5, function() + awful.layout.inc(-1) + end) + )) + -- Create a taglist widget + s.mytaglist = awful.widget.taglist({ + screen = s, + filter = awful.widget.taglist.filter.all, + buttons = taglist_buttons, + }) + + -- Create a tasklist widget + s.mytasklist = awful.widget.tasklist({ + screen = s, + filter = awful.widget.tasklist.filter.currenttags, + buttons = tasklist_buttons, + }) + + -- Create the wibox + s.mywibox = awful.wibar({ position = "top", screen = s }) + + -- Add widgets to the wibox + s.mywibox:setup({ + layout = wibox.layout.align.horizontal, + { -- Left widgets + layout = wibox.layout.fixed.horizontal, + mylauncher, + s.mytaglist, + s.mypromptbox, + }, + s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + mykeyboardlayout, + wibox.widget.systray(), + mytextclock, + s.mylayoutbox, + }, + }) +end) +-- }}} + +-- {{{ Mouse bindings +root.buttons(gears.table.join( + awful.button({}, 3, function() + mymainmenu:toggle() + end), + awful.button({}, 4, awful.tag.viewnext), + awful.button({}, 5, awful.tag.viewprev) +)) +-- }}} + +-- {{{ Key bindings +globalkeys = gears.table.join( + awful.key({ modkey }, "s", hotkeys_popup.show_help, { description = "show help", group = "awesome" }), + awful.key({ modkey }, "Left", awful.tag.viewprev, { description = "view previous", group = "tag" }), + awful.key({ modkey }, "Right", awful.tag.viewnext, { description = "view next", group = "tag" }), + awful.key({ modkey }, "Escape", awful.tag.history.restore, { description = "go back", group = "tag" }), + + awful.key({ modkey }, "j", function() + awful.client.focus.byidx(1) + end, { description = "focus next by index", group = "client" }), + awful.key({ modkey }, "k", function() + awful.client.focus.byidx(-1) + end, { description = "focus previous by index", group = "client" }), + awful.key({ modkey }, "w", function() + mymainmenu:show() + end, { description = "show main menu", group = "awesome" }), + + -- Layout manipulation + awful.key({ modkey, "Shift" }, "j", function() + awful.client.swap.byidx(1) + end, { description = "swap with next client by index", group = "client" }), + awful.key({ modkey, "Shift" }, "k", function() + awful.client.swap.byidx(-1) + end, { description = "swap with previous client by index", group = "client" }), + awful.key({ modkey, "Control" }, "j", function() + awful.screen.focus_relative(1) + end, { description = "focus the next screen", group = "screen" }), + awful.key({ modkey, "Control" }, "k", function() + awful.screen.focus_relative(-1) + end, { description = "focus the previous screen", group = "screen" }), + awful.key({ modkey }, "u", awful.client.urgent.jumpto, { description = "jump to urgent client", group = "client" }), + awful.key({ modkey }, "Tab", function() + awful.client.focus.history.previous() + if client.focus then + client.focus:raise() + end + end, { description = "go back", group = "client" }), + + -- Standard program + awful.key({ modkey }, "Return", function() + awful.spawn(terminal) + end, { description = "open a terminal", group = "launcher" }), + awful.key({ modkey, "Control" }, "r", awesome.restart, { description = "reload awesome", group = "awesome" }), + awful.key({ modkey, "Shift" }, "q", awesome.quit, { description = "quit awesome", group = "awesome" }), + + awful.key({ modkey }, "l", function() + awful.tag.incmwfact(0.05) + end, { description = "increase master width factor", group = "layout" }), + awful.key({ modkey }, "h", function() + awful.tag.incmwfact(-0.05) + end, { description = "decrease master width factor", group = "layout" }), + awful.key({ modkey, "Shift" }, "h", function() + awful.tag.incnmaster(1, nil, true) + end, { description = "increase the number of master clients", group = "layout" }), + awful.key({ modkey, "Shift" }, "l", function() + awful.tag.incnmaster(-1, nil, true) + end, { description = "decrease the number of master clients", group = "layout" }), + awful.key({ modkey, "Control" }, "h", function() + awful.tag.incncol(1, nil, true) + end, { description = "increase the number of columns", group = "layout" }), + awful.key({ modkey, "Control" }, "l", function() + awful.tag.incncol(-1, nil, true) + end, { description = "decrease the number of columns", group = "layout" }), + awful.key({ modkey }, "space", function() + awful.layout.inc(1) + end, { description = "select next", group = "layout" }), + awful.key({ modkey, "Shift" }, "space", function() + awful.layout.inc(-1) + end, { description = "select previous", group = "layout" }), + + awful.key({ modkey, "Control" }, "n", function() + local c = awful.client.restore() + -- Focus restored client + if c then + c:emit_signal("request::activate", "key.unminimize", { raise = true }) + end + end, { description = "restore minimized", group = "client" }), + + -- Prompt + awful.key({ modkey }, "r", function() + awful.screen.focused().mypromptbox:run() + end, { description = "run prompt", group = "launcher" }), + + awful.key({ modkey }, "x", function() + awful.prompt.run({ + prompt = "Run Lua code: ", + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = awful.util.eval, + history_path = awful.util.get_cache_dir() .. "/history_eval", + }) + end, { description = "lua execute prompt", group = "awesome" }), + -- Menubar + awful.key({ modkey }, "p", function() + menubar.show() + end, { description = "show the menubar", group = "launcher" }), + + -- Volume + awful.key({}, "XF86AudioLowerVolume", function() + awful.spawn("pamixer -d 2") + end), + awful.key({}, "XF86AudioRaiseVolume", function() + awful.spawn("pamixer -i 2") + end) +) + +clientkeys = gears.table.join( + awful.key({ modkey }, "f", function(c) + c.fullscreen = not c.fullscreen + c:raise() + end, { description = "toggle fullscreen", group = "client" }), + awful.key({ modkey, "Shift" }, "c", function(c) + c:kill() + end, { description = "close", group = "client" }), + awful.key( + { modkey, "Control" }, + "space", + awful.client.floating.toggle, + { description = "toggle floating", group = "client" } + ), + awful.key({ modkey, "Control" }, "Return", function(c) + c:swap(awful.client.getmaster()) + end, { description = "move to master", group = "client" }), + awful.key({ modkey }, "o", function(c) + c:move_to_screen() + end, { description = "move to screen", group = "client" }), + awful.key({ modkey }, "t", function(c) + c.ontop = not c.ontop + end, { description = "toggle keep on top", group = "client" }), + awful.key({ modkey }, "n", function(c) + -- The client currently has the input focus, so it cannot be + -- minimized, since minimized clients can't have the focus. + c.minimized = true + end, { description = "minimize", group = "client" }), + awful.key({ modkey }, "m", function(c) + c.maximized = not c.maximized + c:raise() + end, { description = "(un)maximize", group = "client" }), + awful.key({ modkey, "Control" }, "m", function(c) + c.maximized_vertical = not c.maximized_vertical + c:raise() + end, { description = "(un)maximize vertically", group = "client" }), + awful.key({ modkey, "Shift" }, "m", function(c) + c.maximized_horizontal = not c.maximized_horizontal + c:raise() + end, { description = "(un)maximize horizontally", group = "client" }) +) + +-- Bind all key numbers to tags. +-- Be careful: we use keycodes to make it work on any keyboard layout. +-- This should map on the top row of your keyboard, usually 1 to 9. +for i = 1, 9 do + globalkeys = gears.table.join( + globalkeys, + -- View tag only. + awful.key({ modkey }, "#" .. i + 9, function() + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + tag:view_only() + end + end, { description = "view tag #" .. i, group = "tag" }), + -- Toggle tag display. + awful.key({ modkey, "Control" }, "#" .. i + 9, function() + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) + end + end, { description = "toggle tag #" .. i, group = "tag" }), + -- Move client to tag. + awful.key({ modkey, "Shift" }, "#" .. i + 9, function() + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:move_to_tag(tag) + end + end + end, { description = "move focused client to tag #" .. i, group = "tag" }), + -- Toggle tag on focused client. + awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function() + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:toggle_tag(tag) + end + end + end, { description = "toggle focused client on tag #" .. i, group = "tag" }) + ) +end + +clientbuttons = gears.table.join( + awful.button({}, 1, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + end), + awful.button({ modkey }, 1, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + awful.mouse.client.move(c) + end), + awful.button({ modkey }, 3, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + awful.mouse.client.resize(c) + end) +) + +-- Set keys +root.keys(globalkeys) +-- }}} + +-- {{{ Rules +-- Rules to apply to new clients (through the "manage" signal). +awful.rules.rules = { + -- All clients will match this rule. + { + rule = {}, + properties = { + border_width = beautiful.border_width, + border_color = beautiful.border_normal, + focus = awful.client.focus.filter, + raise = true, + keys = clientkeys, + buttons = clientbuttons, + screen = awful.screen.preferred, + placement = awful.placement.no_overlap + awful.placement.no_offscreen, + }, + }, + + -- Floating clients. + { + rule_any = { + instance = { + "DTA", -- Firefox addon DownThemAll. + "copyq", -- Includes session name in class. + "pinentry", + }, + class = { + "Arandr", + "Blueman-manager", + "Gpick", + "Kruler", + "MessageWin", -- kalarm. + "Sxiv", + "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. + "Wpa_gui", + "veromix", + "xtightvncviewer", + }, + + -- Note that the name property shown in xprop might be set slightly after creation of the client + -- and the name shown there might not match defined rules here. + name = { + "Event Tester", -- xev. + }, + role = { + "AlarmWindow", -- Thunderbird's calendar. + "ConfigManager", -- Thunderbird's about:config. + "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. + }, + }, + properties = { floating = true }, + }, + + -- Add titlebars to normal clients and dialogs + { rule_any = { type = { "normal", "dialog" } }, properties = { titlebars_enabled = true } }, + + -- Set Firefox to always map on the tag named "2" on screen 1. + -- { rule = { class = "Firefox" }, + -- properties = { screen = 1, tag = "2" } }, +} +-- }}} + +-- {{{ Signals +-- Signal function to execute when a new client appears. +client.connect_signal("manage", function(c) + -- Set the windows at the slave, + -- i.e. put it at the end of others instead of setting it master. + -- if not awesome.startup then awful.client.setslave(c) end + + if awesome.startup and not c.size_hints.user_position and not c.size_hints.program_position then + -- Prevent clients from being unreachable after screen count changes. + awful.placement.no_offscreen(c) + end +end) + +-- Add a titlebar if titlebars_enabled is set to true in the rules. +client.connect_signal("request::titlebars", function(c) + -- buttons for the titlebar + local buttons = gears.table.join( + awful.button({}, 1, function() + c:emit_signal("request::activate", "titlebar", { raise = true }) + awful.mouse.client.move(c) + end), + awful.button({}, 3, function() + c:emit_signal("request::activate", "titlebar", { raise = true }) + awful.mouse.client.resize(c) + end) + ) + + awful.titlebar(c):setup({ + { -- Left + awful.titlebar.widget.iconwidget(c), + buttons = buttons, + layout = wibox.layout.fixed.horizontal, + }, + { -- Middle + { -- Title + align = "center", + widget = awful.titlebar.widget.titlewidget(c), + }, + buttons = buttons, + layout = wibox.layout.flex.horizontal, + }, + { -- Right + awful.titlebar.widget.floatingbutton(c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.stickybutton(c), + awful.titlebar.widget.ontopbutton(c), + awful.titlebar.widget.closebutton(c), + layout = wibox.layout.fixed.horizontal(), + }, + layout = wibox.layout.align.horizontal, + }) +end) + +-- Enable sloppy focus, so that focus follows mouse. +client.connect_signal("mouse::enter", function(c) + c:emit_signal("request::activate", "mouse_enter", { raise = false }) +end) + +client.connect_signal("focus", function(c) + c.border_color = beautiful.border_focus +end) +client.connect_signal("unfocus", function(c) + c.border_color = beautiful.border_normal +end) +-- }}} diff --git a/nixos/home.nix b/nixos/home.nix index 5c05a12..5d2d9d8 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -2,6 +2,7 @@ let + name = "Noah Masur"; font = "Victor Mono"; in { @@ -33,7 +34,6 @@ in { tealdeer gh pass - nixfmt ]; programs.alacritty = { @@ -235,12 +235,21 @@ in { "starship.toml".source = ../starship/starship.toml.configlink; "nvim/init.lua".source = ../nvim.configlink/init.lua; "fish/functions".source = ../fish.configlink/functions; - "awesome/rc.lua".source = ./rc.lua; + "awesome/rc.lua".source = ./awesomerc.lua; + }; + + home.file.".direnvrc".text = + "source $HOME/.nix-profile/share/nix-direnv/direnvrc"; + + programs.direnv = { + enable = true; + enableFishIntegration = true; + nix-direnv.enable = true; }; programs.git = { enable = true; - userName = "Noah Masur"; + userName = "${name}"; userEmail = "7386960+nmasur@users.noreply.github.com"; extraConfig = { core = { editor = "nvim"; }; @@ -258,7 +267,7 @@ in { # programs.himalaya = { # enable = true; # settings = { - # name = "Noah Masur"; + # name = "${name}"; # downloads-dir = "~/Downloads"; # home = { # default = true; diff --git a/nixos/rc.lua b/nixos/rc.lua deleted file mode 100644 index b7e8789..0000000 --- a/nixos/rc.lua +++ /dev/null @@ -1,547 +0,0 @@ --- If LuaRocks is installed, make sure that packages installed through it are --- found (e.g. lgi). If LuaRocks is not installed, do nothing. -pcall(require, "luarocks.loader") - --- Standard awesome library -local gears = require("gears") -local awful = require("awful") -require("awful.autofocus") --- Widget and layout library -local wibox = require("wibox") --- Theme handling library -local beautiful = require("beautiful") --- Notification library -local naughty = require("naughty") -local menubar = require("menubar") -local hotkeys_popup = require("awful.hotkeys_popup") --- Enable hotkeys help widget for VIM and other apps --- when client with a matching name is opened: -require("awful.hotkeys_popup.keys") - --- {{{ Variable definitions --- Themes define colours, icons, font and wallpapers. -beautiful.init(gears.filesystem.get_themes_dir() .. "zenburn/theme.lua") - --- This is used later as the default terminal and editor to run. -terminal = "alacritty" -editor = os.getenv("EDITOR") or "vim" -editor_cmd = terminal .. " -e " .. editor - --- Default modkey. --- Usually, Mod4 is the key with a logo between Control and Alt. --- If you do not like this or do not have such a key, --- I suggest you to remap Mod4 to another key using xmodmap or other tools. --- However, you can use another modifier like Mod1, but it may interact with others. -modkey = "Mod4" - --- Table of layouts to cover with awful.layout.inc, order matters. -awful.layout.layouts = { - awful.layout.suit.tile, - awful.layout.suit.floating, - awful.layout.suit.tile.left, - awful.layout.suit.tile.bottom, - awful.layout.suit.tile.top, - awful.layout.suit.fair, - awful.layout.suit.fair.horizontal, - awful.layout.suit.spiral, - awful.layout.suit.spiral.dwindle, - awful.layout.suit.max, - awful.layout.suit.max.fullscreen, - awful.layout.suit.magnifier, - awful.layout.suit.corner.nw, - -- awful.layout.suit.corner.ne, - -- awful.layout.suit.corner.sw, - -- awful.layout.suit.corner.se, -} --- }}} - --- {{{ Menu --- Create a launcher widget and a main menu -myawesomemenu = { - { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, - { "manual", terminal .. " -e man awesome" }, - { "edit config", editor_cmd .. " " .. awesome.conffile }, - { "restart", awesome.restart }, - { "quit", function() awesome.quit() end }, -} - -mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, - { "open terminal", terminal } - } - }) - -mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, - menu = mymainmenu }) - --- Menubar configuration -menubar.utils.terminal = terminal -- Set the terminal for applications that require it --- }}} - --- Keyboard map indicator and switcher -mykeyboardlayout = awful.widget.keyboardlayout() - --- {{{ Wibar --- Create a textclock widget -mytextclock = wibox.widget.textclock() - --- Create a wibox for each screen and add it -local taglist_buttons = gears.table.join( - awful.button({ }, 1, function(t) t:view_only() end), - awful.button({ modkey }, 1, function(t) - if client.focus then - client.focus:move_to_tag(t) - end - end), - awful.button({ }, 3, awful.tag.viewtoggle), - awful.button({ modkey }, 3, function(t) - if client.focus then - client.focus:toggle_tag(t) - end - end), - awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), - awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end) - ) - -local tasklist_buttons = gears.table.join( - awful.button({ }, 1, function (c) - if c == client.focus then - c.minimized = true - else - c:emit_signal( - "request::activate", - "tasklist", - {raise = true} - ) - end - end), - awful.button({ }, 3, function() - awful.menu.client_list({ theme = { width = 250 } }) - end), - awful.button({ }, 4, function () - awful.client.focus.byidx(1) - end), - awful.button({ }, 5, function () - awful.client.focus.byidx(-1) - end)) - -local function set_wallpaper(s) - -- Wallpaper - if beautiful.wallpaper then - local wallpaper = beautiful.wallpaper - -- If wallpaper is a function, call it with the screen - if type(wallpaper) == "function" then - wallpaper = wallpaper(s) - end - gears.wallpaper.maximized(wallpaper, s, true) - end -end - --- Re-set wallpaper when a screen's geometry changes (e.g. different resolution) -screen.connect_signal("property::geometry", set_wallpaper) - -awful.screen.connect_for_each_screen(function(s) - -- Wallpaper - set_wallpaper(s) - - -- Each screen has its own tag table. - awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) - - -- Create a promptbox for each screen - s.mypromptbox = awful.widget.prompt() - -- Create an imagebox widget which will contain an icon indicating which layout we're using. - -- We need one layoutbox per screen. - s.mylayoutbox = awful.widget.layoutbox(s) - s.mylayoutbox:buttons(gears.table.join( - awful.button({ }, 1, function () awful.layout.inc( 1) end), - awful.button({ }, 3, function () awful.layout.inc(-1) end), - awful.button({ }, 4, function () awful.layout.inc( 1) end), - awful.button({ }, 5, function () awful.layout.inc(-1) end))) - -- Create a taglist widget - s.mytaglist = awful.widget.taglist { - screen = s, - filter = awful.widget.taglist.filter.all, - buttons = taglist_buttons - } - - -- Create a tasklist widget - s.mytasklist = awful.widget.tasklist { - screen = s, - filter = awful.widget.tasklist.filter.currenttags, - buttons = tasklist_buttons - } - - -- Create the wibox - s.mywibox = awful.wibar({ position = "top", screen = s }) - - -- Add widgets to the wibox - s.mywibox:setup { - layout = wibox.layout.align.horizontal, - { -- Left widgets - layout = wibox.layout.fixed.horizontal, - mylauncher, - s.mytaglist, - s.mypromptbox, - }, - s.mytasklist, -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - mykeyboardlayout, - wibox.widget.systray(), - mytextclock, - s.mylayoutbox, - }, - } -end) --- }}} - --- {{{ Mouse bindings -root.buttons(gears.table.join( - awful.button({ }, 3, function () mymainmenu:toggle() end), - awful.button({ }, 4, awful.tag.viewnext), - awful.button({ }, 5, awful.tag.viewprev) -)) --- }}} - --- {{{ Key bindings -globalkeys = gears.table.join( - awful.key({ modkey, }, "s", hotkeys_popup.show_help, - {description="show help", group="awesome"}), - awful.key({ modkey, }, "Left", awful.tag.viewprev, - {description = "view previous", group = "tag"}), - awful.key({ modkey, }, "Right", awful.tag.viewnext, - {description = "view next", group = "tag"}), - awful.key({ modkey, }, "Escape", awful.tag.history.restore, - {description = "go back", group = "tag"}), - - awful.key({ modkey, }, "j", - function () - awful.client.focus.byidx( 1) - end, - {description = "focus next by index", group = "client"} - ), - awful.key({ modkey, }, "k", - function () - awful.client.focus.byidx(-1) - end, - {description = "focus previous by index", group = "client"} - ), - awful.key({ modkey, }, "w", function () mymainmenu:show() end, - {description = "show main menu", group = "awesome"}), - - -- Layout manipulation - awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end, - {description = "swap with next client by index", group = "client"}), - awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end, - {description = "swap with previous client by index", group = "client"}), - awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end, - {description = "focus the next screen", group = "screen"}), - awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end, - {description = "focus the previous screen", group = "screen"}), - awful.key({ modkey, }, "u", awful.client.urgent.jumpto, - {description = "jump to urgent client", group = "client"}), - awful.key({ modkey, }, "Tab", - function () - awful.client.focus.history.previous() - if client.focus then - client.focus:raise() - end - end, - {description = "go back", group = "client"}), - - -- Standard program - awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end, - {description = "open a terminal", group = "launcher"}), - awful.key({ modkey, "Control" }, "r", awesome.restart, - {description = "reload awesome", group = "awesome"}), - awful.key({ modkey, "Shift" }, "q", awesome.quit, - {description = "quit awesome", group = "awesome"}), - - awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end, - {description = "increase master width factor", group = "layout"}), - awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end, - {description = "decrease master width factor", group = "layout"}), - awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end, - {description = "increase the number of master clients", group = "layout"}), - awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end, - {description = "decrease the number of master clients", group = "layout"}), - awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end, - {description = "increase the number of columns", group = "layout"}), - awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end, - {description = "decrease the number of columns", group = "layout"}), - awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end, - {description = "select next", group = "layout"}), - awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end, - {description = "select previous", group = "layout"}), - - awful.key({ modkey, "Control" }, "n", - function () - local c = awful.client.restore() - -- Focus restored client - if c then - c:emit_signal( - "request::activate", "key.unminimize", {raise = true} - ) - end - end, - {description = "restore minimized", group = "client"}), - - -- Prompt - awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end, - {description = "run prompt", group = "launcher"}), - - awful.key({ modkey }, "x", - function () - awful.prompt.run { - prompt = "Run Lua code: ", - textbox = awful.screen.focused().mypromptbox.widget, - exe_callback = awful.util.eval, - history_path = awful.util.get_cache_dir() .. "/history_eval" - } - end, - {description = "lua execute prompt", group = "awesome"}), - -- Menubar - awful.key({ modkey }, "p", function() menubar.show() end, - {description = "show the menubar", group = "launcher"}), - - -- Volume - awful.key({}, "XF86AudioLowerVolume", function() - awful.spawn "pamixer -d 2" - end), - awful.key({}, "XF86AudioRaiseVolume", function() - awful.spawn "pamixer -i 2" - end) -) - -clientkeys = gears.table.join( - awful.key({ modkey, }, "f", - function (c) - c.fullscreen = not c.fullscreen - c:raise() - end, - {description = "toggle fullscreen", group = "client"}), - awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end, - {description = "close", group = "client"}), - awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle , - {description = "toggle floating", group = "client"}), - awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end, - {description = "move to master", group = "client"}), - awful.key({ modkey, }, "o", function (c) c:move_to_screen() end, - {description = "move to screen", group = "client"}), - awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end, - {description = "toggle keep on top", group = "client"}), - awful.key({ modkey, }, "n", - function (c) - -- The client currently has the input focus, so it cannot be - -- minimized, since minimized clients can't have the focus. - c.minimized = true - end , - {description = "minimize", group = "client"}), - awful.key({ modkey, }, "m", - function (c) - c.maximized = not c.maximized - c:raise() - end , - {description = "(un)maximize", group = "client"}), - awful.key({ modkey, "Control" }, "m", - function (c) - c.maximized_vertical = not c.maximized_vertical - c:raise() - end , - {description = "(un)maximize vertically", group = "client"}), - awful.key({ modkey, "Shift" }, "m", - function (c) - c.maximized_horizontal = not c.maximized_horizontal - c:raise() - end , - {description = "(un)maximize horizontally", group = "client"}) -) - --- Bind all key numbers to tags. --- Be careful: we use keycodes to make it work on any keyboard layout. --- This should map on the top row of your keyboard, usually 1 to 9. -for i = 1, 9 do - globalkeys = gears.table.join(globalkeys, - -- View tag only. - awful.key({ modkey }, "#" .. i + 9, - function () - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - tag:view_only() - end - end, - {description = "view tag #"..i, group = "tag"}), - -- Toggle tag display. - awful.key({ modkey, "Control" }, "#" .. i + 9, - function () - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - awful.tag.viewtoggle(tag) - end - end, - {description = "toggle tag #" .. i, group = "tag"}), - -- Move client to tag. - awful.key({ modkey, "Shift" }, "#" .. i + 9, - function () - if client.focus then - local tag = client.focus.screen.tags[i] - if tag then - client.focus:move_to_tag(tag) - end - end - end, - {description = "move focused client to tag #"..i, group = "tag"}), - -- Toggle tag on focused client. - awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, - function () - if client.focus then - local tag = client.focus.screen.tags[i] - if tag then - client.focus:toggle_tag(tag) - end - end - end, - {description = "toggle focused client on tag #" .. i, group = "tag"}) - ) -end - -clientbuttons = gears.table.join( - awful.button({ }, 1, function (c) - c:emit_signal("request::activate", "mouse_click", {raise = true}) - end), - awful.button({ modkey }, 1, function (c) - c:emit_signal("request::activate", "mouse_click", {raise = true}) - awful.mouse.client.move(c) - end), - awful.button({ modkey }, 3, function (c) - c:emit_signal("request::activate", "mouse_click", {raise = true}) - awful.mouse.client.resize(c) - end) -) - --- Set keys -root.keys(globalkeys) --- }}} - --- {{{ Rules --- Rules to apply to new clients (through the "manage" signal). -awful.rules.rules = { - -- All clients will match this rule. - { rule = { }, - properties = { border_width = beautiful.border_width, - border_color = beautiful.border_normal, - focus = awful.client.focus.filter, - raise = true, - keys = clientkeys, - buttons = clientbuttons, - screen = awful.screen.preferred, - placement = awful.placement.no_overlap+awful.placement.no_offscreen - } - }, - - -- Floating clients. - { rule_any = { - instance = { - "DTA", -- Firefox addon DownThemAll. - "copyq", -- Includes session name in class. - "pinentry", - }, - class = { - "Arandr", - "Blueman-manager", - "Gpick", - "Kruler", - "MessageWin", -- kalarm. - "Sxiv", - "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. - "Wpa_gui", - "veromix", - "xtightvncviewer"}, - - -- Note that the name property shown in xprop might be set slightly after creation of the client - -- and the name shown there might not match defined rules here. - name = { - "Event Tester", -- xev. - }, - role = { - "AlarmWindow", -- Thunderbird's calendar. - "ConfigManager", -- Thunderbird's about:config. - "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. - } - }, properties = { floating = true }}, - - -- Add titlebars to normal clients and dialogs - { rule_any = {type = { "normal", "dialog" } - }, properties = { titlebars_enabled = true } - }, - - -- Set Firefox to always map on the tag named "2" on screen 1. - -- { rule = { class = "Firefox" }, - -- properties = { screen = 1, tag = "2" } }, -} --- }}} - --- {{{ Signals --- Signal function to execute when a new client appears. -client.connect_signal("manage", function (c) - -- Set the windows at the slave, - -- i.e. put it at the end of others instead of setting it master. - -- if not awesome.startup then awful.client.setslave(c) end - - if awesome.startup - and not c.size_hints.user_position - and not c.size_hints.program_position then - -- Prevent clients from being unreachable after screen count changes. - awful.placement.no_offscreen(c) - end -end) - --- Add a titlebar if titlebars_enabled is set to true in the rules. -client.connect_signal("request::titlebars", function(c) - -- buttons for the titlebar - local buttons = gears.table.join( - awful.button({ }, 1, function() - c:emit_signal("request::activate", "titlebar", {raise = true}) - awful.mouse.client.move(c) - end), - awful.button({ }, 3, function() - c:emit_signal("request::activate", "titlebar", {raise = true}) - awful.mouse.client.resize(c) - end) - ) - - awful.titlebar(c) : setup { - { -- Left - awful.titlebar.widget.iconwidget(c), - buttons = buttons, - layout = wibox.layout.fixed.horizontal - }, - { -- Middle - { -- Title - align = "center", - widget = awful.titlebar.widget.titlewidget(c) - }, - buttons = buttons, - layout = wibox.layout.flex.horizontal - }, - { -- Right - awful.titlebar.widget.floatingbutton (c), - awful.titlebar.widget.maximizedbutton(c), - awful.titlebar.widget.stickybutton (c), - awful.titlebar.widget.ontopbutton (c), - awful.titlebar.widget.closebutton (c), - layout = wibox.layout.fixed.horizontal() - }, - layout = wibox.layout.align.horizontal - } -end) - --- Enable sloppy focus, so that focus follows mouse. -client.connect_signal("mouse::enter", function(c) - c:emit_signal("request::activate", "mouse_enter", {raise = false}) -end) - -client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) -client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) --- }}} diff --git a/nixos/shell.nix b/nixos/shell.nix new file mode 100644 index 0000000..5c8b10f --- /dev/null +++ b/nixos/shell.nix @@ -0,0 +1,4 @@ +{ pkgs ? import { } }: +pkgs.mkShell { + nativeBuildInputs = [ pkgs.buildPackages.stylua pkgs.buildPackages.nixfmt ]; +} From 8c167a0367815302a809f39ce4996ce42ce7b51c Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Jan 2022 14:55:22 -0500 Subject: [PATCH 27/35] fix hyphen abbreviation --- nixos/home.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/home.nix b/nixos/home.nix index 5d2d9d8..2b66331 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -107,7 +107,7 @@ in { ll = "ls -alhF"; lf = "ls -lh | fzf"; c = "cd"; - # -- - = "cd -"; + "-" = "cd -"; mkd = "mkdir -pv"; # Tmux From 215e5157ab1c7414cd2acbc49b71f331bfbd5abf Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Jan 2022 15:57:46 -0500 Subject: [PATCH 28/35] remove flakes experiment --- nixos/flakes/flake.nix | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 nixos/flakes/flake.nix diff --git a/nixos/flakes/flake.nix b/nixos/flakes/flake.nix deleted file mode 100644 index 619f45d..0000000 --- a/nixos/flakes/flake.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - description = "System Config"; - - inputs = { - nixpkgs.url = "nixpkgs/nixos-21.05"; - home-manager.url = "github:nix-community/home-manager/release-21.05"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - }; - - outputs = { nixpkgs, home-manager, ... }: { - let - system = "x86_64-linux"; - - pkgs = import nixpkgs { - inherit system; - config = { allowUnfree = true; }; - }; - - lib = nixpkgs.lib; - - in { - nixosConfigurations = { - nixos = lib.nixosSystem { - inherit system; - modules = [ - ./configuration.nix - ] - }; - }; - }; -} From d49dbebf9d624c4321a0b9eb58f063bbe45044d6 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Jan 2022 15:58:20 -0500 Subject: [PATCH 29/35] vi mode and direnv updates --- nixos/home.nix | 38 +++++++++++++++++++++++++++----------- nixos/justfile | 8 ++++++++ 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/nixos/home.nix b/nixos/home.nix index 2b66331..dd9171c 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -3,6 +3,7 @@ let name = "Noah Masur"; + editor = "nvim"; font = "Victor Mono"; in { @@ -54,11 +55,24 @@ in { size = 14.0; normal = { family = "${font}"; }; }; - key_bindings = [{ - key = "L"; - mods = "Control|Shift"; - chars = "\\x1F"; - }]; + key_bindings = [ + { + key = "L"; + mods = "Control|Shift"; + chars = "\\x1F"; + } + { + key = "K"; + mods = "Control"; + mode = "~Vi"; + action = "ToggleViMode"; + } + { + key = "Return"; + mode = "Vi"; + action = "ToggleViMode"; + } + ]; colors = { primary = { background = "0x1d2021"; @@ -98,7 +112,10 @@ in { functions = { }; interactiveShellInit = ""; loginShellInit = ""; - shellAliases = { vim = "nvim"; }; + shellAliases = { + vim = "nvim"; + sudo = "doas"; + }; shellAbbrs = { # Directory aliases @@ -155,7 +172,7 @@ in { v = "vim"; vl = "vim -c 'normal! `0'"; vll = "vim -c 'Telescope oldfiles'"; - vimrc = "vim ~/dev/personal/dotfiles/nvim.configlink/init.lua"; + vimrc = "vim ${builtins.getEnv "PWD"}/../nvim.configlink/init.lua"; # Notes qn = "quicknote"; @@ -210,7 +227,7 @@ in { home.sessionVariables = { fish_greeting = ""; - EDITOR = "nvim"; + EDITOR = "${editor}"; NIXOS_CONFIG = builtins.getEnv "PWD"; DOTS = "${builtins.getEnv "PWD"}/.."; }; @@ -236,15 +253,14 @@ in { "nvim/init.lua".source = ../nvim.configlink/init.lua; "fish/functions".source = ../fish.configlink/functions; "awesome/rc.lua".source = ./awesomerc.lua; + "direnvrc".text = "source $HOME/.nix-profile/share/nix-direnv/direnvrc"; }; - home.file.".direnvrc".text = - "source $HOME/.nix-profile/share/nix-direnv/direnvrc"; - programs.direnv = { enable = true; enableFishIntegration = true; nix-direnv.enable = true; + config = { whitelist = { prefix = [ "${builtins.getEnv "PWD"}/" ]; }; }; }; programs.git = { diff --git a/nixos/justfile b/nixos/justfile index af83d3f..ff31cfd 100644 --- a/nixos/justfile +++ b/nixos/justfile @@ -2,6 +2,14 @@ default: @just --list --list-heading $'Update NixOS config:\n' +# Bootstrap from nothing +bootstrap: + sudo nix-channel --add https://nixos.org/channels/nixos-unstable + sudo nix-channel --add https://nixos.org/channels/nixpkgs-unstable + sudo nix-channel --update + sudo nixos-rebuild switch -I nixos-config=./configuration.nix + +# Use intended software channels channels: doas nix-channel --add https://nixos.org/channels/nixos-unstable doas nix-channel --add https://nixos.org/channels/nixpkgs-unstable From 7d52ec72865966247fae12ed59c7bec8489877a9 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Jan 2022 17:19:32 -0500 Subject: [PATCH 30/35] move to make, change formatting, break everything --- .stylua.toml | 1 + nixos/.envrc | 1 - nixos/Makefile | 27 ++ nixos/awesomerc.lua | 834 ++++++++++++++++++++-------------------- nixos/configuration.nix | 1 - nixos/default.nix | 1 + nixos/home.nix | 14 +- nixos/justfile | 24 -- nixos/shell.nix | 4 - 9 files changed, 454 insertions(+), 453 deletions(-) create mode 100644 .stylua.toml delete mode 100644 nixos/.envrc create mode 100644 nixos/Makefile create mode 100644 nixos/default.nix delete mode 100644 nixos/justfile delete mode 100644 nixos/shell.nix diff --git a/.stylua.toml b/.stylua.toml new file mode 100644 index 0000000..394e884 --- /dev/null +++ b/.stylua.toml @@ -0,0 +1 @@ +indent_type = "Spaces" diff --git a/nixos/.envrc b/nixos/.envrc deleted file mode 100644 index 1d953f4..0000000 --- a/nixos/.envrc +++ /dev/null @@ -1 +0,0 @@ -use nix diff --git a/nixos/Makefile b/nixos/Makefile new file mode 100644 index 0000000..32f88e7 --- /dev/null +++ b/nixos/Makefile @@ -0,0 +1,27 @@ +# Show these options +default: + @echo "sudo make bootstrap -- Install from scratch" + @echo "make channels -- Set intended software channels" + @echo "make system -- Update system config" + @echo "make home -- Update home config" + +# Bootstrap from nothing +bootstrap: + nix-channel --add https://nixos.org/channels/nixos-unstable + nix-channel --add https://nixos.org/channels/nixpkgs-unstable + nix-channel --update + nixos-rebuild switch -I nixos-config=./configuration.nix + +# Use intended software channels +channels: + doas nix-channel --add https://nixos.org/channels/nixos-unstable + doas nix-channel --add https://nixos.org/channels/nixpkgs-unstable + doas nix-channel --update + +# Update the system +system: + doas nixos-rebuild switch -I nixos-config=./configuration.nix + +# Update the user environment +home: + home-manager switch -f ./home.nix diff --git a/nixos/awesomerc.lua b/nixos/awesomerc.lua index 3a452e3..a8de26f 100644 --- a/nixos/awesomerc.lua +++ b/nixos/awesomerc.lua @@ -36,50 +36,50 @@ modkey = "Mod4" -- Table of layouts to cover with awful.layout.inc, order matters. awful.layout.layouts = { - awful.layout.suit.tile, - awful.layout.suit.floating, - -- awful.layout.suit.tile.left, - -- awful.layout.suit.tile.bottom, - -- awful.layout.suit.tile.top, - -- awful.layout.suit.fair, - -- awful.layout.suit.fair.horizontal, - -- awful.layout.suit.spiral, - -- awful.layout.suit.spiral.dwindle, - -- awful.layout.suit.max, - -- awful.layout.suit.max.fullscreen, - -- awful.layout.suit.magnifier, - -- awful.layout.suit.corner.nw, - -- awful.layout.suit.corner.ne, - -- awful.layout.suit.corner.sw, - -- awful.layout.suit.corner.se, + awful.layout.suit.tile, + awful.layout.suit.floating, + -- awful.layout.suit.tile.left, + -- awful.layout.suit.tile.bottom, + -- awful.layout.suit.tile.top, + -- awful.layout.suit.fair, + -- awful.layout.suit.fair.horizontal, + -- awful.layout.suit.spiral, + -- awful.layout.suit.spiral.dwindle, + -- awful.layout.suit.max, + -- awful.layout.suit.max.fullscreen, + -- awful.layout.suit.magnifier, + -- awful.layout.suit.corner.nw, + -- awful.layout.suit.corner.ne, + -- awful.layout.suit.corner.sw, + -- awful.layout.suit.corner.se, } -- }}} -- {{{ Menu -- Create a launcher widget and a main menu myawesomemenu = { - { - "hotkeys", - function() - hotkeys_popup.show_help(nil, awful.screen.focused()) - end, - }, - { "manual", terminal .. " -e man awesome" }, - { "edit config", editor_cmd .. " " .. awesome.conffile }, - { "restart", awesome.restart }, - { - "quit", - function() - awesome.quit() - end, - }, + { + "hotkeys", + function() + hotkeys_popup.show_help(nil, awful.screen.focused()) + end, + }, + { "manual", terminal .. " -e man awesome" }, + { "edit config", editor_cmd .. " " .. awesome.conffile }, + { "restart", awesome.restart }, + { + "quit", + function() + awesome.quit() + end, + }, } mymainmenu = awful.menu({ - items = { - { "awesome", myawesomemenu, beautiful.awesome_icon }, - { "open terminal", terminal }, - }, + items = { + { "awesome", myawesomemenu, beautiful.awesome_icon }, + { "open terminal", terminal }, + }, }) mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu }) @@ -97,338 +97,338 @@ mytextclock = wibox.widget.textclock() -- Create a wibox for each screen and add it local taglist_buttons = gears.table.join( - awful.button({}, 1, function(t) - t:view_only() - end), - awful.button({ modkey }, 1, function(t) - if client.focus then - client.focus:move_to_tag(t) - end - end), - awful.button({}, 3, awful.tag.viewtoggle), - awful.button({ modkey }, 3, function(t) - if client.focus then - client.focus:toggle_tag(t) - end - end), - awful.button({}, 4, function(t) - awful.tag.viewnext(t.screen) - end), - awful.button({}, 5, function(t) - awful.tag.viewprev(t.screen) - end) + awful.button({}, 1, function(t) + t:view_only() + end), + awful.button({ modkey }, 1, function(t) + if client.focus then + client.focus:move_to_tag(t) + end + end), + awful.button({}, 3, awful.tag.viewtoggle), + awful.button({ modkey }, 3, function(t) + if client.focus then + client.focus:toggle_tag(t) + end + end), + awful.button({}, 4, function(t) + awful.tag.viewnext(t.screen) + end), + awful.button({}, 5, function(t) + awful.tag.viewprev(t.screen) + end) ) local tasklist_buttons = gears.table.join( - awful.button({}, 1, function(c) - if c == client.focus then - c.minimized = true - else - c:emit_signal("request::activate", "tasklist", { raise = true }) - end - end), - awful.button({}, 3, function() - awful.menu.client_list({ theme = { width = 250 } }) - end), - awful.button({}, 4, function() - awful.client.focus.byidx(1) - end), - awful.button({}, 5, function() - awful.client.focus.byidx(-1) - end) + awful.button({}, 1, function(c) + if c == client.focus then + c.minimized = true + else + c:emit_signal("request::activate", "tasklist", { raise = true }) + end + end), + awful.button({}, 3, function() + awful.menu.client_list({ theme = { width = 250 } }) + end), + awful.button({}, 4, function() + awful.client.focus.byidx(1) + end), + awful.button({}, 5, function() + awful.client.focus.byidx(-1) + end) ) local function set_wallpaper(s) - -- Wallpaper - if beautiful.wallpaper then - local wallpaper = beautiful.wallpaper - -- If wallpaper is a function, call it with the screen - if type(wallpaper) == "function" then - wallpaper = wallpaper(s) - end - gears.wallpaper.maximized(wallpaper, s, true) - end + -- Wallpaper + if beautiful.wallpaper then + local wallpaper = beautiful.wallpaper + -- If wallpaper is a function, call it with the screen + if type(wallpaper) == "function" then + wallpaper = wallpaper(s) + end + gears.wallpaper.maximized(wallpaper, s, true) + end end -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution) screen.connect_signal("property::geometry", set_wallpaper) awful.screen.connect_for_each_screen(function(s) - -- Wallpaper - set_wallpaper(s) + -- Wallpaper + set_wallpaper(s) - -- Each screen has its own tag table. - awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) + -- Each screen has its own tag table. + awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) - -- Create a promptbox for each screen - s.mypromptbox = awful.widget.prompt() - -- Create an imagebox widget which will contain an icon indicating which layout we're using. - -- We need one layoutbox per screen. - s.mylayoutbox = awful.widget.layoutbox(s) - s.mylayoutbox:buttons(gears.table.join( - awful.button({}, 1, function() - awful.layout.inc(1) - end), - awful.button({}, 3, function() - awful.layout.inc(-1) - end), - awful.button({}, 4, function() - awful.layout.inc(1) - end), - awful.button({}, 5, function() - awful.layout.inc(-1) - end) - )) - -- Create a taglist widget - s.mytaglist = awful.widget.taglist({ - screen = s, - filter = awful.widget.taglist.filter.all, - buttons = taglist_buttons, - }) + -- Create a promptbox for each screen + s.mypromptbox = awful.widget.prompt() + -- Create an imagebox widget which will contain an icon indicating which layout we're using. + -- We need one layoutbox per screen. + s.mylayoutbox = awful.widget.layoutbox(s) + s.mylayoutbox:buttons(gears.table.join( + awful.button({}, 1, function() + awful.layout.inc(1) + end), + awful.button({}, 3, function() + awful.layout.inc(-1) + end), + awful.button({}, 4, function() + awful.layout.inc(1) + end), + awful.button({}, 5, function() + awful.layout.inc(-1) + end) + )) + -- Create a taglist widget + s.mytaglist = awful.widget.taglist({ + screen = s, + filter = awful.widget.taglist.filter.all, + buttons = taglist_buttons, + }) - -- Create a tasklist widget - s.mytasklist = awful.widget.tasklist({ - screen = s, - filter = awful.widget.tasklist.filter.currenttags, - buttons = tasklist_buttons, - }) + -- Create a tasklist widget + s.mytasklist = awful.widget.tasklist({ + screen = s, + filter = awful.widget.tasklist.filter.currenttags, + buttons = tasklist_buttons, + }) - -- Create the wibox - s.mywibox = awful.wibar({ position = "top", screen = s }) + -- Create the wibox + s.mywibox = awful.wibar({ position = "top", screen = s }) - -- Add widgets to the wibox - s.mywibox:setup({ - layout = wibox.layout.align.horizontal, - { -- Left widgets - layout = wibox.layout.fixed.horizontal, - mylauncher, - s.mytaglist, - s.mypromptbox, - }, - s.mytasklist, -- Middle widget - { -- Right widgets - layout = wibox.layout.fixed.horizontal, - mykeyboardlayout, - wibox.widget.systray(), - mytextclock, - s.mylayoutbox, - }, - }) + -- Add widgets to the wibox + s.mywibox:setup({ + layout = wibox.layout.align.horizontal, + { -- Left widgets + layout = wibox.layout.fixed.horizontal, + mylauncher, + s.mytaglist, + s.mypromptbox, + }, + s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + mykeyboardlayout, + wibox.widget.systray(), + mytextclock, + s.mylayoutbox, + }, + }) end) -- }}} -- {{{ Mouse bindings root.buttons(gears.table.join( - awful.button({}, 3, function() - mymainmenu:toggle() - end), - awful.button({}, 4, awful.tag.viewnext), - awful.button({}, 5, awful.tag.viewprev) + awful.button({}, 3, function() + mymainmenu:toggle() + end), + awful.button({}, 4, awful.tag.viewnext), + awful.button({}, 5, awful.tag.viewprev) )) -- }}} -- {{{ Key bindings globalkeys = gears.table.join( - awful.key({ modkey }, "s", hotkeys_popup.show_help, { description = "show help", group = "awesome" }), - awful.key({ modkey }, "Left", awful.tag.viewprev, { description = "view previous", group = "tag" }), - awful.key({ modkey }, "Right", awful.tag.viewnext, { description = "view next", group = "tag" }), - awful.key({ modkey }, "Escape", awful.tag.history.restore, { description = "go back", group = "tag" }), + awful.key({ modkey }, "s", hotkeys_popup.show_help, { description = "show help", group = "awesome" }), + awful.key({ modkey }, "Left", awful.tag.viewprev, { description = "view previous", group = "tag" }), + awful.key({ modkey }, "Right", awful.tag.viewnext, { description = "view next", group = "tag" }), + awful.key({ modkey }, "Escape", awful.tag.history.restore, { description = "go back", group = "tag" }), - awful.key({ modkey }, "j", function() - awful.client.focus.byidx(1) - end, { description = "focus next by index", group = "client" }), - awful.key({ modkey }, "k", function() - awful.client.focus.byidx(-1) - end, { description = "focus previous by index", group = "client" }), - awful.key({ modkey }, "w", function() - mymainmenu:show() - end, { description = "show main menu", group = "awesome" }), + awful.key({ modkey }, "j", function() + awful.client.focus.byidx(1) + end, { description = "focus next by index", group = "client" }), + awful.key({ modkey }, "k", function() + awful.client.focus.byidx(-1) + end, { description = "focus previous by index", group = "client" }), + awful.key({ modkey }, "w", function() + mymainmenu:show() + end, { description = "show main menu", group = "awesome" }), - -- Layout manipulation - awful.key({ modkey, "Shift" }, "j", function() - awful.client.swap.byidx(1) - end, { description = "swap with next client by index", group = "client" }), - awful.key({ modkey, "Shift" }, "k", function() - awful.client.swap.byidx(-1) - end, { description = "swap with previous client by index", group = "client" }), - awful.key({ modkey, "Control" }, "j", function() - awful.screen.focus_relative(1) - end, { description = "focus the next screen", group = "screen" }), - awful.key({ modkey, "Control" }, "k", function() - awful.screen.focus_relative(-1) - end, { description = "focus the previous screen", group = "screen" }), - awful.key({ modkey }, "u", awful.client.urgent.jumpto, { description = "jump to urgent client", group = "client" }), - awful.key({ modkey }, "Tab", function() - awful.client.focus.history.previous() - if client.focus then - client.focus:raise() - end - end, { description = "go back", group = "client" }), + -- Layout manipulation + awful.key({ modkey, "Shift" }, "j", function() + awful.client.swap.byidx(1) + end, { description = "swap with next client by index", group = "client" }), + awful.key({ modkey, "Shift" }, "k", function() + awful.client.swap.byidx(-1) + end, { description = "swap with previous client by index", group = "client" }), + awful.key({ modkey, "Control" }, "j", function() + awful.screen.focus_relative(1) + end, { description = "focus the next screen", group = "screen" }), + awful.key({ modkey, "Control" }, "k", function() + awful.screen.focus_relative(-1) + end, { description = "focus the previous screen", group = "screen" }), + awful.key({ modkey }, "u", awful.client.urgent.jumpto, { description = "jump to urgent client", group = "client" }), + awful.key({ modkey }, "Tab", function() + awful.client.focus.history.previous() + if client.focus then + client.focus:raise() + end + end, { description = "go back", group = "client" }), - -- Standard program - awful.key({ modkey }, "Return", function() - awful.spawn(terminal) - end, { description = "open a terminal", group = "launcher" }), - awful.key({ modkey, "Control" }, "r", awesome.restart, { description = "reload awesome", group = "awesome" }), - awful.key({ modkey, "Shift" }, "q", awesome.quit, { description = "quit awesome", group = "awesome" }), + -- Standard program + awful.key({ modkey }, "Return", function() + awful.spawn(terminal) + end, { description = "open a terminal", group = "launcher" }), + awful.key({ modkey, "Control" }, "r", awesome.restart, { description = "reload awesome", group = "awesome" }), + awful.key({ modkey, "Shift" }, "q", awesome.quit, { description = "quit awesome", group = "awesome" }), - awful.key({ modkey }, "l", function() - awful.tag.incmwfact(0.05) - end, { description = "increase master width factor", group = "layout" }), - awful.key({ modkey }, "h", function() - awful.tag.incmwfact(-0.05) - end, { description = "decrease master width factor", group = "layout" }), - awful.key({ modkey, "Shift" }, "h", function() - awful.tag.incnmaster(1, nil, true) - end, { description = "increase the number of master clients", group = "layout" }), - awful.key({ modkey, "Shift" }, "l", function() - awful.tag.incnmaster(-1, nil, true) - end, { description = "decrease the number of master clients", group = "layout" }), - awful.key({ modkey, "Control" }, "h", function() - awful.tag.incncol(1, nil, true) - end, { description = "increase the number of columns", group = "layout" }), - awful.key({ modkey, "Control" }, "l", function() - awful.tag.incncol(-1, nil, true) - end, { description = "decrease the number of columns", group = "layout" }), - awful.key({ modkey }, "space", function() - awful.layout.inc(1) - end, { description = "select next", group = "layout" }), - awful.key({ modkey, "Shift" }, "space", function() - awful.layout.inc(-1) - end, { description = "select previous", group = "layout" }), + awful.key({ modkey }, "l", function() + awful.tag.incmwfact(0.05) + end, { description = "increase master width factor", group = "layout" }), + awful.key({ modkey }, "h", function() + awful.tag.incmwfact(-0.05) + end, { description = "decrease master width factor", group = "layout" }), + awful.key({ modkey, "Shift" }, "h", function() + awful.tag.incnmaster(1, nil, true) + end, { description = "increase the number of master clients", group = "layout" }), + awful.key({ modkey, "Shift" }, "l", function() + awful.tag.incnmaster(-1, nil, true) + end, { description = "decrease the number of master clients", group = "layout" }), + awful.key({ modkey, "Control" }, "h", function() + awful.tag.incncol(1, nil, true) + end, { description = "increase the number of columns", group = "layout" }), + awful.key({ modkey, "Control" }, "l", function() + awful.tag.incncol(-1, nil, true) + end, { description = "decrease the number of columns", group = "layout" }), + awful.key({ modkey }, "space", function() + awful.layout.inc(1) + end, { description = "select next", group = "layout" }), + awful.key({ modkey, "Shift" }, "space", function() + awful.layout.inc(-1) + end, { description = "select previous", group = "layout" }), - awful.key({ modkey, "Control" }, "n", function() - local c = awful.client.restore() - -- Focus restored client - if c then - c:emit_signal("request::activate", "key.unminimize", { raise = true }) - end - end, { description = "restore minimized", group = "client" }), + awful.key({ modkey, "Control" }, "n", function() + local c = awful.client.restore() + -- Focus restored client + if c then + c:emit_signal("request::activate", "key.unminimize", { raise = true }) + end + end, { description = "restore minimized", group = "client" }), - -- Prompt - awful.key({ modkey }, "r", function() - awful.screen.focused().mypromptbox:run() - end, { description = "run prompt", group = "launcher" }), + -- Prompt + awful.key({ modkey }, "r", function() + awful.screen.focused().mypromptbox:run() + end, { description = "run prompt", group = "launcher" }), - awful.key({ modkey }, "x", function() - awful.prompt.run({ - prompt = "Run Lua code: ", - textbox = awful.screen.focused().mypromptbox.widget, - exe_callback = awful.util.eval, - history_path = awful.util.get_cache_dir() .. "/history_eval", - }) - end, { description = "lua execute prompt", group = "awesome" }), - -- Menubar - awful.key({ modkey }, "p", function() - menubar.show() - end, { description = "show the menubar", group = "launcher" }), + awful.key({ modkey }, "x", function() + awful.prompt.run({ + prompt = "Run Lua code: ", + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = awful.util.eval, + history_path = awful.util.get_cache_dir() .. "/history_eval", + }) + end, { description = "lua execute prompt", group = "awesome" }), + -- Menubar + awful.key({ modkey }, "p", function() + menubar.show() + end, { description = "show the menubar", group = "launcher" }), - -- Volume - awful.key({}, "XF86AudioLowerVolume", function() - awful.spawn("pamixer -d 2") - end), - awful.key({}, "XF86AudioRaiseVolume", function() - awful.spawn("pamixer -i 2") - end) + -- Volume + awful.key({}, "XF86AudioLowerVolume", function() + awful.spawn("pamixer -d 2") + end), + awful.key({}, "XF86AudioRaiseVolume", function() + awful.spawn("pamixer -i 2") + end) ) clientkeys = gears.table.join( - awful.key({ modkey }, "f", function(c) - c.fullscreen = not c.fullscreen - c:raise() - end, { description = "toggle fullscreen", group = "client" }), - awful.key({ modkey, "Shift" }, "c", function(c) - c:kill() - end, { description = "close", group = "client" }), - awful.key( - { modkey, "Control" }, - "space", - awful.client.floating.toggle, - { description = "toggle floating", group = "client" } - ), - awful.key({ modkey, "Control" }, "Return", function(c) - c:swap(awful.client.getmaster()) - end, { description = "move to master", group = "client" }), - awful.key({ modkey }, "o", function(c) - c:move_to_screen() - end, { description = "move to screen", group = "client" }), - awful.key({ modkey }, "t", function(c) - c.ontop = not c.ontop - end, { description = "toggle keep on top", group = "client" }), - awful.key({ modkey }, "n", function(c) - -- The client currently has the input focus, so it cannot be - -- minimized, since minimized clients can't have the focus. - c.minimized = true - end, { description = "minimize", group = "client" }), - awful.key({ modkey }, "m", function(c) - c.maximized = not c.maximized - c:raise() - end, { description = "(un)maximize", group = "client" }), - awful.key({ modkey, "Control" }, "m", function(c) - c.maximized_vertical = not c.maximized_vertical - c:raise() - end, { description = "(un)maximize vertically", group = "client" }), - awful.key({ modkey, "Shift" }, "m", function(c) - c.maximized_horizontal = not c.maximized_horizontal - c:raise() - end, { description = "(un)maximize horizontally", group = "client" }) + awful.key({ modkey }, "f", function(c) + c.fullscreen = not c.fullscreen + c:raise() + end, { description = "toggle fullscreen", group = "client" }), + awful.key({ modkey, "Shift" }, "c", function(c) + c:kill() + end, { description = "close", group = "client" }), + awful.key( + { modkey, "Control" }, + "space", + awful.client.floating.toggle, + { description = "toggle floating", group = "client" } + ), + awful.key({ modkey, "Control" }, "Return", function(c) + c:swap(awful.client.getmaster()) + end, { description = "move to master", group = "client" }), + awful.key({ modkey }, "o", function(c) + c:move_to_screen() + end, { description = "move to screen", group = "client" }), + awful.key({ modkey }, "t", function(c) + c.ontop = not c.ontop + end, { description = "toggle keep on top", group = "client" }), + awful.key({ modkey }, "n", function(c) + -- The client currently has the input focus, so it cannot be + -- minimized, since minimized clients can't have the focus. + c.minimized = true + end, { description = "minimize", group = "client" }), + awful.key({ modkey }, "m", function(c) + c.maximized = not c.maximized + c:raise() + end, { description = "(un)maximize", group = "client" }), + awful.key({ modkey, "Control" }, "m", function(c) + c.maximized_vertical = not c.maximized_vertical + c:raise() + end, { description = "(un)maximize vertically", group = "client" }), + awful.key({ modkey, "Shift" }, "m", function(c) + c.maximized_horizontal = not c.maximized_horizontal + c:raise() + end, { description = "(un)maximize horizontally", group = "client" }) ) -- Bind all key numbers to tags. -- Be careful: we use keycodes to make it work on any keyboard layout. -- This should map on the top row of your keyboard, usually 1 to 9. for i = 1, 9 do - globalkeys = gears.table.join( - globalkeys, - -- View tag only. - awful.key({ modkey }, "#" .. i + 9, function() - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - tag:view_only() - end - end, { description = "view tag #" .. i, group = "tag" }), - -- Toggle tag display. - awful.key({ modkey, "Control" }, "#" .. i + 9, function() - local screen = awful.screen.focused() - local tag = screen.tags[i] - if tag then - awful.tag.viewtoggle(tag) - end - end, { description = "toggle tag #" .. i, group = "tag" }), - -- Move client to tag. - awful.key({ modkey, "Shift" }, "#" .. i + 9, function() - if client.focus then - local tag = client.focus.screen.tags[i] - if tag then - client.focus:move_to_tag(tag) - end - end - end, { description = "move focused client to tag #" .. i, group = "tag" }), - -- Toggle tag on focused client. - awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function() - if client.focus then - local tag = client.focus.screen.tags[i] - if tag then - client.focus:toggle_tag(tag) - end - end - end, { description = "toggle focused client on tag #" .. i, group = "tag" }) - ) + globalkeys = gears.table.join( + globalkeys, + -- View tag only. + awful.key({ modkey }, "#" .. i + 9, function() + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + tag:view_only() + end + end, { description = "view tag #" .. i, group = "tag" }), + -- Toggle tag display. + awful.key({ modkey, "Control" }, "#" .. i + 9, function() + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) + end + end, { description = "toggle tag #" .. i, group = "tag" }), + -- Move client to tag. + awful.key({ modkey, "Shift" }, "#" .. i + 9, function() + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:move_to_tag(tag) + end + end + end, { description = "move focused client to tag #" .. i, group = "tag" }), + -- Toggle tag on focused client. + awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function() + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:toggle_tag(tag) + end + end + end, { description = "toggle focused client on tag #" .. i, group = "tag" }) + ) end clientbuttons = gears.table.join( - awful.button({}, 1, function(c) - c:emit_signal("request::activate", "mouse_click", { raise = true }) - end), - awful.button({ modkey }, 1, function(c) - c:emit_signal("request::activate", "mouse_click", { raise = true }) - awful.mouse.client.move(c) - end), - awful.button({ modkey }, 3, function(c) - c:emit_signal("request::activate", "mouse_click", { raise = true }) - awful.mouse.client.resize(c) - end) + awful.button({}, 1, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + end), + awful.button({ modkey }, 1, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + awful.mouse.client.move(c) + end), + awful.button({ modkey }, 3, function(c) + c:emit_signal("request::activate", "mouse_click", { raise = true }) + awful.mouse.client.resize(c) + end) ) -- Set keys @@ -438,127 +438,127 @@ root.keys(globalkeys) -- {{{ Rules -- Rules to apply to new clients (through the "manage" signal). awful.rules.rules = { - -- All clients will match this rule. - { - rule = {}, - properties = { - border_width = beautiful.border_width, - border_color = beautiful.border_normal, - focus = awful.client.focus.filter, - raise = true, - keys = clientkeys, - buttons = clientbuttons, - screen = awful.screen.preferred, - placement = awful.placement.no_overlap + awful.placement.no_offscreen, - }, - }, + -- All clients will match this rule. + { + rule = {}, + properties = { + border_width = beautiful.border_width, + border_color = beautiful.border_normal, + focus = awful.client.focus.filter, + raise = true, + keys = clientkeys, + buttons = clientbuttons, + screen = awful.screen.preferred, + placement = awful.placement.no_overlap + awful.placement.no_offscreen, + }, + }, - -- Floating clients. - { - rule_any = { - instance = { - "DTA", -- Firefox addon DownThemAll. - "copyq", -- Includes session name in class. - "pinentry", - }, - class = { - "Arandr", - "Blueman-manager", - "Gpick", - "Kruler", - "MessageWin", -- kalarm. - "Sxiv", - "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. - "Wpa_gui", - "veromix", - "xtightvncviewer", - }, + -- Floating clients. + { + rule_any = { + instance = { + "DTA", -- Firefox addon DownThemAll. + "copyq", -- Includes session name in class. + "pinentry", + }, + class = { + "Arandr", + "Blueman-manager", + "Gpick", + "Kruler", + "MessageWin", -- kalarm. + "Sxiv", + "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. + "Wpa_gui", + "veromix", + "xtightvncviewer", + }, - -- Note that the name property shown in xprop might be set slightly after creation of the client - -- and the name shown there might not match defined rules here. - name = { - "Event Tester", -- xev. - }, - role = { - "AlarmWindow", -- Thunderbird's calendar. - "ConfigManager", -- Thunderbird's about:config. - "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. - }, - }, - properties = { floating = true }, - }, + -- Note that the name property shown in xprop might be set slightly after creation of the client + -- and the name shown there might not match defined rules here. + name = { + "Event Tester", -- xev. + }, + role = { + "AlarmWindow", -- Thunderbird's calendar. + "ConfigManager", -- Thunderbird's about:config. + "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. + }, + }, + properties = { floating = true }, + }, - -- Add titlebars to normal clients and dialogs - { rule_any = { type = { "normal", "dialog" } }, properties = { titlebars_enabled = true } }, + -- Add titlebars to normal clients and dialogs + { rule_any = { type = { "normal", "dialog" } }, properties = { titlebars_enabled = true } }, - -- Set Firefox to always map on the tag named "2" on screen 1. - -- { rule = { class = "Firefox" }, - -- properties = { screen = 1, tag = "2" } }, + -- Set Firefox to always map on the tag named "2" on screen 1. + -- { rule = { class = "Firefox" }, + -- properties = { screen = 1, tag = "2" } }, } -- }}} -- {{{ Signals -- Signal function to execute when a new client appears. client.connect_signal("manage", function(c) - -- Set the windows at the slave, - -- i.e. put it at the end of others instead of setting it master. - -- if not awesome.startup then awful.client.setslave(c) end + -- Set the windows at the slave, + -- i.e. put it at the end of others instead of setting it master. + -- if not awesome.startup then awful.client.setslave(c) end - if awesome.startup and not c.size_hints.user_position and not c.size_hints.program_position then - -- Prevent clients from being unreachable after screen count changes. - awful.placement.no_offscreen(c) - end + if awesome.startup and not c.size_hints.user_position and not c.size_hints.program_position then + -- Prevent clients from being unreachable after screen count changes. + awful.placement.no_offscreen(c) + end end) -- Add a titlebar if titlebars_enabled is set to true in the rules. client.connect_signal("request::titlebars", function(c) - -- buttons for the titlebar - local buttons = gears.table.join( - awful.button({}, 1, function() - c:emit_signal("request::activate", "titlebar", { raise = true }) - awful.mouse.client.move(c) - end), - awful.button({}, 3, function() - c:emit_signal("request::activate", "titlebar", { raise = true }) - awful.mouse.client.resize(c) - end) - ) + -- buttons for the titlebar + local buttons = gears.table.join( + awful.button({}, 1, function() + c:emit_signal("request::activate", "titlebar", { raise = true }) + awful.mouse.client.move(c) + end), + awful.button({}, 3, function() + c:emit_signal("request::activate", "titlebar", { raise = true }) + awful.mouse.client.resize(c) + end) + ) - awful.titlebar(c):setup({ - { -- Left - awful.titlebar.widget.iconwidget(c), - buttons = buttons, - layout = wibox.layout.fixed.horizontal, - }, - { -- Middle - { -- Title - align = "center", - widget = awful.titlebar.widget.titlewidget(c), - }, - buttons = buttons, - layout = wibox.layout.flex.horizontal, - }, - { -- Right - awful.titlebar.widget.floatingbutton(c), - awful.titlebar.widget.maximizedbutton(c), - awful.titlebar.widget.stickybutton(c), - awful.titlebar.widget.ontopbutton(c), - awful.titlebar.widget.closebutton(c), - layout = wibox.layout.fixed.horizontal(), - }, - layout = wibox.layout.align.horizontal, - }) + awful.titlebar(c):setup({ + { -- Left + awful.titlebar.widget.iconwidget(c), + buttons = buttons, + layout = wibox.layout.fixed.horizontal, + }, + { -- Middle + { -- Title + align = "center", + widget = awful.titlebar.widget.titlewidget(c), + }, + buttons = buttons, + layout = wibox.layout.flex.horizontal, + }, + { -- Right + awful.titlebar.widget.floatingbutton(c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.stickybutton(c), + awful.titlebar.widget.ontopbutton(c), + awful.titlebar.widget.closebutton(c), + layout = wibox.layout.fixed.horizontal(), + }, + layout = wibox.layout.align.horizontal, + }) end) -- Enable sloppy focus, so that focus follows mouse. client.connect_signal("mouse::enter", function(c) - c:emit_signal("request::activate", "mouse_enter", { raise = false }) + c:emit_signal("request::activate", "mouse_enter", { raise = false }) end) client.connect_signal("focus", function(c) - c.border_color = beautiful.border_focus + c.border_color = beautiful.border_focus end) client.connect_signal("unfocus", function(c) - c.border_color = beautiful.border_normal + c.border_color = beautiful.border_normal end) -- }}} diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 74beb5c..e69bfb5 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -159,7 +159,6 @@ wget curl home-manager - just xclip pamixer diff --git a/nixos/default.nix b/nixos/default.nix new file mode 100644 index 0000000..ffcd441 --- /dev/null +++ b/nixos/default.nix @@ -0,0 +1 @@ +{ } diff --git a/nixos/home.nix b/nixos/home.nix index dd9171c..d7e19e5 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -5,6 +5,8 @@ let name = "Noah Masur"; editor = "nvim"; font = "Victor Mono"; + dotfiles = builtins.toString ../.; + nixos_config = builtins.toString ./.; in { nixpkgs.config.allowUnfree = true; @@ -172,7 +174,7 @@ in { v = "vim"; vl = "vim -c 'normal! `0'"; vll = "vim -c 'Telescope oldfiles'"; - vimrc = "vim ${builtins.getEnv "PWD"}/../nvim.configlink/init.lua"; + vimrc = "vim ${dotfiles}/nvim.configlink/init.lua"; # Notes qn = "quicknote"; @@ -180,10 +182,10 @@ in { to = "today"; work = "vim $NOTES_PATH/work.md"; - # Improved CLI Tools + # CLI Tools cat = "bat"; # Swap cat with bat h = "http -Fh --all"; # Curl site for headers - j = "just"; + m = "make"; # For makefiles # Fun CLI Tools weather = "curl wttr.in/$WEATHER_CITY"; @@ -228,8 +230,8 @@ in { home.sessionVariables = { fish_greeting = ""; EDITOR = "${editor}"; - NIXOS_CONFIG = builtins.getEnv "PWD"; - DOTS = "${builtins.getEnv "PWD"}/.."; + NIXOS_CONFIG = "${nixos_config}"; + DOTS = "${dotfiles}"; }; programs.starship = { @@ -260,7 +262,7 @@ in { enable = true; enableFishIntegration = true; nix-direnv.enable = true; - config = { whitelist = { prefix = [ "${builtins.getEnv "PWD"}/" ]; }; }; + config = { whitelist = { prefix = [ "${dotfiles}/" ]; }; }; }; programs.git = { diff --git a/nixos/justfile b/nixos/justfile deleted file mode 100644 index ff31cfd..0000000 --- a/nixos/justfile +++ /dev/null @@ -1,24 +0,0 @@ -# Show these options -default: - @just --list --list-heading $'Update NixOS config:\n' - -# Bootstrap from nothing -bootstrap: - sudo nix-channel --add https://nixos.org/channels/nixos-unstable - sudo nix-channel --add https://nixos.org/channels/nixpkgs-unstable - sudo nix-channel --update - sudo nixos-rebuild switch -I nixos-config=./configuration.nix - -# Use intended software channels -channels: - doas nix-channel --add https://nixos.org/channels/nixos-unstable - doas nix-channel --add https://nixos.org/channels/nixpkgs-unstable - doas nix-channel --update - -# Update the system -system: - doas nixos-rebuild switch -I nixos-config=./configuration.nix - -# Update the user environment -home: - home-manager switch -f ./home.nix diff --git a/nixos/shell.nix b/nixos/shell.nix deleted file mode 100644 index 5c8b10f..0000000 --- a/nixos/shell.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ pkgs ? import { } }: -pkgs.mkShell { - nativeBuildInputs = [ pkgs.buildPackages.stylua pkgs.buildPackages.nixfmt ]; -} From c14702c9eecdcb772f4977ee05b95817a326ce1e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Jan 2022 17:38:36 -0500 Subject: [PATCH 31/35] fix broken system w default.nix --- .envrc | 1 + nixos/default.nix | 6 +++++- shell.nix | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .envrc create mode 100644 shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/nixos/default.nix b/nixos/default.nix index ffcd441..ac091f3 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -1 +1,5 @@ -{ } +# This file does nothing but call configuration.nix +# It is required when in a shell.nix environment +{ ... }: { + imports = [ ./configuration.nix ]; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..4b583c4 --- /dev/null +++ b/shell.nix @@ -0,0 +1,5 @@ +# Environment with formatting tools for editing these files +{ pkgs ? import { } }: +pkgs.mkShell { + nativeBuildInputs = [ pkgs.buildPackages.stylua pkgs.buildPackages.nixfmt ]; +} From 1424f6c98363e9709b2b9e8887bfb3a3adc52c31 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Jan 2022 19:16:37 -0500 Subject: [PATCH 32/35] keybase encryption --- nixos/configuration.nix | 8 +++++++- nixos/home.nix | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index e69bfb5..bdf8f07 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -10,6 +10,7 @@ ]; nixpkgs.config.allowUnfree = true; + nix.extraOptions = "experimental-features = nix-command flakes"; # Use the systemd-boot EFI boot loader. boot.loader.systemd-boot.enable = true; @@ -169,12 +170,17 @@ steam ]; + environment.variables = { NIX_SKIP_KEYBASE_CHECKS = "1"; }; + location = { latitude = 40.0; longitude = 74.0; }; - services.redshift = { enable = true; }; + # Reduce blue light at night + services.redshift.enable = true; + + services.keybase.enable = true; # Some programs need SUID wrappers, can be configured further or are # started in user sessions. diff --git a/nixos/home.nix b/nixos/home.nix index d7e19e5..5ab6fd8 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -26,16 +26,24 @@ in { # Utilities unzip gcc # for tree-sitter - tmux + starship rsync + fzf ripgrep bat fd exa sd + zoxide jq tealdeer gh + direnv + + # Encryption + keybase + keybase-gui + gnupg pass ]; From 623e029b81dca42b3f59d50ffce7a81b3fe41a29 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 22 Jan 2022 23:41:53 -0500 Subject: [PATCH 33/35] dark mode and league of legends --- nixos/configuration.nix | 98 ++++++++++++++++++++--------------------- nixos/home.nix | 6 +++ nixos/todo.txt | 2 + 3 files changed, 56 insertions(+), 50 deletions(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index bdf8f07..a28303f 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -29,49 +29,65 @@ networking.interfaces.enp0s31f6.useDHCP = true; networking.interfaces.wlp3s0.useDHCP = true; - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Select internationalisation properties. - # i18n.defaultLocale = "en_US.UTF-8"; - # console = { - # font = "Lat2-Terminus16"; - # keyMap = "us"; - # }; - # Enable the X11 windowing system. # services.xserver.enable = true; services.xserver = { enable = true; - autoRepeatDelay = 250; - autoRepeatInterval = 40; - # desktopManager = { - # xterm.enable = false; - # xfce.enable = true; - # }; - # displayManager.defaultSession = "xfce"; + # Use the Awesome WM windowManager = { awesome = { enable = true; }; }; - # Enable touchpad support (enabled default in most desktopManager). + # Enable touchpad support libinput.enable = true; # Disable mouse acceleration libinput.mouse.accelProfile = "flat"; libinput.mouse.accelSpeed = "1.5"; + # Keyboard responsiveness + autoRepeatDelay = 250; + autoRepeatInterval = 40; + # Configure keymap in X11 layout = "us"; xkbOptions = "eurosign:e,caps:swapescape"; + + # Login screen + displayManager = { + lightdm = { + enable = true; + + # Make the login screen dark + greeters.gtk.theme.name = "Adwaita-dark"; + + # Put the login screen on the left monitor + greeters.gtk.extraConfig = '' + active-monitor=0 + ''; + }; + setupCommands = '' + ${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 \ + --mode 1920x1200 \ + --pos 1920x0 \ + --rotate left \ + --output HDMI-0 \ + --primary \ + --mode 1920x1080 \ + --pos 0x559 \ + --rotate normal \ + --output DVI-0 --off \ + --output DVI-1 --off \ + ''; + }; + }; + # Required for setting GTK theme (for preferred-color-scheme in browser) + services.dbus.packages = with pkgs; [ dconf gnome3.dconf ]; + # Mouse config services.ratbagd.enable = true; - # Enable CUPS to print documents. - # services.printing.enable = true; - # Enable sound. sound.enable = true; hardware.pulseaudio.enable = false; @@ -88,20 +104,6 @@ pulse.enable = true; }; - services.xserver.displayManager.setupCommands = '' - ${pkgs.xorg.xrandr}/bin/xrandr --output DisplayPort-0 \ - --mode 1920x1200 \ - --pos 1920x0 \ - --rotate left \ - --output HDMI-0 \ - --primary \ - --mode 1920x1080 \ - --pos 0x559 \ - --rotate normal \ - --output DVI-0 --off \ - --output DVI-1 --off \ - ''; - # Install fonts fonts.fonts = with pkgs; [ victor-mono nerdfonts ]; fonts.fontconfig.defaultFonts.monospace = [ "Victor Mono" ]; @@ -112,6 +114,7 @@ driSupport32Bit = true; }; hardware.steam-hardware.enable = true; + boot.kernel.sysctl = { "abi.vsyscall32" = 0; }; # League of Legends anti-cheat # Replace sudo with doas security = { @@ -139,7 +142,7 @@ # Define a user account. Don't forget to set a password with ‘passwd’. users.users.noah = { - # Not sure what this means tbh + # Create a home directory for human user isNormalUser = true; # Automatically create a password to start @@ -160,14 +163,19 @@ wget curl home-manager - xclip - pamixer + xclip # Clipboard + pamixer # Audio control # Mouse config libratbag piper + # Gaming steam + lutris + amdvlk + wine + openssl # Required for League of Legends ]; environment.variables = { NIX_SKIP_KEYBASE_CHECKS = "1"; }; @@ -180,6 +188,7 @@ # Reduce blue light at night services.redshift.enable = true; + # Login to Keybase in the background services.keybase.enable = true; # Some programs need SUID wrappers, can be configured further or are @@ -190,17 +199,6 @@ # enableSSHSupport = true; # }; - # List services that you want to enable: - - # Enable the OpenSSH daemon. - # services.openssh.enable = true; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions # on your system were taken. It‘s perfectly fine and recommended to leave diff --git a/nixos/home.nix b/nixos/home.nix index 5ab6fd8..fcac978 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -22,6 +22,7 @@ in { himalaya # Email mpv # Video viewer sxiv # Image viewer + zathura # PDF viewer # Utilities unzip @@ -39,6 +40,8 @@ in { tealdeer gh direnv + tree + htop # Encryption keybase @@ -47,6 +50,9 @@ in { pass ]; + gtk.enable = true; + gtk.theme = { name = "Adwaita-dark"; }; + programs.alacritty = { enable = true; settings = { diff --git a/nixos/todo.txt b/nixos/todo.txt index 75e24ea..6b2d823 100644 --- a/nixos/todo.txt +++ b/nixos/todo.txt @@ -1,3 +1,5 @@ libratbag (ratbagd) for input devices inspiration: https://github.com/JonathanReeve/dotfiles/blob/minimal/dotfiles/home.nix + +more: https://github.com/mitchellh/nixos-config/blob/main/users/mitchellh/home-manager.nix From e51867e838e53ae7e987473654d9a6343d4d4c9e Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 23 Jan 2022 16:37:47 +0000 Subject: [PATCH 34/35] try qtile --- nixos/configuration.nix | 26 +++--- nixos/home.nix | 1 + nixos/qtile.py | 195 +++++++++++++++++++++++++++++++++++++++ nvim.configlink/init.lua | 16 ++-- 4 files changed, 218 insertions(+), 20 deletions(-) create mode 100644 nixos/qtile.py diff --git a/nixos/configuration.nix b/nixos/configuration.nix index a28303f..5ebf374 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -19,8 +19,10 @@ # networking.hostName = "nixos"; # Define your hostname. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - # Set your time zone. - time.timeZone = "America/New_York"; + # Set your time zone, also used by redshift + services.localtime.enable = true; + services.geoclue2.enable = true; + location = { provider = "geoclue2"; }; # The global useDHCP flag is deprecated, therefore explicitly set to false here. # Per-interface useDHCP will be mandatory in the future, so this generated config @@ -30,12 +32,10 @@ networking.interfaces.wlp3s0.useDHCP = true; # Enable the X11 windowing system. - # services.xserver.enable = true; services.xserver = { enable = true; - # Use the Awesome WM - windowManager = { awesome = { enable = true; }; }; + windowManager = { qtile = { enable = true; }; }; # Enable touchpad support libinput.enable = true; @@ -83,7 +83,7 @@ }; # Required for setting GTK theme (for preferred-color-scheme in browser) - services.dbus.packages = with pkgs; [ dconf gnome3.dconf ]; + services.dbus.packages = with pkgs; [ gnome3.dconf ]; # Mouse config services.ratbagd.enable = true; @@ -176,17 +176,19 @@ amdvlk wine openssl # Required for League of Legends + dconf ]; environment.variables = { NIX_SKIP_KEYBASE_CHECKS = "1"; }; - location = { - latitude = 40.0; - longitude = 74.0; - }; - # Reduce blue light at night - services.redshift.enable = true; + services.redshift = { + enable = true; + brightness = { + day = "1.0"; + night = "0.5"; + }; + }; # Login to Keybase in the background services.keybase.enable = true; diff --git a/nixos/home.nix b/nixos/home.nix index fcac978..c15e54f 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -269,6 +269,7 @@ in { "nvim/init.lua".source = ../nvim.configlink/init.lua; "fish/functions".source = ../fish.configlink/functions; "awesome/rc.lua".source = ./awesomerc.lua; + "qtile/config.py".source = ./qtile.py; "direnvrc".text = "source $HOME/.nix-profile/share/nix-direnv/direnvrc"; }; diff --git a/nixos/qtile.py b/nixos/qtile.py new file mode 100644 index 0000000..7b9584b --- /dev/null +++ b/nixos/qtile.py @@ -0,0 +1,195 @@ +# Copyright (c) 2010 Aldo Cortesi +# Copyright (c) 2010, 2014 dequis +# Copyright (c) 2012 Randall Ma +# Copyright (c) 2012-2014 Tycho Andersen +# Copyright (c) 2012 Craig Barnes +# Copyright (c) 2013 horsik +# Copyright (c) 2013 Tao Sauvage +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +from typing import List # noqa: F401 + +from libqtile import bar, layout, widget +from libqtile.config import Click, Drag, Group, Key, Match, Screen +from libqtile.lazy import lazy +from libqtile.utils import guess_terminal + +mod = "mod4" +terminal = guess_terminal() + +keys = [ + # A list of available commands that can be bound to keys can be found + # at https://docs.qtile.org/en/latest/manual/config/lazy.html + + # Switch between windows + Key([mod], "h", lazy.layout.left(), desc="Move focus to left"), + Key([mod], "l", lazy.layout.right(), desc="Move focus to right"), + Key([mod], "j", lazy.layout.down(), desc="Move focus down"), + Key([mod], "k", lazy.layout.up(), desc="Move focus up"), + Key([mod], "space", lazy.layout.next(), + desc="Move window focus to other window"), + + # Move windows between left/right columns or move up/down in current stack. + # Moving out of range in Columns layout will create new column. + Key([mod, "shift"], "h", lazy.layout.shuffle_left(), + desc="Move window to the left"), + Key([mod, "shift"], "l", lazy.layout.shuffle_right(), + desc="Move window to the right"), + Key([mod, "shift"], "j", lazy.layout.shuffle_down(), + desc="Move window down"), + Key([mod, "shift"], "k", lazy.layout.shuffle_up(), desc="Move window up"), + + # Grow windows. If current window is on the edge of screen and direction + # will be to screen edge - window would shrink. + Key([mod, "control"], "h", lazy.layout.grow_left(), + desc="Grow window to the left"), + Key([mod, "control"], "l", lazy.layout.grow_right(), + desc="Grow window to the right"), + Key([mod, "control"], "j", lazy.layout.grow_down(), + desc="Grow window down"), + Key([mod, "control"], "k", lazy.layout.grow_up(), desc="Grow window up"), + Key([mod], "n", lazy.layout.normalize(), desc="Reset all window sizes"), + + # Toggle between split and unsplit sides of stack. + # Split = all windows displayed + # Unsplit = 1 window displayed, like Max layout, but still with + # multiple stack panes + Key([mod, "shift"], "Return", lazy.layout.toggle_split(), + desc="Toggle between split and unsplit sides of stack"), + Key([mod], "Return", lazy.spawn(terminal), desc="Launch terminal"), + + # Toggle between different layouts as defined below + Key([mod], "Tab", lazy.next_layout(), desc="Toggle between layouts"), + Key([mod], "w", lazy.window.kill(), desc="Kill focused window"), + + Key([mod, "control"], "r", lazy.reload_config(), desc="Reload the config"), + Key([mod, "control"], "q", lazy.shutdown(), desc="Shutdown Qtile"), + Key([mod], "r", lazy.spawncmd(), + desc="Spawn a command using a prompt widget"), +] + +groups = [Group(i) for i in "123456789"] + +for i in groups: + keys.extend([ + # mod1 + letter of group = switch to group + Key([mod], i.name, lazy.group[i.name].toscreen(), + desc="Switch to group {}".format(i.name)), + + # mod1 + shift + letter of group = switch to & move focused window to group + Key([mod, "shift"], i.name, lazy.window.togroup(i.name, switch_group=True), + desc="Switch to & move focused window to group {}".format(i.name)), + # Or, use below if you prefer not to switch to that group. + # # mod1 + shift + letter of group = move focused window to group + # Key([mod, "shift"], i.name, lazy.window.togroup(i.name), + # desc="move focused window to group {}".format(i.name)), + ]) + +layouts = [ + layout.Columns(border_focus_stack=['#d75f5f', '#8f3d3d'], border_width=4), + layout.Max(), + # Try more layouts by unleashing below layouts. + # layout.Stack(num_stacks=2), + # layout.Bsp(), + # layout.Matrix(), + # layout.MonadTall(), + # layout.MonadWide(), + # layout.RatioTile(), + # layout.Tile(), + # layout.TreeTab(), + # layout.VerticalTile(), + # layout.Zoomy(), +] + +widget_defaults = dict( + font='sans', + fontsize=12, + padding=3, +) +extension_defaults = widget_defaults.copy() + +screens = [ + Screen( + top=bar.Bar( + [ + widget.CurrentLayout(), + widget.GroupBox(), + widget.Prompt(), + widget.WindowName(), + widget.Chord( + chords_colors={ + 'launch': ("#ff0000", "#ffffff"), + }, + name_transform=lambda name: name.upper(), + ), + widget.TextBox("Press <M-r> to spawn", foreground="#d75f5f"), + widget.Volume(), + widget.Systray(), + widget.Clock(format='%Y-%m-%d %a %I:%M %p'), + widget.QuickExit(), + ], + 24, + # border_width=[2, 0, 2, 0], # Draw top and bottom borders + # border_color=["ff00ff", "000000", "ff00ff", "000000"] # Borders are magenta + ), + ), +] + +# Drag floating layouts. +mouse = [ + Drag([mod], "Button1", lazy.window.set_position_floating(), + start=lazy.window.get_position()), + Drag([mod], "Button3", lazy.window.set_size_floating(), + start=lazy.window.get_size()), + Click([mod], "Button2", lazy.window.bring_to_front()) +] + +dgroups_key_binder = None +dgroups_app_rules = [] # type: List +follow_mouse_focus = True +bring_front_click = False +cursor_warp = False +floating_layout = layout.Floating(float_rules=[ + # Run the utility of `xprop` to see the wm class and name of an X client. + *layout.Floating.default_float_rules, + Match(wm_class='confirmreset'), # gitk + Match(wm_class='makebranch'), # gitk + Match(wm_class='maketag'), # gitk + Match(wm_class='ssh-askpass'), # ssh-askpass + Match(title='branchdialog'), # gitk + Match(title='pinentry'), # GPG key password entry +]) +auto_fullscreen = True +focus_on_window_activation = "smart" +reconfigure_screens = True + +# If things like steam games want to auto-minimize themselves when losing +# focus, should we respect this or not? +auto_minimize = True + +# XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this +# string besides java UI toolkits; you can see several discussions on the +# mailing lists, GitHub issues, and other WM documentation that suggest setting +# this string if your java app doesn't work correctly. We may as well just lie +# and say that we're a working one by default. +# +# We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in +# java that happens to be on java's whitelist. +wmname = "LG3D" diff --git a/nvim.configlink/init.lua b/nvim.configlink/init.lua index 2414398..a3a4a6a 100644 --- a/nvim.configlink/init.lua +++ b/nvim.configlink/init.lua @@ -138,10 +138,10 @@ require("packer").startup(function(use) require("lspconfig").rust_analyzer.setup({ capabilities = capabilities }) require("lspconfig").tflint.setup({ capabilities = capabilities }) require("lspconfig").terraformls.setup({ capabilities = capabilities }) - require("lspconfig").pyright.setup({ - cmd = { "poetry", "run", "pyright-langserver", "--stdio" }, - capabilities = capabilities, - }) + -- require("lspconfig").pyright.setup({ + -- cmd = { "poetry", "run", "pyright-langserver", "--stdio" }, + -- capabilities = capabilities, + -- }) end, }) @@ -160,10 +160,10 @@ require("packer").startup(function(use) require("null-ls").setup({ sources = { require("null-ls").builtins.formatting.stylua, - require("null-ls").builtins.formatting.black.with({ - command = "poetry", - args = { "run", "black", "--quiet", "--fast", "-" }, - }), + -- require("null-ls").builtins.formatting.black.with({ + -- command = "poetry", + -- args = { "run", "black", "--quiet", "--fast", "-" }, + -- }), require("null-ls").builtins.formatting.fish_indent, require("null-ls").builtins.formatting.nixfmt, require("null-ls").builtins.formatting.rustfmt, From e0c405f8e846ed5692f74ad81fe1d767ff955377 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Mon, 24 Jan 2022 01:32:38 +0000 Subject: [PATCH 35/35] try spectrwm --- nixos/configuration.nix | 7 +- nixos/home.nix | 2 + nixos/spectrwm.conf | 256 ++++++++++++++++++++++++++++++++++++++++ nixos/todo.txt | 9 ++ 4 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 nixos/spectrwm.conf diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 5ebf374..65ea5c9 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -35,7 +35,7 @@ services.xserver = { enable = true; - windowManager = { qtile = { enable = true; }; }; + windowManager = { spectrwm = { enable = true; }; }; # Enable touchpad support libinput.enable = true; @@ -165,6 +165,9 @@ home-manager xclip # Clipboard pamixer # Audio control + dmenu + xlockmore + feh # Mouse config libratbag @@ -186,7 +189,7 @@ enable = true; brightness = { day = "1.0"; - night = "0.5"; + night = "0.75"; }; }; diff --git a/nixos/home.nix b/nixos/home.nix index c15e54f..8e857bf 100644 --- a/nixos/home.nix +++ b/nixos/home.nix @@ -42,6 +42,7 @@ in { direnv tree htop + glow # Encryption keybase @@ -271,6 +272,7 @@ in { "awesome/rc.lua".source = ./awesomerc.lua; "qtile/config.py".source = ./qtile.py; "direnvrc".text = "source $HOME/.nix-profile/share/nix-direnv/direnvrc"; + "spectrwm/spectrwm.conf".source = ./spectrwm.conf; }; programs.direnv = { diff --git a/nixos/spectrwm.conf b/nixos/spectrwm.conf new file mode 100644 index 0000000..522fcf9 --- /dev/null +++ b/nixos/spectrwm.conf @@ -0,0 +1,256 @@ +# PLEASE READ THE MAN PAGE BEFORE EDITING THIS FILE! +# https://htmlpreview.github.io/?https://github.com/conformal/spectrwm/blob/master/spectrwm.html +# NOTE: all rgb color values in this file are in hex! see XQueryColor for examples + +workspace_limit = 9 +# focus_mode = default +# focus_close = previous +# focus_close_wrap = 1 +# focus_default = last +# spawn_position = next +# workspace_clamp = 1 +# warp_focus = 1 +# warp_pointer = 1 + +# Window Decoration +border_width = 0 +# color_focus = red +# color_focus_maximized = yellow +# color_unfocus = rgb:88/88/88 +# color_unfocus_maximized = rgb:88/88/00 +region_padding = 20 +tile_gap = 20 + +# Region containment +# Distance window must be dragged/resized beyond the region edge before it is +# allowed outside the region. +# boundary_width = 50 + +# Remove window border when bar is disabled and there is only one window in workspace +# disable_border = 1 + +# Bar Settings +# bar_enabled = 1 +# bar_enabled_ws[1] = 1 +# bar_border_width = 1 +# bar_border[1] = rgb:00/80/80 +# bar_border_unfocus[1] = rgb:00/40/40 +# bar_color[1] = black +# bar_color_selected[1] = rgb:00/80/80 +# bar_font_color[1] = rgb:a0/a0/a0 +# bar_font_color_selected = black +# bar_font = xos4 Terminus:pixelsize=14:antialias=true +bar_font = Victor Mono:pixelsize=14:antialias=true +# bar_font_pua = Typicons:pixelsize=14:antialias=true +# bar_action = baraction.sh +# bar_action_expand = 0 +bar_justify = center +# bar_format = +N:+I +S <+D>+4<%a %b %d %R %Z %Y+8<+A+4<+V +# workspace_indicator = listcurrent,listactive,markcurrent,printnames +# bar_at_bottom = 1 +# stack_enabled = 1 +# clock_enabled = 1 +# clock_format = %a %b %d %R %Z %Y +# iconic_enabled = 0 +# maximize_hide_bar = 0 +# window_class_enabled = 0 +# window_instance_enabled = 0 +# window_name_enabled = 0 +# verbose_layout = 1 +# urgent_enabled = 1 +# urgent_collapse = 0 + +# Dialog box size ratio when using TRANSSZ quirk; 0.3 < dialog_ratio <= 1.0 +# dialog_ratio = 0.6 + +# Split a non-RandR dual head setup into one region per monitor +# (non-standard driver-based multihead is not seen by spectrwm) +# region = screen[1]:1280x1024+0+0 +# region = screen[1]:1280x1024+1280+0 + +# Launch applications in a workspace of choice +# autorun = ws[1]:xterm +# autorun = ws[2]:xombrero http://www.openbsd.org + +# Customize workspace layout at start +# layout = ws[1]:4:0:0:0:vertical +# layout = ws[2]:0:0:0:0:horizontal +# layout = ws[3]:0:0:0:0:fullscreen +# layout = ws[4]:4:0:0:0:vertical_flip +# layout = ws[5]:0:0:0:0:horizontal_flip + +# Set workspace name at start +# name = ws[1]:IRC +# name = ws[2]:Email +# name = ws[3]:Browse +# name = ws[10]:Music + +# Mod key, (Windows key is Mod4) (Apple key on OSX is Mod2) +modkey = Mod4 + +# This allows you to include pre-defined key bindings for your keyboard layout. +# keyboard_mapping = ~/.spectrwm_us.conf + +# PROGRAMS + +# Validated default programs: +# program[lock] = xlock +program[term] = alacritty +# program[menu] = dmenu_run $dmenu_bottom -fn $bar_font -nb $bar_color -nf $bar_font_color -sb $bar_color_selected -sf $bar_font_color_selected +# program[search] = dmenu $dmenu_bottom -i -fn $bar_font -nb $bar_color -nf $bar_font_color -sb $bar_color_selected -sf $bar_font_color_selected +# program[name_workspace] = dmenu $dmenu_bottom -p Workspace -fn $bar_font -nb $bar_color -nf $bar_font_color -sb $bar_color_selected -sf $bar_font_color_selected + +# To disable validation of the above, free the respective binding(s): +# bind[] = MOD+Shift+Delete # disable lock +# bind[] = MOD+Shift+Return # disable term +# bind[] = MOD+p # disable menu + +# Optional default programs that will only be validated if you override: +# program[screenshot_all] = screenshot.sh full # optional +# program[screenshot_wind] = screenshot.sh window # optional +# program[initscr] = initscreen.sh # optional + +# EXAMPLE: Define 'firefox' action and bind to key. +# program[firefox] = firefox http://spectrwm.org/ +# bind[firefox] = MOD+Shift+b + +# QUIRKS +# Default quirks, remove with: quirk[class:name] = NONE +# quirk[MPlayer:xv] = FLOAT + FULLSCREEN + FOCUSPREV +# quirk[OpenOffice.org 2.4:VCLSalFrame] = FLOAT +# quirk[OpenOffice.org 3.0:VCLSalFrame] = FLOAT +# quirk[OpenOffice.org 3.1:VCLSalFrame] = FLOAT +# quirk[Firefox-bin:firefox-bin] = TRANSSZ +# quirk[Firefox:Dialog] = FLOAT +# quirk[Gimp:gimp] = FLOAT + ANYWHERE +# quirk[XTerm:xterm] = XTERM_FONTADJ +# quirk[xine:Xine Window] = FLOAT + ANYWHERE +# quirk[Xitk:Xitk Combo] = FLOAT + ANYWHERE +# quirk[xine:xine Panel] = FLOAT + ANYWHERE +# quirk[Xitk:Xine Window] = FLOAT + ANYWHERE +# quirk[xine:xine Video Fullscreen Window] = FULLSCREEN + FLOAT +# quirk[pcb:pcb] = FLOAT + +# Key bindings for United States (us) keyboards +# unbind with: bind[] = +# bind[bar_toggle] = MOD+b +# bind[bar_toggle_ws] = MOD+Shift+b +# bind[button2] = MOD+v +# bind[cycle_layout] = MOD+space +# bind[flip_layout] = MOD+Shift+backslash +# bind[float_toggle] = MOD+t +# bind[focus_main] = MOD+m +# bind[focus_next] = MOD+j +# bind[focus_next] = MOD+Tab +# bind[focus_prev] = MOD+k +# bind[focus_prev] = MOD+Shift+Tab +# bind[focus_urgent] = MOD+u +# bind[height_grow] = MOD+Shift+equal +# bind[height_shrink] = MODssh git.charm.sh+Shift+minus +# bind[iconify] = MOD+w +# bind[initscr] = MOD+Shift+i +# bind[lock] = MOD+Shift+Delete +# bind[master_add] = MOD+comma +# bind[master_del] = MOD+period +# bind[master_grow] = MOD+l +# bind[master_shrink] = MOD+h +# bind[maximize_toggle] = MOD+e +# bind[menu] = MOD+p +# bind[move_down] = MOD+Shift+bracketright +# bind[move_left] = MOD+bracketleft +# bind[move_right] = MOD+bracketright +# bind[move_up] = MOD+Shift+bracketleft +# bind[mvrg_1] = MOD+Shift+KP_End +# bind[mvrg_2] = MOD+Shift+KP_Down +# bind[mvrg_3] = MOD+Shift+KP_Next +# bind[mvrg_4] = MOD+Shift+KP_Left +# bind[mvrg_5] = MOD+Shift+KP_Begin +# bind[mvrg_6] = MOD+Shift+KP_Right +# bind[mvrg_7] = MOD+Shift+KP_Home +# bind[mvrg_8] = MOD+Shift+KP_Up +# bind[mvrg_9] = MOD+Shift+KP_Prior +# bind[mvws_1] = MOD+Shift+1 +# bind[mvws_2] = MOD+Shift+2 +# bind[mvws_3] = MOD+Shift+3 +# bind[mvws_4] = MOD+Shift+4 +# bind[mvws_5] = MOD+Shift+5 +# bind[mvws_6] = MOD+Shift+6 +# bind[mvws_7] = MOD+Shift+7 +# bind[mvws_8] = MOD+Shift+8 +# bind[mvws_9] = MOD+Shift+9 +# bind[mvws_10] = MOD+Shift+0 +# bind[mvws_11] = MOD+Shift+F1 +# bind[mvws_12] = MOD+Shift+F2 +# bind[mvws_13] = MOD+Shift+F3 +# bind[mvws_14] = MOD+Shift+F4 +# bind[mvws_15] = MOD+Shift+F5 +# bind[mvws_16] = MOD+Shift+F6 +# bind[mvws_17] = MOD+Shift+F7 +# bind[mvws_18] = MOD+Shift+F8 +# bind[mvws_19] = MOD+Shift+F9 +# bind[mvws_20] = MOD+Shift+F10 +# bind[mvws_21] = MOD+Shift+F11 +# bind[mvws_22] = MOD+Shift+F12 +# bind[name_workspace] = MOD+Shift+slash +# bind[quit] = MOD+Shift+q +# bind[raise_toggle] = MOD+Shift+r +# bind[restart] = MOD+q +# bind[rg_1] = MOD+KP_End +# bind[rg_2] = MOD+KP_Down +# bind[rg_3] = MOD+KP_Next +# bind[rg_4] = MOD+KP_Left +# bind[rg_5] = MOD+KP_Begin +# bind[rg_6] = MOD+KP_Right +# bind[rg_7] = MOD+KP_Home +# bind[rg_8] = MOD+KP_Up +# bind[rg_9] = MOD+KP_Prior +# bind[rg_next] = MOD+Shift+Right +# bind[rg_prev] = MOD+Shift+Left +# bind[screenshot_all] = MOD+s +# bind[screenshot_wind] = MOD+Shift+s +# bind[search_win] = MOD+f +# bind[search_workspace] = MOD+slash +# bind[stack_dec] = MOD+Shift+period +# bind[stack_inc] = MOD+Shift+comma +# bind[stack_reset] = MOD+Shift+space +bind[swap_main] = MOD+Shift+Return +# bind[swap_next] = MOD+Shift+j +# bind[swap_prev] = MOD+Shift+k +bind[rg_next] = MOD+Shift+j +bind[rg_prev] = MOD+Shift+k +bind[term] = MOD+Return +# bind[uniconify] = MOD+Shift+w +# bind[version] = MOD+Shift+v +# bind[width_grow] = MOD+equal +# bind[width_shrink] = MOD+minus +# bind[wind_del] = MOD+x +bind[wind_kill] = MOD+Shift+c +# bind[ws_1] = MOD+1 +# bind[ws_2] = MOD+2 +# bind[ws_3] = MOD+3 +# bind[ws_4] = MOD+4 +# bind[ws_5] = MOD+5 +# bind[ws_6] = MOD+6 +# bind[ws_7] = MOD+7 +# bind[ws_8] = MOD+8 +# bind[ws_9] = MOD+9 +# bind[ws_10] = MOD+0 +# bind[ws_11] = MOD+F1 +# bind[ws_12] = MOD+F2 +# bind[ws_13] = MOD+F3 +# bind[ws_14] = MOD+F4 +# bind[ws_15] = MOD+F5 +# bind[ws_16] = MOD+F6 +# bind[ws_17] = MOD+F7 +# bind[ws_18] = MOD+F8 +# bind[ws_19] = MOD+F9 +# bind[ws_20] = MOD+F10 +# bind[ws_21] = MOD+F11 +# bind[ws_22] = MOD+F12 +# bind[ws_next] = MOD+Right +# bind[ws_next_all] = MOD+Up +# bind[ws_next_move] = MOD+Shift+Up +# bind[ws_prev] = MOD+Left +# bind[ws_prev_all] = MOD+Down +# bind[ws_prev_move] = MOD+Shift+Down +# bind[ws_prior] = MOD+a diff --git a/nixos/todo.txt b/nixos/todo.txt index 6b2d823..aba8331 100644 --- a/nixos/todo.txt +++ b/nixos/todo.txt @@ -3,3 +3,12 @@ libratbag (ratbagd) for input devices inspiration: https://github.com/JonathanReeve/dotfiles/blob/minimal/dotfiles/home.nix more: https://github.com/mitchellh/nixos-config/blob/main/users/mitchellh/home-manager.nix + +https://github.com/kyechou/leagueoflegends + +Encryption: +https://www.passwordstore.org/ +https://github.com/roddhjav/pass-tomb#readme +https://github.com/AGWA/git-crypt +https://github.com/FiloSottile/age +https://sr.ht/~gpanders/passage/