diff options
Diffstat (limited to 'home/sadbeast/features')
-rw-r--r-- | home/sadbeast/features/desktop/default.nix | 21 | ||||
-rw-r--r-- | home/sadbeast/features/desktop/firefox.nix | 127 | ||||
-rw-r--r-- | home/sadbeast/features/desktop/foot.nix | 21 | ||||
-rw-r--r-- | home/sadbeast/features/desktop/sway.nix | 132 | ||||
-rw-r--r-- | home/sadbeast/features/desktop/waybar.css | 70 | ||||
-rw-r--r-- | home/sadbeast/features/desktop/waybar.nix | 57 | ||||
-rw-r--r-- | home/sadbeast/features/git.nix | 28 | ||||
-rw-r--r-- | home/sadbeast/features/gpg.nix | 67 | ||||
-rw-r--r-- | home/sadbeast/features/pass.nix | 17 | ||||
-rw-r--r-- | home/sadbeast/features/services.nix | 21 | ||||
-rw-r--r-- | home/sadbeast/features/ssh.nix | 26 | ||||
-rw-r--r-- | home/sadbeast/features/vim.nix | 245 | ||||
-rw-r--r-- | home/sadbeast/features/zsh.nix | 67 |
13 files changed, 899 insertions, 0 deletions
diff --git a/home/sadbeast/features/desktop/default.nix b/home/sadbeast/features/desktop/default.nix new file mode 100644 index 0000000..d393fff --- /dev/null +++ b/home/sadbeast/features/desktop/default.nix @@ -0,0 +1,21 @@ +{ + pkgs, + config, + lib, + ... +}: { + imports = [ + ./firefox.nix + ./foot.nix + ./sway.nix + ./waybar.nix + ]; + + home = { + packages = with pkgs; [ + galculator + pavucontrol + wine + ]; + }; +} diff --git a/home/sadbeast/features/desktop/firefox.nix b/home/sadbeast/features/desktop/firefox.nix new file mode 100644 index 0000000..08ec448 --- /dev/null +++ b/home/sadbeast/features/desktop/firefox.nix @@ -0,0 +1,127 @@ +{ + pkgs, + inputs, + lib, + config, + ... +}: let + addons = inputs.firefox-addons.packages.${pkgs.system}; +in { + programs.browserpass.enable = true; + programs.firefox = { + enable = true; + profiles.sadbeast = { + search = { + force = true; + default = "Google"; + privateDefault = "DuckDuckGo"; + order = ["Google" "DuckDuckGo"]; + }; + bookmarks = {}; + extensions = with addons; [ + ublock-origin + browserpass + ]; + bookmarks = {}; + settings = { + "browser.startup.homepage" = "about:home"; + + # Disable irritating first-run stuff + "browser.disableResetPrompt" = true; + "browser.download.panel.shown" = true; + "browser.feeds.showFirstRunUI" = false; + "browser.messaging-system.whatsNewPanel.enabled" = false; + "browser.rights.3.shown" = true; + "browser.shell.checkDefaultBrowser" = false; + "browser.shell.defaultBrowserCheckCount" = 1; + "browser.startup.homepage_override.mstone" = "ignore"; + "browser.uitour.enabled" = false; + "startup.homepage_override_url" = ""; + "trailhead.firstrun.didSeeAboutWelcome" = true; + "browser.bookmarks.restore_default_bookmarks" = false; + "browser.bookmarks.addedImportButton" = true; + + # Don't ask for download dir + "browser.download.useDownloadDir" = false; + + # Disable crappy home activity stream page + "browser.newtabpage.activity-stream.feeds.topsites" = false; + "browser.newtabpage.activity-stream.showSponsoredTopSites" = false; + "browser.newtabpage.activity-stream.improvesearch.topSiteSearchShortcuts" = false; + "browser.newtabpage.blocked" = lib.genAttrs [ + # Youtube + "26UbzFJ7qT9/4DhodHKA1Q==" + # Facebook + "4gPpjkxgZzXPVtuEoAL9Ig==" + # Wikipedia + "eV8/WsSLxHadrTL1gAxhug==" + # Reddit + "gLv0ja2RYVgxKdp0I5qwvA==" + # Amazon + "K00ILysCaEq8+bEqV/3nuw==" + # Twitter + "T9nJot5PurhJSy8n038xGA==" + ] (_: 1); + + # Disable some telemetry + "app.shield.optoutstudies.enabled" = false; + "browser.discovery.enabled" = false; + "browser.newtabpage.activity-stream.feeds.telemetry" = false; + "browser.newtabpage.activity-stream.telemetry" = false; + "browser.ping-centre.telemetry" = false; + "datareporting.healthreport.service.enabled" = false; + "datareporting.healthreport.uploadEnabled" = false; + "datareporting.policy.dataSubmissionEnabled" = false; + "datareporting.sessions.current.clean" = true; + "devtools.onboarding.telemetry.logged" = false; + "toolkit.telemetry.archive.enabled" = false; + "toolkit.telemetry.bhrPing.enabled" = false; + "toolkit.telemetry.enabled" = false; + "toolkit.telemetry.firstShutdownPing.enabled" = false; + "toolkit.telemetry.hybridContent.enabled" = false; + "toolkit.telemetry.newProfilePing.enabled" = false; + "toolkit.telemetry.prompted" = 2; + "toolkit.telemetry.rejected" = true; + "toolkit.telemetry.reportingpolicy.firstRun" = false; + "toolkit.telemetry.server" = ""; + "toolkit.telemetry.shutdownPingSender.enabled" = false; + "toolkit.telemetry.unified" = false; + "toolkit.telemetry.unifiedIsOptIn" = false; + "toolkit.telemetry.updatePing.enabled" = false; + + # Disable fx accounts + "identity.fxaccounts.enabled" = false; + # Disable "save password" prompt + "signon.rememberSignons" = false; + # Harden + "privacy.trackingprotection.enabled" = true; + "dom.security.https_only_mode" = true; + # Layout + "browser.uiCustomization.state" = builtins.toJSON { + currentVersion = 20; + newElementCount = 5; + dirtyAreaCache = ["nav-bar" "PersonalToolbar" "toolbar-menubar" "TabsToolbar" "widget-overflow-fixed-list"]; + placements = { + PersonalToolbar = ["personal-bookmarks"]; + TabsToolbar = ["tabbrowser-tabs" "new-tab-button" "alltabs-button"]; + nav-bar = ["back-button" "forward-button" "stop-reload-button" "urlbar-container" "downloads-button" "ublock0_raymondhill_net-browser-action" "browserpass_maximbaz_com-browser-action" "reset-pbm-toolbar-button" "unified-extensions-button"]; + toolbar-menubar = ["menubar-items"]; + unified-extensions-area = []; + widget-overflow-fixed-list = []; + }; + seen = ["save-to-pocket-button" "developer-button" "ublock0_raymondhill_net-browser-action" "browserpass_maximbaz_com-browser-action"]; + }; + }; + }; + }; + + # home = { + # persistence = { + # # Not persisting is safer + # "/persistent${config.home.homeDirectory}" = { + # directories = [ ".mozilla/firefox" ]; + # allowOther = true; + # }; + # }; + # }; +} diff --git a/home/sadbeast/features/desktop/foot.nix b/home/sadbeast/features/desktop/foot.nix new file mode 100644 index 0000000..d6bb965 --- /dev/null +++ b/home/sadbeast/features/desktop/foot.nix @@ -0,0 +1,21 @@ +{ + inputs, + outputs, + ... +}: { + programs.foot = { + enable = true; + + # server.enable = true; + + settings = { + main = { + font = "Iosevka-11:style=Medium,Regular, JoyPixels"; + font-bold = "Iosevka-11:style=Bold"; + font-italic = "Iosevka-11:style=Italic"; + + underline-offset = 1; + }; + }; + }; +} diff --git a/home/sadbeast/features/desktop/sway.nix b/home/sadbeast/features/desktop/sway.nix new file mode 100644 index 0000000..39e9834 --- /dev/null +++ b/home/sadbeast/features/desktop/sway.nix @@ -0,0 +1,132 @@ +{ + config, + lib, + pkgs, + ... +}: { + home.packages = with pkgs; [ + grim + iosevka + (nerdfonts.override {fonts = ["Iosevka"];}) + light + slurp + swayimg + wl-clipboard + dmenu-wayland + ]; + + fonts.fontconfig.enable = true; + + home.sessionVariables = { + XDG_CURRENT_DESKTOP = "sway"; + MOZ_ENABLE_WAYLAND = 1; + QT_QPA_PLATFORM = "wayland"; + LIBSEAT_BACKEND = "logind"; + SDL_VIDEODRIVER = "wayland"; + }; + + gtk = { + enable = true; + theme = { + package = pkgs.gnome-themes-extra; + # name = "Adwaita-dark"; + name = "Adwaita"; + }; + }; + + home.pointerCursor = { + gtk.enable = true; + package = pkgs.vanilla-dmz; + name = "Vanilla-DMZ"; + size = 22; + }; + + wayland.windowManager.sway = { + enable = true; + + config = { + modifier = "Mod4"; + + bars = []; + + fonts = { + names = ["Iosevka"]; + size = 11.0; + }; + + gaps = { + smartGaps = true; + outer = 0; + }; + + input = { + "*" = { + xkb_layout = "us"; + xkb_options = "ctrl:nocaps"; + tap = "enabled"; + }; + }; + + keybindings = let + modifier = config.wayland.windowManager.sway.config.modifier; + in + lib.mkOptionDefault { + "${modifier}+p" = "exec passmenu"; + "${modifier}+Shift+Return" = "exec qutebrowser"; + "${modifier}+y" = "exec grim ~/scrn-$(date +\"%Y-%m-%d-%H-%M-%S\").png"; + "${modifier}+Shift+y" = "exec slurp | grim -g - ~/scrn-$(date +\"%Y-%m-%d-%H-%M-%S\").png"; + "XF86AudioRaiseVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%+ && wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed 's/[^0-9]//g' > $XDG_RUNTIME_DIR/wob.sock"; + "XF86AudioLowerVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%- && wpctl get-volume @DEFAULT_AUDIO_SINK@ | sed 's/[^0-9]//g' > $XDG_RUNTIME_DIR/wob.sock"; + "XF86AudioMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle && (wpctl get-volume @DEFAULT_AUDIO_SINK@ | grep -q MUTED && echo 0 > $XDG_RUNTIME_DIR/wob.sock) || wpctl get-volume @DEFAULT_AUDIO_SINK@ > $XDG_RUNTIME_DIR/wob.sock"; + + "XF86MonBrightnessUp" = "exec light -A 5 && light -G | cut -d'.' -f1 > $XDG_RUNTIME_DIR/wob.sock"; + "XF86MonBrightnessDown" = "exec light -U 5 && light -G | cut -d'.' -f1 > $XDG_RUNTIME_DIR/wob.sock"; + }; + + startup = [ + { + command = "systemctl --user restart waybar"; + always = true; + } + ]; + + terminal = "${pkgs.foot}/bin/foot"; + }; + + extraConfig = '' + # Window borders + default_border pixel 1 + default_floating_border normal + hide_edge_borders smart + ''; + }; + + services = { + mako = { + enable = true; + + extraConfig = '' + [mode=do-not-disturb] + invisible=1 + ''; + }; + + swayidle = { + enable = true; + + events = [ + # { event = "timeout 300"; command = "${pkgs.swaylock}/bin/swaylock -fF -c 000000"; } + # { event = "timeout 600"; command = "swaymsg \"output * dpms off\""; } + { + event = "after-resume"; + command = "swaymsg \"output * dpms on\""; + } + { + event = "before-sleep"; + command = "${pkgs.swaylock}/bin/swaylock -fF -c 000000"; + } + ]; + }; + wob.enable = true; + }; +} diff --git a/home/sadbeast/features/desktop/waybar.css b/home/sadbeast/features/desktop/waybar.css new file mode 100644 index 0000000..725514c --- /dev/null +++ b/home/sadbeast/features/desktop/waybar.css @@ -0,0 +1,70 @@ +* { + border: none; + border-radius: 0; + font-family: Iosevka; + font-size: 13px; + min-height: 0; +} + +window#waybar { + background: rgba(43, 48, 59, 0.5); + border-bottom: 2px solid rgba(100, 114, 125, 0.5); + color: white; +} + +#workspaces { + margin-right: 5px; +} + +#workspaces button { + padding: 0 5px; + background: transparent; + color: white; + border-bottom: 2px solid transparent; +} + +#workspaces button.focused { + background: #64727D; + border-bottom: 2px solid white; +} + +#mode, #clock, #battery { + padding: 0 10px; + margin: 0 5px; +} + +#mode { + background: #64727D; + border-bottom: 2px solid white; +} + +#clock { + background-color: #64727D; +} + +#battery { + background-color: #ffffff; + color: black; +} + +#battery.charging { + color: white; + background-color: #26A65B; +} + +@keyframes blink { + to { + background-color: #ffffff; + color: black; + } +} + +#battery.warning:not(.charging) { + background: #f53c3c; + color: white; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} diff --git a/home/sadbeast/features/desktop/waybar.nix b/home/sadbeast/features/desktop/waybar.nix new file mode 100644 index 0000000..02410b4 --- /dev/null +++ b/home/sadbeast/features/desktop/waybar.nix @@ -0,0 +1,57 @@ +{ + programs.waybar = { + enable = true; + systemd.enable = true; + + settings = { + mainBar = { + layer = "bottom"; + position = "top"; + height = 20; + + modules-left = ["sway/workspaces" "sway/mode" "sway/window"]; + modules-right = ["tray" "battery" "clock"]; + + "sway/workspaces" = { + format = "{name}"; + disable-scroll = true; + }; + + "sway/mode" = { + format = " {}"; + }; + + "sway/window" = { + max-length = 80; + tooltip = false; + }; + + clock = { + format = "{:%a %d %I:%M}"; + tooltip = false; + }; + + battery = { + format = "{capacity}% {icon}"; + format-alt = "{time} {icon}"; + format-icons = ["" "" "" "" ""]; + format-charging = "{capacity}% "; + interval = 30; + + states = { + warning = 25; + critical = 10; + }; + + tooltip = false; + }; + + tray = { + icon-size = 18; + }; + }; + }; + + style = ./waybar.css; + }; +} diff --git a/home/sadbeast/features/git.nix b/home/sadbeast/features/git.nix new file mode 100644 index 0000000..477265b --- /dev/null +++ b/home/sadbeast/features/git.nix @@ -0,0 +1,28 @@ +{ + config, + lib, + ... +}: { + programs.git = { + enable = true; + userName = lib.mkDefault config.home.username; + userEmail = lib.mkDefault "sadbeast@sadbeast.com"; + + aliases = { + p = "pull --ff-only"; + ff = "merge --ff-only"; + graph = "log --decorate --oneline --graph"; + add-nowhitespace = "!git diff -U0 -w --no-color | git apply --cached --ignore-whitespace --unidiff-zero -"; + # for "last branch", shows the most recently accessed branches + lb = "!git reflog show --pretty=format:'%gs ~ %gd' --date=relative | grep 'checkout:' | grep -oE '[^ ]+ ~ .*' | awk -F~ '!seen[$1]++' | head -n 15 | awk -F' ~ HEAD@{' '{printf(\" \\033[33m%s: \\033[37m %s\\033[0m\\n\", substr($2, 1, length($2)-1), $1)}'"; + }; + + extraConfig = { + init.defaultBranch = "main"; + push.autoSetupRemote = true; + # Reuse merge conflict fixes when rebasing + rerere.enabled = true; + }; + ignores = [".direnv"]; + }; +} diff --git a/home/sadbeast/features/gpg.nix b/home/sadbeast/features/gpg.nix new file mode 100644 index 0000000..5af4838 --- /dev/null +++ b/home/sadbeast/features/gpg.nix @@ -0,0 +1,67 @@ +{ + pkgs, + config, + lib, + ... +}: { + services.gpg-agent = { + enable = true; + # enableSshSupport = true; + # sshKeys = [""]; + enableExtraSocket = true; + pinentryPackage = + if config.gtk.enable + then pkgs.pinentry-gnome3 + else pkgs.pinentry-tty; + }; + + home.packages = lib.optional config.gtk.enable pkgs.gcr; + + programs = let + fixGpg = + /* + bash + */ + '' + gpgconf --launch gpg-agent + ''; + in { + # Start gpg-agent if it's not running or tunneled in + # SSH does not start it automatically, so this is needed to avoid having to use a gpg command at startup + # https://www.gnupg.org/faq/whats-new-in-2.1.html#autostart + bash.profileExtra = fixGpg; + zsh.loginExtra = fixGpg; + + gpg = { + enable = true; + settings = { + trust-model = "tofu+pgp"; + }; + # publicKeys = [ + # { + # source = ../../pgp.asc; + # trust = 5; + # } + # ]; + }; + }; + + systemd.user.services = { + # Link /run/user/$UID/gnupg to ~/.gnupg-sockets + # So that SSH config does not have to know the UID + link-gnupg-sockets = { + Unit = { + Description = "link gnupg sockets from /run to /home"; + }; + Service = { + Type = "oneshot"; + ExecStart = "${pkgs.coreutils}/bin/ln -Tfs /run/user/%U/gnupg %h/.gnupg-sockets"; + ExecStop = "${pkgs.coreutils}/bin/rm $HOME/.gnupg-sockets"; + RemainAfterExit = true; + }; + Install.WantedBy = ["default.target"]; + }; + }; +} +# vim: filetype=nix + diff --git a/home/sadbeast/features/pass.nix b/home/sadbeast/features/pass.nix new file mode 100644 index 0000000..0a64f41 --- /dev/null +++ b/home/sadbeast/features/pass.nix @@ -0,0 +1,17 @@ +{ + pkgs, + config, + ... +}: { + programs.password-store = { + enable = true; + settings = { + PASSWORD_STORE_DIR = "$HOME/.password-store"; + }; + package = pkgs.pass.withExtensions (p: [p.pass-otp]); + }; + + # home.persistence = { + # "/persistent${config.home.homeDirectory}".directories = [".password-store"]; + # }; +} diff --git a/home/sadbeast/features/services.nix b/home/sadbeast/features/services.nix new file mode 100644 index 0000000..71ef7d8 --- /dev/null +++ b/home/sadbeast/features/services.nix @@ -0,0 +1,21 @@ +{pkgs, ...}: { + services = { + swayidle = { + enable = true; + + events = [ + # { event = "timeout 300"; command = "${pkgs.swaylock}/bin/swaylock -fF -c 000000"; } + # { event = "timeout 600"; command = "swaymsg \"output * dpms off\""; } + { + event = "after-resume"; + command = "swaymsg \"output * dpms on\""; + } + { + event = "before-sleep"; + command = "${pkgs.swaylock}/bin/swaylock -fF -c 000000"; + } + ]; + }; + wob.enable = true; + }; +} diff --git a/home/sadbeast/features/ssh.nix b/home/sadbeast/features/ssh.nix new file mode 100644 index 0000000..aeace3c --- /dev/null +++ b/home/sadbeast/features/ssh.nix @@ -0,0 +1,26 @@ +{ + programs.ssh = { + enable = true; + + matchBlocks = { + "falken" = { + hostname = "sadbeast.com"; + port = 6973; + }; + + "crystalpalace" = { + hostname = "192.168.0.2"; + port = 6973; + }; + + "joshua" = { + hostname = "192.168.0.3"; + }; + + "teamdraft" = { + hostname = "teamdraft.net"; + port = 6973; + }; + }; + }; +} diff --git a/home/sadbeast/features/vim.nix b/home/sadbeast/features/vim.nix new file mode 100644 index 0000000..173304d --- /dev/null +++ b/home/sadbeast/features/vim.nix @@ -0,0 +1,245 @@ +{pkgs, ...}: { + programs.vim = { + enable = true; + defaultEditor = true; + + plugins = with pkgs.vimPlugins; [ + # ale + asyncomplete-vim + asyncomplete-lsp-vim + base16-vim + copilot-vim + lightline-vim + # lightline-ale + lightline-lsp + fugitive + fzf-vim + vim-commentary + vim-dadbod + vim-dispatch + vim-dotenv + vim-eunuch + vim-lsp + # vim-lsp-ale + vim-lsp-settings + vim-mustache-handlebars + vim-rails + vim-signify + vim-wayland-clipboard + vim-vsnip + vim-vsnip-integ + zig-vim + ]; + + settings = { + hidden = true; + ignorecase = true; + # mouse = "a"; + number = true; + relativenumber = true; + smartcase = true; + }; + + extraConfig = '' + set nocompatible + set encoding=utf-8 + set wildmenu + set showcmd + set hlsearch + " Use visual bell instead of beeping when doing something wrong + set visualbell + + " And reset the terminal code for the visual bell. If visualbell is set, and + " this line is also included, vim will neither flash nor beep. If visualbell + " is unset, this does nothing. + set t_vb= + set backspace=indent,eol,start + set autoindent + set nostartofline + set ruler + set confirm + " Quickly time out on keycodes, but never time out on mappings + set notimeout ttimeout ttimeoutlen=200 + set pastetoggle=<F11> + " automatically leave paste mode so I don't forget + autocmd InsertLeave * set nopaste + " Indentation settings for using 4 spaces instead of tabs. + " Do not change 'tabstop' from its default value of 8 with this setup. + set shiftwidth=4 + set softtabstop=4 + set expandtab + " Don't update the screen when executing macros + set lazyredraw + + " Easier to reach than \ + let mapleader=" " + + " fzf + nmap <leader>p :Files<cr> + nmap <leader>bb :Buffers<cr> + + " dadbod + autocmd FileType sql let b:dispatch = 'pgcli %' + vnoremap <leader>d :DB<cr> + nmap <leader>d :DB<cr> + + set formatoptions=ctqrn1 + + " Show matching brackets. + set showmatch + + " Bracket blinking. + set matchtime=5 + + " start scrolling when we're 8 lines away from margins + set scrolloff=8 + set sidescrolloff=15 + set sidescroll=1 + + set noswapfile + set nobackup + set nowb + + " Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode. + "set fo+=o + " Do not automatically insert a comment leader after an enter + "set fo-=r + " Do no auto-wrap text using textwidth (does not apply to comments) + "set fo-=t + + set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/vendor/*,*/bin/*,*/node_modules/* + + " quicker async update time + set updatetime=100 + + " taller vertical bar for vsplits + set fillchars+=vert:│ + + set ttymouse = "sgr"; + + " Enable 24-bit colors + set termguicolors + let &t_8f = "\<Esc>[38:2::%lu:%lu:%lum" + let &t_8b = "\<Esc>[48:2::%lu:%lu:%lum" + + " Workaround bug in vim, where it incorrectly thinks modifyOtherKeys level 2 is + " enabled, even when it's not. The snippets below ensure modifyOtherKeys=2 is + " enabled. https://github.com/vim/vim/issues/9014 + let &t_TI = "\<Esc>[>4;2m" + let &t_TE = "\<Esc>[>4;m" + + set undodir=~/.vim/backups + set undofile + + " When opening a file, always jump to the last cursor position + autocmd BufReadPost * + \ if line("'\"") > 0 && line ("'\"") <= line("$") | + \ exe "normal g'\"" | + \ endif + + " remove annoying help window + inoremap <F1> <nop> + nnoremap <F1> <nop> + vnoremap <F1> <nop> + + " better window navigation + nnoremap <c-j> <c-w>j + nnoremap <c-k> <c-w>k + nnoremap <c-h> <c-w>h + nnoremap <c-l> <c-w>l + + " quickfix + nnoremap <c-n> :cnext<CR> + nnoremap <c-b> :cprevious<CR> + + " command line autocomplete + set wildchar=<Tab> wildmenu wildmode=full + + " scroll through buffers + noremap <left> :bp<CR> + noremap <right> :bn<CR> + + " show menu to switch buffers + set wildcharm=<C-Z> + nnoremap <F10> :b <C-Z> + + " unhighlight search results + noremap <silent><Leader>/ :nohls<CR> + + " reselect visual block after indent/outdent + vnoremap < <gv + vnoremap > >gv + + " force saving files that require root permission + cmap w!! %!sudo tee > /dev/null % + + " Close the current buffer and move to the previous one + " This replicates the idea of closing a tab + nmap <leader>bq :bp <BAR> bd #<CR> + + colorscheme base16-default-dark + + let g:termdebug_popup = 0 + let g:termdebug_wide = 163 + + " vim-lsp + function! s:on_lsp_buffer_enabled() abort + setlocal omnifunc=lsp#complete + setlocal signcolumn=yes + if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif + nmap <buffer> gd <plug>(lsp-definition) + nmap <buffer> gs <plug>(lsp-document-symbol-search) + nmap <buffer> gS <plug>(lsp-workspace-symbol-search) + nmap <buffer> gr <plug>(lsp-references) + nmap <buffer> gi <plug>(lsp-implementation) + nmap <buffer> gt <plug>(lsp-type-definition) + nmap <buffer> <leader>rn <plug>(lsp-rename) + nmap <buffer> [g <plug>(lsp-previous-diagnostic) + nmap <buffer> ]g <plug>(lsp-next-diagnostic) + nmap <buffer> K <plug>(lsp-hover) + " nnoremap <buffer> <expr><c-f> lsp#scroll(+4) + " nnoremap <buffer> <expr><c-d> lsp#scroll(-4) + + let g:lsp_format_sync_timeout = 1000 + autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync') + + " refer to doc to add more commands + endfunction + + augroup lsp_install + au! + " call s:on_lsp_buffer_enabled only for languages that has the server registered. + autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() + augroup END + + "if executable('solargraph') + " " gem install solargraph + " au User lsp_setup call lsp#register_server({ + " \ 'name': 'solargraph', + " \ 'cmd': {server_info->[&shell, &shellcmdflag, 'solargraph stdio']}, + " \ 'initialization_options': {"diagnostics": "true"}, + " \ 'whitelist': ['ruby'], + " \ }) + "endif + + " asyncomplete + inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>" + inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>" + inoremap <expr> <cr> pumvisible() ? asyncomplete#close_popup() : "\<cr>" + + imap <c-@> <Plug>(asyncomplete_force_refresh) + + " vim-vsnip + " Expand + imap <expr> <C-j> vsnip#expandable() ? '<Plug>(vsnip-expand)' : '<C-j>' + smap <expr> <C-j> vsnip#expandable() ? '<Plug>(vsnip-expand)' : '<C-j>' + + " Expand or jump + imap <expr> <C-l> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>' + smap <expr> <C-l> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<C-l>' + + " Copilot ugh + " let g:copilot_node_command = "/usr/bin/env node" + ''; + }; +} diff --git a/home/sadbeast/features/zsh.nix b/home/sadbeast/features/zsh.nix new file mode 100644 index 0000000..db568e6 --- /dev/null +++ b/home/sadbeast/features/zsh.nix @@ -0,0 +1,67 @@ +{ + pkgs, + config, + ... +}: { + programs.zsh = { + enable = true; + autocd = true; + enableCompletion = true; + enableVteIntegration = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + + loginExtra = '' + if [ "$(tty)" = "/dev/tty1" ]; then + exec sway + fi + ''; + + initExtra = '' + precmd() { + print -Pn "\e]133;A\e\\" + } + + function osc7-pwd() { + emulate -L zsh # also sets localoptions for us + setopt extendedglob + local LC_ALL=C + printf '\e]7;file://%s%s\e\' $HOST ''${PWD//(#m)([^@-Za-z&-;_~])/%''${(l:2::0:)$(([##16]#MATCH))}} + } + + function chpwd-osc7-pwd() { + (( ZSH_SUBSHELL )) || osc7-pwd + } + add-zsh-hook -Uz chpwd chpwd-osc7-pwd + ''; + + defaultKeymap = "emacs"; + + history = { + size = 10000; + path = "${config.xdg.dataHome}/zsh/zsh_history"; + }; + + shellAliases = { + ll = "ls -l"; + }; + + sessionVariables = { + EDITOR = "vim"; + }; + + # TODO: this causes a 2 second delay + # plugins = [ + # { + # name = "zsh-nix-shell"; + # file = "nix-shell.plugin.zsh"; + # src = pkgs.fetchFromGitHub { + # owner = "chisui"; + # repo = "zsh-nix-shell"; + # rev = "v0.8.0"; + # sha256 = "1lzrn0n4fxfcgg65v0qhnj7wnybybqzs4adz7xsrkgmcsr0ii8b7"; + # }; + # } + # ]; + }; +} |