Compare commits

..

No commits in common. "main" and "december-2022-1" have entirely different histories.

14 changed files with 1205 additions and 542 deletions

View file

@ -1 +1,4 @@
{ allowUnfree = true; } {
allowUnfree = true;
}

35
darwin-configuration.nix Normal file
View file

@ -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;
}

View file

@ -1,17 +1,39 @@
{ {
"nodes": { "nodes": {
"darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1668784520,
"narHash": "sha256-gGgVAMwYPPmrfnvnoRi6OkEB5KRsNTb9uYzEceLdO/g=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "6349b99bc2b96ded34d068a88c7c5ced406b7f7f",
"type": "github"
},
"original": {
"owner": "lnl7",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ],
"utils": "utils"
}, },
"locked": { "locked": {
"lastModified": 1730490306, "lastModified": 1670513770,
"narHash": "sha256-AvCVDswOUM9D368HxYD25RsSKp+5o0L0/JHADjLoD38=", "narHash": "sha256-muL74fsbGA8K8WlZSPNWddOiuBnC54kAajncX6nXrh4=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "1743615b61c7285976f85b303a36cdf88a556503", "rev": "054d9e3187ca00479e8036dc0e92900a384f30fd",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -20,33 +42,13 @@
"type": "github" "type": "github"
} }
}, },
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1730600078,
"narHash": "sha256-BoyFmE59HDF3uybBySsWVoyjNuHvz3Wv8row/mSb958=",
"owner": "LnL7",
"repo": "nix-darwin",
"rev": "4652874d014b82cb746173ffc64f6a70044daa7e",
"type": "github"
},
"original": {
"owner": "LnL7",
"repo": "nix-darwin",
"type": "github"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1730200266, "lastModified": 1670597555,
"narHash": "sha256-l253w0XMT8nWHGXuXqyiIC/bMvh1VRszGXgdpQlfhvU=", "narHash": "sha256-/k939P2S2246G6K5fyvC0U2IWvULhb4ZJg9K7ZxsX+k=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "807e9154dcb16384b1b765ebe9cd2bba2ac287fd", "rev": "2dea0f4c2d6e4603f54b2c56c22367e77869490c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -58,11 +60,11 @@
}, },
"nur": { "nur": {
"locked": { "locked": {
"lastModified": 1730612615, "lastModified": 1670690902,
"narHash": "sha256-l5mlB45tLEcMGGEucbGs06CvsrXrxGM4NKueWh7Pkuo=", "narHash": "sha256-AxAy3pmT1gHAIkPrpdZLrjD32kRZYz1BTbS+RzNynbU=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nur", "repo": "nur",
"rev": "88b6dea6f574d59dd0f3bd48d1da32d37118de34", "rev": "9900aa788ffbb86d13e281f9df6b19d98aea5aab",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -73,11 +75,26 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"darwin": "darwin",
"home-manager": "home-manager", "home-manager": "home-manager",
"nix-darwin": "nix-darwin",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nur": "nur" "nur": "nur"
} }
},
"utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -1,99 +1,34 @@
{ {
description = "Nix and home-manager configurations for Softinio's macbook"; description = "Nix and home-manager configurations for Softinio's macbook";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nix-darwin = { nur.url = github:nix-community/nur;
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
nur.url = "github:nix-community/nur";
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = {darwin, home-manager, nur, nixpkgs, ...}:
outputs =
{
self,
nix-darwin,
home-manager,
nur,
nixpkgs,
...
}:
let let
homeManagerConfFor = homeManagerConfFor = config: { ... }: {
config: nixpkgs.overlays = [ nur.overlay ];
{ ... }: imports = [ config ];
{ };
nixpkgs.overlays = [ nur.overlay ]; darwinSystem = darwin.lib.darwinSystem {
imports = [ config ]; system = "x86_64-darwin";
};
m3maxConfiguration =
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [ home-manager ];
fonts = {
packages = with pkgs; [ fira-code ];
};
services.nix-daemon.enable = true;
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 = "aarc64-darwin";
modules = [ modules = [
m3maxConfiguration ./darwin-configuration.nix
home-manager.darwinModules.home-manager home-manager.darwinModules.home-manager {
{
home-manager.useUserPackages = true;
home-manager.users.salar = homeManagerConfFor ./home.nix; home-manager.users.salar = homeManagerConfFor ./home.nix;
} }
]; ];
specialArgs = { specialArgs = { inherit nixpkgs; };
inherit nixpkgs;
};
}; };
in {
darwinPackages = self.darwinConfigurations.salarm3max.pkgs; defaultPackage.x86_64-darwin = darwinSystem.system;
defaultPackage.aarch64-darwin = self.darwinConfigurations.salarm3max.system;
}; };
} }

