diff --git a/config.nix b/config.nix index 69baf10..0ad4e95 100644 --- a/config.nix +++ b/config.nix @@ -1 +1,4 @@ -{ allowUnfree = true; } +{ + allowUnfree = true; +} + diff --git a/darwin-configuration.nix b/darwin-configuration.nix new file mode 100644 index 0000000..7c57259 --- /dev/null +++ b/darwin-configuration.nix @@ -0,0 +1,35 @@ +{ pkgs, nix, nixpkgs, config, lib, ... }: +{ + environment.systemPackages = with pkgs; + [ + home-manager + ]; + + fonts = { + fontDir.enable = true; + fonts = with pkgs; [ + fira-code + ]; + }; + + programs.fish.enable = true; + + system.stateVersion = 4; + users = { + users.salar = { + home = /Users/salar; + }; + }; + + nix = { + nixPath = lib.mkForce [ + "nixpkgs=${nixpkgs}" + ]; + package = pkgs.nixUnstable; + extraOptions = '' + experimental-features = nix-command flakes + ''; + distributedBuilds = false; + }; + services.nix-daemon.enable = true; +} diff --git a/flake.lock b/flake.lock index 23a741f..ba60535 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,23 @@ { "nodes": { - "flake-parts": { + "darwin": { "inputs": { - "nixpkgs-lib": [ - "nur", + "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1733312601, - "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", - "owner": "hercules-ci", - "repo": "flake-parts", - "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", + "lastModified": 1657835815, + "narHash": "sha256-CnZszAYpNKydh6N7+xg+eRtWNVoAAGqc6bg+Lpgq1xc=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "54a24f042f93c79f5679f133faddedec61955cf2", "type": "github" }, "original": { - "owner": "hercules-ci", - "repo": "flake-parts", + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", "type": "github" } }, @@ -25,14 +25,15 @@ "inputs": { "nixpkgs": [ "nixpkgs" - ] + ], + "utils": "utils" }, "locked": { - "lastModified": 1756496801, - "narHash": "sha256-IYIsnPy+cJxe8RbDHBrCtfJY0ry2bG2H7WvMcewiGS8=", + "lastModified": 1659878744, + "narHash": "sha256-81a9Mx5pDMBGN4WnVhcQVkW5mXNTZOt8DZOSI8bVKpU=", "owner": "nix-community", "repo": "home-manager", - "rev": "77a71380c38fb2a440b4b5881bbc839f6230e1cb", + "rev": "f5e9879e74e6202e2dbb3628fad2d20eac0d8be4", "type": "github" }, "original": { @@ -41,49 +42,13 @@ "type": "github" } }, - "nix-darwin": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1755825449, - "narHash": "sha256-XkiN4NM9Xdy59h69Pc+Vg4PxkSm9EWl6u7k6D5FZ5cM=", - "owner": "LnL7", - "repo": "nix-darwin", - "rev": "8df64f819698c1fee0c2969696f54a843b2231e8", - "type": "github" - }, - "original": { - "owner": "LnL7", - "repo": "nix-darwin", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1756438964, - "narHash": "sha256-yo473URkISSmBZeIE1o6Mf94VRSn5qFVFS9phb7l6eg=", + "lastModified": 1659803779, + "narHash": "sha256-+5zkHlbcbFyN5f3buO1RAZ9pH1wXLxCesUJ0vFmLr9Y=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c73522789a3c7552b1122773d6eaa34e1491cc1c", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1756386758, - "narHash": "sha256-1wxxznpW2CKvI9VdniaUnTT2Os6rdRJcRUf65ZK9OtE=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "dfb2f12e899db4876308eba6d93455ab7da304cd", + "rev": "f44884060cb94240efbe55620f38a8ec8d9af601", "type": "github" }, "original": { @@ -94,16 +59,12 @@ } }, "nur": { - "inputs": { - "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs_2" - }, "locked": { - "lastModified": 1756568538, - "narHash": "sha256-nnFpWhG/jtRzI2yJKKgokhefFELHTUw9fgqcTrdX6aM=", + "lastModified": 1659937593, + "narHash": "sha256-tJBCAV7GwxxisvnlUK5YWwzeCm4q9OGgvEE9WFiypiI=", "owner": "nix-community", "repo": "nur", - "rev": "e8f97acd1ededca7944f1fe1b659b61003131ce2", + "rev": "6daa0a7c4ae5c3951ac945b299d40e232674aaaf", "type": "github" }, "original": { @@ -114,11 +75,26 @@ }, "root": { "inputs": { + "darwin": "darwin", "home-manager": "home-manager", - "nix-darwin": "nix-darwin", "nixpkgs": "nixpkgs", "nur": "nur" } + }, + "utils": { + "locked": { + "lastModified": 1653893745, + "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 6908110..4cd500c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,100 +1,34 @@ { description = "Nix and home-manager configurations for Softinio's macbook"; - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - nix-darwin = { - url = "github:LnL7/nix-darwin"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - nur.url = "github:nix-community/nur"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nur.url = github:nix-community/nur; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + darwin = { + url = "github:lnl7/nix-darwin/master"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - - outputs = - { - self, - nix-darwin, - home-manager, - nur, - nixpkgs, - ... - }: + outputs = {darwin, home-manager, nur, nixpkgs, ...}: let - homeManagerConfFor = - config: - { ... }: - { - nixpkgs.overlays = [ nur.overlays.default ]; - imports = [ - config - ]; - }; - - m3maxConfiguration = - { pkgs, ... }: - { - environment.systemPackages = with pkgs; [ home-manager ]; - - fonts = { - packages = with pkgs; [ fira-code ]; - }; - - nix = { - nixPath = nixpkgs.lib.mkForce [ "nixpkgs=${nixpkgs}" ]; - - package = pkgs.nixVersions.stable; - settings = { - experimental-features = "nix-command flakes"; - extra-platforms = [ - "x86_64-darwin" - "aarch64-darwin" - ]; - trusted-users = [ - "root" - "salar" - ]; - }; - distributedBuilds = false; - }; - - programs.fish.enable = true; - - system.configurationRevision = self.rev or self.dirtyRev or null; - - system.stateVersion = 4; - - nixpkgs.hostPlatform = "aarch64-darwin"; - - users = { - users.salar = { - home = /Users/salar; - }; - }; - }; - in - { - darwinConfigurations.salarm3max = nix-darwin.lib.darwinSystem { - system = "aarch64-darwin"; + homeManagerConfFor = config: { ... }: { + nixpkgs.overlays = [ nur.overlay ]; + imports = [ config ]; + }; + darwinSystem = darwin.lib.darwinSystem { + system = "x86_64-darwin"; modules = [ - m3maxConfiguration - home-manager.darwinModules.home-manager - { - home-manager.backupFileExtension = "backup"; - home-manager.useUserPackages = true; + ./darwin-configuration.nix + home-manager.darwinModules.home-manager { home-manager.users.salar = homeManagerConfFor ./home.nix; } ]; - specialArgs = { - inherit nixpkgs; - }; + specialArgs = { inherit nixpkgs; }; }; - - darwinPackages = self.darwinConfigurations.salarm3max.pkgs; - - defaultPackage.aarch64-darwin = self.darwinConfigurations.salarm3max.system; + in { + defaultPackage.x86_64-darwin = darwinSystem.system; }; } diff --git a/home.nix b/home.nix index e8a3dbb..9fef7ab 100644 --- a/home.nix +++ b/home.nix @@ -1,8 +1,4 @@ -{ - lib, - pkgs, - ... -}: +{ config, lib, pkgs, ... }: { # Let Home Manager install and manage itself. @@ -10,127 +6,95 @@ imports = (import ./programs); - nixpkgs.config.allowUnfreePredicate = - pkg: - builtins.elem (lib.getName pkg) [ - "discord" - "gh-copilot" - "slack" - "vscode" - "vscode-extension-github-copilot" - "vscode-extension-github-copilot-chat" - "vscode-extension-MS-python-vscode-pylance" - "vscode-extension-visualjj-visualjj" - ]; + nixpkgs.overlays = [ + (import ./overlays/sumneko-lua-language-server) + # (import (builtins.fetchTarball { + # url = https://github.com/nix-community/neovim-nightly-overlay/archive/master.tar.gz; + # })) + ]; + + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "vscode" + ]; home = { - stateVersion = "25.05"; + stateVersion = "21.11"; sessionVariables = { EDITOR = "nvim"; VISUAL = "$EDITOR"; }; packages = with pkgs; [ + ( python39.withPackages (ps: with ps; [ pip flake8 black ]) ) + adoptopenjdk-bin any-nix-shell aspell - ast-grep - basedpyright - bash-language-server + bloop + cabal-install cachix cmake coursier curlFull - deno - devenv - difftastic - discord - dua + exa fd ffmpeg font-awesome + gitAndTools.diff-so-fancy gnupg go - graphviz - jetbrains-mono - jjui - jq-lsp + haskellPackages.implicit-hie + hugo luajit - lua-language-server - marksman - marp-cli + luajitPackages.luarocks + luajitPackages.luasocket + lorri maven - meld - metals multimarkdown mypy + ncdu + neofetch neovim - nerd-fonts.fira-code - nil niv - nixd nix-index - nixfmt-rfc-style - nix-prefetch-git - nodejs - noto-fonts - ollama + nixfmt + nixFlakes + nodePackages.pyright + nodePackages.typescript-language-server + nodePackages.vscode-html-languageserver-bin + nodePackages.vscode-json-languageserver + nodePackages.yaml-language-server openssl pandoc patchelf - pngpaste - prettyping - pyrefly - python3Full - python3Packages.huggingface-hub - python3Packages.jupyterlab + poetry rclone readline ripgrep ripgrep-all + rnix-lsp + rust-analyzer rustup sbt scala-cli shellcheck - slack - slides - slumber sqlite stylua - swift-format + stack + sumneko-lua-language-server tealdeer + tectonic + texlab tig - tmux-sessionizer tokei tree tree-sitter - typst - typescript - typescript-language-server wget - uv - vscode-langservers-extracted xz - yaml-language-server yq ]; }; programs.bat = { - enable = true; - }; - - programs.btop = { - enable = true; - }; - - programs.darcs = { - enable = true; - author = [ "Salar Rahmanian " ]; - boring = [ - "^.idea$" - "^.direnv$" - "^.envrc$" - "^.vscode$" - ]; + enable = true; }; programs.direnv = { @@ -138,19 +102,6 @@ nix-direnv.enable = true; }; - programs.eza = { - enable = true; - enableFishIntegration = true; - git = true; - icons = "auto"; - extraOptions = [ - "--group-directories-first" - "--long" - "--header" - "--all" - ]; - }; - programs.fzf = { enable = true; enableFishIntegration = true; @@ -158,29 +109,9 @@ programs.gh = { enable = true; - extensions = [ - pkgs.gh-copilot - ]; settings = { editor = "nvim"; git_protocol = "ssh"; - prompt = "enabled"; - aliases = { - co = "pr checkout"; - pv = "pr view"; - }; - }; - }; - - programs.gh-dash = { - enable = true; - }; - - programs.helix = { - enable = true; - settings = { - theme = "tokyonight"; - editor.file-picker.hidden = false; }; }; @@ -188,28 +119,28 @@ enable = true; }; - programs.java = { - enable = true; - }; - programs.jq = { enable = true; }; - programs.lazygit = { + programs.kitty = { enable = true; - }; - - programs.nix-index = { - enable = true; - enableFishIntegration = true; + font = { + name = "FiraCode Nerd Font Mono Retina"; + size = 16; + }; + settings = { + copy_on_select = true; + enabled_layouts = "*"; + macos_quit_when_last_window_closed = true; + scrollback_lines = 10000; + }; }; programs.starship = { enable = true; - enableFishIntegration = true; settings = { - command_timeout = 3000; + command_timeout = 1000; character = { success_symbol = " [λ](bold green)"; error_symbol = " [λ](bold red)"; @@ -217,11 +148,151 @@ }; }; - # Neovim Configuration - xdg.configFile."nvim".source = pkgs.fetchFromGitHub { - owner = "softinio"; - repo = "nvim-config"; - rev = "9a41e9cc3c4f855142a130f945ec31703ac76737"; - sha256 = "sha256-+VWOQMpUF1VdUvBhASvdgPk5h8F3GKDk525opMkwomE="; + programs.vscode = { + enable = true; + extensions = [ + pkgs.vscode-extensions.scalameta.metals + pkgs.vscode-extensions.usernamehw.errorlens + pkgs.vscode-extensions.redhat.java + pkgs.vscode-extensions.xyz.local-history + pkgs.vscode-extensions.yzhang.markdown-all-in-one + pkgs.vscode-extensions.svsool.markdown-memo + pkgs.vscode-extensions.github.vscode-pull-request-github + pkgs.vscode-extensions.github.github-vscode-theme + pkgs.vscode-extensions.jnoortheen.nix-ide + pkgs.vscode-extensions.timonwong.shellcheck + pkgs.vscode-extensions.skyapps.fish-vscode + pkgs.vscode-extensions.baccata.scaladex-search + pkgs.vscode-extensions.davidanson.vscode-markdownlint + ]; + userSettings = { + editor.fontFamily = "FiraCode Nerd Font Mono Retina"; + editor.fontSize = 16; + telemetry.enableTelemetry = false; + workbench.colorTheme = "Solarized Light"; + workbench.iconTheme = "vscode-icons"; + }; }; + + programs.fish = { + enable = true; + + functions = { + gitignore = "curl -sL https://www.gitignore.io/api/$argv"; + }; + + plugins = [ + { + name = "bass"; + src = pkgs.fetchFromGitHub { + owner = "edc"; + repo = "bass"; + rev = "50eba266b0d8a952c7230fca1114cbc9fbbdfbd4"; + sha256 = "0ppmajynpb9l58xbrcnbp41b66g7p0c9l2nlsvyjwk6d16g4p4gy"; + }; + } + { + name = "foreign-env"; + src = pkgs.fetchFromGitHub { + owner = "oh-my-fish"; + repo = "plugin-foreign-env"; + rev = "dddd9213272a0ab848d474d0cbde12ad034e65bc"; + sha256 = "00xqlyl3lffc5l0viin1nyp819wf81fncqyz87jx8ljjdhilmgbs"; + }; + } + { + name = "bobthefish"; + src = pkgs.fetchFromGitHub { + owner = "oh-my-fish"; + repo = "theme-bobthefish"; + rev = "a2ad38aa051aaed25ae3bd6129986e7f27d42d7b"; + sha256 = "1fssb5bqd2d7856gsylf93d28n3rw4rlqkhbg120j5ng27c7v7lq"; + }; + } + ]; + + loginShellInit = '' + set -xg TERM xterm-256color + if test -e /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh + fenv source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh + end + + if test -e /nix/var/nix/profiles/default/etc/profile.d/nix.sh + fenv source /nix/var/nix/profiles/default/etc/profile.d/nix.sh + end + + if test -e $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh + fenv source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh + end + + set -xg PATH $HOME/bin $HOME/.cargo/bin $PATH + + set -xg PATH /Users/salar/.luarocks/bin:/nix/store/95wpywsjf5iiw77f6n9rw347lk1sly15-luarocks-3.2.1/bin:/Users/salar/bin:/Users/salar/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/nix/store/3qp71mhrpxxg080yc82k51nx7b5hkajr-kitty-0.21.2/Applications/kitty.app/Contents/MacOS $PATH + + set -xg JAVA_HOME /Users/salar/.nix-profile + + set -xg JDTLS_CONFIG /Users/salar/.config/jdt-language-server/config_mac + + set -xg JAR /Users/salar/.config/jdt-language-server/plugins/org.eclipse.equinox.launcher_1.6.200.v20210416-2027.jar + + set -xg WORKSPACE /Users/salar/Projects + + set -xg NIX_PATH $HOME/.nix-defexpr/channels $NIX_PATH + + set -xg FZF_DEFAULT_OPTS "--preview='bat {} --color=always'" \n + + set -xg TOOLCHAINS swift + + set -xg XDG_CONFIG_HOME $HOME/.config + + set -xg LUA_PATH "/nix/store/95wpywsjf5iiw77f6n9rw347lk1sly15-luarocks-3.2.1/share/lua/5.1/?.lua;/nix/store/95wpywsjf5iiw77f6n9rw347lk1sly15-luarocks-3.2.1/share/lua/5.1/?/init.lua;/Users/salar/.luarocks/share/lua/5.1/?.lua;/Users/salar/.luarocks/share/lua/5.1/?/init.lua" + + set -xg LUA_CPATH "?.so;/nix/store/95wpywsjf5iiw77f6n9rw347lk1sly15-luarocks-3.2.1/share/lua/5.1/?/init.lua;/Users/salar/.luarocks/lib/lua/5.1/?.so;/nix/store/95wpywsjf5iiw77f6n9rw347lk1sly15-luarocks-3.2.1/lib/lua/5.1/?.so" + ''; + + interactiveShellInit = '' + eval (direnv hook fish) + any-nix-shell fish --info-right | source + ''; + + shellAliases = { + cat="bat"; + du="ncdu --color dark -rr -x"; + fzfp="fzf --preview 'bat --style=numbers --color=always --line-range :500 {}'"; + ping="prettyping"; + ".." = "cd .."; + pj="python -m json.tool"; + l="exa --long --header --git --all"; + g="git"; + gl="git log"; + gc="git commit -m"; + gca="git commit -am"; + gws="git status"; + ghauth="gh auth login --with-token < ~/.ghauth"; + giscala="gitignore scala,vim,java,sbt > .gitignore"; + gforksync="git fetch upstream && git merge upstream/master && git push origin master"; + grep="grep --color=auto"; + new-sbt="sbt new scala/scala-seed.g8"; + nixre="nix build && sudo ./result/activate"; + nixinfo="nix-shell -p nix-info --run \"nix-info -m\""; + nixgc="nix-collect-garbage -d"; + nixq="nix-env -qa"; + nixupdate="sudo nix-channel --update"; + nixversion="nix eval nixpkgs.lib.version"; + rmxcodederived="rm -fr ~/Library/Developer/Xcode/DerivedData"; + v="nvim"; + sshfre1="ssh salar@fre1.softinio.net"; + sshfre2="ssh -p 22 salar@fre2.softinio.net"; + }; + }; + + xdg.configFile."fish/conf.d/plugin-bobthefish.fish".text = lib.mkAfter '' + for f in $plugin_dir/*.fish + source $f + end + ''; + + # Neovim Configuration + xdg.configFile."nvim/lua/salargalaxyline.lua".source = programs/neovim/settings/salargalaxyline.lua; + xdg.configFile."nvim/init.lua".source = programs/neovim/init.lua; } diff --git a/overlays/sumneko-lua-language-server/default.nix b/overlays/sumneko-lua-language-server/default.nix new file mode 100644 index 0000000..6efa0bf --- /dev/null +++ b/overlays/sumneko-lua-language-server/default.nix @@ -0,0 +1,38 @@ +self: super: { + sumneko-lua-language-server = super.sumneko-lua-language-server.overrideAttrs ( + o: rec { + version = "2.2.3"; + + src = builtins.fetchurl { + url = "https://github.com/sumneko/vscode-lua/releases/download/v${version}/lua-${version}.vsix"; + sha256 = "16rpi6p7rslpdfi37ndy5g9qmvh22qljfk9w15kdrr668hfwp7nm"; + }; + + unpackPhase = '' + ${super.pkgs.unzip}/bin/unzip $src + ''; + + platform = if super.stdenv.isDarwin then "macOS" else "Linux"; + + preBuild = ""; + postBuild = ""; + nativeBuildInputs = [ + super.makeWrapper + ]; + + installPhase = '' + mkdir -p $out + cp -r extension $out/extras + chmod a+x $out/extras/server/bin/$platform/lua-language-server + makeWrapper $out/extras/server/bin/$platform/lua-language-server \ + $out/bin/lua-language-server \ + --add-flags "-E -e LANG=en $out/extras/server/main.lua \ + --logpath='~/.cache/sumneko_lua/log' \ + --metapath='~/.cache/sumneko_lua/meta'" + ''; + + meta.platforms = super.lib.platforms.all; + } + ); +} + diff --git a/programs/aider/aider.yml b/programs/aider/aider.yml deleted file mode 100644 index a68dbba..0000000 --- a/programs/aider/aider.yml +++ /dev/null @@ -1,405 +0,0 @@ -########################################################## -# Sample .aider.conf.yml -# This file lists *all* the valid configuration entries. -# Place in your home dir, or at the root of your git repo. -########################################################## - -# Note: You can only put OpenAI and Anthropic API keys in the yaml -# config file. Keys for all APIs can be stored in a .env file -# https://aider.chat/docs/config/dotenv.html - -########## -# options: - -## show this help message and exit -#help: xxx - -############# -# Main model: - -## Specify the model to use for the main chat -model: anthropic/claude-sonnet-4-20250514 - -######################## -# API Keys and settings: - -## Specify the OpenAI API key -#openai-api-key: xxx - -## Specify the Anthropic API key -#anthropic-api-key: xxx - -## Specify the api base url -#openai-api-base: xxx - -## (deprecated, use --set-env OPENAI_API_TYPE=) -#openai-api-type: xxx - -## (deprecated, use --set-env OPENAI_API_VERSION=) -#openai-api-version: xxx - -## (deprecated, use --set-env OPENAI_API_DEPLOYMENT_ID=) -#openai-api-deployment-id: xxx - -## (deprecated, use --set-env OPENAI_ORGANIZATION=) -#openai-organization-id: xxx - -## Set an environment variable (to control API settings, can be used multiple times) -#set-env: xxx -## Specify multiple values like this: -#set-env: -# - xxx -# - yyy -# - zzz - -## Set an API key for a provider (eg: --api-key provider= sets PROVIDER_API_KEY=) -#api-key: xxx -## Specify multiple values like this: -#api-key: -# - xxx -# - yyy -# - zzz - -################# -# Model settings: - -## List known models which match the (partial) MODEL name -#list-models: xxx - -## Specify a file with aider model settings for unknown models -#model-settings-file: .aider.model.settings.yml - -## Specify a file with context window and costs for unknown models -#model-metadata-file: .aider.model.metadata.json - -## Add a model alias (can be used multiple times) -#alias: xxx -## Specify multiple values like this: -#alias: -# - xxx -# - yyy -# - zzz - -## Set the reasoning_effort API parameter (default: not set) -#reasoning-effort: xxx - -## Verify the SSL cert when connecting to models (default: True) -#verify-ssl: true - -## Timeout in seconds for API calls (default: None) -#timeout: xxx - -## Specify what edit format the LLM should use (default depends on model) -#edit-format: xxx - -## Use architect edit format for the main chat -#architect: false - -## Specify the model to use for commit messages and chat history summarization (default depends on --model) -#weak-model: xxx - -## Specify the model to use for editor tasks (default depends on --model) -#editor-model: xxx - -## Specify the edit format for the editor model (default: depends on editor model) -#editor-edit-format: xxx - -## Only work with models that have meta-data available (default: True) -#show-model-warnings: true - -## Soft limit on tokens for chat history, after which summarization begins. If unspecified, defaults to the model's max_chat_history_tokens. -#max-chat-history-tokens: xxx - -################# -# Cache settings: - -## Enable caching of prompts (default: False) -#cache-prompts: false - -## Number of times to ping at 5min intervals to keep prompt cache warm (default: 0) -#cache-keepalive-pings: false - -################### -# Repomap settings: - -## Suggested number of tokens to use for repo map, use 0 to disable -#map-tokens: xxx - -## Control how often the repo map is refreshed. Options: auto, always, files, manual (default: auto) -#map-refresh: auto - -## Multiplier for map tokens when no files are specified (default: 2) -#map-multiplier-no-files: true - -################ -# History Files: - -## Specify the chat input history file (default: .aider.input.history) -#input-history-file: .aider.input.history - -## Specify the chat history file (default: .aider.chat.history.md) -#chat-history-file: .aider.chat.history.md - -## Restore the previous chat history messages (default: False) -#restore-chat-history: false - -## Log the conversation with the LLM to this file (for example, .aider.llm.history) -#llm-history-file: xxx - -################## -# Output settings: - -## Use colors suitable for a dark terminal background (default: False) -dark-mode: true - -## Use colors suitable for a light terminal background (default: False) -#light-mode: false - -## Enable/disable pretty, colorized output (default: True) -#pretty: true - -## Enable/disable streaming responses (default: True) -#stream: true - -## Set the color for user input (default: #00cc00) -#user-input-color: #00cc00 - -## Set the color for tool output (default: None) -#tool-output-color: xxx - -## Set the color for tool error messages (default: #FF2222) -#tool-error-color: #FF2222 - -## Set the color for tool warning messages (default: #FFA500) -#tool-warning-color: #FFA500 - -## Set the color for assistant output (default: #0088ff) -#assistant-output-color: #0088ff - -## Set the color for the completion menu (default: terminal's default text color) -#completion-menu-color: xxx - -## Set the background color for the completion menu (default: terminal's default background color) -#completion-menu-bg-color: xxx - -## Set the color for the current item in the completion menu (default: terminal's default background color) -#completion-menu-current-color: xxx - -## Set the background color for the current item in the completion menu (default: terminal's default text color) -#completion-menu-current-bg-color: xxx - -## Set the markdown code theme (default: default, other options include monokai, solarized-dark, solarized-light, or a Pygments builtin style, see https://pygments.org/styles for available themes) -#code-theme: default - -## Show diffs when committing changes (default: False) -show-diffs: true - -############### -# Git settings: - -## Enable/disable looking for a git repo (default: True) -#git: true - -## Enable/disable adding .aider* to .gitignore (default: True) -#gitignore: true - -## Specify the aider ignore file (default: .aiderignore in git root) -#aiderignore: .aiderignore - -## Only consider files in the current subtree of the git repository -#subtree-only: false - -## Enable/disable auto commit of LLM changes (default: True) -auto-commits: false - -## Enable/disable commits when repo is found dirty (default: True) -#dirty-commits: true - -## Attribute aider code changes in the git author name (default: True) -attribute-author: false - -## Attribute aider commits in the git committer name (default: True) -attribute-committer: false - -## Prefix commit messages with 'aider: ' if aider authored the changes (default: False) -#attribute-commit-message-author: false - -## Prefix all commit messages with 'aider: ' (default: False) -#attribute-commit-message-committer: false - -## Commit all pending changes with a suitable commit message, then exit -#commit: false - -## Specify a custom prompt for generating commit messages -#commit-prompt: xxx - -## Perform a dry run without modifying files (default: False) -#dry-run: false - -## Skip the sanity check for the git repository (default: False) -#skip-sanity-check-repo: false - -## Enable/disable watching files for ai coding comments (default: False) -#watch-files: false - -######################## -# Fixing and committing: - -## Lint and fix provided files, or dirty files if none provided -#lint: false - -## Specify lint commands to run for different languages, eg: "python: flake8 --select=..." (can be used multiple times) -#lint-cmd: xxx -## Specify multiple values like this: -#lint-cmd: -# - xxx -# - yyy -# - zzz - -## Enable/disable automatic linting after changes (default: True) -#auto-lint: true - -## Specify command to run tests -#test-cmd: xxx - -## Enable/disable automatic testing after changes (default: False) -#auto-test: false - -## Run tests, fix problems found and then exit -#test: false - -############ -# Analytics: - -## Enable/disable analytics for current session (default: random) -#analytics: xxx - -## Specify a file to log analytics events -#analytics-log: xxx - -## Permanently disable analytics -analytics-disable: true - -############ -# Upgrading: - -## Check for updates and return status in the exit code -#just-check-update: false - -## Check for new aider versions on launch -check-update: false - -## Show release notes on first run of new version (default: None, ask user) -#show-release-notes: xxx - -## Install the latest version from the main branch -#install-main-branch: false - -## Upgrade aider to the latest version from PyPI -#upgrade: false - -## Show the version number and exit -#version: xxx - -######## -# Modes: - -## Specify a single message to send the LLM, process reply then exit (disables chat mode) -#message: xxx - -## Specify a file containing the message to send the LLM, process reply, then exit (disables chat mode) -#message-file: xxx - -## Run aider in your browser (default: False) -#gui: false - -## Enable automatic copy/paste of chat between aider and web UI (default: False) -#copy-paste: false - -## Apply the changes from the given file instead of running the chat (debug) -#apply: xxx - -## Apply clipboard contents as edits using the main model's editor format -#apply-clipboard-edits: false - -## Do all startup activities then exit before accepting user input (debug) -#exit: false - -## Print the repo map and exit (debug) -#show-repo-map: false - -## Print the system prompts and exit (debug) -#show-prompts: false - -################# -# Voice settings: - -## Audio format for voice recording (default: wav). webm and mp3 require ffmpeg -voice-format: mp3 - -## Specify the language for voice using ISO 639-1 code (default: auto) -#voice-language: en - -## Specify the input device name for voice recording -#voice-input-device: xxx - -################# -# Other settings: - -## specify a file to edit (can be used multiple times) -#file: xxx -## Specify multiple values like this: -#file: -# - xxx -# - yyy -# - zzz - -## specify a read-only file (can be used multiple times) -#read: xxx -## Specify multiple values like this: -#read: -# - xxx -# - yyy -# - zzz - -## Use VI editing mode in the terminal (default: False) -vim: true - -## Specify the language to use in the chat (default: None, uses system settings) -#chat-language: xxx - -## Always say yes to every confirmation -#yes-always: false - -## Enable verbose output -#verbose: false - -## Load and execute /commands from a file on launch -#load: xxx - -## Specify the encoding for input and output (default: utf-8) -#encoding: utf-8 - -## Line endings to use when writing files (default: platform) -#line-endings: platform - -## Specify the config file (default: search for .aider.conf.yml in git root, cwd or home directory) -#config: xxx - -## Specify the .env file to load (default: .env in git root) -#env-file: .env - -## Enable/disable suggesting shell commands (default: True) -#suggest-shell-commands: true - -## Enable/disable fancy input with history and completion (default: True) -#fancy-input: true - -## Enable/disable multi-line input mode with Meta-Enter to submit (default: False) -multiline: false - -## Enable/disable detection and offering to add URLs to chat (default: True) -#detect-urls: true - -## Specify which editor to use for the /editor command -editor: nvim diff --git a/programs/aider/default.nix b/programs/aider/default.nix deleted file mode 100644 index 9f2863c..0000000 --- a/programs/aider/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ pkgs, ... }: - -let - aiderConfig = builtins.readFile ./aider.yml; -in -{ - home.packages = with pkgs; [ - aider-chat-full - ]; - home.file.".aider.conf.yml".text = aiderConfig; -} diff --git a/programs/broot/default.nix b/programs/broot/default.nix deleted file mode 100644 index 84288d9..0000000 --- a/programs/broot/default.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ ... }: -let - myverbs = [ - { - invocation = "panel_right"; - key = "alt-right"; - internal = ":panel_right"; - } - { - invocation = "panel_left_no_open"; - key = "alt-left"; - internal = ":panel_left_no_open"; - } - ]; -in -{ - programs.broot = { - enable = true; - enableFishIntegration = true; - settings = { - modal = true; - verbs = myverbs; - }; - }; -} diff --git a/programs/default.nix b/programs/default.nix index 97af51d..5dcd279 100644 --- a/programs/default.nix +++ b/programs/default.nix @@ -1,13 +1,4 @@ [ - ./aider - ./broot - ./fish - ./ghostty ./git - ./jujutsu - ./kitty ./tmux - ./wezterm - ./vscode - ./zed ] diff --git a/programs/fish/default.nix b/programs/fish/default.nix deleted file mode 100644 index f311ce6..0000000 --- a/programs/fish/default.nix +++ /dev/null @@ -1,103 +0,0 @@ -{ pkgs, ... }: - -{ - home.packages = with pkgs; [ - fish - fishPlugins.foreign-env - fishPlugins.bobthefish - ]; - - home.shell.enableFishIntegration = true; - - programs.fish = { - enable = true; - - functions = { - gitignore = "curl -sL https://www.gitignore.io/api/$argv"; - ot = '' - set otresult (ollama run qwen2.5-coder "Provide only the MacOS terminal command (without markdown) to: $argv") - commandline $otresult - ''; - }; - - plugins = [ - { - name = "fish-ssh-agent"; - src = pkgs.fetchFromGitHub { - owner = "danhper"; - repo = "fish-ssh-agent"; - rev = "f10d95775352931796fd17f54e6bf2f910163d1b"; - sha256 = "sha256-cFroQ7PSBZ5BhXzZEKTKHnEAuEu8W9rFrGZAb8vTgIE="; - }; - } - ]; - - shellInitLast = '' - set -xg TERM xterm-256color - if test -e /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh - fenv source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh - end - - if test -e /nix/var/nix/profiles/default/etc/profile.d/nix.sh - fenv source /nix/var/nix/profiles/default/etc/profile.d/nix.sh - end - - if test -e $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh - fenv source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh - end - - set -xg PATH /Applications/Ghostty.app/Contents/MacOS $HOME/bin $HOME/.cargo/bin $HOME/.npm-global/bin /Users/salar/.luarocks/bin:/Users/salar/bin:/Users/salar/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin $PATH - - set -xg WORKSPACE /Users/salar/Projects - - set -xg FZF_DEFAULT_OPTS "--preview='bat {} --color=always'" \n - - set -xg TOOLCHAINS swift - - set -xg DEVELOPER_DIR "/Library/Developer/CommandLineTools" - set -xg OPENAI_API_KEY (cat ~/.openai) - set -xg ANTHROPIC_API_KEY (cat ~/.anthropic) - ''; - - interactiveShellInit = '' - jj util completion fish | source - eval (direnv hook fish) - any-nix-shell fish --info-right | source - ''; - - shellAliases = { - addsshmac = "ssh-add ~/.ssh/id_ed25519 --apple-use-keychain --apple-load-keychain"; - bf = "broot"; - cat = "bat"; - du = "dua i"; - linesofcode = "git ls-files | xargs wc -l"; - fzfp = "fzf --preview 'bat --style=numbers --color=always --line-range :500 {}'"; - ping = "prettyping"; - ".." = "cd .."; - pj = "python -m json.tool"; - l = "ll"; - g = "git"; - ghauth = "gh auth login --with-token < ~/.ghauth"; - gitpurgemain = ''git branch --merged | grep -v "\*" | grep -v "main" | xargs -n 1 git branch -d''; - gitpurgemaster = ''git branch --merged | grep -v "\*" | grep -v "master" | xargs -n 1 git branch -d''; - giscala = "gitignore scala,vim,java,sbt > .gitignore"; - gforksync = "git fetch upstream && git merge upstream/master && git push origin master"; - grep = "grep --color=auto"; - hg = "kitten hyperlinked-grep"; - lg = "lazygit"; - new-sbt = "sbt new scala/scala-seed.g8"; - nixc = "cd ~/.config/nixpkgs"; - nixre = "nix build && sudo ./result/activate"; - nixinfo = "nix-shell -p nix-info --run \"nix-info -m\""; - nixgc = "nix-collect-garbage -d"; - nixq = "nix-env -qa"; - nixstorerepair = "nix-store --repair --verify --check-contents"; - nixupgrade = "nix upgrade-nix"; - o = "echo (ollama run qwen2.5-coder \"Provide only the MacOS terminal command (without markdown) to: $argv\")"; - rmxcodederived = "rm -fr ~/Library/Developer/Xcode/DerivedData"; - v = "nvim"; - sshhcloud1 = "ssh salar@hcloud1.softinio.net"; - sshhcloud1r = "ssh root@hcloud1.softinio.net"; - }; - }; -} diff --git a/programs/ghostty/default.nix b/programs/ghostty/default.nix deleted file mode 100644 index bf2778e..0000000 --- a/programs/ghostty/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ pkgs, ... }: -let - my_settings = { - auto-update = "off"; - copy-on-select = "clipboard"; - font-family = "SF Mono"; - font-size = 16; - macos-titlebar-style = "transparent"; - mouse-hide-while-typing = true; - split-divider-color = "orange"; - theme = "Builtin Tango Dark"; - window-inherit-working-directory = true; - window-save-state = "always"; - working-directory = "home"; - keybind = [ - "shift+enter=text:\n" - ]; - }; -in -{ - programs.ghostty = { - enable = true; - enableFishIntegration = true; - installVimSyntax = true; - package = pkgs.ghostty-bin; - settings = my_settings; - }; -} diff --git a/programs/git/default.nix b/programs/git/default.nix index c4a7a87..5dad237 100644 --- a/programs/git/default.nix +++ b/programs/git/default.nix @@ -1,77 +1,63 @@ -{ ... }: +{ config, pkgs, ... }: let gitConfig = { core = { editor = "nvim"; + pager = "diff-so-fancy | less --tabs=4 -RFX"; }; - diff = { - colorMoved = "default"; - external = "difft"; - tool = "difftastic"; - }; - difftool.difftastic = { - cmd = "difft \"$MERGED\" \"$LOCAL\" \"abcdef1\" \"100644\" \"$REMOTE\" \"abcdef2\" \"100644\""; + init.defaultBranch = "main"; + merge.conflictstyle = "diff3"; + merge.tool = "nvim"; + mergetool.nvim = { + cmd = "nvim -d -c \"wincmd l\" -c \"norm ]c\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\""; prompt = false; + keepBackup = false; }; + diff.tool = "nvim"; difftool.nvim = { cmd = "nvim -d \"$LOCAL\" \"$REMOTE\""; prompt = false; }; - fetch.prune = true; - init.defaultBranch = "main"; - merge.tool = "intellij"; - mergetool = { - intellij = { - cmd = "'/Applications/IntelliJ IDEA.app/Contents/macOS/idea' merge \“$LOCAL\” \“$REMOTE\” \“$BASE\” \“$MERGED\”"; - trustExitCode = true; - }; - keepBackup = false; - }; - pager = { - difftool = true; - }; - pull = { - rebase = true; - }; url = { "git@github.com:" = { insteadOf = "https://github.com/"; }; }; + fetch.prune = true; + pull = { + rebase = true; + }; }; myAliases = { ci = "commit"; - cim = "commit -m"; - cia = "commit -am"; co = "checkout"; - cob = "checkout -b"; - di = "diff"; - gpo = "push origin"; main = "checkout main"; master = "checkout master"; - st = "status"; }; myIgnores = [ - ".DS_Store" - ".aider*" - "*.bloop" - ".direnv/" - ".idea/" - ".mypy_cache" - "*.metals" - "*.metals.sbt" - "*metals.sbt" - "*.envrc" # there is lorri, nix-direnv & simple direnv; let people decide - "*hie.yaml" # ghcide files - "*.vscode" - "result" - ]; + "*~" + ".DS_Store" + "*.bloop" + ".direnv/" + ".idea/" + ".mypy_cache" + "*.metals" + "*.metals.sbt" + "*metals.sbt" + "*.direnv" + "*.envrc" # there is lorri, nix-direnv & simple direnv; let people decide + "*hie.yaml" # ghcide files + "*.mill-version" # used by metals + "*.idea" + "*.vscode" + "*.python-version" + "result" + ]; in { programs.git = { enable = true; - lfs.enable = true; userEmail = "code@softinio.com"; userName = "Salar Rahmanian"; aliases = myAliases; diff --git a/programs/jujutsu/default.nix b/programs/jujutsu/default.nix deleted file mode 100644 index 6f4a9c8..0000000 --- a/programs/jujutsu/default.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ ... }: -let - MyAliases = { - l = [ - "log" - "-r" - "(main..@):: | (main..@)-" - ]; - }; -in -{ - programs.jujutsu = { - enable = true; - settings = { - aliases = MyAliases; - signing = { - key = "~/.ssh/id_ed25519.pub"; - }; - ui = { - diff-formatter = [ - "difft" - "--color=always" - "$left" - "$right" - ]; - editor = "nvim"; - merge-editor = [ - "meld" - "$left" - "$base" - "$right" - "-o" - "$output" - ]; - pager = "less -FRX"; - }; - user = { - name = "Salar Rahmanian"; - email = "code@softinio.com"; - }; - }; - }; -} diff --git a/programs/kitty/default.nix b/programs/kitty/default.nix deleted file mode 100644 index a8ba4e0..0000000 --- a/programs/kitty/default.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ pkgs, ... }: - -let - actionsConfig = builtins.readFile ./open-actions.conf; -in -{ - programs.kitty = { - enable = true; - keybindings = { - "kitty_mod+enter" = "new_window_with_cwd"; - "f1" = "create_marker"; - "f2" = "remove_marker"; - "ctrl+p" = "scroll_to_mark prev"; - "ctrl+n" = "scroll_to_mark next"; - }; - themeFile = "Tango_Dark"; - font = { - name = "SF Mono"; - size = 13; - }; - settings = { - active_tab_background = "#FF0"; - copy_on_select = true; - enabled_layouts = "Tall,Stack,Horizontal,*"; - kitty_mod = "cmd+option"; - macos_quit_when_last_window_closed = true; - scrollback_lines = 100000; - tab_bar_style = "powerline"; - tab_powerline_style = "slanted"; - }; - shellIntegration.enableFishIntegration = true; - }; - - home.file.".config/kitty/open-actions.conf".text = actionsConfig; -} diff --git a/programs/kitty/open-actions.conf b/programs/kitty/open-actions.conf deleted file mode 100644 index 3c172ab..0000000 --- a/programs/kitty/open-actions.conf +++ /dev/null @@ -1,40 +0,0 @@ -# Open any file with a fragment in vim, fragments are generated -# by the hyperlink-grep kitten and nothing else so far. -protocol file -fragment_matches [0-9]+ -action launch --type=overlay --cwd=current hx +${FRAGMENT} -- ${FILE_PATH} - -# Open text files without fragments in the editor -protocol file -ext txt,md,conf,ini,log,sh,py,js,html,css,xml,json,yaml,yml,scala,sbt,java,go,py,toml,sql,swift,nix,lua -action launch --type=overlay --cwd=current -- hx -- ${FILE_PATH} - -# Open any image in the full kitty window by clicking on it -protocol file -mime image/* -action launch --type=overlay kitten icat --hold -- ${FILE_PATH} - -# Tail a log file (*.log) in a new OS Window and reduce its font size -protocol file -ext log -action launch --title ${FILE} --type=os-window tail -f -- ${FILE_PATH} -action change_font_size current -2 - -# Open script files -protocol file -ext sh,command,tool -action launch --hold --type=os-window kitty +shebang $FILE_PATH $SHELL - -# Open shell specific script files -protocol file -ext fish,bash,zsh -action launch --hold --type=os-window kitty +shebang $FILE_PATH __ext__ - -# Open directories -protocol file -mime inode/directory -action launch --type=os-window --cwd -- $FILE_PATH - -# Open ssh URLs with ssh command -protocol ssh -action launch --type=os-window ssh -- $URL diff --git a/programs/neovim/init.lua b/programs/neovim/init.lua new file mode 100644 index 0000000..3eb875f --- /dev/null +++ b/programs/neovim/init.lua @@ -0,0 +1,653 @@ +local fn = vim.fn + +local install_path = fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim' + +local function load_plugins() + local use = require('packer').use + require('packer').startup(function() + use 'wbthomason/packer.nvim' -- Package manager + use 'neovim/nvim-lspconfig' -- Collection of configurations for built-in LSP client + use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } + use 'nvim-treesitter/nvim-treesitter-textobjects' + use 'nvim-treesitter/playground' + use 'folke/which-key.nvim' + use 'folke/lua-dev.nvim' + use 'folke/tokyonight.nvim' -- Theme + use { 'folke/trouble.nvim', requires = 'kyazdani42/nvim-web-devicons' } + use { 'justinhj/battery.nvim', requires = {{'kyazdani42/nvim-web-devicons'}, {'nvim-lua/plenary.nvim'}}} + use { 'nvim-telescope/telescope.nvim', requires = { { 'nvim-lua/popup.nvim' }, { 'nvim-lua/plenary.nvim' } } } + use 'nvim-telescope/telescope-dap.nvim' + use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' } + use { 'softinio/scaladex.nvim' } + use 'windwp/nvim-autopairs' -- Autopairs + use 'kyazdani42/nvim-tree.lua' -- File explorer + use { + 'glepnir/galaxyline.nvim', + config = function() + require 'salargalaxyline' + end, + requires = 'kyazdani42/nvim-web-devicons', + } + use 'lukas-reineke/indent-blankline.nvim' + use { 'lewis6991/gitsigns.nvim', requires = 'nvim-lua/plenary.nvim' } + use { 'TimUntersberger/neogit', requires = { { 'nvim-lua/plenary.nvim' }, { 'sindrets/diffview.nvim' } } } + use { + 'hrsh7th/nvim-cmp', + requires = { + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + 'hrsh7th/cmp-nvim-lua', + 'hrsh7th/cmp-nvim-lsp-signature-help', + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + } + } + use {'tzachar/cmp-tabnine', run='./install.sh', requires = 'hrsh7th/nvim-cmp'} + use 'kevinhwang91/nvim-bqf' + use 'mfussenegger/nvim-dap' + use 'mfussenegger/nvim-dap-python' + use 'jbyuki/one-small-step-for-vimkind' + use {'theHamsta/nvim-dap-virtual-text'} + use 'sheerun/vim-polyglot' + use 'scalameta/nvim-metals' + use 'b3nj5m1n/kommentary' + use 'ckipp01/stylua-nvim' + use 'gennaro-tedesco/nvim-jqx' + use 'p00f/nvim-ts-rainbow' + use 'christoomey/vim-tmux-navigator' + use 'lervag/vimtex' + use { + 'f3fora/nvim-texlabconfig', + run = 'go build' + } + end) +end + +_G.load_config = function() + require('gitsigns').setup() + require('kommentary.config').use_extended_mappings() + require 'salargalaxyline' + require('trouble').setup() + require('which-key').setup() + require('indent_blankline').setup({ + indent_blankline_use_treesitter = true + }) + + -- nvim-autopairs + require('nvim-autopairs').setup() + + -- battery.nvim + local battery = require("battery") + battery.setup({ + update_rate_seconds = 30, -- Number of seconds between checking battery status + show_status_when_no_battery = true, -- Don't show any icon or text when no battery found (desktop for example) + show_plugged_icon = true, -- If true show a cable icon alongside the battery icon when plugged in + show_unplugged_icon = true, -- When true show a diconnected cable icon when not plugged in + show_percent = true, -- Whether or not to show the percent charge remaining in digits + vertical_icons = true, -- When true icons are vertical, otherwise shows horizontal battery icon + }) + + -- nvim-dap + local dap = require('dap') + dap.configurations.lua = { + { + type = 'nlua', + request = 'attach', + name = "Attach to running Neovim instance", + host = function() + local value = vim.fn.input('Host [127.0.0.1]: ') + if value ~= "" then + return value + end + return '127.0.0.1' + end, + port = function() + local val = tonumber(vim.fn.input('Port: ')) + assert(val, "Please provide a port number") + return val + end, + } + } + + dap.adapters.nlua = function(callback, config) + callback({ type = 'server', host = config.host, port = config.port or 8088 }) + end + + dap.configurations.scala = { + { + type = "scala", + request = "launch", + name = "Run", + metals = { + runType = "run", + args = { "firstArg", "secondArg", "thirdArg" }, + }, + }, + { + type = "scala", + request = "launch", + name = "Test File", + metals = { + runType = "testFile", + }, + }, + { + type = "scala", + request = "launch", + name = "Test Target", + metals = { + runType = "testTarget", + }, + }, + } + + + vim.fn.sign_define('DapBreakpoint', {text='🛑', texthl='', linehl='', numhl=''}) + vim.fn.sign_define('DapStopped', {text='⭐️', texthl='', linehl='', numhl=''}) + + require('dap-python').test_runner = 'pytest' + + -- vimtex + vim.g.vimtex_view_method = 'skim' + vim.g.vimtex_compiler_method = 'tectonic' + + -- nvim-texlabconfig + local tex_preview_executable = '/Applications/Skim.app/Contents/SharedSupport/displayline' + local tex_preview_args = {"%l", "%p", "%f"} + local texlab_build_executable = 'tectonic' + local texlab_build_args = { + '-X', + 'compile', + '%f', + '--synctex', + '--keep-logs', + '--keep-intermediates' + } + require('texlabconfig').setup { + cache_activate = true, + cache_filetypes = { 'tex', 'bib' }, + reverse_search_edit_cmd = 'split', + settings = { + texlab = { + build = { + executable = texlab_build_executable, + args = texlab_build_args + }, + forwardSearch = { + executable = tex_preview_executable, + args = tex_preview_args + } + } + } + } + + -- nvim-tree + require('nvim-tree').setup() + + -- Treesitter + require('nvim-treesitter.configs').setup { + query_linter = { + enable = true, + use_virtual_text = true, + lint_events = { 'BufWrite', 'CursorHold' }, + }, + -- ensure_installed = 'maintained', + highlight = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = 'gnn', + node_incremental = 'grn', + scope_incremental = 'grc', + node_decremental = 'grm', + }, + }, + indent = { + enable = true, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + }, + playground = { + enable = true, + disable = {}, + updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code + persist_queries = false, -- Whether the query persists across vim sessions + keybindings = { + toggle_query_editor = 'o', + toggle_hl_groups = 'i', + toggle_injected_languages = 't', + toggle_anonymous_nodes = 'a', + toggle_language_display = 'I', + focus_language = 'f', + unfocus_language = 'F', + update = 'R', + goto_node = '', + show_help = '?', + }, + }, + rainbow = { + enable = true, + extended_mode = true, + max_file_lines = 1000, + }, + } + -- vim.opt.foldmethod = 'expr' + -- vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' + ---WORKAROUND + vim.api.nvim_create_autocmd({'BufEnter','BufAdd','BufNew','BufNewFile','BufWinEnter'}, { + group = vim.api.nvim_create_augroup('TS_FOLD_WORKAROUND', {}), + callback = function() + vim.opt.foldmethod = 'expr' + vim.opt.foldexpr = 'nvim_treesitter#foldexpr()' + end + }) + ---ENDWORKAROUND + + -- neogit + require('neogit').setup { + integrations = { + diffview = true, + }, + } + + --Incremental live completion + vim.o.inccommand = 'nosplit' + + --Set highlight on search + vim.o.hlsearch = false + vim.o.incsearch = true + + --Make line numbers default + vim.wo.number = true + + --Do not save when switching buffers + vim.o.hidden = true + + --Enable mouse mode + vim.o.mouse = 'a' + + -- clipboard + vim.o.clipboard = 'unnamedplus' + + --Enable break indent + vim.o.breakindent = true + + --Save undo history + vim.cmd [[set undofile]] + + --Case insensitive searching UNLESS /C or capital in search + vim.o.ignorecase = true + vim.o.smartcase = true + + --Decrease update time + vim.o.updatetime = 250 + vim.wo.signcolumn = 'yes' + + --Set colorscheme (order is important here) + vim.g.tokyonight_style = 'night' + vim.g.tokyonight_italic_functions = true + vim.o.termguicolors = true + vim.cmd [[colorscheme tokyonight]] + + --Remap space as leader key + vim.api.nvim_set_keymap('', '', '', { noremap = true, silent = true }) + vim.g.mapleader = ' ' + vim.g.maplocalleader = ' ' + + --Remap for dealing with word wrap + vim.api.nvim_set_keymap('n', 'k', "v:count == 0 ? 'gk' : 'k'", { noremap = true, expr = true, silent = true }) + vim.api.nvim_set_keymap('n', 'j', "v:count == 0 ? 'gj' : 'j'", { noremap = true, expr = true, silent = true }) + + --Remap escape to leave terminal mode + vim.api.nvim_set_keymap('t', '', [[]], { noremap = true }) + + --Add map to enter paste mode + vim.o.pastetoggle = '' + + --Map blankline + vim.g.indent_blankline_char = '┊' + vim.g.indent_blankline_filetype_exclude = { 'help', 'packer' } + vim.g.indent_blankline_buftype_exclude = { 'terminal', 'nofile' } + vim.g.indent_blankline_char_highlight = 'LineNr' + + -- Toggle to disable mouse mode and indentlines for easier paste + ToggleMouse = function() + if vim.o.mouse == 'a' then + vim.cmd [[IndentBlanklineDisable]] + vim.wo.signcolumn = 'no' + vim.o.mouse = 'v' + vim.wo.number = false + print 'Mouse disabled' + else + vim.cmd [[IndentBlanklineEnable]] + vim.wo.signcolumn = 'yes' + vim.o.mouse = 'a' + vim.wo.number = true + print 'Mouse enabled' + end + end + + vim.api.nvim_set_keymap('n', '', 'lua ToggleMouse()', { noremap = true }) + + -- Telescope + require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = false, + [''] = false, + }, + }, + file_ignore_patterns = { "node_modules", "target"}, + extensions = { + fzf = { + fuzzy = true, + override_generic_sorter = true, + override_file_sorter = true, + case_mode = "smart_case" + } + } + }, + } + require('telescope').load_extension('dap') + require('telescope').load_extension('fzf') + require('telescope').load_extension('scaladex') + + --Add leader shortcuts + vim.api.nvim_set_keymap('n', 'f', [[lua require('telescope.builtin').find_files()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', '', [[lua require('telescope.builtin').buffers()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'l', [[lua require('telescope.builtin').current_buffer_fuzzy_find()]], { noremap = true, silent = true }) + -- vim.api.nvim_set_keymap('n', 't', [[lua require('telescope.builtin').tags()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', '?', [[lua require('telescope.builtin').oldfiles()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'sd', [[lua require('telescope.builtin').grep_string()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'sp', [[lua require('telescope.builtin').live_grep()]], { noremap = true, silent = true }) + -- vim.api.nvim_set_keymap('n', 'o', [[lua require('telescope.builtin').tags{ only_current_buffer = true }]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'gco', [[lua require('telescope.builtin').git_commits()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'gb', [[lua require('telescope.builtin').git_branches()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'gs', [[lua require('telescope.builtin').git_status()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'gp', [[lua require('telescope.builtin').git_bcommits()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'm', [[lua require('nvim-tree').toggle()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'ng', [[lua require('neogit').open({ kind = "split" })]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'nm', [[lua require("telescope").extensions.metals.commands()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'tt', [[lua require("metals.tvp").toggle_tree_view()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'tr', [[lua require("metals.tvp").reveal_in_tree()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'ws', [[lua require"metals".worksheet_hover()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'a', [[lua RELOAD("metals").open_all_diagnostics()]], { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'nu', ':PackerUpdate', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'si', [[lua require('telescope').extensions.scaladex.scaladex.search()]], { noremap = true, silent = true }) + + -- Change preview window location + vim.g.splitbelow = true + + -- Highlight on yank + vim.api.nvim_exec( + [[ + augroup YankHighlight + autocmd! + autocmd TextYankPost * silent! lua vim.highlight.on_yank() + augroup end + ]], + false + ) + + -- Y yank until the end of line + vim.api.nvim_set_keymap('n', 'Y', 'y$', { noremap = true }) + -- + -- LSP settings + local nvim_lsp = require 'lspconfig' + local on_attach = function(_client, bufnr) + vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + + local opts = { noremap = true, silent = true } + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', 'lua vim.lsp.buf.declaration()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', 'lua vim.lsp.buf.definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', 'lua vim.lsp.buf.hover()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gm', 'lua vim.lsp.buf.implementation()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', 'lua vim.lsp.buf.signature_help()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'D', 'lua vim.lsp.buf.type_definition()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'rn', 'lua vim.lsp.buf.rename()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', 'lua vim.lsp.buf.references()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ca', 'lua vim.lsp.buf.code_action()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'e', 'lua vim.lsp.diagnostic.show_line_diagnostics()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', 'lua vim.lsp.diagnostic.goto_prev()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', 'lua vim.lsp.diagnostic.goto_next()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'q', 'lua vim.lsp.diagnostic.set_loclist()', opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'dr', [[lua require('dap').repl.toggle()]], { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ds', [[lua require('dap').ui.variables.scopes()]], { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'dk', [[lua require('dap').ui.widgets.hover()]], { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'dl', [[lua require('dap').run_last()]], { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'dz', [[lua require('dap').toggle_breakpoint()]], { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'dc', [[lua require('dap').continue()]], { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', [[lua require('dap').step_over()]], { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', [[lua require('dap').step_out()]], { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(bufnr, 'n', '', [[lua require('dap').step_into()]], { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'B', [[lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))]], { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'lp', [[lua require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: '))]], { noremap = true, silent = true }) + end + + -- Enable the following language servers + local servers = { 'html', 'jdtls', 'jsonls', 'pyright', 'rnix', 'rust_analyzer','sourcekit', 'tsserver', 'yamlls' } + for _, lsp in ipairs(servers) do + nvim_lsp[lsp].setup { on_attach = on_attach } + end + + -- lua language server + local sumneko_binary = vim.fn.getenv 'HOME' .. '/.nix-profile/bin/lua-language-server' + local runtime_path = vim.split(package.path, ';') + table.insert(runtime_path, 'lua/?.lua') + table.insert(runtime_path, 'lua/?/init.lua') + + local luadev = require('lua-dev').setup{ + lspconfig = { + cmd = { sumneko_binary }, + commands = { + Format = { + function() + require('stylua-nvim').format_file() + end, + }, + }, + on_attach = on_attach, + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = runtime_path, + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { 'vim' }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = { + vim.api.nvim_get_runtime_file('', true), + }, + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, + }, + }, + }, + } + nvim_lsp.sumneko_lua.setup(luadev) + + -- metals + vim.g.metals_server_version = '0.11.8' + vim.opt_global.completeopt = { "menuone", "noinsert", "noselect" } + vim.opt_global.shortmess:remove("F"):append("c") + local metals_config = require('metals').bare_config() + metals_config.settings = { + showImplicitArguments = true, + showInferredType = true, + bloopSbtAlreadyInstalled = false, + excludedPackages = { + "akka.actor.typed.javadsl", + "com.github.swagger.akka.javadsl", + "akka.stream.javadsl", + }, + fallbackScalaVersion = "2.13.8", + superMethodLensesEnabled = true, + javaHome = "/Users/salar/.nix-profile" + } + metals_config.init_options.statusBarProvider = 'on' + metals_config.on_attach = function(client, bufnr) + vim.cmd([[autocmd CursorHold lua vim.lsp.buf.document_highlight()]]) + vim.cmd([[autocmd CursorMoved lua vim.lsp.buf.clear_references()]]) + vim.cmd([[autocmd BufEnter,CursorHold,InsertLeave lua vim.lsp.codelens.refresh()]]) + + require("metals").setup_dap() + end + metals_config.init_options.statusBarProvider = "on" + local capabilities = vim.lsp.protocol.make_client_capabilities() + metals_config.capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities) + local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }) + vim.api.nvim_create_autocmd("FileType", { + pattern = { "scala", "sbt" }, + callback = function() + require("metals").initialize_or_attach(metals_config) + end, + group = nvim_metals_group, + }) + + -- Map :Format to vim.lsp.buf.formatting() + vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]] + + -- Set completeopt to have a better completion experience + vim.o.completeopt = 'menuone,noinsert' + + -- nvim-cmp + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + local cmp = require("cmp") + cmp.setup { + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + sources = { + { name = "nvim_lsp", priority = 10 }, + { name = "buffer" }, + { name = "luasnip" }, + { name = "cmp_tabnine" }, + { name = "path" }, + { name = 'nvim_lua' }, + { name = 'nvim_lsp_signature_help' } + }, + mapping = cmp.mapping.preset.insert({ + -- None of this made sense to me when first looking into this since there + -- is no vim docs, but you can't have select = true here _unless_ you are + -- also using the snippet stuff. So keep in mind that if you remove + -- snippets you need to remove this select + [""] = cmp.mapping.confirm({ select = true }), + -- I use tabs... some say you should stick to ins-completion but this is just here as an example + [""] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, + [""] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, + }), + } + cmp.event:on( + 'confirm_done', + cmp_autopairs.on_confirm_done() + ) +-- + + 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 check_back_space() then + return t '' + else + return vim.fn['cmp#complete']() + end + end + _G.s_tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t '' + else + return t '' + end + end + + 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 + +if fn.isdirectory(install_path) == 0 then + fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path } + load_plugins() + require('packer').sync() + vim.cmd 'autocmd User PackerComplete ++once lua load_config()' +else + load_plugins() + _G.load_config() +end diff --git a/programs/neovim/settings/salargalaxyline.lua b/programs/neovim/settings/salargalaxyline.lua new file mode 100644 index 0000000..729f50b --- /dev/null +++ b/programs/neovim/settings/salargalaxyline.lua @@ -0,0 +1,210 @@ +local gl = require 'galaxyline' +local gls = gl.section +gl.short_line_list = { 'LuaTree', 'vista', 'dbui' } + +local colors = { + bg = '#282c34', + yellow = '#fabd2f', + cyan = '#008080', + darkblue = '#081633', + green = '#afd700', + orange = '#FF8800', + purple = '#5d4d7a', + magenta = '#d16d9e', + grey = '#c0c0c0', + blue = '#0087d7', + red = '#ec5f67', +} + +local buffer_not_empty = function() + if vim.fn.empty(vim.fn.expand '%:t') ~= 1 then + return true + end + return false +end + +gls.left[1] = { + FirstElement = { + provider = function() + return '▋' + end, + highlight = { colors.blue, colors.yellow }, + }, +} +gls.left[2] = { + ViMode = { + provider = function() + local alias = { n = 'NORMAL', i = 'INSERT', c = 'COMMAND', v = 'VISUAL', V = 'VISUAL LINE', [''] = 'VISUAL BLOCK' } + return alias[vim.fn.mode()] + end, + separator = '', + separator_highlight = { + colors.purple, + function() + if not buffer_not_empty() then + return colors.purple + end + return colors.darkblue + end, + }, + highlight = { colors.darkblue, colors.purple, 'bold' }, + }, +} +gls.left[3] = { + FileIcon = { + provider = 'FileIcon', + condition = buffer_not_empty, + highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.darkblue }, + }, +} +gls.left[4] = { + FileName = { + provider = { 'FileName', 'FileSize' }, + condition = buffer_not_empty, + separator = '', + separator_highlight = { colors.purple, colors.darkblue }, + highlight = { colors.magenta, colors.darkblue }, + }, +} + +gls.left[5] = { + GitIcon = { + provider = function() + return '  ' + end, + condition = buffer_not_empty, + highlight = { colors.orange, colors.purple }, + }, +} +gls.left[6] = { + GitBranch = { + provider = 'GitBranch', + condition = buffer_not_empty, + highlight = { colors.grey, colors.purple }, + }, +} + +local checkwidth = function() + local squeeze_width = vim.fn.winwidth(0) / 2 + if squeeze_width > 40 then + return true + end + return false +end + +gls.left[7] = { + DiffAdd = { + provider = 'DiffAdd', + condition = checkwidth, + icon = ' ', + highlight = { colors.green, colors.purple }, + }, +} +gls.left[8] = { + DiffModified = { + provider = 'DiffModified', + condition = checkwidth, + icon = ' ', + highlight = { colors.orange, colors.purple }, + }, +} +gls.left[9] = { + DiffRemove = { + provider = 'DiffRemove', + condition = checkwidth, + icon = ' ', + highlight = { colors.red, colors.purple }, + }, +} +gls.left[10] = { + LeftEnd = { + provider = function() + return '' + end, + separator = '', + separator_highlight = { colors.purple, colors.bg }, + highlight = { colors.purple, colors.purple }, + }, +} +gls.left[11] = { + DiagnosticError = { + provider = 'DiagnosticError', + icon = '  ', + highlight = { colors.red, colors.bg }, + }, +} +gls.left[12] = { + Space = { + provider = function() + return ' ' + end, + }, +} +gls.left[13] = { + DiagnosticWarn = { + provider = 'DiagnosticWarn', + icon = '  ', + highlight = { colors.blue, colors.bg }, + }, +} +gls.right[1] = { + FileFormat = { + provider = 'FileFormat', + separator = '', + separator_highlight = { colors.bg, colors.purple }, + highlight = { colors.grey, colors.purple }, + }, +} +gls.right[2] = { + LineInfo = { + provider = 'LineColumn', + separator = ' | ', + separator_highlight = { colors.darkblue, colors.purple }, + highlight = { colors.grey, colors.purple }, + }, +} +gls.right[3] = { + PerCent = { + provider = 'LinePercent', + separator = '', + separator_highlight = { colors.darkblue, colors.purple }, + highlight = { colors.grey, colors.darkblue }, + }, +} +gls.right[4] = { + ScrollBar = { + provider = 'ScrollBar', + separator_highlight = { colors.purple, colors.bg }, + highlight = { colors.yellow, colors.purple }, + }, +} +gls.right[5] = { + BatteryNvim = { + provider = function() + local status = require 'battery'.get_status_line() + local formatted = string.format(status) + return formatted + end, + separator = '', + separator_highlight = { colors.bg, colors.purple }, + highlight = { colors.grey, colors.purple }, + }, +} + +gls.short_line_left[1] = { + BufferType = { + provider = 'FileTypeName', + separator = '', + separator_highlight = { colors.purple, colors.bg }, + highlight = { colors.grey, colors.purple }, + }, +} + +gls.short_line_right[1] = { + BufferIcon = { + provider = 'BufferIcon', + separator = '', + separator_highlight = { colors.purple, colors.bg }, + highlight = { colors.grey, colors.purple }, + }, +} diff --git a/programs/tmux/default.nix b/programs/tmux/default.nix index e630d77..90cb547 100644 --- a/programs/tmux/default.nix +++ b/programs/tmux/default.nix @@ -1,7 +1,8 @@ -{ pkgs, ... }: +{ config, pkgs, ... }: let tmuxConfig = builtins.readFile ./tmux.conf; + in { programs.tmux = { @@ -13,34 +14,25 @@ in prefix = "C-a"; terminal = "xterm-256color"; extraConfig = tmuxConfig; - plugins = with pkgs.tmuxPlugins; [ - sensible - yank - kanagawa + plugins = with pkgs; [ { - plugin = kanagawa; - extraConfig = '' - set -g @kanagawa-theme 'wave' - set -g @kanagawa-plugins "cpu-usage git" - set -g @kanagawa-show-powerline true - set -g @kanagawa-refresh-rate 10 - - set -g status-right " #(tms sessions)" - bind -r '(' switch-client -p\; refresh-client -S - bind -r ')' switch-client -n\; refresh-client -S - ''; - } - { - plugin = resurrect; + plugin = tmuxPlugins.resurrect; extraConfig = "set -g @resurrect-strategy-nvim 'session'"; } { - plugin = continuum; - extraConfig = '' - set -g @continuum-restore 'on' - set -g @continuum-save-interval '60' # minutes - ''; + plugin = tmuxPlugins.continuum; + extraConfig = "set -g @continuum-restore 'on'"; + } + { + plugin = tmuxPlugins.sensible; + } + { + plugin = tmuxPlugins.vim-tmux-navigator; + } + { + plugin = tmuxPlugins.onedark-theme; } ]; }; } + diff --git a/programs/tmux/tmux.conf b/programs/tmux/tmux.conf index 9aef545..e2b72b3 100644 --- a/programs/tmux/tmux.conf +++ b/programs/tmux/tmux.conf @@ -56,9 +56,9 @@ bind p paste-buffer # paste from system clipboard MacOS # bind C-v run \"tmux set-buffer \"$(reattach-to-user-namespace pbpaste)\"; tmux paste-buffer" -# panes: window splitting +# panes: window splitting unbind % -bind "'" split-window -h +bind | split-window -h unbind '"' bind - split-window -v @@ -73,10 +73,10 @@ bind -r C-h select-window -t :- bind -r C-l select-window -t :+ # resize panes -bind -r H resize-pane -L 10 -bind -r J resize-pane -D 10 -bind -r K resize-pane -U 10 -bind -r L resize-pane -R 10 +bind -r H resize-pane -L 5 +bind -r J resize-pane -D 5 +bind -r K resize-pane -U 5 +bind -r L resize-pane -R 5 ## Quickly switch panes unbind ^J @@ -99,4 +99,12 @@ set -g status-left '#[fg=green] #S #[fg=yellow]#I/#[fg=cyan]#P ' # update status bar info set -g status-interval 60 -set -g default-command /etc/profiles/per-user/salar/bin/fish +########################### +# Colors +########################### + +# onedark color scheme +set -g @onedark_widgets "#(date +%s)" +set -g @onedark_time_format "%I:%M %p" +set -g @onedark_date_format "%D" + diff --git a/programs/vscode/default.nix b/programs/vscode/default.nix deleted file mode 100644 index 0e4fbad..0000000 --- a/programs/vscode/default.nix +++ /dev/null @@ -1,111 +0,0 @@ -{ pkgs, ... }: - -let - myExtensions = with pkgs.vscode-extensions; [ - asvetliakov.vscode-neovim - baccata.scaladex-search - charliermarsh.ruff - davidanson.vscode-markdownlint - github.copilot - github.copilot-chat - github.github-vscode-theme - github.vscode-github-actions - github.vscode-pull-request-github - humao.rest-client - jnoortheen.nix-ide - marp-team.marp-vscode - mechatroner.rainbow-csv - mkhl.direnv - ms-python.debugpy - ms-python.python - ms-python.vscode-pylance - ms-toolsai.datawrangler - ms-toolsai.jupyter - ms-toolsai.jupyter-keymap - ms-toolsai.jupyter-renderers - ms-toolsai.vscode-jupyter-cell-tags - ms-toolsai.vscode-jupyter-slideshow - ms-vscode.makefile-tools - redhat.java - redhat.vscode-yaml - scalameta.metals - skyapps.fish-vscode - sswg.swift-lang - svsool.markdown-memo - timonwong.shellcheck - usernamehw.errorlens - visualstudioexptteam.vscodeintellicode - visualjj.visualjj - vscode-icons-team.vscode-icons - vscjava.vscode-java-pack - yzhang.markdown-all-in-one - ]; - myUserSettings = { - "editor.fontFamily" = "SF Mono"; - "editor.fontLigatures" = true; - "editor.fontSize" = 13; - "editor.copyWithSyntaxHighlighting" = true; - "extensions.experimental.affinity" = { - "asvetliakov.vscode-neovim" = 1; - }; - "extensions.ignoreRecommendations" = true; - "files.autoSave" = "afterDelay"; - "git.confirmSync" = true; - "git.rebaseWhenSync" = true; - "github.gitProtocol" = "ssh"; - "github.copilot.chat.codesearch.enabled" = true; - "github.copilot.nextEditSuggestions.enabled" = true; - "github.copilot.chat.editor.temporalContext.enabled" = true; - "github.copilot.chat.generateTests.codeLens" = true; - "github.copilot.chat.languageContext.typescript.enabled" = true; - "github.copilot.chat.newWorkspaceCreation.enabled" = true; - "github.copilot.chat.search.semanticTextResults" = true; - "githubPullRequests.experimental.chat" = true; - "githubPullRequests.notifications" = "pullRequests"; - "githubPullRequests.pullBranch" = "never"; - "markdown.extension.preview.autoShowPreviewToSide" = true; - "notebook.formatOnSave" = true; - # Install paste image manually as not in nix ( https://marketplace.visualstudio.com/items?itemName=mushan.vscode-paste-image ) - "pasteImage.insertPattern" = "![[\${imageFileName}]]"; - "pasteImage.path" = "\${projectRoot}/Attachments"; - "python.analysis.extraPaths" = [ "src" ]; - "python.analysis.autoFormatStrings" = true; - "python.analysis.autoImportCompletions" = true; - "python.analysis.completeFunctionParens" = true; - "python.analysis.inlayHints.pytestParameters" = true; - "python.analysis.typeCheckingMode" = "strict"; - "python.testing.pytestEnabled" = true; - "[python]" = { - "editor.defaultFormatter" = "charliermarsh.ruff"; - "editor.formatOnSave" = true; - "editor.codeActionsOnSave" = { - "source.fixAll" = "always"; - "source.organizeImports" = "always"; - }; - }; - "telemetry.telemetryLevel" = "off"; - "terminal.integrated.defaultProfile.osx" = "fish"; - "terminal.integrated.fontFamily" = "SF Mono"; - "terminal.integrated.fontSize" = 13; - "update.mode" = "none"; - "vsicons.dontShowNewVersionMessage" = true; - "window.openFoldersInNewWindow" = "on"; - "workbench.colorTheme" = "GitHub Dark Default"; - "workbench.iconTheme" = "vscode-icons"; - "workbench.sideBar.location" = "right"; - }; -in -{ - programs.vscode = { - enable = true; - profiles = { - default = { - enableExtensionUpdateCheck = false; - enableUpdateCheck = false; - extensions = myExtensions; - userSettings = myUserSettings; - }; - }; - mutableExtensionsDir = false; - }; -} diff --git a/programs/wezterm/default.nix b/programs/wezterm/default.nix deleted file mode 100644 index c63a016..0000000 --- a/programs/wezterm/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ ... }: - -let - weztermConfig = builtins.readFile ./wezterm.lua; -in -{ - programs.wezterm = { - enable = true; - extraConfig = weztermConfig; - }; -} diff --git a/programs/wezterm/wezterm.lua b/programs/wezterm/wezterm.lua deleted file mode 100644 index c15ee4a..0000000 --- a/programs/wezterm/wezterm.lua +++ /dev/null @@ -1,127 +0,0 @@ -local wezterm = require 'wezterm' -local mux = wezterm.mux -local act = wezterm.action - -wezterm.on('update-right-status', function(window, pane) - window:set_right_status(window:active_workspace()) -end) - -wezterm.on('gui-startup', function(cmd) - local tab, pane, window = mux.spawn_window(cmd or {}) - window:gui_window():maximize() - pane:split { size = 0.2 } -end) - -return { - adjust_window_size_when_changing_font_size = false, - check_for_updates = false, - color_scheme = 'Tango (terminal.sexy)', - default_gui_startup_args = { 'connect', 'unix' }, - font = wezterm.font_with_fallback { 'JetBrains Mono', 'Noto Color Emoji' }, - font_size = 12.0, - dpi = 144, - scrollback_lines = 50000, - initial_cols = 400, - initial_rows = 80, - leader = { key = 'b', mods = 'SUPER', timeout_milliseconds = 1000 }, - default_prog = { '/etc/profiles/per-user/salar/bin/fish' }, - window_decorations = 'RESIZE', - ssh_domains = { - { - name = 'hcloud1', - remote_address = 'hcloud1.softinio.net', - username = 'salar', - remote_wezterm_path = '/run/current-system/sw/bin/wezterm', - }, - }, - unix_domains = { - { - name = 'unix', - proxy_command = { 'nc', '-U', '/Users/salar/.local/share/wezterm/sock' }, - }, - }, - keys = { - { key = '-', mods = 'LEADER', action = wezterm.action { SplitVertical = { domain = 'CurrentPaneDomain' } } }, - { key = "'", mods = 'LEADER', action = wezterm.action { SplitHorizontal = { domain = 'CurrentPaneDomain' } } }, - { key = 'k', mods = 'SUPER', action = act.TogglePaneZoomState }, - { key = 'h', mods = 'LEADER', action = wezterm.action { ActivatePaneDirection = 'Left' } }, - { key = 'j', mods = 'LEADER', action = wezterm.action { ActivatePaneDirection = 'Down' } }, - { key = 'k', mods = 'LEADER', action = wezterm.action { ActivatePaneDirection = 'Up' } }, - { key = 'l', mods = 'LEADER', action = wezterm.action { ActivatePaneDirection = 'Right' } }, - { key = 'H', mods = 'LEADER|SHIFT', action = wezterm.action { AdjustPaneSize = { 'Left', 5 } } }, - { key = 'J', mods = 'LEADER|SHIFT', action = wezterm.action { AdjustPaneSize = { 'Down', 5 } } }, - { key = 'K', mods = 'LEADER|SHIFT', action = wezterm.action { AdjustPaneSize = { 'Up', 5 } } }, - { key = 'L', mods = 'LEADER|SHIFT', action = wezterm.action { AdjustPaneSize = { 'Right', 5 } } }, - { key = '1', mods = 'LEADER', action = wezterm.action { ActivateTab = 0 } }, - { key = '2', mods = 'LEADER', action = wezterm.action { ActivateTab = 1 } }, - { key = '3', mods = 'LEADER', action = wezterm.action { ActivateTab = 2 } }, - { key = '4', mods = 'LEADER', action = wezterm.action { ActivateTab = 3 } }, - { key = '5', mods = 'LEADER', action = wezterm.action { ActivateTab = 4 } }, - { key = '6', mods = 'LEADER', action = wezterm.action { ActivateTab = 5 } }, - { key = '7', mods = 'LEADER', action = wezterm.action { ActivateTab = 6 } }, - { key = '8', mods = 'LEADER', action = wezterm.action { ActivateTab = 7 } }, - { key = '9', mods = 'LEADER', action = wezterm.action { ActivateTab = 8 } }, - { key = '&', mods = 'LEADER', action = wezterm.action { CloseCurrentTab = { confirm = true } } }, - { key = 'x', mods = 'LEADER', action = wezterm.action { CloseCurrentPane = { confirm = true } } }, - { key = 'Enter', mods = 'ALT', action = act.DisableDefaultAssignment }, - { key = 'c', mods = 'SUPER', action = act.CopyTo 'Clipboard' }, - { key = 'v', mods = 'SUPER', action = act.PasteFrom 'Clipboard' }, - { key = 'n', mods = 'SUPER', action = act.SpawnWindow }, - { key = 't', mods = 'SUPER', action = act.SpawnTab 'CurrentPaneDomain' }, - { key = 'h', mods = 'SUPER', action = act { SpawnCommandInNewTab = { cwd = wezterm.home_dir } } }, - { key = 'q', mods = 'SUPER', action = act.QuitApplication }, - { key = 'i', mods = 'CTRL|SHIFT', action = act.SwitchToWorkspace }, - { - key = '8', - mods = 'ALT', - action = wezterm.action_callback(function(window, pane) - -- Here you can dynamically construct a longer list if needed - - local home = wezterm.home_dir - local workspaces = { - { id = home, label = 'Home' }, - { id = home .. '/Projects', label = 'My Projects' }, - { id = home .. '/OpenSource', label = 'Open Source Projects' }, - { id = home .. '/.config/nixpkgs', label = 'Nix Config' }, - { id = home .. '/Projects/scalanews', label = 'Scala News' }, - } - - window:perform_action( - act.InputSelector { - action = wezterm.action_callback(function(inner_window, inner_pane, id, label) - if not id and not label then - wezterm.log_info 'cancelled' - else - wezterm.log_info('id = ' .. id) - wezterm.log_info('label = ' .. label) - inner_window:perform_action( - act.SwitchToWorkspace { - name = label, - spawn = { - label = 'Workspace: ' .. label, - cwd = id, - }, - }, - inner_pane - ) - end - end), - title = 'Choose Workspace', - choices = workspaces, - fuzzy = true, - fuzzy_description = 'Fuzzy find and/or make a workspace', - }, - pane - ) - end), - }, - { - key = '9', - mods = 'ALT', - action = act.ShowLauncherArgs { - flags = 'FUZZY|WORKSPACES', - }, - }, - { key = 'Tab', mods = 'CTRL', action = wezterm.action.DisableDefaultAssignment }, - }, -} diff --git a/programs/zed/default.nix b/programs/zed/default.nix deleted file mode 100644 index a6517ce..0000000 --- a/programs/zed/default.nix +++ /dev/null @@ -1,66 +0,0 @@ -{ ... }: -let - myextensions = [ - "fish" - "lua" - "nix" - "ruff" - "scala" - "sql" - "swift" - "toml" - ]; -in -{ - programs.zed-editor = { - enable = true; - extensions = myextensions; - userSettings = { - assistant = { - version = "2"; - default_model = { - provider = "copilot_chat"; - model = "claude-3-7-sonnet"; - }; - }; - features = { - copilot = true; - }; - language_models = { - anthropic = { - available_models = [ - { - provider = "anthropic"; - name = "claude-3-7-sonnet"; - max_tokens = 128000; - cache_configuration = { - max_cache_anchors = 10; - min_total_token = 10000; - should_speculate = false; - }; - } - ]; - version = "1"; - }; - openai = { - available_models = [ - { - provider = "openai"; - name = "gpt-4o"; - max_tokens = 128000; - } - { - provider = "openai"; - name = "o3-mini"; - max_tokens = 128000; - } - ]; - version = "1"; - }; - }; - telemetry.metrics = false; - theme = "Gruvbox Dark Hard"; - vim_mode = true; - }; - }; -}