diff --git a/README.md b/README.md index e2c6b43..c1e25e1 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # SHELLRC +- [installrc.sh](./installrc.sh) ❯ Installation script. - [bin](./bin) ❯ Executable files. - [etc](./etc) ❯ Configuration files. - - [installrc.sh](./etc/installrc.sh) ❯ Installation script. - [rc.\*](./etc/rc.linux) ❯ Installation manifests. - [Х](./etc/X) ❯ X.org server configuration. - [cron](./etc/cron) ❯ User's crontab. @@ -12,6 +12,7 @@ - [shell](./etc/shell) ❯ Shells and repls: bash (profile, aliases, completion, inputrc), tclsh, guile. - [soft](./etc/soft) ❯ Other applications: git, vim, vifm, sdcv, polybar, etc. - [wm](./etc/wm) ❯ fonts, wallpapers, GUI themes, Musca WM, Xmonad and bspwm configurations. +- [profiles](./profiles) ❯ OS Profiles. - [var](./var) ❯ Logs, shell history, vim temporary files, etc. # NB diff --git a/etc/X/Xdefaults.linux.coal b/etc/X/Xdefaults.linux.coal new file mode 100644 index 0000000..fe3d8f6 --- /dev/null +++ b/etc/X/Xdefaults.linux.coal @@ -0,0 +1,21 @@ + +!Настрока шрифтов +Xft.antialias: true +Xft.dpi: 96 +! Xft.dpi: 120 +Xft.hinting: true +!Xft.hintstyle: hintfull +Xft.hintstyle: hintslight +Xft.rgba: rgb + +!Настройки rofi +!#include "$HOME/etc/soft/rofi/rofi" +!#include "~/.shellrc/etc/soft/rofi/rofi.paper" + +!Настройки эмуляторов терминалов +!#include "~/.shellrc/etc/X/Xdefaults.urxvt" +!#include "~/.shellrc/etc/X/Xdefaults.xst" + +!Цветовые схемы +!#include "~/.shellrc/etc/X/Xdefaults.colorscheme.light" + diff --git a/etc/X/Xdefaults.xst b/etc/X/Xdefaults.xst index 1ffc3a3..a744746 100644 --- a/etc/X/Xdefaults.xst +++ b/etc/X/Xdefaults.xst @@ -9,7 +9,8 @@ st.shell: /bin/bash ! The following options options can be reloaded via USR1 signal. ! st.font: Liberation Mono:pixelsize=12:antialias=true:autohint=true; -st.font: DejaVuSansMono Nerd Font Mono:pixelsize=13:antialias=true:autohint=true +st.font: Anonymice Nerd Font:pixelsize=20:antialias=true:autohint=true +! st.font: DejaVuSansMono:pixelsize=16:antialias=true:autohint=true st.borderpx: 0 ! Available cursor values: 2 4 6 7 = █ _ | ☃ ( 1 3 5 are blinking versions) st.cursorshape: 2 diff --git a/etc/X/Xdefaults.xst.linux.coal b/etc/X/Xdefaults.xst.linux.coal new file mode 100644 index 0000000..32be64c --- /dev/null +++ b/etc/X/Xdefaults.xst.linux.coal @@ -0,0 +1,44 @@ +! These are all possible options, presented with default values. +! xst will fallback to *.option if st.option is not present. +! see src/config.h for more information about option meanings. + +! These options only take effect on startup. +st.termname: st-256color +! if you do not set shell, precedence is: -e arg, utmp option, SHELL env var, /etc/passwd shell +st.shell: /bin/bash + +! The following options options can be reloaded via USR1 signal. +! st.font: Liberation Mono:pixelsize=12:antialias=true:autohint=true; +! st.font: Anonymice Nerd Font:pixelsize=19:antialias=true:autohint=true +st.font: Cousine:pixelsize=19:antialias=true:autohint=true +! st.font: DejaVuSansMono:pixelsize=16:antialias=true:autohint=true +st.borderpx: 0 +! Available cursor values: 2 4 6 7 = █ _ | ☃ ( 1 3 5 are blinking versions) +st.cursorshape: 2 +! thickness of underline and bar cursors +st.cursorthickness: 1 +! 0: normal blinking, 1: leave cursor border and blink with cursors background +st.cursorblinkstyle: 0 +! 0: cursor blinks with a constant interval; 1: blinking cycle resets on key input +st.cursorblinkontype: 1 +st.bold_font: 0 +st.xfps: 120 +st.actionfps: 30 +! Amount of lines scrolled +st.mouseScrollLines: 3 +! Kerning / character bounding-box height multiplier +st.chscale: 1.0 +! Kerning / character bounding-box width multiplier +st.cwscale: 1.0 +! blinking timeout for terminal and cursor blinking (0 disables) +st.blinktimeout: 800 +! bell volume. Value between -100 and 100. (0 disables) +st.bellvolume: 100 +! this is a char that is exposed like so: `printf '\033[z'` +st.prompt_char: $ +! This option is can be preedit style. Available values: `root` `overthespot` (Default taken `root`) +st.imstyle: root + +! opacity==255 means what terminal will be not transparent, 0 - fully transparent +st.opacity: 255 + diff --git a/etc/X/Xmodmaprc.linux.coal b/etc/X/Xmodmaprc.linux.coal new file mode 100644 index 0000000..6cef8c3 --- /dev/null +++ b/etc/X/Xmodmaprc.linux.coal @@ -0,0 +1,3 @@ +! Использование PrintScreen в качестве Mod1 наряду с Alt_L +! clear Mod1 +add Mod1 = Alt_L Print diff --git a/etc/X/xbindkeysrc.linux.coal b/etc/X/xbindkeysrc.linux.coal new file mode 100644 index 0000000..eeafaf0 --- /dev/null +++ b/etc/X/xbindkeysrc.linux.coal @@ -0,0 +1,32 @@ +# xbindkeysrc.AuthenticAMD +# +# Изменён: Ср 03 ноя 2021 15:30:27 +# + +#ACPI#{{{ + +# Pulseaudio +"pactl -- set-sink-volume 0 -5%" + XF86AudioLowerVolume + +"pactl -- set-sink-volume 0 +5%" + XF86AudioRaiseVolume + +"pactl set-sink-mute @DEFAULT_SINK@ toggle" + XF86AudioMute + +# Light +"light -U 5" + XF86MonBrightnessDown + +"light -A 5" + XF86MonBrightnessUp + +"light -U 2" + Control + XF86MonBrightnessDown + +"light -A 2" + Control + XF86MonBrightnessUp + +#}}} + diff --git a/etc/X/xinitrc.linux.carbon b/etc/X/xinitrc.linux.carbon index 41aadcb..8ecb79d 100644 --- a/etc/X/xinitrc.linux.carbon +++ b/etc/X/xinitrc.linux.carbon @@ -1,21 +1,16 @@ -display -window root $SHELLRC/etc/wm/img/wallpaper.$(uname -i).jpg -xsetroot -cursor_name left_ptr +#!/usr/bin/env bash -setxkbmap -option "" -setxkbmap -model pc104 -layout us,ru,el,co -variant ,,polytonic, -setxkbmap -option -option terminate:ctrl_alt_bksp,caps:escape,grp:lwin_toggle,compose:ralt +#display -window root $SHELLRC/etc/wm/img/wallpaper.$(uname -i).jpg +#xsetroot -cursor_name left_ptr -xmodmap $SHELLRC/etc/X/Xmodmaprc.$(uname -i) -xbindkeys -f $SHELLRC/etc/X/xbindkeysrc.$(uname -i) -sh $SHELLRC/etc/X/xrandr.$(uname -i) +#exec setxkbmap -option "" +#exec setxkbmap -model pc104 -layout us,ru,el,co -variant ,,polytonic, +#exec setxkbmap -option -option terminate:ctrl_alt_bksp,caps:escape,grp:lwin_toggle,compose:ralt -# export GTK_IM_MODULE="ibus" -# export QT_IM_MODULE="ibus" -unset XMODIFIERS -# export XMODIFIERS=@im=ibus +#exec xbindkeys -f $SHELLRC/etc/X/xbindkeysrc.$HOSTNAME +#sh $SHELLRC/etc/X/xrandr.$HOSTNAME -#exec musca -#exec ck-launch-session xmonad +#unset XMODIFIERS exec bspwm diff --git a/etc/X/xinitrc.linux.coal b/etc/X/xinitrc.linux.coal new file mode 100755 index 0000000..607fc65 --- /dev/null +++ b/etc/X/xinitrc.linux.coal @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +#exec xbindkeys -f "$SHELLRC/etc/X/xbindkeysrc.$PLATFORM.$HOSTNAME" +#sh $SHELLRC/etc/X/xrandr.$HOSTNAME + +#unset XMODIFIERS + +exec bspwm + diff --git a/etc/media/ncmpcpp/ncmpcpp b/etc/media/ncmpcpp/ncmpcpp new file mode 120000 index 0000000..bad6b92 --- /dev/null +++ b/etc/media/ncmpcpp/ncmpcpp @@ -0,0 +1 @@ +/home/envrm/.shellrc/etc/media/ncmpcpp \ No newline at end of file diff --git a/etc/net/newsboat/newsboat b/etc/net/newsboat/newsboat new file mode 120000 index 0000000..51bfbd2 --- /dev/null +++ b/etc/net/newsboat/newsboat @@ -0,0 +1 @@ +/home/envrm/.shellrc/etc/net/newsboat \ No newline at end of file diff --git a/etc/shell/bash/aliases b/etc/shell/bash/aliases index b1634a0..21b6947 100755 --- a/etc/shell/bash/aliases +++ b/etc/shell/bash/aliases @@ -55,7 +55,7 @@ alias lss='\ls --format=single-column' #noindex alias lsh='ls --hyperlink' #noindex alias nl="nl -b a" #noindex alias df='df -hT' #noindex -alias dfc='dfc -t apfs,ext4,fuseblk,osxfuse -w -s -T' #noindex +alias dfc='dfc -t apfs,ext4,fuseblk,osxfuse -d -w -s -T' #noindex alias du='du -hs' #noindex alias ip='ip -color=auto' #noindex alias free="free -m" #noindex @@ -95,7 +95,7 @@ alias screen="TERM=rxvt-256color screen" #noindex alias figlet="figlet -f $SHELLRC/etc/soft/figlet/fonts/standard.flf" #noindex alias kz="killall zathura" #noindex alias g=git #noindex -alias startx="xinit -- /usr/bin/X" #noindex +# alias startx="xinit -- /usr/bin/X" #noindex alias lftp="LFTP_HOME=$SHELLRC/etc/net/lftp lftp" #noindex alias fm="nnn" #noindex @@ -112,7 +112,7 @@ sed() { if command -V gsed >/dev/null 2>&1; then gsed "$@" else - sed "$@" + command sed "$@" fi } @@ -358,7 +358,7 @@ src() { vcat "$1" | less -R; } #- Поиск пути к исполняемому файлу, просмотр кода функций и псевдонимов which() { #noindex RESULT=$({ alias; declare -f; } \ - | /usr/bin/which \ + | /usr/bin/env which \ --tty-only \ --read-alias \ --read-functions \ @@ -371,12 +371,12 @@ which() { #noindex #- Переход в директорию файла cdwhich() { - cd "$(dirname "$(/usr/bin/which "$1")")" + cd "$(dirname "$(/usr/bin/env which "$1")")" } #- Редактирование скриптов dowhich() { #noindex - eval "$1" "$(/usr/bin/which "$2")" + eval "$1" "$(/usr/bin/env which "$2")" } #- Редактирование скриптов diff --git a/etc/shell/bash/aliases_linux b/etc/shell/bash/aliases_linux index 65e0fdb..3b2e678 100644 --- a/etc/shell/bash/aliases_linux +++ b/etc/shell/bash/aliases_linux @@ -1,13 +1,18 @@ # Псевдонимы -ls-with-icons() { ls-i --color=always -N -w $(tput cols) "$@"; } #noindex -dir-with-icons() { dir-i --color=always -N -w $(tput cols) "$@"; } #noindex -vdir-with-icons() { vdir-i --color=always -N -w $(tput cols) "$@"; } #noindex +# ls-with-icons() { ls-i --color=always -N -w $(tput cols) "$@"; } #noindex +# dir-with-icons() { dir-i --color=always -N -w $(tput cols) "$@"; } #noindex +# vdir-with-icons() { vdir-i --color=always -N -w $(tput cols) "$@"; } #noindex -alias ls='ls-with-icons -lGhpXv --color=always --group-directories-first' #noindex -alias lsl='ls-with-icons -L' #noindex -alias lst='ls-with-icons -al --time-style=+%D | grep $(\date +%D)' #noindex -alias lsh='ls-with-icons --hyperlink' #noindex +# alias ls='ls-with-icons -lGhpXv --color=always --group-directories-first' #noindex +# alias lsl='ls-with-icons -L' #noindex +# alias lst='ls-with-icons -al --time-style=+%D | grep $(\date +%D)' #noindex +# alias lsh='ls-with-icons --hyperlink' #noindex + +alias ls='ls -lGhpXv --color=always --group-directories-first' #noindex +alias lsl='ls -L' #noindex +alias lst='ls -al --time-style=+%D | grep $(\date +%D)' #noindex +alias lsh='ls --hyperlink' #noindex alias ps="ps -aux" #noindex # alias ping="pingp --nolegend" #noindex diff --git a/etc/shell/bash/bashrc b/etc/shell/bash/bashrc index 12a43f4..425ac70 100755 --- a/etc/shell/bash/bashrc +++ b/etc/shell/bash/bashrc @@ -1,6 +1,6 @@ #!/usr/bin/env bash ############################################################ # -# Изменён: вт 02 ноя 2021 21:12:01 +# Изменён: Ср 03 ноя 2021 15:56:18 # ################################################################################ diff --git a/etc/shell/bash/bashrc_linux b/etc/shell/bash/bashrc_linux index 1fb69e7..ecb50fe 100644 --- a/etc/shell/bash/bashrc_linux +++ b/etc/shell/bash/bashrc_linux @@ -7,7 +7,8 @@ path++ $SHELLRC/bin:$SHELLRC/bin/scripts:$SHELLRC/bin/hub PATH path++ $HOME/.local/bin PATH path++ /bin:/usr/bin:/usr/local/bin PATH -[[ (-f $BASHRC/cdargs-bash.sh) ]] && . $BASHRC/cdargs-bash.sh +# TODO: upgrade , +# [[ (-f $BASHRC/cdargs-bash.sh) ]] && . $BASHRC/cdargs-bash.sh [[ -f $BASHRC/aliases_linux ]] && LINUX_ALIASES="$BASHRC/aliases_linux" \ && . $LINUX_ALIASES \ diff --git a/etc/soft/htop/htop b/etc/soft/htop/htop new file mode 120000 index 0000000..fcb2f0e --- /dev/null +++ b/etc/soft/htop/htop @@ -0,0 +1 @@ +/home/envrm/.shellrc/etc/soft/htop \ No newline at end of file diff --git a/etc/soft/nvim/+plugins/vim-nix/LICENSE b/etc/soft/nvim/+plugins/vim-nix/LICENSE new file mode 100644 index 0000000..16dc3e8 --- /dev/null +++ b/etc/soft/nvim/+plugins/vim-nix/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/etc/soft/nvim/+plugins/vim-nix/README.md b/etc/soft/nvim/+plugins/vim-nix/README.md new file mode 100644 index 0000000..0d6a943 --- /dev/null +++ b/etc/soft/nvim/+plugins/vim-nix/README.md @@ -0,0 +1,55 @@ +# vim-nix + +[![Build Status](https://travis-ci.org/LnL7/vim-nix.svg?branch=master)](https://travis-ci.org/LnL7/vim-nix) + +Support for writing [Nix expressions](http://nixos.org/nix/manual/#chap-writing-nix-expressions) in vim. + +Features included so far: + +* Syntax highlighting for Nix +* Filetype detection for `.nix` files +* Automatic indentation +* [`NixEdit`](https://github.com/LnL7/vim-nix/commit/9b2e5c5d389e4a7f2b587ae1fdf7a46143993f21) command: navigate nixpkgs by attribute name + + +## Installation + +### Plugin managers + +As of version 8.0 Vim supports packages. Clone this repository inside `~/.vim/pack/all/start`: + +```bash +git clone https://github.com/LnL7/vim-nix.git ~/.vim/pack/all/start/vim-nix +``` + +The most common plugin managers include [vim-plug][vim-plug], +[NeoBundle][neobundle], [Vundle][vundle] and [pathogen.vim][pathogen]. + +With pathogen.vim, just clone this repository inside `~/.vim/bundle`: + +```bash +git clone https://github.com/LnL7/vim-nix.git ~/.vim/bundle/vim-nix +``` + +With the other plugin managers, just follow the instructions on the homepage of +each plugin. In general, you have to add a line to your `~/.vimrc`: + +```viml +" vim-plug +Plug 'LnL7/vim-nix' +" NeoBundle +NeoBundle 'LnL7/vim-nix' +" Vundle +Plugin 'LnL7/vim-nix' +``` + +### Manual installation + +Copy the contents of each directory in the respective directories inside +`~/.vim`. + + +[vim-plug]: https://github.com/junegunn/vim-plug +[vundle]: https://github.com/gmarik/Vundle.vim +[neobundle]: https://github.com/Shougo/neobundle.vim +[pathogen]: https://github.com/tpope/vim-pathogen diff --git a/etc/soft/nvim/+plugins/vim-nix/compiler/nix-build.vim b/etc/soft/nvim/+plugins/vim-nix/compiler/nix-build.vim new file mode 100644 index 0000000..5c04ad5 --- /dev/null +++ b/etc/soft/nvim/+plugins/vim-nix/compiler/nix-build.vim @@ -0,0 +1,11 @@ +if exists('current_compiler') + finish +endif +let current_compiler = 'nix-build' + +if exists(":CompilerSet") != 2 + command -nargs=* CompilerSet setlocal +endif + +CompilerSet errorformat=error:\ %m\ at\ %f:%l:%c,builder\ for\ \'%m\'\ failed\ with\ exit\ code\ %n,fixed-output\ derivation\ produced\ path\ \'%s\'\ with\ %m +CompilerSet makeprg=nix-build diff --git a/etc/soft/nvim/+plugins/vim-nix/default.nix b/etc/soft/nvim/+plugins/vim-nix/default.nix new file mode 100644 index 0000000..190972b --- /dev/null +++ b/etc/soft/nvim/+plugins/vim-nix/default.nix @@ -0,0 +1,58 @@ +{ pkgs ? import {} }: + +let + inherit (pkgs) stdenv fetchFromGitHub writeText runCommand vim; + + # Fallback for nix 1.11 + fetchGit = builtins.fetchGit or (x: x); + + vader = fetchFromGitHub { + owner = "junegunn"; + repo = "vader.vim"; + rev = "ddb714246535e814ddd7c62b86ca07ffbec8a0af"; + sha256 = "0jlxbp883y84nal5p55fxg7a3wqh3zny9dhsvfjajrzvazmiz44n"; + }; +in + +stdenv.mkDerivation rec { + name = "vim-nix-${version}${versionSuffix}"; + version = "0.1.0"; + versionSuffix = "pre${toString src.revCount or 0}.${src.shortRev or "0000000"}"; + src = fetchGit ./.; + + dontBuild = true; + preferLocalBuild = true; + + buildInputs = [ vim ]; + + installPhase = '' + mkdir -p $out + cp -r ftdetect ftplugin indent syntax $out + ''; + + vimrc = writeText "vimrc" '' + filetype off + set rtp+=${vader} + set rtp+=${src} + filetype plugin indent on + syntax enable + + function! Syntax() + echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') + endfunction + + command! Syntax call Syntax() + ''; + + checkPhase = '' + ( vim -XNu ${vimrc} -i NONE -c 'Vader! test/*.vader' ) |& tee vim-nix-test.log >&2 + ''; + + doCheck = true; + + shellHook = '' + vim() { + command vim -XNu ${vimrc} -i NONE "$@" + } + ''; +} diff --git a/etc/soft/nvim/+plugins/vim-nix/ftdetect/nix.vim b/etc/soft/nvim/+plugins/vim-nix/ftdetect/nix.vim new file mode 100644 index 0000000..43c429a --- /dev/null +++ b/etc/soft/nvim/+plugins/vim-nix/ftdetect/nix.vim @@ -0,0 +1,6 @@ +" Vim filetype detect +" Language: Nix +" Maintainer: Daiderd Jordan +" URL: https://github.com/LnL7/vim-nix + +au BufRead,BufNewFile *.nix setf nix diff --git a/etc/soft/nvim/+plugins/vim-nix/ftplugin/nix.vim b/etc/soft/nvim/+plugins/vim-nix/ftplugin/nix.vim new file mode 100644 index 0000000..2ea7c88 --- /dev/null +++ b/etc/soft/nvim/+plugins/vim-nix/ftplugin/nix.vim @@ -0,0 +1,21 @@ +" Vim filetype plugin +" Language: Nix +" Maintainer: Daiderd Jordan +" URL: https://github.com/LnL7/vim-nix + +if (exists("b:did_ftplugin")) + finish +endif +let b:did_ftplugin = 1 + +setlocal + \ comments=:# + \ commentstring=#\ %s + \ iskeyword+=- + +if get(g:, 'nix_recommended_style', 1) + setlocal + \ shiftwidth=2 + \ softtabstop=2 + \ expandtab +endif diff --git a/etc/soft/nvim/+plugins/vim-nix/indent/nix.vim b/etc/soft/nvim/+plugins/vim-nix/indent/nix.vim new file mode 100644 index 0000000..450989f --- /dev/null +++ b/etc/soft/nvim/+plugins/vim-nix/indent/nix.vim @@ -0,0 +1,103 @@ +" Vim indent file +" Language: Nix +" Maintainer: Daiderd Jordan +" URL: https://github.com/LnL7/vim-nix + +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal indentexpr=GetNixIndent() +setlocal indentkeys+=0=then,0=else,0=inherit,0=in,* + +if exists("*GetNixIndent") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +let s:skip_syntax = '\%(Comment\|String\)$' +let s:binding_open = '\%(\\)' +let s:binding_close = '\%(\\)' +let s:block_open = '\%({\|[\)' +let s:block_close = '\%(}\|]\)' + +function! GetNixIndent() + let lnum = prevnonblank(v:lnum - 1) + let ind = indent(lnum) + + " At the start of the file use zero indent. + if lnum == 0 + return 0 + endif + + " Skip indentation for single line comments explicitly, in case a + " comment was just inserted (eg. visual block mode) + if getline(v:lnum) =~ '^\s*#' + return indent(v:lnum) + endif + + if synIDattr(synID(v:lnum, 1, 1), "name") !~ s:skip_syntax + let current_line = getline(v:lnum) + let last_line = getline(lnum) + + if current_line =~ '^\s*in\>' + let save_cursor = getcurpos() + normal ^ + let bslnum = searchpair(s:binding_open, '', s:binding_close, 'bnW', + \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "StringSpecial$"') + call setpos('.', save_cursor) + return indent(bslnum) + endif + + if last_line =~ s:block_open . '\s*$' + let ind += &sw + endif + + if current_line =~ '^\s*' . s:block_close + let ind -= &sw + endif + + if last_line =~ '[(=]$' + let ind += &sw + endif + + if last_line =~ '\' + let ind -= &sw + endif + endif + + if synIDattr(synID(v:lnum, 1, 1), "name") =~ '^nixString' + let current_line = getline(v:lnum) + + let ind = indent(v:lnum) + let bslnum = searchpair('''''', '', '''''', 'bnW', + \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? "StringSpecial$"') + + if ind <= indent(bslnum) + let ind = indent(bslnum) + &sw + endif + + if current_line =~ '^\s*''''[^''\$]' + let ind = indent(bslnum) + endif + if current_line =~ '^\s*''''$' + let ind = indent(bslnum) + endif + endif + + return ind +endfunction + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/etc/soft/nvim/+plugins/vim-nix/plugin/nix.vim b/etc/soft/nvim/+plugins/vim-nix/plugin/nix.vim new file mode 100644 index 0000000..87330b1 --- /dev/null +++ b/etc/soft/nvim/+plugins/vim-nix/plugin/nix.vim @@ -0,0 +1,25 @@ +function! nix#find_drv_position() + let line = search("description") + if line == 0 + let line = search("name") + endif + if line == 0 + echo "error: could not find derivation" + return + endif + + return expand("%") . ":" . line +endfunction + +function! nix#edit(attr) + let output = system("nix-instantiate --eval ./. -A " . a:attr . ".meta.position") + if match(output, "^error:") == -1 + let position = split(split(output, '"')[0], ":") + execute "edit " . position[0] + execute position[1] + " Update default command to nix-build. + let b:dispatch = 'nix-build --no-out-link -A ' . a:attr + endif +endfunction + +command! -bang -nargs=* NixEdit call nix#edit() diff --git a/etc/soft/nvim/+plugins/vim-nix/syntax/nix.vim b/etc/soft/nvim/+plugins/vim-nix/syntax/nix.vim new file mode 100644 index 0000000..3414e1c --- /dev/null +++ b/etc/soft/nvim/+plugins/vim-nix/syntax/nix.vim @@ -0,0 +1,198 @@ +" Vim syntax file +" Language: Nix +" Maintainer: Daiderd Jordan +" URL: https://github.com/LnL7/vim-nix + +if exists("b:current_syntax") + finish +endif + +syn keyword nixBoolean true false +syn keyword nixNull null +syn keyword nixRecKeyword rec + +syn keyword nixOperator or +syn match nixOperator '!=\|!' +syn match nixOperator '<=\?' +syn match nixOperator '>=\?' +syn match nixOperator '&&' +syn match nixOperator '//\=' +syn match nixOperator '==' +syn match nixOperator '?' +syn match nixOperator '||' +syn match nixOperator '++\=' +syn match nixOperator '-' +syn match nixOperator '\*' +syn match nixOperator '->' + +syn match nixParen '[()]' +syn match nixInteger '\d\+' + +syn keyword nixTodo FIXME NOTE TODO OPTIMIZE XXX HACK contained +syn match nixComment '#.*' contains=nixTodo,@Spell +syn region nixComment start=+/\*+ end=+\*/+ contains=nixTodo,@Spell + +syn region nixInterpolation matchgroup=nixInterpolationDelimiter start="\${" end="}" contained contains=@nixExpr,nixInterpolationParam + +syn match nixSimpleStringSpecial /\\\%([nrt"\\$]\|$\)/ contained +syn match nixStringSpecial /''['$]/ contained +syn match nixStringSpecial /\$\$/ contained +syn match nixStringSpecial /''\\[nrt]/ contained + +syn match nixInvalidSimpleStringEscape /\\[^nrt"\\$]/ contained +syn match nixInvalidStringEscape /''\\[^nrt]/ contained + +syn region nixSimpleString matchgroup=nixStringDelimiter start=+"+ skip=+\\"+ end=+"+ contains=nixInterpolation,nixSimpleStringSpecial,nixInvalidSimpleStringEscape +syn region nixString matchgroup=nixStringDelimiter start=+''+ skip=+''['$\\]+ end=+''+ contains=nixInterpolation,nixStringSpecial,nixInvalidStringEscape + +syn match nixFunctionCall "[a-zA-Z_][a-zA-Z0-9_'-]*" + +syn match nixPath "[a-zA-Z0-9._+-]*\%(/[a-zA-Z0-9._+-]\+\)\+" +syn match nixHomePath "\~\%(/[a-zA-Z0-9._+-]\+\)\+" +syn match nixSearchPath "[a-zA-Z0-9._+-]\+\%(\/[a-zA-Z0-9._+-]\+\)*" contained +syn match nixPathDelimiter "[<>]" contained +syn match nixSearchPathRef "<[a-zA-Z0-9._+-]\+\%(\/[a-zA-Z0-9._+-]\+\)*>" contains=nixSearchPath,nixPathDelimiter +syn match nixURI "[a-zA-Z][a-zA-Z0-9.+-]*:[a-zA-Z0-9%/?:@&=$,_.!~*'+-]\+" + +syn match nixAttributeDot "\." contained +syn match nixAttribute "[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%([^a-zA-Z0-9_'.-]\|$\)" contained +syn region nixAttributeAssignment start="=" end="\ze;" contained contains=@nixExpr +syn region nixAttributeDefinition start=/\ze[a-zA-Z_"$]/ end=";" contained contains=nixComment,nixAttribute,nixInterpolation,nixSimpleString,nixAttributeDot,nixAttributeAssignment + +syn region nixInheritAttributeScope start="(" end=")" contained contains=nixComment,nixAttributeDot +syn region nixAttributeDefinition matchgroup=nixInherit start="\" end=";" contained contains=nixComment,nixInheritAttributeScope,nixAttribute + +syn region nixAttributeSet start="{" end="}" contains=nixComment,nixAttributeDefinition + +" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +syn region nixArgumentDefinitionWithDefault matchgroup=nixArgumentDefinition start="[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*?\@=" matchgroup=NONE end="[,}]\@=" transparent contained contains=@nixExpr +" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +syn match nixArgumentDefinition "[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*[,}]\@=" contained +syn match nixArgumentEllipsis "\.\.\." contained +syn match nixArgumentSeparator "," contained + +" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +syn match nixArgOperator '@\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*[a-zA-Z_][a-zA-Z0-9_'-]*\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*:'he=s+1 contained contains=nixAttribute + +" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +syn match nixArgOperator '[a-zA-Z_][a-zA-Z0-9_'-]*\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*@'hs=e-1 contains=nixAttribute nextgroup=nixFunctionArgument + +" This is a bit more complicated, because function arguments can be passed in a +" very similar form on how attribute sets are defined and two regions with the +" same start patterns will shadow each other. Instead of a region we could use a +" match on {\_.\{-\}}, which unfortunately doesn't take nesting into account. +" +" So what we do instead is that we look forward until we are sure that it's a +" function argument. Unfortunately, we need to catch comments and both vertical +" and horizontal white space, which the following regex should hopefully do: +" +" "\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*" +" +" It is also used throught the whole file and is marked with 'v's as well. +" +" Fortunately the matching rules for function arguments are much simpler than +" for real attribute sets, because we can stop when we hit the first ellipsis or +" default value operator, but we also need to paste the "whitespace & comments +" eating" regex all over the place (marked with 'v's): +" +" Region match 1: { foo ? ... } or { foo, ... } or { ... } (ellipsis) +" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv {----- identifier -----}vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +syn region nixFunctionArgument start="{\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*\%([a-zA-Z_][a-zA-Z0-9_'-]*\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*[,?}]\|\.\.\.\)" end="}" contains=nixComment,nixArgumentDefinitionWithDefault,nixArgumentDefinition,nixArgumentEllipsis,nixArgumentSeparator nextgroup=nixArgOperator + +" Now it gets more tricky, because we need to look forward for the colon, but +" there could be something like "{}@foo:", even though it's highly unlikely. +" +" Region match 2: {} +" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv@vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv{----- identifier -----} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +syn region nixFunctionArgument start="{\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*}\%(\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*@\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*[a-zA-Z_][a-zA-Z0-9_'-]*\)\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*:" end="}" contains=nixComment nextgroup=nixArgOperator + +" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +syn match nixSimpleFunctionArgument "[a-zA-Z_][a-zA-Z0-9_'-]*\ze\%(\s\|#.\{-\}\n\|\n\|/\*\_.\{-\}\*/\)*:\([\n ]\)\@=" + +syn region nixList matchgroup=nixListBracket start="\[" end="\]" contains=@nixExpr + +syn region nixLetExpr matchgroup=nixLetExprKeyword start="\" end="\" contains=nixComment,nixAttributeDefinition + +syn keyword nixIfExprKeyword then contained +syn region nixIfExpr matchgroup=nixIfExprKeyword start="\" end="\" contains=@nixExpr,nixIfExprKeyword + +syn region nixWithExpr matchgroup=nixWithExprKeyword start="\" matchgroup=NONE end=";" contains=@nixExpr + +syn region nixAssertExpr matchgroup=nixAssertKeyword start="\" matchgroup=NONE end=";" contains=@nixExpr + +syn cluster nixExpr contains=nixBoolean,nixNull,nixOperator,nixParen,nixInteger,nixRecKeyword,nixConditional,nixBuiltin,nixSimpleBuiltin,nixComment,nixFunctionCall,nixFunctionArgument,nixArgOperator,nixSimpleFunctionArgument,nixPath,nixHomePath,nixSearchPathRef,nixURI,nixAttributeSet,nixList,nixSimpleString,nixString,nixLetExpr,nixIfExpr,nixWithExpr,nixAssertExpr,nixInterpolation + +" These definitions override @nixExpr and have to come afterwards: + +syn match nixInterpolationParam "[a-zA-Z_][a-zA-Z0-9_'-]*\%(\.[a-zA-Z_][a-zA-Z0-9_'-]*\)*" contained + +" Non-namespaced Nix builtins as of version 2.0: +syn keyword nixSimpleBuiltin + \ abort baseNameOf derivation derivationStrict dirOf fetchGit + \ fetchMercurial fetchTarball import isNull map placeholder removeAttrs + \ scopedImport throw toString + + +" Namespaced and non-namespaced Nix builtins as of version 2.0: +syn keyword nixNamespacedBuiltin contained + \ abort add addErrorContext all any attrNames attrValues baseNameOf + \ catAttrs compareVersions concatLists concatStringsSep currentSystem + \ currentTime deepSeq derivation derivationStrict dirOf div elem elemAt + \ fetchGit fetchMercurial fetchTarball fetchurl filter \ filterSource + \ findFile foldl' fromJSON functionArgs genList \ genericClosure getAttr + \ getEnv hasAttr hasContext hashString head import intersectAttrs isAttrs + \ isBool isFloat isFunction isInt isList isNull isString langVersion + \ length lessThan listToAttrs map match mul nixPath nixVersion + \ parseDrvName partition path pathExists placeholder readDir readFile + \ removeAttrs replaceStrings scopedImport seq sort split splitVersion + \ storeDir storePath stringLength sub substring tail throw toFile toJSON + \ toPath toString toXML trace tryEval typeOf unsafeDiscardOutputDependency + \ unsafeDiscardStringContext unsafeGetAttrPos valueSize fromTOML bitAnd + \ bitOr bitXor + +syn match nixBuiltin "builtins\.[a-zA-Z']\+"he=s+9 contains=nixComment,nixNamespacedBuiltin + +hi def link nixArgOperator Operator +hi def link nixArgumentDefinition Identifier +hi def link nixArgumentEllipsis Operator +hi def link nixAssertKeyword Keyword +hi def link nixAttribute Identifier +hi def link nixAttributeDot Operator +hi def link nixBoolean Boolean +hi def link nixBuiltin Special +hi def link nixComment Comment +hi def link nixConditional Conditional +hi def link nixHomePath Include +hi def link nixIfExprKeyword Keyword +hi def link nixInherit Keyword +hi def link nixInteger Integer +hi def link nixInterpolation Macro +hi def link nixInterpolationDelimiter Delimiter +hi def link nixInterpolationParam Macro +hi def link nixInvalidSimpleStringEscape Error +hi def link nixInvalidStringEscape Error +hi def link nixLetExprKeyword Keyword +hi def link nixNamespacedBuiltin Special +hi def link nixNull Constant +hi def link nixOperator Operator +hi def link nixPath Include +hi def link nixPathDelimiter Delimiter +hi def link nixRecKeyword Keyword +hi def link nixSearchPath Include +hi def link nixSimpleBuiltin Keyword +hi def link nixSimpleFunctionArgument Identifier +hi def link nixSimpleString String +hi def link nixSimpleStringSpecial SpecialChar +hi def link nixString String +hi def link nixStringDelimiter Delimiter +hi def link nixStringSpecial Special +hi def link nixTodo Todo +hi def link nixURI Include +hi def link nixWithExprKeyword Keyword + +" This could lead up to slow syntax highlighting for large files, but usually +" large files such as all-packages.nix are one large attribute set, so if we'd +" use sync patterns we'd have to go back to the start of the file anyway +syn sync fromstart + +let b:current_syntax = "nix" diff --git a/etc/soft/nvim/+plugins/vim-nix/test/nix.vader b/etc/soft/nvim/+plugins/vim-nix/test/nix.vader new file mode 100644 index 0000000..f5795df --- /dev/null +++ b/etc/soft/nvim/+plugins/vim-nix/test/nix.vader @@ -0,0 +1,547 @@ +Given nix (attribute): + { + foo = pkgs.callPackage ./examples/foo {}; + } + +Do (reindent): + vip= + +Expect (indentation): +~~~~~~~ + { + foo = pkgs.callPackage ./examples/foo {}; + } +~~~~~~~ + +Execute (syntax): + AssertEqual SyntaxOf('foo'), 'nixAttribute' + +Given nix (attribute-assignment): + { + foo = rec { }; + } + +Execute (syntax): + AssertEqual SyntaxOf('foo'), 'nixAttribute' + AssertEqual SyntaxOf('rec'), 'nixRecKeyword' + +Given nix (attribute-path): + { + foo.bar.baz = 2; + } + +Execute (syntax): + AssertNotEqual SyntaxOf('foo'), 'nixAttribute' + AssertNotEqual SyntaxOf('bar'), 'nixAttribute' + AssertEqual SyntaxOf('\.'), 'nixAttributeDot' + AssertEqual SyntaxOf('baz'), 'nixAttribute' + AssertEqual SyntaxOf('2'), 'nixInteger' + +Given nix (attribute-nested): + { + a = { + b = { + c = "2}"; + }; + }; + } + +Do (reindent): + vip= + +Expect (indentation): +~~~~~~~ + { + a = { + b = { + c = "2}"; + }; + }; + } + +Execute (syntax): + AssertEqual SyntaxOf('a'), 'nixAttribute' + AssertEqual SyntaxOf('b'), 'nixAttribute' + AssertEqual SyntaxOf('c'), 'nixAttribute' + AssertEqual SyntaxOf('2}'), 'nixSimpleString' + +Given nix (attribute-nested-insert-indentation): +Do (insert): + i{\a = {\b = {\c = "2}";\};\};\}\ + +Expect (indentation): +~~~~~~~ + { + a = { + b = { + c = "2}"; + }; + }; + } + +Given nix (attribute-inherit): + { + inherit (a.b.c) foo; + inherit bar baz; + } + +Execute (syntax): + AssertNotEqual SyntaxOf('c'), 'nixAttribute' + AssertEqual SyntaxOf('inherit'), 'nixInherit' + AssertEqual SyntaxOf('('), 'nixInheritAttributeScope' + AssertEqual SyntaxOf(')'), 'nixInheritAttributeScope' + AssertEqual SyntaxOf('\.'), 'nixAttributeDot' + AssertEqual SyntaxOf('foo'), 'nixAttribute' + AssertEqual SyntaxOf('bar'), 'nixAttribute' + AssertEqual SyntaxOf('baz'), 'nixAttribute' + +Given nix (attribute-lookup): + { + foo = attrs."foo.foo"; + bar = attrs."${foo.bar}"; + baz = attrs.${foo.baz}; + } + +Execute (syntax): + AssertEqual SyntaxOf('foo'), 'nixAttribute' + AssertEqual SyntaxOf('foo.foo'), 'nixSimpleString' + AssertEqual SyntaxOf('bar'), 'nixAttribute' + AssertEqual SyntaxOf('${'), 'nixInterpolationDelimiter' + AssertEqual SyntaxOf('}'), 'nixInterpolationDelimiter' + AssertEqual SyntaxOf('foo.bar'), 'nixInterpolationParam' + AssertEqual SyntaxOf('baz'), 'nixAttribute' + AssertEqual SyntaxOf('${'), 'nixInterpolationDelimiter' + AssertEqual SyntaxOf('}'), 'nixInterpolationDelimiter' + AssertEqual SyntaxOf('foo.baz'), 'nixInterpolationParam' + +Given nix (list): + { + foo = [ + a + b + ]; + } + +Do (reindent): + vip= + +Expect (indentation): +~~~~~~~ + { + foo = [ + a + b + ]; + } +~~~~~~~ + +Execute (syntax): + AssertEqual SyntaxOf('foo'), 'nixAttribute' + AssertEqual SyntaxOf('a'), 'nixFunctionCall' + AssertEqual SyntaxOf('b'), 'nixFunctionCall' + +Given nix (string): + "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz" + +Execute (syntax): + AssertEqual SyntaxOf('"'), 'nixStringDelimiter' + AssertEqual SyntaxOf('https'), 'nixSimpleString' + AssertEqual SyntaxOf('${'), 'nixInterpolationDelimiter' + AssertEqual SyntaxOf('}'), 'nixInterpolationDelimiter' + AssertEqual SyntaxOf('owner'), 'nixInterpolationParam' + AssertEqual SyntaxOf('repo'), 'nixInterpolationParam' + AssertEqual SyntaxOf('rev'), 'nixInterpolationParam' + +Given nix (multiline-string): + '' + line1 ${ref1} + ${ref2} line2 + line3 ${ref3} + '' + +Execute (syntax): + AssertEqual SyntaxOf('line1'), 'nixString' + AssertEqual SyntaxOf('line2'), 'nixString' + AssertEqual SyntaxOf('line3'), 'nixString' + AssertEqual SyntaxOf('ref1'), 'nixInterpolationParam' + AssertEqual SyntaxOf('ref2'), 'nixInterpolationParam' + AssertEqual SyntaxOf('ref3'), 'nixInterpolationParam' + +Given nix (multiline-string): + '' + foo + ''${bar} + ''' + baz + '' + +Do (reindent): + vip= + +Expect (indentation): +~~~~~~~ + '' + foo + ''${bar} + ''' + baz + '' +~~~~~~~ + +Given nix (url): + https://github.com/LnL7/vim-nix + +Execute (syntax): + AssertEqual SyntaxOf('https'), 'nixURI' + AssertEqual SyntaxOf('github'), 'nixURI' + AssertEqual SyntaxOf('nix'), 'nixURI' + +Given nix (nix-search-path): + assert ; + +Execute (syntax): + AssertEqual SyntaxOf('<'), 'nixPathDelimiter' + AssertEqual SyntaxOf('foo'), 'nixSearchPath' + AssertEqual SyntaxOf('-'), 'nixSearchPath' + AssertEqual SyntaxOf('bar'), 'nixSearchPath' + AssertEqual SyntaxOf('/'), 'nixSearchPath' + AssertEqual SyntaxOf('\.'), 'nixSearchPath' + AssertEqual SyntaxOf('>'), 'nixPathDelimiter' + +Given nix (nix-paths): + [ ~/homefile ./. /etc/passwd ] + +Execute (syntax): + AssertEqual SyntaxOf('\~/homefile'), 'nixHomePath' + AssertEqual SyntaxOf('\./\.'), 'nixPath' + AssertEqual SyntaxOf('/etc/passwd'), 'nixPath' + +Given nix (let): + let + foo = true; + bar = false; + in { + result = foo && bar; + } + +Do (reindent): + vip= + +Expect (indentation): +~~~~~~~ + let + foo = true; + bar = false; + in { + result = foo && bar; + } +~~~~~~~ + +Given nix (let-in-whitespace): + let + + foo = true; + bar = false; + + in + + { + result = foo && bar; + } + +Do (reindent): + vip= + +Expect (indentation): +~~~~~~~ + let + + foo = true; + bar = false; + + in + + { + result = foo && bar; + } +~~~~~~~ + +Execute (syntax): + AssertEqual SyntaxOf('let'), 'nixLetExprKeyword' + AssertEqual SyntaxOf('in'), 'nixLetExprKeyword' + AssertEqual SyntaxOf('foo'), 'nixAttribute' + AssertEqual SyntaxOf('bar'), 'nixAttribute' + AssertEqual SyntaxOf('result'), 'nixAttribute' + AssertEqual SyntaxOf('&&'), 'nixOperator' + +Given nix (let-multiline-binding): + let + result = + foo && bar; + in + result + +Do (reindent): + vip= + +Expect (indentation): +~~~~~~~ + let + result = + foo && bar; + in + result +~~~~~~~ + +Given nix (let-multiline-binding-insert-indentation): +Do (insert): + ilet\result =\foo && bar;\in\result\ + +Expect (indentation): +~~~~~~~ + let + result = + foo && bar; + in + result +~~~~~~~ + +Given nix (let-inherit-insert-indentation): +Do (insert): + ilet\inherit (attr) foo;\in\foo\ + +Expect (indentation): +~~~~~~~ + let + inherit (attr) foo; + in + foo +~~~~~~~ + +Given nix (let-in-indent-sameline): +Do (let-in-indent-sameline): + ilet\foo = 111;\in foo\ + +Expect (indentation): +~~~~~~~ + let + foo = 111; + in foo +~~~~~~~ + +Given nix (builtins): + builtins.doesntexist (builtins.map id [ + hashString (builtins.fetchurl (toString "abort")) + ]) + +Execute (syntax): + AssertNotEqual SyntaxOf('doesntexist'), 'nixBuiltin' + AssertEqual SyntaxOf('map'), 'nixNamespacedBuiltin' + AssertNotEqual SyntaxOf('hashString'), 'nixBuiltin' + AssertNotEqual SyntaxOf('hashString'), 'nixNamespacedBuiltin' + AssertEqual SyntaxOf('builtins'), 'nixBuiltin' + AssertEqual SyntaxOf('\.'), 'nixBuiltin' + AssertEqual SyntaxOf('fetchurl'), 'nixNamespacedBuiltin' + AssertEqual SyntaxOf('toString'), 'nixSimpleBuiltin' + AssertEqual SyntaxOf('abort'), 'nixSimpleString' + +Given nix (simple-string-escape): + "foo\nbar\"end\${xxx}" + +Execute (syntax): + AssertEqual SyntaxAt(1, 1), 'nixStringDelimiter' + AssertEqual SyntaxOf('foo'), 'nixSimpleString' + AssertEqual SyntaxOf('\\n'), 'nixSimpleStringSpecial' + AssertEqual SyntaxOf('bar'), 'nixSimpleString' + AssertEqual SyntaxOf('\\"'), 'nixSimpleStringSpecial' + AssertEqual SyntaxOf('end'), 'nixSimpleString' + AssertEqual SyntaxOf('\$'), 'nixSimpleStringSpecial' + AssertEqual SyntaxOf('{'), 'nixSimpleString' + AssertEqual SyntaxOf('xxx'), 'nixSimpleString' + AssertEqual SyntaxOf('}'), 'nixSimpleString' + AssertEqual SyntaxAt(1, 22), 'nixStringDelimiter' + +Given nix (multiline-string-escape): + '' + foo'''bar''\nend + ''${xxx} + $${foo} + '' + +Execute (syntax): + AssertEqual SyntaxOf('foo'), 'nixString' + AssertEqual SyntaxOf("'''"), 'nixStringSpecial' + AssertEqual SyntaxOf('bar'), 'nixString' + AssertEqual SyntaxOf("''\\\\"), 'nixStringSpecial' + AssertEqual SyntaxOf('end'), 'nixString' + AssertEqual SyntaxOf("''\\$"), 'nixStringSpecial' + AssertEqual SyntaxOf('{'), 'nixString' + AssertEqual SyntaxOf('xxx'), 'nixString' + AssertEqual SyntaxOf('}'), 'nixString' + AssertEqual SyntaxOf('\$\$'), 'nixStringSpecial' + AssertEqual SyntaxOf('{foo}'), 'nixString' + +Given nix (string-escape-errors): + '' + foo''\abar + foo''\nbar + ${"foo\xbar"} + ${"foo\tbar"} + ${"foo \ + bar"} + ${"foo\\bar"} + ${"complex\\\\\f\\bar"} + '' + +Execute (syntax): + AssertEqual SyntaxOf("''\\\\a"), 'nixInvalidStringEscape' + AssertEqual SyntaxOf("''\\\\n"), 'nixStringSpecial' + AssertEqual SyntaxOf("\\\\x"), 'nixInvalidSimpleStringEscape' + AssertEqual SyntaxOf("\\\\t"), 'nixSimpleStringSpecial' + AssertEqual SyntaxOf("\\\\$"), 'nixSimpleStringSpecial' + AssertEqual SyntaxOf("foo\\\\\\zs\\\\"), 'nixSimpleStringSpecial' + AssertEqual SyntaxOf("complex\\zs."), 'nixSimpleStringSpecial' + AssertEqual SyntaxOf("complex.\\zs."), 'nixSimpleStringSpecial' + AssertEqual SyntaxOf("complex..\\zs."), 'nixSimpleStringSpecial' + AssertEqual SyntaxOf("complex.*\\zs.\\zebar"), 'nixSimpleStringSpecial' + AssertEqual SyntaxOf("complex....\\zs."), 'nixInvalidSimpleStringEscape' + +Given nix (lambda-attrs): + { # very descriptive comment + foo + /**/ + ? # another comment + /* yet another comment */ + # default value here: + 1 + , bar ? "xxx" + , yyy + # last comment + , ... + }: { + result = null; + } + +Execute (syntax): + AssertEqual SyntaxOf('very descriptive comment'), 'nixComment' + AssertEqual SyntaxOf('foo'), 'nixArgumentDefinition' + AssertEqual SyntaxOf('?'), 'nixOperator' + AssertEqual SyntaxOf('/\*\*/'), 'nixComment' + AssertEqual SyntaxOf('another comment'), 'nixComment' + AssertEqual SyntaxOf('yet another comment'), 'nixComment' + AssertEqual SyntaxOf('default value here:'), 'nixComment' + AssertEqual SyntaxOf('1'), 'nixInteger' + AssertEqual SyntaxOf('bar'), 'nixArgumentDefinition' + AssertEqual SyntaxOf('xxx'), 'nixSimpleString' + AssertEqual SyntaxOf('yyy'), 'nixArgumentDefinition' + AssertEqual SyntaxOf('last comment'), 'nixComment' + AssertEqual SyntaxOf('\.\.\.'), 'nixArgumentEllipsis' + AssertEqual SyntaxOf('result'), 'nixAttribute' + AssertEqual SyntaxOf('null'), 'nixNull' + +Given nix (ifexpr): + if true then 111 else { a = 222; } + +Execute (syntax): + AssertEqual SyntaxOf('if'), 'nixIfExprKeyword' + AssertEqual SyntaxOf('true'), 'nixBoolean' + AssertEqual SyntaxOf('then'), 'nixIfExprKeyword' + AssertEqual SyntaxOf('111'), 'nixInteger' + AssertEqual SyntaxOf('else'), 'nixIfExprKeyword' + AssertEqual SyntaxOf('a'), 'nixAttribute' + AssertEqual SyntaxOf('222'), 'nixInteger' + +Given nix (multiline-ifexpr): + { + foo = + if true + then 111 + else 222; + } + +Execute (syntax): + AssertEqual SyntaxOf('if'), 'nixIfExprKeyword' + AssertEqual SyntaxOf('then'), 'nixIfExprKeyword' + AssertEqual SyntaxOf('else'), 'nixIfExprKeyword' + +Do (visualblock-coment): + 02jw\2jI# \ + +Expect (indentation): +~~~~~~~ + { + foo = + # if true + # then 111 + # else 222; + } +~~~~~~~ + + +Given nix (with-expr): + with foo; withfoo + +Execute (syntax): + AssertEqual SyntaxOf('with'), 'nixWithExprKeyword' + AssertEqual SyntaxOf('foo'), 'nixFunctionCall' + AssertEqual SyntaxOf('withfoo'), 'nixFunctionCall' + +Given nix (with-newline-let-staircase-bug): +Do (with-newline-let-staircase-bug): + iwith foo;\\let\bar = 111;\in bar\ + +Expect (indentation): +~~~~~~~ + with foo; + + let + bar = 111; + in bar +~~~~~~~ + +Given nix (assert-expr): + assert true -> false; null + +Execute (syntax): + AssertEqual SyntaxOf('assert'), 'nixAssertKeyword' + AssertEqual SyntaxOf('true'), 'nixBoolean' + AssertEqual SyntaxOf('->'), 'nixOperator' + AssertEqual SyntaxOf('false'), 'nixBoolean' + AssertEqual SyntaxOf('null'), 'nixNull' + +Given nix (funarg-let-attrset): + { xxx ? null }@yyy: + + bbb@{ ccc, ... }: + + let foo = 11; in let xxx = 22; in { + bar = foo + zzz; + } + +Execute (syntax): + AssertEqual SyntaxOf('xxx'), 'nixArgumentDefinition' + AssertEqual SyntaxOf('?'), 'nixOperator' + AssertEqual SyntaxOf('null'), 'nixNull' + AssertEqual SyntaxOf('@'), 'nixArgOperator' + AssertEqual SyntaxOf('yyy'), 'nixAttribute' + AssertEqual SyntaxOf('bbb'), 'nixAttribute' + AssertEqual SyntaxOf('ccc'), 'nixArgumentDefinition' + AssertEqual SyntaxOf('let'), 'nixLetExprKeyword' + AssertEqual SyntaxOf('bar'), 'nixAttribute' + +Given nix (searchpath-versus-lt): + { + alwaysTrue = 4 < 5; + alwaysFalse = 4 > 5; + somePath = ; + tailTrue = 4 <= 5; + tailFalse = 4 >= 5; + } + +Execute (syntax): + AssertEqual SyntaxOf('alwaysTrue.*\zs<'), 'nixOperator' + AssertEqual SyntaxOf('alwaysFalse.*\zs>'), 'nixOperator' + AssertEqual SyntaxOf('somePath.*\zs<'), 'nixPathDelimiter' + AssertEqual SyntaxOf('somePath.*\zs>'), 'nixPathDelimiter' + AssertEqual SyntaxOf('tailTrue.*\zs<'), 'nixOperator' + AssertEqual SyntaxOf('tailFalse.*\zs>'), 'nixOperator' diff --git a/etc/soft/nvim/+plugins/vim-nix/test/run-tests.sh b/etc/soft/nvim/+plugins/vim-nix/test/run-tests.sh new file mode 100755 index 0000000..c68c905 --- /dev/null +++ b/etc/soft/nvim/+plugins/vim-nix/test/run-tests.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +cd "$( dirname "${BASH_SOURCE[0]}" )" && vim -Nu vimrc -c 'Vader! *' diff --git a/etc/soft/nvim/+plugins/vim-nix/test/vimrc b/etc/soft/nvim/+plugins/vim-nix/test/vimrc new file mode 100644 index 0000000..3fdd6ea --- /dev/null +++ b/etc/soft/nvim/+plugins/vim-nix/test/vimrc @@ -0,0 +1,5 @@ +filetype off +set rtp+=../vader.vim +set rtp+=../ +filetype plugin indent on +syntax enable diff --git a/etc/soft/nvim/ftdetect/detect.vim b/etc/soft/nvim/ftdetect/detect.vim index 5fb31f6..98e3c31 100644 --- a/etc/soft/nvim/ftdetect/detect.vim +++ b/etc/soft/nvim/ftdetect/detect.vim @@ -26,6 +26,7 @@ au BufRead,BufNewFile Containerfile setlocal au BufRead,BufNewFile Vagrantfile setlocal filetype=ruby au BufRead,BufNewFile bash-fc* setlocal filetype=sh au BufRead,BufNewFile rfc* setlocal filetype=rfc +au BufRead,BufNewFile *.nix setlocal filetype=nix au BufWinEnter,BufRead,BufNewFile *.wiki setlocal nocursorline diff --git a/etc/soft/polybar/config b/etc/soft/polybar/config.linux.carbon similarity index 100% rename from etc/soft/polybar/config rename to etc/soft/polybar/config.linux.carbon diff --git a/etc/soft/polybar/config.linux.coal b/etc/soft/polybar/config.linux.coal new file mode 100644 index 0000000..f2fcfc9 --- /dev/null +++ b/etc/soft/polybar/config.linux.coal @@ -0,0 +1,215 @@ +;========================================================== +; +; +; ██████╗ ██████╗ ██╗ ██╗ ██╗██████╗ █████╗ ██████╗ +; ██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝██╔══██╗██╔══██╗██╔══██╗ +; ██████╔╝██║ ██║██║ ╚████╔╝ ██████╔╝███████║██████╔╝ +; ██╔═══╝ ██║ ██║██║ ╚██╔╝ ██╔══██╗██╔══██║██╔══██╗ +; ██║ ╚██████╔╝███████╗██║ ██████╔╝██║ ██║██║ ██║ +; ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ +; +; +; To learn more about how to configure Polybar +; go to https://github.com/jaagr/polybar +; +; The README contains alot of information +; +;========================================================== + +[colors] +;background = ${xrdb:color0:#222} +background = #D9D9D9 +background-alt = #444 +;foreground = ${xrdb:color7:#222} +foreground = #000000 +foreground-alt = #555 +primary = #ffb52a +secondary = #e60053 +alert = #bd2c40 + +green = #008000 +yellow = #FF8C00 +magenta = #B217B2 +cyan = #00B0B0 + +[global/wm] +margin-bottom = 0 + +[settings] +screenchange-reload = true +;compositing-background = xor +;compositing-background = screen +;compositing-foreground = source +;compositing-border = over + +[bar/main] +wm-name = Bar + +wm-restack = bspwm + +;monitor = ${env:MONITOR:eDP1} +width = 100% +height = 21 +fixed-center = false + +background = ${colors.background} +foreground = ${colors.foreground} + +line-size = 2 + +border-size = 0 +border-color = ${colors.background} + +padding-left = 1 +padding-right = 1 + +module-margin-left = 1 +module-margin-right = 1 + +font-0 = NotoMono Nerd Font:size=12 +font-1 = NotoMono Nerd Font:size=12 +font-2 = NotoMono Nerd Font:size=12 + +modules-left = desktop +modules-center = filesystem +; modules-right = battery xbacklight alsa xkeyboard date +modules-right = battery xbacklight alsa date xkeyboard + +separator = | + +tray-position = right +tray-padding = 2 +;tray-transparent = true +;tray-background = #0063ff + +cursor-click = pointer +cursor-scroll = pointer + +[module/desktop] +;type = internal/xworkspaces +type = internal/bspwm + +pin-workspaces = false +inline-mode = true + +enable-click = true + +fuzy-match = true + +format = " | " + +label-monitor =  + +label-focused-foreground = #B22222 +label-urgent-foreground = ${colors.alert} + +;label-focused-underline = ${colors.alert} +;label-empty-underline = ${colors.alert} + +[module/delimiter] +type = custom/text +content = ] + +[module/xkeyboard] +type = internal/xkeyboard +blacklist-0 = num lock +blacklist-1 = scroll lock + +format = +format-spacing = 0 + +format-prefix = +format-prefix-foreground = ${colors.foreground-alt} +format-prefix-underline = ${colors.secondary} + +label-layout = [ %layout% ] +label-layout-underline = ${colors.secondary} + +[module/filesystem] +type = internal/fs + +mount-0 = / +mount-1 = /mnt/data + +interval = 25 + +fixed-values = true + +label-mounted = %mountpoint%: %{F#bd2c40}%free%%{F-} +label-unmounted = + +[module/date] +type = internal/date +interval = 5 + +time = "%{A1:tcalendar &:} %H:%M%{A}" +date = "%{A1:tcalendar &:} %Y-%m-%d%{A}" + +format-prefix = +format-prefix-foreground = ${colors.foreground-alt} +format-underline = #0a6cf5 + +label = "%time% | %date%" + +[module/alsa] +type = internal/alsa + +format-volume = +label-volume = 墳 %percentage%% +label-volume-foreground = ${root.foreground} +label-volume-underline = ${colors.green} + +ramp-volume-0 = XXX + +format-muted-prefix = "婢 " +format-muted-foreground = ${colors.foreground-alt} +format-muted-underline = ${colors.foreground-alt} +label-muted = %percentage%% + +[module/webcheck] +type = custom/script +label = %output% +label-padding = 1 +format-underline = #0a6cf5 + +interval = 1200 +exec = "webcheck short" + +[module/battery] +type = internal/battery +battery = BAT0 +adapter = ADP1 +full-at = 90 + +format-charging = +format-charging-underline = ${colors.green} + +format-discharging = +format-discharging-underline = ${colors.yellow} + +format-full-prefix = " " +format-full-prefix-foreground = ${colors.green} +format-full-underline = ${colors.green} + +ramp-capacity-0 =  +ramp-capacity-1 =  +ramp-capacity-2 =  +ramp-capacity-foreground = ${colors.yellow} + +animation-charging-0 =  +animation-charging-1 =  +animation-charging-2 =  +animation-charging-foreground = ${colors.green} +animation-charging-framerate = 750 + +[module/xbacklight] +type = internal/backlight +card = intel_backlight + +enable-scroll = true + +label =  %percentage%% + +label-underline = ${colors.cyan} + +; vim:ft=dosini diff --git a/etc/soft/procps/procps b/etc/soft/procps/procps new file mode 120000 index 0000000..8be0b45 --- /dev/null +++ b/etc/soft/procps/procps @@ -0,0 +1 @@ +/home/envrm/.shellrc/etc/soft/procps \ No newline at end of file diff --git a/etc/soft/sxhkd/sxhkdrc b/etc/soft/sxhkd/sxhkdrc index 8adf6f9..59a9ae7 100644 --- a/etc/soft/sxhkd/sxhkdrc +++ b/etc/soft/sxhkd/sxhkdrc @@ -4,7 +4,8 @@ # terminal emulator alt + t - xstab + xst + # xstab # program launcher alt + x diff --git a/etc/soft/sxhkd/sxhkdrc.linux.coal b/etc/soft/sxhkd/sxhkdrc.linux.coal new file mode 100644 index 0000000..b42dcf0 --- /dev/null +++ b/etc/soft/sxhkd/sxhkdrc.linux.coal @@ -0,0 +1,149 @@ +# +# wm independent hotkeys +# + +# {_,ctrl +} {XF86MonBrightnessDown, XF86MonBrightnessUp} +# light -{U,A} {7,3} + +# XF86MonBrightnessDown +# light -U 10 + +# XF86MonBrightnessUp +# light -A 10 + +# ctrl + XF86MonBrightnessDown +# light -U 5 + +# ctrl + XF86MonBrightnessUp +# light -A 5 + +# terminal emulator +alt + t + xstab + +# program launcher +alt + x + dmenu_run + +# alternate between the tiled and monocle layout +alt + o + bspc desktop -l next + +alt + g + calculator + +# focus the node in the given direction +alt + {_,shift + }{h,j,k,l} + bspc node -{f,s} {west,south,north,east} + +# focus the next/previous node in the current desktop +alt + {_,shift + }Tab + bspc node -f {next,prev}.local + +# focus or send to the given desktop +alt + {_,shift + }{1-9,0} + bspc {desktop -f,node -d} '^{1-9,10}' + +# focus or send to the next monitor +alt + Return + bspc monitor -f next + +alt + w + bspc monitor -f next + +# focus the next/previous desktop in the current monitor +alt + {_,shift + }Escape + bspc desktop -f {next,prev}.local + + + + +# make sxhkd reload its configuration files: +#alt + Escape +#pkill -USR1 -x sxhkd + +# focus the node for the given path jump +#super + {p,b,comma,period} +#bspc node -f @{parent,brother,first,second} + +# focus the last node/desktop +# super + {grave,Tab} +# bspc {node,desktop} -f last + +# focus the older or newer node in the focus history +#super + {o,i} +#bspc wm -h off; \ +#bspc node {older,newer} -f; \ +#bspc wm -h on + +# +# preselect +# + +# preselect the direction +#super + ctrl + {h,j,k,l} +#bspc node -p {west,south,north,east} + +# preselect the ratio +#super + ctrl + {1-9} +#bspc node -o 0.{1-9} + +# cancel the preselection for the focused node +#super + ctrl + space +#bspc node -p cancel + +# cancel the preselection for the focused desktop +#super + ctrl + shift + space +#bspc query -N -d | xargs -I id -n 1 bspc node id -p cancel + +# +# move/resize +# + +# expand a window by moving one of its side outward +alt + ctrl + {h,j,k,l} + bspc node -z {left -20 0,bottom 0 20,top 0 -20,right 20 0} + +# contract a window by moving one of its side inward +alt + shift + {h,j,k,l} + bspc node -z {right -20 0,top 0 20,bottom 0 -20,left 20 0} + +# move a floating window +alt + {Left,Down,Up,Right} + bspc node -v {-20 0,0 20,0 -20,20 0} + +# +# bspwm hotkeys +# + +# quit/restart bspwm +#super + alt + {q,r} +#bspc {quit,wm -r} + +# close and kill +#super + {_,shift + }w +#bspc node -{c,k} + +# send the newest marked node to the newest preselected node +#super + y +#bspc node newest.marked.local -n newest.!automatic.local + +# swap the current node and the biggest node +#super + g +#bspc node -s biggest + +# +# state/flags +# + +# set the window state +alt + {_,shift + }s + bspc node -t {floating,tiled} + +#super + {t,shift + t,s,f} +#bspc node -t {tiled,pseudo_tiled,floating,fullscreen} + +# set the node flags +#super + ctrl + {m,x,y,z} +#bspc node -g {marked,locked,sticky,private} + diff --git a/etc/soft/sxiv/sxiv b/etc/soft/sxiv/sxiv new file mode 120000 index 0000000..bfb1dc2 --- /dev/null +++ b/etc/soft/sxiv/sxiv @@ -0,0 +1 @@ +/home/envrm/.shellrc/etc/soft/sxiv \ No newline at end of file diff --git a/etc/soft/vifm/vifm b/etc/soft/vifm/vifm new file mode 120000 index 0000000..9cdcf1b --- /dev/null +++ b/etc/soft/vifm/vifm @@ -0,0 +1 @@ +/home/envrm/.shellrc/etc/soft/vifm \ No newline at end of file diff --git a/etc/wm/bspwm/bspwmrc b/etc/wm/bspwm/bspwmrc.linux.carbon similarity index 100% rename from etc/wm/bspwm/bspwmrc rename to etc/wm/bspwm/bspwmrc.linux.carbon diff --git a/etc/wm/bspwm/bspwmrc.linux.coal b/etc/wm/bspwm/bspwmrc.linux.coal new file mode 100755 index 0000000..b65a5c8 --- /dev/null +++ b/etc/wm/bspwm/bspwmrc.linux.coal @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +export HOST="$PLATFORM.$HOSTNAME" + +sxhkd & +polybar main & +unclutter & + +bspc monitor eDP-1 -d α β γ δ + +bspc config -m eDP-1 top_padding 21 + +bspc config border_width 1 +bspc config window_gap 0 + +bspc config split_ratio 0.50 +bspc config borderless_monocle true +bspc config gapless_monocle true + +bspc rule -a Sxiv state=fullscreen +bspc rule -a Geeqie state=fullscreen +bspc rule -a Zathura state=tiled +bspc rule -a mpv state=fullscreen +bspc rule -a Firefox desktop=^2 follow=on +bspc rule -a Vivaldi-stable desktop=^2 follow=on +bspc rule -a Mptk desktop=^5 follow=off +bspc rule -a Press-n-post state=fullscreen +bspc rule -a Joplin desktop=^4 follow=on +bspc rule -a Tcalendar state=floating follow=on focus=on + +#bspc config external_rules_command ~/bspwm_rules.sh + +bspc config focus_follows_pointer false +bspc config pointer_follows_monitor false + +bspc config normal_border_color "#dddddd" +bspc config focused_border_color "#3f7efc" +#bspc config urgent_border_color "magenta" +#bspc config presel_border_color "magenta" + +xrdb -merge "$SHELLRC/etc/X/Xdefaults.$HOST" +xrdb -merge "$SHELLRC/etc/X/Xdefaults.xst.$HOST" +xrdb -merge "$SHELLRC/etc/X/Xdefaults.colorscheme.light" + +xbindkeys -f "$SHELLRC/etc/X/xbindkeysrc.$HOST" +xkbcomp -I"$SHELLRC/etc/wm/xkb/xkb.$HOST" "$SHELLRC/etc/wm/xkb/xkb.$HOST/keymap/keymap" "$DISPLAY" +display -window root "$SHELLRC/etc/wm/img/wallpaper.$HOST.jpg" +xsetroot -cursor_name left_ptr + +xstab & + diff --git a/etc/wm/img/wallpaper.linux.coal.jpg b/etc/wm/img/wallpaper.linux.coal.jpg new file mode 100644 index 0000000..63ce3e7 Binary files /dev/null and b/etc/wm/img/wallpaper.linux.coal.jpg differ diff --git a/etc/wm/xkb/xkb.linux.coal/keymap/keymap b/etc/wm/xkb/xkb.linux.coal/keymap/keymap new file mode 100644 index 0000000..6430b8c --- /dev/null +++ b/etc/wm/xkb/xkb.linux.coal/keymap/keymap @@ -0,0 +1,7 @@ +xkb_keymap { + xkb_keycodes { include "evdev+aliases(qwerty)" }; + xkb_types { include "complete" }; + xkb_compat { include "complete" }; + xkb_symbols { include "pc+us+ru:2+inet(evdev)+group(lwin_toggle)+capslock(escape)+compose(ralt)+terminate(ctrl_alt_bksp)+meta(bind_print_to_meta)" }; + xkb_geometry { include "pc(pc104)" }; +}; diff --git a/etc/wm/xkb/xkb.linux.coal/symbols/meta b/etc/wm/xkb/xkb.linux.coal/symbols/meta new file mode 100644 index 0000000..c4bcbd8d --- /dev/null +++ b/etc/wm/xkb/xkb.linux.coal/symbols/meta @@ -0,0 +1,5 @@ +partial modifier_keys +xkb_symbols "bind_print_to_meta" { + replace key { [ Meta_L ] }; +}; + diff --git a/etc/installrc.sh b/installrc.sh similarity index 75% rename from etc/installrc.sh rename to installrc.sh index aa1ce68..6522d6d 100755 --- a/etc/installrc.sh +++ b/installrc.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash #Создан: Пт 23 авг 2013 19:57:29 -#Изменён: вт 02 ноя 2021 12:40:46 +#Изменён: Ср 03 ноя 2021 16:16:02 # -# (c) 2013, Maxim Lihachev, +# (c) 2013-2021, Maxim Lihachev, # # Скрипт создания ссылок на файлы настроек. # @@ -26,15 +26,6 @@ # При установке имеющиеся ссылки и файлы будут переименованы в файл.<дата>. # - -#Директория для установки -PLATFORM="$(uname -s | tr 'A-Z' 'a-z')" -HOSTFILE="${PLATFORM}.${HOSTNAME%%.*}" -RCDIR=$(pwd) -RCLIST="${RCDIR}/rc.${HOSTFILE}" - -ROOTDIR=$HOME - #Настройка цветовых кодов rstc="\033[00m" yellow="\033[1;33m" @@ -42,13 +33,28 @@ red="\033[1;31m" green="\033[1;32m" white="\033[1;1m" +SCRIPTPATH="$(dirname $(realpath "$0"))" + +#Директория для установки +PLATFORM="$(uname -s | tr 'A-Z' 'a-z')" +HOSTFILE="${PLATFORM}.${HOSTNAME%%.*}" +RCDIR="${SCRIPTPATH}/etc" + +PROFILES="${SCRIPTPATH}/profiles/" + +if [ -e "${PROFILES}/${HOSTFILE}" ]; then + RCLIST="${PROFILES}/${HOSTFILE}" +else + RCLIST="${PROFILES}/default" + echo -e "${red}Профиль $HOSTFILE не найден. Используется профиль по умолчанию.${rstc}" +fi + +ROOTDIR=$HOME + #Вывод [цветного] сообщения с заполнением строки до 30 колонки знаком "." # msg1 msg2 ?color? report() { - len=$((30 - $(echo -e -n "$2" | wc -m))) - - echo -e -n " ${3:-$rstc} $1 $2 $rstc" - eval printf "%-.s-" {1..$len} + printf " %-60.40s" "$*" } #Проверка доступности файла настроек @@ -56,7 +62,7 @@ report() { check() { report Поиск "$(basename "$1")" - if [ -a "$RCDIR/$1" ]; then + if [ -f "$RCDIR/$1" ]; then echo OK else echo -e "$red ФАЙЛ НАСТРОЕК НЕ СУЩЕСТВУЕТ: $RCDIR/$1 $rstc" >&2 @@ -93,41 +99,49 @@ dotfile() { #Создание ссылки на конфигурационный файл # source destination mklink() { - SRC=$1 + RC=$1 + + #Файл существует? + if [ -a "$RCDIR/${RC}.${HOSTFILE}" ]; then + SRC="${RC}.${HOSTFILE}" + elif [ -a "$RCDIR/${RC}" ]; then + SRC="${RC}" + else + echo -e "$red ФАЙЛ НАСТРОЕК НЕ СУЩЕСТВУЕТ: $RCDIR/$SRC $rstc" >&2 + return 1 + fi + DST=$2 + filename=$(basename "$SRC") + + report Установка "$SRC" + + link=$(dotfile "$DST/${filename//\.${HOSTFILE}}") + + mkdir -p "$(dirname "$link")" + #Файл существует? - if [ -a "$RCDIR/$SRC" ]; then - filename=$(basename "$SRC") - - report Установка "$filename" - - link=$(dotfile "$DST/${filename//\.${HOSTFILE}}") - - #Файл существует? - if [ -a "$link" ]; then - #Файл -- ссылка? - if [ -L "$link" ]; then - ref=$(readlink "$link") - if [ "$ref" == "$RCDIR/$SRC" ]; then - echo -e "Установка не требуется" - return - else - echo -e "$redНайденная ссылка указывает на другой файл: $ref$rstc" - fi + if [ -a "$link" ]; then + #Файл -- ссылка? + if [ -L "$link" ]; then + ref=$(readlink "$link") + if [ "$ref" == "$RCDIR/$SRC" ]; then + echo -e "Установка не требуется" + return else - echo -e "$redНайден конфигурационный файл$rstc" + echo -e "$redНайденная ссылка указывает на другой файл: $ref$rstc" fi - - backup "$link" && \ - mklink "$SRC" "$DST" else - #Ссылка на файл-источник - ln -s "$RCDIR/$SRC" "$(dotfile "$DST/${filename//\.${HOSTFILE}}")" 2>&- && \ - echo -e "${green}OK${rstc}" + echo -e "$redНайден конфигурационный файл$rstc" fi + + backup "$link" && \ + mklink "$SRC" "$DST" else - echo -e "$red ФАЙЛ НАСТРОЕК НЕ СУЩЕСТВУЕТ: $RCDIR/$SRC $rstc" >&2 + #Ссылка на файл-источник + ln -s "$RCDIR/$SRC" "$link" 2>&- && \ + echo -e "${green}OK${rstc}" fi } diff --git a/etc/rc.cygwin.windows b/profiles/cygwin.windows similarity index 100% rename from etc/rc.cygwin.windows rename to profiles/cygwin.windows diff --git a/etc/rc.darwin.macos b/profiles/darwin.silver similarity index 100% rename from etc/rc.darwin.macos rename to profiles/darwin.silver diff --git a/etc/rc.linux.gentoo b/profiles/default similarity index 100% rename from etc/rc.linux.gentoo rename to profiles/default diff --git a/etc/rc.linux.nixos b/profiles/linux.carbon similarity index 100% rename from etc/rc.linux.nixos rename to profiles/linux.carbon diff --git a/profiles/linux.coal b/profiles/linux.coal new file mode 100644 index 0000000..690f13c --- /dev/null +++ b/profiles/linux.coal @@ -0,0 +1,92 @@ +# --------------------------------------------------------------- +# [ GNU/LINUX ] +# --------------------------------------------------------------- + +# [ Shell ] + ++ shell/bash/bash_profile ~ ++ shell/bash/bashrc ~ +- shell/guile/guile ~ +- shell/screen/screenrc ~ ++ shell/hstr/hstr_blacklist ~ + +# [ X.org ] + +- X/Xdefaults ~ ++ X/XCompose ~ ++ X/xinitrc ~ +- wm/fonts/fonts.conf ~ +- wm/gtk/gtkrc-2.0 ~ +- wm/gtk/gtk-bookmarks ~ ++ wm/bspwm/bspwmrc ~/.config/bspwm ++ soft/sxhkd/sxhkdrc ~/.config/sxhkd ++ wm/xdg/user-dirs.dirs ~/.config + +# [ Net ] + ++ net/ssh ~ +- net/rtorrent/rtorrent.rc ~ +- net/lftp/lftprc ~ +- net/snownews ~ +- net/newsboat ~/.config +- mail/mailcap/mailcap ~ +- mail/procmail/procmailrc ~ + +# [ Soft ] + ++ media/ncmpcpp ~ +- media/moc ~ +- media/scmpc ~ +- soft/bar/barrc ~ +- soft/conky/conkyrc ~ +- soft/ctags/ctags ~ ++ soft/nvim ~/.config ++ soft/vifm ~/.config +- soft/vimperator ~ +- soft/vimperator/vimperatorrc ~ ++ soft/git/gitconfig ~ +- soft/git/gitk ~ +- soft/stalonetray/stalonetrayrc ~ +- soft/tmux/tmux.conf ~ +- media/alsa/asoundrc ~ ++ soft/sxiv ~/.config ++ soft/dfc ~/.config ++ soft/polybar/config ~/.config/polybar ++ soft/procps ~/.config +- soft/k9s/config.$(uname -i).yml ~/.k9s +- soft/k9s/skin.$(uname -i).yml ~/.k9s +- soft/htop ~/.config +- soft/mc ~/.config +- soft/vim ~/.config +- soft/vim/vimrc ~ +- soft/dunst/dunstrc ~/.config/dunst +- soft/linters/eslintrc ~ ++ soft/joplin/userchrome.css ~/.config/joplin-desktop/ ++ soft/joplin/userstyle.css ~/.config/joplin-desktop/ + +# [ Dev ] + ++ dev/tcl/tclshrc ~ +- dev/tcl/wishrc ~ ++ dev/terraform/tflint/tflint.hcl ~ + +: --------------------------------------------------------------- + +mkdir -pv ~/{FILES,Downloads} +mkdir -pv ~/FILES/{Projects,Work} + +mkdir -pv bin/{scripts,hub} + +mkdir -pv var/{shell,log,man,mpd,scmpc,vim} +mkdir -pv var/vim/{backup,undo,mru,swp,view,yankring} +#mkdir -pv net/ssh/sessions + +: --------------------------------------------------------------- + +#xdg-mime default zathura.desktop application/pdf +#xdg-mime default gpicview.desktop image/gif +#xdg-mime default gpicview.desktop image/jpg +#xdg-mime default gpicview.desktop image/png + +: --------------------------------------------------------------- +