Refactor: ..., also: Added vim-lastplace and tmate

This commit is contained in:
kat witch 2021-05-07 00:49:01 +01:00
parent 386fe7a2c0
commit 46169bc8c2
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
103 changed files with 142 additions and 167 deletions

12
users/kat/base/base16.nix Normal file
View file

@ -0,0 +1,12 @@
{ config, ... }:
{
base16 = {
shell.enable = true;
schemes = [ "rebecca.rebecca" ];
};
# home.base16-shell = {
# enable = true;
# defaultTheme = "rebecca.rebecca";
# };
}

View file

@ -0,0 +1,16 @@
{ ... }:
{
imports = [
./vim
./zsh.nix
./git.nix
./kitty.nix
./tmux.nix
./base16.nix
./xdg.nix
./ssh.nix
./packages.nix
./weechat.nix
];
}

31
users/kat/base/git.nix Normal file
View file

@ -0,0 +1,31 @@
{ config, pkgs, lib, ... }:
{
home.packages = with pkgs; [
git-crypt
gitAndTools.gitRemoteGcrypt
gitAndTools.gitAnnex
git-revise
gitAndTools.git-annex-remote-b2
];
programs.git = {
enable = true;
package = pkgs.gitAndTools.gitFull;
userName = "kat witch";
userEmail = "kat@kittywit.ch";
extraConfig = {
init = { defaultBranch = "main"; };
protocol.gcrypt.allow = "always";
annex = {
autocommit = false;
backend = "BLAKE2B512";
synccontent = true;
};
};
signing = {
key = "01F50A29D4AA91175A11BDB17248991EFA8EFBEE";
signByDefault = true;
};
};
}

6
users/kat/base/kitty.nix Normal file
View file

@ -0,0 +1,6 @@
{ config, pkgs, ... }:
{
home.sessionVariables.TERMINFO_DIRS =
"${pkgs.kitty.terminfo.outPath}/share/terminfo";
}

View file

@ -0,0 +1,29 @@
{ config, lib, pkgs, ... }:
{
home.packages = with pkgs; [
tmate
htop
fd
sd
duc
bat
exa
fd
socat
rsync
wget
ripgrep
nixfmt
pv
progress
zstd
file
whois
niv
dnsutils
rink
borgbackup
neofetch
];
}

25
users/kat/base/ssh.nix Normal file
View file

@ -0,0 +1,25 @@
{ config, pkgs, lib, ... }:
{
programs.ssh = {
enable = true;
controlMaster = "auto";
controlPersist = "10m";
hashKnownHosts = true;
matchBlocks = let
common = {
forwardAgent = true;
extraOptions = {
RemoteForward =
"/run/user/1000/gnupg/S.gpg-agent /run/user/1000/gnupg/S.gpg-agent.extra";
};
port = 62954;
};
in {
"athame" = { hostname = "athame.kittywit.ch"; } // common;
"samhain" = { hostname = "192.168.1.135"; } // common;
"yule" = { hostname = "192.168.1.92"; } // common;
"ostara" = { hostname = "192.168.1.245"; } // common;
};
};
}

55
users/kat/base/tmux.nix Normal file
View file

