2017-12-12 16:32:21 +08:00
|
|
|
"=============================================================================
|
|
|
|
" vimrc --- Entry file for vim
|
2022-06-12 15:37:35 +08:00
|
|
|
" Copyright (c) 2016-2022 Shidong Wang & Contributors
|
2020-09-19 16:19:58 +08:00
|
|
|
" Author: Shidong Wang < wsdjeg@outlook.com >
|
2017-12-12 16:32:21 +08:00
|
|
|
" URL: https://spacevim.org
|
2018-02-15 22:25:03 +08:00
|
|
|
" License: GPLv3
|
2017-12-12 16:32:21 +08:00
|
|
|
"=============================================================================
|
|
|
|
|
feat:(XDG): add XDG support
* fonts: Ensure mkfontscale is installed
When installing fonts, we have a silent igored error about missing
`mkfontscale` (and `mkfontdir`). Add a requirements check for it, and
'need' it when actually attempting to install fonts.
* fetch_repo: Never change a directory
It is bad practice to change the currents shell working directory. E.g.
never use 'cd' in a script.
For example, if `git pull` crashes, it would leave the user in the git
directory 'somewhere' on his filesystem, potentially causing confusion,
as the following `cd -` command is never executed.
There are of course always exceptions, such as when tooling does not
(easily) support out of tree invocation.
To solve this, run the command in a subshell, which won't touch the
current working directory as the exit of the subshell kept the previous
working directory.
A more difficult alternative would be to pass `--git-dir` and
`--work-tree` along to git, but this would make it far harder to read.
* fetch_repo: Do not duplicate code all over
There is no reason to put `need 'git'` all over the place, when the only
time we truly need it, is if we pull the repo. Make the code a little
less cluttered and a bit easier to read.
* install: Support XDG_CONFIG_HOME
Add support for the XDG specification for XDG_CONFIG_HOME. NeoVIM
already follows this, regular vim needs a bit of help there.
Closes: #3517
* SpaceVim.d: Support XDG paths
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2022-12-28 14:19:06 +08:00
|
|
|
" Use XDG paths if available
|
|
|
|
if !empty($XDG_CONFIG_HOME)
|
|
|
|
set runtimepath^=$XDG_CONFIG_HOME/vim
|
|
|
|
set runtimepath+=$XDG_DATA_HOME/vim
|
|
|
|
set runtimepath+=$XDG_CONFIG_HOME/vim/after
|
|
|
|
|
2023-03-11 22:50:18 +08:00
|
|
|
if exists('&packpath')
|
|
|
|
set packpath^=$XDG_DATA_HOME/vim,$XDG_CONFIG_HOME/vim
|
|
|
|
set packpath+=$XDG_CONFIG_HOME/vim/after,$XDG_DATA_HOME/vim/after
|
|
|
|
endif
|
feat:(XDG): add XDG support
* fonts: Ensure mkfontscale is installed
When installing fonts, we have a silent igored error about missing
`mkfontscale` (and `mkfontdir`). Add a requirements check for it, and
'need' it when actually attempting to install fonts.
* fetch_repo: Never change a directory
It is bad practice to change the currents shell working directory. E.g.
never use 'cd' in a script.
For example, if `git pull` crashes, it would leave the user in the git
directory 'somewhere' on his filesystem, potentially causing confusion,
as the following `cd -` command is never executed.
There are of course always exceptions, such as when tooling does not
(easily) support out of tree invocation.
To solve this, run the command in a subshell, which won't touch the
current working directory as the exit of the subshell kept the previous
working directory.
A more difficult alternative would be to pass `--git-dir` and
`--work-tree` along to git, but this would make it far harder to read.
* fetch_repo: Do not duplicate code all over
There is no reason to put `need 'git'` all over the place, when the only
time we truly need it, is if we pull the repo. Make the code a little
less cluttered and a bit easier to read.
* install: Support XDG_CONFIG_HOME
Add support for the XDG specification for XDG_CONFIG_HOME. NeoVIM
already follows this, regular vim needs a bit of help there.
Closes: #3517
* SpaceVim.d: Support XDG paths
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2022-12-28 14:19:06 +08:00
|
|
|
|
|
|
|
let g:netrw_home = $XDG_DATA_HOME."/vim"
|
2023-02-21 18:42:11 +08:00
|
|
|
if !isdirectory($XDG_DATA_HOME."/vim")
|
|
|
|
call mkdir($XDG_DATA_HOME."/vim", 'p')
|
|
|
|
endif
|
feat:(XDG): add XDG support
* fonts: Ensure mkfontscale is installed
When installing fonts, we have a silent igored error about missing
`mkfontscale` (and `mkfontdir`). Add a requirements check for it, and
'need' it when actually attempting to install fonts.
* fetch_repo: Never change a directory
It is bad practice to change the currents shell working directory. E.g.
never use 'cd' in a script.
For example, if `git pull` crashes, it would leave the user in the git
directory 'somewhere' on his filesystem, potentially causing confusion,
as the following `cd -` command is never executed.
There are of course always exceptions, such as when tooling does not
(easily) support out of tree invocation.
To solve this, run the command in a subshell, which won't touch the
current working directory as the exit of the subshell kept the previous
working directory.
A more difficult alternative would be to pass `--git-dir` and
`--work-tree` along to git, but this would make it far harder to read.
* fetch_repo: Do not duplicate code all over
There is no reason to put `need 'git'` all over the place, when the only
time we truly need it, is if we pull the repo. Make the code a little
less cluttered and a bit easier to read.
* install: Support XDG_CONFIG_HOME
Add support for the XDG specification for XDG_CONFIG_HOME. NeoVIM
already follows this, regular vim needs a bit of help there.
Closes: #3517
* SpaceVim.d: Support XDG paths
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2022-12-28 14:19:06 +08:00
|
|
|
call mkdir($XDG_DATA_HOME."/vim/spell", 'p')
|
|
|
|
|
|
|
|
set backupdir=$XDG_STATE_HOME/vim/backup | call mkdir(&backupdir, 'p')
|
|
|
|
set directory=$XDG_STATE_HOME/vim/swap | call mkdir(&directory, 'p')
|
|
|
|
set undodir=$XDG_STATE_HOME/vim/undo | call mkdir(&undodir, 'p')
|
|
|
|
set viewdir=$XDG_STATE_HOME/vim/view | call mkdir(&viewdir, 'p')
|
|
|
|
|
|
|
|
if !has('nvim') | set viminfofile=$XDG_STATE_HOME/vim/viminfo | endif
|
|
|
|
endif
|
|
|
|
|
2016-12-26 20:36:18 +08:00
|
|
|
" Note: Skip initialization for vim-tiny or vim-small.
|
|
|
|
if 1
|
2019-10-08 22:24:03 +08:00
|
|
|
let g:_spacevim_if_lua = 0
|
|
|
|
if has('lua')
|
2022-03-29 21:48:33 +08:00
|
|
|
" add ~/.SpaceVim/lua to lua package path
|
2020-01-31 21:38:24 +08:00
|
|
|
if has('win16') || has('win32') || has('win64')
|
|
|
|
let s:plugin_dir = fnamemodify(expand('<sfile>'), ':h').'\lua'
|
|
|
|
let s:str = s:plugin_dir . '\?.lua;' . s:plugin_dir . '\?\init.lua;'
|
|
|
|
else
|
|
|
|
let s:plugin_dir = fnamemodify(expand('<sfile>'), ':h').'/lua'
|
|
|
|
let s:str = s:plugin_dir . '/?.lua;' . s:plugin_dir . '/?/init.lua;'
|
|
|
|
endif
|
2019-10-11 23:07:03 +08:00
|
|
|
silent! lua package.path=vim.eval("s:str") .. package.path
|
|
|
|
if empty(v:errmsg)
|
2019-10-08 22:24:03 +08:00
|
|
|
let g:_spacevim_if_lua = 1
|
2019-10-11 23:07:03 +08:00
|
|
|
endif
|
2019-10-08 22:24:03 +08:00
|
|
|
endif
|
2022-11-20 12:33:55 +08:00
|
|
|
execute 'source' fnamemodify(expand('<sfile>'), ':h').'/init.vim'
|
2016-12-26 20:36:18 +08:00
|
|
|
endif
|
2017-03-06 23:26:26 +08:00
|
|
|
" vim:set et sw=2
|