From e17507adb1c199dfd98ffe2673bf53b22900e706 Mon Sep 17 00:00:00 2001 From: Ian Mancini Date: Sat, 22 Aug 2020 20:41:32 -0300 Subject: [PATCH] Update i3, nvim, env and shell files in template --- template/bash/.bashrc | 2 +- template/{shell => environment}/.aliasrc | 0 template/{shell => environment}/.envrc | 22 +-- template/environment/.pam_environment | 4 + template/i3/.config/i3/config | 73 +++++----- template/nvim/.config/nvim/coc-settings.json | 4 +- template/nvim/.config/nvim/init.vim | 142 ++++++++++++++----- template/zsh/.zshrc | 31 ++-- 8 files changed, 180 insertions(+), 98 deletions(-) rename template/{shell => environment}/.aliasrc (100%) rename template/{shell => environment}/.envrc (82%) create mode 100644 template/environment/.pam_environment diff --git a/template/bash/.bashrc b/template/bash/.bashrc index d6baa11..c558dd4 100755 --- a/template/bash/.bashrc +++ b/template/bash/.bashrc @@ -4,7 +4,7 @@ # load Aliases [ -f "$HOME/.aliasrc" ] && source "$HOME/.aliasrc" -# Load environment +# Load environment [ -f "$HOME/.aliasrc" ] && source "$HOME/.envrc" # Enable bash_completion diff --git a/template/shell/.aliasrc b/template/environment/.aliasrc similarity index 100% rename from template/shell/.aliasrc rename to template/environment/.aliasrc diff --git a/template/shell/.envrc b/template/environment/.envrc similarity index 82% rename from template/shell/.envrc rename to template/environment/.envrc index 5819494..b24d601 100644 --- a/template/shell/.envrc +++ b/template/environment/.envrc @@ -6,7 +6,7 @@ TERMINAL="alacritty" BROWSER="chromium" # bin -export PATH=/home/ianmethyst/.local/bin:$PATH +export PATH=/home/ianmethyst/.bin:/home/ianmethyst/.local/bin:$PATH # Enable colors eval "`dircolors -b`" @@ -18,22 +18,15 @@ export LESS='-R' export LESS_TERMCAP_mb=$'\E[01;31m' export LESS_TERMCAP_md=$'\E[01;33m' export LESS_TERMCAP_me=$'\E[0m' -export LESS_TERMCAP_se=$'\E[0m' +export LESS_TERMCAP_se=$'\E[0m' export LESS_TERMCAP_so=$'\E[01;42;30m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[01;36m' # fzf -export FZF_DEFAULT_COMMAND='ag --hidden -g ""' +export FZF_DEFAULT_COMMAND='ag --hidden --ignore .git -g ""' export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" -# Keychain -if [ -z ${DISPLAY+x} ]; then - eval "$(keychain --eval --quiet --noask --agents gpg,ssh id_rsa)" -else - eval "$(keychain --eval --quiet --agents gpg,ssh id_rsa)" -fi - # fnm export PATH=/home/ianmethyst/.fnm:$PATH eval "`fnm env --multi`" @@ -47,10 +40,17 @@ export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache # pyenv export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" -if command -v pyenv 1>/dev/null 2>&1; then; eval "$(pyenv init -)"; fi +if command -v pyenv 1>/dev/null 2>&1; then eval "$(pyenv init -)"; fi # pipenv export PIPENV_VENV_IN_PROJECT=1 export PIPENV_SKIP_LOCK=true export PIPENV_PYTHON=$PYENV_ROOT/shims/python eval "$(pipenv --completion)" + +# Keychain +if [ -z ${DISPLAY+x} ]; then + eval "$(keychain --eval --quiet --noask --agents gpg,ssh id_rsa)" +else + eval "$(keychain --eval --quiet --agents gpg,ssh id_rsa)" +fi diff --git a/template/environment/.pam_environment b/template/environment/.pam_environment new file mode 100644 index 0000000..aca13fc --- /dev/null +++ b/template/environment/.pam_environment @@ -0,0 +1,4 @@ +XDG_DATA_HOME DEFAULT=@{HOME}/.local/share +XDG_CONFIG_HOME DEFAULT=@{HOME}/.config +XDG_CACHE_HOME DEFAULT=@{HOME}/.cache +XDG_CURRENT_DESKTOP DEFAULT=XFCE diff --git a/template/i3/.config/i3/config b/template/i3/.config/i3/config index 00c1aa6..c34dffb 100755 --- a/template/i3/.config/i3/config +++ b/template/i3/.config/i3/config @@ -2,10 +2,10 @@ # General # ########### -# Using Super instead of alt +# Using Super instead of alt set $mod Mod4 -# Font +# Font font pango: {{FONT}} {{FONTSIZE}} # Titles @@ -30,7 +30,7 @@ set $ws10 "10" # Colors # ########## -set_from_resource $background background {{COLORS.background}} +set_from_resource $background background {{COLORS.background}} set_from_resource $foreground foreground {{COLORS.background}} set_from_resource $lightblack color8 {{COLORS.color8}} @@ -98,7 +98,7 @@ bindsym $mod+Shift+Up move up bindsym $mod+Shift+Right move right # Toggle Split in vertical/horizontal orientation -bindsym $mod+v split toggle +bindsym $mod+v split toggle # Enter fullscreen mode for the focused container bindsym $mod+f fullscreen toggle @@ -124,7 +124,7 @@ bindsym $mod+a focus parent # bindsym $mod+d focus child # Reload the configuration file -bindsym $mod+Shift+c reload +# bindsym $mod+Shift+c reload # Restart i3 inplace (preserves your layout/session, can be used to upgrde i3) bindsym $mod+Shift+r restart @@ -136,21 +136,23 @@ bindsym $mod+shift+x exec betterlockscreen -l dim # Scrot bindsym --release Print exec $HOME/.bin/scrot-screen -bindsym --release Shift+Print exec $HOME/.bin/scrot-area +bindsym --release Shift+Print exec $HOME/.bin/scrot-area -# pcmanfm +# pcmanfm # bindsym $mod+p exec --no-startup-id pcmanfm -n # Chromium bindsym $mod+c exec --no-startup-id chromium # Rofi -bindsym $mod+d exec --no-startup-id rofi -show run -bindsym $mod+Shift+w exec --no-startup-id rofi -show window +bindsym $mod+d exec --no-startup-id rofi -show run +bindsym $mod+Shift+w exec --no-startup-id rofi -show window bindsym $mod+Shift+s exec --no-startup-id rofi -show ssh -bindsym $mod+Shift+e exec --no-startup-id rofimoji +bindsym $mod+Shift+e exec --no-startup-id rofimoji bindsym $mod+Shift+p exec --no-startup-id ~/.bin/rofi-passmenu bindsym $mod+p exec --no-startup-id ~/.bin/rofi-xrandr +bindsym $mod+Shift+c exec --no-startup-id ~/.bin/rofi-project + ############## # Workspaces # @@ -191,19 +193,20 @@ bindsym $mod+Shift+0 move container to workspace number $ws10 assign [class="^Nautilus$"] → $ws1 assign [class="^pcmanfm$"] → $ws1 assign [class="^Pcmanfm$"] → $ws1 +assign [class="^Thunar$"] → $ws1 assign [class="^Firefox$"] → $ws2 assign [class="^Chromium$" window_role="^browser$"] → $ws2 -for_window [class="^Chromium$" window_role="^pop-up$"] floating enable +for_window [class="^Chromium$" window_role="^pop-up$"] floating enable assign [class="^atom$"] → $ws3 assign [class="^Atom$"] → $ws3 assign [class="^sun-awt-X11-XFramePeer$"] → $ws3 assign [class="^Processing$"] → $ws3 -for_window [title="^Welcome to Processing"] floating enable +for_window [title="^Welcome to Processing"] floating enable assign [class="^processing-app-Base$"] → $ws3 -for_window [title="^Java$"] floating enable -for_window [title="^Java$"] move position center +for_window [title="^Java$"] floating enable +for_window [title="^Java$"] move position center assign [class="^discord$"] → $ws4 assign [class="^telegram-desktop$"] → $ws4 @@ -225,15 +228,15 @@ assign [class="^libreoffice-writer$"] → $ws6 assign [class="^Steam$"] → $ws9 assign [title="^Steam$"] → $ws9 -for_window [class="^Unity$"] floating enable +for_window [class="^Unity$"] floating enable for_window [title="^Unity - Unity"] floating disable -for_window [class="^Steam$"] floating enable -for_window [class="^Steam$" title="^Steam$"] floating disable +for_window [class="^Steam$"] floating enable +for_window [class="^Steam$" title="^Steam$"] floating disable -for_window [class="^pavucontrol$"] floating enable -for_window [class="^Pavucontrol$"] floating enable -for_window [class="^arandr$"] floating enable -for_window [class="^Arandr$"] floating enable +for_window [class="^pavucontrol$"] floating enable +for_window [class="^Pavucontrol$"] floating enable +for_window [class="^arandr$"] floating enable +for_window [class="^Arandr$"] floating enable ############# # Autostart # @@ -249,15 +252,15 @@ exec_always --no-startup-id $HOME/.bin/launch-dunst exec xautolock -time 15 -locker "betterlockscreen -l dim" -corners 0-00 -exec pcmanfm -d +exec pcmanfm -d exec discord exec telegram-desktop exec steam exec nm-applet -# exec blueman-applet -# exec pasystray -exec redshift-gtk -exec cbatticon BAT0 -l 25 -r 10 +exec blueman-applet +exec pasystray +exec redshift-gtk +exec cbatticon BAT0 -l 25 -r 10 # exec clipit ######### @@ -314,12 +317,12 @@ exec_always --no-startup-id $HOME/.bin/launch-polybar # Multimedia Keys # ################### -# Volume +# Volume # PulseAudio -bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume 0 +2% #increase sound volume -bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume 0 -2% #decrease sound volume -bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # mute sound +bindsym XF86AudioRaiseVolume exec --no-startup-id $HOME/.bin/manage_volume -i 2 -n +bindsym XF86AudioLowerVolume exec --no-startup-id $HOME/.bin/manage_volume -d 2 -n +bindsym XF86AudioMute exec --no-startup-id $HOME/.bin/manage_volume -t -n # ALSA #bindsym XF86AudioRaiseVolume exec --no-startup-id amixer -D pulse sset Master '2%+' @@ -330,11 +333,11 @@ bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute 0 toggle # mute s bindsym XF86AudioPrev exec mpc prev bindsym XF86AudioNext exec mpc next bindsym XF86AudioPlay exec mpc toggle -bindsym XF86AudioStop exec mpc stop +bindsym XF86AudioStop exec mpc stop # Sreen brightness controls #bindsym XF86MonBrightnessUp exec xbacklight +2 -#bindsym XF86MonBrightnessDown exec xbacklight -2 +#bindsym XF86MonBrightnessDown exec xbacklight -2 bindsym XF86Display exec arandr bindsym XF86TouchpadToggle exec pavucontrol @@ -343,16 +346,16 @@ bindsym XF86TouchpadToggle exec pavucontrol # i3-Gaps # ########### -# Borders +# Borders for_window [class="^.*"] border pixel 3 for_window [class="^Chromium$" window_role="^browser$"] border pixel 0 # Set inner/outer gaps -gaps inner 0 +gaps inner 0 gaps outer 0 # Smart gaps (gaps used if only more than one container on the workspace) # smart_gaps on -# Smart borders (draw borders around container only if it is not the only container on this workspace) +# Smart borders (draw borders around container only if it is not the only container on this workspace) smart_borders on diff --git a/template/nvim/.config/nvim/coc-settings.json b/template/nvim/.config/nvim/coc-settings.json index 4a230e4..9c4b240 100644 --- a/template/nvim/.config/nvim/coc-settings.json +++ b/template/nvim/.config/nvim/coc-settings.json @@ -1,3 +1,5 @@ { - "python.linting.enabled": false + "python.linting.enabled": false, + "eslint.enable": true, + "diagnostic.displayByAle": false } diff --git a/template/nvim/.config/nvim/init.vim b/template/nvim/.config/nvim/init.vim index 055ec8c..cd6caf3 100755 --- a/template/nvim/.config/nvim/init.vim +++ b/template/nvim/.config/nvim/init.vim @@ -14,9 +14,12 @@ Plug 'joshdick/onedark.vim' Plug 'itchyny/lightline.vim' Plug 'daviesjamie/vim-base16-lightline' -Plug 'maximbaz/lightline-ale' +"Plug 'maximbaz/lightline-ale' Plug 'gioele/vim-autoswap' "Requires wmctrl +Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } } + +Plug 'scrooloose/nerdcommenter' Plug 'sheerun/vim-polyglot' Plug 'sirtaj/vim-openscad' @@ -24,10 +27,12 @@ Plug 'othree/yajs.vim' Plug 'othree/es.next.syntax.vim' Plug 'othree/javascript-libraries-syntax.vim' Plug 'styled-components/vim-styled-components', { 'branch': 'main' } +Plug 'hail2u/vim-css3-syntax' Plug 'vim-pandoc/vim-pandoc-syntax' Plug 'Vimjas/vim-python-pep8-indent' Plug 'ntpeters/vim-better-whitespace' +Plug 'rhysd/clever-f.vim' Plug 'junegunn/fzf.vim' Plug 'scrooloose/nerdtree' Plug 'xuyuanp/nerdtree-git-plugin' @@ -40,7 +45,7 @@ Plug 'lervag/vimtex' Plug 'neoclide/coc.nvim', {'branch': 'release'} -Plug 'dense-analysis/ale' +" Plug 'dense-analysis/ale' Plug 'tpope/vim-fugitive' @@ -71,11 +76,15 @@ let g:nord_underline = 1 let g:nord_italic = 1 let g:nord_italic_comments = 0 let g:nord_cursor_line_number_background = 1 -let g:solarized_termcolors= 16 -let g:solarized_bold = 1 -let g:solarized_underline = 1 +let g:solarized_termcolors= 16 +let g:solarized_bold = 1 +let g:solarized_underline = 1 let g:solarized_italic = 1 +" Fix for styled-components +autocmd BufEnter *.{js,jsx,ts,tsx} :syntax sync fromstart +autocmd BufLeave *.{js,jsx,ts,tsx} :syntax sync clear + set termguicolors colorscheme {{VIMCOLORSCHEME}} set background={{VIMBACKGROUND}} @@ -121,7 +130,14 @@ set scrolloff=10 set cmdheight=2 set updatetime=300 set shortmess+=c -set signcolumn=yes + +if has("patch-8.1.1564") + " Recently vim can merge signcolumn and number column into one + set signcolumn=number +else + set signcolumn=yes +endif + set lazyredraw " Redraw only when we need to. set showmatch " Highlight matching [{()}] @@ -146,11 +162,13 @@ set foldopen=block,hor,insert,jump,mark,percent,quickfix,search,tag,undo set mouse=a " Backups -set backup -set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp -set backupskip=/tmp/*,/private/tmp/* -set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp -set writebackup +set directory=$XDG_DATA_HOME/nvim/swap/ +set backupdir=$XDG_DATA_HOME/nvim/backup/ +set backupskip=/tmp/* +set undodir=$XDG_DATA_HOME/nvim/undodir/ +set undofile +set nobackup +set nowritebackup " ########### " # Keymaps # @@ -175,6 +193,17 @@ nnoremap s :mksession " NERD Tree map :NERDTreeToggle +" Nerd commenter +vmap NERDCommenterToggle +nmap NERDCommenterToggle + +let g:NERDSpaceDelims = 1 +let g:NERDDefaultAlign = 'left' +let g:NERDCompactSexyComs = 1 +let g:NERDCommentEmptyLines = 1 +let g:NERDTrimTrailingWhitespace = 1 +let g:NERDToggleCheckAllLines = 1 + " Ale nmap aj :ALENext nmap ak :ALEPrevious @@ -207,16 +236,19 @@ let g:lightline = { \ 'left': [ [ 'mode', 'paste' ], \ [ 'gitbranch', 'readonly', 'filename', 'modified' ], \ [ 'hunksummary' ] ], - \ 'right': [ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_ok' ], + \ 'right': [ [ 'cocstatus' ], \ [ 'percent', 'lineinfo'], \ [ 'fileformat', 'fileencoding', 'filetype'] ] \ }, \ 'component_function': { + \ 'cocstatus': 'coc#status', \ 'gitbranch': 'FugitiveHead', \ 'hunksummary': 'GitStatus' \ }, \} +"'right': [ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_ok' ], + function! GitStatus() let [a,m,r] = GitGutterGetHunkSummary() return printf('+%d ~%d -%d', a, m, r) @@ -241,14 +273,16 @@ let g:ale_linters = { \ 'javascriptreact': ['eslint'], \ 'javascript.jsx': ['eslint'], \ 'vim': ['vint'], - \ 'python': ['flake8'] + \ 'python': ['flake8'], + \ 'json': ['fixjson'] \} -let b:ale_fixers = { +let g:ale_fixers = { \ 'javascript': ['eslint'], \ 'javascriptreact': ['eslint'], \ 'javascript.jsx': ['eslint'], - \ 'python': ['yapf'] + \ 'python': ['yapf'], + \ 'json': ['fixjson'] \} let g:ale_pattern_options = { @@ -256,42 +290,66 @@ let g:ale_pattern_options = { \ '\.min\.css$': {'ale_linters': [], 'ale_fixers': []}, \} - " Coc let g:coc_global_extensions = [ \ 'coc-tsserver', - \ 'coc-json', - \ 'coc-css', + \ 'coc-eslint', + \ 'coc-json', + \ 'coc-css', \ 'coc-html', \ 'coc-snippets', \ 'coc-pairs', \ 'coc-yaml', \ 'coc-highlight', \ 'coc-syntax', - \ 'coc-python' + \ 'coc-python', + \ 'coc-actions', + \ 'coc-vimlsp', + \ 'coc-sh', + \ 'coc-svg' \] " Use tab for trigger completion with characters ahead and navigate. " Use command ':verbose imap ' to make sure tab is not mapped by other plugin. -inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() -inoremap pumvisible() ? "\" : "\" - -function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction + inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() + inoremap pumvisible() ? "\" : "\" + + function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' + endfunction + + " Use for trigger snippet expand. +imap (coc-snippets-expand) + +" Use for select text for visual placeholder of snippet. +vmap (coc-snippets-select) + +" Use for jump to next placeholder, it's default of coc.nvim +let g:coc_snippet_next = '' + +" Use for jump to previous placeholder, it's default of coc.nvim +let g:coc_snippet_prev = '' + +" Use for both expand and jump (make expand higher priority.) +imap (coc-snippets-expand-jump) + +let g:coc_snippet_next = '' " Use to trigger completion. inoremap coc#refresh() -" Use to confirm completion, `u` means break undo chain at current position. -" Coc only does snippet and additional edit on confirm. -inoremap pumvisible() ? "\" : "\u\" -" Or use `complete_info` if your vim support it, like: -" inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" +" Use to confirm completion, `u` means break undo chain at current +" position. Coc only does snippet and additional edit on confirm. +" could be remapped by other vim plugin, try `:verbose imap `. +if exists('*complete_info') + inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" +else + inoremap pumvisible() ? "\" : "\u\" +endif " Use `[g` and `]g` to navigate diagnostics nmap [g (coc-diagnostic-prev) @@ -365,11 +423,13 @@ set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} " Using CocList " Show all diagnostics -nnoremap a :CocList diagnostics +nnoremap d :CocList diagnostics " Manage extensions nnoremap e :CocList extensions " Show commands nnoremap c :CocList commands +" Show actions +nnoremap a :CocList actions " Find symbol of current document nnoremap o :CocList outline " Search workspace symbols @@ -381,5 +441,17 @@ nnoremap k :CocPrev " Resume latest coc list nnoremap p :CocListResume +" coc-actions + +" Remap for do codeAction of selected region +function! s:cocActionsOpenFromSelected(type) abort + execute 'CocCommand actions.open ' . a:type +endfunction +xmap a :execute 'CocCommand actions.open ' . visualmode() +nmap a :set operatorfunc=cocActionsOpenFromSelectedg@ + " vim-rainbow let g:rainbow_active = 1 + +" vimtex +let g:tex_flavor = 'latex' diff --git a/template/zsh/.zshrc b/template/zsh/.zshrc index fa72c1b..6f57e46 100755 --- a/template/zsh/.zshrc +++ b/template/zsh/.zshrc @@ -1,18 +1,12 @@ # Skip all this for non-interactive shells [[ -z "$PS1" ]] && return -# Load aliases -[ -f "$HOME/.aliasrc" ] && source "$HOME/.aliasrc" - -# Load environment -[ -f "$HOME/.aliasrc" ] && source "$HOME/.envrc" - ######### # zplug # ######### export ZPLUG_HOME=~/.zplug -source $ZPLUG_HOME/init.zsh +source $ZPLUG_HOME/init.zsh zplug 'zplug/zplug', hook-build:'zplug --self-manage' @@ -48,7 +42,7 @@ if ! zplug check --verbose; then fi # Then, source plugins and add commands to $PATH -zplug load +zplug load ################ # Zsh settings # @@ -69,15 +63,15 @@ bindkey '^w' backward-kill-word # ctrl-r starts searching history backward bindkey '^r' history-incremental-search-backward -# History +# History HISTFILE="$HOME/.zsh_history" HISTSIZE=10000000 SAVEHIST=$HISTSIZE -setopt INC_APPEND_HISTORY -setopt HIST_IGNORE_SPACE -setopt SHARE_HISTORY -setopt HIST_IGNORE_ALL_DUPS -setopt HIST_REDUCE_BLANKS +setopt INC_APPEND_HISTORY +setopt HIST_IGNORE_SPACE +setopt SHARE_HISTORY +setopt HIST_IGNORE_ALL_DUPS +setopt HIST_REDUCE_BLANKS # Other options @@ -91,7 +85,7 @@ setopt AUTO_CONTINUE setopt NOCLOBBER # Completion -zmodload zsh/complist +zmodload zsh/complist autoload -Uz compinit compinit zstyle :compinstall filename '${HOME}/.zshrc' @@ -121,3 +115,10 @@ zstyle ':completion:*' cache-path ~/.zsh/cache # bindkey "^[[B" history-beginning-search-forward bindkey '^[[A' history-substring-search-up bindkey '^[[B' history-substring-search-down + +# Load aliases +[ -f "$HOME/.aliasrc" ] && source "$HOME/.aliasrc" + +# Load environment +[ -f "$HOME/.aliasrc" ] && source "$HOME/.envrc" +