aboutsummaryrefslogtreecommitdiff
path: root/vim/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'vim/autoload')
-rw-r--r--vim/autoload/argument.vim8
-rw-r--r--vim/autoload/diff.vim2
-rw-r--r--vim/autoload/filetype/repeat.vim2
-rw-r--r--vim/autoload/fortune.vim59
-rw-r--r--vim/autoload/has.vim34
-rw-r--r--vim/autoload/html/timestamp.vim4
-rw-r--r--vim/autoload/indent.vim20
-rw-r--r--vim/autoload/mail.vim4
-rw-r--r--vim/autoload/mail/header/field.vim2
-rw-r--r--vim/autoload/option.vim8
-rw-r--r--vim/autoload/patch.vim35
-rw-r--r--vim/autoload/path.vim14
-rw-r--r--vim/autoload/plugin.vim7
-rw-r--r--vim/autoload/put_date.vim24
-rw-r--r--vim/autoload/quote.vim4
-rw-r--r--vim/autoload/xdg.vim67
16 files changed, 123 insertions, 171 deletions
diff --git a/vim/autoload/argument.vim b/vim/autoload/argument.vim
deleted file mode 100644
index 85d75eb1..00000000
--- a/vim/autoload/argument.vim
+++ /dev/null
@@ -1,8 +0,0 @@
-" Escape a single argument for use on an Ex command line; essentially
-" a backport of fnameescape() for versions before v7.1.299
-"
-function! argument#Escape(argument) abort
- return exists('*fnameescape')
- \ ? fnameescape(a:argument)
- \ : escape(a:argument, "\n\r\t".' *?[{`$\%#''"|!<')
-endfunction
diff --git a/vim/autoload/diff.vim b/vim/autoload/diff.vim
index 29389b95..6e87b62a 100644
--- a/vim/autoload/diff.vim
+++ b/vim/autoload/diff.vim
@@ -1,7 +1,7 @@
" Move between diff block headers
function! diff#MoveBlock(count, up, visual) abort
- " Reselect visual selection
+ " Re-select visual selection
if a:visual
normal! gv
endif
diff --git a/vim/autoload/filetype/repeat.vim b/vim/autoload/filetype/repeat.vim
index f681932b..899bbcc4 100644
--- a/vim/autoload/filetype/repeat.vim
+++ b/vim/autoload/filetype/repeat.vim
@@ -53,7 +53,7 @@ function! filetype#repeat#Sudo() abort
elseif fn =~# '/[^/]\+\.\w\{8}$'
let fn = expand('<afile>:r')
- " Unrecognised pattern; return, don't repeat
+ " Unrecognized pattern; return, don't repeat
else
return
endif
diff --git a/vim/autoload/fortune.vim b/vim/autoload/fortune.vim
deleted file mode 100644
index da6e2fa3..00000000
--- a/vim/autoload/fortune.vim
+++ /dev/null
@@ -1,59 +0,0 @@
-" Declare paths to check for fortune files
-let s:paths = [
- \ $HOME.'/.fortunes',
- \ $HOME.'/.local/share/games/fortunes',
- \]
-
-" List of executables for which we need to check
-let s:executables = [
- \ 'fortune',
- \ 'timeout',
- \]
-
-" Entry point for plugin
-function! fortune#() abort
-
- " Check we have all of the executables we need
- for executable in s:executables
- if !executable(executable)
- echoerr 'Missing executable "'.executable.'"'
- endif
- endfor
-
- " Maximum length of fortunes is the width of the screen minus 1; characters
- " wider than one column will break this
- "
- let limit = &columns - 1
-
- " Some implementations of fortune(6) thrash the disk if they can't meet the
- " length limit, so we need to rap this invocation in a timeout(1) call
- let command = [
- \ 'timeout',
- \ '0.3s',
- \ 'fortune',
- \ '-s',
- \ '-n',
- \ limit,
- \]
-
- " Find a path for custom fortunes and add it on to the command if found
- for path in s:paths
- if isdirectory(path)
- call add(command, path)
- break
- endif
- endfor
-
- " Run the command and condense any control or space character groups into
- " just one space
- let fortune = substitute(
- \ system(join(command)),
- \ '[[:cntrl:][:space:]]\+',
- \ ' ',
- \ 'g',
- \)
-
- " Show the fortune message!
- echomsg fortune
-
-endfunction
diff --git a/vim/autoload/has.vim b/vim/autoload/has.vim
deleted file mode 100644
index 162e4929..00000000
--- a/vim/autoload/has.vim
+++ /dev/null
@@ -1,34 +0,0 @@
-" Wrapper to backport the nicer has() syntax for simultaneous version and
-" patch level checking that was introduced in v7.4.236 and fixed in v7.4.237.
-"
-" * <https://github.com/vim/vim/releases/tag/v7.4.236>
-" * <https://github.com/vim/vim/releases/tag/v7.4.237>
-"
-function! has#(feature) abort
-
- " If we're new enough, we can just run the native has()
- if has('patch-7.4.237')
- return has(a:feature)
- endif
-
- " Otherwise, we have to break down the pattern and do manual version and
- " patch level checks; if it doesn't match the patch syntax, just return what
- " the native has() does
- "
- let feature = a:feature
- let pattern = '^patch-\(\d\+\)\.\(\d\+\)\.\(\d\+\)$'
- let matchlist = matchlist(feature, pattern)
- if empty(matchlist)
- return has(a:feature)
- endif
- let [major, minor, patch] = matchlist[1:3]
-
- " The v:version variable looks like e.g. 801 for v8.1
- let l:version = major * 100 + minor
-
- " Compare the version numbers, and then the patch level if they're the same
- return v:version != l:version
- \ ? v:version > l:version
- \ : has('patch-'.patch)
-
-endfunction
diff --git a/vim/autoload/html/timestamp.vim b/vim/autoload/html/timestamp.vim
index 9de19aa0..8f250710 100644
--- a/vim/autoload/html/timestamp.vim
+++ b/vim/autoload/html/timestamp.vim
@@ -34,7 +34,7 @@ function! s:Timestamp(time) abort
endfunction
" Define timestamp prefix string
-let s:prefix = '<strong>Last updated:</strong> '
+let s:prefix = 'Last updated: '
" Define pattern to match date timestamps; no ZALGO, please
let s:pattern = '\m\C'
@@ -69,6 +69,6 @@ function! html#timestamp#Update() abort
" Apply the updated timestamp
let line = getline(lnum)
let line = substitute(line, s:pattern, update, '')
- call setline(lnum, line)
+ keepjumps call setline(lnum, line)
endfunction
diff --git a/vim/autoload/indent.vim b/vim/autoload/indent.vim
index d597653f..19a9f03d 100644
--- a/vim/autoload/indent.vim
+++ b/vim/autoload/indent.vim
@@ -10,7 +10,7 @@ function! indent#Spaces(...) abort
" If we have the patch that supports it, set 'softtabstop' to dynamically
" mirror the value of 'shiftwidth'; failing that, just copy it
- let &l:softtabstop = has#('patch-7.3.693')
+ let &l:softtabstop = patch#('7.3.693')
\ ? -1
\ : &l:shiftwidth
@@ -19,27 +19,17 @@ endfunction
" Set the current buffer to tab indent
function! indent#Tabs() abort
- setlocal noexpandtab
- setlocal shiftwidth< softtabstop<
+ setlocal noexpandtab shiftwidth< softtabstop<
call indent#Undo()
endfunction
" Add commands to b:undo_indent to clean up buffer-local indentation changes
" on a change of filetype
function! indent#Undo() abort
-
- " Check and set a flag so that we only do this once per buffer
- if exists('b:undo_indent_type_set')
- return
- endif
- let b:undo_indent_type_set = 1
-
- " Either set or append relevant commands to b:undo_indent
- let l:undo = 'setlocal expandtab< shiftwidth< softtabstop< tabstop<'
+ let undo = 'setlocal expandtab< shiftwidth< softtabstop<'
if exists('b:undo_indent')
- let b:undo_indent .= '|'.l:undo
+ let b:undo_indent .= '|'.undo
else
- let b:undo_indent = l:undo
+ let b:undo_indent = undo
endif
-
endfunction
diff --git a/vim/autoload/mail.vim b/vim/autoload/mail.vim
index cd585af4..6d4874ca 100644
--- a/vim/autoload/mail.vim
+++ b/vim/autoload/mail.vim
@@ -1,7 +1,7 @@
" Move through quoted paragraphs like normal-mode `{` and `}`
function! mail#NewBlank(count, up, visual) abort
- " Reselect visual selection
+ " Re-select visual selection
if a:visual
normal! gv
endif
@@ -61,7 +61,7 @@ function! mail#StrictQuote(start, end) abort
continue
endif
- " Normalise the quote with no spaces
+ " Normalize the quote with no spaces
let quote = substitute(quote, '[^>]', '', 'g')
" Re-set the line
diff --git a/vim/autoload/mail/header/field.vim b/vim/autoload/mail/header/field.vim
index e27d13c0..db38c09f 100644
--- a/vim/autoload/mail/header/field.vim
+++ b/vim/autoload/mail/header/field.vim
@@ -9,7 +9,7 @@ function! mail#header#field#Add(header, name, body) abort
endfunction
" Set a field in a header, replacing the first one with the same name (if
-" any), and and removing any others
+" any), and removing any others
"
function! mail#header#field#Set(header, name, body) abort
let fields = []
diff --git a/vim/autoload/option.vim b/vim/autoload/option.vim
index 5ff44ced..49fbf1a4 100644
--- a/vim/autoload/option.vim
+++ b/vim/autoload/option.vim
@@ -7,5 +7,11 @@ function! option#Split(expr, ...) abort
endif
let keepempty = a:0 ? a:1 : 0
let parts = split(a:expr, '\\\@<!,[, ]*', keepempty)
- return map(parts, 'substitute(v:val, ''\\,'', '','', ''g'')')
+ return map(copy(parts), 'substitute(v:val, ''\\,'', '','', ''g'')')
+endfunction
+
+" Escape the right-hand side of a :set option value
+"
+function! option#Escape(expr) abort
+ return escape(a:expr, ' |"\')
endfunction
diff --git a/vim/autoload/patch.vim b/vim/autoload/patch.vim
new file mode 100644
index 00000000..3a17ccda
--- /dev/null
+++ b/vim/autoload/patch.vim
@@ -0,0 +1,35 @@
+" Wrapper to emulate the nicer has() syntax for simultaneous version and patch
+" level checking that was introduced in v7.4.236 and fixed in v7.4.237.
+"
+" * <https://github.com/vim/vim/releases/tag/v7.4.236>
+" * <https://github.com/vim/vim/releases/tag/v7.4.237>
+"
+function! patch#(version) abort
+
+ " If the Vim running is new enough for its has() function to support
+ " checking patch levels with version prefixes, we can just add a "patch-"
+ " prefix to the query, and pass it on to has().
+ "
+ if has('patch-7.4.237')
+ return has('patch-'.a:version)
+ endif
+
+ " Failing that, we need to do our own version number and patch number
+ " comparisons; split the queried version on dots.
+ "
+ let [major, minor, patch] = split(a:version, '\.')
+
+ " The internal variable v:version describing the running Vim looks like
+ " e.g. 801 for v8.1; reproduce that logic for the queried version.
+ "
+ let l:version = major * 100 + minor
+
+ " If the running version number is the same as the required one, return
+ " whether we have the specific patch requested; otherwise, return whether
+ " the running version number is greater than the required one.
+ "
+ return v:version == l:version
+ \ ? has('patch-'.patch)
+ \ : v:version > l:version
+
+endfunction
diff --git a/vim/autoload/path.vim b/vim/autoload/path.vim
deleted file mode 100644
index e230cab2..00000000
--- a/vim/autoload/path.vim
+++ /dev/null
@@ -1,14 +0,0 @@
-" Create all the directories needed for a path, with optional flag for
-" owner-only permissions
-function! path#Create(name, ...) abort
- if a:0 > 2
- echoerr 'Too many arguments'
- endif
- if isdirectory(a:name)
- return 1
- endif
- let name = a:name
- let path = 'p'
- let prot = a:0 == 1 && a:1 ? 0700 : 0755
- return mkdir(name, path, prot)
-endfunction
diff --git a/vim/autoload/plugin.vim b/vim/autoload/plugin.vim
deleted file mode 100644
index 629a4367..00000000
--- a/vim/autoload/plugin.vim
+++ /dev/null
@@ -1,7 +0,0 @@
-" Check whether plugins are enabled and a specific named plugin (excluding
-" extension .vim) is available somewhere within 'runtimepath'
-"
-function! plugin#Ready(name) abort
- return &loadplugins
- \ && globpath(&runtimepath, 'plugin/'.a:name.'.vim') !=# ''
-endfunction
diff --git a/vim/autoload/put_date.vim b/vim/autoload/put_date.vim
deleted file mode 100644
index b0b0b548..00000000
--- a/vim/autoload/put_date.vim
+++ /dev/null
@@ -1,24 +0,0 @@
-" RFC2822 format string for strftime()
-let s:rfc_2822 = '%a, %d %b %Y %T %z'
-
-" Write a date to the buffer, UTC or local, in the specified format,
-" defaulting to RFC2822; formats are provided without the leading % signs
-" before each letter, like PHP date()
-"
-function! put_date#(line, utc, format) abort
- let line = a:line
- let utc = a:utc
- let format = strlen(a:format)
- \ ? substitute(a:format, '\a', '%&', 'g')
- \ : s:rfc_2822
- if utc
- if exists('$TZ')
- let tz = $TZ
- endif
- let $TZ = 'UTC'
- endif
- execute line.'put =strftime(format)'
- if exists('tz')
- let $TZ = tz
- endif
-endfunction
diff --git a/vim/autoload/quote.vim b/vim/autoload/quote.vim
index 690ba2db..7574ed71 100644
--- a/vim/autoload/quote.vim
+++ b/vim/autoload/quote.vim
@@ -24,8 +24,8 @@ function! quote#QuoteOpfunc(type) abort
continue
endif
- " If configured to do so, add a a space after the quote character, but
- " only if this line isn't already quoted
+ " If configured to do so, add a space after the quote character, but only
+ " if this line isn't already quoted
let new = char
if space && cur[0] != char
let new .= ' '
diff --git a/vim/autoload/xdg.vim b/vim/autoload/xdg.vim
new file mode 100644
index 00000000..cb7adcf5
--- /dev/null
+++ b/vim/autoload/xdg.vim
@@ -0,0 +1,67 @@
+" <https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables>
+let s:defaults = {
+ \ 'XDG_CACHE_HOME': $HOME.'/.cache',
+ \ 'XDG_CONFIG_HOME': $HOME.'/.config',
+ \ 'XDG_CONFIG_DIRS': '/etc/xdg',
+ \ 'XDG_DATA_HOME': $HOME.'/.local/share',
+ \ 'XDG_DATA_DIRS': '/usr/local/share:/usr/share',
+ \ 'XDG_STATE_HOME': $HOME.'/.local/state',
+ \}
+
+function! s:Get(name) abort
+ let name = a:name
+ if !has_key(s:defaults, name)
+ throw 'Illegal XDG basedirs env var name'
+ endif
+ let value = s:defaults[name]
+ if exists('$'.a:name)
+ execute 'let value = $'.a:name
+ endif
+ return value
+endfunction
+
+function! s:Absolute(path) abort
+ return a:path =~# '^/'
+ \ || a:path =~# '^\~/'
+ \ || a:path ==# '~'
+endfunction
+
+function! s:Home(name) abort
+ let home = s:Get(a:name)
+ if !s:Absolute(home)
+ return ''
+ endif
+ return home.'/vim'
+endfunction
+
+function! s:Dirs(name) abort
+ let dirs = split(s:Get(a:name), ':')
+ return map(
+ \ filter(copy(dirs), 's:Absolute(v:val)')
+ \,'v:val.''/vim'''
+ \)
+endfunction
+
+function! xdg#CacheHome() abort
+ return has('unix') ? s:Home('XDG_CACHE_HOME') : ''
+endfunction
+
+function! xdg#ConfigHome() abort
+ return has('unix') ? s:Home('XDG_CONFIG_HOME') : ''
+endfunction
+
+function! xdg#DataHome() abort
+ return has('unix') ? s:Home('XDG_DATA_HOME') : ''
+endfunction
+
+function! xdg#StateHome() abort
+ return has('unix') ? s:Home('XDG_STATE_HOME') : ''
+endfunction
+
+function! xdg#ConfigDirs() abort
+ return has('unix') ? s:Dirs('XDG_CONFIG_DIRS') : []
+endfunction
+
+function! xdg#DataDirs() abort
+ return has('unix') ? s:Dirs('XDG_DATA_DIRS') : []
+endfunction