Add nix config
This commit is contained in:
69
config/nix/common.nix
Normal file
69
config/nix/common.nix
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./user/sh.nix
|
||||||
|
./user/tmux.nix
|
||||||
|
./user/git.nix
|
||||||
|
./user/dev.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
neovim
|
||||||
|
|
||||||
|
# # It is sometimes useful to fine-tune packages, for example, by applying
|
||||||
|
# # overrides. You can do that directly here, just don't forget the
|
||||||
|
# # parentheses. Maybe you want to install Nerd Fonts with a limited number of
|
||||||
|
# # fonts?
|
||||||
|
# (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; })
|
||||||
|
|
||||||
|
# # You can also create simple shell scripts directly inside your
|
||||||
|
# # configuration. For example, this adds a command 'my-hello' to your
|
||||||
|
# # environment:
|
||||||
|
# (pkgs.writeShellScriptBin "my-hello" ''
|
||||||
|
# echo "Hello, ${config.home.username}!"
|
||||||
|
# '')
|
||||||
|
];
|
||||||
|
|
||||||
|
# Home Manager is pretty good at managing dotfiles. The primary way to manage
|
||||||
|
# plain files is through 'home.file'.
|
||||||
|
home.file = {
|
||||||
|
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
|
||||||
|
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
|
||||||
|
# # symlink to the Nix store copy.
|
||||||
|
# ".screenrc".source = dotfiles/screenrc;
|
||||||
|
|
||||||
|
# # You can also set the file content immediately.
|
||||||
|
# ".gradle/gradle.properties".text = ''
|
||||||
|
# org.gradle.console=verbose
|
||||||
|
# org.gradle.daemon.idletimeout=3600000
|
||||||
|
# '';
|
||||||
|
};
|
||||||
|
|
||||||
|
# Home Manager can also manage your environment variables through
|
||||||
|
# 'home.sessionVariables'. If you don't want to manage your shell through Home
|
||||||
|
# Manager then you have to manually source 'hm-session-vars.sh' located at
|
||||||
|
# either
|
||||||
|
#
|
||||||
|
# ~/.nix-profile/etc/profile.d/hm-session-vars.sh
|
||||||
|
#
|
||||||
|
# or
|
||||||
|
#
|
||||||
|
# ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
|
||||||
|
#
|
||||||
|
# or
|
||||||
|
#
|
||||||
|
# /etc/profiles/per-user/moustachioed/etc/profile.d/hm-session-vars.sh
|
||||||
|
#
|
||||||
|
home.sessionVariables = {
|
||||||
|
EDITOR = "nvim";
|
||||||
|
};
|
||||||
|
|
||||||
|
home.shellAliases = {
|
||||||
|
vim = "nvim";
|
||||||
|
};
|
||||||
|
|
||||||
|
news.display = "silent";
|
||||||
|
|
||||||
|
programs.home-manager.enable = true;
|
||||||
|
}
|
||||||
48
config/nix/flake.lock
generated
Normal file
48
config/nix/flake.lock
generated
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"home-manager": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1711133180,
|
||||||
|
"narHash": "sha256-WJOahf+6115+GMl3wUfURu8fszuNeJLv9qAWFQl3Vmo=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"rev": "1c2c5e4cabba4c43504ef0f8cc3f3dfa284e2dbb",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "home-manager",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1711163522,
|
||||||
|
"narHash": "sha256-YN/Ciidm+A0fmJPWlHBGvVkcarYWSC+s3NTPk/P+q3c=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "44d0940ea560dee511026a53f0e2e2cde489b4d4",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"home-manager": "home-manager",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
38
config/nix/flake.nix
Normal file
38
config/nix/flake.nix
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
description = "Home Manager configuration of moustachioed";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
home-manager = {
|
||||||
|
url = "github:nix-community/home-manager";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { nixpkgs, home-manager, ... }:
|
||||||
|
let
|
||||||
|
system = "x86_64-darwin";
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in {
|
||||||
|
homeConfigurations = {
|
||||||
|
"moustachioed" = home-manager.lib.homeManagerConfiguration {
|
||||||
|
inherit pkgs;
|
||||||
|
|
||||||
|
modules = [
|
||||||
|
./user/profiles/moustachioedBook.nix
|
||||||
|
./common.nix
|
||||||
|
./user/task.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
|
"work" = home-manager.lib.homeManagerConfiguration {
|
||||||
|
inherit pkgs;
|
||||||
|
|
||||||
|
modules = [
|
||||||
|
./user/profiles/work.nix
|
||||||
|
./common.nix
|
||||||
|
./user/task.nix
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
11
config/nix/user/dev.nix
Normal file
11
config/nix/user/dev.nix
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.direnv = {
|
||||||
|
enable = true;
|
||||||
|
enableZshIntegration = true;
|
||||||
|
nix-direnv.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.ripgrep.enable = true;
|
||||||
|
}
|
||||||
27
config/nix/user/git.nix
Normal file
27
config/nix/user/git.nix
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.git = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
aliases = {
|
||||||
|
st = "status";
|
||||||
|
ci = "commit";
|
||||||
|
co = "checkout";
|
||||||
|
br = "branch";
|
||||||
|
pl = "pull";
|
||||||
|
ps = "push";
|
||||||
|
mno =" merge --no-ff";
|
||||||
|
lg = "log --color --graph --pretty=format:'%cred%h%creset -%c(yellow)%d%creset %s %cgreen(%cr)%c(bold blue)<%an>%creset' --abbrev-commit";
|
||||||
|
};
|
||||||
|
|
||||||
|
difftastic.enable = true;
|
||||||
|
|
||||||
|
extraConfig = {
|
||||||
|
core = {
|
||||||
|
editor = "nvim";
|
||||||
|
};
|
||||||
|
push.default = "matching";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
13
config/nix/user/profiles/moustachioedBook.nix
Normal file
13
config/nix/user/profiles/moustachioedBook.nix
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
home.username = "moustachioed";
|
||||||
|
home.homeDirectory = "/Users/moustachioed";
|
||||||
|
|
||||||
|
home.stateVersion = "23.11"; # Please read the comment before changing.
|
||||||
|
|
||||||
|
programs.git = {
|
||||||
|
userName = "Martin";
|
||||||
|
userEmail = "git@pander-on.de";
|
||||||
|
};
|
||||||
|
}
|
||||||
13
config/nix/user/profiles/work.nix
Normal file
13
config/nix/user/profiles/work.nix
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
home.username = "moustachioed";
|
||||||
|
home.homeDirectory = "/Users/moustachioed";
|
||||||
|
|
||||||
|
home.stateVersion = "23.11"; # Please read the comment before changing.
|
||||||
|
|
||||||
|
programs.git = {
|
||||||
|
userName = "Martin Pander";
|
||||||
|
userEmail = "martin.pander@knowtion.de";
|
||||||
|
};
|
||||||
|
}
|
||||||
73
config/nix/user/sh.nix
Normal file
73
config/nix/user/sh.nix
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.zsh = {
|
||||||
|
enable = true;
|
||||||
|
enableCompletion = true;
|
||||||
|
autosuggestion.enable = true;
|
||||||
|
syntaxHighlighting.enable = true;
|
||||||
|
|
||||||
|
history.size = 500000;
|
||||||
|
#history.path = "${config.xdg.dataHome}/zsh/history";
|
||||||
|
prezto = {
|
||||||
|
enable = true;
|
||||||
|
caseSensitive = true;
|
||||||
|
color = true;
|
||||||
|
editor = {
|
||||||
|
dotExpansion = true;
|
||||||
|
keymap = "vi";
|
||||||
|
};
|
||||||
|
pmodules = [
|
||||||
|
"environment"
|
||||||
|
"terminal"
|
||||||
|
"editor"
|
||||||
|
"history"
|
||||||
|
"directory"
|
||||||
|
"spectrum"
|
||||||
|
"utility"
|
||||||
|
"completion"
|
||||||
|
"syntax-highlighting"
|
||||||
|
"history-substring-search"
|
||||||
|
"prompt"
|
||||||
|
"git"
|
||||||
|
];
|
||||||
|
prompt.theme = "minimal";
|
||||||
|
syntaxHighlighting.highlighters = [
|
||||||
|
"main"
|
||||||
|
"brackets"
|
||||||
|
"pattern"
|
||||||
|
"line"
|
||||||
|
"cursor"
|
||||||
|
"root"
|
||||||
|
];
|
||||||
|
tmux = {
|
||||||
|
autoStartLocal = true;
|
||||||
|
itermIntegration = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
initExtra = ''
|
||||||
|
HISTCONTROL='erasedups:ignoreboth'
|
||||||
|
HISTIGNORE='&:[ ]*:exit:ls:bg:fg:history:clear'
|
||||||
|
unsetopt beep
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.fzf = {
|
||||||
|
enable = true;
|
||||||
|
enableZshIntegration = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.lsd = {
|
||||||
|
enable = true;
|
||||||
|
enableAliases = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
programs.bat.enable = true;
|
||||||
|
programs.ripgrep.enable = true;
|
||||||
|
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
du-dust
|
||||||
|
#nerdfonts
|
||||||
|
];
|
||||||
|
}
|
||||||
16
config/nix/user/task.nix
Normal file
16
config/nix/user/task.nix
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{config, pkgs, ...}:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.taskwarrior = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
home.packages = with pkgs; [
|
||||||
|
taskwarrior-tui
|
||||||
|
];
|
||||||
|
|
||||||
|
home.shellAliases = {
|
||||||
|
t = "task";
|
||||||
|
tt = "taskwarrior-tui";
|
||||||
|
};
|
||||||
|
}
|
||||||
58
config/nix/user/tmux.nix
Normal file
58
config/nix/user/tmux.nix
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.tmux = {
|
||||||
|
enable = true;
|
||||||
|
shortcut = "a";
|
||||||
|
mouse = true;
|
||||||
|
keyMode = "vi";
|
||||||
|
escapeTime = 0;
|
||||||
|
extraConfig = ''
|
||||||
|
set -g display-time 1500
|
||||||
|
|
||||||
|
unbind S
|
||||||
|
bind S command-prompt "switch -t %1"
|
||||||
|
|
||||||
|
bind-key -n M-K switch-client -p
|
||||||
|
bind-key -n M-J switch-client -n
|
||||||
|
|
||||||
|
bind-key -n M-L next-window
|
||||||
|
bind-key -n M-H previous-window
|
||||||
|
|
||||||
|
bind '"' split-window -c "#{pane_current_path}"
|
||||||
|
bind % split-window -h -c "#{pane_current_path}"
|
||||||
|
bind c new-window -a -c "#{pane_current_path}"
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# status line
|
||||||
|
#######################################
|
||||||
|
set -g status-justify centre
|
||||||
|
|
||||||
|
set -g status-left "#[bg=#808080,fg=#ffffff,bold] #S #[default]#[bg=#BCBCBC] #{-30:pane_title} "
|
||||||
|
set -g status-left-length 40
|
||||||
|
|
||||||
|
set -g status-right "#[bg=#BCBCBC] %H:%M #[bg=#808080,fg=#ffffff] %d.%m.%y "
|
||||||
|
|
||||||
|
# setw -g window-status-format " #W#F "
|
||||||
|
# setw -g window-status-current-format " #W#F "
|
||||||
|
setw -g window-status-format " #W "
|
||||||
|
setw -g window-status-current-format " #W "
|
||||||
|
setw -g window-status-separator ""
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# colors, taken from vim-lucius
|
||||||
|
#######################################
|
||||||
|
set -g status-style "bg=#DADADA,fg=#000000"
|
||||||
|
|
||||||
|
setw -g window-status-style "bg=#BCBCBC,fg=#000000"
|
||||||
|
setw -g window-status-current-style "bg=#808080,fg=#ffffff"
|
||||||
|
|
||||||
|
setw -g window-status-activity-style "bg=#AFD7AF,fg=#000000"
|
||||||
|
setw -g window-status-bell-style "bg=#AFD7AF,fg=#000000"
|
||||||
|
#setw -g window-status-content-style "bg=#AFD7AF,fg=#000000"
|
||||||
|
|
||||||
|
set -g pane-active-border-style "bg=#eeeeee,fg=#006699"
|
||||||
|
set -g pane-border-style "bg=#eeeeee,fg=#999999"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -152,13 +152,13 @@ zstyle ':prezto:module:syntax-highlighting' highlighters \
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Auto start a session when Zsh is launched in a local terminal.
|
# Auto start a session when Zsh is launched in a local terminal.
|
||||||
# zstyle ':prezto:module:tmux:auto-start' local 'yes'
|
zstyle ':prezto:module:tmux:auto-start' local 'yes'
|
||||||
|
|
||||||
# Auto start a session when Zsh is launched in a SSH connection.
|
# Auto start a session when Zsh is launched in a SSH connection.
|
||||||
# zstyle ':prezto:module:tmux:auto-start' remote 'yes'
|
zstyle ':prezto:module:tmux:auto-start' remote 'yes'
|
||||||
|
|
||||||
# Integrate with iTerm2.
|
# Integrate with iTerm2.
|
||||||
# zstyle ':prezto:module:tmux:iterm' integrate 'yes'
|
zstyle ':prezto:module:tmux:iterm' integrate 'yes'
|
||||||
|
|
||||||
#
|
#
|
||||||
# Completion
|
# Completion
|
||||||
|
|||||||
@ -41,6 +41,6 @@ export PATH="$HOME/bin:/usr/local/bin:$PATH"
|
|||||||
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||||
|
|
||||||
unalias rm
|
unalias rm
|
||||||
alias open='nautilus . &'
|
#alias open='nautilus . &'
|
||||||
|
|
||||||
export OPENAI_API_KEY=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
|
export OPENAI_API_KEY=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
|
||||||
|
|||||||
@ -391,6 +391,9 @@ function! plug#end()
|
|||||||
if !empty(types)
|
if !empty(types)
|
||||||
augroup filetypedetect
|
augroup filetypedetect
|
||||||
call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim')
|
call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim')
|
||||||
|
if has('nvim-0.5.0')
|
||||||
|
call s:source(s:rtp(plug), 'ftdetect/**/*.lua', 'after/ftdetect/**/*.lua')
|
||||||
|
endif
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
for type in types
|
for type in types
|
||||||
@ -438,6 +441,9 @@ endfunction
|
|||||||
|
|
||||||
function! s:load_plugin(spec)
|
function! s:load_plugin(spec)
|
||||||
call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim')
|
call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim')
|
||||||
|
if has('nvim-0.5.0')
|
||||||
|
call s:source(s:rtp(a:spec), 'plugin/**/*.lua', 'after/plugin/**/*.lua')
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:reload_plugins()
|
function! s:reload_plugins()
|
||||||
@ -655,6 +661,9 @@ function! s:lod(names, types, ...)
|
|||||||
let rtp = s:rtp(g:plugs[name])
|
let rtp = s:rtp(g:plugs[name])
|
||||||
for dir in a:types
|
for dir in a:types
|
||||||
call s:source(rtp, dir.'/**/*.vim')
|
call s:source(rtp, dir.'/**/*.vim')
|
||||||
|
if has('nvim-0.5.0') " see neovim#14686
|
||||||
|
call s:source(rtp, dir.'/**/*.lua')
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
if a:0
|
if a:0
|
||||||
if !s:source(rtp, a:1) && !empty(s:glob(rtp, a:2))
|
if !s:source(rtp, a:1) && !empty(s:glob(rtp, a:2))
|
||||||
@ -869,7 +878,7 @@ function! s:lastline(msg)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:new_window()
|
function! s:new_window()
|
||||||
execute get(g:, 'plug_window', 'vertical topleft new')
|
execute get(g:, 'plug_window', '-tabnew')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:plug_window_exists()
|
function! s:plug_window_exists()
|
||||||
@ -1031,6 +1040,11 @@ function! s:is_updated(dir)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:do(pull, force, todo)
|
function! s:do(pull, force, todo)
|
||||||
|
if has('nvim')
|
||||||
|
" Reset &rtp to invalidate Neovim cache of loaded Lua modules
|
||||||
|
" See https://github.com/junegunn/vim-plug/pull/1157#issuecomment-1809226110
|
||||||
|
let &rtp = &rtp
|
||||||
|
endif
|
||||||
for [name, spec] in items(a:todo)
|
for [name, spec] in items(a:todo)
|
||||||
if !isdirectory(spec.dir)
|
if !isdirectory(spec.dir)
|
||||||
continue
|
continue
|
||||||
@ -1092,12 +1106,14 @@ endfunction
|
|||||||
function! s:checkout(spec)
|
function! s:checkout(spec)
|
||||||
let sha = a:spec.commit
|
let sha = a:spec.commit
|
||||||
let output = s:git_revision(a:spec.dir)
|
let output = s:git_revision(a:spec.dir)
|
||||||
|
let error = 0
|
||||||
if !empty(output) && !s:hash_match(sha, s:lines(output)[0])
|
if !empty(output) && !s:hash_match(sha, s:lines(output)[0])
|
||||||
let credential_helper = s:git_version_requirement(2) ? '-c credential.helper= ' : ''
|
let credential_helper = s:git_version_requirement(2) ? '-c credential.helper= ' : ''
|
||||||
let output = s:system(
|
let output = s:system(
|
||||||
\ 'git '.credential_helper.'fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir)
|
\ 'git '.credential_helper.'fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir)
|
||||||
|
let error = v:shell_error
|
||||||
endif
|
endif
|
||||||
return output
|
return [output, error]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:finish(pull)
|
function! s:finish(pull)
|
||||||
@ -1158,7 +1174,7 @@ function! s:update_impl(pull, force, args) abort
|
|||||||
let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
|
let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ?
|
||||||
\ remove(args, -1) : get(g:, 'plug_threads', 16)
|
\ remove(args, -1) : get(g:, 'plug_threads', 16)
|
||||||
|
|
||||||
let managed = filter(copy(g:plugs), 's:is_managed(v:key)')
|
let managed = filter(deepcopy(g:plugs), 's:is_managed(v:key)')
|
||||||
let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') :
|
let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') :
|
||||||
\ filter(managed, 'index(args, v:key) >= 0')
|
\ filter(managed, 'index(args, v:key) >= 0')
|
||||||
|
|
||||||
@ -1292,9 +1308,11 @@ function! s:update_finish()
|
|||||||
if !pos
|
if !pos
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
let out = ''
|
||||||
|
let error = 0
|
||||||
if has_key(spec, 'commit')
|
if has_key(spec, 'commit')
|
||||||
call s:log4(name, 'Checking out '.spec.commit)
|
call s:log4(name, 'Checking out '.spec.commit)
|
||||||
let out = s:checkout(spec)
|
let [out, error] = s:checkout(spec)
|
||||||
elseif has_key(spec, 'tag')
|
elseif has_key(spec, 'tag')
|
||||||
let tag = spec.tag
|
let tag = spec.tag
|
||||||
if tag =~ '\*'
|
if tag =~ '\*'
|
||||||
@ -1307,19 +1325,16 @@ function! s:update_finish()
|
|||||||
endif
|
endif
|
||||||
call s:log4(name, 'Checking out '.tag)
|
call s:log4(name, 'Checking out '.tag)
|
||||||
let out = s:system('git checkout -q '.plug#shellescape(tag).' -- 2>&1', spec.dir)
|
let out = s:system('git checkout -q '.plug#shellescape(tag).' -- 2>&1', spec.dir)
|
||||||
else
|
let error = v:shell_error
|
||||||
let branch = s:git_origin_branch(spec)
|
|
||||||
call s:log4(name, 'Merging origin/'.s:esc(branch))
|
|
||||||
let out = s:system('git checkout -q '.plug#shellescape(branch).' -- 2>&1'
|
|
||||||
\. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only '.plug#shellescape('origin/'.branch).' 2>&1')), spec.dir)
|
|
||||||
endif
|
endif
|
||||||
if !v:shell_error && filereadable(spec.dir.'/.gitmodules') &&
|
if !error && filereadable(spec.dir.'/.gitmodules') &&
|
||||||
\ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir))
|
\ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir))
|
||||||
call s:log4(name, 'Updating submodules. This may take a while.')
|
call s:log4(name, 'Updating submodules. This may take a while.')
|
||||||
let out .= s:bang('git submodule update --init --recursive'.s:submodule_opt.' 2>&1', spec.dir)
|
let out .= s:bang('git submodule update --init --recursive'.s:submodule_opt.' 2>&1', spec.dir)
|
||||||
|
let error = v:shell_error
|
||||||
endif
|
endif
|
||||||
let msg = s:format_message(v:shell_error ? 'x': '-', name, out)
|
let msg = s:format_message(v:shell_error ? 'x': '-', name, out)
|
||||||
if v:shell_error
|
if error
|
||||||
call add(s:update.errors, name)
|
call add(s:update.errors, name)
|
||||||
call s:regress_bar()
|
call s:regress_bar()
|
||||||
silent execute pos 'd _'
|
silent execute pos 'd _'
|
||||||
@ -1382,7 +1397,9 @@ function! s:job_out_cb(self, data) abort
|
|||||||
if !self.running || self.tick % len(s:jobs) == 0
|
if !self.running || self.tick % len(s:jobs) == 0
|
||||||
let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-')
|
let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-')
|
||||||
let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines)
|
let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines)
|
||||||
call s:log(bullet, self.name, result)
|
if len(result)
|
||||||
|
call s:log(bullet, self.name, result)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -1406,16 +1423,17 @@ function! s:nvim_cb(job_id, data, event) dict abort
|
|||||||
\ s:job_cb('s:job_exit_cb', self, 0, a:data)
|
\ s:job_cb('s:job_exit_cb', self, 0, a:data)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:spawn(name, cmd, opts)
|
function! s:spawn(name, spec, queue, opts)
|
||||||
let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''],
|
let job = { 'name': a:name, 'spec': a:spec, 'running': 1, 'error': 0, 'lines': [''],
|
||||||
\ 'new': get(a:opts, 'new', 0) }
|
\ 'new': get(a:opts, 'new', 0), 'queue': copy(a:queue) }
|
||||||
|
let Item = remove(job.queue, 0)
|
||||||
|
let argv = type(Item) == s:TYPE.funcref ? call(Item, [a:spec]) : Item
|
||||||
let s:jobs[a:name] = job
|
let s:jobs[a:name] = job
|
||||||
|
|
||||||
if s:nvim
|
if s:nvim
|
||||||
if has_key(a:opts, 'dir')
|
if has_key(a:opts, 'dir')
|
||||||
let job.cwd = a:opts.dir
|
let job.cwd = a:opts.dir
|
||||||
endif
|
endif
|
||||||
let argv = a:cmd
|
|
||||||
call extend(job, {
|
call extend(job, {
|
||||||
\ 'on_stdout': function('s:nvim_cb'),
|
\ 'on_stdout': function('s:nvim_cb'),
|
||||||
\ 'on_stderr': function('s:nvim_cb'),
|
\ 'on_stderr': function('s:nvim_cb'),
|
||||||
@ -1431,7 +1449,7 @@ function! s:spawn(name, cmd, opts)
|
|||||||
\ 'Invalid arguments (or job table is full)']
|
\ 'Invalid arguments (or job table is full)']
|
||||||
endif
|
endif
|
||||||
elseif s:vim8
|
elseif s:vim8
|
||||||
let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"script": 0})'))
|
let cmd = join(map(copy(argv), 'plug#shellescape(v:val, {"script": 0})'))
|
||||||
if has_key(a:opts, 'dir')
|
if has_key(a:opts, 'dir')
|
||||||
let cmd = s:with_cd(cmd, a:opts.dir, 0)
|
let cmd = s:with_cd(cmd, a:opts.dir, 0)
|
||||||
endif
|
endif
|
||||||
@ -1451,27 +1469,34 @@ function! s:spawn(name, cmd, opts)
|
|||||||
let job.lines = ['Failed to start job']
|
let job.lines = ['Failed to start job']
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let job.lines = s:lines(call('s:system', has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd]))
|
let job.lines = s:lines(call('s:system', has_key(a:opts, 'dir') ? [argv, a:opts.dir] : [argv]))
|
||||||
let job.error = v:shell_error != 0
|
let job.error = v:shell_error != 0
|
||||||
let job.running = 0
|
let job.running = 0
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:reap(name)
|
function! s:reap(name)
|
||||||
let job = s:jobs[a:name]
|
let job = remove(s:jobs, a:name)
|
||||||
if job.error
|
if job.error
|
||||||
call add(s:update.errors, a:name)
|
call add(s:update.errors, a:name)
|
||||||
elseif get(job, 'new', 0)
|
elseif get(job, 'new', 0)
|
||||||
let s:update.new[a:name] = 1
|
let s:update.new[a:name] = 1
|
||||||
endif
|
endif
|
||||||
let s:update.bar .= job.error ? 'x' : '='
|
|
||||||
|
|
||||||
let bullet = job.error ? 'x' : '-'
|
let more = len(get(job, 'queue', []))
|
||||||
|
let bullet = job.error ? 'x' : more ? (job.new ? '+' : '*') : '-'
|
||||||
let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines)
|
let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines)
|
||||||
call s:log(bullet, a:name, empty(result) ? 'OK' : result)
|
if len(result)
|
||||||
call s:bar()
|
call s:log(bullet, a:name, result)
|
||||||
|
endif
|
||||||
|
|
||||||
call remove(s:jobs, a:name)
|
if !job.error && more
|
||||||
|
let job.spec.queue = job.queue
|
||||||
|
let s:update.todo[a:name] = job.spec
|
||||||
|
else
|
||||||
|
let s:update.bar .= job.error ? 'x' : '='
|
||||||
|
call s:bar()
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:bar()
|
function! s:bar()
|
||||||
@ -1524,6 +1549,16 @@ function! s:update_vim()
|
|||||||
call s:tick()
|
call s:tick()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:checkout_command(spec)
|
||||||
|
let a:spec.branch = s:git_origin_branch(a:spec)
|
||||||
|
return ['git', 'checkout', '-q', a:spec.branch, '--']
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:merge_command(spec)
|
||||||
|
let a:spec.branch = s:git_origin_branch(a:spec)
|
||||||
|
return ['git', 'merge', '--ff-only', 'origin/'.a:spec.branch]
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:tick()
|
function! s:tick()
|
||||||
let pull = s:update.pull
|
let pull = s:update.pull
|
||||||
let prog = s:progress_opt(s:nvim || s:vim8)
|
let prog = s:progress_opt(s:nvim || s:vim8)
|
||||||
@ -1538,13 +1573,18 @@ while 1 " Without TCO, Vim stack is bound to explode
|
|||||||
|
|
||||||
let name = keys(s:update.todo)[0]
|
let name = keys(s:update.todo)[0]
|
||||||
let spec = remove(s:update.todo, name)
|
let spec = remove(s:update.todo, name)
|
||||||
let new = empty(globpath(spec.dir, '.git', 1))
|
let queue = get(spec, 'queue', [])
|
||||||
|
let new = empty(globpath(spec.dir, '.git', 1))
|
||||||
|
|
||||||
call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
|
if empty(queue)
|
||||||
redraw
|
call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...')
|
||||||
|
redraw
|
||||||
|
endif
|
||||||
|
|
||||||
let has_tag = has_key(spec, 'tag')
|
let has_tag = has_key(spec, 'tag')
|
||||||
if !new
|
if len(queue)
|
||||||
|
call s:spawn(name, spec, queue, { 'dir': spec.dir })
|
||||||
|
elseif !new
|
||||||
let [error, _] = s:git_validate(spec, 0)
|
let [error, _] = s:git_validate(spec, 0)
|
||||||
if empty(error)
|
if empty(error)
|
||||||
if pull
|
if pull
|
||||||
@ -1555,7 +1595,11 @@ while 1 " Without TCO, Vim stack is bound to explode
|
|||||||
if !empty(prog)
|
if !empty(prog)
|
||||||
call add(cmd, prog)
|
call add(cmd, prog)
|
||||||
endif
|
endif
|
||||||
call s:spawn(name, cmd, { 'dir': spec.dir })
|
let queue = [cmd, split('git remote set-head origin -a')]
|
||||||
|
if !has_tag && !has_key(spec, 'commit')
|
||||||
|
call extend(queue, [function('s:checkout_command'), function('s:merge_command')])
|
||||||
|
endif
|
||||||
|
call s:spawn(name, spec, queue, { 'dir': spec.dir })
|
||||||
else
|
else
|
||||||
let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 }
|
let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 }
|
||||||
endif
|
endif
|
||||||
@ -1570,7 +1614,7 @@ while 1 " Without TCO, Vim stack is bound to explode
|
|||||||
if !empty(prog)
|
if !empty(prog)
|
||||||
call add(cmd, prog)
|
call add(cmd, prog)
|
||||||
endif
|
endif
|
||||||
call s:spawn(name, extend(cmd, [spec.uri, s:trim(spec.dir)]), { 'new': 1 })
|
call s:spawn(name, spec, [extend(cmd, [spec.uri, s:trim(spec.dir)]), function('s:checkout_command'), function('s:merge_command')], { 'new': 1 })
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !s:jobs[name].running
|
if !s:jobs[name].running
|
||||||
@ -2346,18 +2390,21 @@ function! s:git_validate(spec, check_branch)
|
|||||||
\ current_branch, origin_branch)
|
\ current_branch, origin_branch)
|
||||||
endif
|
endif
|
||||||
if empty(err)
|
if empty(err)
|
||||||
let [ahead, behind] = split(s:lastline(s:system([
|
let ahead_behind = split(s:lastline(s:system([
|
||||||
\ 'git', 'rev-list', '--count', '--left-right',
|
\ 'git', 'rev-list', '--count', '--left-right',
|
||||||
\ printf('HEAD...origin/%s', origin_branch)
|
\ printf('HEAD...origin/%s', origin_branch)
|
||||||
\ ], a:spec.dir)), '\t')
|
\ ], a:spec.dir)), '\t')
|
||||||
if !v:shell_error && ahead
|
if v:shell_error || len(ahead_behind) != 2
|
||||||
if behind
|
let err = "Failed to compare with the origin. The default branch might have changed.\nPlugClean required."
|
||||||
|
else
|
||||||
|
let [ahead, behind] = ahead_behind
|
||||||
|
if ahead && behind
|
||||||
" Only mention PlugClean if diverged, otherwise it's likely to be
|
" Only mention PlugClean if diverged, otherwise it's likely to be
|
||||||
" pushable (and probably not that messed up).
|
" pushable (and probably not that messed up).
|
||||||
let err = printf(
|
let err = printf(
|
||||||
\ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n"
|
\ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n"
|
||||||
\ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', origin_branch, ahead, behind)
|
\ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', origin_branch, ahead, behind)
|
||||||
else
|
elseif ahead
|
||||||
let err = printf("Ahead of origin/%s by %d commit(s).\n"
|
let err = printf("Ahead of origin/%s by %d commit(s).\n"
|
||||||
\ .'Cannot update until local changes are pushed.',
|
\ .'Cannot update until local changes are pushed.',
|
||||||
\ origin_branch, ahead)
|
\ origin_branch, ahead)
|
||||||
@ -2637,8 +2684,8 @@ function! s:preview_commit()
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists('g:plug_pwindow') && !s:is_preview_window_open()
|
if !s:is_preview_window_open()
|
||||||
execute g:plug_pwindow
|
execute get(g:, 'plug_pwindow', 'vertical rightbelow new')
|
||||||
execute 'e' title
|
execute 'e' title
|
||||||
else
|
else
|
||||||
execute 'pedit' title
|
execute 'pedit' title
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
|
||||||
"
|
"
|
||||||
" " On-demand loading
|
" " On-demand loading
|
||||||
" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
" Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
|
||||||
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
|
||||||
"
|
"
|
||||||
" " Using a non-default branch
|
" " Using a non-default branch
|
||||||
|
|||||||
Reference in New Issue
Block a user