@ -0,0 +1,55 @@
{ config, lib, pkgs, ... }:
{
programs.zsh.shellAliases = {
tne = "tmux new -s";
tat = "tmux attach -t";
tren = "tmux new -AD -s";
};
programs.tmux = {
enable = true;
extraConfig = ''
# start from 1
set -g base-index 1
setw -g pane-base-index 1
# proper title handling
set -g set-titles on
set -g set-titles-string "#T"
# 256 color
set -g default-terminal "screen-256color"
# modes
setw -g clock-mode-colour colour5
setw -g mode-style 'fg=colour1 bg=colour18 bold'
# panes
set -g pane-border-style 'fg=colour19 bg=colour0'
set -g pane-active-border-style 'bg=colour0 fg=colour9'
# statusbar
set -g status-position bottom
set -g status-justify left
set -g status-style 'bg=colour18 fg=colour137 dim'
set -g status-left '''
set -g status-right '#[fg=colour233,bg=colour19] %F #[fg=colour233,bg=colour8] %H:%M:%S %Z'
set -g status-right-length 50
set -g status-left-length 20
setw -g window-status-current-style 'fg=colour1 bg=colour19 bold'
setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F '
setw -g window-status-style 'fg=colour9 bg=colour18'
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '
setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold'
# messages
set -g message-style 'fg=colour232 bg=colour16 bold'
# mouse
set -g mouse on
'';
};
}

View file

@ -0,0 +1,58 @@
{ config, lib, pkgs, ... }:
{
home.sessionVariables.EDITOR = "vim";
programs.vim = {
enable = true;
package = pkgs.arc.pkgs.vim_configurable-pynvim;
#withPython3 = true;
plugins = with pkgs.vimPlugins; [
nerdtree
vim-nix
rust-vim
coc-nvim
coc-rust-analyzer
coc-yank
coc-python
coc-json
coc-yaml
coc-git
coc-css
coc-html
vim-fugitive
vim-startify
vim-airline
vim-airline-themes
vim-lastplace
base16-vim
];
#extraPackages = with pkgs;
# [ (python3.withPackages (ps: with ps; [ black flake8 ])) ];
#extraPython3Packages = (ps: with ps; [ jedi pylint ]);
extraConfig = import ./vimrc.nix { inherit pkgs config; };
};
xdg.dataFile = {
"vim/undo/.keep".text = "";
"vim/swap/.keep".text = "";
"vim/backup/.keep".text = "";
};
xdg.configFile = {
"vim/coc/coc-settings.json".text = builtins.toJSON {
"rust.rustfmt_path" = "${pkgs.rustfmt}/bin/rustfmt";
"rust-analyzer.serverPath" = "rust-analyzer";
"rust-analyzer.updates.prompt" = false;
"rust-analyzer.notifications.cargoTomlNotFound" = false;
"rust-analyzer.notifications.workspaceLoaded" = false;
"rust-analyzer.procMacro.enable" = true;
"rust-analyzer.cargo.loadOutDirsFromCheck" = true;
"rust-analyzer.cargo-watch.enable" =
true; # TODO: want some way to toggle this on-demand?
"rust-analyzer.completion.addCallParenthesis" =
false; # consider using this?
"rust-analyzer.hoverActions.linksInHover" = true;
"rust-analyzer.diagnostics.disabled" = [
"inactive-code" # it has strange cfg support..?
];
};
};
}

View file

@ -0,0 +1,196 @@
{ config, pkgs }:
''
" Enable mouse
set mouse=a
set viminfo='100000,<100000,s1000,h,n$XDG_DATA_HOME/vim/viminfo
" colors
let base16colorspace=256
colorscheme base16-default-dark
" tabline
let g:airline#extensions#tabline#enabled = 1
" notmuch!
let g:notmuch_config_file='${config.xdg.configHome}/notmuch/notmuchrc'
let g:notmuch_folders_count_threads=0
let g:notmuch_date_format='%y-%m-%d %H:%M'
let g:notmuch_datetime_format='%y-%m-%d %H:%M'
let g:notmuch_show_date_format='%Y/%m/%d %H:%M'
let g:notmuch_search_date_format='%Y/%m/%d %H:%M'
let g:notmuch_html_converter='${pkgs.elinks}/bin/elinks --dump'
" lastplace
let g:lastplace_ignore = "gitcommit,gitrebase,svn,hgcommit"
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() |
\ quit | endif
autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
let g:coc_node_path='${pkgs.nodejs}/bin/node'
let g:coc_config_home=$XDG_CONFIG_HOME . '/vim/coc'
set undodir=$XDG_DATA_HOME/vim/undo
set directory=$XDG_DATA_HOME/vim/swap//
set backupdir=$XDG_DATA_HOME/vim/backup
set ttimeoutlen=100
set number
set hidden
set nobackup
set nowritebackup
set cmdheight=2
set updatetime=300
set cursorline
set colorcolumn=100
set linebreak showbreak= "
set hlsearch
set relativenumber
set completeopt=longest,menuone
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current buffer.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function',''')}
" Mappings for CoCList
" Show all diagnostics.
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
'' + (if config.deploy.profile.sway then ''
noremap "+y y:call system("wl-copy", @")<CR>
nnoremap "+p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', ''', 'g')<CR>p
nnoremap "*p :let @"=substitute(system("wl-paste --no-newline --primary"), '<C-v><C-m>', ''', 'g')<CR>p
'' else
"")

View file

@ -0,0 +1,70 @@
{ config, pkgs, lib, ... }:
{
programs.weechat = {
init = lib.mkMerge [
(lib.mkBefore ''
/server add freenode athame.kittywit.ch/5001 -ssl -autoconnect
/server add espernet athame.kittywit.ch/5001 -ssl -autoconnect
/matrix server add kat kittywit.ch
/key bind meta-g /go
/key bind meta-c /buffer close
/key bind meta-n /bar toggle nicklist
/key bind meta-b /bar toggle buflist
/relay add weechat 9000
'')
(lib.mkAfter "/matrix connect kat")
];
packageUnwrapped = pkgs.weechat-unwrapped;
homeDirectory = "${config.xdg.dataHome}/weechat";
plugins.python = {
enable = true;
packages = [ "weechat-matrix" ];
};
scripts = with pkgs.weechatScripts; [
go
auto_away
autosort
colorize_nicks
unread_buffer
urlgrab
vimode-git
weechat-matrix
weechat-notify-send
title
];
config = {
logger.level.irc = 0;
logger.level.matrix = 0;
weechat = {
look = { mouse = true; };
bar = {
buflist = { size_max = 24; };
nicklist = { size_max = 18; };
};
};
urlgrab.default.copycmd = "${pkgs.wl-clipboard}/bin/wl-copy";
plugins.var.python.vimode.copy_clipboard_cmd = "wl-copy";
plugins.var.python.vimode.paste_clipboard_cmd = "wl-paste --no-newline";
plugins.var.python.title.title_prefix = "weechat - ";
plugins.var.python.title.show_hotlist = true;
plugins.var.python.title.current_buffer_suffix = " [";
plugins.var.python.title.title_suffix = " ]";
plugins.var.python.notify_send.icon = "";
plugins.var.python.go.short_name = true;
irc = { look = { server_buffer = "independent"; }; };
matrix = {
network = {
max_backlog_sync_events = 30;
lazy_load_room_users = true;
autoreconnect_delay_max = 5;
lag_min-show = 1000;
};
look = {
server_buffer = "independent";
redactions = "notice";
};
};
};
};
}

18
users/kat/base/xdg.nix Normal file
View file

@ -0,0 +1,18 @@
{ config, lib, ... }:
{
xdg = {
enable = true;
userDirs = {
enable = true;
pictures = "$HOME/media";
videos = "$HOME/media/videos";
documents = "$HOME/docs";
download = "$HOME/downloads";
desktop = "$HOME/tmp";
templates = "$HOME/tmp";
publicShare = "$HOME/shared";
music = "$HOME/media-share/music";
};
};
}

65
users/kat/base/zsh.nix Normal file
View file

@ -0,0 +1,65 @@
{ config, lib, pkgs, ... }:
{
xdg.dataFile = { "z/.keep".text = ""; };
home.packages = with pkgs; [ fzf fd ];
programs.zsh = {
enable = true;
enableAutosuggestions = true;
shellAliases = {
nixdirfmt = "fd --color=never .nix | xargs nixfmt";
exa = "exa --time-style long-iso";
ls = "exa -G";
la = "exa -Ga";
ll = "exa -l";
lla = "exa -lga";
};
initExtra = ''
genmac() { nix run nixpkgs.openssl -c openssl rand -hex 6 | sed 's/\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)/\1:\2:\3:\4:\5:\6/' }
nano() { echo "baps you for being naughty, use vim" }
'';
localVariables = {
_Z_DATA = "${config.xdg.dataHome}/z/data";
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE = "fg=3,bold";
ZSH_AUTOSUGGEST_USE_ASYNC = 1;
};
plugins = [
(with pkgs.zsh-syntax-highlighting; {
name = "zsh-syntax-highlighting";
inherit src;
})
{
name = "z";
file = "z.sh";
src = pkgs.fetchFromGitHub {
owner = "rupa";
repo = "z";
rev = "9d5a3fe0407101e2443499e4b95bca33f7a9a9ca";
sha256 = "0aghw6zmd3851xpzgy0jkh25wzs9a255gxlbdr3zw81948qd9wb1";
};
}
{
name = "fzf-z";
src = pkgs.fetchFromGitHub {
owner = "andrewferrier";
repo = "fzf-z";
rev = "089ba6cacd3876c349cfb6b65dc2c3e68b478fd0";
sha256 = "1lvvkz0v4xibq6z3y8lgfkl9ibcx0spr4qzni0n925ar38s20q81";
};
}
];
oh-my-zsh = {
enable = true;
plugins = [ "git" "sudo" "adb" "cargo" "emoji" ];
};
};
programs.starship = {
enable = true;
enableZshIntegration = true;
};
programs.direnv = {
enable = true;
enableZshIntegration = true;
enableNixDirenvIntegration = true;
};
}