From 8689f00131942a0dc66c4a4f72250b68dff8535f Mon Sep 17 00:00:00 2001 From: Andrejus Date: Sun, 12 Jul 2020 22:33:50 +0100 Subject: [PATCH] Install improvements --- files/.config/nvim/base.vim | 102 +++++++ files/.config/nvim/init.vim | 473 +------------------------------- files/.config/nvim/mappings.vim | 128 +++++++++ files/.config/nvim/plugins.vim | 303 ++++++++++++++++++-- install.pl | 15 +- install/02-fish.sh | 4 +- install/10-pyenv.sh | 2 +- install/11-python.sh | 3 + install/12-poetry.sh | 1 + install/16-vim.sh | 8 +- install/utils.sh | 1 + 11 files changed, 534 insertions(+), 506 deletions(-) create mode 100644 files/.config/nvim/base.vim create mode 100644 files/.config/nvim/mappings.vim diff --git a/files/.config/nvim/base.vim b/files/.config/nvim/base.vim new file mode 100644 index 0000000..81e894f --- /dev/null +++ b/files/.config/nvim/base.vim @@ -0,0 +1,102 @@ +set fileencoding=utf-8 +set fileformat=unix +filetype on +filetype plugin on +syntax on + +" ============================================================================ " +" === EDITING OPTIONS === " +" ============================================================================ " + +" Remap leader key to +let g:mapleader=' ' + +" Yank and paste with the system clipboard +set clipboard= + +" Hides buffers instead of closing them +set hidden + +set smartindent + +set expandtab +set tabstop=4 +set shiftwidth=4 + +set foldenable +set foldmethod=indent +set foldlevel=99 + +set cursorline +set cursorcolumn + +set nonumber +set relativenumber + +" do not wrap long lines by default +set nowrap + +" two lines for command line +set cmdheight=2 + +" ============================================================================ " +" === UI === " +" ============================================================================ " + +" Enable true color support +" set termguicolors + +" Enable pseudo-transparency +set pumblend + +" Change vertical split character to be a space (essentially hide it) +set fillchars+=vert:. + +" Set preview window to appear at bottom +set splitbelow + +" Don't dispay mode in command line (airilne already shows it) +set noshowmode + +" Set floating window to be slightly transparent +set winbl=10 + +" Editor theme +set background=dark + +" Vim airline theme + +" ============================================================================ " +" === MISC. === " +" ============================================================================ " + +" Automaticaly close nvim if NERDTree is only thing left open +autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif + +" === Search === " +" ignore case when searching +set ignorecase + +" if the search string has an upper case letter in it, the search will be case sensitive +set smartcase + +" Automatically re-read file if a change was detected outside of vim +set autoread + +" Enable line numbers +set number + +" Enable spellcheck for markdown files +autocmd BufRead,BufNewFile *.md setlocal spell + +" Set backups +if has('persistent_undo') + set undofile + set undolevels=3000 + set undoreload=10000 +endif +set backupdir=$XDG_DATA_HOME/nvim/backup " Don't put backups in current dir +set backup +set noswapfile + + diff --git a/files/.config/nvim/init.vim b/files/.config/nvim/init.vim index 11a790c..84e2261 100644 --- a/files/.config/nvim/init.vim +++ b/files/.config/nvim/init.vim @@ -1,466 +1,11 @@ -scriptencoding utf-8 +if &compatible + set nocompatible +endif + +" ============================================================================ " +" === Load files === " +" ============================================================================ " +source $XDG_CONFIG_HOME/nvim/base.vim source $XDG_CONFIG_HOME/nvim/plugins.vim - - -" ============================================================================ " -" === EDITING OPTIONS === " -" ============================================================================ " - -" Remap leader key to , -let g:mapleader=',' - -" Yank and paste with the system clipboard -set clipboard=unnamed - -" Hides buffers instead of closing them -set hidden - -" === TAB/Space settings === " -" Insert spaces when TAB is pressed. -set expandtab - -" do not wrap long lines by default -set nowrap - -" Only one line for command line -set cmdheight=1 - - -" ============================================================================ " -" === PLUGIN SETUP === " -" ============================================================================ " - -" Wrap in try/catch to avoid errors on initial install before plugin is available -try -" === Denite setup ===" -" Use ripgrep for searching current directory for files -" By default, ripgrep will respect rules in .gitignore -" --files: Print each file that would be searched (but don't search) -" --glob: Include or exclues files for searching that match the given glob -" (aka ignore .git files) -" -call denite#custom#var('file/rec', 'command', ['rg', '--files', '--glob', '!.git']) - -" Use ripgrep in place of "grep" -call denite#custom#var('grep', 'command', ['rg']) - -" Custom options for ripgrep -" --vimgrep: Show results with every match on it's own line -" --hidden: Search hidden directories and files -" --heading: Show the file name above clusters of matches from each file -" --S: Search case insensitively if the pattern is all lowercase -call denite#custom#var('grep', 'default_opts', ['--hidden', '--vimgrep', '--heading', '-S']) - -" Recommended defaults for ripgrep via Denite docs -call denite#custom#var('grep', 'recursive_opts', []) -call denite#custom#var('grep', 'pattern_opt', ['--regexp']) -call denite#custom#var('grep', 'separator', ['--']) -call denite#custom#var('grep', 'final_opts', []) - -" Remove date from buffer list -call denite#custom#var('buffer', 'date_format', '') - -" Custom options for Denite -" auto_resize - Auto resize the Denite window height automatically. -" prompt - Customize denite prompt -" direction - Specify Denite window direction as directly below current pane -" winminheight - Specify min height for Denite window -" highlight_mode_insert - Specify h1-CursorLine in insert mode -" prompt_highlight - Specify color of prompt -" highlight_matched_char - Matched characters highlight -" highlight_matched_range - matched range highlight -let s:denite_options = {'default' : { -\ 'split': 'floating', -\ 'start_filter': 1, -\ 'auto_resize': 1, -\ 'source_names': 'short', -\ 'prompt': 'λ ', -\ 'highlight_matched_char': 'QuickFixLine', -\ 'highlight_matched_range': 'Visual', -\ 'highlight_window_background': 'Visual', -\ 'highlight_filter_background': 'DiffAdd', -\ 'winrow': 1, -\ 'vertical_preview': 1 -\ }} - -" Loop through denite options and enable them -function! s:profile(opts) abort - for l:fname in keys(a:opts) - for l:dopt in keys(a:opts[l:fname]) - call denite#custom#option(l:fname, l:dopt, a:opts[l:fname][l:dopt]) - endfor - endfor -endfunction - -call s:profile(s:denite_options) -catch - echo 'Denite not installed. It should work after running :PlugInstall' -endtry - -" === Coc.nvim === " -" use for trigger completion and navigate to next complete item -function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~ '\s' -endfunction - -inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() - -"Close preview window when completion is done. -autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif - -" Allow use of :Prettier -command! -nargs=0 Prettier :CocCommand prettier.formatFile - -" === NeoSnippet === " -" Map as shortcut to activate snippet if available -imap (neosnippet_expand_or_jump) -smap (neosnippet_expand_or_jump) -xmap (neosnippet_expand_target) - -" Load custom snippets from snippets folder -let g:neosnippet#snippets_directory='~/.config/nvim/snippets' - -" Hide conceal markers -let g:neosnippet#enable_conceal_markers = 0 - -" === NERDTree === " -" Show hidden files/directories -let g:NERDTreeShowHidden = 1 - -" Remove bookmarks and help text from NERDTree -let g:NERDTreeMinimalUI = 1 - -" Custom icons for expandable/expanded directories -let g:NERDTreeDirArrowExpandable = '' -let g:NERDTreeDirArrowCollapsible = '' - -" Hide certain files and directories from NERDTree -let g:NERDTreeIgnore = ['^\.DS_Store$', '^tags$', '\.git$[[dir]]', '\.idea$[[dir]]', '\.sass-cache$'] - -" Wrap in try/catch to avoid errors on initial install before plugin is available -try - -" === Vim airline ==== " -" Enable extensions -let g:airline_extensions = ['branch', 'hunks', 'coc'] - -" Update section z to just have line number -let g:airline_section_z = airline#section#create(['linenr']) - -" Do not draw separators for empty sections (only for the active window) > -let g:airline_skip_empty_sections = 1 - -" Smartly uniquify buffers names with similar filename, suppressing common parts of paths. -let g:airline#extensions#tabline#formatter = 'unique_tail' - -" Custom setup that removes filetype/whitespace from default vim airline bar -let g:airline#extensions#default#layout = [['a', 'b', 'c'], ['x', 'z', 'warning', 'error']] - -" Customize vim airline per filetype -" 'nerdtree' - Hide nerdtree status line -" 'list' - Only show file type plus current line number out of total -let g:airline_filetype_overrides = { - \ 'nerdtree': [ get(g:, 'NERDTreeStatusline', ''), '' ], - \ 'list': [ '%y', '%l/%L'], - \ } - -" Enable powerline fonts -let g:airline_powerline_fonts = 1 - -" Enable caching of syntax highlighting groups -let g:airline_highlighting_cache = 1 - -" Define custom airline symbols -if !exists('g:airline_symbols') - let g:airline_symbols = {} -endif - -" Don't show git changes to current file in airline -let g:airline#extensions#hunks#enabled=0 - -catch - echo 'Airline not installed. It should work after running :PlugInstall' -endtry - -" === echodoc === " -" Enable echodoc on startup -let g:echodoc#enable_at_startup = 1 - -" === vim-javascript === " -" Enable syntax highlighting for JSDoc -let g:javascript_plugin_jsdoc = 1 - -" === vim-jsx === " -" Highlight jsx syntax even in non .jsx files -let g:jsx_ext_required = 0 - -" === javascript-libraries-syntax === " -let g:used_javascript_libs = 'underscore,requirejs,chai,jquery' - -" === Signify === " -let g:signify_sign_delete = '-' - - -" ============================================================================ " -" === UI === " -" ============================================================================ " - -" Enable true color support -set termguicolors - -" Vim airline theme -let g:airline_theme='codedark' - -" Change vertical split character to be a space (essentially hide it) -set fillchars+=vert:. - -" Set preview window to appear at bottom -set splitbelow - -" Don't dispay mode in command line (airilne already shows it) -set noshowmode - -" Set floating window to be slightly transparent -set winbl=10 - -" ============================================================================ " -" === CUSTOM COLORSCHEME CHANGES === " -" ============================================================================ " -" -" Add custom highlights in method that is executed every time a colorscheme is sourced -" See https://gist.github.com/romainl/379904f91fa40533175dfaec4c833f2f for details -function! TrailingSpaceHighlights() abort - " Hightlight trailing whitespace - highlight Trail ctermbg=red guibg=red - call matchadd('Trail', '\s\+$', 100) -endfunction - -function! s:custom_jarvis_colors() - " coc.nvim color changes - hi link CocErrorSign WarningMsg - hi link CocWarningSign Number - hi link CocInfoSign Type - - " Make background transparent for many things - hi Normal ctermbg=NONE guibg=NONE - hi NonText ctermbg=NONE guibg=NONE - hi LineNr ctermfg=NONE guibg=NONE - hi SignColumn ctermfg=NONE guibg=NONE - hi StatusLine guifg=#16252b guibg=#6699CC - hi StatusLineNC guifg=#16252b guibg=#16252b - - " Try to hide vertical spit and end of buffer symbol - hi VertSplit gui=NONE guifg=#17252c guibg=#17252c - hi EndOfBuffer ctermbg=NONE ctermfg=NONE guibg=#17252c guifg=#17252c - - " Customize NERDTree directory - hi NERDTreeCWD guifg=#99c794 - - " Make background color transparent for git changes - hi SignifySignAdd guibg=NONE - hi SignifySignDelete guibg=NONE - hi SignifySignChange guibg=NONE - - " Highlight git change signs - hi SignifySignAdd guifg=#99c794 - hi SignifySignDelete guifg=#ec5f67 - hi SignifySignChange guifg=#c594c5 -endfunction - -autocmd! ColorScheme * call TrailingSpaceHighlights() -autocmd! ColorScheme codedark call s:custom_jarvis_colors() - -" Call method on window enter -augroup WindowManagement - autocmd! - autocmd WinEnter * call Handle_Win_Enter() -augroup END - -" Change highlight group of preview window when open -function! Handle_Win_Enter() - if &previewwindow - setlocal winhighlight=Normal:MarkdownError - endif -endfunction - -" Editor theme -set background=dark -try - colorscheme codedark -catch - colorscheme slate -endtry - - -" ============================================================================ " -" === KEY MAPPINGS === " -" ============================================================================ " - -" === Denite shorcuts === " -" ; - Browser currently open buffers -" t - Browse list of files in current directory -" g - Search current directory for occurences of given term and close window if no results -" j - Search current directory for occurences of word under cursor -nmap ; :Denite buffer -nmap t :DeniteProjectDir file/rec -nnoremap g :Denite grep:. -no-empty -nnoremap j :DeniteCursorWord grep:. - -" Define mappings while in 'filter' mode -" - Switch to normal mode inside of search results -" - Exit denite window in any mode -" - Open currently selected file in any mode -" - Open currently selected file in a new tab -" - Open currently selected file a vertical split -" - Open currently selected file in a horizontal split -autocmd FileType denite-filter call s:denite_filter_my_settings() -function! s:denite_filter_my_settings() abort - imap - \ (denite_filter_quit) - inoremap - \ denite#do_map('quit') - nnoremap - \ denite#do_map('quit') - inoremap - \ denite#do_map('do_action') - inoremap - \ denite#do_map('do_action', 'tabopen') - inoremap - \ denite#do_map('do_action', 'vsplit') - inoremap - \ denite#do_map('do_action', 'split') -endfunction - -" Define mappings while in denite window -" - Opens currently selected file -" q or - Quit Denite window -" d - Delete currenly selected file -" p - Preview currently selected file -" or i - Switch to insert mode inside of filter prompt -" - Open currently selected file in a new tab -" - Open currently selected file a vertical split -" - Open currently selected file in a horizontal split -autocmd FileType denite call s:denite_my_settings() -function! s:denite_my_settings() abort - nnoremap - \ denite#do_map('do_action') - nnoremap q - \ denite#do_map('quit') - nnoremap - \ denite#do_map('quit') - nnoremap d - \ denite#do_map('do_action', 'delete') - nnoremap p - \ denite#do_map('do_action', 'preview') - nnoremap i - \ denite#do_map('open_filter_buffer') - nnoremap - \ denite#do_map('open_filter_buffer') - nnoremap - \ denite#do_map('do_action', 'tabopen') - nnoremap - \ denite#do_map('do_action', 'vsplit') - nnoremap - \ denite#do_map('do_action', 'split') -endfunction - -" === Nerdtree shorcuts === " -" n - Toggle NERDTree on/off -" f - Opens current file location in NERDTree -nmap n :NERDTreeToggle -nmap f :NERDTreeFind - -" - PageDown -" - - PageUp -noremap -noremap - - -" Quick window switching -nmap h -nmap j -nmap k -nmap l - -" === coc.nvim === " -" dd - Jump to definition of current symbol -" dr - Jump to references of current symbol -" dj - Jump to implementation of current symbol -" ds - Fuzzy search current project symbols -" p - Run Prettier formatter on file -nmap dd (coc-definition) -nmap dr (coc-references) -nmap dj (coc-implementation) -nnoremap ds :CocList -I -N --top symbols -nmap p :Prettier - -" === vim-better-whitespace === " -" y - Automatically remove trailing whitespace -nmap y :StripWhitespace - -" === Search shorcuts === " -" h - Find and replace -" / - Claer highlighted search terms while preserving history -map h :%s/// -nmap / :nohlsearch - -" === Easy-motion shortcuts ===" -" w - Easy-motion highlights first word letters bi-directionally -map w (easymotion-bd-w) - -" Allows you to save files you opened without write permissions via sudo -cmap w!! w !sudo tee % - -" === vim-jsdoc shortcuts ===" -" Generate jsdoc for function under cursor -nmap z :JsDoc - -" Delete current visual selection and dump in black hole buffer before pasting -" Used when you want to paste over something without it getting copied to -" Vim's default buffer -vnoremap p "_dP - -" ============================================================================ " -" === MISC. === " -" ============================================================================ " - -" Automaticaly close nvim if NERDTree is only thing left open -autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif - -" === Search === " -" ignore case when searching -set ignorecase - -" if the search string has an upper case letter in it, the search will be case sensitive -set smartcase - -" Automatically re-read file if a change was detected outside of vim -set autoread - -" Enable line numbers -set number - -" Enable spellcheck for markdown files -autocmd BufRead,BufNewFile *.md setlocal spell - -" Set backups -if has('persistent_undo') - set undofile - set undolevels=3000 - set undoreload=10000 -endif -set backupdir=$XDG_DATA_HOME/nvim/backup " Don't put backups in current dir -set backup -set noswapfile - -" Reload icons after init source -if exists('g:loaded_webdevicons') - call webdevicons#refresh() -endif - -" Disable deprecated python2 provider -let g:loaded_python_provider = 0 +source $XDG_CONFIG_HOME/nvim/mappings.vim diff --git a/files/.config/nvim/mappings.vim b/files/.config/nvim/mappings.vim new file mode 100644 index 0000000..4fb9fda --- /dev/null +++ b/files/.config/nvim/mappings.vim @@ -0,0 +1,128 @@ + +" ============================================================================ " +" === KEY MAPPINGS === " +" ============================================================================ " + +" === Denite shorcuts === " +" ; - Browser currently open buffers +" t - Browse list of files in current directory +" g - Search current directory for occurences of given term and close window if no results +" j - Search current directory for occurences of word under cursor +nmap ; :Denite buffer +nmap t :DeniteProjectDir file/rec +nnoremap g :Denite grep:. -no-empty +nnoremap j :DeniteCursorWord grep:. + +" Define mappings while in 'filter' mode +" - Switch to normal mode inside of search results +" - Exit denite window in any mode +" - Open currently selected file in any mode +" - Open currently selected file in a new tab +" - Open currently selected file a vertical split +" - Open currently selected file in a horizontal split +autocmd FileType denite-filter call s:denite_filter_my_settings() +function! s:denite_filter_my_settings() abort + imap + \ (denite_filter_quit) + inoremap + \ denite#do_map('quit') + nnoremap + \ denite#do_map('quit') + inoremap + \ denite#do_map('do_action') + inoremap + \ denite#do_map('do_action', 'tabopen') + inoremap + \ denite#do_map('do_action', 'vsplit') + inoremap + \ denite#do_map('do_action', 'split') +endfunction + +" Define mappings while in denite window +" - Opens currently selected file +" q or - Quit Denite window +" d - Delete currenly selected file +" p - Preview currently selected file +" or i - Switch to insert mode inside of filter prompt +" - Open currently selected file in a new tab +" - Open currently selected file a vertical split +" - Open currently selected file in a horizontal split +autocmd FileType denite call s:denite_my_settings() +function! s:denite_my_settings() abort + nnoremap + \ denite#do_map('do_action') + nnoremap q + \ denite#do_map('quit') + nnoremap + \ denite#do_map('quit') + nnoremap d + \ denite#do_map('do_action', 'delete') + nnoremap p + \ denite#do_map('do_action', 'preview') + nnoremap i + \ denite#do_map('open_filter_buffer') + nnoremap + \ denite#do_map('open_filter_buffer') + nnoremap + \ denite#do_map('do_action', 'tabopen') + nnoremap + \ denite#do_map('do_action', 'vsplit') + nnoremap + \ denite#do_map('do_action', 'split') +endfunction + +" === Nerdtree shorcuts === " +" n - Toggle NERDTree on/off +" f - Opens current file location in NERDTree +nmap n :NERDTreeToggle +nmap f :NERDTreeFind + +" - PageDown +" - - PageUp +noremap +noremap - + +" Quick window switching +nmap h +nmap j +nmap k +nmap l + +" === coc.nvim === " +" dd - Jump to definition of current symbol +" dr - Jump to references of current symbol +" dj - Jump to implementation of current symbol +" ds - Fuzzy search current project symbols +" p - Run Prettier formatter on file +nmap dd (coc-definition) +nmap dr (coc-references) +nmap dj (coc-implementation) +nnoremap ds :CocList -I -N --top symbols +nmap p :Prettier + +" === vim-better-whitespace === " +" y - Automatically remove trailing whitespace +nmap y :StripWhitespace + +" === Search shorcuts === " +" h - Find and replace +" / - Claer highlighted search terms while preserving history +map h :%s/// +nmap / :nohlsearch + +" === Easy-motion shortcuts ===" +" w - Easy-motion highlights first word letters bi-directionally +map w (easymotion-bd-w) + +" Allows you to save files you opened without write permissions via sudo +cmap w!! w !sudo tee % + +" === vim-jsdoc shortcuts ===" +" Generate jsdoc for function under cursor +nmap z :JsDoc + +" Delete current visual selection and dump in black hole buffer before pasting +" Used when you want to paste over something without it getting copied to +" Vim's default buffer +vnoremap p "_dP + diff --git a/files/.config/nvim/plugins.vim b/files/.config/nvim/plugins.vim index a708682..f57426d 100644 --- a/files/.config/nvim/plugins.vim +++ b/files/.config/nvim/plugins.vim @@ -1,27 +1,32 @@ - " ============================================================================ " " === PLUGINS === " " ============================================================================ " - -" check whether vim-plug is installed and install it if necessary -let plugpath = expand(':p:h'). '/autoload/plug.vim' -if !filereadable(plugpath) - if executable('curl') - let plugurl = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - call system('curl -fLo ' . shellescape(plugpath) . ' --create-dirs ' . plugurl) - if v:shell_error - echom "Error downloading vim-plug. Please install it manually.\n" - exit - endif - else - echom "vim-plug not installed. Please install it manually or install curl.\n" - exit - endif -endif - call plug#begin('~/.config/nvim/plugged') -" === Editing Plugins === " +" Sensible (?) defaults +Plug 'tpope/vim-sensible' + +" colorscheme +Plug 'gilgigilgil/anderson.vim' +silent! colorscheme anderson + + +" lint +Plug 'dense-analysis/ale' +let g:ale_fix_on_save = 1 + +" Intellisense Engine +Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'} + +" Denite - Fuzzy finding, buffer management +if has('nvim') + Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' } +else + Plug 'Shougo/denite.nvim' + Plug 'roxma/nvim-yarp' + Plug 'roxma/vim-hug-neovim-rpc' +endif + " Trailing whitespace highlighting & automatic fixing Plug 'ntpeters/vim-better-whitespace' @@ -31,12 +36,6 @@ Plug 'rstacruz/vim-closer' " Improved motion in Vim Plug 'easymotion/vim-easymotion' -" Intellisense Engine -Plug 'neoclide/coc.nvim', {'branch': 'release'} - -" Denite - Fuzzy finding, buffer management -Plug 'Shougo/denite.nvim' - " Snippet support Plug 'Shougo/neosnippet' Plug 'Shougo/neosnippet-snippets' @@ -74,12 +73,10 @@ Plug 'othree/yajs.vim' " File explorer Plug 'scrooloose/nerdtree' -" Colorscheme -Plug 'tomasiser/vim-code-dark' - " Customized vim status line Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' +let g:airline_theme='onedark' " Icons Plug 'ryanoasis/vim-devicons' @@ -88,3 +85,253 @@ Plug 'tiagofumo/vim-nerdtree-syntax-highlight' " Initialize plugin system call plug#end() + + +" ============================================================================ " +" === PLUGIN SETUP === " +" ============================================================================ " + +" Wrap in try/catch to avoid errors on initial install before plugin is available +try +" === Denite setup ===" +" Use ripgrep for searching current directory for files +" By default, ripgrep will respect rules in .gitignore +" --files: Print each file that would be searched (but don't search) +" --glob: Include or exclues files for searching that match the given glob +" (aka ignore .git files) +" +call denite#custom#var('file/rec', 'command', ['rg', '--files', '--glob', '!.git']) + +" Use ripgrep in place of "grep" +call denite#custom#var('grep', 'command', ['rg']) + +" Custom options for ripgrep +" --vimgrep: Show results with every match on it's own line +" --hidden: Search hidden directories and files +" --heading: Show the file name above clusters of matches from each file +" --S: Search case insensitively if the pattern is all lowercase +call denite#custom#var('grep', 'default_opts', ['--hidden', '--vimgrep', '--heading', '-S']) + +" Recommended defaults for ripgrep via Denite docs +call denite#custom#var('grep', 'recursive_opts', []) +call denite#custom#var('grep', 'pattern_opt', ['--regexp']) +call denite#custom#var('grep', 'separator', ['--']) +call denite#custom#var('grep', 'final_opts', []) + +" Remove date from buffer list +call denite#custom#var('buffer', 'date_format', '') + +" Custom options for Denite +" auto_resize - Auto resize the Denite window height automatically. +" prompt - Customize denite prompt +" direction - Specify Denite window direction as directly below current pane +" winminheight - Specify min height for Denite window +" highlight_mode_insert - Specify h1-CursorLine in insert mode +" prompt_highlight - Specify color of prompt +" highlight_matched_char - Matched characters highlight +" highlight_matched_range - matched range highlight +let s:denite_options = {'default' : { +\ 'split': 'floating', +\ 'start_filter': 1, +\ 'auto_resize': 1, +\ 'source_names': 'short', +\ 'prompt': 'λ ', +\ 'highlight_matched_char': 'QuickFixLine', +\ 'highlight_matched_range': 'Visual', +\ 'highlight_window_background': 'Visual', +\ 'highlight_filter_background': 'DiffAdd', +\ 'winrow': 1, +\ 'vertical_preview': 1 +\ }} + +" Loop through denite options and enable them +function! s:profile(opts) abort + for l:fname in keys(a:opts) + for l:dopt in keys(a:opts[l:fname]) + call denite#custom#option(l:fname, l:dopt, a:opts[l:fname][l:dopt]) + endfor + endfor +endfunction + +call s:profile(s:denite_options) +catch + echo 'Denite not installed. It should work after running :PlugInstall' +endtry + +" === Coc.nvim === " +" use for trigger completion and navigate to next complete item +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~ '\s' +endfunction + +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() + +"Close preview window when completion is done. +autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif + +" Allow use of :Prettier +command! -nargs=0 Prettier :CocCommand prettier.formatFile + +" === NeoSnippet === " +" Map as shortcut to activate snippet if available +imap (neosnippet_expand_or_jump) +smap (neosnippet_expand_or_jump) +xmap (neosnippet_expand_target) + +" Load custom snippets from snippets folder +let g:neosnippet#snippets_directory='~/.config/nvim/snippets' + +" Hide conceal markers +let g:neosnippet#enable_conceal_markers = 0 + +" === NERDTree === " +" Show hidden files/directories +let g:NERDTreeShowHidden = 1 + +" Remove bookmarks and help text from NERDTree +let g:NERDTreeMinimalUI = 1 + +" Custom icons for expandable/expanded directories +let g:NERDTreeDirArrowExpandable = '' +let g:NERDTreeDirArrowCollapsible = '' + +" Hide certain files and directories from NERDTree +let g:NERDTreeIgnore = ['^\.DS_Store$', '^tags$', '\.git$[[dir]]', '\.idea$[[dir]]', '\.sass-cache$'] + +" Wrap in try/catch to avoid errors on initial install before plugin is available +try + +" === Vim airline ==== " +" Enable extensions +let g:airline_extensions = ['branch', 'hunks', 'coc'] + +" Update section z to just have line number +let g:airline_section_z = airline#section#create(['linenr']) + +" Do not draw separators for empty sections (only for the active window) > +let g:airline_skip_empty_sections = 1 + +" Smartly uniquify buffers names with similar filename, suppressing common parts of paths. +let g:airline#extensions#tabline#formatter = 'unique_tail' + +" Custom setup that removes filetype/whitespace from default vim airline bar +let g:airline#extensions#default#layout = [['a', 'b', 'c'], ['x', 'z', 'warning', 'error']] + +" Customize vim airline per filetype +" 'nerdtree' - Hide nerdtree status line +" 'list' - Only show file type plus current line number out of total +let g:airline_filetype_overrides = { + \ 'nerdtree': [ get(g:, 'NERDTreeStatusline', ''), '' ], + \ 'list': [ '%y', '%l/%L'], + \ } + +" Enable powerline fonts +let g:airline_powerline_fonts = 1 + +" Enable caching of syntax highlighting groups +let g:airline_highlighting_cache = 1 + +" Define custom airline symbols +if !exists('g:airline_symbols') + let g:airline_symbols = {} +endif + +" Don't show git changes to current file in airline +let g:airline#extensions#hunks#enabled=0 + +catch + echo 'Airline not installed. It should work after running :PlugInstall' +endtry + +" === echodoc === " +" Enable echodoc on startup +let g:echodoc#enable_at_startup = 1 + +" === vim-javascript === " +" Enable syntax highlighting for JSDoc +let g:javascript_plugin_jsdoc = 1 + +" === vim-jsx === " +" Highlight jsx syntax even in non .jsx files +let g:jsx_ext_required = 0 + +" === javascript-libraries-syntax === " +let g:used_javascript_libs = 'underscore,requirejs,chai,jquery' + +" === Signify === " +let g:signify_sign_delete = '-' + + +" ============================================================================ " +" === CUSTOM COLORSCHEME CHANGES === " +" ============================================================================ " +" +" Add custom highlights in method that is executed every time a colorscheme is sourced +" See https://gist.github.com/romainl/379904f91fa40533175dfaec4c833f2f for details +function! TrailingSpaceHighlights() abort + " Hightlight trailing whitespace + highlight Trail ctermbg=red guibg=red + call matchadd('Trail', '\s\+$', 100) +endfunction + +function! s:custom_jarvis_colors() + " coc.nvim color changes + hi link CocErrorSign WarningMsg + hi link CocWarningSign Number + hi link CocInfoSign Type + + " Make background transparent for many things + hi Normal ctermbg=NONE guibg=NONE + hi NonText ctermbg=NONE guibg=NONE + hi LineNr ctermfg=NONE guibg=NONE + hi SignColumn ctermfg=NONE guibg=NONE + hi StatusLine guifg=#16252b guibg=#6699CC + hi StatusLineNC guifg=#16252b guibg=#16252b + + " Try to hide vertical spit and end of buffer symbol + hi VertSplit gui=NONE guifg=#17252c guibg=#17252c + hi EndOfBuffer ctermbg=NONE ctermfg=NONE guibg=#17252c guifg=#17252c + + " Customize NERDTree directory + hi NERDTreeCWD guifg=#99c794 + + " Make background color transparent for git changes + hi SignifySignAdd guibg=NONE + hi SignifySignDelete guibg=NONE + hi SignifySignChange guibg=NONE + + " Highlight git change signs + hi SignifySignAdd guifg=#99c794 + hi SignifySignDelete guifg=#ec5f67 + hi SignifySignChange guifg=#c594c5 +endfunction + +autocmd! ColorScheme * call TrailingSpaceHighlights() +autocmd! ColorScheme codedark call s:custom_jarvis_colors() + +" Call method on window enter +augroup WindowManagement + autocmd! + autocmd WinEnter * call Handle_Win_Enter() +augroup END + +" Change highlight group of preview window when open +function! Handle_Win_Enter() + if &previewwindow + setlocal winhighlight=Normal:MarkdownError + endif +endfunction + + +" Reload icons after init source +if exists('g:loaded_webdevicons') + call webdevicons#refresh() +endif + +" Disable deprecated python2 provider +let g:loaded_python_provider = 0 + diff --git a/install.pl b/install.pl index 73abc4f..c94e641 100755 --- a/install.pl +++ b/install.pl @@ -19,7 +19,8 @@ if ($log_target ne 'STDOUT') { # Generate unique logfile my $log_dir = "$dir/logs"; `mkdir -p $log_dir`; - my $uuid = chomp `uuidgen`; + my $uuid = `uuidgen`; + chomp $uuid; $log_path = "$log_dir/$uuid.log"; } print "Logs: $log_path\n"; @@ -28,10 +29,10 @@ print "Logs: $log_path\n"; # @arg 0 command to run sub log_execute { my $command = $log_path ne '' - ? "$_[0] &> $log_path" + ? "$_[0] >> $log_path 2>&1" : $_[0]; - print "# $command\n"; - return system($command); + system($command) == 0 + or die "system $command failed: $?"; } @@ -57,9 +58,5 @@ if ($target ne 'all') { } foreach my $file (@files) { print "Running $file...\r"; - my $exit_status = log_execute("/bin/bash -l $install_dir/$file"); - if ($exit_status != 0) { - print "Failure in $file, see above and logs for more detail.\n"; - exit ($exit_status); - } + log_execute("$install_dir/$file"); } diff --git a/install/02-fish.sh b/install/02-fish.sh index 7d3f634..98ee0b9 100755 --- a/install/02-fish.sh +++ b/install/02-fish.sh @@ -7,8 +7,8 @@ if not_installed "fish"; then update install fish fi -echo "fish is installed" +echo "fish is installed" fish --version fisher_location="$XDG_CONFIG_HOME/fish/functions/fisher.fish" @@ -17,7 +17,7 @@ if ! [ -f "$fisher_location" ]; then curl https://git.io/fisher --create-dirs -sLo "$fisher_location" fi echo "fisher is installed, updating..." -sh -c 'env HOME=$(mktemp -d) fish -c "fisher"' +`fish -c "fisher"`; fish -c "fisher --version" diff --git a/install/10-pyenv.sh b/install/10-pyenv.sh index e26ed2a..1b5a5e4 100755 --- a/install/10-pyenv.sh +++ b/install/10-pyenv.sh @@ -17,7 +17,7 @@ if not_installed "pyenv"; then "bash" fi -echo "pyenv is installed, upgrading..." +echo "pyenv is installed, upgrading $PYENV_ROOT..." git --git-dir="$PYENV_ROOT/.git" fetch -q git --git-dir="$PYENV_ROOT/.git" rebase -q --autostash FETCH_HEAD diff --git a/install/11-python.sh b/install/11-python.sh index f6a2cea..cad75be 100755 --- a/install/11-python.sh +++ b/install/11-python.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash source "$(dirname $0)/utils.sh" +export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring # python3 and pip3 are installed if not_installed "pip3"; then @@ -8,9 +9,11 @@ if not_installed "pip3"; then pyenv install 3.7.0 pyenv global 3.7.0 + refresh fi echo "python3 and pip3 are installed, upgrading..." +pip install --upgrade pip pip3 install --upgrade pip python3 --version pip3 --version diff --git a/install/12-poetry.sh b/install/12-poetry.sh index 35af53d..86a0b9e 100755 --- a/install/12-poetry.sh +++ b/install/12-poetry.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash source "$(dirname $0)/utils.sh" +export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring # poetry is installed if not_installed "poetry"; then diff --git a/install/16-vim.sh b/install/16-vim.sh index 20aa89d..9335433 100755 --- a/install/16-vim.sh +++ b/install/16-vim.sh @@ -1,18 +1,22 @@ #!/usr/bin/env bash source "$(dirname $0)/utils.sh" +export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring mkdir -p "$XDG_DATA_HOME/nvim/backup" plug_target="$XDG_DATA_HOME/nvim/site/autoload/plug.vim" if [ ! -f $plug_target ]; then + echo "Downloading vim-plug to $plug_target"; curl -fLo "$plug_target" --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim fi +echo "Installing neovim support"; pip3 install neovim +pip3 install pynvim node --version yarn global add neovim sudo gem install neovim -nvim -E PlugInstall -c q -nvim -E PluginInstall -c q +echo "Running PlugInstall"; +nvim --headless +PlugInstall +PlugUpgrade +PlugUpdate +qall nvim --version diff --git a/install/utils.sh b/install/utils.sh index 0aec29e..bcfb57b 100755 --- a/install/utils.sh +++ b/install/utils.sh @@ -106,6 +106,7 @@ C_NC='\033[0m' # ---------------------------------------------------------------------------- # # Helper variables # # ---------------------------------------------------------------------------- # +export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring install_dir="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" dotfiles_dir="$(dirname "$install_dir")" source "$dotfiles_dir/files/.bash_profile"