302
home.nix
View file

@ -1,9 +1,4 @@
{ { config, lib, pkgs, ... }:
config,
lib,
pkgs,
...
}:
{ {
# Let Home Manager install and manage itself. # Let Home Manager install and manage itself.
@ -11,87 +6,85 @@
imports = (import ./programs); imports = (import ./programs);
nixpkgs.config.allowUnfreePredicate = nixpkgs.overlays = [
pkg: (import ./overlays/sumneko-lua-language-server)
builtins.elem (lib.getName pkg) [ # (import (builtins.fetchTarball {
"discord" # url = https://github.com/nix-community/neovim-nightly-overlay/archive/master.tar.gz;
"slack" # }))
"vscode" ];
"vscode-extension-github-copilot"
"vscode-extension-github-copilot-chat" nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"vscode-extension-MS-python-vscode-pylance" "vscode"
"zoom" ];
];
home = { home = {
stateVersion = "24.05"; stateVersion = "22.11";
sessionVariables = { sessionVariables = {
EDITOR = "nvim"; EDITOR = "nvim";
VISUAL = "$EDITOR"; VISUAL = "$EDITOR";
}; };
packages = with pkgs; [ packages = with pkgs; [
( python310.withPackages (ps: with ps; [ pip flake8 black ]) )
# adoptopenjdk-hotspot-bin-17
jdk
any-nix-shell any-nix-shell
aspell aspell
basedpyright bloop
bash-language-server cabal-install
cabal2nix
cachix cachix
cmake cmake
coursier coursier
curlFull curlFull
delta exa
deno
devenv
discord
dua
fd fd
ffmpeg ffmpeg
fishPlugins.foreign-env
fishPlugins.bobthefish
font-awesome font-awesome
gitAndTools.diff-so-fancy gitAndTools.diff-so-fancy
ghc
ghcid
gnupg gnupg
go go
graphviz graphviz
jq-lsp haskell-language-server
hugo
luajit luajit
lua-language-server luajitPackages.luarocks
marksman luajitPackages.luasocket
marp-cli lorri
maven maven
metals
multimarkdown multimarkdown
mypy mypy
ncdu
neofetch neofetch
neovim neovim
nil
niv niv
nixd
nix-index nix-index
nixfmt-rfc-style nixfmt
nix-prefetch-git nix-prefetch-git
nodejs nodePackages.pyright
ollama nodePackages.typescript-language-server
nodePackages.vscode-html-languageserver-bin
nodePackages.vscode-json-languageserver
nodePackages.yaml-language-server
openssl openssl
pandoc pandoc
patchelf patchelf
pngpaste pijul
prettyping
python3Packages.huggingface-hub
python3Packages.jupyterlab
rclone rclone
readline readline
ripgrep ripgrep
ripgrep-all ripgrep-all
rnix-lsp
rust-analyzer
rustup rustup
sbt sbt
scala-cli scala-cli
shellcheck shellcheck
skimpdf
slack
slides
slumber
sqlite sqlite
stylua stylua
stack
sumneko-lua-language-server
tealdeer tealdeer
tectonic tectonic
texlab texlab
@ -99,35 +92,14 @@
tokei tokei
tree tree
tree-sitter tree-sitter
typescript
typescript-language-server
wget wget
vscode-langservers-extracted
# xcodes
xz xz
yaml-language-server
yq yq
zoom-us
]; ];
}; };
programs.bat = { programs.bat = {
enable = true; enable = true;
};
programs.btop = {
enable = true;
};
programs.darcs = {
enable = true;
author = [ "Salar Rahmanian <code@softinio.com>" ];
boring = [
"^.idea$"
"^.direnv$"
"^.envrc$"
"^.vscode$"
];
}; };
programs.direnv = { programs.direnv = {
@ -135,19 +107,6 @@
nix-direnv.enable = true; nix-direnv.enable = true;
}; };
programs.eza = {
enable = true;
enableFishIntegration = true;
git = true;
icons = "auto";
extraOptions = [
"--group-directories-first"
"--long"
"--header"
"--all"
];
};
programs.fzf = { programs.fzf = {
enable = true; enable = true;
enableFishIntegration = true; enableFishIntegration = true;
@ -158,22 +117,6 @@
settings = { settings = {
editor = "nvim"; editor = "nvim";
git_protocol = "ssh"; git_protocol = "ssh";
prompt = "enabled";
aliases = {
co = "pr checkout";
pv = "pr view";
};
};
};
programs.gh-dash = {
enable = true;
};
programs.helix = {
enable = true;
settings = {
theme = "tokyonight";
}; };
}; };
@ -181,26 +124,26 @@
enable = true; enable = true;
}; };
programs.java = {
enable = true;
};
programs.jq = { programs.jq = {
enable = true; enable = true;
}; };
programs.lazygit = { programs.kitty = {
enable = true; enable = true;
}; font = {
name = "FiraCode Nerd Font Mono Retina";
programs.nix-index = { size = 16;
enable = true; };
enableFishIntegration = true; settings = {
copy_on_select = true;
enabled_layouts = "*";
macos_quit_when_last_window_closed = true;
scrollback_lines = 10000;
};
}; };
programs.starship = { programs.starship = {
enable = true; enable = true;
enableFishIntegration = true;
settings = { settings = {
command_timeout = 1000; command_timeout = 1000;
character = { character = {
@ -210,6 +153,32 @@
}; };
}; };
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 = { programs.fish = {
enable = true; enable = true;
@ -217,7 +186,35 @@
gitignore = "curl -sL https://www.gitignore.io/api/$argv"; gitignore = "curl -sL https://www.gitignore.io/api/$argv";
}; };
plugins = [ ]; 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 = '' loginShellInit = ''
set -xg TERM xterm-256color set -xg TERM xterm-256color
@ -235,14 +232,28 @@
set -xg PATH $HOME/bin $HOME/.cargo/bin $PATH set -xg PATH $HOME/bin $HOME/.cargo/bin $PATH
set -xg PATH /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 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 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 FZF_DEFAULT_OPTS "--preview='bat {} --color=always'" \n
set -xg TOOLCHAINS swift 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 = '' interactiveShellInit = ''
eval (direnv hook fish) eval (direnv hook fish)
@ -250,46 +261,43 @@
''; '';
shellAliases = { shellAliases = {
addsshmac = "ssh-add ~/.ssh/id_ed25519 --apple-use-keychain --apple-load-keychain"; cat="bat";
cat = "bat"; du="ncdu --color dark -rr -x";
du = "dua i"; fzfp="fzf --preview 'bat --style=numbers --color=always --line-range :500 {}'";
fzfp = "fzf --preview 'bat --style=numbers --color=always --line-range :500 {}'"; ping="prettyping";
ping = "prettyping";
".." = "cd .."; ".." = "cd ..";
pj = "python -m json.tool"; pj="python -m json.tool";
l = "ll"; l="exa --long --header --git --all";
g = "git"; g="git";
gl = "git log"; gl="git log";
gc = "git commit -m"; gc="git commit -m";
gca = "git commit -am"; gca="git commit -am";
gws = "git status"; gws="git status";
gu = "gitui"; ghauth="gh auth login --with-token < ~/.ghauth";
ghauth = "gh auth login --with-token < ~/.ghauth"; giscala="gitignore scala,vim,java,sbt > .gitignore";
gitpurgemain = ''git branch --merged | grep -v "\*" | grep -v "main" | xargs -n 1 git branch -d''; gforksync="git fetch upstream && git merge upstream/master && git push origin master";
gitpurgemaster = ''git branch --merged | grep -v "\*" | grep -v "master" | xargs -n 1 git branch -d''; grep="grep --color=auto";
giscala = "gitignore scala,vim,java,sbt > .gitignore"; new-sbt="sbt new scala/scala-seed.g8";
gforksync = "git fetch upstream && git merge upstream/master && git push origin master"; nixre="nix build && sudo ./result/activate";
grep = "grep --color=auto"; nixinfo="nix-shell -p nix-info --run \"nix-info -m\"";
lg = "lazygit"; nixgc="nix-collect-garbage -d";
new-sbt = "sbt new scala/scala-seed.g8"; nixq="nix-env -qa";
nixc = "cd ~/.config/nixpkgs"; nixupdate="sudo nix-channel --update";
nixre = "nix build && sudo ./result/activate"; nixversion="nix eval nixpkgs.lib.version";
nixinfo = "nix-shell -p nix-info --run \"nix-info -m\""; rmxcodederived="rm -fr ~/Library/Developer/Xcode/DerivedData";
nixgc = "nix-collect-garbage -d"; v="nvim";
nixq = "nix-env -qa"; sshfre1="ssh salar@fre1.softinio.net";
nixstorerepair = "nix-store --repair --verify --check-contents"; sshfre2="ssh -p 22 salar@fre2.softinio.net";
nixupgrade = "nix upgrade-nix";
rmxcodederived = "rm -fr ~/Library/Developer/Xcode/DerivedData";
v = "nvim";
wezk = "wezterm show-keys --lua";
sshhcloud1 = "ssh salar@hcloud1.softinio.net";
sshhcloud1r = "ssh root@hcloud1.softinio.net";
}; };
}; };
xdg.configFile."fish/conf.d/plugin-bobthefish.fish".text = lib.mkAfter ''
for f in $plugin_dir/*.fish
source $f
end
'';
# Neovim Configuration # Neovim Configuration
xdg.configFile."nvim".source = builtins.fetchGit { xdg.configFile."nvim/lua/salargalaxyline.lua".source = programs/neovim/settings/salargalaxyline.lua;
url = "https://code.softinio.com/softinio/nvim-config"; xdg.configFile."nvim/init.lua".source = programs/neovim/init.lua;
rev = "902fbd939c74ece8fabe543e511af36471a1a197";
};
} }

View file

@ -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;
}
);
}

View file

@ -1,6 +1,4 @@
[ [
./git ./git
./tmux ./tmux
./wezterm
./vscode
] ]

View file

@ -4,7 +4,7 @@ let
gitConfig = { gitConfig = {
core = { core = {
editor = "nvim"; editor = "nvim";
pager = "diff-so-fancy | less --tabs=4 -RFX"; pager = "diff-so-fancy | less --tabs=4 -RFX";
}; };
init.defaultBranch = "main"; init.defaultBranch = "main";
merge.conflictstyle = "diff3"; merge.conflictstyle = "diff3";
@ -19,11 +19,11 @@ let
cmd = "nvim -d \"$LOCAL\" \"$REMOTE\""; cmd = "nvim -d \"$LOCAL\" \"$REMOTE\"";
prompt = false; prompt = false;
}; };
# url = { url = {
# "git@github.com:" = { "git@github.com:" = {
# insteadOf = "https://github.com/"; insteadOf = "https://github.com/";
# }; };
# }; };
fetch.prune = true; fetch.prune = true;
pull = { pull = {
rebase = true; rebase = true;
@ -36,22 +36,24 @@ let
master = "checkout master"; master = "checkout master";
}; };
myIgnores = [ myIgnores = [
"*~" "*~"
".DS_Store" ".DS_Store"
"*.bloop" "*.bloop"
".direnv/" ".direnv/"
".idea/" ".idea/"
".mypy_cache" ".mypy_cache"
"*.metals" "*.metals"
"*.metals.sbt" "*.metals.sbt"
"*metals.sbt" "*metals.sbt"
"*.envrc" # there is lorri, nix-direnv & simple direnv; let people decide "*.direnv"
"*hie.yaml" # ghcide files "*.envrc" # there is lorri, nix-direnv & simple direnv; let people decide
"*.mill-version" # used by metals "*hie.yaml" # ghcide files
"*.vscode" "*.mill-version" # used by metals
"*.python-version" "*.idea"
"result" "*.vscode"
]; "*.python-version"
"result"
];
in in
{ {
programs.git = { programs.git = {

663
programs/neovim/init.lua Normal file
View file

@ -0,0 +1,663 @@
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/neodev.nvim'
use 'folke/tokyonight.nvim' -- Theme
use { 'folke/trouble.nvim' }
use { 'justinhj/battery.nvim', requires = '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 'nvim-tree/nvim-web-devicons'
use {
'nvim-tree/nvim-tree.lua',
tag = 'nightly' -- optional, updated every week. (see issue #1193)
}
use {
'glepnir/galaxyline.nvim',
config = function()
require 'salargalaxyline'
end,
}
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'
}
use {
'phaazon/mind.nvim',
branch = 'v2.2',
requires = { 'nvim-lua/plenary.nvim' },
config = function()
require'mind'.setup()
end
}
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
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
require("nvim-tree").setup({
sort_by = "case_sensitive",
disable_netrw = true,
view = {
adaptive_size = true,
mappings = {
list = {
{ key = "u", action = "dir_up" },
},
},
},
renderer = {
highlight_git = true,
group_empty = true,
},
filters = {
dotfiles = false,
},
})
-- 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 = '<cr>',
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('', '<Space>', '<Nop>', { 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', '<Esc>', [[<c-\><c-n>]], { noremap = true })
--Add map to enter paste mode
vim.o.pastetoggle = '<F3>'
--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', '<F10>', '<cmd>lua ToggleMouse()<cr>', { noremap = true })
-- Telescope
require('telescope').setup {
defaults = {
mappings = {
i = {
['<C-u>'] = false,
['<C-d>'] = 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', '<leader>f', [[<cmd>lua require('telescope.builtin').find_files()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader><space>', [[<cmd>lua require('telescope.builtin').buffers()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>l', [[<cmd>lua require('telescope.builtin').current_buffer_fuzzy_find()<cr>]], { noremap = true, silent = true })
-- vim.api.nvim_set_keymap('n', '<leader>t', [[<cmd>lua require('telescope.builtin').tags()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>?', [[<cmd>lua require('telescope.builtin').oldfiles()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sd', [[<cmd>lua require('telescope.builtin').grep_string()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sp', [[<cmd>lua require('telescope.builtin').live_grep()<cr>]], { noremap = true, silent = true })
-- vim.api.nvim_set_keymap('n', '<leader>o', [[<cmd>lua require('telescope.builtin').tags{ only_current_buffer = true }<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>gco', [[<cmd>lua require('telescope.builtin').git_commits()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>gb', [[<cmd>lua require('telescope.builtin').git_branches()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>gs', [[<cmd>lua require('telescope.builtin').git_status()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>gp', [[<cmd>lua require('telescope.builtin').git_bcommits()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>m', [[<cmd>lua require('nvim-tree').toggle()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>ng', [[<cmd>lua require('neogit').open({ kind = "split" })<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>nm', [[<cmd>lua require("telescope").extensions.metals.commands()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>tt', [[<cmd>lua require("metals.tvp").toggle_tree_view()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>tr', [[<cmd>lua require("metals.tvp").reveal_in_tree()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>ws', [[<cmd>lua require"metals".worksheet_hover()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>a', [[<cmd>lua RELOAD("metals").open_all_diagnostics()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>nu', ':PackerUpdate<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>si', [[<cmd>lua require('telescope').extensions.scaladex.scaladex.search()<cr>]], { 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', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gm', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-s>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'dr', [[<cmd>lua require('dap').repl.toggle()<cr>]], { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ds', [[<cmd>lua require('dap').ui.variables.scopes()<cr>]], { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'dk', [[<cmd>lua require('dap').ui.widgets.hover()<cr>]], { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'dl', [[<cmd>lua require('dap').run_last()<cr>]], { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'dz', [[<cmd>lua require('dap').toggle_breakpoint()<cr>]], { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'dc', [[<cmd>lua require('dap').continue()<cr>]], { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<F7>', [[<cmd>lua require('dap').step_over()<cr>]], { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<F6>', [[<cmd>lua require('dap').step_out()<cr>]], { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<F5>', [[<cmd>lua require('dap').step_into()<cr>]], { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'B', [[<cmd>lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))<cr>]], { noremap = true, silent = true })
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'lp', [[<cmd>lua require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<cr>]], { noremap = true, silent = true })
end
-- Enable the following language servers
local servers = { 'hls', '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')
require("neodev").setup({
override = function(root_dir, library)
if require("neodev.util").has_file(root_dir, "/etc/nixos") then
library.enabled = true
library.plugins = true
end
end,
})
nvim_lsp.sumneko_lua.setup({
settings = {
Lua = {
completion = {
callSnippet = "Replace"
}
}
}
})
-- metals
vim.g.metals_server_version = '0.11.9'
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 <buffer> lua vim.lsp.buf.document_highlight()]])
vim.cmd([[autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()]])
vim.cmd([[autocmd BufEnter,CursorHold,InsertLeave <buffer> 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").default_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
["<CR>"] = cmp.mapping.confirm({ select = true }),
-- I use tabs... some say you should stick to ins-completion but this is just here as an example
["<Tab>"] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end,
["<S-Tab>"] = 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 '<C-n>'
elseif check_back_space() then
return t '<Tab>'
else
return vim.fn['cmp#complete']()
end
end
_G.s_tab_complete = function()
if vim.fn.pumvisible() == 1 then
return t '<C-p>'
else
return t '<S-Tab>'
end
end
vim.api.nvim_set_keymap('i', '<Tab>', 'v:lua.tab_complete()', { expr = true })
vim.api.nvim_set_keymap('s', '<Tab>', 'v:lua.tab_complete()', { expr = true })
vim.api.nvim_set_keymap('i', '<S-Tab>', 'v:lua.s_tab_complete()', { expr = true })
vim.api.nvim_set_keymap('s', '<S-Tab>', '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

View file

@ -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 },
},
}

View file

@ -2,6 +2,7 @@
let let
tmuxConfig = builtins.readFile ./tmux.conf; tmuxConfig = builtins.readFile ./tmux.conf;
in in
{ {
programs.tmux = { programs.tmux = {
@ -22,9 +23,16 @@ in
plugin = tmuxPlugins.continuum; plugin = tmuxPlugins.continuum;
extraConfig = "set -g @continuum-restore 'on'"; extraConfig = "set -g @continuum-restore 'on'";
} }
{ plugin = tmuxPlugins.sensible; } {
{ plugin = tmuxPlugins.vim-tmux-navigator; } plugin = tmuxPlugins.sensible;
{ plugin = tmuxPlugins.onedark-theme; } }
{
plugin = tmuxPlugins.vim-tmux-navigator;
}
{
plugin = tmuxPlugins.onedark-theme;
}
]; ];
}; };
} }

View file

@ -1,73 +0,0 @@
{ config, pkgs, ... }:
let
myExtensions = with pkgs.vscode-extensions; [
asvetliakov.vscode-neovim
baccata.scaladex-search
davidanson.vscode-markdownlint
enkia.tokyo-night
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.python
ms-python.vscode-pylance
ms-vscode.makefile-tools
ms-toolsai.jupyter
redhat.java
redhat.vscode-yaml
rust-lang.rust-analyzer
scalameta.metals
skyapps.fish-vscode
sswg.swift-lang
svsool.markdown-memo
timonwong.shellcheck
usernamehw.errorlens
visualstudioexptteam.vscodeintellicode
vscode-icons-team.vscode-icons
vscjava.vscode-java-pack
xyz.local-history
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;
};
"files.autoSave" = "afterDelay";
"git.autoSave" = "afterDelay";
"git.rebaseWhenSync" = true;
"github.gitProtocol" = "ssh";
"githubPullRequests.notifications" = "pullRequests";
"githubPullRequests.pullBranch" = "never";
"markdown.extension.preview.autoShowPreviewToSide" = 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" ];
"telemetry.telemetryLevel" = "off";
"window.openFoldersInNewWindow" = "on";
"workbench.colorTheme" = "Tokyo Night";
"workbench.iconTheme" = "vscode-icons";
"workbench.sideBar.location" = "right";
};
in
{
programs.vscode = {
enable = true;
enableUpdateCheck = false;
enableExtensionUpdateCheck = false;
mutableExtensionsDir = false;
extensions = myExtensions;
userSettings = myUserSettings;
};
}

View file

@ -1,11 +0,0 @@
{ config, pkgs, ... }:
let
weztermConfig = builtins.readFile ./wezterm.lua;
in
{
programs.wezterm = {
enable = true;
extraConfig = weztermConfig;
};
}

View file

@ -1,170 +0,0 @@
local wezterm = require 'wezterm'
local mux = wezterm.mux
local act = wezterm.action
local function is_vim(pane)
-- this is set by the plugin, and unset on ExitPre in Neovim
return pane:get_user_vars().IS_NVIM == 'true'
end
local direction_keys = {
a = 'Left',
o = 'Down',
e = 'Up',
u = 'Right',
}
local function split_nav(resize_or_move, key)
return {
key = key,
mods = resize_or_move == 'resize' and 'META' or 'CTRL',
action = wezterm.action_callback(function(win, pane)
if is_vim(pane) then
-- pass the keys through to vim/nvim
win:perform_action({
SendKey = { key = key, mods = resize_or_move == 'resize' and 'META' or 'CTRL' },
}, pane)
else
if resize_or_move == 'resize' then
win:perform_action({ AdjustPaneSize = { direction_keys[key], 3 } }, pane)
else
win:perform_action({ ActivatePaneDirection = direction_keys[key] }, pane)
end
end
end),
}
end
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 = "Gruvbox Light";
color_scheme = 'tokyonight',
default_gui_startup_args = { 'connect', 'unix' },
font = wezterm.font 'SF Mono',
font_size = 16,
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' },
ssh_domains = {
{
name = 'hcloud1',
remote_address = 'hcloud1.softinio.net',
username = 'salar',
remote_wezterm_path = '/run/current-system/sw/bin/wezterm',
},
},
unix_domains = {
{
name = 'unix',
},
},
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.ToggleFullScreen },
{ 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 = '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 },
-- move between split panes
split_nav('move', 'a'),
split_nav('move', 'o'),
split_nav('move', 'e'),
split_nav('move', 'u'),
-- resize panes
split_nav('resize', 'a'),
split_nav('resize', 'o'),
split_nav('resize', 'e'),
split_nav('resize', 'u'),
},
-- temp fix
front_end = 'WebGpu',
}