Skip to content

Commit

Permalink
Create OS- and host-specific dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
huyz committed Jan 8, 2023
1 parent 5fad8cb commit d98bcf4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ plugin
syntax
packages
plugged
# OS-specific plugins
plugged-*

### For plugins

session
# host-specific plugins
session-*
3 changes: 3 additions & 0 deletions .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" Init {{{1

""" "linux" or "darwin"
let g:uname = tolower(substitute(system('uname'), '\n', '', ''))

""" Find .vim/ relative to .vimrc
" Usage: vim -u /path/to/portable/vim/.vimrc

Expand Down
19 changes: 12 additions & 7 deletions init.plugins.vim
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ if empty(glob('~/.vim/autoload/plug.vim'))
endif

" Specify a directory for plugins
" - Avoid using standard Vim directory names like 'plugin'
" - Normallly, for Neovim it would be: ~/.local/share/nvim/plugged
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" - Vim (Windows): '~/vimfiles/plugged'
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
call plug#begin('~/.vim/plugged')

" Conditional activation
Expand All @@ -47,12 +49,15 @@ Plug 'mattn/webapi-vim'

""" Plugins {{{2

" OS-specific directory for plugins
let g:plug_os_dir = expand('~/.vim/plugged-' . g:uname)

" Files
Plug 'mhinz/vim-startify'
" plenary: dependency of telescope
Plug 'nvim-lua/plenary.nvim', Cond(exists('g:nvim'))
Plug 'nvim-telescope/telescope.nvim', Cond(exists('g:nvim'))
Plug 'nvim-telescope/telescope-fzf-native.nvim', Cond(exists('g:nvim'), { 'do': 'make' })
Plug 'nvim-telescope/telescope-fzf-native.nvim', Cond(exists('g:nvim'), { 'dir': g:plug_os_dir . '/telescope-fzf-native.nvim', 'do': 'make'})
Plug 'kien/ctrlp.vim'
" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Expand Down Expand Up @@ -88,7 +93,7 @@ Plug 'chriskempson/base16-vim'
" UI
Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
Plug 'kyazdani42/nvim-tree.lua', Cond(exists('g:nvim'))
Plug 'preservim/nerdtree', Cond(!exists('g:nvim'))
Plug 'preservim/nerdtree', Cond(!exists('g:nvim'), { 'on': 'NERDTreeToggle' })
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'nathanaelkane/vim-indent-guides'
Expand Down Expand Up @@ -211,7 +216,7 @@ call plug#end()

""" startify {{{2

let g:startify_session_dir = '~/.vim/session'
let g:startify_session_dir = expand('$MYVIM/session-') . hostname()
if exists('g:nvim')
let g:startify_session_before_save = [ 'silent! tabdo NvimTreeClose' ]
else
Expand Down Expand Up @@ -272,8 +277,8 @@ autocmd VimLeavePre * silent execute 'SSave! ' . GetUniqueSessionNam

" Need to make sure the session directory exists, or SSave will prompt (and beacuse of the
" `silent`, you won't see a prompt to create a directory--just a pause
if !isdirectory(expand('$MYVIM/session/session.vim'))
execute "!mkdir -p '" . expand('$MYVIM/session/session.vim') . "'"
if !isdirectory(g:startify_session_dir)
execute "!mkdir -p '" . g:startify_session_dir . "'"
endif

""" telescope {{{2
Expand Down

0 comments on commit d98bcf4

Please sign in to comment.